/* * Copyright (C) 2011 Google Inc. All rights reserved. * Copyright (C) 2013 Apple Inc. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND ANY * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include "config.h" #include "DeprecatedStyleBuilder.h" #include "BasicShapeFunctions.h" #include "BasicShapes.h" #include "CSSAspectRatioValue.h" #include "CSSCalculationValue.h" #include "CSSCursorImageValue.h" #include "CSSPrimitiveValue.h" #include "CSSPrimitiveValueMappings.h" #include "CSSToStyleMap.h" #include "CSSValueList.h" #include "ClipPathOperation.h" #include "CursorList.h" #include "Document.h" #include "Element.h" #include "Pair.h" #include "Rect.h" #include "RenderObject.h" #include "RenderStyle.h" #include "RenderView.h" #include "Settings.h" #include "StyleResolver.h" #include #if ENABLE(CSS_SHAPES) #include "ShapeValue.h" #endif using namespace std; namespace WebCore { enum ExpandValueBehavior {SuppressValue = 0, ExpandValue}; template class ApplyPropertyExpanding { public: template static inline void applyInheritValue(CSSPropertyID propertyID, StyleResolver* styleResolver) { if (id == CSSPropertyInvalid) return; const DeprecatedStyleBuilder& table = DeprecatedStyleBuilder::sharedStyleBuilder(); const PropertyHandler& handler = table.propertyHandler(id); if (handler.isValid()) handler.applyInheritValue(propertyID, styleResolver); } static void applyInheritValue(CSSPropertyID propertyID, StyleResolver* styleResolver) { applyInheritValue(propertyID, styleResolver); applyInheritValue(propertyID, styleResolver); applyInheritValue(propertyID, styleResolver); applyInheritValue(propertyID, styleResolver); applyInheritValue(propertyID, styleResolver); } template static inline void applyInitialValue(CSSPropertyID propertyID, StyleResolver* styleResolver) { if (id == CSSPropertyInvalid) return; const DeprecatedStyleBuilder& table = DeprecatedStyleBuilder::sharedStyleBuilder(); const PropertyHandler& handler = table.propertyHandler(id); if (handler.isValid()) handler.applyInitialValue(propertyID, styleResolver); } static void applyInitialValue(CSSPropertyID propertyID, StyleResolver* styleResolver) { applyInitialValue(propertyID, styleResolver); applyInitialValue(propertyID, styleResolver); applyInitialValue(propertyID, styleResolver); applyInitialValue(propertyID, styleResolver); applyInitialValue(propertyID, styleResolver); } template static inline void applyValue(CSSPropertyID propertyID, StyleResolver* styleResolver, CSSValue* value) { if (id == CSSPropertyInvalid) return; const DeprecatedStyleBuilder& table = DeprecatedStyleBuilder::sharedStyleBuilder(); const PropertyHandler& handler = table.propertyHandler(id); if (handler.isValid()) handler.applyValue(propertyID, styleResolver, value); } static void applyValue(CSSPropertyID propertyID, StyleResolver* styleResolver, CSSValue* value) { if (!expandValue) return; applyValue(propertyID, styleResolver, value); applyValue(propertyID, styleResolver, value); applyValue(propertyID, styleResolver, value); applyValue(propertyID, styleResolver, value); applyValue(propertyID, styleResolver, value); } static PropertyHandler createHandler() { return PropertyHandler(&applyInheritValue, &applyInitialValue, &applyValue); } }; template class ApplyPropertyDefaultBase { public: static void setValue(RenderStyle* style, SetterType value) { (style->*setterFunction)(value); } static GetterType value(RenderStyle* style) { return (style->*getterFunction)(); } static InitialType initial() { return (*initialFunction)(); } static void applyInheritValue(CSSPropertyID, StyleResolver* styleResolver) { setValue(styleResolver->style(), value(styleResolver->parentStyle())); } static void applyInitialValue(CSSPropertyID, StyleResolver* styleResolver) { setValue(styleResolver->style(), initial()); } static void applyValue(CSSPropertyID, StyleResolver*, CSSValue*) { } static PropertyHandler createHandler() { return PropertyHandler(&applyInheritValue, &applyInitialValue, &applyValue); } }; template class ApplyPropertyDefault { public: static void setValue(RenderStyle* style, SetterType value) { (style->*setterFunction)(value); } static void applyValue(CSSPropertyID, StyleResolver* styleResolver, CSSValue* value) { if (value->isPrimitiveValue()) setValue(styleResolver->style(), *static_cast(value)); } static PropertyHandler createHandler() { PropertyHandler handler = ApplyPropertyDefaultBase::createHandler(); return PropertyHandler(handler.inheritFunction(), handler.initialFunction(), &applyValue); } }; template class ApplyPropertyNumber { public: static void setValue(RenderStyle* style, NumberType value) { (style->*setterFunction)(value); } static void applyValue(CSSPropertyID, StyleResolver* styleResolver, CSSValue* value) { if (!value->isPrimitiveValue()) return; CSSPrimitiveValue* primitiveValue = static_cast(value); if (primitiveValue->getValueID() == idMapsToMinusOne) setValue(styleResolver->style(), -1); else setValue(styleResolver->style(), primitiveValue->getValue(CSSPrimitiveValue::CSS_NUMBER)); } static PropertyHandler createHandler() { PropertyHandler handler = ApplyPropertyDefaultBase::createHandler(); return PropertyHandler(handler.inheritFunction(), handler.initialFunction(), &applyValue); } }; template ), StyleImage* (*initialFunction)(), CSSPropertyID property> class ApplyPropertyStyleImage { public: static void applyValue(CSSPropertyID, StyleResolver* styleResolver, CSSValue* value) { (styleResolver->style()->*setterFunction)(styleResolver->styleImage(property, value)); } static PropertyHandler createHandler() { PropertyHandler handler = ApplyPropertyDefaultBase, setterFunction, StyleImage*, initialFunction>::createHandler(); return PropertyHandler(handler.inheritFunction(), handler.initialFunction(), &applyValue); } }; enum AutoValueType {Number = 0, ComputeLength}; template class ApplyPropertyAuto { public: static void setValue(RenderStyle* style, T value) { (style->*setterFunction)(value); } static T value(RenderStyle* style) { return (style->*getterFunction)(); } static bool hasAuto(RenderStyle* style) { return (style->*hasAutoFunction)(); } static void setAuto(RenderStyle* style) { (style->*setAutoFunction)(); } static void applyInheritValue(CSSPropertyID, StyleResolver* styleResolver) { if (hasAuto(styleResolver->parentStyle())) setAuto(styleResolver->style()); else setValue(styleResolver->style(), value(styleResolver->parentStyle())); } static void applyInitialValue(CSSPropertyID, StyleResolver* styleResolver) { setAuto(styleResolver->style()); } static void applyValue(CSSPropertyID, StyleResolver* styleResolver, CSSValue* value) { if (!value->isPrimitiveValue()) return; CSSPrimitiveValue* primitiveValue = static_cast(value); if (primitiveValue->getValueID() == autoIdentity) setAuto(styleResolver->style()); else if (valueType == Number) setValue(styleResolver->style(), *primitiveValue); else if (valueType == ComputeLength) setValue(styleResolver->style(), primitiveValue->computeLength(styleResolver->style(), styleResolver->rootElementStyle(), styleResolver->style()->effectiveZoom())); } static PropertyHandler createHandler() { return PropertyHandler(&applyInheritValue, &applyInitialValue, &applyValue); } }; class ApplyPropertyClip { private: static Length convertToLength(StyleResolver* styleResolver, CSSPrimitiveValue* value) { return value->convertToLength(styleResolver->style(), styleResolver->rootElementStyle(), styleResolver->style()->effectiveZoom()); } public: static void applyInheritValue(CSSPropertyID propertyID, StyleResolver* styleResolver) { RenderStyle* parentStyle = styleResolver->parentStyle(); if (!parentStyle->hasClip()) return applyInitialValue(propertyID, styleResolver); styleResolver->style()->setClip(parentStyle->clipTop(), parentStyle->clipRight(), parentStyle->clipBottom(), parentStyle->clipLeft()); styleResolver->style()->setHasClip(true); } static void applyInitialValue(CSSPropertyID, StyleResolver* styleResolver) { styleResolver->style()->setClip(Length(), Length(), Length(), Length()); styleResolver->style()->setHasClip(false); } static void applyValue(CSSPropertyID, StyleResolver* styleResolver, CSSValue* value) { if (!value->isPrimitiveValue()) return; CSSPrimitiveValue* primitiveValue = static_cast(value); if (Rect* rect = primitiveValue->getRectValue()) { Length top = convertToLength(styleResolver, rect->top()); Length right = convertToLength(styleResolver, rect->right()); Length bottom = convertToLength(styleResolver, rect->bottom()); Length left = convertToLength(styleResolver, rect->left()); styleResolver->style()->setClip(top, right, bottom, left); styleResolver->style()->setHasClip(true); } else if (primitiveValue->getValueID() == CSSValueAuto) { styleResolver->style()->setClip(Length(), Length(), Length(), Length()); styleResolver->style()->setHasClip(false); } } static PropertyHandler createHandler() { return PropertyHandler(&applyInheritValue, &applyInitialValue, &applyValue); } }; enum ColorInherit {NoInheritFromParent = 0, InheritFromParent}; Color defaultInitialColor(); Color defaultInitialColor() { return Color(); } template class ApplyPropertyColor { public: static void applyInheritValue(CSSPropertyID, StyleResolver* styleResolver) { // Visited link style can never explicitly inherit from parent visited link style so no separate getters are needed. Color color = (styleResolver->parentStyle()->*getterFunction)(); applyColorValue(styleResolver, color.isValid() ? color : (styleResolver->parentStyle()->*defaultFunction)()); } static void applyInitialValue(CSSPropertyID, StyleResolver* styleResolver) { applyColorValue(styleResolver, initialFunction()); } static void applyValue(CSSPropertyID propertyID, StyleResolver* styleResolver, CSSValue* value) { if (!value->isPrimitiveValue()) return; CSSPrimitiveValue* primitiveValue = static_cast(value); if (inheritColorFromParent && primitiveValue->getValueID() == CSSValueCurrentcolor) applyInheritValue(propertyID, styleResolver); else { if (styleResolver->applyPropertyToRegularStyle()) (styleResolver->style()->*setterFunction)(styleResolver->colorFromPrimitiveValue(primitiveValue)); if (styleResolver->applyPropertyToVisitedLinkStyle()) (styleResolver->style()->*visitedLinkSetterFunction)(styleResolver->colorFromPrimitiveValue(primitiveValue, /* forVisitedLink */ true)); } } static void applyColorValue(StyleResolver* styleResolver, const Color& color) { if (styleResolver->applyPropertyToRegularStyle()) (styleResolver->style()->*setterFunction)(color); if (styleResolver->applyPropertyToVisitedLinkStyle()) (styleResolver->style()->*visitedLinkSetterFunction)(color); } static PropertyHandler createHandler() { return PropertyHandler(&applyInheritValue, &applyInitialValue, &applyValue); } }; template class ApplyPropertyDirection { public: static void applyValue(CSSPropertyID propertyID, StyleResolver* styleResolver, CSSValue* value) { ApplyPropertyDefault::applyValue(propertyID, styleResolver, value); Element* element = styleResolver->element(); if (element && styleResolver->element() == element->document()->documentElement()) element->document()->setDirectionSetOnDocumentElement(true); } static PropertyHandler createHandler() { PropertyHandler handler = ApplyPropertyDefault::createHandler(); return PropertyHandler(handler.inheritFunction(), handler.initialFunction(), &applyValue); } }; enum LengthAuto { AutoDisabled = 0, AutoEnabled }; enum LengthLegacyIntrinsic { LegacyIntrinsicDisabled = 0, LegacyIntrinsicEnabled }; enum LengthIntrinsic { IntrinsicDisabled = 0, IntrinsicEnabled }; enum LengthNone { NoneDisabled = 0, NoneEnabled }; enum LengthUndefined { UndefinedDisabled = 0, UndefinedEnabled }; template class ApplyPropertyLength { public: static void setValue(RenderStyle* style, Length value) { (style->*setterFunction)(value); } static void applyValue(CSSPropertyID, StyleResolver* styleResolver, CSSValue* value) { if (!value->isPrimitiveValue()) return; CSSPrimitiveValue* primitiveValue = static_cast(value); if (noneEnabled && primitiveValue->getValueID() == CSSValueNone) { if (noneUndefined) setValue(styleResolver->style(), Length(Undefined)); else setValue(styleResolver->style(), Length()); } if (legacyIntrinsicEnabled) { if (primitiveValue->getValueID() == CSSValueIntrinsic) setValue(styleResolver->style(), Length(Intrinsic)); else if (primitiveValue->getValueID() == CSSValueMinIntrinsic) setValue(styleResolver->style(), Length(MinIntrinsic)); } if (intrinsicEnabled) { if (primitiveValue->getValueID() == CSSValueWebkitMinContent) setValue(styleResolver->style(), Length(MinContent)); else if (primitiveValue->getValueID() == CSSValueWebkitMaxContent) setValue(styleResolver->style(), Length(MaxContent)); else if (primitiveValue->getValueID() == CSSValueWebkitFillAvailable) setValue(styleResolver->style(), Length(FillAvailable)); else if (primitiveValue->getValueID() == CSSValueWebkitFitContent) setValue(styleResolver->style(), Length(FitContent)); } if (autoEnabled && primitiveValue->getValueID() == CSSValueAuto) setValue(styleResolver->style(), Length()); else if (primitiveValue->isLength()) { Length length = primitiveValue->computeLength(styleResolver->style(), styleResolver->rootElementStyle(), styleResolver->style()->effectiveZoom()); length.setQuirk(primitiveValue->isQuirkValue()); setValue(styleResolver->style(), length); } else if (primitiveValue->isPercentage()) setValue(styleResolver->style(), Length(primitiveValue->getDoubleValue(), Percent)); else if (primitiveValue->isCalculatedPercentageWithLength()) setValue(styleResolver->style(), Length(primitiveValue->cssCalcValue()->toCalcValue(styleResolver->style(), styleResolver->rootElementStyle(), styleResolver->style()->effectiveZoom()))); else if (primitiveValue->isViewportPercentageLength()) setValue(styleResolver->style(), primitiveValue->viewportPercentageLength()); } static PropertyHandler createHandler() { PropertyHandler handler = ApplyPropertyDefaultBase::createHandler(); return PropertyHandler(handler.inheritFunction(), handler.initialFunction(), &applyValue); } }; enum StringIdentBehavior { NothingMapsToNull = 0, MapNoneToNull, MapAutoToNull }; template class ApplyPropertyString { public: static void setValue(RenderStyle* style, const AtomicString& value) { (style->*setterFunction)(value); } static void applyValue(CSSPropertyID, StyleResolver* styleResolver, CSSValue* value) { if (!value->isPrimitiveValue()) return; CSSPrimitiveValue* primitiveValue = static_cast(value); if ((identBehavior == MapNoneToNull && primitiveValue->getValueID() == CSSValueNone) || (identBehavior == MapAutoToNull && primitiveValue->getValueID() == CSSValueAuto)) setValue(styleResolver->style(), nullAtom); else setValue(styleResolver->style(), primitiveValue->getStringValue()); } static PropertyHandler createHandler() { PropertyHandler handler = ApplyPropertyDefaultBase::createHandler(); return PropertyHandler(handler.inheritFunction(), handler.initialFunction(), &applyValue); } }; template class ApplyPropertyBorderRadius { public: static void setValue(RenderStyle* style, LengthSize value) { (style->*setterFunction)(value); } static void applyValue(CSSPropertyID, StyleResolver* styleResolver, CSSValue* value) { if (!value->isPrimitiveValue()) return; CSSPrimitiveValue* primitiveValue = static_cast(value); Pair* pair = primitiveValue->getPairValue(); if (!pair || !pair->first() || !pair->second()) return; Length radiusWidth; Length radiusHeight; if (pair->first()->isPercentage()) radiusWidth = Length(pair->first()->getDoubleValue(), Percent); else if (pair->first()->isViewportPercentageLength()) radiusWidth = pair->first()->viewportPercentageLength(); else if (pair->first()->isCalculatedPercentageWithLength()) radiusWidth = Length((pair->first()->cssCalcValue()->toCalcValue(styleResolver->style(), styleResolver->rootElementStyle(), styleResolver->style()->effectiveZoom()))); else radiusWidth = pair->first()->computeLength(styleResolver->style(), styleResolver->rootElementStyle(), styleResolver->style()->effectiveZoom()); if (pair->second()->isPercentage()) radiusHeight = Length(pair->second()->getDoubleValue(), Percent); else if (pair->second()->isViewportPercentageLength()) radiusHeight = pair->second()->viewportPercentageLength(); else if (pair->second()->isCalculatedPercentageWithLength()) radiusHeight = Length((pair->second()->cssCalcValue()->toCalcValue(styleResolver->style(), styleResolver->rootElementStyle(), styleResolver->style()->effectiveZoom()))); else radiusHeight = pair->second()->computeLength(styleResolver->style(), styleResolver->rootElementStyle(), styleResolver->style()->effectiveZoom()); int width = radiusWidth.value(); int height = radiusHeight.value(); if (width < 0 || height < 0) return; if (!width) radiusHeight = radiusWidth; // Null out the other value. else if (!height) radiusWidth = radiusHeight; // Null out the other value. LengthSize size(radiusWidth, radiusHeight); setValue(styleResolver->style(), size); } static PropertyHandler createHandler() { PropertyHandler handler = ApplyPropertyDefaultBase::createHandler(); return PropertyHandler(handler.inheritFunction(), handler.initialFunction(), &applyValue); } }; template struct FillLayerAccessorTypes { typedef T Setter; typedef T Getter; }; template <> struct FillLayerAccessorTypes { typedef PassRefPtr Setter; typedef StyleImage* Getter; }; template ::Getter (FillLayer::*getFunction)() const, void (FillLayer::*setFunction)(typename FillLayerAccessorTypes::Setter), void (FillLayer::*clearFunction)(), typename FillLayerAccessorTypes::Getter (*initialFunction)(EFillLayerType), void (CSSToStyleMap::*mapFillFunction)(CSSPropertyID, FillLayer*, CSSValue*)> class ApplyPropertyFillLayer { public: static void applyInheritValue(CSSPropertyID, StyleResolver* styleResolver) { FillLayer* currChild = (styleResolver->style()->*accessLayersFunction)(); FillLayer* prevChild = 0; const FillLayer* currParent = (styleResolver->parentStyle()->*layersFunction)(); while (currParent && (currParent->*testFunction)()) { if (!currChild) { /* Need to make a new layer.*/ currChild = new FillLayer(fillLayerType); prevChild->setNext(currChild); } (currChild->*setFunction)((currParent->*getFunction)()); prevChild = currChild; currChild = prevChild->next(); currParent = currParent->next(); } while (currChild) { /* Reset any remaining layers to not have the property set. */ (currChild->*clearFunction)(); currChild = currChild->next(); } } static void applyInitialValue(CSSPropertyID, StyleResolver* styleResolver) { FillLayer* currChild = (styleResolver->style()->*accessLayersFunction)(); (currChild->*setFunction)((*initialFunction)(fillLayerType)); for (currChild = currChild->next(); currChild; currChild = currChild->next()) (currChild->*clearFunction)(); } static void applyValue(CSSPropertyID, StyleResolver* styleResolver, CSSValue* value) { FillLayer* currChild = (styleResolver->style()->*accessLayersFunction)(); FillLayer* prevChild = 0; if (value->isValueList() #if ENABLE(CSS_IMAGE_SET) && !value->isImageSetValue() #endif ) { /* Walk each value and put it into a layer, creating new layers as needed. */ CSSValueList* valueList = static_cast(value); for (unsigned int i = 0; i < valueList->length(); i++) { if (!currChild) { /* Need to make a new layer to hold this value */ currChild = new FillLayer(fillLayerType); prevChild->setNext(currChild); } (styleResolver->styleMap()->*mapFillFunction)(propertyId, currChild, valueList->itemWithoutBoundsCheck(i)); prevChild = currChild; currChild = currChild->next(); } } else { (styleResolver->styleMap()->*mapFillFunction)(propertyId, currChild, value); currChild = currChild->next(); } while (currChild) { /* Reset all remaining layers to not have the property set. */ (currChild->*clearFunction)(); currChild = currChild->next(); } } static PropertyHandler createHandler() { return PropertyHandler(&applyInheritValue, &applyInitialValue, &applyValue); } }; enum ComputeLengthNormal {NormalDisabled = 0, NormalEnabled}; enum ComputeLengthThickness {ThicknessDisabled = 0, ThicknessEnabled}; enum ComputeLengthSVGZoom {SVGZoomDisabled = 0, SVGZoomEnabled}; template class ApplyPropertyComputeLength { public: static void setValue(RenderStyle* style, T value) { (style->*setterFunction)(value); } static void applyValue(CSSPropertyID, StyleResolver* styleResolver, CSSValue* value) { // note: CSSPropertyLetter/WordSpacing right now sets to zero if it's not a primitive value for some reason... if (!value->isPrimitiveValue()) return; CSSPrimitiveValue* primitiveValue = static_cast(value); CSSValueID ident = primitiveValue->getValueID(); T length; if (normalEnabled && ident == CSSValueNormal) { length = 0; } else if (thicknessEnabled && ident == CSSValueThin) { length = 1; } else if (thicknessEnabled && ident == CSSValueMedium) { length = 3; } else if (thicknessEnabled && ident == CSSValueThick) { length = 5; } else if (ident == CSSValueInvalid) { float zoom = (svgZoomEnabled && styleResolver->useSVGZoomRules()) ? 1.0f : styleResolver->style()->effectiveZoom(); // Any original result that was >= 1 should not be allowed to fall below 1. // This keeps border lines from vanishing. length = primitiveValue->computeLength(styleResolver->style(), styleResolver->rootElementStyle(), zoom); if (zoom < 1.0f && length < 1.0) { T originalLength = primitiveValue->computeLength(styleResolver->style(), styleResolver->rootElementStyle(), 1.0); if (originalLength >= 1.0) length = 1.0; } if (primitiveValue->isViewportPercentageLength()) { int viewPortHeight = styleResolver->document()->renderView()->viewportSize().height() * length / 100.0f; int viewPortWidth = styleResolver->document()->renderView()->viewportSize().width() * length / 100.0f; if (primitiveValue->isViewportPercentageHeight()) length = viewPortHeight; else if (primitiveValue->isViewportPercentageWidth()) length = viewPortWidth; else if (primitiveValue->isViewportPercentageMax()) length = max(viewPortWidth, viewPortHeight); else if (primitiveValue->isViewportPercentageMin()) length = min(viewPortWidth, viewPortHeight); } } else { ASSERT_NOT_REACHED(); length = 0; } setValue(styleResolver->style(), length); } static PropertyHandler createHandler() { PropertyHandler handler = ApplyPropertyDefaultBase::createHandler(); return PropertyHandler(handler.inheritFunction(), handler.initialFunction(), &applyValue); } }; template class ApplyPropertyFont { public: static void applyInheritValue(CSSPropertyID, StyleResolver* styleResolver) { FontDescription fontDescription = styleResolver->fontDescription(); (fontDescription.*setterFunction)((styleResolver->parentFontDescription().*getterFunction)()); styleResolver->setFontDescription(fontDescription); } static void applyInitialValue(CSSPropertyID, StyleResolver* styleResolver) { FontDescription fontDescription = styleResolver->fontDescription(); (fontDescription.*setterFunction)(initialValue); styleResolver->setFontDescription(fontDescription); } static void applyValue(CSSPropertyID, StyleResolver* styleResolver, CSSValue* value) { if (!value->isPrimitiveValue()) return; CSSPrimitiveValue* primitiveValue = static_cast(value); FontDescription fontDescription = styleResolver->fontDescription(); (fontDescription.*setterFunction)(*primitiveValue); styleResolver->setFontDescription(fontDescription); } static PropertyHandler createHandler() { return PropertyHandler(&applyInheritValue, &applyInitialValue, &applyValue); } }; class ApplyPropertyFontFamily { public: static void applyInheritValue(CSSPropertyID, StyleResolver* styleResolver) { FontDescription fontDescription = styleResolver->style()->fontDescription(); FontDescription parentFontDescription = styleResolver->parentStyle()->fontDescription(); fontDescription.setGenericFamily(parentFontDescription.genericFamily()); fontDescription.setFamilies(parentFontDescription.families()); fontDescription.setIsSpecifiedFont(parentFontDescription.isSpecifiedFont()); styleResolver->setFontDescription(fontDescription); return; } static void applyInitialValue(CSSPropertyID, StyleResolver* styleResolver) { FontDescription fontDescription = styleResolver->style()->fontDescription(); FontDescription initialDesc = FontDescription(); // We need to adjust the size to account for the generic family change from monospace to non-monospace. if (fontDescription.keywordSize() && fontDescription.useFixedDefaultSize()) styleResolver->setFontSize(fontDescription, styleResolver->fontSizeForKeyword(styleResolver->document(), CSSValueXxSmall + fontDescription.keywordSize() - 1, false)); fontDescription.setGenericFamily(initialDesc.genericFamily()); if (!initialDesc.firstFamily().isEmpty()) fontDescription.setFamilies(initialDesc.families()); styleResolver->setFontDescription(fontDescription); return; } static void applyValue(CSSPropertyID, StyleResolver* styleResolver, CSSValue* value) { if (!value->isValueList()) return; FontDescription fontDescription = styleResolver->style()->fontDescription(); // Before mapping in a new font-family property, we should reset the generic family. bool oldFamilyUsedFixedDefaultSize = fontDescription.useFixedDefaultSize(); fontDescription.setGenericFamily(FontDescription::NoFamily); Vector families; for (CSSValueListIterator i = value; i.hasMore(); i.advance()) { CSSValue* item = i.value(); if (!item->isPrimitiveValue()) continue; CSSPrimitiveValue* contentValue = static_cast(item); AtomicString face; if (contentValue->isString()) face = contentValue->getStringValue(); else if (Settings* settings = styleResolver->document()->settings()) { switch (contentValue->getValueID()) { case CSSValueWebkitBody: face = settings->standardFontFamily(); break; case CSSValueSerif: face = serifFamily; fontDescription.setGenericFamily(FontDescription::SerifFamily); break; case CSSValueSansSerif: face = sansSerifFamily; fontDescription.setGenericFamily(FontDescription::SansSerifFamily); break; case CSSValueCursive: face = cursiveFamily; fontDescription.setGenericFamily(FontDescription::CursiveFamily); break; case CSSValueFantasy: face = fantasyFamily; fontDescription.setGenericFamily(FontDescription::FantasyFamily); break; case CSSValueMonospace: face = monospaceFamily; fontDescription.setGenericFamily(FontDescription::MonospaceFamily); break; case CSSValueWebkitPictograph: face = pictographFamily; fontDescription.setGenericFamily(FontDescription::PictographFamily); break; default: break; } } if (face.isEmpty()) continue; if (families.isEmpty()) fontDescription.setIsSpecifiedFont(fontDescription.genericFamily() == FontDescription::NoFamily); families.append(face); } if (families.isEmpty()) return; fontDescription.adoptFamilies(families); if (fontDescription.keywordSize() && fontDescription.useFixedDefaultSize() != oldFamilyUsedFixedDefaultSize) styleResolver->setFontSize(fontDescription, styleResolver->fontSizeForKeyword(styleResolver->document(), CSSValueXxSmall + fontDescription.keywordSize() - 1, !oldFamilyUsedFixedDefaultSize)); styleResolver->setFontDescription(fontDescription); } static PropertyHandler createHandler() { return PropertyHandler(&applyInheritValue, &applyInitialValue, &applyValue); } }; class ApplyPropertyFontSize { private: // When the CSS keyword "larger" is used, this function will attempt to match within the keyword // table, and failing that, will simply multiply by 1.2. static float largerFontSize(float size) { // FIXME: Figure out where we fall in the size ranges (xx-small to xxx-large) and scale up to // the next size level. return size * 1.2f; } // Like the previous function, but for the keyword "smaller". static float smallerFontSize(float size) { // FIXME: Figure out where we fall in the size ranges (xx-small to xxx-large) and scale down to // the next size level. return size / 1.2f; } public: static void applyInheritValue(CSSPropertyID, StyleResolver* styleResolver) { float size = styleResolver->parentStyle()->fontDescription().specifiedSize(); if (size < 0) return; FontDescription fontDescription = styleResolver->style()->fontDescription(); fontDescription.setKeywordSize(styleResolver->parentStyle()->fontDescription().keywordSize()); styleResolver->setFontSize(fontDescription, size); styleResolver->setFontDescription(fontDescription); return; } static void applyInitialValue(CSSPropertyID, StyleResolver* styleResolver) { FontDescription fontDescription = styleResolver->style()->fontDescription(); float size = styleResolver->fontSizeForKeyword(styleResolver->document(), CSSValueMedium, fontDescription.useFixedDefaultSize()); if (size < 0) return; fontDescription.setKeywordSize(CSSValueMedium - CSSValueXxSmall + 1); styleResolver->setFontSize(fontDescription, size); styleResolver->setFontDescription(fontDescription); return; } static void applyValue(CSSPropertyID, StyleResolver* styleResolver, CSSValue* value) { if (!value->isPrimitiveValue()) return; CSSPrimitiveValue* primitiveValue = static_cast(value); FontDescription fontDescription = styleResolver->style()->fontDescription(); fontDescription.setKeywordSize(0); float parentSize = 0; bool parentIsAbsoluteSize = false; float size = 0; if (styleResolver->parentStyle()) { parentSize = styleResolver->parentStyle()->fontDescription().specifiedSize(); parentIsAbsoluteSize = styleResolver->parentStyle()->fontDescription().isAbsoluteSize(); } if (CSSValueID ident = primitiveValue->getValueID()) { // Keywords are being used. switch (ident) { case CSSValueXxSmall: case CSSValueXSmall: case CSSValueSmall: case CSSValueMedium: case CSSValueLarge: case CSSValueXLarge: case CSSValueXxLarge: case CSSValueWebkitXxxLarge: size = styleResolver->fontSizeForKeyword(styleResolver->document(), ident, fontDescription.useFixedDefaultSize()); fontDescription.setKeywordSize(ident - CSSValueXxSmall + 1); break; case CSSValueLarger: size = largerFontSize(parentSize); break; case CSSValueSmaller: size = smallerFontSize(parentSize); break; default: return; } fontDescription.setIsAbsoluteSize(parentIsAbsoluteSize && (ident == CSSValueLarger || ident == CSSValueSmaller)); } else { fontDescription.setIsAbsoluteSize(parentIsAbsoluteSize || !(primitiveValue->isPercentage() || primitiveValue->isFontRelativeLength())); if (primitiveValue->isLength()) size = primitiveValue->computeLength(styleResolver->parentStyle(), styleResolver->rootElementStyle(), 1.0, true); else if (primitiveValue->isPercentage()) size = (primitiveValue->getFloatValue() * parentSize) / 100.0f; else if (primitiveValue->isCalculatedPercentageWithLength()) size = primitiveValue->cssCalcValue()->toCalcValue(styleResolver->parentStyle(), styleResolver->rootElementStyle())->evaluate(parentSize); else if (primitiveValue->isViewportPercentageLength()) size = valueForLength(primitiveValue->viewportPercentageLength(), 0, styleResolver->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 = min(maximumAllowedFontSize, size); styleResolver->setFontSize(fontDescription, size); styleResolver->setFontDescription(fontDescription); return; } static PropertyHandler createHandler() { return PropertyHandler(&applyInheritValue, &applyInitialValue, &applyValue); } }; class ApplyPropertyFontWeight { public: static void applyValue(CSSPropertyID, StyleResolver* styleResolver, CSSValue* value) { if (!value->isPrimitiveValue()) return; CSSPrimitiveValue* primitiveValue = static_cast(value); FontDescription fontDescription = styleResolver->fontDescription(); switch (primitiveValue->getValueID()) { case CSSValueInvalid: ASSERT_NOT_REACHED(); break; case CSSValueBolder: fontDescription.setWeight(fontDescription.bolderWeight()); break; case CSSValueLighter: fontDescription.setWeight(fontDescription.lighterWeight()); break; default: fontDescription.setWeight(*primitiveValue); } styleResolver->setFontDescription(fontDescription); } static PropertyHandler createHandler() { PropertyHandler handler = ApplyPropertyFont::createHandler(); return PropertyHandler(handler.inheritFunction(), handler.initialFunction(), &applyValue); } }; class ApplyPropertyFontVariantLigatures { public: static void applyInheritValue(CSSPropertyID, StyleResolver* styleResolver) { const FontDescription& parentFontDescription = styleResolver->parentFontDescription(); FontDescription fontDescription = styleResolver->fontDescription(); fontDescription.setCommonLigaturesState(parentFontDescription.commonLigaturesState()); fontDescription.setDiscretionaryLigaturesState(parentFontDescription.discretionaryLigaturesState()); fontDescription.setHistoricalLigaturesState(parentFontDescription.historicalLigaturesState()); styleResolver->setFontDescription(fontDescription); } static void applyInitialValue(CSSPropertyID, StyleResolver* styleResolver) { FontDescription fontDescription = styleResolver->fontDescription(); fontDescription.setCommonLigaturesState(FontDescription::NormalLigaturesState); fontDescription.setDiscretionaryLigaturesState(FontDescription::NormalLigaturesState); fontDescription.setHistoricalLigaturesState(FontDescription::NormalLigaturesState); styleResolver->setFontDescription(fontDescription); } static void applyValue(CSSPropertyID, StyleResolver* styleResolver, CSSValue* value) { FontDescription::LigaturesState commonLigaturesState = FontDescription::NormalLigaturesState; FontDescription::LigaturesState discretionaryLigaturesState = FontDescription::NormalLigaturesState; FontDescription::LigaturesState historicalLigaturesState = FontDescription::NormalLigaturesState; if (value->isValueList()) { CSSValueList* valueList = static_cast(value); for (size_t i = 0; i < valueList->length(); ++i) { CSSValue* item = valueList->itemWithoutBoundsCheck(i); ASSERT(item->isPrimitiveValue()); if (item->isPrimitiveValue()) { CSSPrimitiveValue* primitiveValue = static_cast(item); switch (primitiveValue->getValueID()) { case CSSValueNoCommonLigatures: commonLigaturesState = FontDescription::DisabledLigaturesState; break; case CSSValueCommonLigatures: commonLigaturesState = FontDescription::EnabledLigaturesState; break; case CSSValueNoDiscretionaryLigatures: discretionaryLigaturesState = FontDescription::DisabledLigaturesState; break; case CSSValueDiscretionaryLigatures: discretionaryLigaturesState = FontDescription::EnabledLigaturesState; break; case CSSValueNoHistoricalLigatures: historicalLigaturesState = FontDescription::DisabledLigaturesState; break; case CSSValueHistoricalLigatures: historicalLigaturesState = FontDescription::EnabledLigaturesState; break; default: ASSERT_NOT_REACHED(); break; } } } } #if !ASSERT_DISABLED else { ASSERT_WITH_SECURITY_IMPLICATION(value->isPrimitiveValue()); ASSERT(static_cast(value)->getValueID() == CSSValueNormal); } #endif FontDescription fontDescription = styleResolver->fontDescription(); fontDescription.setCommonLigaturesState(commonLigaturesState); fontDescription.setDiscretionaryLigaturesState(discretionaryLigaturesState); fontDescription.setHistoricalLigaturesState(historicalLigaturesState); styleResolver->setFontDescription(fontDescription); } static PropertyHandler createHandler() { return PropertyHandler(&applyInheritValue, &applyInitialValue, &applyValue); } }; enum BorderImageType { BorderImage = 0, BorderMask }; template class ApplyPropertyBorderImage { public: static void applyValue(CSSPropertyID, StyleResolver* styleResolver, CSSValue* value) { NinePieceImage image; if (borderImageType == BorderMask) image.setMaskDefaults(); styleResolver->styleMap()->mapNinePieceImage(property, value, image); (styleResolver->style()->*setterFunction)(image); } static PropertyHandler createHandler() { PropertyHandler handler = ApplyPropertyDefaultBase::createHandler(); return PropertyHandler(handler.inheritFunction(), handler.initialFunction(), &applyValue); } }; enum BorderImageModifierType { Outset, Repeat, Slice, Width }; template class ApplyPropertyBorderImageModifier { private: static inline const NinePieceImage& getValue(RenderStyle* style) { return type == BorderImage ? style->borderImage() : style->maskBoxImage(); } static inline void setValue(RenderStyle* style, const NinePieceImage& value) { return type == BorderImage ? style->setBorderImage(value) : style->setMaskBoxImage(value); } public: static void applyInheritValue(CSSPropertyID, StyleResolver* styleResolver) { NinePieceImage image(getValue(styleResolver->style())); switch (modifier) { case Outset: image.copyOutsetFrom(getValue(styleResolver->parentStyle())); break; case Repeat: image.copyRepeatFrom(getValue(styleResolver->parentStyle())); break; case Slice: image.copyImageSlicesFrom(getValue(styleResolver->parentStyle())); break; case Width: image.copyBorderSlicesFrom(getValue(styleResolver->parentStyle())); break; } setValue(styleResolver->style(), image); } static void applyInitialValue(CSSPropertyID, StyleResolver* styleResolver) { NinePieceImage image(getValue(styleResolver->style())); switch (modifier) { case Outset: image.setOutset(LengthBox(0)); break; case Repeat: image.setHorizontalRule(StretchImageRule); image.setVerticalRule(StretchImageRule); break; case Slice: // Masks have a different initial value for slices. Preserve the value of 0 for backwards compatibility. image.setImageSlices(type == BorderImage ? LengthBox(Length(100, Percent), Length(100, Percent), Length(100, Percent), Length(100, Percent)) : LengthBox()); image.setFill(false); break; case Width: // Masks have a different initial value for widths. They use an 'auto' value rather than trying to fit to the border. image.setBorderSlices(type == BorderImage ? LengthBox(Length(1, Relative), Length(1, Relative), Length(1, Relative), Length(1, Relative)) : LengthBox()); break; } setValue(styleResolver->style(), image); } static void applyValue(CSSPropertyID, StyleResolver* styleResolver, CSSValue* value) { NinePieceImage image(getValue(styleResolver->style())); switch (modifier) { case Outset: image.setOutset(styleResolver->styleMap()->mapNinePieceImageQuad(value)); break; case Repeat: styleResolver->styleMap()->mapNinePieceImageRepeat(value, image); break; case Slice: styleResolver->styleMap()->mapNinePieceImageSlice(value, image); break; case Width: image.setBorderSlices(styleResolver->styleMap()->mapNinePieceImageQuad(value)); break; } setValue(styleResolver->style(), image); } static PropertyHandler createHandler() { return PropertyHandler(&applyInheritValue, &applyInitialValue, &applyValue); } }; template ), StyleImage* (*initialFunction)()> class ApplyPropertyBorderImageSource { public: static void applyValue(CSSPropertyID, StyleResolver* styleResolver, CSSValue* value) { (styleResolver->style()->*setterFunction)(styleResolver->styleImage(id, value)); } static PropertyHandler createHandler() { PropertyHandler handler = ApplyPropertyDefaultBase, setterFunction, StyleImage*, initialFunction>::createHandler(); return PropertyHandler(handler.inheritFunction(), handler.initialFunction(), &applyValue); } }; enum CounterBehavior {Increment = 0, Reset}; template class ApplyPropertyCounter { public: static void emptyFunction(CSSPropertyID, StyleResolver*) { } static void applyInheritValue(CSSPropertyID, StyleResolver* styleResolver) { CounterDirectiveMap& map = styleResolver->style()->accessCounterDirectives(); CounterDirectiveMap& parentMap = styleResolver->parentStyle()->accessCounterDirectives(); typedef CounterDirectiveMap::iterator Iterator; Iterator end = parentMap.end(); for (Iterator it = parentMap.begin(); it != end; ++it) { CounterDirectives& directives = map.add(it->key, CounterDirectives()).iterator->value; if (counterBehavior == Reset) { directives.inheritReset(it->value); } else { directives.inheritIncrement(it->value); } } } static void applyValue(CSSPropertyID, StyleResolver* styleResolver, CSSValue* value) { bool setCounterIncrementToNone = counterBehavior == Increment && value->isPrimitiveValue() && static_cast(value)->getValueID() == CSSValueNone; if (!value->isValueList() && !setCounterIncrementToNone) return; CounterDirectiveMap& map = styleResolver->style()->accessCounterDirectives(); typedef CounterDirectiveMap::iterator Iterator; Iterator end = map.end(); for (Iterator it = map.begin(); it != end; ++it) if (counterBehavior == Reset) it->value.clearReset(); else it->value.clearIncrement(); if (setCounterIncrementToNone) return; CSSValueList* list = static_cast(value); int length = list ? list->length() : 0; for (int i = 0; i < length; ++i) { CSSValue* currValue = list->itemWithoutBoundsCheck(i); if (!currValue->isPrimitiveValue()) continue; Pair* pair = static_cast(currValue)->getPairValue(); if (!pair || !pair->first() || !pair->second()) continue; AtomicString identifier = static_cast(pair->first())->getStringValue(); int value = static_cast(pair->second())->getIntValue(); CounterDirectives& directives = map.add(identifier, CounterDirectives()).iterator->value; if (counterBehavior == Reset) { directives.setResetValue(value); } else { directives.addIncrementValue(value); } } } static PropertyHandler createHandler() { return PropertyHandler(&applyInheritValue, &emptyFunction, &applyValue); } }; class ApplyPropertyCursor { public: static void applyInheritValue(CSSPropertyID, StyleResolver* styleResolver) { styleResolver->style()->setCursor(styleResolver->parentStyle()->cursor()); styleResolver->style()->setCursorList(styleResolver->parentStyle()->cursors()); } static void applyInitialValue(CSSPropertyID, StyleResolver* styleResolver) { styleResolver->style()->clearCursorList(); styleResolver->style()->setCursor(RenderStyle::initialCursor()); } static void applyValue(CSSPropertyID, StyleResolver* styleResolver, CSSValue* value) { styleResolver->style()->clearCursorList(); if (value->isValueList()) { CSSValueList* list = static_cast(value); int len = list->length(); styleResolver->style()->setCursor(CURSOR_AUTO); for (int i = 0; i < len; i++) { CSSValue* item = list->itemWithoutBoundsCheck(i); if (item->isCursorImageValue()) { CSSCursorImageValue* image = static_cast(item); if (image->updateIfSVGCursorIsUsed(styleResolver->element())) // Elements with SVG cursors are not allowed to share style. styleResolver->style()->setUnique(); styleResolver->style()->addCursor(styleResolver->styleImage(CSSPropertyCursor, image), image->hotSpot()); } else if (item->isPrimitiveValue()) { CSSPrimitiveValue* primitiveValue = static_cast(item); if (primitiveValue->isValueID()) styleResolver->style()->setCursor(*primitiveValue); } } } else if (value->isPrimitiveValue()) { CSSPrimitiveValue* primitiveValue = static_cast(value); if (primitiveValue->isValueID() && styleResolver->style()->cursor() != ECursor(*primitiveValue)) styleResolver->style()->setCursor(*primitiveValue); } } static PropertyHandler createHandler() { return PropertyHandler(&applyInheritValue, &applyInitialValue, &applyValue); } }; class ApplyPropertyTextAlign { public: static void applyValue(CSSPropertyID, StyleResolver* styleResolver, CSSValue* value) { if (!value->isPrimitiveValue()) return; CSSPrimitiveValue* primitiveValue = static_cast(value); ASSERT(primitiveValue->isValueID()); if (primitiveValue->getValueID() != CSSValueWebkitMatchParent) styleResolver->style()->setTextAlign(*primitiveValue); else if (styleResolver->parentStyle()->textAlign() == TASTART) styleResolver->style()->setTextAlign(styleResolver->parentStyle()->isLeftToRightDirection() ? LEFT : RIGHT); else if (styleResolver->parentStyle()->textAlign() == TAEND) styleResolver->style()->setTextAlign(styleResolver->parentStyle()->isLeftToRightDirection() ? RIGHT : LEFT); else styleResolver->style()->setTextAlign(styleResolver->parentStyle()->textAlign()); } static PropertyHandler createHandler() { PropertyHandler handler = ApplyPropertyDefaultBase::createHandler(); return PropertyHandler(handler.inheritFunction(), handler.initialFunction(), &applyValue); } }; class ApplyPropertyTextDecoration { public: static void applyValue(CSSPropertyID, StyleResolver* styleResolver, CSSValue* value) { TextDecoration t = RenderStyle::initialTextDecoration(); for (CSSValueListIterator i(value); i.hasMore(); i.advance()) { CSSValue* item = i.value(); ASSERT_WITH_SECURITY_IMPLICATION(item->isPrimitiveValue()); t |= *static_cast(item); } styleResolver->style()->setTextDecoration(t); } static PropertyHandler createHandler() { PropertyHandler handler = ApplyPropertyDefaultBase::createHandler(); return PropertyHandler(handler.inheritFunction(), handler.initialFunction(), &applyValue); } }; class ApplyPropertyMarqueeIncrement { public: static void applyValue(CSSPropertyID, StyleResolver* styleResolver, CSSValue* value) { if (!value->isPrimitiveValue()) return; CSSPrimitiveValue* primitiveValue = static_cast(value); if (primitiveValue->getValueID()) { switch (primitiveValue->getValueID()) { case CSSValueSmall: styleResolver->style()->setMarqueeIncrement(Length(1, Fixed)); // 1px. break; case CSSValueNormal: styleResolver->style()->setMarqueeIncrement(Length(6, Fixed)); // 6px. The WinIE default. break; case CSSValueLarge: styleResolver->style()->setMarqueeIncrement(Length(36, Fixed)); // 36px. break; default: break; } } else { Length marqueeLength = styleResolver->convertToIntLength(primitiveValue, styleResolver->style(), styleResolver->rootElementStyle()); if (!marqueeLength.isUndefined()) styleResolver->style()->setMarqueeIncrement(marqueeLength); } } static PropertyHandler createHandler() { PropertyHandler handler = ApplyPropertyLength<&RenderStyle::marqueeIncrement, &RenderStyle::setMarqueeIncrement, &RenderStyle::initialMarqueeIncrement>::createHandler(); return PropertyHandler(handler.inheritFunction(), handler.initialFunction(), &applyValue); } }; class ApplyPropertyMarqueeRepetition { public: static void applyValue(CSSPropertyID, StyleResolver* styleResolver, CSSValue* value) { if (!value->isPrimitiveValue()) return; CSSPrimitiveValue* primitiveValue = static_cast(value); if (primitiveValue->getValueID() == CSSValueInfinite) styleResolver->style()->setMarqueeLoopCount(-1); // -1 means repeat forever. else if (primitiveValue->isNumber()) styleResolver->style()->setMarqueeLoopCount(primitiveValue->getIntValue()); } static PropertyHandler createHandler() { PropertyHandler handler = ApplyPropertyDefault::createHandler(); return PropertyHandler(handler.inheritFunction(), handler.initialFunction(), &applyValue); } }; class ApplyPropertyMarqueeSpeed { public: static void applyValue(CSSPropertyID, StyleResolver* styleResolver, CSSValue* value) { if (!value->isPrimitiveValue()) return; CSSPrimitiveValue* primitiveValue = static_cast(value); if (CSSValueID ident = primitiveValue->getValueID()) { switch (ident) { case CSSValueSlow: styleResolver->style()->setMarqueeSpeed(500); // 500 msec. break; case CSSValueNormal: styleResolver->style()->setMarqueeSpeed(85); // 85msec. The WinIE default. break; case CSSValueFast: styleResolver->style()->setMarqueeSpeed(10); // 10msec. Super fast. break; default: break; } } else if (primitiveValue->isTime()) styleResolver->style()->setMarqueeSpeed(primitiveValue->computeTime()); else if (primitiveValue->isNumber()) // For scrollamount support. styleResolver->style()->setMarqueeSpeed(primitiveValue->getIntValue()); } static PropertyHandler createHandler() { PropertyHandler handler = ApplyPropertyDefault::createHandler(); return PropertyHandler(handler.inheritFunction(), handler.initialFunction(), &applyValue); } }; #if ENABLE(CSS3_TEXT) class ApplyPropertyTextUnderlinePosition { public: static void applyValue(CSSPropertyID, StyleResolver* styleResolver, CSSValue* value) { // This is true if value is 'auto' or 'alphabetic'. if (value->isPrimitiveValue()) { TextUnderlinePosition t = *static_cast(value); styleResolver->style()->setTextUnderlinePosition(t); return; } unsigned t = 0; for (CSSValueListIterator i(value); i.hasMore(); i.advance()) { CSSValue* item = i.value(); ASSERT(item->isPrimitiveValue()); TextUnderlinePosition t2 = *static_cast(item); t |= t2; } styleResolver->style()->setTextUnderlinePosition(static_cast(t)); } static PropertyHandler createHandler() { PropertyHandler handler = ApplyPropertyDefaultBase::createHandler(); return PropertyHandler(handler.inheritFunction(), handler.initialFunction(), &applyValue); } }; #endif // CSS3_TEXT class ApplyPropertyLineHeight { public: static void applyValue(CSSPropertyID, StyleResolver* styleResolver, CSSValue* value) { if (!value->isPrimitiveValue()) return; CSSPrimitiveValue* primitiveValue = static_cast(value); Length lineHeight; if (primitiveValue->getValueID() == CSSValueNormal) lineHeight = RenderStyle::initialLineHeight(); else if (primitiveValue->isLength()) { double multiplier = styleResolver->style()->effectiveZoom(); if (Frame* frame = styleResolver->document()->frame()) multiplier *= frame->textZoomFactor(); lineHeight = primitiveValue->computeLength(styleResolver->style(), styleResolver->rootElementStyle(), multiplier); } else if (primitiveValue->isPercentage()) { // FIXME: percentage should not be restricted to an integer here. lineHeight = Length((styleResolver->style()->fontSize() * primitiveValue->getIntValue()) / 100, Fixed); } else if (primitiveValue->isNumber()) { // FIXME: number and percentage values should produce the same type of Length (ie. Fixed or Percent). lineHeight = Length(primitiveValue->getDoubleValue() * 100.0, Percent); } else if (primitiveValue->isViewportPercentageLength()) lineHeight = primitiveValue->viewportPercentageLength(); else return; styleResolver->style()->setLineHeight(lineHeight); } static PropertyHandler createHandler() { PropertyHandler handler = ApplyPropertyDefaultBase::createHandler(); return PropertyHandler(handler.inheritFunction(), handler.initialFunction(), &applyValue); } }; class ApplyPropertyPageSize { private: static Length mmLength(double mm) { return CSSPrimitiveValue::create(mm, CSSPrimitiveValue::CSS_MM)->computeLength(0, 0); } static Length inchLength(double inch) { return CSSPrimitiveValue::create(inch, CSSPrimitiveValue::CSS_IN)->computeLength(0, 0); } static bool getPageSizeFromName(CSSPrimitiveValue* pageSizeName, CSSPrimitiveValue* pageOrientation, Length& width, Length& height) { DEFINE_STATIC_LOCAL(Length, a5Width, (mmLength(148))); DEFINE_STATIC_LOCAL(Length, a5Height, (mmLength(210))); DEFINE_STATIC_LOCAL(Length, a4Width, (mmLength(210))); DEFINE_STATIC_LOCAL(Length, a4Height, (mmLength(297))); DEFINE_STATIC_LOCAL(Length, a3Width, (mmLength(297))); DEFINE_STATIC_LOCAL(Length, a3Height, (mmLength(420))); DEFINE_STATIC_LOCAL(Length, b5Width, (mmLength(176))); DEFINE_STATIC_LOCAL(Length, b5Height, (mmLength(250))); DEFINE_STATIC_LOCAL(Length, b4Width, (mmLength(250))); DEFINE_STATIC_LOCAL(Length, b4Height, (mmLength(353))); DEFINE_STATIC_LOCAL(Length, letterWidth, (inchLength(8.5))); DEFINE_STATIC_LOCAL(Length, letterHeight, (inchLength(11))); DEFINE_STATIC_LOCAL(Length, legalWidth, (inchLength(8.5))); DEFINE_STATIC_LOCAL(Length, legalHeight, (inchLength(14))); DEFINE_STATIC_LOCAL(Length, ledgerWidth, (inchLength(11))); DEFINE_STATIC_LOCAL(Length, ledgerHeight, (inchLength(17))); if (!pageSizeName) return false; switch (pageSizeName->getValueID()) { case CSSValueA5: width = a5Width; height = a5Height; break; case CSSValueA4: width = a4Width; height = a4Height; break; case CSSValueA3: width = a3Width; height = a3Height; break; case CSSValueB5: width = b5Width; height = b5Height; break; case CSSValueB4: width = b4Width; height = b4Height; break; case CSSValueLetter: width = letterWidth; height = letterHeight; break; case CSSValueLegal: width = legalWidth; height = legalHeight; break; case CSSValueLedger: width = ledgerWidth; height = ledgerHeight; break; default: return false; } if (pageOrientation) { switch (pageOrientation->getValueID()) { case CSSValueLandscape: std::swap(width, height); break; case CSSValuePortrait: // Nothing to do. break; default: return false; } } return true; } public: static void applyInheritValue(CSSPropertyID, StyleResolver*) { } static void applyInitialValue(CSSPropertyID, StyleResolver*) { } static void applyValue(CSSPropertyID, StyleResolver* styleResolver, CSSValue* value) { styleResolver->style()->resetPageSizeType(); Length width; Length height; PageSizeType pageSizeType = PAGE_SIZE_AUTO; CSSValueListInspector inspector(value); switch (inspector.length()) { case 2: { // {2} | if (!inspector.first()->isPrimitiveValue() || !inspector.second()->isPrimitiveValue()) return; CSSPrimitiveValue* first = static_cast(inspector.first()); CSSPrimitiveValue* second = static_cast(inspector.second()); if (first->isLength()) { // {2} if (!second->isLength()) return; width = first->computeLength(styleResolver->style(), styleResolver->rootElementStyle()); height = second->computeLength(styleResolver->style(), styleResolver->rootElementStyle()); } else { // // The value order is guaranteed. See CSSParser::parseSizeParameter. if (!getPageSizeFromName(first, second, width, height)) return; } pageSizeType = PAGE_SIZE_RESOLVED; break; } case 1: { // | auto | | [ portrait | landscape] if (!inspector.first()->isPrimitiveValue()) return; CSSPrimitiveValue* primitiveValue = static_cast(inspector.first()); if (primitiveValue->isLength()) { // pageSizeType = PAGE_SIZE_RESOLVED; width = height = primitiveValue->computeLength(styleResolver->style(), styleResolver->rootElementStyle()); } else { switch (primitiveValue->getValueID()) { case 0: return; case CSSValueAuto: pageSizeType = PAGE_SIZE_AUTO; break; case CSSValuePortrait: pageSizeType = PAGE_SIZE_AUTO_PORTRAIT; break; case CSSValueLandscape: pageSizeType = PAGE_SIZE_AUTO_LANDSCAPE; break; default: // pageSizeType = PAGE_SIZE_RESOLVED; if (!getPageSizeFromName(primitiveValue, 0, width, height)) return; } } break; } default: return; } styleResolver->style()->setPageSizeType(pageSizeType); styleResolver->style()->setPageSize(LengthSize(width, height)); } static PropertyHandler createHandler() { return PropertyHandler(&applyInheritValue, &applyInitialValue, &applyValue); } }; class ApplyPropertyTextEmphasisStyle { public: static void applyInheritValue(CSSPropertyID, StyleResolver* styleResolver) { styleResolver->style()->setTextEmphasisFill(styleResolver->parentStyle()->textEmphasisFill()); styleResolver->style()->setTextEmphasisMark(styleResolver->parentStyle()->textEmphasisMark()); styleResolver->style()->setTextEmphasisCustomMark(styleResolver->parentStyle()->textEmphasisCustomMark()); } static void applyInitialValue(CSSPropertyID, StyleResolver* styleResolver) { styleResolver->style()->setTextEmphasisFill(RenderStyle::initialTextEmphasisFill()); styleResolver->style()->setTextEmphasisMark(RenderStyle::initialTextEmphasisMark()); styleResolver->style()->setTextEmphasisCustomMark(RenderStyle::initialTextEmphasisCustomMark()); } static void applyValue(CSSPropertyID, StyleResolver* styleResolver, CSSValue* value) { if (value->isValueList()) { CSSValueList* list = static_cast(value); ASSERT(list->length() == 2); if (list->length() != 2) return; for (unsigned i = 0; i < 2; ++i) { CSSValue* item = list->itemWithoutBoundsCheck(i); if (!item->isPrimitiveValue()) continue; CSSPrimitiveValue* value = static_cast(item); if (value->getValueID() == CSSValueFilled || value->getValueID() == CSSValueOpen) styleResolver->style()->setTextEmphasisFill(*value); else styleResolver->style()->setTextEmphasisMark(*value); } styleResolver->style()->setTextEmphasisCustomMark(nullAtom); return; } if (!value->isPrimitiveValue()) return; CSSPrimitiveValue* primitiveValue = static_cast(value); if (primitiveValue->isString()) { styleResolver->style()->setTextEmphasisFill(TextEmphasisFillFilled); styleResolver->style()->setTextEmphasisMark(TextEmphasisMarkCustom); styleResolver->style()->setTextEmphasisCustomMark(primitiveValue->getStringValue()); return; } styleResolver->style()->setTextEmphasisCustomMark(nullAtom); if (primitiveValue->getValueID() == CSSValueFilled || primitiveValue->getValueID() == CSSValueOpen) { styleResolver->style()->setTextEmphasisFill(*primitiveValue); styleResolver->style()->setTextEmphasisMark(TextEmphasisMarkAuto); } else { styleResolver->style()->setTextEmphasisFill(TextEmphasisFillFilled); styleResolver->style()->setTextEmphasisMark(*primitiveValue); } } static PropertyHandler createHandler() { return PropertyHandler(&applyInheritValue, &applyInitialValue, &applyValue); } }; template class ApplyPropertyAnimation { public: static void setValue(Animation* animation, T value) { (animation->*setterFunction)(value); } static T value(const Animation* animation) { return (animation->*getterFunction)(); } static bool test(const Animation* animation) { return (animation->*testFunction)(); } static void clear(Animation* animation) { (animation->*clearFunction)(); } static T initial() { return (*initialFunction)(); } static void map(StyleResolver* styleResolver, Animation* animation, CSSValue* value) { (styleResolver->styleMap()->*mapFunction)(animation, value); } static AnimationList* accessAnimations(RenderStyle* style) { return (style->*animationGetterFunction)(); } static const AnimationList* animations(RenderStyle* style) { return (style->*immutableAnimationGetterFunction)(); } static void applyInheritValue(CSSPropertyID, StyleResolver* styleResolver) { AnimationList* list = accessAnimations(styleResolver->style()); const AnimationList* parentList = animations(styleResolver->parentStyle()); size_t i = 0, parentSize = parentList ? parentList->size() : 0; for ( ; i < parentSize && test(parentList->animation(i)); ++i) { if (list->size() <= i) list->append(Animation::create()); setValue(list->animation(i), value(parentList->animation(i))); list->animation(i)->setAnimationMode(parentList->animation(i)->animationMode()); } /* Reset any remaining animations to not have the property set. */ for ( ; i < list->size(); ++i) clear(list->animation(i)); } static void applyInitialValue(CSSPropertyID propertyID, StyleResolver* styleResolver) { AnimationList* list = accessAnimations(styleResolver->style()); if (list->isEmpty()) list->append(Animation::create()); setValue(list->animation(0), initial()); if (propertyID == CSSPropertyWebkitTransitionProperty) list->animation(0)->setAnimationMode(Animation::AnimateAll); for (size_t i = 1; i < list->size(); ++i) clear(list->animation(i)); } static void applyValue(CSSPropertyID, StyleResolver* styleResolver, CSSValue* value) { AnimationList* list = accessAnimations(styleResolver->style()); size_t childIndex = 0; if (value->isValueList()) { /* Walk each value and put it into an animation, creating new animations as needed. */ for (CSSValueListIterator i = value; i.hasMore(); i.advance()) { if (childIndex <= list->size()) list->append(Animation::create()); map(styleResolver, list->animation(childIndex), i.value()); ++childIndex; } } else { if (list->isEmpty()) list->append(Animation::create()); map(styleResolver, list->animation(childIndex), value); childIndex = 1; } for ( ; childIndex < list->size(); ++childIndex) { /* Reset all remaining animations to not have the property set. */ clear(list->animation(childIndex)); } } static PropertyHandler createHandler() { return PropertyHandler(&applyInheritValue, &applyInitialValue, &applyValue); } }; class ApplyPropertyOutlineStyle { public: static void applyInheritValue(CSSPropertyID propertyID, StyleResolver* styleResolver) { ApplyPropertyDefaultBase::applyInheritValue(propertyID, styleResolver); ApplyPropertyDefaultBase::applyInheritValue(propertyID, styleResolver); } static void applyInitialValue(CSSPropertyID propertyID, StyleResolver* styleResolver) { ApplyPropertyDefaultBase::applyInitialValue(propertyID, styleResolver); ApplyPropertyDefaultBase::applyInitialValue(propertyID, styleResolver); } static void applyValue(CSSPropertyID propertyID, StyleResolver* styleResolver, CSSValue* value) { ApplyPropertyDefault::applyValue(propertyID, styleResolver, value); ApplyPropertyDefault::applyValue(propertyID, styleResolver, value); } static PropertyHandler createHandler() { return PropertyHandler(&applyInheritValue, &applyInitialValue, &applyValue); } }; class ApplyPropertyResize { public: static void applyValue(CSSPropertyID, StyleResolver* styleResolver, CSSValue* value) { if (!value->isPrimitiveValue()) return; CSSPrimitiveValue* primitiveValue = static_cast(value); EResize r = RESIZE_NONE; switch (primitiveValue->getValueID()) { case 0: return; case CSSValueAuto: if (Settings* settings = styleResolver->document()->settings()) r = settings->textAreasAreResizable() ? RESIZE_BOTH : RESIZE_NONE; break; default: r = *primitiveValue; } styleResolver->style()->setResize(r); } static PropertyHandler createHandler() { PropertyHandler handler = ApplyPropertyDefaultBase::createHandler(); return PropertyHandler(handler.inheritFunction(), handler.initialFunction(), &applyValue); } }; class ApplyPropertyVerticalAlign { public: static void applyValue(CSSPropertyID, StyleResolver* styleResolver, CSSValue* value) { if (!value->isPrimitiveValue()) return; CSSPrimitiveValue* primitiveValue = static_cast(value); if (primitiveValue->getValueID()) return styleResolver->style()->setVerticalAlign(*primitiveValue); styleResolver->style()->setVerticalAlignLength(primitiveValue->convertToLength(styleResolver->style(), styleResolver->rootElementStyle(), styleResolver->style()->effectiveZoom())); } static PropertyHandler createHandler() { PropertyHandler handler = ApplyPropertyDefaultBase::createHandler(); return PropertyHandler(handler.inheritFunction(), handler.initialFunction(), &applyValue); } }; class ApplyPropertyAspectRatio { public: static void applyInheritValue(CSSPropertyID, StyleResolver* styleResolver) { if (!styleResolver->parentStyle()->hasAspectRatio()) return; styleResolver->style()->setHasAspectRatio(true); styleResolver->style()->setAspectRatioDenominator(styleResolver->parentStyle()->aspectRatioDenominator()); styleResolver->style()->setAspectRatioNumerator(styleResolver->parentStyle()->aspectRatioNumerator()); } static void applyInitialValue(CSSPropertyID, StyleResolver* styleResolver) { styleResolver->style()->setHasAspectRatio(RenderStyle::initialHasAspectRatio()); styleResolver->style()->setAspectRatioDenominator(RenderStyle::initialAspectRatioDenominator()); styleResolver->style()->setAspectRatioNumerator(RenderStyle::initialAspectRatioNumerator()); } static void applyValue(CSSPropertyID, StyleResolver* styleResolver, CSSValue* value) { if (!value->isAspectRatioValue()) { styleResolver->style()->setHasAspectRatio(false); return; } CSSAspectRatioValue* aspectRatioValue = static_cast(value); styleResolver->style()->setHasAspectRatio(true); styleResolver->style()->setAspectRatioDenominator(aspectRatioValue->denominatorValue()); styleResolver->style()->setAspectRatioNumerator(aspectRatioValue->numeratorValue()); } static PropertyHandler createHandler() { return PropertyHandler(&applyInheritValue, &applyInitialValue, &applyValue); } }; class ApplyPropertyZoom { private: static void resetEffectiveZoom(StyleResolver* styleResolver) { // Reset the zoom in effect. This allows the setZoom method to accurately compute a new zoom in effect. styleResolver->setEffectiveZoom(styleResolver->parentStyle() ? styleResolver->parentStyle()->effectiveZoom() : RenderStyle::initialZoom()); } public: static void applyInheritValue(CSSPropertyID, StyleResolver* styleResolver) { resetEffectiveZoom(styleResolver); styleResolver->setZoom(styleResolver->parentStyle()->zoom()); } static void applyInitialValue(CSSPropertyID, StyleResolver* styleResolver) { resetEffectiveZoom(styleResolver); styleResolver->setZoom(RenderStyle::initialZoom()); } static void applyValue(CSSPropertyID, StyleResolver* styleResolver, CSSValue* value) { ASSERT_WITH_SECURITY_IMPLICATION(value->isPrimitiveValue()); CSSPrimitiveValue* primitiveValue = static_cast(value); if (primitiveValue->getValueID() == CSSValueNormal) { resetEffectiveZoom(styleResolver); styleResolver->setZoom(RenderStyle::initialZoom()); } else if (primitiveValue->getValueID() == CSSValueReset) { styleResolver->setEffectiveZoom(RenderStyle::initialZoom()); styleResolver->setZoom(RenderStyle::initialZoom()); } else if (primitiveValue->getValueID() == CSSValueDocument) { float docZoom = styleResolver->rootElementStyle() ? styleResolver->rootElementStyle()->zoom() : RenderStyle::initialZoom(); styleResolver->setEffectiveZoom(docZoom); styleResolver->setZoom(docZoom); } else if (primitiveValue->isPercentage()) { resetEffectiveZoom(styleResolver); if (float percent = primitiveValue->getFloatValue()) styleResolver->setZoom(percent / 100.0f); } else if (primitiveValue->isNumber()) { resetEffectiveZoom(styleResolver); if (float number = primitiveValue->getFloatValue()) styleResolver->setZoom(number); } } static PropertyHandler createHandler() { return PropertyHandler(&applyInheritValue, &applyInitialValue, &applyValue); } }; class ApplyPropertyDisplay { private: static inline bool isValidDisplayValue(StyleResolver* styleResolver, EDisplay displayPropertyValue) { #if ENABLE(SVG) if (styleResolver->element() && styleResolver->element()->isSVGElement() && styleResolver->style()->styleType() == NOPSEUDO) return (displayPropertyValue == INLINE || displayPropertyValue == BLOCK || displayPropertyValue == NONE); #else UNUSED_PARAM(styleResolver); UNUSED_PARAM(displayPropertyValue); #endif return true; } public: static void applyInheritValue(CSSPropertyID, StyleResolver* styleResolver) { EDisplay display = styleResolver->parentStyle()->display(); if (!isValidDisplayValue(styleResolver, display)) return; styleResolver->style()->setDisplay(display); } static void applyInitialValue(CSSPropertyID, StyleResolver* styleResolver) { styleResolver->style()->setDisplay(RenderStyle::initialDisplay()); } static void applyValue(CSSPropertyID, StyleResolver* styleResolver, CSSValue* value) { if (!value->isPrimitiveValue()) return; EDisplay display = *static_cast(value); if (!isValidDisplayValue(styleResolver, display)) return; styleResolver->style()->setDisplay(display); } static PropertyHandler createHandler() { return PropertyHandler(&applyInheritValue, &applyInitialValue, &applyValue); } }; template ), ClipPathOperation* (*initialFunction)()> class ApplyPropertyClipPath { public: static void setValue(RenderStyle* style, PassRefPtr value) { (style->*setterFunction)(value); } static void applyValue(CSSPropertyID, StyleResolver* styleResolver, CSSValue* value) { if (value->isPrimitiveValue()) { CSSPrimitiveValue* primitiveValue = static_cast(value); if (primitiveValue->getValueID() == CSSValueNone) setValue(styleResolver->style(), 0); else if (primitiveValue->isShape()) { setValue(styleResolver->style(), ShapeClipPathOperation::create(basicShapeForValue(styleResolver->style(), styleResolver->rootElementStyle(), primitiveValue->getShapeValue()))); } #if ENABLE(SVG) else if (primitiveValue->primitiveType() == CSSPrimitiveValue::CSS_URI) { String cssURLValue = primitiveValue->getStringValue(); KURL url = styleResolver->document()->completeURL(cssURLValue); // FIXME: It doesn't work with forward or external SVG references (see https://bugs.webkit.org/show_bug.cgi?id=90405) setValue(styleResolver->style(), ReferenceClipPathOperation::create(cssURLValue, url.fragmentIdentifier())); } #endif } } static PropertyHandler createHandler() { PropertyHandler handler = ApplyPropertyDefaultBase, setterFunction, ClipPathOperation*, initialFunction>::createHandler(); return PropertyHandler(handler.inheritFunction(), handler.initialFunction(), &applyValue); } }; #if ENABLE(CSS_SHAPES) template ), ShapeValue* (*initialFunction)()> class ApplyPropertyShape { public: static void setValue(RenderStyle* style, PassRefPtr value) { (style->*setterFunction)(value); } static void applyValue(CSSPropertyID property, StyleResolver* styleResolver, CSSValue* value) { if (value->isPrimitiveValue()) { CSSPrimitiveValue* primitiveValue = static_cast(value); if (primitiveValue->getValueID() == CSSValueAuto) setValue(styleResolver->style(), 0); // FIXME Bug 102571: Layout for the value 'outside-shape' is not yet implemented else if (primitiveValue->getValueID() == CSSValueOutsideShape) setValue(styleResolver->style(), ShapeValue::createOutsideValue()); else if (primitiveValue->isShape()) { RefPtr shape = ShapeValue::createShapeValue(basicShapeForValue(styleResolver->style(), styleResolver->rootElementStyle(), primitiveValue->getShapeValue())); setValue(styleResolver->style(), shape.release()); } } else if (value->isImageValue()) { RefPtr shape = ShapeValue::createImageValue(styleResolver->styleImage(property, value)); setValue(styleResolver->style(), shape.release()); } } static PropertyHandler createHandler() { PropertyHandler handler = ApplyPropertyDefaultBase, setterFunction, ShapeValue*, initialFunction>::createHandler(); return PropertyHandler(handler.inheritFunction(), handler.initialFunction(), &applyValue); } }; #endif #if ENABLE(CSS_IMAGE_RESOLUTION) class ApplyPropertyImageResolution { public: static void applyInheritValue(CSSPropertyID propertyID, StyleResolver* styleResolver) { ApplyPropertyDefaultBase::applyInheritValue(propertyID, styleResolver); ApplyPropertyDefaultBase::applyInheritValue(propertyID, styleResolver); ApplyPropertyDefaultBase::applyInheritValue(propertyID, styleResolver); } static void applyInitialValue(CSSPropertyID propertyID, StyleResolver* styleResolver) { ApplyPropertyDefaultBase::applyInitialValue(propertyID, styleResolver); ApplyPropertyDefaultBase::applyInitialValue(propertyID, styleResolver); ApplyPropertyDefaultBase::applyInitialValue(propertyID, styleResolver); } static void applyValue(CSSPropertyID, StyleResolver* styleResolver, CSSValue* value) { if (!value->isValueList()) return; CSSValueList* valueList = static_cast(value); ImageResolutionSource source = RenderStyle::initialImageResolutionSource(); ImageResolutionSnap snap = RenderStyle::initialImageResolutionSnap(); double resolution = RenderStyle::initialImageResolution(); for (size_t i = 0; i < valueList->length(); i++) { CSSValue* item = valueList->itemWithoutBoundsCheck(i); if (!item->isPrimitiveValue()) continue; CSSPrimitiveValue* primitiveValue = static_cast(item); if (primitiveValue->getValueID() == CSSValueFromImage) source = ImageResolutionFromImage; else if (primitiveValue->getValueID() == CSSValueSnap) snap = ImageResolutionSnapPixels; else resolution = primitiveValue->getDoubleValue(CSSPrimitiveValue::CSS_DPPX); } styleResolver->style()->setImageResolutionSource(source); styleResolver->style()->setImageResolutionSnap(snap); styleResolver->style()->setImageResolution(resolution); } static PropertyHandler createHandler() { return PropertyHandler(&applyInheritValue, &applyInitialValue, &applyValue); } }; #endif class ApplyPropertyTextIndent { public: static void applyInheritValue(CSSPropertyID, StyleResolver* styleResolver) { styleResolver->style()->setTextIndent(styleResolver->parentStyle()->textIndent()); #if ENABLE(CSS3_TEXT) styleResolver->style()->setTextIndentLine(styleResolver->parentStyle()->textIndentLine()); styleResolver->style()->setTextIndentType(styleResolver->parentStyle()->textIndentType()); #endif } static void applyInitialValue(CSSPropertyID, StyleResolver* styleResolver) { styleResolver->style()->setTextIndent(RenderStyle::initialTextIndent()); #if ENABLE(CSS3_TEXT) styleResolver->style()->setTextIndentLine(RenderStyle::initialTextIndentLine()); styleResolver->style()->setTextIndentType(RenderStyle::initialTextIndentType()); #endif } static void applyValue(CSSPropertyID, StyleResolver* styleResolver, CSSValue* value) { if (!value->isValueList()) return; Length lengthOrPercentageValue; #if ENABLE(CSS3_TEXT) TextIndentLine textIndentLineValue = RenderStyle::initialTextIndentLine(); TextIndentType textIndentTypeValue = RenderStyle::initialTextIndentType(); #endif CSSValueList* valueList = static_cast(value); for (size_t i = 0; i < valueList->length(); ++i) { CSSValue* item = valueList->itemWithoutBoundsCheck(i); if (!item->isPrimitiveValue()) continue; CSSPrimitiveValue* primitiveValue = static_cast(item); if (!primitiveValue->getValueID()) lengthOrPercentageValue = primitiveValue->convertToLength(styleResolver->style(), styleResolver->rootElementStyle(), styleResolver->style()->effectiveZoom()); #if ENABLE(CSS3_TEXT) else if (primitiveValue->getValueID() == CSSValueWebkitEachLine) textIndentLineValue = TextIndentEachLine; else if (primitiveValue->getValueID() == CSSValueWebkitHanging) textIndentTypeValue = TextIndentHanging; #endif } ASSERT(!lengthOrPercentageValue.isUndefined()); styleResolver->style()->setTextIndent(lengthOrPercentageValue); #if ENABLE(CSS3_TEXT) styleResolver->style()->setTextIndentLine(textIndentLineValue); styleResolver->style()->setTextIndentType(textIndentTypeValue); #endif } static PropertyHandler createHandler() { return PropertyHandler(&applyInheritValue, &applyInitialValue, &applyValue); } }; const DeprecatedStyleBuilder& DeprecatedStyleBuilder::sharedStyleBuilder() { DEFINE_STATIC_LOCAL(DeprecatedStyleBuilder, styleBuilderInstance, ()); return styleBuilderInstance; } DeprecatedStyleBuilder::DeprecatedStyleBuilder() { for (int i = 0; i < numCSSProperties; ++i) m_propertyMap[i] = PropertyHandler(); // Please keep CSS property list in alphabetical order. setPropertyHandler(CSSPropertyBackgroundAttachment, ApplyPropertyFillLayer::createHandler()); setPropertyHandler(CSSPropertyBackgroundClip, ApplyPropertyFillLayer::createHandler()); setPropertyHandler(CSSPropertyBackgroundColor, ApplyPropertyColor::createHandler()); setPropertyHandler(CSSPropertyBackgroundImage, ApplyPropertyFillLayer::createHandler()); setPropertyHandler(CSSPropertyBackgroundOrigin, ApplyPropertyFillLayer::createHandler()); setPropertyHandler(CSSPropertyBackgroundPositionX, ApplyPropertyFillLayer::createHandler()); setPropertyHandler(CSSPropertyBackgroundPositionY, ApplyPropertyFillLayer::createHandler()); setPropertyHandler(CSSPropertyBackgroundRepeatX, ApplyPropertyFillLayer::createHandler()); setPropertyHandler(CSSPropertyBackgroundRepeatY, ApplyPropertyFillLayer::createHandler()); setPropertyHandler(CSSPropertyBackgroundSize, ApplyPropertyFillLayer::createHandler()); setPropertyHandler(CSSPropertyBorderBottomColor, ApplyPropertyColor::createHandler()); setPropertyHandler(CSSPropertyBorderBottomLeftRadius, ApplyPropertyBorderRadius<&RenderStyle::borderBottomLeftRadius, &RenderStyle::setBorderBottomLeftRadius, &RenderStyle::initialBorderRadius>::createHandler()); setPropertyHandler(CSSPropertyBorderBottomRightRadius, ApplyPropertyBorderRadius<&RenderStyle::borderBottomRightRadius, &RenderStyle::setBorderBottomRightRadius, &RenderStyle::initialBorderRadius>::createHandler()); setPropertyHandler(CSSPropertyBorderBottomStyle, ApplyPropertyDefault::createHandler()); setPropertyHandler(CSSPropertyBorderBottomWidth, ApplyPropertyComputeLength::createHandler()); setPropertyHandler(CSSPropertyBorderCollapse, ApplyPropertyDefault::createHandler()); setPropertyHandler(CSSPropertyBorderImageOutset, ApplyPropertyBorderImageModifier::createHandler()); setPropertyHandler(CSSPropertyBorderImageRepeat, ApplyPropertyBorderImageModifier::createHandler()); setPropertyHandler(CSSPropertyBorderImageSlice, ApplyPropertyBorderImageModifier::createHandler()); setPropertyHandler(CSSPropertyBorderImageSource, ApplyPropertyBorderImageSource::createHandler()); setPropertyHandler(CSSPropertyBorderImageWidth, ApplyPropertyBorderImageModifier::createHandler()); setPropertyHandler(CSSPropertyBorderLeftColor, ApplyPropertyColor::createHandler()); setPropertyHandler(CSSPropertyBorderLeftStyle, ApplyPropertyDefault::createHandler()); setPropertyHandler(CSSPropertyBorderLeftWidth, ApplyPropertyComputeLength::createHandler()); setPropertyHandler(CSSPropertyBorderRightColor, ApplyPropertyColor::createHandler()); setPropertyHandler(CSSPropertyBorderRightStyle, ApplyPropertyDefault::createHandler()); setPropertyHandler(CSSPropertyBorderRightWidth, ApplyPropertyComputeLength::createHandler()); setPropertyHandler(CSSPropertyBorderTopColor, ApplyPropertyColor::createHandler()); setPropertyHandler(CSSPropertyBorderTopLeftRadius, ApplyPropertyBorderRadius<&RenderStyle::borderTopLeftRadius, &RenderStyle::setBorderTopLeftRadius, &RenderStyle::initialBorderRadius>::createHandler()); setPropertyHandler(CSSPropertyBorderTopRightRadius, ApplyPropertyBorderRadius<&RenderStyle::borderTopRightRadius, &RenderStyle::setBorderTopRightRadius, &RenderStyle::initialBorderRadius>::createHandler()); setPropertyHandler(CSSPropertyBorderTopStyle, ApplyPropertyDefault::createHandler()); setPropertyHandler(CSSPropertyBorderTopWidth, ApplyPropertyComputeLength::createHandler()); setPropertyHandler(CSSPropertyBottom, ApplyPropertyLength<&RenderStyle::bottom, &RenderStyle::setBottom, &RenderStyle::initialOffset, AutoEnabled>::createHandler()); setPropertyHandler(CSSPropertyBoxSizing, ApplyPropertyDefault::createHandler()); setPropertyHandler(CSSPropertyCaptionSide, ApplyPropertyDefault::createHandler()); setPropertyHandler(CSSPropertyClear, ApplyPropertyDefault::createHandler()); setPropertyHandler(CSSPropertyClip, ApplyPropertyClip::createHandler()); setPropertyHandler(CSSPropertyColor, ApplyPropertyColor::createHandler()); setPropertyHandler(CSSPropertyCounterIncrement, ApplyPropertyCounter::createHandler()); setPropertyHandler(CSSPropertyCounterReset, ApplyPropertyCounter::createHandler()); setPropertyHandler(CSSPropertyCursor, ApplyPropertyCursor::createHandler()); setPropertyHandler(CSSPropertyDirection, ApplyPropertyDirection<&RenderStyle::direction, &RenderStyle::setDirection, RenderStyle::initialDirection>::createHandler()); setPropertyHandler(CSSPropertyDisplay, ApplyPropertyDisplay::createHandler()); setPropertyHandler(CSSPropertyEmptyCells, ApplyPropertyDefault::createHandler()); setPropertyHandler(CSSPropertyFloat, ApplyPropertyDefault::createHandler()); setPropertyHandler(CSSPropertyFontFamily, ApplyPropertyFontFamily::createHandler()); setPropertyHandler(CSSPropertyFontSize, ApplyPropertyFontSize::createHandler()); setPropertyHandler(CSSPropertyFontStyle, ApplyPropertyFont::createHandler()); setPropertyHandler(CSSPropertyFontVariant, ApplyPropertyFont::createHandler()); setPropertyHandler(CSSPropertyFontWeight, ApplyPropertyFontWeight::createHandler()); setPropertyHandler(CSSPropertyHeight, ApplyPropertyLength<&RenderStyle::height, &RenderStyle::setHeight, &RenderStyle::initialSize, AutoEnabled, LegacyIntrinsicEnabled, IntrinsicDisabled, NoneDisabled, UndefinedDisabled>::createHandler()); #if ENABLE(CSS_IMAGE_ORIENTATION) setPropertyHandler(CSSPropertyImageOrientation, ApplyPropertyDefault::createHandler()); #endif setPropertyHandler(CSSPropertyImageRendering, ApplyPropertyDefault::createHandler()); #if ENABLE(CSS_IMAGE_RESOLUTION) setPropertyHandler(CSSPropertyImageResolution, ApplyPropertyImageResolution::createHandler()); #endif setPropertyHandler(CSSPropertyLeft, ApplyPropertyLength<&RenderStyle::left, &RenderStyle::setLeft, &RenderStyle::initialOffset, AutoEnabled>::createHandler()); setPropertyHandler(CSSPropertyLetterSpacing, ApplyPropertyComputeLength::createHandler()); setPropertyHandler(CSSPropertyLineHeight, ApplyPropertyLineHeight::createHandler()); setPropertyHandler(CSSPropertyListStyleImage, ApplyPropertyStyleImage<&RenderStyle::listStyleImage, &RenderStyle::setListStyleImage, &RenderStyle::initialListStyleImage, CSSPropertyListStyleImage>::createHandler()); setPropertyHandler(CSSPropertyListStylePosition, ApplyPropertyDefault::createHandler()); setPropertyHandler(CSSPropertyListStyleType, ApplyPropertyDefault::createHandler()); setPropertyHandler(CSSPropertyMarginBottom, ApplyPropertyLength<&RenderStyle::marginBottom, &RenderStyle::setMarginBottom, &RenderStyle::initialMargin, AutoEnabled>::createHandler()); setPropertyHandler(CSSPropertyMarginLeft, ApplyPropertyLength<&RenderStyle::marginLeft, &RenderStyle::setMarginLeft, &RenderStyle::initialMargin, AutoEnabled>::createHandler()); setPropertyHandler(CSSPropertyMarginRight, ApplyPropertyLength<&RenderStyle::marginRight, &RenderStyle::setMarginRight, &RenderStyle::initialMargin, AutoEnabled>::createHandler()); setPropertyHandler(CSSPropertyMarginTop, ApplyPropertyLength<&RenderStyle::marginTop, &RenderStyle::setMarginTop, &RenderStyle::initialMargin, AutoEnabled>::createHandler()); setPropertyHandler(CSSPropertyMaxHeight, ApplyPropertyLength<&RenderStyle::maxHeight, &RenderStyle::setMaxHeight, &RenderStyle::initialMaxSize, AutoEnabled, LegacyIntrinsicEnabled, IntrinsicDisabled, NoneEnabled, UndefinedEnabled>::createHandler()); setPropertyHandler(CSSPropertyMaxWidth, ApplyPropertyLength<&RenderStyle::maxWidth, &RenderStyle::setMaxWidth, &RenderStyle::initialMaxSize, AutoEnabled, LegacyIntrinsicEnabled, IntrinsicEnabled, NoneEnabled, UndefinedEnabled>::createHandler()); setPropertyHandler(CSSPropertyMinHeight, ApplyPropertyLength<&RenderStyle::minHeight, &RenderStyle::setMinHeight, &RenderStyle::initialMinSize, AutoEnabled, LegacyIntrinsicEnabled, IntrinsicDisabled>::createHandler()); setPropertyHandler(CSSPropertyMinWidth, ApplyPropertyLength<&RenderStyle::minWidth, &RenderStyle::setMinWidth, &RenderStyle::initialMinSize, AutoEnabled, LegacyIntrinsicEnabled, IntrinsicEnabled>::createHandler()); setPropertyHandler(CSSPropertyOpacity, ApplyPropertyDefault::createHandler()); setPropertyHandler(CSSPropertyOrphans, ApplyPropertyAuto::createHandler()); setPropertyHandler(CSSPropertyOutlineColor, ApplyPropertyColor::createHandler()); setPropertyHandler(CSSPropertyOutlineOffset, ApplyPropertyComputeLength::createHandler()); setPropertyHandler(CSSPropertyOutlineStyle, ApplyPropertyOutlineStyle::createHandler()); setPropertyHandler(CSSPropertyOutlineWidth, ApplyPropertyComputeLength::createHandler()); setPropertyHandler(CSSPropertyOverflowWrap, ApplyPropertyDefault::createHandler()); setPropertyHandler(CSSPropertyOverflowX, ApplyPropertyDefault::createHandler()); setPropertyHandler(CSSPropertyOverflowY, ApplyPropertyDefault::createHandler()); setPropertyHandler(CSSPropertyPaddingBottom, ApplyPropertyLength<&RenderStyle::paddingBottom, &RenderStyle::setPaddingBottom, &RenderStyle::initialPadding>::createHandler()); setPropertyHandler(CSSPropertyPaddingLeft, ApplyPropertyLength<&RenderStyle::paddingLeft, &RenderStyle::setPaddingLeft, &RenderStyle::initialPadding>::createHandler()); setPropertyHandler(CSSPropertyPaddingRight, ApplyPropertyLength<&RenderStyle::paddingRight, &RenderStyle::setPaddingRight, &RenderStyle::initialPadding>::createHandler()); setPropertyHandler(CSSPropertyPaddingTop, ApplyPropertyLength<&RenderStyle::paddingTop, &RenderStyle::setPaddingTop, &RenderStyle::initialPadding>::createHandler()); setPropertyHandler(CSSPropertyPageBreakAfter, ApplyPropertyDefault::createHandler()); setPropertyHandler(CSSPropertyPageBreakBefore, ApplyPropertyDefault::createHandler()); setPropertyHandler(CSSPropertyPageBreakInside, ApplyPropertyDefault::createHandler()); setPropertyHandler(CSSPropertyPointerEvents, ApplyPropertyDefault::createHandler()); setPropertyHandler(CSSPropertyPosition, ApplyPropertyDefault::createHandler()); setPropertyHandler(CSSPropertyResize, ApplyPropertyResize::createHandler()); setPropertyHandler(CSSPropertyRight, ApplyPropertyLength<&RenderStyle::right, &RenderStyle::setRight, &RenderStyle::initialOffset, AutoEnabled>::createHandler()); setPropertyHandler(CSSPropertySize, ApplyPropertyPageSize::createHandler()); setPropertyHandler(CSSPropertySpeak, ApplyPropertyDefault::createHandler()); setPropertyHandler(CSSPropertyTableLayout, ApplyPropertyDefault::createHandler()); setPropertyHandler(CSSPropertyTabSize, ApplyPropertyDefault::createHandler()); setPropertyHandler(CSSPropertyTextAlign, ApplyPropertyTextAlign::createHandler()); setPropertyHandler(CSSPropertyTextDecoration, ApplyPropertyTextDecoration::createHandler()); #if ENABLE(CSS3_TEXT) setPropertyHandler(CSSPropertyWebkitTextDecorationLine, ApplyPropertyTextDecoration::createHandler()); setPropertyHandler(CSSPropertyWebkitTextDecorationStyle, ApplyPropertyDefault::createHandler()); setPropertyHandler(CSSPropertyWebkitTextDecorationColor, ApplyPropertyColor::createHandler()); setPropertyHandler(CSSPropertyWebkitTextAlignLast, ApplyPropertyDefault::createHandler()); setPropertyHandler(CSSPropertyWebkitTextJustify, ApplyPropertyDefault::createHandler()); setPropertyHandler(CSSPropertyWebkitTextUnderlinePosition, ApplyPropertyTextUnderlinePosition::createHandler()); #endif // CSS3_TEXT setPropertyHandler(CSSPropertyTextIndent, ApplyPropertyTextIndent::createHandler()); setPropertyHandler(CSSPropertyTextOverflow, ApplyPropertyDefault::createHandler()); setPropertyHandler(CSSPropertyTextRendering, ApplyPropertyFont::createHandler()); setPropertyHandler(CSSPropertyTextTransform, ApplyPropertyDefault::createHandler()); setPropertyHandler(CSSPropertyTop, ApplyPropertyLength<&RenderStyle::top, &RenderStyle::setTop, &RenderStyle::initialOffset, AutoEnabled>::createHandler()); setPropertyHandler(CSSPropertyUnicodeBidi, ApplyPropertyDefault::createHandler()); setPropertyHandler(CSSPropertyVerticalAlign, ApplyPropertyVerticalAlign::createHandler()); setPropertyHandler(CSSPropertyVisibility, ApplyPropertyDefault::createHandler()); setPropertyHandler(CSSPropertyWebkitAnimationDelay, ApplyPropertyAnimation::createHandler()); setPropertyHandler(CSSPropertyWebkitAnimationDirection, ApplyPropertyAnimation::createHandler()); setPropertyHandler(CSSPropertyWebkitAnimationDuration, ApplyPropertyAnimation::createHandler()); setPropertyHandler(CSSPropertyWebkitAnimationFillMode, ApplyPropertyAnimation::createHandler()); setPropertyHandler(CSSPropertyWebkitAnimationIterationCount, ApplyPropertyAnimation::createHandler()); setPropertyHandler(CSSPropertyWebkitAnimationName, ApplyPropertyAnimation::createHandler()); setPropertyHandler(CSSPropertyWebkitAnimationPlayState, ApplyPropertyAnimation::createHandler()); setPropertyHandler(CSSPropertyWebkitAnimationTimingFunction, ApplyPropertyAnimation, &Animation::timingFunction, &Animation::setTimingFunction, &Animation::isTimingFunctionSet, &Animation::clearTimingFunction, &Animation::initialAnimationTimingFunction, &CSSToStyleMap::mapAnimationTimingFunction, &RenderStyle::accessAnimations, &RenderStyle::animations>::createHandler()); setPropertyHandler(CSSPropertyWebkitAppearance, ApplyPropertyDefault::createHandler()); setPropertyHandler(CSSPropertyWebkitAspectRatio, ApplyPropertyAspectRatio::createHandler()); setPropertyHandler(CSSPropertyWebkitBackfaceVisibility, ApplyPropertyDefault::createHandler()); setPropertyHandler(CSSPropertyWebkitBackgroundBlendMode, ApplyPropertyFillLayer::createHandler()); setPropertyHandler(CSSPropertyWebkitBackgroundClip, CSSPropertyBackgroundClip); setPropertyHandler(CSSPropertyWebkitBackgroundComposite, ApplyPropertyFillLayer::createHandler()); setPropertyHandler(CSSPropertyWebkitBackgroundOrigin, CSSPropertyBackgroundOrigin); setPropertyHandler(CSSPropertyWebkitBackgroundSize, CSSPropertyBackgroundSize); #if ENABLE(CSS_COMPOSITING) setPropertyHandler(CSSPropertyWebkitBlendMode, ApplyPropertyDefault::createHandler()); #endif setPropertyHandler(CSSPropertyWebkitBorderFit, ApplyPropertyDefault::createHandler()); setPropertyHandler(CSSPropertyWebkitBorderHorizontalSpacing, ApplyPropertyComputeLength::createHandler()); setPropertyHandler(CSSPropertyWebkitBorderImage, ApplyPropertyBorderImage::createHandler()); setPropertyHandler(CSSPropertyWebkitBorderVerticalSpacing, ApplyPropertyComputeLength::createHandler()); setPropertyHandler(CSSPropertyWebkitBoxAlign, ApplyPropertyDefault::createHandler()); #if ENABLE(CSS_BOX_DECORATION_BREAK) setPropertyHandler(CSSPropertyWebkitBoxDecorationBreak, ApplyPropertyDefault::createHandler()); #endif setPropertyHandler(CSSPropertyWebkitBoxDirection, ApplyPropertyDefault::createHandler()); setPropertyHandler(CSSPropertyWebkitBoxFlex, ApplyPropertyDefault::createHandler()); setPropertyHandler(CSSPropertyWebkitBoxFlexGroup, ApplyPropertyDefault::createHandler()); setPropertyHandler(CSSPropertyWebkitBoxLines, ApplyPropertyDefault::createHandler()); setPropertyHandler(CSSPropertyWebkitBoxOrdinalGroup, ApplyPropertyDefault::createHandler()); setPropertyHandler(CSSPropertyWebkitBoxOrient, ApplyPropertyDefault::createHandler()); setPropertyHandler(CSSPropertyWebkitBoxPack, ApplyPropertyDefault::createHandler()); setPropertyHandler(CSSPropertyWebkitColorCorrection, ApplyPropertyDefault::createHandler()); setPropertyHandler(CSSPropertyWebkitColumnAxis, ApplyPropertyDefault::createHandler()); setPropertyHandler(CSSPropertyWebkitColumnBreakAfter, ApplyPropertyDefault::createHandler()); setPropertyHandler(CSSPropertyWebkitColumnBreakBefore, ApplyPropertyDefault::createHandler()); setPropertyHandler(CSSPropertyWebkitColumnBreakInside, ApplyPropertyDefault::createHandler()); setPropertyHandler(CSSPropertyWebkitColumnCount, ApplyPropertyAuto::createHandler()); setPropertyHandler(CSSPropertyWebkitColumnGap, ApplyPropertyAuto::createHandler()); setPropertyHandler(CSSPropertyWebkitColumnProgression, ApplyPropertyDefault::createHandler()); setPropertyHandler(CSSPropertyWebkitColumnRuleColor, ApplyPropertyColor::createHandler()); setPropertyHandler(CSSPropertyWebkitColumnRuleWidth, ApplyPropertyComputeLength::createHandler()); setPropertyHandler(CSSPropertyWebkitColumnSpan, ApplyPropertyDefault::createHandler()); setPropertyHandler(CSSPropertyWebkitColumnRuleStyle, ApplyPropertyDefault::createHandler()); setPropertyHandler(CSSPropertyWebkitColumnWidth, ApplyPropertyAuto::createHandler()); #if ENABLE(CURSOR_VISIBILITY) setPropertyHandler(CSSPropertyWebkitCursorVisibility, ApplyPropertyDefault::createHandler()); #endif setPropertyHandler(CSSPropertyAlignContent, ApplyPropertyDefault::createHandler()); setPropertyHandler(CSSPropertyAlignItems, ApplyPropertyDefault::createHandler()); setPropertyHandler(CSSPropertyAlignSelf, ApplyPropertyDefault::createHandler()); setPropertyHandler(CSSPropertyFlexBasis, ApplyPropertyLength<&RenderStyle::flexBasis, &RenderStyle::setFlexBasis, &RenderStyle::initialFlexBasis, AutoEnabled>::createHandler()); setPropertyHandler(CSSPropertyFlexDirection, ApplyPropertyDefault::createHandler()); setPropertyHandler(CSSPropertyFlexGrow, ApplyPropertyDefault::createHandler()); setPropertyHandler(CSSPropertyFlexShrink, ApplyPropertyDefault::createHandler()); setPropertyHandler(CSSPropertyFlexWrap, ApplyPropertyDefault::createHandler()); setPropertyHandler(CSSPropertyWebkitGridAutoFlow, ApplyPropertyDefault::createHandler()); setPropertyHandler(CSSPropertyJustifyContent, ApplyPropertyDefault::createHandler()); setPropertyHandler(CSSPropertyOrder, ApplyPropertyDefault::createHandler()); #if ENABLE(CSS_REGIONS) setPropertyHandler(CSSPropertyWebkitFlowFrom, ApplyPropertyString::createHandler()); setPropertyHandler(CSSPropertyWebkitFlowInto, ApplyPropertyString::createHandler()); #endif setPropertyHandler(CSSPropertyWebkitFontKerning, ApplyPropertyFont::createHandler()); setPropertyHandler(CSSPropertyWebkitFontSmoothing, ApplyPropertyFont::createHandler()); setPropertyHandler(CSSPropertyWebkitFontVariantLigatures, ApplyPropertyFontVariantLigatures::createHandler()); setPropertyHandler(CSSPropertyWebkitHighlight, ApplyPropertyString::createHandler()); setPropertyHandler(CSSPropertyWebkitHyphenateCharacter, ApplyPropertyString::createHandler()); setPropertyHandler(CSSPropertyWebkitHyphenateLimitAfter, ApplyPropertyNumber::createHandler()); setPropertyHandler(CSSPropertyWebkitHyphenateLimitBefore, ApplyPropertyNumber::createHandler()); setPropertyHandler(CSSPropertyWebkitHyphenateLimitLines, ApplyPropertyNumber::createHandler()); setPropertyHandler(CSSPropertyWebkitHyphens, ApplyPropertyDefault::createHandler()); setPropertyHandler(CSSPropertyWebkitLineAlign, ApplyPropertyDefault::createHandler()); setPropertyHandler(CSSPropertyWebkitLineBreak, ApplyPropertyDefault::createHandler()); setPropertyHandler(CSSPropertyWebkitLineClamp, ApplyPropertyDefault::createHandler()); setPropertyHandler(CSSPropertyWebkitLineGrid, ApplyPropertyString::createHandler()); setPropertyHandler(CSSPropertyWebkitLineSnap, ApplyPropertyDefault::createHandler()); setPropertyHandler(CSSPropertyWebkitMarginAfterCollapse, ApplyPropertyDefault::createHandler()); setPropertyHandler(CSSPropertyWebkitMarginBeforeCollapse, ApplyPropertyDefault::createHandler()); setPropertyHandler(CSSPropertyWebkitMarginBottomCollapse, CSSPropertyWebkitMarginAfterCollapse); setPropertyHandler(CSSPropertyWebkitMarginTopCollapse, CSSPropertyWebkitMarginBeforeCollapse); setPropertyHandler(CSSPropertyWebkitMarqueeDirection, ApplyPropertyDefault::createHandler()); setPropertyHandler(CSSPropertyWebkitMarqueeIncrement, ApplyPropertyMarqueeIncrement::createHandler()); setPropertyHandler(CSSPropertyWebkitMarqueeRepetition, ApplyPropertyMarqueeRepetition::createHandler()); setPropertyHandler(CSSPropertyWebkitMarqueeSpeed, ApplyPropertyMarqueeSpeed::createHandler()); setPropertyHandler(CSSPropertyWebkitMarqueeStyle, ApplyPropertyDefault::createHandler()); setPropertyHandler(CSSPropertyWebkitMaskBoxImage, ApplyPropertyBorderImage::createHandler()); setPropertyHandler(CSSPropertyWebkitMaskBoxImageOutset, ApplyPropertyBorderImageModifier::createHandler()); setPropertyHandler(CSSPropertyWebkitMaskBoxImageRepeat, ApplyPropertyBorderImageModifier::createHandler()); setPropertyHandler(CSSPropertyWebkitMaskBoxImageSlice, ApplyPropertyBorderImageModifier::createHandler()); setPropertyHandler(CSSPropertyWebkitMaskBoxImageSource, ApplyPropertyBorderImageSource::createHandler()); setPropertyHandler(CSSPropertyWebkitMaskBoxImageWidth, ApplyPropertyBorderImageModifier::createHandler()); setPropertyHandler(CSSPropertyWebkitMaskClip, ApplyPropertyFillLayer::createHandler()); setPropertyHandler(CSSPropertyWebkitMaskComposite, ApplyPropertyFillLayer::createHandler()); setPropertyHandler(CSSPropertyWebkitMaskImage, ApplyPropertyFillLayer::createHandler()); setPropertyHandler(CSSPropertyWebkitMaskOrigin, ApplyPropertyFillLayer::createHandler()); setPropertyHandler(CSSPropertyWebkitMaskPositionX, ApplyPropertyFillLayer::createHandler()); setPropertyHandler(CSSPropertyWebkitMaskPositionY, ApplyPropertyFillLayer::createHandler()); setPropertyHandler(CSSPropertyWebkitMaskRepeatX, ApplyPropertyFillLayer::createHandler()); setPropertyHandler(CSSPropertyWebkitMaskRepeatY, ApplyPropertyFillLayer::createHandler()); setPropertyHandler(CSSPropertyWebkitMaskSize, ApplyPropertyFillLayer::createHandler()); setPropertyHandler(CSSPropertyWebkitNbspMode, ApplyPropertyDefault::createHandler()); setPropertyHandler(CSSPropertyWebkitPerspectiveOrigin, ApplyPropertyExpanding::createHandler()); setPropertyHandler(CSSPropertyWebkitPerspectiveOriginX, ApplyPropertyLength<&RenderStyle::perspectiveOriginX, &RenderStyle::setPerspectiveOriginX, &RenderStyle::initialPerspectiveOriginX>::createHandler()); setPropertyHandler(CSSPropertyWebkitPerspectiveOriginY, ApplyPropertyLength<&RenderStyle::perspectiveOriginY, &RenderStyle::setPerspectiveOriginY, &RenderStyle::initialPerspectiveOriginY>::createHandler()); setPropertyHandler(CSSPropertyWebkitPrintColorAdjust, ApplyPropertyDefault::createHandler()); #if ENABLE(CSS_REGIONS) setPropertyHandler(CSSPropertyWebkitRegionBreakAfter, ApplyPropertyDefault::createHandler()); setPropertyHandler(CSSPropertyWebkitRegionBreakBefore, ApplyPropertyDefault::createHandler()); setPropertyHandler(CSSPropertyWebkitRegionBreakInside, ApplyPropertyDefault::createHandler()); setPropertyHandler(CSSPropertyWebkitRegionFragment, ApplyPropertyDefault::createHandler()); #endif setPropertyHandler(CSSPropertyWebkitRtlOrdering, ApplyPropertyDefault::createHandler()); setPropertyHandler(CSSPropertyWebkitRubyPosition, ApplyPropertyDefault::createHandler()); setPropertyHandler(CSSPropertyWebkitTextCombine, ApplyPropertyDefault::createHandler()); setPropertyHandler(CSSPropertyWebkitTextEmphasisColor, ApplyPropertyColor::createHandler()); setPropertyHandler(CSSPropertyWebkitTextEmphasisPosition, ApplyPropertyDefault::createHandler()); setPropertyHandler(CSSPropertyWebkitTextEmphasisStyle, ApplyPropertyTextEmphasisStyle::createHandler()); setPropertyHandler(CSSPropertyWebkitTextFillColor, ApplyPropertyColor::createHandler()); setPropertyHandler(CSSPropertyWebkitTextSecurity, ApplyPropertyDefault::createHandler()); setPropertyHandler(CSSPropertyWebkitTextStrokeColor, ApplyPropertyColor::createHandler()); setPropertyHandler(CSSPropertyWebkitTransformOriginX, ApplyPropertyLength<&RenderStyle::transformOriginX, &RenderStyle::setTransformOriginX, &RenderStyle::initialTransformOriginX>::createHandler()); setPropertyHandler(CSSPropertyWebkitTransformOriginY, ApplyPropertyLength<&RenderStyle::transformOriginY, &RenderStyle::setTransformOriginY, &RenderStyle::initialTransformOriginY>::createHandler()); setPropertyHandler(CSSPropertyWebkitTransformOriginZ, ApplyPropertyComputeLength::createHandler()); setPropertyHandler(CSSPropertyWebkitTransformStyle, ApplyPropertyDefault::createHandler()); setPropertyHandler(CSSPropertyWebkitTransitionDelay, ApplyPropertyAnimation::createHandler()); setPropertyHandler(CSSPropertyWebkitTransitionDuration, ApplyPropertyAnimation::createHandler()); setPropertyHandler(CSSPropertyWebkitTransitionProperty, ApplyPropertyAnimation::createHandler()); setPropertyHandler(CSSPropertyWebkitTransitionTimingFunction, ApplyPropertyAnimation, &Animation::timingFunction, &Animation::setTimingFunction, &Animation::isTimingFunctionSet, &Animation::clearTimingFunction, &Animation::initialAnimationTimingFunction, &CSSToStyleMap::mapAnimationTimingFunction, &RenderStyle::accessTransitions, &RenderStyle::transitions>::createHandler()); setPropertyHandler(CSSPropertyWebkitUserDrag, ApplyPropertyDefault::createHandler()); setPropertyHandler(CSSPropertyWebkitUserModify, ApplyPropertyDefault::createHandler()); setPropertyHandler(CSSPropertyWebkitUserSelect, ApplyPropertyDefault::createHandler()); setPropertyHandler(CSSPropertyWebkitClipPath, ApplyPropertyClipPath<&RenderStyle::clipPath, &RenderStyle::setClipPath, &RenderStyle::initialClipPath>::createHandler()); #if ENABLE(CSS_EXCLUSIONS) setPropertyHandler(CSSPropertyWebkitWrapFlow, ApplyPropertyDefault::createHandler()); setPropertyHandler(CSSPropertyWebkitWrapThrough, ApplyPropertyDefault::createHandler()); #endif #if ENABLE(CSS_SHAPES) setPropertyHandler(CSSPropertyWebkitShapeMargin, ApplyPropertyLength<&RenderStyle::shapeMargin, &RenderStyle::setShapeMargin, &RenderStyle::initialShapeMargin>::createHandler()); setPropertyHandler(CSSPropertyWebkitShapePadding, ApplyPropertyLength<&RenderStyle::shapePadding, &RenderStyle::setShapePadding, &RenderStyle::initialShapePadding>::createHandler()); setPropertyHandler(CSSPropertyWebkitShapeInside, ApplyPropertyShape<&RenderStyle::shapeInside, &RenderStyle::setShapeInside, &RenderStyle::initialShapeInside>::createHandler()); setPropertyHandler(CSSPropertyWebkitShapeOutside, ApplyPropertyShape<&RenderStyle::shapeOutside, &RenderStyle::setShapeOutside, &RenderStyle::initialShapeOutside>::createHandler()); #endif setPropertyHandler(CSSPropertyWhiteSpace, ApplyPropertyDefault::createHandler()); setPropertyHandler(CSSPropertyWidows, ApplyPropertyAuto::createHandler()); setPropertyHandler(CSSPropertyWidth, ApplyPropertyLength<&RenderStyle::width, &RenderStyle::setWidth, &RenderStyle::initialSize, AutoEnabled, LegacyIntrinsicEnabled, IntrinsicEnabled, NoneDisabled, UndefinedDisabled>::createHandler()); setPropertyHandler(CSSPropertyWordBreak, ApplyPropertyDefault::createHandler()); setPropertyHandler(CSSPropertyWordSpacing, ApplyPropertyComputeLength::createHandler()); // UAs must treat 'word-wrap' as an alternate name for the 'overflow-wrap' property. So using the same handlers. setPropertyHandler(CSSPropertyWordWrap, ApplyPropertyDefault::createHandler()); setPropertyHandler(CSSPropertyZIndex, ApplyPropertyAuto::createHandler()); setPropertyHandler(CSSPropertyZoom, ApplyPropertyZoom::createHandler()); } }