CSSPrimitiveValue::CSSPrimitiveValue(const Length& length, const RenderStyle* style) : CSSValue(PrimitiveClass) { switch (length.type()) { case Auto: case Intrinsic: case MinIntrinsic: case MinContent: case MaxContent: case FillAvailable: case FitContent: case Percent: init(length); return; case Fixed: m_primitiveUnitType = CSS_PX; m_value.num = adjustFloatForAbsoluteZoom(length.value(), style); return; case Calculated: { RefPtr<CSSCalcValue> calcValue = CSSCalcValue::create(length.calculationValue(), *style); init(calcValue.release()); return; } case Relative: case Undefined: ASSERT_NOT_REACHED(); return; } ASSERT_NOT_REACHED(); }
static PassRefPtr<AnimatableValue> createFromLength(const Length& length, const RenderStyle& style) { switch (length.type()) { case Fixed: return AnimatableLength::create(adjustFloatForAbsoluteZoom(length.value(), style), AnimatableLength::UnitTypePixels); case Percent: return AnimatableLength::create(length.value(), AnimatableLength::UnitTypePercentage); case ViewportPercentageWidth: return AnimatableLength::create(length.value(), AnimatableLength::UnitTypeViewportWidth); case ViewportPercentageHeight: return AnimatableLength::create(length.value(), AnimatableLength::UnitTypeViewportHeight); case ViewportPercentageMin: return AnimatableLength::create(length.value(), AnimatableLength::UnitTypeViewportMin); case ViewportPercentageMax: return AnimatableLength::create(length.value(), AnimatableLength::UnitTypeViewportMax); case Calculated: return AnimatableLength::create(CSSCalcValue::createExpressionNode(length.calculationValue()->expression(), style.effectiveZoom())); case Auto: case Intrinsic: case MinIntrinsic: case MinContent: case MaxContent: case FillAvailable: case FitContent: return AnimatableUnknown::create(CSSPrimitiveValue::create(length)); case Undefined: return AnimatableUnknown::create(CSSValueNone); case ExtendToZoom: // Does not apply to elements. case Relative: // Does not get used by interpolable properties. ASSERT_NOT_REACHED(); return 0; } ASSERT_NOT_REACHED(); return 0; }
static PassRefPtr<AnimatableValue> createFromLineHeight(const Length& length, const RenderStyle& style) { double value = length.value(); switch (length.type()) { case Fixed: return AnimatableLength::create(adjustFloatForAbsoluteZoom(value, style), AnimatableLength::UnitTypePixels); case Percent: // -100% is used to represent "normal" line height. if (value == -100) return AnimatableUnknown::create(CSSValueNormal); return AnimatableDouble::create(value); default: ASSERT_NOT_REACHED(); return 0; } }
static PassRefPtr<AnimatableValue> createFromLength(const Length& length, const RenderStyle* style) { switch (length.type()) { case Relative: return AnimatableNumber::create(length.value(), AnimatableNumber::UnitTypeNumber); case Fixed: return AnimatableNumber::create(adjustFloatForAbsoluteZoom(length.value(), style), AnimatableNumber::UnitTypeLength); case Percent: return AnimatableNumber::create(length.value(), AnimatableNumber::UnitTypePercentage); case ViewportPercentageWidth: return AnimatableNumber::create(length.value(), AnimatableNumber::UnitTypeViewportWidth); case ViewportPercentageHeight: return AnimatableNumber::create(length.value(), AnimatableNumber::UnitTypeViewportHeight); case ViewportPercentageMin: return AnimatableNumber::create(length.value(), AnimatableNumber::UnitTypeViewportMin); case ViewportPercentageMax: return AnimatableNumber::create(length.value(), AnimatableNumber::UnitTypeViewportMax); case Calculated: // FIXME: Convert platform calcs to CSS calcs. ASSERT_WITH_MESSAGE(false, "Web Animations not yet implemented: Convert platform CalculationValue to AnimatableValue"); return 0; case Auto: case Intrinsic: case MinIntrinsic: case MinContent: case MaxContent: case FillAvailable: case FitContent: return AnimatableUnknown::create(CSSPrimitiveValue::create(length)); case Undefined: return AnimatableUnknown::create(CSSPrimitiveValue::create(CSSValueNone)); case ExtendToZoom: // Does not apply to elements. ASSERT_NOT_REACHED(); return 0; } ASSERT_NOT_REACHED(); return 0; }
inline static PassRefPtrWillBeRawPtr<CSSPrimitiveValue> zoomAdjustedPixelValue(double value, const ComputedStyle& style) { return cssValuePool().createValue(adjustFloatForAbsoluteZoom(value, style), CSSPrimitiveValue::UnitType::Pixels); }