public void resolve (final LayoutProcess process,
final LayoutElement element,
final StyleKey key)
{
final LayoutContext layoutContext = element.getLayoutContext();
final CSSValue displayRole = layoutContext.getValue(BoxStyleKeys.DISPLAY_ROLE);
if (DisplayRole.NONE.equals(displayRole))
{
// [GENERATED] 8.3. Counters in elements with 'display: none'
//
// An element that is not displayed ('display' set to 'none') cannot
// increment or reset a counter.
return;
}
final CSSValue value = layoutContext.getValue(key);
if (value instanceof CSSValueList == false)
{
return; // do nothing.
}
final CSSValueList valueList = (CSSValueList) value;
for (int i = 0; i < valueList.getLength(); i++)
{
final CSSValue item = valueList.getItem(i);
if (item instanceof CSSValuePair == false)
{
continue;
}
final CSSValuePair counter = (CSSValuePair) item;
final CSSValue counterName = counter.getFirstValue();
if (counterName instanceof CSSConstant == false)
{
continue;
}
final CSSValue counterValue = counter.getSecondValue();
final int counterIntValue = parseCounterValue(counterValue, element);
element.resetCounter(counterName.getCSSText(), counterIntValue);
}
}