double CSSPrimitiveValue::getFloatValue(unsigned short unitType) { if (unitType == m_type || unitType < CSS_PX || unitType > CSS_PC) return m_value.num; double convertedValue = m_value.num; // First convert the value from m_type into CSSPixels double factor = scaleFactorForConversion(m_type); convertedValue *= factor; // Now convert from CSSPixels to the specified unitType factor = scaleFactorForConversion(unitType); convertedValue /= factor; return convertedValue; }
double CSSPrimitiveValue::getDoubleValue(unsigned short unitType, ExceptionCode& ec) { ec = 0; if (m_type < CSS_NUMBER || m_type > CSS_DIMENSION || unitType < CSS_NUMBER || unitType > CSS_DIMENSION) { ec = INVALID_ACCESS_ERR; return 0.0; } if (unitType == m_type || unitType < CSS_PX || unitType > CSS_PC) return m_value.num; double convertedValue = m_value.num; // First convert the value from m_type into CSSPixels double factor = scaleFactorForConversion(m_type); convertedValue *= factor; // Now convert from CSSPixels to the specified unitType factor = scaleFactorForConversion(unitType); convertedValue /= factor; return convertedValue; }