public CssAbsPrimitiveLengthValue(CssPrimitiveValue cssValue, string propertyName, XmlElement element)
{
if(cssValue.PrimitiveType == CssPrimitiveType.Ident)
{
// this is primarily to deal with font sizes.
float absSize;
switch(cssValue.GetStringValue())
{
case "xx-small":
absSize = 6F;
break;
case "x-small":
absSize = 7.5F;
break;
case "small":
absSize = 8.88F;
break;
case "large":
absSize = 12F;
break;
case "x-large":
absSize = 15F;
break;
case "xx-large":
absSize = 20F;
break;
case "larger":
case "smaller":
float parSize;
if(_parentElement != null)
{
CssStyleDeclaration csd = (CssStyleDeclaration)_ownerDocument.GetComputedStyle(_parentElement, String.Empty);
CssPrimitiveValue cssPrimValue = csd.GetPropertyCssValue("font-size") as CssPrimitiveValue;
// no default font-size set => use 10px
if(cssPrimValue == null)
{
parSize = 10;
}
else
{
parSize = (float)cssPrimValue.GetFloatValue(CssPrimitiveType.Px);
}
}
else
{
parSize = 10;
}
if(cssValue.GetStringValue() == "smaller") absSize = parSize / 1.2F;
else absSize = parSize * 1.2F;
break;
default:
absSize = 10F;
break;
}
_setFloatValue(absSize);
_setType(CssPrimitiveType.Px);
}
else
{
_setFloatValue(cssValue.GetFloatValue(cssValue.PrimitiveType));
_setType(cssValue.PrimitiveType);
}
_propertyName = propertyName;
_element = element;
}