case CSSPrimitiveValue.CSS_NUMBER:
case CSSPrimitiveValue.CSS_PX:
return value;
case CSSPrimitiveValue.CSS_MM:
CSSContext ctx = engine.getCSSContext();
float v = value.getFloatValue();
return new FloatValue(CSSPrimitiveValue.CSS_NUMBER,
v / ctx.getPixelUnitToMillimeter());
case CSSPrimitiveValue.CSS_CM:
ctx = engine.getCSSContext();
v = value.getFloatValue();
return new FloatValue(CSSPrimitiveValue.CSS_NUMBER,
v * 10f / ctx.getPixelUnitToMillimeter());
case CSSPrimitiveValue.CSS_IN:
ctx = engine.getCSSContext();
v = value.getFloatValue();
return new FloatValue(CSSPrimitiveValue.CSS_NUMBER,
v * 25.4f / ctx.getPixelUnitToMillimeter());
case CSSPrimitiveValue.CSS_PT:
ctx = engine.getCSSContext();
v = value.getFloatValue();
return new FloatValue(CSSPrimitiveValue.CSS_NUMBER,
v * 25.4f /
(72f * ctx.getPixelUnitToMillimeter()));
case CSSPrimitiveValue.CSS_PC:
ctx = engine.getCSSContext();
v = value.getFloatValue();
return new FloatValue(CSSPrimitiveValue.CSS_NUMBER,
(v * 25.4f /
(6f * ctx.getPixelUnitToMillimeter())));
case CSSPrimitiveValue.CSS_EMS:
sm.putFontSizeRelative(idx, true);
v = value.getFloatValue();
int fsidx = engine.getFontSizeIndex();
float fs;
fs = engine.getComputedStyle(elt, pseudo, fsidx).getFloatValue();
return new FloatValue(CSSPrimitiveValue.CSS_NUMBER, v * fs);
case CSSPrimitiveValue.CSS_EXS:
sm.putFontSizeRelative(idx, true);
v = value.getFloatValue();
fsidx = engine.getFontSizeIndex();
fs = engine.getComputedStyle(elt, pseudo, fsidx).getFloatValue();
return new FloatValue(CSSPrimitiveValue.CSS_NUMBER, v * fs * 0.5f);
case CSSPrimitiveValue.CSS_PERCENTAGE:
ctx = engine.getCSSContext();
switch (getOrientation()) {
case HORIZONTAL_ORIENTATION:
sm.putBlockWidthRelative(idx, true);
fs = value.getFloatValue() * ctx.getBlockWidth(elt) / 100f;
break;
case VERTICAL_ORIENTATION:
sm.putBlockHeightRelative(idx, true);
fs = value.getFloatValue() * ctx.getBlockHeight(elt) / 100f;
break;
default: // Both
sm.putBlockWidthRelative(idx, true);
sm.putBlockHeightRelative(idx, true);
double w = ctx.getBlockWidth(elt);
double h = ctx.getBlockHeight(elt);
fs = (float)(value.getFloatValue() *
(Math.sqrt(w * w + h * h) / Math.sqrt(2)) / 100.0);
}
return new FloatValue(CSSPrimitiveValue.CSS_NUMBER, fs);
}