void CSSToStyleMap::mapFillYPosition(CSSPropertyID propertyID, FillLayer* layer, CSSValue* value) { if (value->isInitialValue()) { layer->setYPosition(FillLayer::initialFillYPosition(layer->type())); return; } if (!value->isPrimitiveValue()) return; float zoomFactor = style()->effectiveZoom(); CSSPrimitiveValue* primitiveValue = static_cast<CSSPrimitiveValue*>(value); Pair* pair = primitiveValue->getPairValue(); if (pair) { ASSERT_UNUSED(propertyID, propertyID == CSSPropertyBackgroundPositionY || propertyID == CSSPropertyWebkitMaskPositionY); primitiveValue = pair->second(); } Length length; if (primitiveValue->isLength()) length = primitiveValue->computeLength<Length>(style(), rootElementStyle(), zoomFactor); else if (primitiveValue->isPercentage()) length = Length(primitiveValue->getDoubleValue(), Percent); else if (primitiveValue->isCalculatedPercentageWithLength()) length = Length(primitiveValue->cssCalcValue()->toCalcValue(style(), rootElementStyle(), zoomFactor)); else if (primitiveValue->isViewportPercentageLength()) length = primitiveValue->viewportPercentageLength(); else return; layer->setYPosition(length); if (pair) layer->setBackgroundYOrigin(*(pair->first())); }
void CSSToStyleMap::mapFillYPosition(CSSPropertyID, FillLayer* layer, CSSValue* value) { if (value->isInitialValue()) { layer->setYPosition(FillLayer::initialFillYPosition(layer->type())); return; } if (!value->isPrimitiveValue()) return; float zoomFactor = style()->effectiveZoom(); CSSPrimitiveValue* primitiveValue = static_cast<CSSPrimitiveValue*>(value); Length length; if (primitiveValue->isLength()) length = primitiveValue->computeLength<Length>(style(), rootElementStyle(), zoomFactor); else if (primitiveValue->isPercentage()) length = Length(primitiveValue->getDoubleValue(), Percent); else if (primitiveValue->isCalculatedPercentageWithLength()) length = Length(primitiveValue->cssCalcValue()->toCalcValue(style(), rootElementStyle(), zoomFactor)); else if (primitiveValue->isViewportPercentageLength()) length = primitiveValue->viewportPercentageLength(); else return; layer->setYPosition(length); }
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; } CSSValueID id = primitiveValue.getValueID(); bool isColor = ((id >= CSSValueAqua && id <= CSSValueTransparent) || (id >= CSSValueAliceblue && id <= CSSValueYellowgreen) || id == CSSValueGrey); return (id != CSSValueNone) && !isColor; }
Length ViewportStyleResolver::viewportLengthValue(CSSPropertyID id) const { ASSERT(id == CSSPropertyMaxHeight || id == CSSPropertyMinHeight || id == CSSPropertyMaxWidth || id == CSSPropertyMinWidth); RefPtr<CSSValue> value = m_propertySet->getPropertyCSSValue(id); if (!value || !value->isPrimitiveValue()) return Length(); // auto CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(value.get()); if (primitiveValue->isLength()) return primitiveValue->computeLength<Length>(m_document->renderStyle(), m_document->renderStyle()); if (primitiveValue->isViewportPercentageLength()) return primitiveValue->viewportPercentageLength(); if (primitiveValue->isPercentage()) return Length(primitiveValue->getFloatValue(), Percent); switch (primitiveValue->getValueID()) { case CSSValueInternalExtendToZoom: return Length(ExtendToZoom); case CSSValueAuto: return Length(); default: // Unrecognized keyword. ASSERT_NOT_REACHED(); return Length(0, Fixed); } }
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()); return (primitiveValue.getValueID() != CSSValueNone); }
// FIXME: Have to pass RenderStyles here for calc/computed values. This shouldn't be neecessary. void FontBuilder::setFontSizeValue(CSSValue* value, RenderStyle* parentStyle, const RenderStyle* rootElementStyle, float effectiveZoom) { if (!value->isPrimitiveValue()) return; CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(value); FontDescriptionChangeScope scope(this); scope.fontDescription().setKeywordSize(0); float parentSize = 0; bool parentIsAbsoluteSize = false; float size = 0; // FIXME: Find out when parentStyle could be 0? if (parentStyle) { parentSize = parentStyle->fontDescription().specifiedSize(); parentIsAbsoluteSize = parentStyle->fontDescription().isAbsoluteSize(); } if (CSSValueID valueID = primitiveValue->getValueID()) { switch (valueID) { case CSSValueXxSmall: case CSSValueXSmall: case CSSValueSmall: case CSSValueMedium: case CSSValueLarge: case CSSValueXLarge: case CSSValueXxLarge: case CSSValueWebkitXxxLarge: size = FontSize::fontSizeForKeyword(m_document, valueID, scope.fontDescription().useFixedDefaultSize()); scope.fontDescription().setKeywordSize(valueID - CSSValueXxSmall + 1); break; case CSSValueLarger: size = largerFontSize(parentSize); break; case CSSValueSmaller: size = smallerFontSize(parentSize); break; default: return; } scope.fontDescription().setIsAbsoluteSize(parentIsAbsoluteSize && (valueID == CSSValueLarger || valueID == CSSValueSmaller)); } else { scope.fontDescription().setIsAbsoluteSize(parentIsAbsoluteSize || !(primitiveValue->isPercentage() || primitiveValue->isFontRelativeLength())); if (primitiveValue->isLength()) size = primitiveValue->computeLength<float>(parentStyle, rootElementStyle, 1.0, true); else if (primitiveValue->isPercentage()) size = (primitiveValue->getFloatValue() * parentSize) / 100.0f; else if (primitiveValue->isCalculatedPercentageWithLength()) size = primitiveValue->cssCalcValue()->toCalcValue(parentStyle, rootElementStyle)->evaluate(parentSize); else if (primitiveValue->isViewportPercentageLength()) size = valueForLength(primitiveValue->viewportPercentageLength(), 0, m_document->renderView()); else return; } if (size < 0) return; // Overly large font sizes will cause crashes on some platforms (such as Windows). // Cap font size here to make sure that doesn't happen. size = std::min(maximumAllowedFontSize, size); setSize(scope.fontDescription(), effectiveZoom, size); }