{
final LayoutContext layoutContext = element.getLayoutContext();
final ContentSpecification contentSpecification =
layoutContext.getContentSpecification();
final CSSValue value = layoutContext.getValue(key);
if (value instanceof CSSConstant)
{
if (ContentValues.NONE.equals(value))
{
contentSpecification.setAllowContentProcessing(false);
contentSpecification.setInhibitContent(false);
contentSpecification.setContents(PSEUDO_CONTENT);
return;
}
else if (ContentValues.INHIBIT.equals(value))
{
contentSpecification.setAllowContentProcessing(false);
contentSpecification.setInhibitContent(true);
contentSpecification.setContents(PSEUDO_CONTENT);
return;
}
else if (ContentValues.NORMAL.equals(value))
{
if (layoutContext.isPseudoElement())
{
if (isListMarker(element))
{
processListItem(process, element, contentSpecification);
return;
}
else
{
// a pseudo-element does not have content by default.
contentSpecification.setAllowContentProcessing(false);
contentSpecification.setInhibitContent(true);
contentSpecification.setContents(PSEUDO_CONTENT);
return;
}
}
}
}
contentSpecification.setInhibitContent(false);
contentSpecification.setAllowContentProcessing(true);
contentSpecification.setContents(DEFAULT_CONTENT);
if (value instanceof CSSAttrFunction)
{
final ContentToken token =
evaluateFunction((CSSFunctionValue) value, process, element);
if (token == null)
{
return;
}
contentSpecification.setContents(new ContentToken[]{token});
}
if (value instanceof CSSValueList == false)
{
return; // cant handle that one
}
final ArrayList tokens = new ArrayList();
final CSSValueList list = (CSSValueList) value;
final int size = list.getLength();
for (int i = 0; i < size; i++)
{
final CSSValueList sequence = (CSSValueList) list.getItem(i);
for (int j = 0; j < sequence.getLength(); j++)
{
final CSSValue content = sequence.getItem(j);
final ContentToken token = createToken(process, element, content);
if (token == null)
{
// ok, a failure. Skip to the next content spec ...
tokens.clear();
break;
}
tokens.add(token);
}
if (tokens.isEmpty() == false)
{
final ContentToken[] contents = (ContentToken[]) tokens.toArray
(new ContentToken[tokens.size()]);
contentSpecification.setContents(contents);
return;
}