if (rawValue instanceof CSSNumericValue == false)
{
return CSSNumericValue.ZERO_LENGTH;
}
final CSSNumericValue value = (CSSNumericValue) rawValue;
if (CSSNumericType.PERCENTAGE.equals(value.getType()))
{
return CSSNumericValue.createValue(basePercentage.getNumericType(), value.getValue() * basePercentage.getValue() / 100d);
}
if (baseElement != null)
{
final CSSValue baseVal = baseElement.getLayoutStyle().getValue(FontStyleKeys.FONT_SIZE);
if (baseVal instanceof CSSNumericValue == false)
{
return CSSNumericValue.ZERO_LENGTH;
}
final CSSNumericValue baseNValue = (CSSNumericValue) baseVal;
if (CSSNumericType.EM.equals(value.getType()))
{
// base is the font-size
return CSSNumericValue.createValue(baseNValue.getNumericType(), value.getValue() * baseNValue.getValue());
}
if (CSSNumericType.EX.equals(value.getType()))
{
// base is the parent font's x-height.
// todo: cheating for now: We assume a sensible default and do not ask the font system.
return CSSNumericValue.createValue(baseNValue.getNumericType(), value.getValue() * baseNValue.getValue() * 0.58);
}
return baseNValue;
}
return CSSNumericValue.ZERO_LENGTH;
}