public void resolve(final DocumentContext process,
final LayoutElement currentNode,
final StyleKey key)
{
final LayoutStyle layoutContext = currentNode.getLayoutStyle();
final CSSValue value = layoutContext.getValue(key);
if (value instanceof CSSConstant == false)
{
// fine, we're done here ...
return;
}
final LayoutOutputMetaData metaData = process.getOutputMetaData();
final int resolution = (int) metaData.getNumericFeatureValue(OutputProcessorFeature.DEVICE_RESOLUTION);
final CSSConstant constant = (CSSConstant) value;
final LayoutElement parent = currentNode.getParentLayoutElement();
if (parent != null)
{
final CSSValue parentFontSizeValue = parent.getLayoutStyle().getValue(FontStyleKeys.FONT_SIZE);
final double parentFontSize = StyleSheetUtility.convertLengthToDouble(parentFontSizeValue, resolution);
if (RelativeFontSize.LARGER.equals(value))
{
final double scaleFactor = getScaleLargerFactor(parentFontSize);
layoutContext.setValue(key, CSSNumericValue.createValue(CSSNumericType.PERCENTAGE, scaleFactor));
return;
}
if (RelativeFontSize.SMALLER.equals(value))
{
final double scaleFactor = getScaleSmallerFactor(parentFontSize);
layoutContext.setValue(key, CSSNumericValue.createValue(CSSNumericType.PERCENTAGE, scaleFactor));
return;
}
}
else
{
// we might not have a parent, but that won't stop us ..
if (RelativeFontSize.LARGER.equals(value))
{
layoutContext.setValue(key, CSSNumericValue.createValue(CSSNumericType.PERCENTAGE, 120));
return;
}
if (RelativeFontSize.SMALLER.equals(value))
{
layoutContext.setValue(key, CSSNumericValue.createValue(CSSNumericType.PERCENTAGE, 85));
return;
}
}
final CSSValue resolvedValue = lookupValue(constant);
if (resolvedValue != null)
{
layoutContext.setValue(key, resolvedValue);
}
}