double CSSPrimitiveValue::computeSeconds() { ASSERT(isTime() || (isCalculated() && cssCalcValue()->category() == CalcTime)); UnitType currentType = isCalculated() ? cssCalcValue()->expressionNode()->typeWithCalcResolved() : type(); if (currentType == UnitType::Seconds) return getDoubleValue(); if (currentType == UnitType::Milliseconds) return getDoubleValue() / 1000; ASSERT_NOT_REACHED(); return 0; }
float SVGLength::value(const SVGLengthContext& context) const { if (isCalculated()) return context.resolveValue(asCSSPrimitiveValue(), unitMode()); return context.convertValueToUserUnits(m_value->getFloatValue(), unitMode(), m_value->typeWithCalcResolved()); }
float Length::nonNanCalculatedValue(int maxValue) const { ASSERT(isCalculated()); float result = calculationValue().evaluate(maxValue); if (std::isnan(result)) return 0; return result; }
Length CSSPrimitiveValue::convertToLength(const CSSToLengthConversionData& conversionData) { if (isLength()) return computeLength<Length>(conversionData); if (isPercentage()) return Length(getDoubleValue(), Percent); ASSERT(isCalculated()); return Length(cssCalcValue()->toCalcValue(conversionData)); }
double CSSPrimitiveValue::computeDegrees() const { ASSERT(isAngle() || (isCalculated() && cssCalcValue()->category() == CalcAngle)); UnitType currentType = isCalculated() ? cssCalcValue()->expressionNode()->typeWithCalcResolved() : type(); switch (currentType) { case UnitType::Degrees: return getDoubleValue(); case UnitType::Radians: return rad2deg(getDoubleValue()); case UnitType::Gradians: return grad2deg(getDoubleValue()); case UnitType::Turns: return turn2deg(getDoubleValue()); default: ASSERT_NOT_REACHED(); return 0; } }
void Length::deref() const { ASSERT(isCalculated()); calculationValues().deref(m_calculationValueHandle); }
CalculationValue& Length::calculationValue() const { ASSERT(isCalculated()); return calculationValues().get(m_calculationValueHandle); }