bool DeferredLegacyStyleInterpolation::interpolationRequiresStyleResolve(const CSSPrimitiveValue& primitiveValue) { // FIXME: consider other types. if (primitiveValue.isNumber() || primitiveValue.isPercentage() || primitiveValue.isAngle() || primitiveValue.isRGBColor() || primitiveValue.isURI()) return false; if (primitiveValue.isLength()) return primitiveValue.isFontRelativeLength() || primitiveValue.isViewportPercentageLength(); if (primitiveValue.isCalculated()) { CSSLengthArray lengthArray(CSSPrimitiveValue::LengthUnitTypeCount); primitiveValue.accumulateLengthArray(lengthArray); return lengthArray[CSSPrimitiveValue::UnitTypeFontSize] != 0 || lengthArray[CSSPrimitiveValue::UnitTypeFontXSize] != 0 || lengthArray[CSSPrimitiveValue::UnitTypeRootFontSize] != 0 || lengthArray[CSSPrimitiveValue::UnitTypeZeroCharacterWidth] != 0 || lengthArray[CSSPrimitiveValue::UnitTypeViewportWidth] != 0 || lengthArray[CSSPrimitiveValue::UnitTypeViewportHeight] != 0 || lengthArray[CSSPrimitiveValue::UnitTypeViewportMin] != 0 || lengthArray[CSSPrimitiveValue::UnitTypeViewportMax] != 0; } if (Pair* pair = primitiveValue.getPairValue()) { return interpolationRequiresStyleResolve(*pair->first()) || interpolationRequiresStyleResolve(*pair->second()); } if (Rect* rect = primitiveValue.getRectValue()) { return interpolationRequiresStyleResolve(*rect->top()) || interpolationRequiresStyleResolve(*rect->right()) || interpolationRequiresStyleResolve(*rect->bottom()) || interpolationRequiresStyleResolve(*rect->left()); } if (Quad* quad = primitiveValue.getQuadValue()) { return interpolationRequiresStyleResolve(*quad->top()) || interpolationRequiresStyleResolve(*quad->right()) || interpolationRequiresStyleResolve(*quad->bottom()) || interpolationRequiresStyleResolve(*quad->left()); } if (primitiveValue.isShape()) return interpolationRequiresStyleResolve(*primitiveValue.getShapeValue()); CSSValueID id = primitiveValue.getValueID(); bool isColor = ((id >= CSSValueAqua && id <= CSSValueTransparent) || (id >= CSSValueAliceblue && id <= CSSValueYellowgreen) || id == CSSValueGrey); return (id != CSSValueNone) && !isColor; }
LengthBox CSSToStyleMap::mapNinePieceImageQuad(CSSValue* value) { if (!value || !value->isPrimitiveValue()) return LengthBox(); // Get our zoom value. float zoom = useSVGZoomRules() ? 1.0f : style()->effectiveZoom(); // Retrieve the primitive value. CSSPrimitiveValue* borderWidths = static_cast<CSSPrimitiveValue*>(value); // Set up a length box to represent our image slices. LengthBox box; // Defaults to 'auto' so we don't have to handle that explicitly below. Quad* slices = borderWidths->getQuadValue(); if (slices->top()->isNumber()) box.m_top = Length(slices->top()->getIntValue(), Relative); else if (slices->top()->isPercentage()) box.m_top = Length(slices->top()->getDoubleValue(CSSPrimitiveValue::CSS_PERCENTAGE), Percent); else if (slices->top()->getValueID() != CSSValueAuto) box.m_top = slices->top()->computeLength<Length>(style(), rootElementStyle(), zoom); if (slices->right()->isNumber()) box.m_right = Length(slices->right()->getIntValue(), Relative); else if (slices->right()->isPercentage()) box.m_right = Length(slices->right()->getDoubleValue(CSSPrimitiveValue::CSS_PERCENTAGE), Percent); else if (slices->right()->getValueID() != CSSValueAuto) box.m_right = slices->right()->computeLength<Length>(style(), rootElementStyle(), zoom); if (slices->bottom()->isNumber()) box.m_bottom = Length(slices->bottom()->getIntValue(), Relative); else if (slices->bottom()->isPercentage()) box.m_bottom = Length(slices->bottom()->getDoubleValue(CSSPrimitiveValue::CSS_PERCENTAGE), Percent); else if (slices->bottom()->getValueID() != CSSValueAuto) box.m_bottom = slices->bottom()->computeLength<Length>(style(), rootElementStyle(), zoom); if (slices->left()->isNumber()) box.m_left = Length(slices->left()->getIntValue(), Relative); else if (slices->left()->isPercentage()) box.m_left = Length(slices->left()->getDoubleValue(CSSPrimitiveValue::CSS_PERCENTAGE), Percent); else if (slices->left()->getValueID() != CSSValueAuto) box.m_left = slices->left()->computeLength<Length>(style(), rootElementStyle(), zoom); return box; }
LengthBox CSSToStyleMap::mapNinePieceImageQuad(CSSValue* value) { if (!value || !value->isPrimitiveValue()) return LengthBox(); // Get our zoom value. CSSToLengthConversionData conversionData = useSVGZoomRules() ? m_resolver->state().cssToLengthConversionData().copyWithAdjustedZoom(1.0f) : m_resolver->state().cssToLengthConversionData(); // Retrieve the primitive value. CSSPrimitiveValue* borderWidths = toCSSPrimitiveValue(value); // Set up a length box to represent our image slices. LengthBox box; // Defaults to 'auto' so we don't have to handle that explicitly below. Quad* slices = borderWidths->getQuadValue(); if (slices->top()->isNumber()) box.m_top = Length(slices->top()->getIntValue(), Relative); else if (slices->top()->isPercentage()) box.m_top = Length(slices->top()->getDoubleValue(CSSPrimitiveValue::CSS_PERCENTAGE), Percent); else if (slices->top()->getValueID() != CSSValueAuto) box.m_top = slices->top()->computeLength<Length>(conversionData); if (slices->right()->isNumber()) box.m_right = Length(slices->right()->getIntValue(), Relative); else if (slices->right()->isPercentage()) box.m_right = Length(slices->right()->getDoubleValue(CSSPrimitiveValue::CSS_PERCENTAGE), Percent); else if (slices->right()->getValueID() != CSSValueAuto) box.m_right = slices->right()->computeLength<Length>(conversionData); if (slices->bottom()->isNumber()) box.m_bottom = Length(slices->bottom()->getIntValue(), Relative); else if (slices->bottom()->isPercentage()) box.m_bottom = Length(slices->bottom()->getDoubleValue(CSSPrimitiveValue::CSS_PERCENTAGE), Percent); else if (slices->bottom()->getValueID() != CSSValueAuto) box.m_bottom = slices->bottom()->computeLength<Length>(conversionData); if (slices->left()->isNumber()) box.m_left = Length(slices->left()->getIntValue(), Relative); else if (slices->left()->isPercentage()) box.m_left = Length(slices->left()->getDoubleValue(CSSPrimitiveValue::CSS_PERCENTAGE), Percent); else if (slices->left()->getValueID() != CSSValueAuto) box.m_left = slices->left()->computeLength<Length>(conversionData); return box; }