Changeset 143556 in webkit
- Timestamp:
- Feb 20, 2013 7:39:42 PM (11 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 13 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r143555 r143556 1 2013-02-20 Takashi Sakamoto <tasak@google.com> 2 3 [Refactoring] Make m_state an on-stack object 4 https://bugs.webkit.org/show_bug.cgi?id=109909 5 6 Reviewed by Antti Koivisto. 7 8 Mode m_state, an instance of StyleResolver::State, an on-stack object. 9 The state is only required in styleForElement, styleForKeyframe and 10 so on. No need to keep the state outside of those methods. 11 12 No new tests, because just refactoring. 13 14 * css/BasicShapeFunctions.cpp: 15 (WebCore::convertToLength): 16 (WebCore::basicShapeForValue): 17 * css/BasicShapeFunctions.h: 18 (WebCore): 19 Replaced StyleResolver* with StyleResolver::State&. 20 * css/CSSGradientValue.cpp: 21 (WebCore::CSSGradientValue::gradientWithStylesResolved): 22 * css/CSSGradientValue.h: 23 (CSSGradientValue): 24 Replaced StyleResolver* with StyleResolver::State&. 25 * css/CSSToStyleMap.cpp: 26 (WebCore::CSSToStyleMap::style): 27 (WebCore::CSSToStyleMap::rootElementStyle): 28 (WebCore::CSSToStyleMap::useSVGZoomRules): 29 (WebCore::CSSToStyleMap::styleImage): 30 * css/CSSToStyleMap.h: 31 (WebCore): 32 (WebCore::CSSToStyleMap::CSSToStyleMap): 33 (CSSToStyleMap): 34 Replaced StyleResolver* with StyleResolver::State&. 35 * css/SVGCSSStyleSelector.cpp: 36 (WebCore::StyleResolver::applySVGProperty): 37 Replaced m_state with state which is given as an argument of 38 applySVGProperty. 39 * css/StyleBuilder.cpp: 40 (WebCore::ApplyPropertyExpanding::applyInheritValue): 41 (WebCore::ApplyPropertyExpanding::applyInitialValue): 42 (WebCore::ApplyPropertyExpanding::applyValue): 43 (WebCore::ApplyPropertyDefaultBase::applyInheritValue): 44 (WebCore::ApplyPropertyDefaultBase::applyInitialValue): 45 (WebCore::ApplyPropertyDefaultBase::applyValue): 46 (WebCore::ApplyPropertyDefault::applyValue): 47 (WebCore::ApplyPropertyNumber::applyValue): 48 (WebCore::ApplyPropertyStyleImage::applyValue): 49 (WebCore::ApplyPropertyAuto::applyInheritValue): 50 (WebCore::ApplyPropertyAuto::applyInitialValue): 51 (WebCore::ApplyPropertyAuto::applyValue): 52 (WebCore::ApplyPropertyClip::convertToLength): 53 (WebCore::ApplyPropertyClip::applyInheritValue): 54 (WebCore::ApplyPropertyClip::applyInitialValue): 55 (WebCore::ApplyPropertyClip::applyValue): 56 (WebCore::ApplyPropertyColor::applyInheritValue): 57 (WebCore::ApplyPropertyColor::applyInitialValue): 58 (WebCore::ApplyPropertyColor::applyValue): 59 (WebCore::ApplyPropertyColor::applyColorValue): 60 (WebCore::ApplyPropertyDirection::applyValue): 61 (WebCore::ApplyPropertyLength::applyValue): 62 (WebCore::ApplyPropertyString::applyValue): 63 (WebCore::ApplyPropertyBorderRadius::applyValue): 64 (WebCore::ApplyPropertyFillLayer::applyInheritValue): 65 (WebCore::ApplyPropertyFillLayer::applyInitialValue): 66 (WebCore::ApplyPropertyFillLayer::applyValue): 67 (WebCore::ApplyPropertyComputeLength::applyValue): 68 (WebCore::ApplyPropertyFont::applyInheritValue): 69 (WebCore::ApplyPropertyFont::applyInitialValue): 70 (WebCore::ApplyPropertyFont::applyValue): 71 (WebCore::ApplyPropertyFontSize::applyInheritValue): 72 (WebCore::ApplyPropertyFontSize::applyInitialValue): 73 (WebCore::ApplyPropertyFontSize::applyValue): 74 (WebCore::ApplyPropertyFontWeight::applyValue): 75 (WebCore::ApplyPropertyFontVariantLigatures::applyInheritValue): 76 (WebCore::ApplyPropertyFontVariantLigatures::applyInitialValue): 77 (WebCore::ApplyPropertyFontVariantLigatures::applyValue): 78 (WebCore::ApplyPropertyBorderImage::applyValue): 79 (WebCore::ApplyPropertyBorderImageModifier::applyInheritValue): 80 (WebCore::ApplyPropertyBorderImageModifier::applyInitialValue): 81 (WebCore::ApplyPropertyBorderImageModifier::applyValue): 82 (WebCore::ApplyPropertyBorderImageSource::applyValue): 83 (WebCore::ApplyPropertyCounter::emptyFunction): 84 (WebCore::ApplyPropertyCounter::applyInheritValue): 85 (WebCore::ApplyPropertyCounter::applyValue): 86 (WebCore::ApplyPropertyCursor::applyInheritValue): 87 (WebCore::ApplyPropertyCursor::applyInitialValue): 88 (WebCore::ApplyPropertyCursor::applyValue): 89 (WebCore::ApplyPropertyTextAlign::applyValue): 90 (WebCore::ApplyPropertyTextDecoration::applyValue): 91 (WebCore::ApplyPropertyLineHeight::applyValue): 92 (WebCore::ApplyPropertyPageSize::applyInheritValue): 93 (WebCore::ApplyPropertyPageSize::applyInitialValue): 94 (WebCore::ApplyPropertyPageSize::applyValue): 95 (WebCore::ApplyPropertyTextEmphasisStyle::applyInheritValue): 96 (WebCore::ApplyPropertyTextEmphasisStyle::applyInitialValue): 97 (WebCore::ApplyPropertyTextEmphasisStyle::applyValue): 98 (WebCore::ApplyPropertyAnimation::map): 99 (WebCore::ApplyPropertyAnimation::applyInheritValue): 100 (WebCore::ApplyPropertyAnimation::applyInitialValue): 101 (WebCore::ApplyPropertyAnimation::applyValue): 102 (WebCore::ApplyPropertyOutlineStyle::applyInheritValue): 103 (WebCore::ApplyPropertyOutlineStyle::applyInitialValue): 104 (WebCore::ApplyPropertyOutlineStyle::applyValue): 105 (WebCore::ApplyPropertyResize::applyValue): 106 (WebCore::ApplyPropertyVerticalAlign::applyValue): 107 (WebCore::ApplyPropertyAspectRatio::applyInheritValue): 108 (WebCore::ApplyPropertyAspectRatio::applyInitialValue): 109 (WebCore::ApplyPropertyAspectRatio::applyValue): 110 (WebCore::ApplyPropertyZoom::resetEffectiveZoom): 111 (WebCore::ApplyPropertyZoom::applyInheritValue): 112 (WebCore::ApplyPropertyZoom::applyInitialValue): 113 (WebCore::ApplyPropertyZoom::applyValue): 114 (WebCore::ApplyPropertyDisplay::isValidDisplayValue): 115 (WebCore::ApplyPropertyDisplay::applyInheritValue): 116 (WebCore::ApplyPropertyDisplay::applyInitialValue): 117 (WebCore::ApplyPropertyDisplay::applyValue): 118 (WebCore::ApplyPropertyClipPath::applyValue): 119 (WebCore::ApplyPropertyExclusionShape::applyValue): 120 (WebCore::ApplyPropertyImageResolution::applyInheritValue): 121 (WebCore::ApplyPropertyImageResolution::applyInitialValue): 122 (WebCore::ApplyPropertyImageResolution::applyValue): 123 * css/StyleBuilder.h: 124 (WebCore): 125 (PropertyHandler): 126 (WebCore::PropertyHandler::applyInheritValue): 127 (WebCore::PropertyHandler::applyInitialValue): 128 (WebCore::PropertyHandler::applyValue): 129 Replaced StyleResolver* with StyleResolver::State&. 130 * css/StyleResolver.cpp: 131 (WebCore): 132 (WebCore::StyleResolver::StyleResolver): 133 Removed m_styleMap. Now m_styleMap is an on-stack object. 134 (WebCore::StyleResolver::collectMatchingRules): 135 (WebCore::StyleResolver::collectMatchingRulesForRegion): 136 (WebCore::StyleResolver::sortAndTransferMatchedRules): 137 (WebCore::StyleResolver::matchScopedAuthorRules): 138 (WebCore::StyleResolver::styleSharingCandidateMatchesHostRules): 139 (WebCore::StyleResolver::matchHostRules): 140 (WebCore::StyleResolver::matchAuthorRules): 141 (WebCore::StyleResolver::matchUserRules): 142 (WebCore::StyleResolver::matchUARules): 143 (WebCore::StyleResolver::collectMatchingRulesForList): 144 (WebCore::StyleResolver::sortMatchedRules): 145 (WebCore::StyleResolver::matchAllRules): 146 (WebCore::StyleResolver::initElement): 147 (WebCore::StyleResolver::styleSharingCandidateMatchesRuleSet): 148 (WebCore::StyleResolver::canShareStyleWithControl): 149 (WebCore::StyleResolver::sharingCandidateHasIdenticalStyleAffectingAttributes): 150 (WebCore::StyleResolver::canShareStyleWithElement): 151 (WebCore::StyleResolver::findSiblingForStyleSharing): 152 (WebCore::StyleResolver::locateSharedStyle): 153 (WebCore::StyleResolver::styleForElement): 154 (WebCore::StyleResolver::styleForKeyframe): 155 (WebCore::StyleResolver::keyframeStylesForAnimation): 156 (WebCore::StyleResolver::pseudoStyleForElement): 157 (WebCore::StyleResolver::styleForPage): 158 (WebCore::StyleResolver::defaultStyleForElement): 159 (WebCore::StyleResolver::adjustRenderStyle): 160 (WebCore::StyleResolver::updateFont): 161 (WebCore::StyleResolver::pseudoStyleRulesForElement): 162 (WebCore::StyleResolver::ruleMatches): 163 (WebCore::StyleResolver::checkRegionSelector): 164 (WebCore::StyleResolver::applyProperties): 165 (WebCore::StyleResolver::applyMatchedProperties): 166 (WebCore::StyleResolver::isLeftPage): 167 (WebCore::StyleResolver::applyPropertyWithNullCheck): 168 (WebCore::StyleResolver::applyFontPropertyToStyle): 169 (WebCore::StyleResolver::resolveVariables): 170 (WebCore::StyleResolver::applyProperty): 171 (WebCore::StyleResolver::styleImage): 172 (WebCore::StyleResolver::cachedOrPendingFromValue): 173 (WebCore::StyleResolver::generatedOrPendingFromValue): 174 (WebCore::StyleResolver::setOrPendingFromValue): 175 (WebCore::StyleResolver::cursorOrPendingFromValue): 176 (WebCore::StyleResolver::checkForTextSizeAdjust): 177 (WebCore::StyleResolver::checkForZoomChange): 178 (WebCore::StyleResolver::checkForGenericFamilyChange): 179 (WebCore::StyleResolver::initializeFontStyle): 180 (WebCore::StyleResolver::setFontSize): 181 (WebCore::StyleResolver::colorFromPrimitiveValue): 182 (WebCore::StyleResolver::loadPendingSVGDocuments): 183 (WebCore::StyleResolver::styleShader): 184 (WebCore::StyleResolver::cachedOrPendingStyleShaderFromValue): 185 (WebCore::StyleResolver::loadPendingShaders): 186 (WebCore::StyleResolver::parseCustomFilterTransformParameter): 187 (WebCore::StyleResolver::parseCustomFilterParameter): 188 (WebCore::StyleResolver::parseCustomFilterParameterList): 189 (WebCore::StyleResolver::createCustomFilterOperationWithInlineSyntax): 190 (WebCore::StyleResolver::createCustomFilterOperation): 191 (WebCore::StyleResolver::createFilterOperations): 192 (WebCore::StyleResolver::loadPendingImage): 193 (WebCore::StyleResolver::loadPendingImages): 194 (WebCore::StyleResolver::loadPendingResources): 195 Just replaced m_state with state and added one more parameter to 196 provide the state. 197 (WebCore::StyleResolver::reportMemoryUsage): 198 Since m_state was removed, removed a code for reporting m_state's 199 memory usage. 200 * css/StyleResolver.h: 201 (StyleResolver): 202 (WebCore::StyleResolver::isRightPage): 203 (WebCore::StyleResolver::State::State): 204 (WebCore::StyleResolver::State::document): 205 Since State::m_element is not always available (sometimes, 0), 206 added m_document to State and modified to return the m_document. 207 (WebCore::StyleResolver::State::useSVGZoomRules): 208 Moved StyleResolver to State. 209 (State): 210 * html/canvas/CanvasRenderingContext2D.cpp: 211 (WebCore::CanvasRenderingContext2D::setFont): 212 Moved the code, updating a style by using a given StylePropertySet, 213 to StyleResolver. 214 1 215 2013-02-20 Ojan Vafai <ojan@chromium.org> 2 216 -
trunk/Source/WebCore/css/BasicShapeFunctions.cpp
r127155 r143556 35 35 #include "CSSPrimitiveValueMappings.h" 36 36 #include "CSSValuePool.h" 37 #include "StyleResolver.h"38 37 39 38 namespace WebCore { … … 101 100 } 102 101 103 static Length convertToLength(const StyleResolver * styleResolver, CSSPrimitiveValue* value)102 static Length convertToLength(const StyleResolver::State& state, CSSPrimitiveValue* value) 104 103 { 105 return value->convertToLength<FixedIntegerConversion | FixedFloatConversion | PercentConversion | ViewportPercentageConversion>(st yleResolver->style(), styleResolver->rootElementStyle(), styleResolver->style()->effectiveZoom());104 return value->convertToLength<FixedIntegerConversion | FixedFloatConversion | PercentConversion | ViewportPercentageConversion>(state.style(), state.rootElementStyle(), state.style()->effectiveZoom()); 106 105 } 107 106 108 PassRefPtr<BasicShape> basicShapeForValue(const StyleResolver * styleResolver, const CSSBasicShape* basicShapeValue)107 PassRefPtr<BasicShape> basicShapeForValue(const StyleResolver::State& state, const CSSBasicShape* basicShapeValue) 109 108 { 110 109 RefPtr<BasicShape> basicShape; … … 115 114 RefPtr<BasicShapeRectangle> rect = BasicShapeRectangle::create(); 116 115 117 rect->setX(convertToLength(st yleResolver, rectValue->x()));118 rect->setY(convertToLength(st yleResolver, rectValue->y()));119 rect->setWidth(convertToLength(st yleResolver, rectValue->width()));120 rect->setHeight(convertToLength(st yleResolver, rectValue->height()));116 rect->setX(convertToLength(state, rectValue->x())); 117 rect->setY(convertToLength(state, rectValue->y())); 118 rect->setWidth(convertToLength(state, rectValue->width())); 119 rect->setHeight(convertToLength(state, rectValue->height())); 121 120 if (rectValue->radiusX()) { 122 rect->setCornerRadiusX(convertToLength(st yleResolver, rectValue->radiusX()));121 rect->setCornerRadiusX(convertToLength(state, rectValue->radiusX())); 123 122 if (rectValue->radiusY()) 124 rect->setCornerRadiusY(convertToLength(st yleResolver, rectValue->radiusY()));123 rect->setCornerRadiusY(convertToLength(state, rectValue->radiusY())); 125 124 } 126 125 basicShape = rect.release(); … … 131 130 RefPtr<BasicShapeCircle> circle = BasicShapeCircle::create(); 132 131 133 circle->setCenterX(convertToLength(st yleResolver, circleValue->centerX()));134 circle->setCenterY(convertToLength(st yleResolver, circleValue->centerY()));135 circle->setRadius(convertToLength(st yleResolver, circleValue->radius()));132 circle->setCenterX(convertToLength(state, circleValue->centerX())); 133 circle->setCenterY(convertToLength(state, circleValue->centerY())); 134 circle->setRadius(convertToLength(state, circleValue->radius())); 136 135 137 136 basicShape = circle.release(); … … 142 141 RefPtr<BasicShapeEllipse> ellipse = BasicShapeEllipse::create(); 143 142 144 ellipse->setCenterX(convertToLength(st yleResolver, ellipseValue->centerX()));145 ellipse->setCenterY(convertToLength(st yleResolver, ellipseValue->centerY()));146 ellipse->setRadiusX(convertToLength(st yleResolver, ellipseValue->radiusX()));147 ellipse->setRadiusY(convertToLength(st yleResolver, ellipseValue->radiusY()));143 ellipse->setCenterX(convertToLength(state, ellipseValue->centerX())); 144 ellipse->setCenterY(convertToLength(state, ellipseValue->centerY())); 145 ellipse->setRadiusX(convertToLength(state, ellipseValue->radiusX())); 146 ellipse->setRadiusY(convertToLength(state, ellipseValue->radiusY())); 148 147 149 148 basicShape = ellipse.release(); … … 157 156 const Vector<RefPtr<CSSPrimitiveValue> >& values = polygonValue->values(); 158 157 for (unsigned i = 0; i < values.size(); i += 2) 159 polygon->appendPoint(convertToLength(st yleResolver, values.at(i).get()), convertToLength(styleResolver, values.at(i + 1).get()));158 polygon->appendPoint(convertToLength(state, values.at(i).get()), convertToLength(state, values.at(i + 1).get())); 160 159 161 160 basicShape = polygon.release(); -
trunk/Source/WebCore/css/BasicShapeFunctions.h
r127155 r143556 31 31 #define BasicShapeFunctions_h 32 32 33 #include "StyleResolver.h" 33 34 #include <wtf/PassRefPtr.h> 34 35 … … 38 39 class CSSBasicShape; 39 40 class CSSValue; 40 class StyleResolver;41 41 42 42 PassRefPtr<CSSValue> valueForBasicShape(const BasicShape*); 43 PassRefPtr<BasicShape> basicShapeForValue(const StyleResolver *, const CSSBasicShape*);43 PassRefPtr<BasicShape> basicShapeForValue(const StyleResolver::State&, const CSSBasicShape*); 44 44 45 45 } -
trunk/Source/WebCore/css/CSSGradientValue.cpp
r142444 r143556 36 36 #include "NodeRenderStyle.h" 37 37 #include "RenderObject.h" 38 #include "StyleResolver.h"39 38 #include "WebCoreMemoryInstrumentation.h" 40 39 #include <wtf/MemoryInstrumentationVector.h> … … 116 115 }; 117 116 118 PassRefPtr<CSSGradientValue> CSSGradientValue::gradientWithStylesResolved(StyleResolver * styleResolver)117 PassRefPtr<CSSGradientValue> CSSGradientValue::gradientWithStylesResolved(StyleResolver::State& state) 119 118 { 120 119 bool derived = false; 121 120 for (unsigned i = 0; i < m_stops.size(); i++) 122 if ( styleResolver->colorFromPrimitiveValueIsDerivedFromElement(m_stops[i].m_color.get())) {121 if (StyleResolver::colorFromPrimitiveValueIsDerivedFromElement(m_stops[i].m_color.get())) { 123 122 m_stops[i].m_colorIsDerivedFromElement = true; 124 123 derived = true; … … 139 138 140 139 for (unsigned i = 0; i < result->m_stops.size(); i++) 141 result->m_stops[i].m_resolvedColor = styleResolver->colorFromPrimitiveValue(result->m_stops[i].m_color.get());140 result->m_stops[i].m_resolvedColor = StyleResolver::colorFromPrimitiveValue(state, result->m_stops[i].m_color.get()); 142 141 143 142 return result.release(); -
trunk/Source/WebCore/css/CSSGradientValue.h
r142444 r143556 29 29 #include "CSSImageGeneratorValue.h" 30 30 #include "CSSPrimitiveValue.h" 31 #include "StyleResolver.h" 31 32 #include <wtf/RefPtr.h> 32 33 #include <wtf/Vector.h> … … 90 91 91 92 void loadSubimages(CachedResourceLoader*) { } 92 PassRefPtr<CSSGradientValue> gradientWithStylesResolved(StyleResolver *);93 PassRefPtr<CSSGradientValue> gradientWithStylesResolved(StyleResolver::State&); 93 94 94 95 protected: -
trunk/Source/WebCore/css/CSSToStyleMap.cpp
r142168 r143556 44 44 RenderStyle* CSSToStyleMap::style() const 45 45 { 46 return m_ resolver->style();46 return m_state.style(); 47 47 } 48 48 49 49 RenderStyle* CSSToStyleMap::rootElementStyle() const 50 50 { 51 return m_ resolver->rootElementStyle();51 return m_state.rootElementStyle(); 52 52 } 53 53 54 54 bool CSSToStyleMap::useSVGZoomRules() const 55 55 { 56 return m_ resolver->useSVGZoomRules();56 return m_state.useSVGZoomRules(); 57 57 } 58 58 59 59 PassRefPtr<StyleImage> CSSToStyleMap::styleImage(CSSPropertyID propertyId, CSSValue* value) 60 60 { 61 return m_resolver->styleImage(propertyId, value);61 return StyleResolver::styleImage(m_state, propertyId, value); 62 62 } 63 63 -
trunk/Source/WebCore/css/CSSToStyleMap.h
r142168 r143556 25 25 #include "CSSPropertyNames.h" 26 26 #include "LengthBox.h" 27 #include "StyleResolver.h" 27 28 28 29 namespace WebCore { … … 33 34 class RenderStyle; 34 35 class StyleImage; 35 class StyleResolver;36 36 class NinePieceImage; 37 37 … … 41 41 42 42 public: 43 CSSToStyleMap(StyleResolver * resolver) : m_resolver(resolver) { }43 CSSToStyleMap(StyleResolver::State& state) : m_state(state) { } 44 44 45 45 void mapFillAttachment(CSSPropertyID, FillLayer*, CSSValue*); … … 83 83 PassRefPtr<StyleImage> styleImage(CSSPropertyID, CSSValue*); 84 84 85 StyleResolver * m_resolver;85 StyleResolver::State& m_state; 86 86 }; 87 87 -
trunk/Source/WebCore/css/SVGCSSStyleSelector.cpp
r142757 r143556 103 103 } 104 104 105 void StyleResolver::applySVGProperty( CSSPropertyID id, CSSValue* value)105 void StyleResolver::applySVGProperty(const State& state, CSSPropertyID id, CSSValue* value) 106 106 { 107 107 ASSERT(value); … … 110 110 primitiveValue = static_cast<CSSPrimitiveValue*>(value); 111 111 112 const State& state = m_state;113 112 SVGRenderStyle* svgstyle = state.style()->accessSVGStyle(); 114 113 … … 232 231 if (isInherit) { 233 232 const SVGRenderStyle* svgParentStyle = state.parentStyle()->svgStyle(); 234 svgstyle->setFillPaint(svgParentStyle->fillPaintType(), svgParentStyle->fillPaintColor(), svgParentStyle->fillPaintUri(), applyPropertyToRegularStyle(),applyPropertyToVisitedLinkStyle());233 svgstyle->setFillPaint(svgParentStyle->fillPaintType(), svgParentStyle->fillPaintColor(), svgParentStyle->fillPaintUri(), state.applyPropertyToRegularStyle(), state.applyPropertyToVisitedLinkStyle()); 235 234 return; 236 235 } 237 236 if (isInitial) { 238 svgstyle->setFillPaint(SVGRenderStyle::initialFillPaintType(), SVGRenderStyle::initialFillPaintColor(), SVGRenderStyle::initialFillPaintUri(), applyPropertyToRegularStyle(),applyPropertyToVisitedLinkStyle());237 svgstyle->setFillPaint(SVGRenderStyle::initialFillPaintType(), SVGRenderStyle::initialFillPaintColor(), SVGRenderStyle::initialFillPaintUri(), state.applyPropertyToRegularStyle(), state.applyPropertyToVisitedLinkStyle()); 239 238 return; 240 239 } 241 240 if (value->isSVGPaint()) { 242 241 SVGPaint* svgPaint = static_cast<SVGPaint*>(value); 243 svgstyle->setFillPaint(svgPaint->paintType(), colorFromSVGColorCSSValue(svgPaint, state.style()->color()), svgPaint->uri(), applyPropertyToRegularStyle(),applyPropertyToVisitedLinkStyle());242 svgstyle->setFillPaint(svgPaint->paintType(), colorFromSVGColorCSSValue(svgPaint, state.style()->color()), svgPaint->uri(), state.applyPropertyToRegularStyle(), state.applyPropertyToVisitedLinkStyle()); 244 243 } 245 244 break; … … 249 248 if (isInherit) { 250 249 const SVGRenderStyle* svgParentStyle = state.parentStyle()->svgStyle(); 251 svgstyle->setStrokePaint(svgParentStyle->strokePaintType(), svgParentStyle->strokePaintColor(), svgParentStyle->strokePaintUri(), applyPropertyToRegularStyle(),applyPropertyToVisitedLinkStyle());250 svgstyle->setStrokePaint(svgParentStyle->strokePaintType(), svgParentStyle->strokePaintColor(), svgParentStyle->strokePaintUri(), state.applyPropertyToRegularStyle(), state.applyPropertyToVisitedLinkStyle()); 252 251 return; 253 252 } 254 253 if (isInitial) { 255 svgstyle->setStrokePaint(SVGRenderStyle::initialStrokePaintType(), SVGRenderStyle::initialStrokePaintColor(), SVGRenderStyle::initialStrokePaintUri(), applyPropertyToRegularStyle(),applyPropertyToVisitedLinkStyle());254 svgstyle->setStrokePaint(SVGRenderStyle::initialStrokePaintType(), SVGRenderStyle::initialStrokePaintColor(), SVGRenderStyle::initialStrokePaintUri(), state.applyPropertyToRegularStyle(), state.applyPropertyToVisitedLinkStyle()); 256 255 return; 257 256 } 258 257 if (value->isSVGPaint()) { 259 258 SVGPaint* svgPaint = static_cast<SVGPaint*>(value); 260 svgstyle->setStrokePaint(svgPaint->paintType(), colorFromSVGColorCSSValue(svgPaint, state.style()->color()), svgPaint->uri(), applyPropertyToRegularStyle(),applyPropertyToVisitedLinkStyle());259 svgstyle->setStrokePaint(svgPaint->paintType(), colorFromSVGColorCSSValue(svgPaint, state.style()->color()), svgPaint->uri(), state.applyPropertyToRegularStyle(), state.applyPropertyToVisitedLinkStyle()); 261 260 } 262 261 break; … … 571 570 Color color; 572 571 if (item->color) 573 color = colorFromPrimitiveValue(item->color.get());572 color = StyleResolver::colorFromPrimitiveValue(state, item->color.get()); 574 573 575 574 // -webkit-svg-shadow does should not have a spread or style -
trunk/Source/WebCore/css/StyleBuilder.cpp
r142168 r143556 44 44 #include "RenderView.h" 45 45 #include "Settings.h" 46 #include "StyleResolver.h"47 46 #include <wtf/StdLibExtras.h> 48 47 #include <wtf/UnusedParam.h> … … 62 61 63 62 template <CSSPropertyID id> 64 static inline void applyInheritValue(CSSPropertyID propertyID, StyleResolver * styleResolver)63 static inline void applyInheritValue(CSSPropertyID propertyID, StyleResolver::State& state) 65 64 { 66 65 if (id == CSSPropertyInvalid) … … 70 69 const PropertyHandler& handler = table.propertyHandler(id); 71 70 if (handler.isValid()) 72 handler.applyInheritValue(propertyID, st yleResolver);73 } 74 75 static void applyInheritValue(CSSPropertyID propertyID, StyleResolver * styleResolver)76 { 77 applyInheritValue<one>(propertyID, st yleResolver);78 applyInheritValue<two>(propertyID, st yleResolver);79 applyInheritValue<three>(propertyID, st yleResolver);80 applyInheritValue<four>(propertyID, st yleResolver);81 applyInheritValue<five>(propertyID, st yleResolver);71 handler.applyInheritValue(propertyID, state); 72 } 73 74 static void applyInheritValue(CSSPropertyID propertyID, StyleResolver::State& state) 75 { 76 applyInheritValue<one>(propertyID, state); 77 applyInheritValue<two>(propertyID, state); 78 applyInheritValue<three>(propertyID, state); 79 applyInheritValue<four>(propertyID, state); 80 applyInheritValue<five>(propertyID, state); 82 81 } 83 82 84 83 template <CSSPropertyID id> 85 static inline void applyInitialValue(CSSPropertyID propertyID, StyleResolver * styleResolver)84 static inline void applyInitialValue(CSSPropertyID propertyID, StyleResolver::State& state) 86 85 { 87 86 if (id == CSSPropertyInvalid) … … 91 90 const PropertyHandler& handler = table.propertyHandler(id); 92 91 if (handler.isValid()) 93 handler.applyInitialValue(propertyID, st yleResolver);94 } 95 96 static void applyInitialValue(CSSPropertyID propertyID, StyleResolver * styleResolver)97 { 98 applyInitialValue<one>(propertyID, st yleResolver);99 applyInitialValue<two>(propertyID, st yleResolver);100 applyInitialValue<three>(propertyID, st yleResolver);101 applyInitialValue<four>(propertyID, st yleResolver);102 applyInitialValue<five>(propertyID, st yleResolver);92 handler.applyInitialValue(propertyID, state); 93 } 94 95 static void applyInitialValue(CSSPropertyID propertyID, StyleResolver::State& state) 96 { 97 applyInitialValue<one>(propertyID, state); 98 applyInitialValue<two>(propertyID, state); 99 applyInitialValue<three>(propertyID, state); 100 applyInitialValue<four>(propertyID, state); 101 applyInitialValue<five>(propertyID, state); 103 102 } 104 103 105 104 template <CSSPropertyID id> 106 static inline void applyValue(CSSPropertyID propertyID, StyleResolver * styleResolver, CSSValue* value)105 static inline void applyValue(CSSPropertyID propertyID, StyleResolver::State& state, CSSValue* value) 107 106 { 108 107 if (id == CSSPropertyInvalid) … … 112 111 const PropertyHandler& handler = table.propertyHandler(id); 113 112 if (handler.isValid()) 114 handler.applyValue(propertyID, st yleResolver, value);115 } 116 117 static void applyValue(CSSPropertyID propertyID, StyleResolver * styleResolver, CSSValue* value)113 handler.applyValue(propertyID, state, value); 114 } 115 116 static void applyValue(CSSPropertyID propertyID, StyleResolver::State& state, CSSValue* value) 118 117 { 119 118 if (!expandValue) 120 119 return; 121 120 122 applyValue<one>(propertyID, st yleResolver, value);123 applyValue<two>(propertyID, st yleResolver, value);124 applyValue<three>(propertyID, st yleResolver, value);125 applyValue<four>(propertyID, st yleResolver, value);126 applyValue<five>(propertyID, st yleResolver, value);121 applyValue<one>(propertyID, state, value); 122 applyValue<two>(propertyID, state, value); 123 applyValue<three>(propertyID, state, value); 124 applyValue<four>(propertyID, state, value); 125 applyValue<five>(propertyID, state, value); 127 126 } 128 127 static PropertyHandler createHandler() { return PropertyHandler(&applyInheritValue, &applyInitialValue, &applyValue); } … … 135 134 static GetterType value(RenderStyle* style) { return (style->*getterFunction)(); } 136 135 static InitialType initial() { return (*initialFunction)(); } 137 static void applyInheritValue(CSSPropertyID, StyleResolver * styleResolver) { setValue(styleResolver->style(), value(styleResolver->parentStyle())); }138 static void applyInitialValue(CSSPropertyID, StyleResolver * styleResolver) { setValue(styleResolver->style(), initial()); }139 static void applyValue(CSSPropertyID, StyleResolver *, CSSValue*) { }136 static void applyInheritValue(CSSPropertyID, StyleResolver::State& state) { setValue(state.style(), value(state.parentStyle())); } 137 static void applyInitialValue(CSSPropertyID, StyleResolver::State& state) { setValue(state.style(), initial()); } 138 static void applyValue(CSSPropertyID, StyleResolver::State&, CSSValue*) { } 140 139 static PropertyHandler createHandler() { return PropertyHandler(&applyInheritValue, &applyInitialValue, &applyValue); } 141 140 }; … … 145 144 public: 146 145 static void setValue(RenderStyle* style, SetterType value) { (style->*setterFunction)(value); } 147 static void applyValue(CSSPropertyID, StyleResolver * styleResolver, CSSValue* value)146 static void applyValue(CSSPropertyID, StyleResolver::State& state, CSSValue* value) 148 147 { 149 148 if (value->isPrimitiveValue()) 150 setValue(st yleResolver->style(), *static_cast<CSSPrimitiveValue*>(value));149 setValue(state.style(), *static_cast<CSSPrimitiveValue*>(value)); 151 150 } 152 151 static PropertyHandler createHandler() … … 161 160 public: 162 161 static void setValue(RenderStyle* style, NumberType value) { (style->*setterFunction)(value); } 163 static void applyValue(CSSPropertyID, StyleResolver * styleResolver, CSSValue* value)162 static void applyValue(CSSPropertyID, StyleResolver::State& state, CSSValue* value) 164 163 { 165 164 if (!value->isPrimitiveValue()) … … 168 167 CSSPrimitiveValue* primitiveValue = static_cast<CSSPrimitiveValue*>(value); 169 168 if (primitiveValue->getIdent() == idMapsToMinusOne) 170 setValue(st yleResolver->style(), -1);169 setValue(state.style(), -1); 171 170 else 172 setValue(st yleResolver->style(), primitiveValue->getValue<NumberType>(CSSPrimitiveValue::CSS_NUMBER));171 setValue(state.style(), primitiveValue->getValue<NumberType>(CSSPrimitiveValue::CSS_NUMBER)); 173 172 } 174 173 static PropertyHandler createHandler() … … 182 181 class ApplyPropertyStyleImage { 183 182 public: 184 static void applyValue(CSSPropertyID, StyleResolver * styleResolver, CSSValue* value) { (styleResolver->style()->*setterFunction)(styleResolver->styleImage(property, value)); }183 static void applyValue(CSSPropertyID, StyleResolver::State& state, CSSValue* value) { (state.style()->*setterFunction)(StyleResolver::styleImage(state, property, value)); } 185 184 static PropertyHandler createHandler() 186 185 { … … 199 198 static void setAuto(RenderStyle* style) { (style->*setAutoFunction)(); } 200 199 201 static void applyInheritValue(CSSPropertyID, StyleResolver * styleResolver)202 { 203 if (hasAuto(st yleResolver->parentStyle()))204 setAuto(st yleResolver->style());200 static void applyInheritValue(CSSPropertyID, StyleResolver::State& state) 201 { 202 if (hasAuto(state.parentStyle())) 203 setAuto(state.style()); 205 204 else 206 setValue(st yleResolver->style(), value(styleResolver->parentStyle()));207 } 208 209 static void applyInitialValue(CSSPropertyID, StyleResolver * styleResolver) { setAuto(styleResolver->style()); }210 211 static void applyValue(CSSPropertyID, StyleResolver * styleResolver, CSSValue* value)205 setValue(state.style(), value(state.parentStyle())); 206 } 207 208 static void applyInitialValue(CSSPropertyID, StyleResolver::State& state) { setAuto(state.style()); } 209 210 static void applyValue(CSSPropertyID, StyleResolver::State& state, CSSValue* value) 212 211 { 213 212 if (!value->isPrimitiveValue()) … … 216 215 CSSPrimitiveValue* primitiveValue = static_cast<CSSPrimitiveValue*>(value); 217 216 if (primitiveValue->getIdent() == autoIdentity) 218 setAuto(st yleResolver->style());217 setAuto(state.style()); 219 218 else if (valueType == Number) 220 setValue(st yleResolver->style(), *primitiveValue);219 setValue(state.style(), *primitiveValue); 221 220 else if (valueType == ComputeLength) 222 setValue(st yleResolver->style(), primitiveValue->computeLength<T>(styleResolver->style(), styleResolver->rootElementStyle(), styleResolver->style()->effectiveZoom()));221 setValue(state.style(), primitiveValue->computeLength<T>(state.style(), state.rootElementStyle(), state.style()->effectiveZoom())); 223 222 } 224 223 … … 228 227 class ApplyPropertyClip { 229 228 private: 230 static Length convertToLength(StyleResolver * styleResolver, CSSPrimitiveValue* value)231 { 232 return value->convertToLength<FixedIntegerConversion | PercentConversion | FractionConversion | AutoConversion>(st yleResolver->style(), styleResolver->rootElementStyle(), styleResolver->style()->effectiveZoom());233 } 234 public: 235 static void applyInheritValue(CSSPropertyID propertyID, StyleResolver * styleResolver)236 { 237 RenderStyle* parentStyle = st yleResolver->parentStyle();229 static Length convertToLength(StyleResolver::State& state, CSSPrimitiveValue* value) 230 { 231 return value->convertToLength<FixedIntegerConversion | PercentConversion | FractionConversion | AutoConversion>(state.style(), state.rootElementStyle(), state.style()->effectiveZoom()); 232 } 233 public: 234 static void applyInheritValue(CSSPropertyID propertyID, StyleResolver::State& state) 235 { 236 RenderStyle* parentStyle = state.parentStyle(); 238 237 if (!parentStyle->hasClip()) 239 return applyInitialValue(propertyID, st yleResolver);240 st yleResolver->style()->setClip(parentStyle->clipTop(), parentStyle->clipRight(), parentStyle->clipBottom(), parentStyle->clipLeft());241 st yleResolver->style()->setHasClip(true);242 } 243 244 static void applyInitialValue(CSSPropertyID, StyleResolver * styleResolver)245 { 246 st yleResolver->style()->setClip(Length(), Length(), Length(), Length());247 st yleResolver->style()->setHasClip(false);248 } 249 250 static void applyValue(CSSPropertyID, StyleResolver * styleResolver, CSSValue* value)238 return applyInitialValue(propertyID, state); 239 state.style()->setClip(parentStyle->clipTop(), parentStyle->clipRight(), parentStyle->clipBottom(), parentStyle->clipLeft()); 240 state.style()->setHasClip(true); 241 } 242 243 static void applyInitialValue(CSSPropertyID, StyleResolver::State& state) 244 { 245 state.style()->setClip(Length(), Length(), Length(), Length()); 246 state.style()->setHasClip(false); 247 } 248 249 static void applyValue(CSSPropertyID, StyleResolver::State& state, CSSValue* value) 251 250 { 252 251 if (!value->isPrimitiveValue()) … … 256 255 257 256 if (Rect* rect = primitiveValue->getRectValue()) { 258 Length top = convertToLength(st yleResolver, rect->top());259 Length right = convertToLength(st yleResolver, rect->right());260 Length bottom = convertToLength(st yleResolver, rect->bottom());261 Length left = convertToLength(st yleResolver, rect->left());262 st yleResolver->style()->setClip(top, right, bottom, left);263 st yleResolver->style()->setHasClip(true);257 Length top = convertToLength(state, rect->top()); 258 Length right = convertToLength(state, rect->right()); 259 Length bottom = convertToLength(state, rect->bottom()); 260 Length left = convertToLength(state, rect->left()); 261 state.style()->setClip(top, right, bottom, left); 262 state.style()->setHasClip(true); 264 263 } else if (primitiveValue->getIdent() == CSSValueAuto) { 265 st yleResolver->style()->setClip(Length(), Length(), Length(), Length());266 st yleResolver->style()->setHasClip(false);264 state.style()->setClip(Length(), Length(), Length(), Length()); 265 state.style()->setHasClip(false); 267 266 } 268 267 } … … 282 281 class ApplyPropertyColor { 283 282 public: 284 static void applyInheritValue(CSSPropertyID, StyleResolver * styleResolver)283 static void applyInheritValue(CSSPropertyID, StyleResolver::State& state) 285 284 { 286 285 // Visited link style can never explicitly inherit from parent visited link style so no separate getters are needed. 287 Color color = (st yleResolver->parentStyle()->*getterFunction)();288 applyColorValue(st yleResolver, color.isValid() ? color : (styleResolver->parentStyle()->*defaultFunction)());289 } 290 291 static void applyInitialValue(CSSPropertyID, StyleResolver * styleResolver)292 { 293 applyColorValue(st yleResolver, initialFunction());294 } 295 296 static void applyValue(CSSPropertyID propertyID, StyleResolver * styleResolver, CSSValue* value)286 Color color = (state.parentStyle()->*getterFunction)(); 287 applyColorValue(state, color.isValid() ? color : (state.parentStyle()->*defaultFunction)()); 288 } 289 290 static void applyInitialValue(CSSPropertyID, StyleResolver::State& state) 291 { 292 applyColorValue(state, initialFunction()); 293 } 294 295 static void applyValue(CSSPropertyID propertyID, StyleResolver::State& state, CSSValue* value) 297 296 { 298 297 if (!value->isPrimitiveValue()) … … 301 300 CSSPrimitiveValue* primitiveValue = static_cast<CSSPrimitiveValue*>(value); 302 301 if (inheritColorFromParent && primitiveValue->getIdent() == CSSValueCurrentcolor) 303 applyInheritValue(propertyID, st yleResolver);302 applyInheritValue(propertyID, state); 304 303 else { 305 if (st yleResolver->applyPropertyToRegularStyle())306 (st yleResolver->style()->*setterFunction)(styleResolver->colorFromPrimitiveValue(primitiveValue));307 if (st yleResolver->applyPropertyToVisitedLinkStyle())308 (st yleResolver->style()->*visitedLinkSetterFunction)(styleResolver->colorFromPrimitiveValue(primitiveValue, /* forVisitedLink */ true));309 } 310 } 311 312 static void applyColorValue(StyleResolver * styleResolver, const Color& color)313 { 314 if (st yleResolver->applyPropertyToRegularStyle())315 (st yleResolver->style()->*setterFunction)(color);316 if (st yleResolver->applyPropertyToVisitedLinkStyle())317 (st yleResolver->style()->*visitedLinkSetterFunction)(color);304 if (state.applyPropertyToRegularStyle()) 305 (state.style()->*setterFunction)(StyleResolver::colorFromPrimitiveValue(state, primitiveValue)); 306 if (state.applyPropertyToVisitedLinkStyle()) 307 (state.style()->*visitedLinkSetterFunction)(StyleResolver::colorFromPrimitiveValue(state, primitiveValue, /* forVisitedLink */ true)); 308 } 309 } 310 311 static void applyColorValue(StyleResolver::State& state, const Color& color) 312 { 313 if (state.applyPropertyToRegularStyle()) 314 (state.style()->*setterFunction)(color); 315 if (state.applyPropertyToVisitedLinkStyle()) 316 (state.style()->*visitedLinkSetterFunction)(color); 318 317 } 319 318 … … 324 323 class ApplyPropertyDirection { 325 324 public: 326 static void applyValue(CSSPropertyID propertyID, StyleResolver * styleResolver, CSSValue* value)327 { 328 ApplyPropertyDefault<TextDirection, getterFunction, TextDirection, setterFunction, TextDirection, initialFunction>::applyValue(propertyID, st yleResolver, value);329 Element* element = st yleResolver->element();330 if (element && st yleResolver->element() == element->document()->documentElement())325 static void applyValue(CSSPropertyID propertyID, StyleResolver::State& state, CSSValue* value) 326 { 327 ApplyPropertyDefault<TextDirection, getterFunction, TextDirection, setterFunction, TextDirection, initialFunction>::applyValue(propertyID, state, value); 328 Element* element = state.element(); 329 if (element && state.element() == element->document()->documentElement()) 331 330 element->document()->setDirectionSetOnDocumentElement(true); 332 331 } … … 355 354 public: 356 355 static void setValue(RenderStyle* style, Length value) { (style->*setterFunction)(value); } 357 static void applyValue(CSSPropertyID, StyleResolver * styleResolver, CSSValue* value)356 static void applyValue(CSSPropertyID, StyleResolver::State& state, CSSValue* value) 358 357 { 359 358 if (!value->isPrimitiveValue()) … … 363 362 if (noneEnabled && primitiveValue->getIdent() == CSSValueNone) { 364 363 if (noneUndefined) 365 setValue(st yleResolver->style(), Length(Undefined));364 setValue(state.style(), Length(Undefined)); 366 365 else 367 setValue(st yleResolver->style(), Length());366 setValue(state.style(), Length()); 368 367 } 369 368 if (legacyIntrinsicEnabled) { 370 369 if (primitiveValue->getIdent() == CSSValueIntrinsic) 371 setValue(st yleResolver->style(), Length(Intrinsic));370 setValue(state.style(), Length(Intrinsic)); 372 371 else if (primitiveValue->getIdent() == CSSValueMinIntrinsic) 373 setValue(st yleResolver->style(), Length(MinIntrinsic));372 setValue(state.style(), Length(MinIntrinsic)); 374 373 } 375 374 if (intrinsicEnabled) { 376 375 if (primitiveValue->getIdent() == CSSValueWebkitMinContent) 377 setValue(st yleResolver->style(), Length(MinContent));376 setValue(state.style(), Length(MinContent)); 378 377 else if (primitiveValue->getIdent() == CSSValueWebkitMaxContent) 379 setValue(st yleResolver->style(), Length(MaxContent));378 setValue(state.style(), Length(MaxContent)); 380 379 else if (primitiveValue->getIdent() == CSSValueWebkitFillAvailable) 381 setValue(st yleResolver->style(), Length(FillAvailable));380 setValue(state.style(), Length(FillAvailable)); 382 381 else if (primitiveValue->getIdent() == CSSValueWebkitFitContent) 383 setValue(st yleResolver->style(), Length(FitContent));382 setValue(state.style(), Length(FitContent)); 384 383 } 385 384 386 385 if (autoEnabled && primitiveValue->getIdent() == CSSValueAuto) 387 setValue(st yleResolver->style(), Length());386 setValue(state.style(), Length()); 388 387 else if (primitiveValue->isLength()) { 389 Length length = primitiveValue->computeLength<Length>(st yleResolver->style(), styleResolver->rootElementStyle(), styleResolver->style()->effectiveZoom());388 Length length = primitiveValue->computeLength<Length>(state.style(), state.rootElementStyle(), state.style()->effectiveZoom()); 390 389 length.setQuirk(primitiveValue->isQuirkValue()); 391 setValue(st yleResolver->style(), length);390 setValue(state.style(), length); 392 391 } else if (primitiveValue->isPercentage()) 393 setValue(st yleResolver->style(), Length(primitiveValue->getDoubleValue(), Percent));392 setValue(state.style(), Length(primitiveValue->getDoubleValue(), Percent)); 394 393 else if (primitiveValue->isCalculatedPercentageWithLength()) 395 setValue(st yleResolver->style(), Length(primitiveValue->cssCalcValue()->toCalcValue(styleResolver->style(), styleResolver->rootElementStyle(), styleResolver->style()->effectiveZoom())));394 setValue(state.style(), Length(primitiveValue->cssCalcValue()->toCalcValue(state.style(), state.rootElementStyle(), state.style()->effectiveZoom()))); 396 395 else if (primitiveValue->isViewportPercentageLength()) 397 setValue(st yleResolver->style(), primitiveValue->viewportPercentageLength());396 setValue(state.style(), primitiveValue->viewportPercentageLength()); 398 397 } 399 398 … … 410 409 public: 411 410 static void setValue(RenderStyle* style, const AtomicString& value) { (style->*setterFunction)(value); } 412 static void applyValue(CSSPropertyID, StyleResolver * styleResolver, CSSValue* value)411 static void applyValue(CSSPropertyID, StyleResolver::State& state, CSSValue* value) 413 412 { 414 413 if (!value->isPrimitiveValue()) … … 417 416 if ((identBehavior == MapNoneToNull && primitiveValue->getIdent() == CSSValueNone) 418 417 || (identBehavior == MapAutoToNull && primitiveValue->getIdent() == CSSValueAuto)) 419 setValue(st yleResolver->style(), nullAtom);418 setValue(state.style(), nullAtom); 420 419 else 421 setValue(st yleResolver->style(), primitiveValue->getStringValue());420 setValue(state.style(), primitiveValue->getStringValue()); 422 421 } 423 422 static PropertyHandler createHandler() … … 432 431 public: 433 432 static void setValue(RenderStyle* style, LengthSize value) { (style->*setterFunction)(value); } 434 static void applyValue(CSSPropertyID, StyleResolver * styleResolver, CSSValue* value)433 static void applyValue(CSSPropertyID, StyleResolver::State& state, CSSValue* value) 435 434 { 436 435 if (!value->isPrimitiveValue()) … … 449 448 radiusWidth = pair->first()->viewportPercentageLength(); 450 449 else if (pair->first()->isCalculatedPercentageWithLength()) 451 radiusWidth = Length((pair->first()->cssCalcValue()->toCalcValue(st yleResolver->style(), styleResolver->rootElementStyle(), styleResolver->style()->effectiveZoom())));450 radiusWidth = Length((pair->first()->cssCalcValue()->toCalcValue(state.style(), state.rootElementStyle(), state.style()->effectiveZoom()))); 452 451 else 453 radiusWidth = pair->first()->computeLength<Length>(st yleResolver->style(), styleResolver->rootElementStyle(), styleResolver->style()->effectiveZoom());452 radiusWidth = pair->first()->computeLength<Length>(state.style(), state.rootElementStyle(), state.style()->effectiveZoom()); 454 453 if (pair->second()->isPercentage()) 455 454 radiusHeight = Length(pair->second()->getDoubleValue(), Percent); … … 457 456 radiusHeight = pair->second()->viewportPercentageLength(); 458 457 else if (pair->second()->isCalculatedPercentageWithLength()) 459 radiusHeight = Length((pair->second()->cssCalcValue()->toCalcValue(st yleResolver->style(), styleResolver->rootElementStyle(), styleResolver->style()->effectiveZoom())));458 radiusHeight = Length((pair->second()->cssCalcValue()->toCalcValue(state.style(), state.rootElementStyle(), state.style()->effectiveZoom()))); 460 459 else 461 radiusHeight = pair->second()->computeLength<Length>(st yleResolver->style(), styleResolver->rootElementStyle(), styleResolver->style()->effectiveZoom());460 radiusHeight = pair->second()->computeLength<Length>(state.style(), state.rootElementStyle(), state.style()->effectiveZoom()); 462 461 int width = radiusWidth.value(); 463 462 int height = radiusHeight.value(); … … 470 469 471 470 LengthSize size(radiusWidth, radiusHeight); 472 setValue(st yleResolver->style(), size);471 setValue(state.style(), size); 473 472 } 474 473 static PropertyHandler createHandler() … … 504 503 class ApplyPropertyFillLayer { 505 504 public: 506 static void applyInheritValue(CSSPropertyID, StyleResolver * styleResolver)507 { 508 FillLayer* currChild = (st yleResolver->style()->*accessLayersFunction)();505 static void applyInheritValue(CSSPropertyID, StyleResolver::State& state) 506 { 507 FillLayer* currChild = (state.style()->*accessLayersFunction)(); 509 508 FillLayer* prevChild = 0; 510 const FillLayer* currParent = (st yleResolver->parentStyle()->*layersFunction)();509 const FillLayer* currParent = (state.parentStyle()->*layersFunction)(); 511 510 while (currParent && (currParent->*testFunction)()) { 512 511 if (!currChild) { … … 528 527 } 529 528 530 static void applyInitialValue(CSSPropertyID, StyleResolver * styleResolver)531 { 532 FillLayer* currChild = (st yleResolver->style()->*accessLayersFunction)();529 static void applyInitialValue(CSSPropertyID, StyleResolver::State& state) 530 { 531 FillLayer* currChild = (state.style()->*accessLayersFunction)(); 533 532 (currChild->*setFunction)((*initialFunction)(fillLayerType)); 534 533 for (currChild = currChild->next(); currChild; currChild = currChild->next()) … … 536 535 } 537 536 538 static void applyValue(CSSPropertyID, StyleResolver * styleResolver, CSSValue* value)539 { 540 FillLayer* currChild = (st yleResolver->style()->*accessLayersFunction)();537 static void applyValue(CSSPropertyID, StyleResolver::State& state, CSSValue* value) 538 { 539 FillLayer* currChild = (state.style()->*accessLayersFunction)(); 541 540 FillLayer* prevChild = 0; 541 CSSToStyleMap styleMap(state); 542 542 if (value->isValueList() 543 543 #if ENABLE(CSS_IMAGE_SET) … … 553 553 prevChild->setNext(currChild); 554 554 } 555 (style Resolver->styleMap()->*mapFillFunction)(propertyId, currChild, valueList->itemWithoutBoundsCheck(i));555 (styleMap.*mapFillFunction)(propertyId, currChild, valueList->itemWithoutBoundsCheck(i)); 556 556 prevChild = currChild; 557 557 currChild = currChild->next(); 558 558 } 559 559 } else { 560 (style Resolver->styleMap()->*mapFillFunction)(propertyId, currChild, value);560 (styleMap.*mapFillFunction)(propertyId, currChild, value); 561 561 currChild = currChild->next(); 562 562 } … … 584 584 public: 585 585 static void setValue(RenderStyle* style, T value) { (style->*setterFunction)(value); } 586 static void applyValue(CSSPropertyID, StyleResolver * styleResolver, CSSValue* value)586 static void applyValue(CSSPropertyID, StyleResolver::State& state, CSSValue* value) 587 587 { 588 588 // note: CSSPropertyLetter/WordSpacing right now sets to zero if it's not a primitive value for some reason... … … 603 603 length = 5; 604 604 } else if (ident == CSSValueInvalid) { 605 float zoom = (svgZoomEnabled && st yleResolver->useSVGZoomRules()) ? 1.0f : styleResolver->style()->effectiveZoom();605 float zoom = (svgZoomEnabled && state.useSVGZoomRules()) ? 1.0f : state.style()->effectiveZoom(); 606 606 607 607 // Any original result that was >= 1 should not be allowed to fall below 1. 608 608 // This keeps border lines from vanishing. 609 length = primitiveValue->computeLength<T>(st yleResolver->style(), styleResolver->rootElementStyle(), zoom);609 length = primitiveValue->computeLength<T>(state.style(), state.rootElementStyle(), zoom); 610 610 if (zoom < 1.0f && length < 1.0) { 611 T originalLength = primitiveValue->computeLength<T>(st yleResolver->style(), styleResolver->rootElementStyle(), 1.0);611 T originalLength = primitiveValue->computeLength<T>(state.style(), state.rootElementStyle(), 1.0); 612 612 if (originalLength >= 1.0) 613 613 length = 1.0; … … 619 619 } 620 620 621 setValue(st yleResolver->style(), length);621 setValue(state.style(), length); 622 622 } 623 623 static PropertyHandler createHandler() … … 631 631 class ApplyPropertyFont { 632 632 public: 633 static void applyInheritValue(CSSPropertyID, StyleResolver * styleResolver)634 { 635 FontDescription fontDescription = st yleResolver->fontDescription();636 (fontDescription.*setterFunction)((st yleResolver->parentFontDescription().*getterFunction)());637 st yleResolver->setFontDescription(fontDescription);638 } 639 640 static void applyInitialValue(CSSPropertyID, StyleResolver * styleResolver)641 { 642 FontDescription fontDescription = st yleResolver->fontDescription();633 static void applyInheritValue(CSSPropertyID, StyleResolver::State& state) 634 { 635 FontDescription fontDescription = state.fontDescription(); 636 (fontDescription.*setterFunction)((state.parentFontDescription().*getterFunction)()); 637 state.setFontDescription(fontDescription); 638 } 639 640 static void applyInitialValue(CSSPropertyID, StyleResolver::State& state) 641 { 642 FontDescription fontDescription = state.fontDescription(); 643 643 (fontDescription.*setterFunction)(initialValue); 644 st yleResolver->setFontDescription(fontDescription);645 } 646 647 static void applyValue(CSSPropertyID, StyleResolver * styleResolver, CSSValue* value)644 state.setFontDescription(fontDescription); 645 } 646 647 static void applyValue(CSSPropertyID, StyleResolver::State& state, CSSValue* value) 648 648 { 649 649 if (!value->isPrimitiveValue()) 650 650 return; 651 651 CSSPrimitiveValue* primitiveValue = static_cast<CSSPrimitiveValue*>(value); 652 FontDescription fontDescription = st yleResolver->fontDescription();652 FontDescription fontDescription = state.fontDescription(); 653 653 (fontDescription.*setterFunction)(*primitiveValue); 654 st yleResolver->setFontDescription(fontDescription);654 state.setFontDescription(fontDescription); 655 655 } 656 656 … … 677 677 } 678 678 public: 679 static void applyInheritValue(CSSPropertyID, StyleResolver * styleResolver)680 { 681 float size = st yleResolver->parentStyle()->fontDescription().specifiedSize();679 static void applyInheritValue(CSSPropertyID, StyleResolver::State& state) 680 { 681 float size = state.parentStyle()->fontDescription().specifiedSize(); 682 682 683 683 if (size < 0) 684 684 return; 685 685 686 FontDescription fontDescription = st yleResolver->style()->fontDescription();687 fontDescription.setKeywordSize(st yleResolver->parentStyle()->fontDescription().keywordSize());688 styleResolver->setFontSize(fontDescription, size);689 st yleResolver->setFontDescription(fontDescription);686 FontDescription fontDescription = state.style()->fontDescription(); 687 fontDescription.setKeywordSize(state.parentStyle()->fontDescription().keywordSize()); 688 StyleResolver::setFontSize(state, fontDescription, size); 689 state.setFontDescription(fontDescription); 690 690 return; 691 691 } 692 692 693 static void applyInitialValue(CSSPropertyID, StyleResolver * styleResolver)694 { 695 FontDescription fontDescription = st yleResolver->style()->fontDescription();696 float size = styleResolver->fontSizeForKeyword(styleResolver->document(), CSSValueMedium, fontDescription.useFixedDefaultSize());693 static void applyInitialValue(CSSPropertyID, StyleResolver::State& state) 694 { 695 FontDescription fontDescription = state.style()->fontDescription(); 696 float size = StyleResolver::fontSizeForKeyword(state.document(), CSSValueMedium, fontDescription.useFixedDefaultSize()); 697 697 698 698 if (size < 0) … … 700 700 701 701 fontDescription.setKeywordSize(CSSValueMedium - CSSValueXxSmall + 1); 702 styleResolver->setFontSize(fontDescription, size);703 st yleResolver->setFontDescription(fontDescription);702 StyleResolver::setFontSize(state, fontDescription, size); 703 state.setFontDescription(fontDescription); 704 704 return; 705 705 } 706 706 707 static void applyValue(CSSPropertyID, StyleResolver * styleResolver, CSSValue* value)707 static void applyValue(CSSPropertyID, StyleResolver::State& state, CSSValue* value) 708 708 { 709 709 if (!value->isPrimitiveValue()) … … 712 712 CSSPrimitiveValue* primitiveValue = static_cast<CSSPrimitiveValue*>(value); 713 713 714 FontDescription fontDescription = st yleResolver->style()->fontDescription();714 FontDescription fontDescription = state.style()->fontDescription(); 715 715 fontDescription.setKeywordSize(0); 716 716 float parentSize = 0; … … 718 718 float size = 0; 719 719 720 if (st yleResolver->parentStyle()) {721 parentSize = st yleResolver->parentStyle()->fontDescription().specifiedSize();722 parentIsAbsoluteSize = st yleResolver->parentStyle()->fontDescription().isAbsoluteSize();720 if (state.parentStyle()) { 721 parentSize = state.parentStyle()->fontDescription().specifiedSize(); 722 parentIsAbsoluteSize = state.parentStyle()->fontDescription().isAbsoluteSize(); 723 723 } 724 724 … … 734 734 case CSSValueXxLarge: 735 735 case CSSValueWebkitXxxLarge: 736 size = styleResolver->fontSizeForKeyword(styleResolver->document(), ident, fontDescription.useFixedDefaultSize());736 size = StyleResolver::fontSizeForKeyword(state.document(), ident, fontDescription.useFixedDefaultSize()); 737 737 fontDescription.setKeywordSize(ident - CSSValueXxSmall + 1); 738 738 break; … … 752 752 || !(primitiveValue->isPercentage() || primitiveValue->isFontRelativeLength())); 753 753 if (primitiveValue->isLength()) 754 size = primitiveValue->computeLength<float>(st yleResolver->parentStyle(), styleResolver->rootElementStyle(), 1.0, true);754 size = primitiveValue->computeLength<float>(state.parentStyle(), state.rootElementStyle(), 1.0, true); 755 755 else if (primitiveValue->isPercentage()) 756 756 size = (primitiveValue->getFloatValue() * parentSize) / 100.0f; 757 757 else if (primitiveValue->isCalculatedPercentageWithLength()) 758 size = primitiveValue->cssCalcValue()->toCalcValue(st yleResolver->parentStyle(), styleResolver->rootElementStyle())->evaluate(parentSize);758 size = primitiveValue->cssCalcValue()->toCalcValue(state.parentStyle(), state.rootElementStyle())->evaluate(parentSize); 759 759 else if (primitiveValue->isViewportPercentageLength()) 760 size = valueForLength(primitiveValue->viewportPercentageLength(), 0, st yleResolver->document()->renderView());760 size = valueForLength(primitiveValue->viewportPercentageLength(), 0, state.document()->renderView()); 761 761 else 762 762 return; … … 770 770 size = min(maximumAllowedFontSize, size); 771 771 772 styleResolver->setFontSize(fontDescription, size);773 st yleResolver->setFontDescription(fontDescription);772 StyleResolver::setFontSize(state, fontDescription, size); 773 state.setFontDescription(fontDescription); 774 774 return; 775 775 } … … 780 780 class ApplyPropertyFontWeight { 781 781 public: 782 static void applyValue(CSSPropertyID, StyleResolver * styleResolver, CSSValue* value)782 static void applyValue(CSSPropertyID, StyleResolver::State& state, CSSValue* value) 783 783 { 784 784 if (!value->isPrimitiveValue()) 785 785 return; 786 786 CSSPrimitiveValue* primitiveValue = static_cast<CSSPrimitiveValue*>(value); 787 FontDescription fontDescription = st yleResolver->fontDescription();787 FontDescription fontDescription = state.fontDescription(); 788 788 switch (primitiveValue->getIdent()) { 789 789 case CSSValueInvalid: … … 799 799 fontDescription.setWeight(*primitiveValue); 800 800 } 801 st yleResolver->setFontDescription(fontDescription);801 state.setFontDescription(fontDescription); 802 802 } 803 803 static PropertyHandler createHandler() … … 810 810 class ApplyPropertyFontVariantLigatures { 811 811 public: 812 static void applyInheritValue(CSSPropertyID, StyleResolver * styleResolver)813 { 814 const FontDescription& parentFontDescription = st yleResolver->parentFontDescription();815 FontDescription fontDescription = st yleResolver->fontDescription();812 static void applyInheritValue(CSSPropertyID, StyleResolver::State& state) 813 { 814 const FontDescription& parentFontDescription = state.parentFontDescription(); 815 FontDescription fontDescription = state.fontDescription(); 816 816 817 817 fontDescription.setCommonLigaturesState(parentFontDescription.commonLigaturesState()); … … 819 819 fontDescription.setHistoricalLigaturesState(parentFontDescription.historicalLigaturesState()); 820 820 821 st yleResolver->setFontDescription(fontDescription);822 } 823 824 static void applyInitialValue(CSSPropertyID, StyleResolver * styleResolver)825 { 826 FontDescription fontDescription = st yleResolver->fontDescription();821 state.setFontDescription(fontDescription); 822 } 823 824 static void applyInitialValue(CSSPropertyID, StyleResolver::State& state) 825 { 826 FontDescription fontDescription = state.fontDescription(); 827 827 828 828 fontDescription.setCommonLigaturesState(FontDescription::NormalLigaturesState); … … 830 830 fontDescription.setHistoricalLigaturesState(FontDescription::NormalLigaturesState); 831 831 832 st yleResolver->setFontDescription(fontDescription);833 } 834 835 static void applyValue(CSSPropertyID, StyleResolver * styleResolver, CSSValue* value)832 state.setFontDescription(fontDescription); 833 } 834 835 static void applyValue(CSSPropertyID, StyleResolver::State& state, CSSValue* value) 836 836 { 837 837 FontDescription::LigaturesState commonLigaturesState = FontDescription::NormalLigaturesState; … … 879 879 #endif 880 880 881 FontDescription fontDescription = st yleResolver->fontDescription();881 FontDescription fontDescription = state.fontDescription(); 882 882 fontDescription.setCommonLigaturesState(commonLigaturesState); 883 883 fontDescription.setDiscretionaryLigaturesState(discretionaryLigaturesState); 884 884 fontDescription.setHistoricalLigaturesState(historicalLigaturesState); 885 st yleResolver->setFontDescription(fontDescription);885 state.setFontDescription(fontDescription); 886 886 } 887 887 … … 899 899 class ApplyPropertyBorderImage { 900 900 public: 901 static void applyValue(CSSPropertyID, StyleResolver * styleResolver, CSSValue* value)901 static void applyValue(CSSPropertyID, StyleResolver::State& state, CSSValue* value) 902 902 { 903 903 NinePieceImage image; 904 904 if (borderImageType == BorderMask) 905 905 image.setMaskDefaults(); 906 styleResolver->styleMap()->mapNinePieceImage(property, value, image); 907 (styleResolver->style()->*setterFunction)(image); 906 CSSToStyleMap styleMap(state); 907 styleMap.mapNinePieceImage(property, value, image); 908 (state.style()->*setterFunction)(image); 908 909 } 909 910 … … 922 923 static inline void setValue(RenderStyle* style, const NinePieceImage& value) { return type == BorderImage ? style->setBorderImage(value) : style->setMaskBoxImage(value); } 923 924 public: 924 static void applyInheritValue(CSSPropertyID, StyleResolver * styleResolver)925 { 926 NinePieceImage image(getValue(st yleResolver->style()));925 static void applyInheritValue(CSSPropertyID, StyleResolver::State& state) 926 { 927 NinePieceImage image(getValue(state.style())); 927 928 switch (modifier) { 928 929 case Outset: 929 image.copyOutsetFrom(getValue(st yleResolver->parentStyle()));930 image.copyOutsetFrom(getValue(state.parentStyle())); 930 931 break; 931 932 case Repeat: 932 image.copyRepeatFrom(getValue(st yleResolver->parentStyle()));933 image.copyRepeatFrom(getValue(state.parentStyle())); 933 934 break; 934 935 case Slice: 935 image.copyImageSlicesFrom(getValue(st yleResolver->parentStyle()));936 image.copyImageSlicesFrom(getValue(state.parentStyle())); 936 937 break; 937 938 case Width: 938 image.copyBorderSlicesFrom(getValue(st yleResolver->parentStyle()));939 break; 940 } 941 setValue(st yleResolver->style(), image);942 } 943 944 static void applyInitialValue(CSSPropertyID, StyleResolver * styleResolver)945 { 946 NinePieceImage image(getValue(st yleResolver->style()));939 image.copyBorderSlicesFrom(getValue(state.parentStyle())); 940 break; 941 } 942 setValue(state.style(), image); 943 } 944 945 static void applyInitialValue(CSSPropertyID, StyleResolver::State& state) 946 { 947 NinePieceImage image(getValue(state.style())); 947 948 switch (modifier) { 948 949 case Outset: … … 963 964 break; 964 965 } 965 setValue(styleResolver->style(), image); 966 } 967 968 static void applyValue(CSSPropertyID, StyleResolver* styleResolver, CSSValue* value) 969 { 970 NinePieceImage image(getValue(styleResolver->style())); 966 setValue(state.style(), image); 967 } 968 969 static void applyValue(CSSPropertyID, StyleResolver::State& state, CSSValue* value) 970 { 971 NinePieceImage image(getValue(state.style())); 972 CSSToStyleMap styleMap(state); 971 973 switch (modifier) { 972 974 case Outset: 973 image.setOutset(style Resolver->styleMap()->mapNinePieceImageQuad(value));975 image.setOutset(styleMap.mapNinePieceImageQuad(value)); 974 976 break; 975 977 case Repeat: 976 style Resolver->styleMap()->mapNinePieceImageRepeat(value, image);978 styleMap.mapNinePieceImageRepeat(value, image); 977 979 break; 978 980 case Slice: 979 style Resolver->styleMap()->mapNinePieceImageSlice(value, image);981 styleMap.mapNinePieceImageSlice(value, image); 980 982 break; 981 983 case Width: 982 image.setBorderSlices(style Resolver->styleMap()->mapNinePieceImageQuad(value));983 break; 984 } 985 setValue(st yleResolver->style(), image);984 image.setBorderSlices(styleMap.mapNinePieceImageQuad(value)); 985 break; 986 } 987 setValue(state.style(), image); 986 988 } 987 989 … … 992 994 class ApplyPropertyBorderImageSource { 993 995 public: 994 static void applyValue(CSSPropertyID, StyleResolver * styleResolver, CSSValue* value) { (styleResolver->style()->*setterFunction)(styleResolver->styleImage(id, value)); }996 static void applyValue(CSSPropertyID, StyleResolver::State& state, CSSValue* value) { (state.style()->*setterFunction)(StyleResolver::styleImage(state, id, value)); } 995 997 static PropertyHandler createHandler() 996 998 { … … 1004 1006 class ApplyPropertyCounter { 1005 1007 public: 1006 static void emptyFunction(CSSPropertyID, StyleResolver *) { }1007 static void applyInheritValue(CSSPropertyID, StyleResolver * styleResolver)1008 { 1009 CounterDirectiveMap& map = st yleResolver->style()->accessCounterDirectives();1010 CounterDirectiveMap& parentMap = st yleResolver->parentStyle()->accessCounterDirectives();1008 static void emptyFunction(CSSPropertyID, StyleResolver::State&) { } 1009 static void applyInheritValue(CSSPropertyID, StyleResolver::State& state) 1010 { 1011 CounterDirectiveMap& map = state.style()->accessCounterDirectives(); 1012 CounterDirectiveMap& parentMap = state.parentStyle()->accessCounterDirectives(); 1011 1013 1012 1014 typedef CounterDirectiveMap::iterator Iterator; … … 1021 1023 } 1022 1024 } 1023 static void applyValue(CSSPropertyID, StyleResolver * styleResolver, CSSValue* value)1025 static void applyValue(CSSPropertyID, StyleResolver::State& state, CSSValue* value) 1024 1026 { 1025 1027 if (!value->isValueList()) … … 1028 1030 CSSValueList* list = static_cast<CSSValueList*>(value); 1029 1031 1030 CounterDirectiveMap& map = st yleResolver->style()->accessCounterDirectives();1032 CounterDirectiveMap& map = state.style()->accessCounterDirectives(); 1031 1033 typedef CounterDirectiveMap::iterator Iterator; 1032 1034 … … 1064 1066 class ApplyPropertyCursor { 1065 1067 public: 1066 static void applyInheritValue(CSSPropertyID, StyleResolver * styleResolver)1067 { 1068 st yleResolver->style()->setCursor(styleResolver->parentStyle()->cursor());1069 st yleResolver->style()->setCursorList(styleResolver->parentStyle()->cursors());1070 } 1071 1072 static void applyInitialValue(CSSPropertyID, StyleResolver * styleResolver)1073 { 1074 st yleResolver->style()->clearCursorList();1075 st yleResolver->style()->setCursor(RenderStyle::initialCursor());1076 } 1077 1078 static void applyValue(CSSPropertyID, StyleResolver * styleResolver, CSSValue* value)1079 { 1080 st yleResolver->style()->clearCursorList();1068 static void applyInheritValue(CSSPropertyID, StyleResolver::State& state) 1069 { 1070 state.style()->setCursor(state.parentStyle()->cursor()); 1071 state.style()->setCursorList(state.parentStyle()->cursors()); 1072 } 1073 1074 static void applyInitialValue(CSSPropertyID, StyleResolver::State& state) 1075 { 1076 state.style()->clearCursorList(); 1077 state.style()->setCursor(RenderStyle::initialCursor()); 1078 } 1079 1080 static void applyValue(CSSPropertyID, StyleResolver::State& state, CSSValue* value) 1081 { 1082 state.style()->clearCursorList(); 1081 1083 if (value->isValueList()) { 1082 1084 CSSValueList* list = static_cast<CSSValueList*>(value); 1083 1085 int len = list->length(); 1084 st yleResolver->style()->setCursor(CURSOR_AUTO);1086 state.style()->setCursor(CURSOR_AUTO); 1085 1087 for (int i = 0; i < len; i++) { 1086 1088 CSSValue* item = list->itemWithoutBoundsCheck(i); 1087 1089 if (item->isCursorImageValue()) { 1088 1090 CSSCursorImageValue* image = static_cast<CSSCursorImageValue*>(item); 1089 if (image->updateIfSVGCursorIsUsed(st yleResolver->element())) // Elements with SVG cursors are not allowed to share style.1090 st yleResolver->style()->setUnique();1091 st yleResolver->style()->addCursor(styleResolver->styleImage(CSSPropertyCursor, image), image->hotSpot());1091 if (image->updateIfSVGCursorIsUsed(state.element())) // Elements with SVG cursors are not allowed to share style. 1092 state.style()->setUnique(); 1093 state.style()->addCursor(StyleResolver::styleImage(state, CSSPropertyCursor, image), image->hotSpot()); 1092 1094 } else if (item->isPrimitiveValue()) { 1093 1095 CSSPrimitiveValue* primitiveValue = static_cast<CSSPrimitiveValue*>(item); 1094 1096 if (primitiveValue->isIdent()) 1095 st yleResolver->style()->setCursor(*primitiveValue);1097 state.style()->setCursor(*primitiveValue); 1096 1098 } 1097 1099 } 1098 1100 } else if (value->isPrimitiveValue()) { 1099 1101 CSSPrimitiveValue* primitiveValue = static_cast<CSSPrimitiveValue*>(value); 1100 if (primitiveValue->isIdent() && st yleResolver->style()->cursor() != ECursor(*primitiveValue))1101 st yleResolver->style()->setCursor(*primitiveValue);1102 if (primitiveValue->isIdent() && state.style()->cursor() != ECursor(*primitiveValue)) 1103 state.style()->setCursor(*primitiveValue); 1102 1104 } 1103 1105 } … … 1108 1110 class ApplyPropertyTextAlign { 1109 1111 public: 1110 static void applyValue(CSSPropertyID, StyleResolver * styleResolver, CSSValue* value)1112 static void applyValue(CSSPropertyID, StyleResolver::State& state, CSSValue* value) 1111 1113 { 1112 1114 if (!value->isPrimitiveValue()) … … 1116 1118 1117 1119 if (primitiveValue->getIdent() != CSSValueWebkitMatchParent) 1118 st yleResolver->style()->setTextAlign(*primitiveValue);1119 else if (st yleResolver->parentStyle()->textAlign() == TASTART)1120 st yleResolver->style()->setTextAlign(styleResolver->parentStyle()->isLeftToRightDirection() ? LEFT : RIGHT);1121 else if (st yleResolver->parentStyle()->textAlign() == TAEND)1122 st yleResolver->style()->setTextAlign(styleResolver->parentStyle()->isLeftToRightDirection() ? RIGHT : LEFT);1120 state.style()->setTextAlign(*primitiveValue); 1121 else if (state.parentStyle()->textAlign() == TASTART) 1122 state.style()->setTextAlign(state.parentStyle()->isLeftToRightDirection() ? LEFT : RIGHT); 1123 else if (state.parentStyle()->textAlign() == TAEND) 1124 state.style()->setTextAlign(state.parentStyle()->isLeftToRightDirection() ? RIGHT : LEFT); 1123 1125 else 1124 st yleResolver->style()->setTextAlign(styleResolver->parentStyle()->textAlign());1126 state.style()->setTextAlign(state.parentStyle()->textAlign()); 1125 1127 } 1126 1128 static PropertyHandler createHandler() … … 1133 1135 class ApplyPropertyTextDecoration { 1134 1136 public: 1135 static void applyValue(CSSPropertyID, StyleResolver * styleResolver, CSSValue* value)1137 static void applyValue(CSSPropertyID, StyleResolver::State& state, CSSValue* value) 1136 1138 { 1137 1139 ETextDecoration t = RenderStyle::initialTextDecoration(); … … 1141 1143 t |= *static_cast<CSSPrimitiveValue*>(item); 1142 1144 } 1143 st yleResolver->style()->setTextDecoration(t);1145 state.style()->setTextDecoration(t); 1144 1146 } 1145 1147 static PropertyHandler createHandler() … … 1152 1154 class ApplyPropertyLineHeight { 1153 1155 public: 1154 static void applyValue(CSSPropertyID, StyleResolver * styleResolver, CSSValue* value)1156 static void applyValue(CSSPropertyID, StyleResolver::State& state, CSSValue* value) 1155 1157 { 1156 1158 if (!value->isPrimitiveValue()) … … 1163 1165 lineHeight = RenderStyle::initialLineHeight(); 1164 1166 else if (primitiveValue->isLength()) { 1165 double multiplier = st yleResolver->style()->effectiveZoom();1166 if (st yleResolver->style()->textSizeAdjust()) {1167 if (Frame* frame = st yleResolver->document()->frame())1167 double multiplier = state.style()->effectiveZoom(); 1168 if (state.style()->textSizeAdjust()) { 1169 if (Frame* frame = state.document()->frame()) 1168 1170 multiplier *= frame->textZoomFactor(); 1169 1171 } 1170 lineHeight = primitiveValue->computeLength<Length>(st yleResolver->style(), styleResolver->rootElementStyle(), multiplier);1172 lineHeight = primitiveValue->computeLength<Length>(state.style(), state.rootElementStyle(), multiplier); 1171 1173 } else if (primitiveValue->isPercentage()) { 1172 1174 // FIXME: percentage should not be restricted to an integer here. 1173 lineHeight = Length((st yleResolver->style()->fontSize() * primitiveValue->getIntValue()) / 100, Fixed);1175 lineHeight = Length((state.style()->fontSize() * primitiveValue->getIntValue()) / 100, Fixed); 1174 1176 } else if (primitiveValue->isNumber()) { 1175 1177 // FIXME: number and percentage values should produce the same type of Length (ie. Fixed or Percent). … … 1179 1181 else 1180 1182 return; 1181 st yleResolver->style()->setLineHeight(lineHeight);1183 state.style()->setLineHeight(lineHeight); 1182 1184 } 1183 1185 static PropertyHandler createHandler() … … 1266 1268 } 1267 1269 public: 1268 static void applyInheritValue(CSSPropertyID, StyleResolver *) { }1269 static void applyInitialValue(CSSPropertyID, StyleResolver *) { }1270 static void applyValue(CSSPropertyID, StyleResolver * styleResolver, CSSValue* value)1271 { 1272 st yleResolver->style()->resetPageSizeType();1270 static void applyInheritValue(CSSPropertyID, StyleResolver::State&) { } 1271 static void applyInitialValue(CSSPropertyID, StyleResolver::State&) { } 1272 static void applyValue(CSSPropertyID, StyleResolver::State& state, CSSValue* value) 1273 { 1274 state.style()->resetPageSizeType(); 1273 1275 Length width; 1274 1276 Length height; … … 1286 1288 if (!second->isLength()) 1287 1289 return; 1288 width = first->computeLength<Length>(st yleResolver->style(), styleResolver->rootElementStyle());1289 height = second->computeLength<Length>(st yleResolver->style(), styleResolver->rootElementStyle());1290 width = first->computeLength<Length>(state.style(), state.rootElementStyle()); 1291 height = second->computeLength<Length>(state.style(), state.rootElementStyle()); 1290 1292 } else { 1291 1293 // <page-size> <orientation> … … 1305 1307 // <length> 1306 1308 pageSizeType = PAGE_SIZE_RESOLVED; 1307 width = height = primitiveValue->computeLength<Length>(st yleResolver->style(), styleResolver->rootElementStyle());1309 width = height = primitiveValue->computeLength<Length>(state.style(), state.rootElementStyle()); 1308 1310 } else { 1309 1311 switch (primitiveValue->getIdent()) { … … 1331 1333 return; 1332 1334 } 1333 st yleResolver->style()->setPageSizeType(pageSizeType);1334 st yleResolver->style()->setPageSize(LengthSize(width, height));1335 state.style()->setPageSizeType(pageSizeType); 1336 state.style()->setPageSize(LengthSize(width, height)); 1335 1337 } 1336 1338 static PropertyHandler createHandler() { return PropertyHandler(&applyInheritValue, &applyInitialValue, &applyValue); } … … 1339 1341 class ApplyPropertyTextEmphasisStyle { 1340 1342 public: 1341 static void applyInheritValue(CSSPropertyID, StyleResolver * styleResolver)1342 { 1343 st yleResolver->style()->setTextEmphasisFill(styleResolver->parentStyle()->textEmphasisFill());1344 st yleResolver->style()->setTextEmphasisMark(styleResolver->parentStyle()->textEmphasisMark());1345 st yleResolver->style()->setTextEmphasisCustomMark(styleResolver->parentStyle()->textEmphasisCustomMark());1346 } 1347 1348 static void applyInitialValue(CSSPropertyID, StyleResolver * styleResolver)1349 { 1350 st yleResolver->style()->setTextEmphasisFill(RenderStyle::initialTextEmphasisFill());1351 st yleResolver->style()->setTextEmphasisMark(RenderStyle::initialTextEmphasisMark());1352 st yleResolver->style()->setTextEmphasisCustomMark(RenderStyle::initialTextEmphasisCustomMark());1353 } 1354 1355 static void applyValue(CSSPropertyID, StyleResolver * styleResolver, CSSValue* value)1343 static void applyInheritValue(CSSPropertyID, StyleResolver::State& state) 1344 { 1345 state.style()->setTextEmphasisFill(state.parentStyle()->textEmphasisFill()); 1346 state.style()->setTextEmphasisMark(state.parentStyle()->textEmphasisMark()); 1347 state.style()->setTextEmphasisCustomMark(state.parentStyle()->textEmphasisCustomMark()); 1348 } 1349 1350 static void applyInitialValue(CSSPropertyID, StyleResolver::State& state) 1351 { 1352 state.style()->setTextEmphasisFill(RenderStyle::initialTextEmphasisFill()); 1353 state.style()->setTextEmphasisMark(RenderStyle::initialTextEmphasisMark()); 1354 state.style()->setTextEmphasisCustomMark(RenderStyle::initialTextEmphasisCustomMark()); 1355 } 1356 1357 static void applyValue(CSSPropertyID, StyleResolver::State& state, CSSValue* value) 1356 1358 { 1357 1359 if (value->isValueList()) { … … 1367 1369 CSSPrimitiveValue* value = static_cast<CSSPrimitiveValue*>(item); 1368 1370 if (value->getIdent() == CSSValueFilled || value->getIdent() == CSSValueOpen) 1369 st yleResolver->style()->setTextEmphasisFill(*value);1371 state.style()->setTextEmphasisFill(*value); 1370 1372 else 1371 st yleResolver->style()->setTextEmphasisMark(*value);1373 state.style()->setTextEmphasisMark(*value); 1372 1374 } 1373 st yleResolver->style()->setTextEmphasisCustomMark(nullAtom);1375 state.style()->setTextEmphasisCustomMark(nullAtom); 1374 1376 return; 1375 1377 } … … 1380 1382 1381 1383 if (primitiveValue->isString()) { 1382 st yleResolver->style()->setTextEmphasisFill(TextEmphasisFillFilled);1383 st yleResolver->style()->setTextEmphasisMark(TextEmphasisMarkCustom);1384 st yleResolver->style()->setTextEmphasisCustomMark(primitiveValue->getStringValue());1385 return; 1386 } 1387 1388 st yleResolver->style()->setTextEmphasisCustomMark(nullAtom);1384 state.style()->setTextEmphasisFill(TextEmphasisFillFilled); 1385 state.style()->setTextEmphasisMark(TextEmphasisMarkCustom); 1386 state.style()->setTextEmphasisCustomMark(primitiveValue->getStringValue()); 1387 return; 1388 } 1389 1390 state.style()->setTextEmphasisCustomMark(nullAtom); 1389 1391 1390 1392 if (primitiveValue->getIdent() == CSSValueFilled || primitiveValue->getIdent() == CSSValueOpen) { 1391 st yleResolver->style()->setTextEmphasisFill(*primitiveValue);1392 st yleResolver->style()->setTextEmphasisMark(TextEmphasisMarkAuto);1393 state.style()->setTextEmphasisFill(*primitiveValue); 1394 state.style()->setTextEmphasisMark(TextEmphasisMarkAuto); 1393 1395 } else { 1394 st yleResolver->style()->setTextEmphasisFill(TextEmphasisFillFilled);1395 st yleResolver->style()->setTextEmphasisMark(*primitiveValue);1396 state.style()->setTextEmphasisFill(TextEmphasisFillFilled); 1397 state.style()->setTextEmphasisMark(*primitiveValue); 1396 1398 } 1397 1399 } … … 1416 1418 static void clear(Animation* animation) { (animation->*clearFunction)(); } 1417 1419 static T initial() { return (*initialFunction)(); } 1418 static void map(StyleResolver* styleResolver, Animation* animation, CSSValue* value) { (styleResolver->styleMap()->*mapFunction)(animation, value); } 1420 static void map(StyleResolver::State& state, Animation* animation, CSSValue* value) 1421 { 1422 CSSToStyleMap styleMap(state); 1423 (styleMap.*mapFunction)(animation, value); 1424 } 1419 1425 static AnimationList* accessAnimations(RenderStyle* style) { return (style->*animationGetterFunction)(); } 1420 1426 static const AnimationList* animations(RenderStyle* style) { return (style->*immutableAnimationGetterFunction)(); } 1421 1427 1422 static void applyInheritValue(CSSPropertyID, StyleResolver * styleResolver)1423 { 1424 AnimationList* list = accessAnimations(st yleResolver->style());1425 const AnimationList* parentList = animations(st yleResolver->parentStyle());1428 static void applyInheritValue(CSSPropertyID, StyleResolver::State& state) 1429 { 1430 AnimationList* list = accessAnimations(state.style()); 1431 const AnimationList* parentList = animations(state.parentStyle()); 1426 1432 size_t i = 0, parentSize = parentList ? parentList->size() : 0; 1427 1433 for ( ; i < parentSize && test(parentList->animation(i)); ++i) { … … 1437 1443 } 1438 1444 1439 static void applyInitialValue(CSSPropertyID propertyID, StyleResolver * styleResolver)1440 { 1441 AnimationList* list = accessAnimations(st yleResolver->style());1445 static void applyInitialValue(CSSPropertyID propertyID, StyleResolver::State& state) 1446 { 1447 AnimationList* list = accessAnimations(state.style()); 1442 1448 if (list->isEmpty()) 1443 1449 list->append(Animation::create()); … … 1449 1455 } 1450 1456 1451 static void applyValue(CSSPropertyID, StyleResolver * styleResolver, CSSValue* value)1452 { 1453 AnimationList* list = accessAnimations(st yleResolver->style());1457 static void applyValue(CSSPropertyID, StyleResolver::State& state, CSSValue* value) 1458 { 1459 AnimationList* list = accessAnimations(state.style()); 1454 1460 size_t childIndex = 0; 1455 1461 if (value->isValueList()) { … … 1458 1464 if (childIndex <= list->size()) 1459 1465 list->append(Animation::create()); 1460 map(st yleResolver, list->animation(childIndex), i.value());1466 map(state, list->animation(childIndex), i.value()); 1461 1467 ++childIndex; 1462 1468 } … … 1464 1470 if (list->isEmpty()) 1465 1471 list->append(Animation::create()); 1466 map(st yleResolver, list->animation(childIndex), value);1472 map(state, list->animation(childIndex), value); 1467 1473 childIndex = 1; 1468 1474 } … … 1478 1484 class ApplyPropertyOutlineStyle { 1479 1485 public: 1480 static void applyInheritValue(CSSPropertyID propertyID, StyleResolver * styleResolver)1481 { 1482 ApplyPropertyDefaultBase<OutlineIsAuto, &RenderStyle::outlineStyleIsAuto, OutlineIsAuto, &RenderStyle::setOutlineStyleIsAuto, OutlineIsAuto, &RenderStyle::initialOutlineStyleIsAuto>::applyInheritValue(propertyID, st yleResolver);1483 ApplyPropertyDefaultBase<EBorderStyle, &RenderStyle::outlineStyle, EBorderStyle, &RenderStyle::setOutlineStyle, EBorderStyle, &RenderStyle::initialBorderStyle>::applyInheritValue(propertyID, st yleResolver);1484 } 1485 1486 static void applyInitialValue(CSSPropertyID propertyID, StyleResolver * styleResolver)1487 { 1488 ApplyPropertyDefaultBase<OutlineIsAuto, &RenderStyle::outlineStyleIsAuto, OutlineIsAuto, &RenderStyle::setOutlineStyleIsAuto, OutlineIsAuto, &RenderStyle::initialOutlineStyleIsAuto>::applyInitialValue(propertyID, st yleResolver);1489 ApplyPropertyDefaultBase<EBorderStyle, &RenderStyle::outlineStyle, EBorderStyle, &RenderStyle::setOutlineStyle, EBorderStyle, &RenderStyle::initialBorderStyle>::applyInitialValue(propertyID, st yleResolver);1490 } 1491 1492 static void applyValue(CSSPropertyID propertyID, StyleResolver * styleResolver, CSSValue* value)1493 { 1494 ApplyPropertyDefault<OutlineIsAuto, &RenderStyle::outlineStyleIsAuto, OutlineIsAuto, &RenderStyle::setOutlineStyleIsAuto, OutlineIsAuto, &RenderStyle::initialOutlineStyleIsAuto>::applyValue(propertyID, st yleResolver, value);1495 ApplyPropertyDefault<EBorderStyle, &RenderStyle::outlineStyle, EBorderStyle, &RenderStyle::setOutlineStyle, EBorderStyle, &RenderStyle::initialBorderStyle>::applyValue(propertyID, st yleResolver, value);1486 static void applyInheritValue(CSSPropertyID propertyID, StyleResolver::State& state) 1487 { 1488 ApplyPropertyDefaultBase<OutlineIsAuto, &RenderStyle::outlineStyleIsAuto, OutlineIsAuto, &RenderStyle::setOutlineStyleIsAuto, OutlineIsAuto, &RenderStyle::initialOutlineStyleIsAuto>::applyInheritValue(propertyID, state); 1489 ApplyPropertyDefaultBase<EBorderStyle, &RenderStyle::outlineStyle, EBorderStyle, &RenderStyle::setOutlineStyle, EBorderStyle, &RenderStyle::initialBorderStyle>::applyInheritValue(propertyID, state); 1490 } 1491 1492 static void applyInitialValue(CSSPropertyID propertyID, StyleResolver::State& state) 1493 { 1494 ApplyPropertyDefaultBase<OutlineIsAuto, &RenderStyle::outlineStyleIsAuto, OutlineIsAuto, &RenderStyle::setOutlineStyleIsAuto, OutlineIsAuto, &RenderStyle::initialOutlineStyleIsAuto>::applyInitialValue(propertyID, state); 1495 ApplyPropertyDefaultBase<EBorderStyle, &RenderStyle::outlineStyle, EBorderStyle, &RenderStyle::setOutlineStyle, EBorderStyle, &RenderStyle::initialBorderStyle>::applyInitialValue(propertyID, state); 1496 } 1497 1498 static void applyValue(CSSPropertyID propertyID, StyleResolver::State& state, CSSValue* value) 1499 { 1500 ApplyPropertyDefault<OutlineIsAuto, &RenderStyle::outlineStyleIsAuto, OutlineIsAuto, &RenderStyle::setOutlineStyleIsAuto, OutlineIsAuto, &RenderStyle::initialOutlineStyleIsAuto>::applyValue(propertyID, state, value); 1501 ApplyPropertyDefault<EBorderStyle, &RenderStyle::outlineStyle, EBorderStyle, &RenderStyle::setOutlineStyle, EBorderStyle, &RenderStyle::initialBorderStyle>::applyValue(propertyID, state, value); 1496 1502 } 1497 1503 … … 1501 1507 class ApplyPropertyResize { 1502 1508 public: 1503 static void applyValue(CSSPropertyID, StyleResolver * styleResolver, CSSValue* value)1509 static void applyValue(CSSPropertyID, StyleResolver::State& state, CSSValue* value) 1504 1510 { 1505 1511 if (!value->isPrimitiveValue()) … … 1513 1519 return; 1514 1520 case CSSValueAuto: 1515 if (Settings* settings = st yleResolver->document()->settings())1521 if (Settings* settings = state.document()->settings()) 1516 1522 r = settings->textAreasAreResizable() ? RESIZE_BOTH : RESIZE_NONE; 1517 1523 break; … … 1519 1525 r = *primitiveValue; 1520 1526 } 1521 st yleResolver->style()->setResize(r);1527 state.style()->setResize(r); 1522 1528 } 1523 1529 … … 1531 1537 class ApplyPropertyVerticalAlign { 1532 1538 public: 1533 static void applyValue(CSSPropertyID, StyleResolver * styleResolver, CSSValue* value)1539 static void applyValue(CSSPropertyID, StyleResolver::State& state, CSSValue* value) 1534 1540 { 1535 1541 if (!value->isPrimitiveValue()) … … 1539 1545 1540 1546 if (primitiveValue->getIdent()) 1541 return st yleResolver->style()->setVerticalAlign(*primitiveValue);1542 1543 st yleResolver->style()->setVerticalAlignLength(primitiveValue->convertToLength<FixedIntegerConversion | PercentConversion | CalculatedConversion | ViewportPercentageConversion>(styleResolver->style(), styleResolver->rootElementStyle(), styleResolver->style()->effectiveZoom()));1547 return state.style()->setVerticalAlign(*primitiveValue); 1548 1549 state.style()->setVerticalAlignLength(primitiveValue->convertToLength<FixedIntegerConversion | PercentConversion | CalculatedConversion | ViewportPercentageConversion>(state.style(), state.rootElementStyle(), state.style()->effectiveZoom())); 1544 1550 } 1545 1551 … … 1553 1559 class ApplyPropertyAspectRatio { 1554 1560 public: 1555 static void applyInheritValue(CSSPropertyID, StyleResolver * styleResolver)1556 { 1557 if (!st yleResolver->parentStyle()->hasAspectRatio())1558 return; 1559 st yleResolver->style()->setHasAspectRatio(true);1560 st yleResolver->style()->setAspectRatioDenominator(styleResolver->parentStyle()->aspectRatioDenominator());1561 st yleResolver->style()->setAspectRatioNumerator(styleResolver->parentStyle()->aspectRatioNumerator());1562 } 1563 1564 static void applyInitialValue(CSSPropertyID, StyleResolver * styleResolver)1565 { 1566 st yleResolver->style()->setHasAspectRatio(RenderStyle::initialHasAspectRatio());1567 st yleResolver->style()->setAspectRatioDenominator(RenderStyle::initialAspectRatioDenominator());1568 st yleResolver->style()->setAspectRatioNumerator(RenderStyle::initialAspectRatioNumerator());1569 } 1570 1571 static void applyValue(CSSPropertyID, StyleResolver * styleResolver, CSSValue* value)1561 static void applyInheritValue(CSSPropertyID, StyleResolver::State& state) 1562 { 1563 if (!state.parentStyle()->hasAspectRatio()) 1564 return; 1565 state.style()->setHasAspectRatio(true); 1566 state.style()->setAspectRatioDenominator(state.parentStyle()->aspectRatioDenominator()); 1567 state.style()->setAspectRatioNumerator(state.parentStyle()->aspectRatioNumerator()); 1568 } 1569 1570 static void applyInitialValue(CSSPropertyID, StyleResolver::State& state) 1571 { 1572 state.style()->setHasAspectRatio(RenderStyle::initialHasAspectRatio()); 1573 state.style()->setAspectRatioDenominator(RenderStyle::initialAspectRatioDenominator()); 1574 state.style()->setAspectRatioNumerator(RenderStyle::initialAspectRatioNumerator()); 1575 } 1576 1577 static void applyValue(CSSPropertyID, StyleResolver::State& state, CSSValue* value) 1572 1578 { 1573 1579 if (!value->isAspectRatioValue()) { 1574 st yleResolver->style()->setHasAspectRatio(false);1580 state.style()->setHasAspectRatio(false); 1575 1581 return; 1576 1582 } 1577 1583 CSSAspectRatioValue* aspectRatioValue = static_cast<CSSAspectRatioValue*>(value); 1578 st yleResolver->style()->setHasAspectRatio(true);1579 st yleResolver->style()->setAspectRatioDenominator(aspectRatioValue->denominatorValue());1580 st yleResolver->style()->setAspectRatioNumerator(aspectRatioValue->numeratorValue());1584 state.style()->setHasAspectRatio(true); 1585 state.style()->setAspectRatioDenominator(aspectRatioValue->denominatorValue()); 1586 state.style()->setAspectRatioNumerator(aspectRatioValue->numeratorValue()); 1581 1587 } 1582 1588 … … 1589 1595 class ApplyPropertyZoom { 1590 1596 private: 1591 static void resetEffectiveZoom(StyleResolver * styleResolver)1597 static void resetEffectiveZoom(StyleResolver::State& state) 1592 1598 { 1593 1599 // Reset the zoom in effect. This allows the setZoom method to accurately compute a new zoom in effect. 1594 st yleResolver->setEffectiveZoom(styleResolver->parentStyle() ? styleResolver->parentStyle()->effectiveZoom() : RenderStyle::initialZoom());1595 } 1596 1597 public: 1598 static void applyInheritValue(CSSPropertyID, StyleResolver * styleResolver)1599 { 1600 resetEffectiveZoom(st yleResolver);1601 st yleResolver->setZoom(styleResolver->parentStyle()->zoom());1602 } 1603 1604 static void applyInitialValue(CSSPropertyID, StyleResolver * styleResolver)1605 { 1606 resetEffectiveZoom(st yleResolver);1607 st yleResolver->setZoom(RenderStyle::initialZoom());1608 } 1609 1610 static void applyValue(CSSPropertyID, StyleResolver * styleResolver, CSSValue* value)1600 state.setEffectiveZoom(state.parentStyle() ? state.parentStyle()->effectiveZoom() : RenderStyle::initialZoom()); 1601 } 1602 1603 public: 1604 static void applyInheritValue(CSSPropertyID, StyleResolver::State& state) 1605 { 1606 resetEffectiveZoom(state); 1607 state.setZoom(state.parentStyle()->zoom()); 1608 } 1609 1610 static void applyInitialValue(CSSPropertyID, StyleResolver::State& state) 1611 { 1612 resetEffectiveZoom(state); 1613 state.setZoom(RenderStyle::initialZoom()); 1614 } 1615 1616 static void applyValue(CSSPropertyID, StyleResolver::State& state, CSSValue* value) 1611 1617 { 1612 1618 ASSERT_WITH_SECURITY_IMPLICATION(value->isPrimitiveValue()); … … 1614 1620 1615 1621 if (primitiveValue->getIdent() == CSSValueNormal) { 1616 resetEffectiveZoom(st yleResolver);1617 st yleResolver->setZoom(RenderStyle::initialZoom());1622 resetEffectiveZoom(state); 1623 state.setZoom(RenderStyle::initialZoom()); 1618 1624 } else if (primitiveValue->getIdent() == CSSValueReset) { 1619 st yleResolver->setEffectiveZoom(RenderStyle::initialZoom());1620 st yleResolver->setZoom(RenderStyle::initialZoom());1625 state.setEffectiveZoom(RenderStyle::initialZoom()); 1626 state.setZoom(RenderStyle::initialZoom()); 1621 1627 } else if (primitiveValue->getIdent() == CSSValueDocument) { 1622 float docZoom = st yleResolver->rootElementStyle() ? styleResolver->rootElementStyle()->zoom() : RenderStyle::initialZoom();1623 st yleResolver->setEffectiveZoom(docZoom);1624 st yleResolver->setZoom(docZoom);1628 float docZoom = state.rootElementStyle() ? state.rootElementStyle()->zoom() : RenderStyle::initialZoom(); 1629 state.setEffectiveZoom(docZoom); 1630 state.setZoom(docZoom); 1625 1631 } else if (primitiveValue->isPercentage()) { 1626 resetEffectiveZoom(st yleResolver);1632 resetEffectiveZoom(state); 1627 1633 if (float percent = primitiveValue->getFloatValue()) 1628 st yleResolver->setZoom(percent / 100.0f);1634 state.setZoom(percent / 100.0f); 1629 1635 } else if (primitiveValue->isNumber()) { 1630 resetEffectiveZoom(st yleResolver);1636 resetEffectiveZoom(state); 1631 1637 if (float number = primitiveValue->getFloatValue()) 1632 st yleResolver->setZoom(number);1638 state.setZoom(number); 1633 1639 } 1634 1640 } … … 1642 1648 class ApplyPropertyDisplay { 1643 1649 private: 1644 static inline bool isValidDisplayValue(StyleResolver * styleResolver, EDisplay displayPropertyValue)1650 static inline bool isValidDisplayValue(StyleResolver::State& state, EDisplay displayPropertyValue) 1645 1651 { 1646 1652 #if ENABLE(SVG) 1647 if (st yleResolver->element() && styleResolver->element()->isSVGElement() && styleResolver->style()->styleType() == NOPSEUDO)1653 if (state.element() && state.element()->isSVGElement() && state.style()->styleType() == NOPSEUDO) 1648 1654 return (displayPropertyValue == INLINE || displayPropertyValue == BLOCK || displayPropertyValue == NONE); 1649 1655 #else 1650 UNUSED_PARAM(st yleResolver);1656 UNUSED_PARAM(state); 1651 1657 UNUSED_PARAM(displayPropertyValue); 1652 1658 #endif … … 1654 1660 } 1655 1661 public: 1656 static void applyInheritValue(CSSPropertyID, StyleResolver * styleResolver)1657 { 1658 EDisplay display = st yleResolver->parentStyle()->display();1659 if (!isValidDisplayValue(st yleResolver, display))1660 return; 1661 st yleResolver->style()->setDisplay(display);1662 } 1663 1664 static void applyInitialValue(CSSPropertyID, StyleResolver * styleResolver)1665 { 1666 st yleResolver->style()->setDisplay(RenderStyle::initialDisplay());1667 } 1668 1669 static void applyValue(CSSPropertyID, StyleResolver * styleResolver, CSSValue* value)1662 static void applyInheritValue(CSSPropertyID, StyleResolver::State& state) 1663 { 1664 EDisplay display = state.parentStyle()->display(); 1665 if (!isValidDisplayValue(state, display)) 1666 return; 1667 state.style()->setDisplay(display); 1668 } 1669 1670 static void applyInitialValue(CSSPropertyID, StyleResolver::State& state) 1671 { 1672 state.style()->setDisplay(RenderStyle::initialDisplay()); 1673 } 1674 1675 static void applyValue(CSSPropertyID, StyleResolver::State& state, CSSValue* value) 1670 1676 { 1671 1677 if (!value->isPrimitiveValue()) … … 1674 1680 EDisplay display = *static_cast<CSSPrimitiveValue*>(value); 1675 1681 1676 if (!isValidDisplayValue(st yleResolver, display))1677 return; 1678 1679 st yleResolver->style()->setDisplay(display);1682 if (!isValidDisplayValue(state, display)) 1683 return; 1684 1685 state.style()->setDisplay(display); 1680 1686 } 1681 1687 … … 1690 1696 public: 1691 1697 static void setValue(RenderStyle* style, PassRefPtr<ClipPathOperation> value) { (style->*setterFunction)(value); } 1692 static void applyValue(CSSPropertyID, StyleResolver * styleResolver, CSSValue* value)1698 static void applyValue(CSSPropertyID, StyleResolver::State& state, CSSValue* value) 1693 1699 { 1694 1700 if (value->isPrimitiveValue()) { 1695 1701 CSSPrimitiveValue* primitiveValue = static_cast<CSSPrimitiveValue*>(value); 1696 1702 if (primitiveValue->getIdent() == CSSValueNone) 1697 setValue(st yleResolver->style(), 0);1703 setValue(state.style(), 0); 1698 1704 else if (primitiveValue->isShape()) { 1699 setValue(st yleResolver->style(), ShapeClipPathOperation::create(basicShapeForValue(styleResolver, primitiveValue->getShapeValue())));1705 setValue(state.style(), ShapeClipPathOperation::create(basicShapeForValue(state, primitiveValue->getShapeValue()))); 1700 1706 } 1701 1707 #if ENABLE(SVG) 1702 1708 else if (primitiveValue->primitiveType() == CSSPrimitiveValue::CSS_URI) { 1703 1709 String cssURLValue = primitiveValue->getStringValue(); 1704 KURL url = st yleResolver->document()->completeURL(cssURLValue);1710 KURL url = state.document()->completeURL(cssURLValue); 1705 1711 // FIXME: It doesn't work with forward or external SVG references (see https://bugs.webkit.org/show_bug.cgi?id=90405) 1706 setValue(st yleResolver->style(), ReferenceClipPathOperation::create(cssURLValue, url.fragmentIdentifier()));1712 setValue(state.style(), ReferenceClipPathOperation::create(cssURLValue, url.fragmentIdentifier())); 1707 1713 } 1708 1714 #endif … … 1721 1727 public: 1722 1728 static void setValue(RenderStyle* style, PassRefPtr<ExclusionShapeValue> value) { (style->*setterFunction)(value); } 1723 static void applyValue(CSSPropertyID, StyleResolver * styleResolver, CSSValue* value)1729 static void applyValue(CSSPropertyID, StyleResolver::State& state, CSSValue* value) 1724 1730 { 1725 1731 if (value->isPrimitiveValue()) { 1726 1732 CSSPrimitiveValue* primitiveValue = static_cast<CSSPrimitiveValue*>(value); 1727 1733 if (primitiveValue->getIdent() == CSSValueAuto) 1728 setValue(st yleResolver->style(), 0);1734 setValue(state.style(), 0); 1729 1735 // FIXME Bug 102571: Layout for the value 'outside-shape' is not yet implemented 1730 1736 else if (primitiveValue->getIdent() == CSSValueOutsideShape) 1731 setValue(st yleResolver->style(), ExclusionShapeValue::createOutsideValue());1737 setValue(state.style(), ExclusionShapeValue::createOutsideValue()); 1732 1738 else if (primitiveValue->isShape()) { 1733 RefPtr<ExclusionShapeValue> shape = ExclusionShapeValue::createShapeValue(basicShapeForValue(st yleResolver, primitiveValue->getShapeValue()));1734 setValue(st yleResolver->style(), shape.release());1739 RefPtr<ExclusionShapeValue> shape = ExclusionShapeValue::createShapeValue(basicShapeForValue(state, primitiveValue->getShapeValue())); 1740 setValue(state.style(), shape.release()); 1735 1741 } 1736 1742 } … … 1747 1753 class ApplyPropertyImageResolution { 1748 1754 public: 1749 static void applyInheritValue(CSSPropertyID propertyID, StyleResolver * styleResolver)1750 { 1751 ApplyPropertyDefaultBase<ImageResolutionSource, &RenderStyle::imageResolutionSource, ImageResolutionSource, &RenderStyle::setImageResolutionSource, ImageResolutionSource, &RenderStyle::initialImageResolutionSource>::applyInheritValue(propertyID, st yleResolver);1752 ApplyPropertyDefaultBase<ImageResolutionSnap, &RenderStyle::imageResolutionSnap, ImageResolutionSnap, &RenderStyle::setImageResolutionSnap, ImageResolutionSnap, &RenderStyle::initialImageResolutionSnap>::applyInheritValue(propertyID, st yleResolver);1753 ApplyPropertyDefaultBase<float, &RenderStyle::imageResolution, float, &RenderStyle::setImageResolution, float, &RenderStyle::initialImageResolution>::applyInheritValue(propertyID, st yleResolver);1754 } 1755 1756 static void applyInitialValue(CSSPropertyID propertyID, StyleResolver * styleResolver)1757 { 1758 ApplyPropertyDefaultBase<ImageResolutionSource, &RenderStyle::imageResolutionSource, ImageResolutionSource, &RenderStyle::setImageResolutionSource, ImageResolutionSource, &RenderStyle::initialImageResolutionSource>::applyInitialValue(propertyID, st yleResolver);1759 ApplyPropertyDefaultBase<ImageResolutionSnap, &RenderStyle::imageResolutionSnap, ImageResolutionSnap, &RenderStyle::setImageResolutionSnap, ImageResolutionSnap, &RenderStyle::initialImageResolutionSnap>::applyInitialValue(propertyID, st yleResolver);1760 ApplyPropertyDefaultBase<float, &RenderStyle::imageResolution, float, &RenderStyle::setImageResolution, float, &RenderStyle::initialImageResolution>::applyInitialValue(propertyID, st yleResolver);1761 } 1762 1763 static void applyValue(CSSPropertyID, StyleResolver * styleResolver, CSSValue* value)1755 static void applyInheritValue(CSSPropertyID propertyID, StyleResolver::State& state) 1756 { 1757 ApplyPropertyDefaultBase<ImageResolutionSource, &RenderStyle::imageResolutionSource, ImageResolutionSource, &RenderStyle::setImageResolutionSource, ImageResolutionSource, &RenderStyle::initialImageResolutionSource>::applyInheritValue(propertyID, state); 1758 ApplyPropertyDefaultBase<ImageResolutionSnap, &RenderStyle::imageResolutionSnap, ImageResolutionSnap, &RenderStyle::setImageResolutionSnap, ImageResolutionSnap, &RenderStyle::initialImageResolutionSnap>::applyInheritValue(propertyID, state); 1759 ApplyPropertyDefaultBase<float, &RenderStyle::imageResolution, float, &RenderStyle::setImageResolution, float, &RenderStyle::initialImageResolution>::applyInheritValue(propertyID, state); 1760 } 1761 1762 static void applyInitialValue(CSSPropertyID propertyID, StyleResolver::State& state) 1763 { 1764 ApplyPropertyDefaultBase<ImageResolutionSource, &RenderStyle::imageResolutionSource, ImageResolutionSource, &RenderStyle::setImageResolutionSource, ImageResolutionSource, &RenderStyle::initialImageResolutionSource>::applyInitialValue(propertyID, state); 1765 ApplyPropertyDefaultBase<ImageResolutionSnap, &RenderStyle::imageResolutionSnap, ImageResolutionSnap, &RenderStyle::setImageResolutionSnap, ImageResolutionSnap, &RenderStyle::initialImageResolutionSnap>::applyInitialValue(propertyID, state); 1766 ApplyPropertyDefaultBase<float, &RenderStyle::imageResolution, float, &RenderStyle::setImageResolution, float, &RenderStyle::initialImageResolution>::applyInitialValue(propertyID, state); 1767 } 1768 1769 static void applyValue(CSSPropertyID, StyleResolver::State& state, CSSValue* value) 1764 1770 { 1765 1771 if (!value->isValueList()) … … 1781 1787 resolution = primitiveValue->getDoubleValue(CSSPrimitiveValue::CSS_DPPX); 1782 1788 } 1783 st yleResolver->style()->setImageResolutionSource(source);1784 st yleResolver->style()->setImageResolutionSnap(snap);1785 st yleResolver->style()->setImageResolution(resolution);1789 state.style()->setImageResolutionSource(source); 1790 state.style()->setImageResolutionSnap(snap); 1791 state.style()->setImageResolution(resolution); 1786 1792 } 1787 1793 -
trunk/Source/WebCore/css/StyleBuilder.h
r128656 r143556 27 27 28 28 #include "CSSPropertyNames.h" 29 #include "StyleResolver.h" 29 30 #include <wtf/PassRefPtr.h> 30 31 #include <wtf/RefCounted.h> … … 34 35 class CSSValue; 35 36 class StyleBuilder; 36 class StyleResolver;37 37 38 38 class PropertyHandler { 39 39 public: 40 typedef void (*InheritFunction)(CSSPropertyID, StyleResolver *);41 typedef void (*InitialFunction)(CSSPropertyID, StyleResolver *);42 typedef void (*ApplyFunction)(CSSPropertyID, StyleResolver *, CSSValue*);40 typedef void (*InheritFunction)(CSSPropertyID, StyleResolver::State&); 41 typedef void (*InitialFunction)(CSSPropertyID, StyleResolver::State&); 42 typedef void (*ApplyFunction)(CSSPropertyID, StyleResolver::State&, CSSValue*); 43 43 PropertyHandler() : m_inherit(0), m_initial(0), m_apply(0) { } 44 44 PropertyHandler(InheritFunction inherit, InitialFunction initial, ApplyFunction apply) : m_inherit(inherit), m_initial(initial), m_apply(apply) { } 45 void applyInheritValue(CSSPropertyID propertyID, StyleResolver * styleResolver) const { ASSERT(m_inherit); (*m_inherit)(propertyID, styleResolver); }46 void applyInitialValue(CSSPropertyID propertyID, StyleResolver * styleResolver) const { ASSERT(m_initial); (*m_initial)(propertyID, styleResolver); }47 void applyValue(CSSPropertyID propertyID, StyleResolver * styleResolver, CSSValue* value) const { ASSERT(m_apply); (*m_apply)(propertyID, styleResolver, value); }45 void applyInheritValue(CSSPropertyID propertyID, StyleResolver::State& state) const { ASSERT(m_inherit); (*m_inherit)(propertyID, state); } 46 void applyInitialValue(CSSPropertyID propertyID, StyleResolver::State& state) const { ASSERT(m_initial); (*m_initial)(propertyID, state); } 47 void applyValue(CSSPropertyID propertyID, StyleResolver::State& state, CSSValue* value) const { ASSERT(m_apply); (*m_apply)(propertyID, state, value); } 48 48 bool isValid() const { return m_inherit && m_initial && m_apply; } 49 49 InheritFunction inheritFunction() const { return m_inherit; } -
trunk/Source/WebCore/css/StyleResolver.cpp
r143300 r143556 48 48 #include "CSSSupportsRule.h" 49 49 #include "CSSTimingFunctionValue.h" 50 #include "CSSToStyleMap.h" 50 51 #include "CSSValueList.h" 51 52 #if ENABLE(CSS_VARIABLES) … … 195 196 #define HANDLE_INHERIT(prop, Prop) \ 196 197 if (isInherit) { \ 197 m_state.style()->set##Prop(m_state.parentStyle()->prop());\198 state.style()->set##Prop(state.parentStyle()->prop()); \ 198 199 return; \ 199 200 } … … 202 203 HANDLE_INHERIT(prop, Prop) \ 203 204 if (isInitial) { \ 204 m_state.style()->set##Prop(RenderStyle::initial##Prop()); \205 state.style()->set##Prop(RenderStyle::initial##Prop()); \ 205 206 return; \ 206 207 } … … 223 224 return rightToLeftDecl.get(); 224 225 } 225 226 226 227 227 inline StaticCSSRuleList* StyleResolver::State::ensureRuleList() … … 270 270 #endif 271 271 , m_styleBuilder(StyleBuilder::sharedStyleBuilder()) 272 , m_styleMap(this)273 272 { 274 273 Element* root = document->documentElement(); … … 454 453 bool MatchingUARulesScope::m_matchingUARules = false; 455 454 456 void StyleResolver::collectMatchingRules( const MatchRequest& matchRequest, RuleRange& ruleRange)455 void StyleResolver::collectMatchingRules(State& state, const MatchRequest& matchRequest, RuleRange& ruleRange) 457 456 { 458 457 ASSERT(matchRequest.ruleSet); 459 ASSERT(m_state.element()); 460 461 State& state = m_state; 458 ASSERT(state.element()); 459 462 460 Element* element = state.element(); 463 461 const StyledElement* styledElement = state.styledElement(); … … 465 463 if (!pseudoId.isEmpty()) { 466 464 ASSERT(styledElement); 467 collectMatchingRulesForList( matchRequest.ruleSet->shadowPseudoElementRules(pseudoId.impl()), matchRequest, ruleRange);465 collectMatchingRulesForList(state, matchRequest.ruleSet->shadowPseudoElementRules(pseudoId.impl()), matchRequest, ruleRange); 468 466 } 469 467 470 468 #if ENABLE(VIDEO_TRACK) 471 469 if (element->isWebVTTElement()) 472 collectMatchingRulesForList( matchRequest.ruleSet->cuePseudoRules(), matchRequest, ruleRange);470 collectMatchingRulesForList(state, matchRequest.ruleSet->cuePseudoRules(), matchRequest, ruleRange); 473 471 #endif 474 472 // Check whether other types of rules are applicable in the current tree scope. Criteria for this: … … 486 484 // then sort the buffer. 487 485 if (element->hasID()) 488 collectMatchingRulesForList( matchRequest.ruleSet->idRules(element->idForStyleResolution().impl()), matchRequest, ruleRange);486 collectMatchingRulesForList(state, matchRequest.ruleSet->idRules(element->idForStyleResolution().impl()), matchRequest, ruleRange); 489 487 if (styledElement && styledElement->hasClass()) { 490 488 for (size_t i = 0; i < styledElement->classNames().size(); ++i) 491 collectMatchingRulesForList( matchRequest.ruleSet->classRules(styledElement->classNames()[i].impl()), matchRequest, ruleRange);489 collectMatchingRulesForList(state, matchRequest.ruleSet->classRules(styledElement->classNames()[i].impl()), matchRequest, ruleRange); 492 490 } 493 491 494 492 if (element->isLink()) 495 collectMatchingRulesForList( matchRequest.ruleSet->linkPseudoClassRules(), matchRequest, ruleRange);493 collectMatchingRulesForList(state, matchRequest.ruleSet->linkPseudoClassRules(), matchRequest, ruleRange); 496 494 if (SelectorChecker::matchesFocusPseudoClass(element)) 497 collectMatchingRulesForList( matchRequest.ruleSet->focusPseudoClassRules(), matchRequest, ruleRange);498 collectMatchingRulesForList( matchRequest.ruleSet->tagRules(element->localName().impl()), matchRequest, ruleRange);499 collectMatchingRulesForList( matchRequest.ruleSet->universalRules(), matchRequest, ruleRange);500 } 501 502 void StyleResolver::collectMatchingRulesForRegion( const MatchRequest& matchRequest, RuleRange& ruleRange)503 { 504 if (! m_state.regionForStyling())495 collectMatchingRulesForList(state, matchRequest.ruleSet->focusPseudoClassRules(), matchRequest, ruleRange); 496 collectMatchingRulesForList(state, matchRequest.ruleSet->tagRules(element->localName().impl()), matchRequest, ruleRange); 497 collectMatchingRulesForList(state, matchRequest.ruleSet->universalRules(), matchRequest, ruleRange); 498 } 499 500 void StyleResolver::collectMatchingRulesForRegion(State& state, const MatchRequest& matchRequest, RuleRange& ruleRange) 501 { 502 if (!state.regionForStyling()) 505 503 return; 506 504 … … 508 506 for (unsigned i = 0; i < size; ++i) { 509 507 const CSSSelector* regionSelector = matchRequest.ruleSet->m_regionSelectorsAndRuleSets.at(i).selector; 510 if (checkRegionSelector(regionSelector, static_cast<Element*>( m_state.regionForStyling()->node()))) {508 if (checkRegionSelector(regionSelector, static_cast<Element*>(state.regionForStyling()->node()))) { 511 509 RuleSet* regionRules = matchRequest.ruleSet->m_regionSelectorsAndRuleSets.at(i).ruleSet.get(); 512 510 ASSERT(regionRules); 513 collectMatchingRules(MatchRequest(regionRules, matchRequest.includeEmptyRules, matchRequest.scope), ruleRange); 514 } 515 } 516 } 517 518 void StyleResolver::sortAndTransferMatchedRules(MatchResult& result) 519 { 520 State& state = m_state; 511 collectMatchingRules(state, MatchRequest(regionRules, matchRequest.includeEmptyRules, matchRequest.scope), ruleRange); 512 } 513 } 514 } 515 516 void StyleResolver::sortAndTransferMatchedRules(State& state, MatchResult& result) 517 { 521 518 Vector<const RuleData*, 32>& matchedRules = state.matchedRules(); 522 519 if (matchedRules.isEmpty()) 523 520 return; 524 521 525 sortMatchedRules( );522 sortMatchedRules(state); 526 523 527 524 if (state.mode() == SelectorChecker::CollectingRules) { … … 539 536 } 540 537 541 void StyleResolver::matchScopedAuthorRules( MatchResult& result, bool includeEmptyRules)538 void StyleResolver::matchScopedAuthorRules(State& state, MatchResult& result, bool includeEmptyRules) 542 539 { 543 540 #if ENABLE(STYLE_SCOPED) || ENABLE(SHADOW_DOM) … … 546 543 547 544 // Match scoped author rules by traversing the scoped element stack (rebuild it if it got inconsistent). 548 if (m_scopeResolver->hasScopedStyles() && m_scopeResolver->ensureStackConsistency( m_state.element())) {549 bool applyAuthorStyles = m_state.element()->treeScope()->applyAuthorStyles();545 if (m_scopeResolver->hasScopedStyles() && m_scopeResolver->ensureStackConsistency(state.element())) { 546 bool applyAuthorStyles = state.element()->treeScope()->applyAuthorStyles(); 550 547 bool documentScope = true; 551 548 unsigned scopeSize = m_scopeResolver->stackSize(); 552 549 for (unsigned i = 0; i < scopeSize; ++i) { 553 m_state.matchedRules().clear();550 state.matchedRules().clear(); 554 551 result.ranges.lastAuthorRule = result.matchedProperties.size() - 1; 555 552 … … 566 563 MatchRequest matchRequest(frame.m_ruleSet, includeEmptyRules, frame.m_scope); 567 564 RuleRange ruleRange = result.ranges.authorRuleRange(); 568 collectMatchingRules( matchRequest, ruleRange);569 collectMatchingRulesForRegion( matchRequest, ruleRange);570 sortAndTransferMatchedRules( result);571 } 572 } 573 574 matchHostRules( result, includeEmptyRules);565 collectMatchingRules(state, matchRequest, ruleRange); 566 collectMatchingRulesForRegion(state, matchRequest, ruleRange); 567 sortAndTransferMatchedRules(state, result); 568 } 569 } 570 571 matchHostRules(state, result, includeEmptyRules); 575 572 #else 573 UNUSED_PARAM(state); 576 574 UNUSED_PARAM(result); 577 575 UNUSED_PARAM(includeEmptyRules); … … 579 577 } 580 578 581 inline bool StyleResolver::styleSharingCandidateMatchesHostRules( )579 inline bool StyleResolver::styleSharingCandidateMatchesHostRules(State& state) 582 580 { 583 581 #if ENABLE(SHADOW_DOM) 584 return m_scopeResolver && m_scopeResolver->styleSharingCandidateMatchesHostRules( m_state.element());582 return m_scopeResolver && m_scopeResolver->styleSharingCandidateMatchesHostRules(state.element()); 585 583 #else 586 584 return false; 587 #endif 588 } 589 590 void StyleResolver::matchHostRules(MatchResult& result, bool includeEmptyRules) 585 UNUSED_PARAM(state); 586 #endif 587 } 588 589 void StyleResolver::matchHostRules(State& state, MatchResult& result, bool includeEmptyRules) 591 590 { 592 591 #if ENABLE(SHADOW_DOM) 593 592 ASSERT(m_scopeResolver); 594 593 595 m_state.matchedRules().clear();594 state.matchedRules().clear(); 596 595 result.ranges.lastAuthorRule = result.matchedProperties.size() - 1; 597 596 598 597 Vector<RuleSet*> matchedRules; 599 m_scopeResolver->matchHostRules( m_state.element(), matchedRules);598 m_scopeResolver->matchHostRules(state.element(), matchedRules); 600 599 if (matchedRules.isEmpty()) 601 600 return; … … 603 602 for (unsigned i = matchedRules.size(); i > 0; --i) { 604 603 RuleRange ruleRange = result.ranges.authorRuleRange(); 605 collectMatchingRules( MatchRequest(matchedRules.at(i-1), includeEmptyRules, m_state.element()), ruleRange);606 } 607 sortAndTransferMatchedRules( result);604 collectMatchingRules(state, MatchRequest(matchedRules.at(i-1), includeEmptyRules, state.element()), ruleRange); 605 } 606 sortAndTransferMatchedRules(state, result); 608 607 #else 608 UNUSED_PARAM(state); 609 609 UNUSED_PARAM(result); 610 610 UNUSED_PARAM(includeEmptyRules); … … 612 612 } 613 613 614 void StyleResolver::matchAuthorRules( MatchResult& result, bool includeEmptyRules)615 { 616 m_state.matchedRules().clear();614 void StyleResolver::matchAuthorRules(State& state, MatchResult& result, bool includeEmptyRules) 615 { 616 state.matchedRules().clear(); 617 617 result.ranges.lastAuthorRule = result.matchedProperties.size() - 1; 618 618 619 if (! m_state.element())619 if (!state.element()) 620 620 return; 621 621 … … 623 623 MatchRequest matchRequest(m_ruleSets.authorStyle(), includeEmptyRules); 624 624 RuleRange ruleRange = result.ranges.authorRuleRange(); 625 collectMatchingRules( matchRequest, ruleRange);626 collectMatchingRulesForRegion( matchRequest, ruleRange);625 collectMatchingRules(state, matchRequest, ruleRange); 626 collectMatchingRulesForRegion(state, matchRequest, ruleRange); 627 627 #if ENABLE(SHADOW_DOM) 628 628 Vector<MatchRequest> matchRequests; 629 629 m_ruleSets.shadowDistributedRules().collectMatchRequests(includeEmptyRules, matchRequests); 630 630 for (size_t i = 0; i < matchRequests.size(); ++i) 631 collectMatchingRules( matchRequests[i], ruleRange);632 #endif 633 634 sortAndTransferMatchedRules( result);635 636 matchScopedAuthorRules( result, includeEmptyRules);637 } 638 639 void StyleResolver::matchUserRules( MatchResult& result, bool includeEmptyRules)631 collectMatchingRules(state, matchRequests[i], ruleRange); 632 #endif 633 634 sortAndTransferMatchedRules(state, result); 635 636 matchScopedAuthorRules(state, result, includeEmptyRules); 637 } 638 639 void StyleResolver::matchUserRules(State& state, MatchResult& result, bool includeEmptyRules) 640 640 { 641 641 if (!m_ruleSets.userStyle()) 642 642 return; 643 643 644 m_state.matchedRules().clear();644 state.matchedRules().clear(); 645 645 646 646 result.ranges.lastUserRule = result.matchedProperties.size() - 1; 647 647 MatchRequest matchRequest(m_ruleSets.userStyle(), includeEmptyRules); 648 648 RuleRange ruleRange = result.ranges.userRuleRange(); 649 collectMatchingRules( matchRequest, ruleRange);650 collectMatchingRulesForRegion( matchRequest, ruleRange);651 652 sortAndTransferMatchedRules( result);653 } 654 655 void StyleResolver::matchUARules( MatchResult& result, RuleSet* rules)656 { 657 m_state.matchedRules().clear();649 collectMatchingRules(state, matchRequest, ruleRange); 650 collectMatchingRulesForRegion(state, matchRequest, ruleRange); 651 652 sortAndTransferMatchedRules(state, result); 653 } 654 655 void StyleResolver::matchUARules(State& state, MatchResult& result, RuleSet* rules) 656 { 657 state.matchedRules().clear(); 658 658 659 659 result.ranges.lastUARule = result.matchedProperties.size() - 1; 660 660 RuleRange ruleRange = result.ranges.UARuleRange(); 661 collectMatchingRules( MatchRequest(rules), ruleRange);662 663 sortAndTransferMatchedRules( result);664 } 665 666 void StyleResolver::collectMatchingRulesForList( const Vector<RuleData>* rules, const MatchRequest& matchRequest, RuleRange& ruleRange)661 collectMatchingRules(state, MatchRequest(rules), ruleRange); 662 663 sortAndTransferMatchedRules(state, result); 664 } 665 666 void StyleResolver::collectMatchingRulesForList(State& state, const Vector<RuleData>* rules, const MatchRequest& matchRequest, RuleRange& ruleRange) 667 667 { 668 668 if (!rules) 669 669 return; 670 670 671 State& state = m_state;672 671 // In some cases we may end up looking up style for random elements in the middle of a recursive tree resolve. 673 672 // Ancestor identifier filter won't be up-to-date in that case and we can't use the fast path. … … 683 682 InspectorInstrumentationCookie cookie = InspectorInstrumentation::willMatchRule(document(), rule, this); 684 683 PseudoId dynamicPseudo = NOPSEUDO; 685 if (ruleMatches( ruleData, matchRequest.scope, dynamicPseudo, matchRequest.behaviorAtBoundary)) {684 if (ruleMatches(state, ruleData, matchRequest.scope, dynamicPseudo, matchRequest.behaviorAtBoundary)) { 686 685 // If the rule has no properties to apply, then ignore it in the non-debug mode. 687 686 const StylePropertySet* properties = rule->properties(); … … 711 710 712 711 // Add this rule to our list of matched rules. 713 m_state.addMatchedRule(&ruleData);712 state.addMatchedRule(&ruleData); 714 713 InspectorInstrumentation::didMatchRule(cookie, true); 715 714 continue; … … 727 726 } 728 727 729 void StyleResolver::sortMatchedRules( )730 { 731 std::sort( m_state.matchedRules().begin(), m_state.matchedRules().end(), compareRules);732 } 733 734 void StyleResolver::matchAllRules( MatchResult& result, bool includeSMILProperties)735 { 736 matchUARules( result);728 void StyleResolver::sortMatchedRules(State& state) 729 { 730 std::sort(state.matchedRules().begin(), state.matchedRules().end(), compareRules); 731 } 732 733 void StyleResolver::matchAllRules(State& state, MatchResult& result, bool includeSMILProperties) 734 { 735 matchUARules(state, result); 737 736 738 737 // Now we check user sheet rules. 739 738 if (m_matchAuthorAndUserStyles) 740 matchUserRules( result, false);739 matchUserRules(state, result, false); 741 740 742 741 // Now check author rules, beginning first with presentational attributes mapped from HTML. 743 if ( m_state.styledElement()) {744 addElementStyleProperties(result, m_state.styledElement()->presentationAttributeStyle());742 if (state.styledElement()) { 743 addElementStyleProperties(result, state.styledElement()->presentationAttributeStyle()); 745 744 746 745 // Now we check additional mapped declarations. 747 746 // Tables and table cells share an additional mapped rule that must be applied 748 747 // after all attributes, since their mapped style depends on the values of multiple attributes. 749 addElementStyleProperties(result, m_state.styledElement()->additionalPresentationAttributeStyle());750 751 if ( m_state.styledElement()->isHTMLElement()) {748 addElementStyleProperties(result, state.styledElement()->additionalPresentationAttributeStyle()); 749 750 if (state.styledElement()->isHTMLElement()) { 752 751 bool isAuto; 753 TextDirection textDirection = toHTMLElement( m_state.styledElement())->directionalityIfhasDirAutoAttribute(isAuto);752 TextDirection textDirection = toHTMLElement(state.styledElement())->directionalityIfhasDirAutoAttribute(isAuto); 754 753 if (isAuto) 755 754 addMatchedProperties(result, textDirection == LTR ? leftToRightDeclaration() : rightToLeftDeclaration()); … … 759 758 // Check the rules in author sheets next. 760 759 if (m_matchAuthorAndUserStyles) 761 matchAuthorRules( result, false);760 matchAuthorRules(state, result, false); 762 761 763 762 // Now check our inline style attribute. 764 if (m_matchAuthorAndUserStyles && m_state.styledElement() && m_state.styledElement()->inlineStyle()) {763 if (m_matchAuthorAndUserStyles && state.styledElement() && state.styledElement()->inlineStyle()) { 765 764 // Inline style is immutable as long as there is no CSSOM wrapper. 766 765 // FIXME: Media control shadow trees seem to have problems with caching. 767 bool isInlineStyleCacheable = ! m_state.styledElement()->inlineStyle()->isMutable() && !m_state.styledElement()->isInShadowTree();766 bool isInlineStyleCacheable = !state.styledElement()->inlineStyle()->isMutable() && !state.styledElement()->isInShadowTree(); 768 767 // FIXME: Constify. 769 addElementStyleProperties(result, m_state.styledElement()->inlineStyle(), isInlineStyleCacheable);768 addElementStyleProperties(result, state.styledElement()->inlineStyle(), isInlineStyleCacheable); 770 769 } 771 770 772 771 #if ENABLE(SVG) 773 772 // Now check SMIL animation override style. 774 if (includeSMILProperties && m_matchAuthorAndUserStyles && m_state.styledElement() && m_state.styledElement()->isSVGElement())775 addElementStyleProperties(result, static_cast<SVGElement*>( m_state.styledElement())->animatedSMILStyleProperties(), false /* isCacheable */);773 if (includeSMILProperties && m_matchAuthorAndUserStyles && state.styledElement() && state.styledElement()->isSVGElement()) 774 addElementStyleProperties(result, static_cast<SVGElement*>(state.styledElement())->animatedSMILStyleProperties(), false /* isCacheable */); 776 775 #else 777 776 UNUSED_PARAM(includeSMILProperties); … … 795 794 } 796 795 797 inline void StyleResolver::initElement(Element* e) 798 { 799 if (m_state.element() != e) { 800 m_state.initElement(e); 801 if (e && e == e->document()->documentElement()) { 802 e->document()->setDirectionSetOnDocumentElement(false); 803 e->document()->setWritingModeSetOnDocumentElement(false); 804 } 796 inline void StyleResolver::initElement(State& state, Element* e) 797 { 798 state.initElement(e); 799 if (e && e == e->document()->documentElement()) { 800 e->document()->setDirectionSetOnDocumentElement(false); 801 e->document()->setWritingModeSetOnDocumentElement(false); 805 802 } 806 803 } … … 890 887 } 891 888 892 bool StyleResolver::styleSharingCandidateMatchesRuleSet( RuleSet* ruleSet)889 bool StyleResolver::styleSharingCandidateMatchesRuleSet(Element* e, RuleSet* ruleSet) 893 890 { 894 891 if (!ruleSet) 895 892 return false; 896 m_state.matchedRules().clear(); 897 898 m_state.setMode(SelectorChecker::SharingRules); 893 894 State state(document()); 895 state.initElement(e); 896 state.setMode(SelectorChecker::SharingRules); 899 897 int firstRuleIndex = -1, lastRuleIndex = -1; 900 898 RuleRange ruleRange(firstRuleIndex, lastRuleIndex); 901 collectMatchingRules(MatchRequest(ruleSet), ruleRange); 902 m_state.setMode(SelectorChecker::ResolvingStyle); 903 if (m_state.matchedRules().isEmpty()) 904 return false; 905 m_state.matchedRules().clear(); 906 return true; 907 } 908 909 bool StyleResolver::canShareStyleWithControl(StyledElement* element) const 910 { 911 const State& state = m_state; 899 collectMatchingRules(state, MatchRequest(ruleSet), ruleRange); 900 return !state.matchedRules().isEmpty(); 901 } 902 903 bool StyleResolver::canShareStyleWithControl(const State& state, StyledElement* element) const 904 { 912 905 HTMLInputElement* thisInputElement = element->toInputElement(); 913 906 HTMLInputElement* otherInputElement = state.element()->toInputElement(); … … 963 956 } 964 957 965 bool StyleResolver::sharingCandidateHasIdenticalStyleAffectingAttributes(StyledElement* sharingCandidate) const 966 { 967 const State& state = m_state; 958 bool StyleResolver::sharingCandidateHasIdenticalStyleAffectingAttributes(const State& state, StyledElement* sharingCandidate) const 959 { 968 960 if (state.element()->elementData() == sharingCandidate->elementData()) 969 961 return true; … … 1005 997 } 1006 998 1007 bool StyleResolver::canShareStyleWithElement( StyledElement* element) const999 bool StyleResolver::canShareStyleWithElement(const State& state, StyledElement* element) const 1008 1000 { 1009 1001 RenderStyle* style = element->renderStyle(); 1010 const State& state = m_state;1011 1002 1012 1003 if (!style) … … 1038 1029 if (element == element->document()->cssTarget()) 1039 1030 return false; 1040 if (!sharingCandidateHasIdenticalStyleAffectingAttributes( element))1031 if (!sharingCandidateHasIdenticalStyleAffectingAttributes(state, element)) 1041 1032 return false; 1042 1033 if (element->additionalPresentationAttributeStyle() != state.styledElement()->additionalPresentationAttributeStyle()) … … 1059 1050 return false; 1060 1051 1061 if (isControl && !canShareStyleWithControl( element))1052 if (isControl && !canShareStyleWithControl(state, element)) 1062 1053 return false; 1063 1054 … … 1099 1090 } 1100 1091 1101 inline StyledElement* StyleResolver::findSiblingForStyleSharing( Node* node, unsigned& count) const1092 inline StyledElement* StyleResolver::findSiblingForStyleSharing(const State& state, Node* node, unsigned& count) const 1102 1093 { 1103 1094 for (; node; node = node->previousSibling()) { 1104 1095 if (!node->isStyledElement()) 1105 1096 continue; 1106 if (canShareStyleWithElement(stat ic_cast<StyledElement*>(node)))1097 if (canShareStyleWithElement(state, static_cast<StyledElement*>(node))) 1107 1098 break; 1108 1099 if (count++ == cStyleSearchThreshold) … … 1112 1103 } 1113 1104 1114 RenderStyle* StyleResolver::locateSharedStyle() 1115 { 1116 State& state = m_state; 1105 RenderStyle* StyleResolver::locateSharedStyle(State& state) 1106 { 1117 1107 if (!state.styledElement() || !state.parentStyle()) 1118 1108 return 0; … … 1147 1137 Node* cousinList = state.styledElement()->previousSibling(); 1148 1138 while (cousinList) { 1149 shareElement = findSiblingForStyleSharing( cousinList, count);1139 shareElement = findSiblingForStyleSharing(state, cousinList, count); 1150 1140 if (shareElement) 1151 1141 break; … … 1158 1148 1159 1149 // Can't share if sibling rules apply. This is checked at the end as it should rarely fail. 1160 if (styleSharingCandidateMatchesRuleSet( m_ruleSets.sibling()))1150 if (styleSharingCandidateMatchesRuleSet(state.element(), m_ruleSets.sibling())) 1161 1151 return 0; 1162 1152 // Can't share if attribute rules apply. 1163 if (styleSharingCandidateMatchesRuleSet( m_ruleSets.uncommonAttribute()))1153 if (styleSharingCandidateMatchesRuleSet(state.element(), m_ruleSets.uncommonAttribute())) 1164 1154 return 0; 1165 1155 // Can't share if @host @-rules apply. 1166 if (styleSharingCandidateMatchesHostRules( ))1156 if (styleSharingCandidateMatchesHostRules(state)) 1167 1157 return 0; 1168 1158 // Tracking child index requires unique style for each node. This may get set by the sibling rule match above. … … 1172 1162 } 1173 1163 1174 void StyleResolver::matchUARules( MatchResult& result)1164 void StyleResolver::matchUARules(State& state, MatchResult& result) 1175 1165 { 1176 1166 MatchingUARulesScope scope; … … 1181 1171 RuleSet* userAgentStyleSheet = m_medium->mediaTypeMatchSpecific("print") 1182 1172 ? CSSDefaultStyleSheets::defaultPrintStyle : CSSDefaultStyleSheets::defaultStyle; 1183 matchUARules( result, userAgentStyleSheet);1173 matchUARules(state, result, userAgentStyleSheet); 1184 1174 1185 1175 // In quirks mode, we match rules from the quirks user agent sheet. 1186 1176 if (document()->inQuirksMode()) 1187 matchUARules( result, CSSDefaultStyleSheets::defaultQuirksStyle);1177 matchUARules(state, result, CSSDefaultStyleSheets::defaultQuirksStyle); 1188 1178 1189 1179 // If document uses view source styles (in view source mode or in xml viewer mode), then we match rules from the view source style sheet. 1190 1180 if (document()->isViewSource()) 1191 matchUARules( result, CSSDefaultStyleSheets::viewSourceStyle());1181 matchUARules(state, result, CSSDefaultStyleSheets::viewSourceStyle()); 1192 1182 } 1193 1183 … … 1387 1377 } 1388 1378 1389 State & state = m_state;1390 initElement( element);1379 State state(document()); 1380 initElement(state, element); 1391 1381 state.initForStyleResolve(document(), element, defaultParent, NOPSEUDO, regionForStyling); 1392 1382 if (sharingBehavior == AllowStyleSharing && !state.distributedToInsertionPoint()) { 1393 RenderStyle* sharedStyle = locateSharedStyle( );1383 RenderStyle* sharedStyle = locateSharedStyle(state); 1394 1384 if (sharedStyle) 1395 1385 return sharedStyle; … … 1397 1387 1398 1388 RefPtr<RenderStyle> cloneForParent; 1389 RefPtr<RenderStyle> style; 1399 1390 1400 1391 if (state.parentStyle()) { 1401 st ate.setStyle(RenderStyle::create());1402 st ate.style()->inheritFrom(state.parentStyle(), isAtShadowBoundary(element) ? RenderStyle::AtShadowBoundary : RenderStyle::NotAtShadowBoundary);1392 style = RenderStyle::create(); 1393 style->inheritFrom(state.parentStyle(), isAtShadowBoundary(element) ? RenderStyle::AtShadowBoundary : RenderStyle::NotAtShadowBoundary); 1403 1394 } else { 1404 st ate.setStyle(defaultStyleForElement());1405 cloneForParent = RenderStyle::clone(st ate.style());1395 style = defaultStyleForElement(); 1396 cloneForParent = RenderStyle::clone(style.get()); 1406 1397 state.setParentStyle(cloneForParent.get()); 1407 1398 } 1399 state.setStyle(style); 1400 1408 1401 // contenteditable attribute (implemented by -webkit-user-modify) should 1409 1402 // be propagated from shadow host to distributed node. … … 1433 1426 MatchResult matchResult; 1434 1427 if (matchingBehavior == MatchOnlyUserAgentRules) 1435 matchUARules( matchResult);1428 matchUARules(state, matchResult); 1436 1429 else 1437 matchAllRules( matchResult, matchingBehavior != MatchAllRulesExcludingSMIL);1438 1439 applyMatchedProperties( matchResult, element);1430 matchAllRules(state, matchResult, matchingBehavior != MatchAllRulesExcludingSMIL); 1431 1432 applyMatchedProperties(state, matchResult, element); 1440 1433 1441 1434 // Clean up our style object's display and text decorations (among other fixups). 1442 adjustRenderStyle(state.style(), state.parentStyle(), element); 1443 1444 state.clear(); // Clear out for the next resolve. 1435 adjustRenderStyle(state, style.get(), state.parentStyle(), element); 1445 1436 1446 1437 document()->didAccessStyleResolver(); … … 1450 1441 } 1451 1442 1452 PassRefPtr<RenderStyle> StyleResolver::styleForKeyframe( const RenderStyle* elementStyle, const StyleKeyframe* keyframe, KeyframeValue& keyframeValue)1443 PassRefPtr<RenderStyle> StyleResolver::styleForKeyframe(State& state, const RenderStyle* elementStyle, const StyleKeyframe* keyframe, KeyframeValue& keyframeValue) 1453 1444 { 1454 1445 MatchResult result; … … 1456 1447 addMatchedProperties(result, keyframe->properties()); 1457 1448 1458 ASSERT(!m_state.style());1459 1460 State& state = m_state;1461 1462 1449 // Create the style 1463 state.setStyle(RenderStyle::clone(elementStyle)); 1450 RefPtr<RenderStyle> style = RenderStyle::clone(elementStyle); 1451 state.setStyle(style); 1464 1452 state.setLineHeightValue(0); 1465 1453 … … 1468 1456 bool inheritedOnly = false; 1469 1457 if (keyframe->properties()) 1470 applyMatchedProperties<HighPriorityProperties>( result, false, 0, result.matchedProperties.size() - 1, inheritedOnly);1458 applyMatchedProperties<HighPriorityProperties>(state, result, false, 0, result.matchedProperties.size() - 1, inheritedOnly); 1471 1459 1472 1460 // If our font got dirtied, go ahead and update it now. 1473 updateFont( );1461 updateFont(state); 1474 1462 1475 1463 // Line-height is set when we are sure we decided on the font-size 1476 1464 if (state.lineHeightValue()) 1477 applyProperty( CSSPropertyLineHeight, state.lineHeightValue());1465 applyProperty(state, CSSPropertyLineHeight, state.lineHeightValue()); 1478 1466 1479 1467 // Now do rest of the properties. 1480 1468 if (keyframe->properties()) 1481 applyMatchedProperties<LowPriorityProperties>( result, false, 0, result.matchedProperties.size() - 1, inheritedOnly);1469 applyMatchedProperties<LowPriorityProperties>(state, result, false, 0, result.matchedProperties.size() - 1, inheritedOnly); 1482 1470 1483 1471 // If our font got dirtied by one of the non-essential font props, 1484 1472 // go ahead and update it a second time. 1485 updateFont( );1473 updateFont(state); 1486 1474 1487 1475 // Start loading resources referenced by this style. 1488 loadPendingResources( );1476 loadPendingResources(state); 1489 1477 1490 1478 // Add all the animating properties to the keyframe. … … 1523 1511 // Construct and populate the style for each keyframe 1524 1512 const Vector<RefPtr<StyleKeyframe> >& keyframes = keyframesRule->keyframes(); 1513 State state(document()); 1514 initElement(state, e); 1515 state.initForStyleResolve(document(), e); 1525 1516 for (unsigned i = 0; i < keyframes.size(); ++i) { 1526 1517 // Apply the declaration to the style. This is a simplified version of the logic in styleForElement 1527 initElement(e);1528 m_state.initForStyleResolve(document(), e);1529 1530 1518 const StyleKeyframe* keyframe = keyframes[i].get(); 1531 1519 1532 1520 KeyframeValue keyframeValue(0, 0); 1533 keyframeValue.setStyle(styleForKeyframe( elementStyle, keyframe, keyframeValue));1521 keyframeValue.setStyle(styleForKeyframe(state, elementStyle, keyframe, keyframeValue)); 1534 1522 1535 1523 // Add this keyframe style to all the indicated key times … … 1551 1539 } 1552 1540 KeyframeValue keyframeValue(0, 0); 1553 keyframeValue.setStyle(styleForKeyframe( elementStyle, zeroPercentKeyframe, keyframeValue));1541 keyframeValue.setStyle(styleForKeyframe(state, elementStyle, zeroPercentKeyframe, keyframeValue)); 1554 1542 list.insert(keyframeValue); 1555 1543 } … … 1563 1551 } 1564 1552 KeyframeValue keyframeValue(1, 0); 1565 keyframeValue.setStyle(styleForKeyframe( elementStyle, hundredPercentKeyframe, keyframeValue));1553 keyframeValue.setStyle(styleForKeyframe(state, elementStyle, hundredPercentKeyframe, keyframeValue)); 1566 1554 list.insert(keyframeValue); 1567 1555 } … … 1574 1562 return 0; 1575 1563 1576 State& state = m_state; 1577 1578 initElement(e); 1579 1564 State state(document()); 1565 initElement(state, e); 1580 1566 state.initForStyleResolve(document(), e, parentStyle, pseudo); 1581 1567 state.setStyle(RenderStyle::create()); 1582 state.style()->inheritFrom( m_state.parentStyle());1568 state.style()->inheritFrom(state.parentStyle()); 1583 1569 1584 1570 // Since we don't use pseudo-elements in any of our quirk/print user agent rules, don't waste time walking … … 1587 1573 // Check UA, user and author rules. 1588 1574 MatchResult matchResult; 1589 matchUARules( matchResult);1575 matchUARules(state, matchResult); 1590 1576 1591 1577 if (m_matchAuthorAndUserStyles) { 1592 matchUserRules( matchResult, false);1593 matchAuthorRules( matchResult, false);1578 matchUserRules(state, matchResult, false); 1579 matchAuthorRules(state, matchResult, false); 1594 1580 } 1595 1581 … … 1599 1585 state.style()->setStyleType(pseudo); 1600 1586 1601 applyMatchedProperties( matchResult, e);1587 applyMatchedProperties(state, matchResult, e); 1602 1588 1603 1589 // Clean up our style object's display and text decorations (among other fixups). 1604 adjustRenderStyle(state .style(), m_state.parentStyle(), 0);1590 adjustRenderStyle(state, state.style(), state.parentStyle(), 0); 1605 1591 1606 1592 // Start loading resources referenced by this style. 1607 loadPendingResources( );1593 loadPendingResources(state); 1608 1594 1609 1595 document()->didAccessStyleResolver(); … … 1615 1601 PassRefPtr<RenderStyle> StyleResolver::styleForPage(int pageIndex) 1616 1602 { 1617 m_state.initForStyleResolve(document(), document()->documentElement()); // m_rootElementStyle will be set to the document style. 1618 1619 m_state.setStyle(RenderStyle::create()); 1620 m_state.style()->inheritFrom(m_state.rootElementStyle()); 1621 1622 const bool isLeft = isLeftPage(pageIndex); 1603 State state(document()); 1604 state.initForStyleResolve(document(), document()->documentElement()); // m_rootElementStyle will be set to the document style. 1605 1606 state.setStyle(RenderStyle::create()); 1607 state.style()->inheritFrom(state.rootElementStyle()); 1608 1609 const bool isLeft = isLeftPage(state, pageIndex); 1623 1610 const bool isFirst = isFirstPage(pageIndex); 1624 1611 const String page = pageName(pageIndex); … … 1629 1616 // Only consider the global author RuleSet for @page rules, as per the HTML5 spec. 1630 1617 matchPageRules(result, m_ruleSets.authorStyle(), isLeft, isFirst, page); 1631 m_state.setLineHeightValue(0);1618 state.setLineHeightValue(0); 1632 1619 bool inheritedOnly = false; 1633 1620 #if ENABLE(CSS_VARIABLES) 1634 applyMatchedProperties<VariableDefinitions>( result, false, 0, result.matchedProperties.size() - 1, inheritedOnly);1635 #endif 1636 applyMatchedProperties<HighPriorityProperties>( result, false, 0, result.matchedProperties.size() - 1, inheritedOnly);1621 applyMatchedProperties<VariableDefinitions>(state, result, false, 0, result.matchedProperties.size() - 1, inheritedOnly); 1622 #endif 1623 applyMatchedProperties<HighPriorityProperties>(state, result, false, 0, result.matchedProperties.size() - 1, inheritedOnly); 1637 1624 1638 1625 // If our font got dirtied, go ahead and update it now. 1639 updateFont( );1626 updateFont(state); 1640 1627 1641 1628 // Line-height is set when we are sure we decided on the font-size. 1642 if ( m_state.lineHeightValue())1643 applyProperty( CSSPropertyLineHeight, m_state.lineHeightValue());1644 1645 applyMatchedProperties<LowPriorityProperties>( result, false, 0, result.matchedProperties.size() - 1, inheritedOnly);1629 if (state.lineHeightValue()) 1630 applyProperty(state, CSSPropertyLineHeight, state.lineHeightValue()); 1631 1632 applyMatchedProperties<LowPriorityProperties>(state, result, false, 0, result.matchedProperties.size() - 1, inheritedOnly); 1646 1633 1647 1634 // Start loading resources referenced by this style. 1648 loadPendingResources( );1635 loadPendingResources(state); 1649 1636 1650 1637 document()->didAccessStyleResolver(); 1651 1638 1652 1639 // Now return the style. 1653 return m_state.takeStyle();1640 return state.takeStyle(); 1654 1641 } 1655 1642 1656 1643 PassRefPtr<RenderStyle> StyleResolver::defaultStyleForElement() 1657 1644 { 1658 m_state.setStyle(RenderStyle::create()); 1645 State state(document()); 1646 state.setStyle(RenderStyle::create()); 1659 1647 // Make sure our fonts are initialized if we don't inherit them from our parent style. 1660 1648 if (Settings* settings = documentSettings()) { 1661 initializeFontStyle(s ettings);1662 m_state.style()->font().update(fontSelector());1649 initializeFontStyle(state, settings); 1650 state.style()->font().update(fontSelector()); 1663 1651 } else 1664 m_state.style()->font().update(0);1665 1666 return m_state.takeStyle();1652 state.style()->font().update(0); 1653 1654 return state.takeStyle(); 1667 1655 } 1668 1656 … … 1759 1747 } 1760 1748 1761 void StyleResolver::adjustRenderStyle( RenderStyle* style, RenderStyle* parentStyle, Element *e)1749 void StyleResolver::adjustRenderStyle(State& state, RenderStyle* style, RenderStyle* parentStyle, Element *e) 1762 1750 { 1763 1751 ASSERT(parentStyle); … … 1952 1940 // Let the theme also have a crack at adjusting the style. 1953 1941 if (style->hasAppearance()) 1954 RenderTheme::defaultTheme()->adjustStyle(this, style, e, m_state.hasUAAppearance(), m_state.borderData(), m_state.backgroundData(), m_state.backgroundColor());1942 RenderTheme::defaultTheme()->adjustStyle(this, style, e, state.hasUAAppearance(), state.borderData(), state.backgroundData(), state.backgroundColor()); 1955 1943 1956 1944 // If we have first-letter pseudo style, do not share this style. … … 2033 2021 } 2034 2022 2035 void StyleResolver::updateFont( )2036 { 2037 if (! m_state.fontDirty())2038 return; 2039 2040 checkForTextSizeAdjust( );2041 RenderStyle* style = m_state.style();2042 checkForGenericFamilyChange(st yle, m_state.parentStyle());2043 checkForZoomChange(st yle, m_state.parentStyle());2023 void StyleResolver::updateFont(State& state) 2024 { 2025 if (!state.fontDirty()) 2026 return; 2027 2028 checkForTextSizeAdjust(state); 2029 RenderStyle* style = state.style(); 2030 checkForGenericFamilyChange(state, style, state.parentStyle()); 2031 checkForZoomChange(state, style, state.parentStyle()); 2044 2032 checkForOrientationChange(style); 2045 2033 style->font().update(m_fontSelector); 2046 m_state.setFontDirty(false);2034 state.setFontDirty(false); 2047 2035 } 2048 2036 … … 2057 2045 return 0; 2058 2046 2059 m_state.setMode(SelectorChecker::CollectingRules); 2060 2061 initElement(e); 2062 m_state.initForStyleResolve(document(), e, 0, pseudoId); 2047 State state(document()); 2048 state.setMode(SelectorChecker::CollectingRules); 2049 2050 initElement(state, e); 2051 state.initForStyleResolve(document(), e, 0, pseudoId); 2063 2052 2064 2053 MatchResult dummy; 2065 2054 if (rulesToInclude & UAAndUserCSSRules) { 2066 2055 // First we match rules from the user agent sheet. 2067 matchUARules( dummy);2056 matchUARules(state, dummy); 2068 2057 2069 2058 // Now we check user sheet rules. 2070 2059 if (m_matchAuthorAndUserStyles) 2071 matchUserRules( dummy, rulesToInclude & EmptyCSSRules);2060 matchUserRules(state, dummy, rulesToInclude & EmptyCSSRules); 2072 2061 } 2073 2062 2074 2063 if (m_matchAuthorAndUserStyles && (rulesToInclude & AuthorCSSRules)) { 2075 m_state.setSameOriginOnly(!(rulesToInclude & CrossOriginCSSRules));2064 state.setSameOriginOnly(!(rulesToInclude & CrossOriginCSSRules)); 2076 2065 2077 2066 // Check the rules in author sheets. 2078 matchAuthorRules(dummy, rulesToInclude & EmptyCSSRules); 2079 2080 m_state.setSameOriginOnly(false); 2081 } 2082 2083 m_state.setMode(SelectorChecker::ResolvingStyle); 2084 2085 return m_state.takeRuleList(); 2086 } 2087 2088 inline bool StyleResolver::ruleMatches(const RuleData& ruleData, const ContainerNode* scope, PseudoId& dynamicPseudo, SelectorChecker::BehaviorAtBoundary behaviorAtBoundary) 2089 { 2090 State& state = m_state; 2091 2067 matchAuthorRules(state, dummy, rulesToInclude & EmptyCSSRules); 2068 } 2069 2070 return state.takeRuleList(); 2071 } 2072 2073 inline bool StyleResolver::ruleMatches(State& state, const RuleData& ruleData, const ContainerNode* scope, PseudoId& dynamicPseudo, SelectorChecker::BehaviorAtBoundary behaviorAtBoundary) 2074 { 2092 2075 if (ruleData.hasFastCheckableSelector()) { 2093 2076 // We know this selector does not include any pseudo elements. … … 2128 2111 return false; 2129 2112 2130 SelectorChecker selectorChecker(document(), m_state.mode());2113 SelectorChecker selectorChecker(document(), SelectorChecker::QueryingRules); 2131 2114 for (const CSSSelector* s = regionSelector; s; s = CSSSelectorList::next(s)) 2132 2115 if (selectorChecker.matches(s, regionElement)) … … 2150 2133 2151 2134 template <StyleResolver::StyleApplicationPass pass> 2152 void StyleResolver::applyProperties( const StylePropertySet* properties, StyleRule* rule, bool isImportant, bool inheritedOnly, PropertyWhitelistType propertyWhitelistType)2153 { 2154 ASSERT((propertyWhitelistType != PropertyWhitelistRegion) || m_state.regionForStyling());2135 void StyleResolver::applyProperties(State& state, const StylePropertySet* properties, StyleRule* rule, bool isImportant, bool inheritedOnly, PropertyWhitelistType propertyWhitelistType) 2136 { 2137 ASSERT((propertyWhitelistType != PropertyWhitelistRegion) || state.regionForStyling()); 2155 2138 InspectorInstrumentationCookie cookie = InspectorInstrumentation::willProcessRule(document(), rule, this); 2156 2139 … … 2180 2163 COMPILE_ASSERT(CSSPropertyVariable < firstCSSProperty, CSS_variable_is_before_first_property); 2181 2164 if (property == CSSPropertyVariable) 2182 applyProperty( current.id(), current.value());2165 applyProperty(state, current.id(), current.value()); 2183 2166 break; 2184 2167 #endif … … 2193 2176 // give special priority to font-xxx, color properties, etc 2194 2177 if (property < CSSPropertyLineHeight) 2195 applyProperty( current.id(), current.value());2178 applyProperty(state, current.id(), current.value()); 2196 2179 // we apply line-height later 2197 2180 else if (property == CSSPropertyLineHeight) 2198 m_state.setLineHeightValue(current.value());2181 state.setLineHeightValue(current.value()); 2199 2182 break; 2200 2183 case LowPriorityProperties: 2201 2184 if (property > CSSPropertyLineHeight) 2202 applyProperty( current.id(), current.value());2185 applyProperty(state, current.id(), current.value()); 2203 2186 } 2204 2187 } … … 2207 2190 2208 2191 template <StyleResolver::StyleApplicationPass pass> 2209 void StyleResolver::applyMatchedProperties( const MatchResult& matchResult, bool isImportant, int startIndex, int endIndex, bool inheritedOnly)2192 void StyleResolver::applyMatchedProperties(State& state, const MatchResult& matchResult, bool isImportant, int startIndex, int endIndex, bool inheritedOnly) 2210 2193 { 2211 2194 if (startIndex == -1) 2212 2195 return; 2213 2196 2214 State& state = m_state;2215 2197 if (state.style()->insideLink() != NotInsideLink) { 2216 2198 for (int i = startIndex; i <= endIndex; ++i) { … … 2221 2203 state.setApplyPropertyToVisitedLinkStyle(linkMatchType & SelectorChecker::MatchVisited); 2222 2204 2223 applyProperties<pass>( matchedProperties.properties.get(), matchResult.matchedRules[i], isImportant, inheritedOnly, static_cast<PropertyWhitelistType>(matchedProperties.whitelistType));2205 applyProperties<pass>(state, matchedProperties.properties.get(), matchResult.matchedRules[i], isImportant, inheritedOnly, static_cast<PropertyWhitelistType>(matchedProperties.whitelistType)); 2224 2206 } 2225 2207 state.setApplyPropertyToRegularStyle(true); … … 2229 2211 for (int i = startIndex; i <= endIndex; ++i) { 2230 2212 const MatchedProperties& matchedProperties = matchResult.matchedProperties[i]; 2231 applyProperties<pass>( matchedProperties.properties.get(), matchResult.matchedRules[i], isImportant, inheritedOnly, static_cast<PropertyWhitelistType>(matchedProperties.whitelistType));2213 applyProperties<pass>(state, matchedProperties.properties.get(), matchResult.matchedRules[i], isImportant, inheritedOnly, static_cast<PropertyWhitelistType>(matchedProperties.whitelistType)); 2232 2214 } 2233 2215 } … … 2329 2311 } 2330 2312 2331 void StyleResolver::applyMatchedProperties( const MatchResult& matchResult, const Element* element)2313 void StyleResolver::applyMatchedProperties(State& state, const MatchResult& matchResult, const Element* element) 2332 2314 { 2333 2315 ASSERT(element); 2334 State& state = m_state;2335 2316 unsigned cacheHash = matchResult.isCacheable ? computeMatchedPropertiesHash(matchResult.matchedProperties.data(), matchResult.matchedProperties.size()) : 0; 2336 2317 bool applyInheritedOnly = false; … … 2356 2337 #if ENABLE(CSS_VARIABLES) 2357 2338 // First apply all variable definitions, as they may be used during application of later properties. 2358 applyMatchedProperties<VariableDefinitions>( matchResult, false, 0, matchResult.matchedProperties.size() - 1, applyInheritedOnly);2359 applyMatchedProperties<VariableDefinitions>( matchResult, true, matchResult.ranges.firstAuthorRule, matchResult.ranges.lastAuthorRule, applyInheritedOnly);2360 applyMatchedProperties<VariableDefinitions>( matchResult, true, matchResult.ranges.firstUserRule, matchResult.ranges.lastUserRule, applyInheritedOnly);2361 applyMatchedProperties<VariableDefinitions>( matchResult, true, matchResult.ranges.firstUARule, matchResult.ranges.lastUARule, applyInheritedOnly);2339 applyMatchedProperties<VariableDefinitions>(state, matchResult, false, 0, matchResult.matchedProperties.size() - 1, applyInheritedOnly); 2340 applyMatchedProperties<VariableDefinitions>(state, matchResult, true, matchResult.ranges.firstAuthorRule, matchResult.ranges.lastAuthorRule, applyInheritedOnly); 2341 applyMatchedProperties<VariableDefinitions>(state, matchResult, true, matchResult.ranges.firstUserRule, matchResult.ranges.lastUserRule, applyInheritedOnly); 2342 applyMatchedProperties<VariableDefinitions>(state, matchResult, true, matchResult.ranges.firstUARule, matchResult.ranges.lastUARule, applyInheritedOnly); 2362 2343 #endif 2363 2344 … … 2367 2348 // and (4) normal important. 2368 2349 state.setLineHeightValue(0); 2369 applyMatchedProperties<HighPriorityProperties>( matchResult, false, 0, matchResult.matchedProperties.size() - 1, applyInheritedOnly);2370 applyMatchedProperties<HighPriorityProperties>( matchResult, true, matchResult.ranges.firstAuthorRule, matchResult.ranges.lastAuthorRule, applyInheritedOnly);2371 applyMatchedProperties<HighPriorityProperties>( matchResult, true, matchResult.ranges.firstUserRule, matchResult.ranges.lastUserRule, applyInheritedOnly);2372 applyMatchedProperties<HighPriorityProperties>( matchResult, true, matchResult.ranges.firstUARule, matchResult.ranges.lastUARule, applyInheritedOnly);2350 applyMatchedProperties<HighPriorityProperties>(state, matchResult, false, 0, matchResult.matchedProperties.size() - 1, applyInheritedOnly); 2351 applyMatchedProperties<HighPriorityProperties>(state, matchResult, true, matchResult.ranges.firstAuthorRule, matchResult.ranges.lastAuthorRule, applyInheritedOnly); 2352 applyMatchedProperties<HighPriorityProperties>(state, matchResult, true, matchResult.ranges.firstUserRule, matchResult.ranges.lastUserRule, applyInheritedOnly); 2353 applyMatchedProperties<HighPriorityProperties>(state, matchResult, true, matchResult.ranges.firstUARule, matchResult.ranges.lastUARule, applyInheritedOnly); 2373 2354 2374 2355 if (cacheItem && cacheItem->renderStyle->effectiveZoom() != state.style()->effectiveZoom()) { … … 2378 2359 2379 2360 // If our font got dirtied, go ahead and update it now. 2380 updateFont( );2361 updateFont(state); 2381 2362 2382 2363 // Line-height is set when we are sure we decided on the font-size. 2383 2364 if (state.lineHeightValue()) 2384 applyProperty( CSSPropertyLineHeight, state.lineHeightValue());2365 applyProperty(state, CSSPropertyLineHeight, state.lineHeightValue()); 2385 2366 2386 2367 // Many properties depend on the font. If it changes we just apply all properties. … … 2389 2370 2390 2371 // Now do the normal priority UA properties. 2391 applyMatchedProperties<LowPriorityProperties>( matchResult, false, matchResult.ranges.firstUARule, matchResult.ranges.lastUARule, applyInheritedOnly);2372 applyMatchedProperties<LowPriorityProperties>(state, matchResult, false, matchResult.ranges.firstUARule, matchResult.ranges.lastUARule, applyInheritedOnly); 2392 2373 2393 2374 // Cache our border and background so that we can examine them later. … … 2395 2376 2396 2377 // Now do the author and user normal priority properties and all the !important properties. 2397 applyMatchedProperties<LowPriorityProperties>( matchResult, false, matchResult.ranges.lastUARule + 1, matchResult.matchedProperties.size() - 1, applyInheritedOnly);2398 applyMatchedProperties<LowPriorityProperties>( matchResult, true, matchResult.ranges.firstAuthorRule, matchResult.ranges.lastAuthorRule, applyInheritedOnly);2399 applyMatchedProperties<LowPriorityProperties>( matchResult, true, matchResult.ranges.firstUserRule, matchResult.ranges.lastUserRule, applyInheritedOnly);2400 applyMatchedProperties<LowPriorityProperties>( matchResult, true, matchResult.ranges.firstUARule, matchResult.ranges.lastUARule, applyInheritedOnly);2378 applyMatchedProperties<LowPriorityProperties>(state, matchResult, false, matchResult.ranges.lastUARule + 1, matchResult.matchedProperties.size() - 1, applyInheritedOnly); 2379 applyMatchedProperties<LowPriorityProperties>(state, matchResult, true, matchResult.ranges.firstAuthorRule, matchResult.ranges.lastAuthorRule, applyInheritedOnly); 2380 applyMatchedProperties<LowPriorityProperties>(state, matchResult, true, matchResult.ranges.firstUserRule, matchResult.ranges.lastUserRule, applyInheritedOnly); 2381 applyMatchedProperties<LowPriorityProperties>(state, matchResult, true, matchResult.ranges.firstUARule, matchResult.ranges.lastUARule, applyInheritedOnly); 2401 2382 2402 2383 // Start loading resources referenced by this style. 2403 loadPendingResources( );2384 loadPendingResources(state); 2404 2385 2405 2386 ASSERT(!state.fontDirty()); … … 2471 2452 } 2472 2453 2473 bool StyleResolver::isLeftPage( int pageIndex) const2454 bool StyleResolver::isLeftPage(State& state, int pageIndex) const 2474 2455 { 2475 2456 bool isFirstPageLeft = false; 2476 if (! m_state.rootElementStyle()->isLeftToRightDirection())2457 if (!state.rootElementStyle()->isLeftToRightDirection()) 2477 2458 isFirstPageLeft = true; 2478 2459 … … 2492 2473 } 2493 2474 2494 void StyleResolver::applyPropertyToStyle(CSSPropertyID id, CSSValue* value, RenderStyle* style) 2495 { 2496 initElement(0); 2497 m_state.initForStyleResolve(document(), 0, style); 2498 m_state.setStyle(style); 2499 applyPropertyToCurrentStyle(id, value); 2500 } 2501 2502 void StyleResolver::applyPropertyToCurrentStyle(CSSPropertyID id, CSSValue* value) 2503 { 2504 if (value) 2505 applyProperty(id, value); 2475 void StyleResolver::applyPropertyWithNullCheck(State& state, CSSPropertyID id, CSSValue* value) 2476 { 2477 if (!value) 2478 return; 2479 applyProperty(state, id, value); 2480 } 2481 2482 void StyleResolver::applyFontPropertyToStyle(RenderStyle* style, const StylePropertySet* parsedStyle) 2483 { 2484 State state(document()); 2485 state.initForStyleResolve(document(), 0, style); 2486 state.setStyle(style); 2487 2488 applyPropertyWithNullCheck(state, CSSPropertyFontFamily, parsedStyle->getPropertyCSSValue(CSSPropertyFontFamily).get()); 2489 applyPropertyWithNullCheck(state, CSSPropertyFontStyle, parsedStyle->getPropertyCSSValue(CSSPropertyFontStyle).get()); 2490 applyPropertyWithNullCheck(state, CSSPropertyFontVariant, parsedStyle->getPropertyCSSValue(CSSPropertyFontVariant).get()); 2491 applyPropertyWithNullCheck(state, CSSPropertyFontWeight, parsedStyle->getPropertyCSSValue(CSSPropertyFontWeight).get()); 2492 2493 // As described in BUG66291, setting font-size and line-height on a font may entail a CSSPrimitiveValue::computeLengthDouble call, 2494 // which assumes the fontMetrics are available for the affected font, otherwise a crash occurs (see http://trac.webkit.org/changeset/96122). 2495 // The updateFont() calls below update the fontMetrics and ensure the proper setting of font-size and line-height. 2496 updateFont(state); 2497 applyPropertyWithNullCheck(state, CSSPropertyFontSize, parsedStyle->getPropertyCSSValue(CSSPropertyFontSize).get()); 2498 updateFont(state); 2499 applyPropertyWithNullCheck(state, CSSPropertyLineHeight, parsedStyle->getPropertyCSSValue(CSSPropertyLineHeight).get()); 2506 2500 } 2507 2501 … … 2606 2600 // if we'd pass a 1.0 zoom factor everyhwere. So we only pass a zoom factor of 1.0 for specific 2607 2601 // properties that are NOT allowed to scale within a zoomed SVG document (letter/word-spacing/font-size). 2608 bool StyleResolver::useSVGZoomRules()2609 {2610 return m_state.element() && m_state.element()->isSVGElement();2611 }2612 2602 2613 2603 static bool createGridTrackBreadth(CSSPrimitiveValue* primitiveValue, const StyleResolver::State& state, Length& workingLength) … … 2727 2717 } 2728 2718 2729 void StyleResolver::resolveVariables( CSSPropertyID id, CSSValue* value, Vector<std::pair<CSSPropertyID, String> >& knownExpressions)2730 { 2731 std::pair<CSSPropertyID, String> expression(id, value->serializeResolvingVariables(* m_state.style()->variables()));2719 void StyleResolver::resolveVariables(State& state, CSSPropertyID id, CSSValue* value, Vector<std::pair<CSSPropertyID, String> >& knownExpressions) 2720 { 2721 std::pair<CSSPropertyID, String> expression(id, value->serializeResolvingVariables(*state.style()->variables())); 2732 2722 2733 2723 if (knownExpressions.contains(expression)) … … 2744 2734 StylePropertySet::PropertyReference property = resultSet->propertyAt(i); 2745 2735 if (property.id() != CSSPropertyVariable && hasVariableReference(property.value())) 2746 resolveVariables( property.id(), property.value(), knownExpressions);2736 resolveVariables(state, property.id(), property.value(), knownExpressions); 2747 2737 else 2748 applyProperty( property.id(), property.value());2749 } 2750 } 2751 #endif 2752 2753 void StyleResolver::applyProperty( CSSPropertyID id, CSSValue* value)2738 applyProperty(state, property.id(), property.value()); 2739 } 2740 } 2741 #endif 2742 2743 void StyleResolver::applyProperty(State& state, CSSPropertyID id, CSSValue* value) 2754 2744 { 2755 2745 #if ENABLE(CSS_VARIABLES) 2756 2746 if (id != CSSPropertyVariable && hasVariableReference(value)) { 2757 2747 Vector<std::pair<CSSPropertyID, String> > knownExpressions; 2758 resolveVariables(id, value, knownExpressions); 2759 return; 2760 } 2761 #endif 2762 2763 State& state = m_state; 2748 resolveVariables(state, id, value, knownExpressions); 2749 return; 2750 } 2751 #endif 2752 2764 2753 bool isInherit = state.parentNode() && value->isInheritedValue(); 2765 2754 bool isInitial = value->isInitialValue() || (!state.parentNode() && value->isInheritedValue()); … … 2791 2780 if (handler.isValid()) { 2792 2781 if (isInherit) 2793 handler.applyInheritValue(id, this);2782 handler.applyInheritValue(id, state); 2794 2783 else if (isInitial) 2795 handler.applyInitialValue(id, this);2784 handler.applyInitialValue(id, state); 2796 2785 else 2797 handler.applyValue(id, this, value);2786 handler.applyValue(id, state, value); 2798 2787 return; 2799 2788 } … … 2827 2816 if (item->isImageGeneratorValue()) { 2828 2817 if (item->isGradientValue()) 2829 state.style()->setContent(StyleGeneratedImage::create(static_cast<CSSGradientValue*>(item)->gradientWithStylesResolved( this).get()), didSet);2818 state.style()->setContent(StyleGeneratedImage::create(static_cast<CSSGradientValue*>(item)->gradientWithStylesResolved(state).get()), didSet); 2830 2819 else 2831 2820 state.style()->setContent(StyleGeneratedImage::create(static_cast<CSSImageGeneratorValue*>(item)), didSet); … … 2833 2822 #if ENABLE(CSS_IMAGE_SET) 2834 2823 } else if (item->isImageSetValue()) { 2835 state.style()->setContent(setOrPendingFromValue( CSSPropertyContent, static_cast<CSSImageSetValue*>(item)), didSet);2824 state.style()->setContent(setOrPendingFromValue(state, CSSPropertyContent, static_cast<CSSImageSetValue*>(item)), didSet); 2836 2825 didSet = true; 2837 2826 #endif … … 2839 2828 2840 2829 if (item->isImageValue()) { 2841 state.style()->setContent(cachedOrPendingFromValue( CSSPropertyContent, static_cast<CSSImageValue*>(item)), didSet);2830 state.style()->setContent(cachedOrPendingFromValue(state, CSSPropertyContent, static_cast<CSSImageValue*>(item)), didSet); 2842 2831 didSet = true; 2843 2832 continue; … … 2941 2930 fontDescription.setFamily(parentFontDescription.firstFamily()); 2942 2931 fontDescription.setIsSpecifiedFont(parentFontDescription.isSpecifiedFont()); 2943 s etFontDescription(fontDescription);2932 state.setFontDescription(fontDescription); 2944 2933 return; 2945 2934 } … … 2951 2940 // to non-monospace. 2952 2941 if (fontDescription.keywordSize() && fontDescription.useFixedDefaultSize()) 2953 setFontSize( fontDescription, fontSizeForKeyword(document(), CSSValueXxSmall + fontDescription.keywordSize() - 1, false));2942 setFontSize(state, fontDescription, fontSizeForKeyword(document(), CSSValueXxSmall + fontDescription.keywordSize() - 1, false)); 2954 2943 fontDescription.setGenericFamily(initialDesc.genericFamily()); 2955 2944 if (!initialDesc.firstFamily().familyIsEmpty()) 2956 2945 fontDescription.setFamily(initialDesc.firstFamily()); 2957 s etFontDescription(fontDescription);2946 state.setFontDescription(fontDescription); 2958 2947 return; 2959 2948 } … … 3030 3019 if (currFamily) { 3031 3020 if (fontDescription.keywordSize() && fontDescription.useFixedDefaultSize() != oldFamilyUsedFixedDefaultSize) 3032 setFontSize( fontDescription, fontSizeForKeyword(document(), CSSValueXxSmall + fontDescription.keywordSize() - 1, !oldFamilyUsedFixedDefaultSize));3033 3034 s etFontDescription(fontDescription);3021 setFontSize(state, fontDescription, fontSizeForKeyword(document(), CSSValueXxSmall + fontDescription.keywordSize() - 1, !oldFamilyUsedFixedDefaultSize)); 3022 3023 state.setFontDescription(fontDescription); 3035 3024 } 3036 3025 return; … … 3057 3046 state.style()->setLineHeight(state.parentStyle()->specifiedLineHeight()); 3058 3047 state.setLineHeightValue(0); 3059 s etFontDescription(fontDescription);3048 state.setFontDescription(fontDescription); 3060 3049 } else if (isInitial) { 3061 3050 Settings* settings = documentSettings(); … … 3063 3052 if (!settings) 3064 3053 return; 3065 initializeFontStyle(s ettings);3054 initializeFontStyle(state, settings); 3066 3055 } else if (primitiveValue) { 3067 3056 state.style()->setLineHeight(RenderStyle::initialLineHeight()); … … 3082 3071 3083 3072 // Handle the zoom factor. 3084 fontDescription.setComputedSize(getComputedSizeFromSpecifiedSize(document(), state.style(), fontDescription.isAbsoluteSize(), fontDescription.specifiedSize(), useSVGZoomRules()));3085 s etFontDescription(fontDescription);3073 fontDescription.setComputedSize(getComputedSizeFromSpecifiedSize(document(), state.style(), fontDescription.isAbsoluteSize(), fontDescription.specifiedSize(), state.useSVGZoomRules())); 3074 state.setFontDescription(fontDescription); 3086 3075 } 3087 3076 } else if (value->isFontValue()) { … … 3090 3079 || !font->size || !font->lineHeight || !font->family) 3091 3080 return; 3092 applyProperty( CSSPropertyFontStyle, font->style.get());3093 applyProperty( CSSPropertyFontVariant, font->variant.get());3094 applyProperty( CSSPropertyFontWeight, font->weight.get());3081 applyProperty(state, CSSPropertyFontStyle, font->style.get()); 3082 applyProperty(state, CSSPropertyFontVariant, font->variant.get()); 3083 applyProperty(state, CSSPropertyFontWeight, font->weight.get()); 3095 3084 // The previous properties can dirty our font but they don't try to read the font's 3096 3085 // properties back, which is safe. However if font-size is using the 'ex' unit, it will 3097 3086 // need query the dirtied font's x-height to get the computed size. To be safe in this 3098 3087 // case, let's just update the font now. 3099 updateFont( );3100 applyProperty( CSSPropertyFontSize, font->size.get());3088 updateFont(state); 3089 applyProperty(state, CSSPropertyFontSize, font->size.get()); 3101 3090 3102 3091 state.setLineHeightValue(font->lineHeight.get()); 3103 3092 3104 applyProperty( CSSPropertyFontFamily, font->family.get());3093 applyProperty(state, CSSPropertyFontFamily, font->family.get()); 3105 3094 } 3106 3095 return; … … 3133 3122 Color color; 3134 3123 if (item->color) 3135 color = colorFromPrimitiveValue( item->color.get());3124 color = colorFromPrimitiveValue(state, item->color.get()); 3136 3125 else if (state.style()) 3137 3126 color = state.style()->color(); … … 3162 3151 NinePieceImage mask; 3163 3152 mask.setMaskDefaults(); 3164 m_styleMap.mapNinePieceImage(id, reflectValue->mask(), mask); 3153 CSSToStyleMap styleMap(state); 3154 styleMap.mapNinePieceImage(id, reflectValue->mask(), mask); 3165 3155 reflection->setMask(mask); 3166 3156 … … 3254 3244 FontDescription fontDescription = state.style()->fontDescription(); 3255 3245 fontDescription.setScript(localeToScriptCodeForFontSelection(state.style()->locale())); 3256 s etFontDescription(fontDescription);3246 state.setFontDescription(fontDescription); 3257 3247 return; 3258 3248 } … … 3261 3251 if (!primitiveValue || !primitiveValue->getIdent()) 3262 3252 return; 3263 s etTextSizeAdjust(primitiveValue->getIdent() == CSSValueAuto);3253 state.setTextSizeAdjust(primitiveValue->getIdent() == CSSValueAuto); 3264 3254 return; 3265 3255 } … … 3388 3378 break; 3389 3379 3390 Color col = colorFromPrimitiveValue( primitiveValue);3380 Color col = colorFromPrimitiveValue(state, primitiveValue); 3391 3381 state.style()->setTapHighlightColor(col); 3392 3382 return; … … 3443 3433 CSSPropertyID newId = CSSProperty::resolveDirectionAwareProperty(id, state.style()->direction(), state.style()->writingMode()); 3444 3434 ASSERT(newId != id); 3445 return applyProperty( newId, value);3435 return applyProperty(state, newId, value); 3446 3436 } 3447 3437 case CSSPropertyFontStretch: … … 3473 3463 3474 3464 if (primitiveValue) 3475 s etWritingMode(*primitiveValue);3465 state.setWritingMode(*primitiveValue); 3476 3466 3477 3467 // FIXME: It is not ok to modify document state while applying style. … … 3485 3475 3486 3476 if (primitiveValue) 3487 s etTextOrientation(*primitiveValue);3477 state.setTextOrientation(*primitiveValue); 3488 3478 3489 3479 return; … … 3508 3498 case CSSPropertyWebkitFontFeatureSettings: { 3509 3499 if (primitiveValue && primitiveValue->getIdent() == CSSValueNormal) { 3510 s etFontDescription(state.style()->fontDescription().makeNormalFeatureSettings());3500 state.setFontDescription(state.style()->fontDescription().makeNormalFeatureSettings()); 3511 3501 return; 3512 3502 } … … 3527 3517 } 3528 3518 fontDescription.setFeatureSettings(settings.release()); 3529 s etFontDescription(fontDescription);3519 state.setFontDescription(fontDescription); 3530 3520 return; 3531 3521 } … … 3535 3525 HANDLE_INHERIT_AND_INITIAL(filter, Filter); 3536 3526 FilterOperations operations; 3537 if (createFilterOperations( value, state.style(), state.rootElementStyle(), operations))3527 if (createFilterOperations(state, value, state.style(), state.rootElementStyle(), operations)) 3538 3528 state.style()->setFilter(operations); 3539 3529 return; … … 3856 3846 #if ENABLE(SVG) 3857 3847 // Try the SVG properties 3858 applySVGProperty( id, value);3859 #endif 3860 return; 3861 } 3862 } 3863 3864 PassRefPtr<StyleImage> StyleResolver::styleImage( CSSPropertyID property, CSSValue* value)3848 applySVGProperty(state, id, value); 3849 #endif 3850 return; 3851 } 3852 } 3853 3854 PassRefPtr<StyleImage> StyleResolver::styleImage(State& state, CSSPropertyID property, CSSValue* value) 3865 3855 { 3866 3856 if (value->isImageValue()) 3867 return cachedOrPendingFromValue( property, static_cast<CSSImageValue*>(value));3857 return cachedOrPendingFromValue(state, property, static_cast<CSSImageValue*>(value)); 3868 3858 3869 3859 if (value->isImageGeneratorValue()) { 3870 3860 if (value->isGradientValue()) 3871 return generatedOrPendingFromValue( property, static_cast<CSSGradientValue*>(value)->gradientWithStylesResolved(this).get());3872 return generatedOrPendingFromValue( property, static_cast<CSSImageGeneratorValue*>(value));3861 return generatedOrPendingFromValue(state, property, static_cast<CSSGradientValue*>(value)->gradientWithStylesResolved(state).get()); 3862 return generatedOrPendingFromValue(state, property, static_cast<CSSImageGeneratorValue*>(value)); 3873 3863 } 3874 3864 3875 3865 #if ENABLE(CSS_IMAGE_SET) 3876 3866 if (value->isImageSetValue()) 3877 return setOrPendingFromValue( property, static_cast<CSSImageSetValue*>(value));3867 return setOrPendingFromValue(state, property, static_cast<CSSImageSetValue*>(value)); 3878 3868 #endif 3879 3869 3880 3870 if (value->isCursorImageValue()) 3881 return cursorOrPendingFromValue( property, static_cast<CSSCursorImageValue*>(value));3871 return cursorOrPendingFromValue(state, property, static_cast<CSSCursorImageValue*>(value)); 3882 3872 3883 3873 return 0; 3884 3874 } 3885 3875 3886 PassRefPtr<StyleImage> StyleResolver::cachedOrPendingFromValue( CSSPropertyID property, CSSImageValue* value)3876 PassRefPtr<StyleImage> StyleResolver::cachedOrPendingFromValue(State& state, CSSPropertyID property, CSSImageValue* value) 3887 3877 { 3888 3878 RefPtr<StyleImage> image = value->cachedOrPendingImage(); 3889 3879 if (image && image->isPendingImage()) 3890 m_state.pendingImageProperties().set(property, value);3880 state.pendingImageProperties().set(property, value); 3891 3881 return image.release(); 3892 3882 } 3893 3883 3894 PassRefPtr<StyleImage> StyleResolver::generatedOrPendingFromValue( CSSPropertyID property, CSSImageGeneratorValue* value)3884 PassRefPtr<StyleImage> StyleResolver::generatedOrPendingFromValue(State& state, CSSPropertyID property, CSSImageGeneratorValue* value) 3895 3885 { 3896 3886 if (value->isPending()) { 3897 m_state.pendingImageProperties().set(property, value);3887 state.pendingImageProperties().set(property, value); 3898 3888 return StylePendingImage::create(value); 3899 3889 } … … 3902 3892 3903 3893 #if ENABLE(CSS_IMAGE_SET) 3904 PassRefPtr<StyleImage> StyleResolver::setOrPendingFromValue( CSSPropertyID property, CSSImageSetValue* value)3905 { 3906 RefPtr<StyleImage> image = value->cachedOrPendingImageSet( document());3894 PassRefPtr<StyleImage> StyleResolver::setOrPendingFromValue(State& state, CSSPropertyID property, CSSImageSetValue* value) 3895 { 3896 RefPtr<StyleImage> image = value->cachedOrPendingImageSet(state.document()); 3907 3897 if (image && image->isPendingImage()) 3908 m_state.pendingImageProperties().set(property, value);3898 state.pendingImageProperties().set(property, value); 3909 3899 return image.release(); 3910 3900 } 3911 3901 #endif 3912 3902 3913 PassRefPtr<StyleImage> StyleResolver::cursorOrPendingFromValue( CSSPropertyID property, CSSCursorImageValue* value)3914 { 3915 RefPtr<StyleImage> image = value->cachedOrPendingImage( document());3903 PassRefPtr<StyleImage> StyleResolver::cursorOrPendingFromValue(State& state, CSSPropertyID property, CSSCursorImageValue* value) 3904 { 3905 RefPtr<StyleImage> image = value->cachedOrPendingImage(state.document()); 3916 3906 if (image && image->isPendingImage()) 3917 m_state.pendingImageProperties().set(property, value);3907 state.pendingImageProperties().set(property, value); 3918 3908 return image.release(); 3919 3909 } 3920 3910 3921 void StyleResolver::checkForTextSizeAdjust( )3922 { 3923 RenderStyle* style = m_state.style();3911 void StyleResolver::checkForTextSizeAdjust(State& state) 3912 { 3913 RenderStyle* style = state.style(); 3924 3914 3925 3915 if (style->textSizeAdjust()) … … 3931 3921 } 3932 3922 3933 void StyleResolver::checkForZoomChange( RenderStyle* style, RenderStyle* parentStyle)3923 void StyleResolver::checkForZoomChange(State& state, RenderStyle* style, RenderStyle* parentStyle) 3934 3924 { 3935 3925 if (style->effectiveZoom() == parentStyle->effectiveZoom()) … … 3938 3928 const FontDescription& childFont = style->fontDescription(); 3939 3929 FontDescription newFontDescription(childFont); 3940 setFontSize( newFontDescription, childFont.specifiedSize());3930 setFontSize(state, newFontDescription, childFont.specifiedSize()); 3941 3931 style->setFontDescription(newFontDescription); 3942 3932 } 3943 3933 3944 void StyleResolver::checkForGenericFamilyChange( RenderStyle* style, RenderStyle* parentStyle)3934 void StyleResolver::checkForGenericFamilyChange(State& state, RenderStyle* style, RenderStyle* parentStyle) 3945 3935 { 3946 3936 const FontDescription& childFont = style->fontDescription(); … … 3976 3966 3977 3967 FontDescription newFontDescription(childFont); 3978 setFontSize( newFontDescription, size);3968 setFontSize(state, newFontDescription, size); 3979 3969 style->setFontDescription(newFontDescription); 3980 3970 } 3981 3971 3982 void StyleResolver::initializeFontStyle(S ettings* settings)3972 void StyleResolver::initializeFontStyle(State& state, Settings* settings) 3983 3973 { 3984 3974 FontDescription fontDescription; … … 3992 3982 } 3993 3983 fontDescription.setKeywordSize(CSSValueMedium - CSSValueXxSmall + 1); 3994 setFontSize( fontDescription, fontSizeForKeyword(document(), CSSValueMedium, false));3995 m_state.style()->setLineHeight(RenderStyle::initialLineHeight());3996 m_state.setLineHeightValue(0);3997 s etFontDescription(fontDescription);3998 } 3999 4000 void StyleResolver::setFontSize( FontDescription& fontDescription, float size)3984 setFontSize(state, fontDescription, fontSizeForKeyword(document(), CSSValueMedium, false)); 3985 state.style()->setLineHeight(RenderStyle::initialLineHeight()); 3986 state.setLineHeightValue(0); 3987 state.setFontDescription(fontDescription); 3988 } 3989 3990 void StyleResolver::setFontSize(State& state, FontDescription& fontDescription, float size) 4001 3991 { 4002 3992 fontDescription.setSpecifiedSize(size); 4003 fontDescription.setComputedSize(getComputedSizeFromSpecifiedSize( document(), m_state.style(), fontDescription.isAbsoluteSize(), size,useSVGZoomRules()));3993 fontDescription.setComputedSize(getComputedSizeFromSpecifiedSize(state.document(), state.style(), fontDescription.isAbsoluteSize(), size, state.useSVGZoomRules())); 4004 3994 } 4005 3995 … … 4199 4189 } 4200 4190 4201 Color StyleResolver::colorFromPrimitiveValue( CSSPrimitiveValue* value, bool forVisitedLink) const4191 Color StyleResolver::colorFromPrimitiveValue(const StyleResolver::State& state, CSSPrimitiveValue* value, bool forVisitedLink) 4202 4192 { 4203 4193 if (value->isRGBColor()) 4204 4194 return Color(value->getRGBA32Value()); 4205 4195 4206 const State& state = m_state;4207 4196 int ident = value->getIdent(); 4208 4197 switch (ident) { … … 4550 4539 4551 4540 #if ENABLE(CSS_FILTERS) && ENABLE(SVG) 4552 void StyleResolver::loadPendingSVGDocuments() 4553 { 4554 State& state = m_state; 4541 void StyleResolver::loadPendingSVGDocuments(State& state) 4542 { 4555 4543 if (!state.style()->hasFilter() || state.pendingSVGDocuments().isEmpty()) 4556 4544 return; … … 4579 4567 4580 4568 #if ENABLE(CSS_SHADERS) 4581 StyleShader* StyleResolver::styleShader( CSSValue* value)4569 StyleShader* StyleResolver::styleShader(State& state, CSSValue* value) 4582 4570 { 4583 4571 if (value->isWebKitCSSShaderValue()) 4584 return cachedOrPendingStyleShaderFromValue(stat ic_cast<WebKitCSSShaderValue*>(value));4572 return cachedOrPendingStyleShaderFromValue(state, static_cast<WebKitCSSShaderValue*>(value)); 4585 4573 return 0; 4586 4574 } 4587 4575 4588 StyleShader* StyleResolver::cachedOrPendingStyleShaderFromValue( WebKitCSSShaderValue* value)4576 StyleShader* StyleResolver::cachedOrPendingStyleShaderFromValue(State& state, WebKitCSSShaderValue* value) 4589 4577 { 4590 4578 StyleShader* shader = value->cachedOrPendingShader(); 4591 4579 if (shader && shader->isPendingShader()) 4592 m_state.setHasPendingShaders(true);4580 state.setHasPendingShaders(true); 4593 4581 return shader; 4594 4582 } 4595 4583 4596 void StyleResolver::loadPendingShaders( )4597 { 4598 if (! m_state.style()->hasFilter() || !m_state.hasPendingShaders())4599 return; 4600 4601 CachedResourceLoader* cachedResourceLoader = m_state.document()->cachedResourceLoader();4602 4603 Vector<RefPtr<FilterOperation> >& filterOperations = m_state.style()->mutableFilter().operations();4584 void StyleResolver::loadPendingShaders(State& state) 4585 { 4586 if (!state.style()->hasFilter() || !state.hasPendingShaders()) 4587 return; 4588 4589 CachedResourceLoader* cachedResourceLoader = state.document()->cachedResourceLoader(); 4590 4591 Vector<RefPtr<FilterOperation> >& filterOperations = state.style()->mutableFilter().operations(); 4604 4592 for (unsigned i = 0; i < filterOperations.size(); ++i) { 4605 4593 RefPtr<FilterOperation> filterOperation = filterOperations.at(i); … … 4618 4606 } 4619 4607 } 4620 m_state.setHasPendingShaders(false);4608 state.setHasPendingShaders(false); 4621 4609 } 4622 4610 … … 4656 4644 } 4657 4645 4658 PassRefPtr<CustomFilterParameter> StyleResolver::parseCustomFilterTransformParameter( const String& name, CSSValueList* values)4646 PassRefPtr<CustomFilterParameter> StyleResolver::parseCustomFilterTransformParameter(State& state, const String& name, CSSValueList* values) 4659 4647 { 4660 4648 RefPtr<CustomFilterTransformParameter> transformParameter = CustomFilterTransformParameter::create(name); 4661 4649 TransformOperations operations; 4662 createTransformOperations(values, m_state.style(), m_state.rootElementStyle(), operations);4650 createTransformOperations(values, state.style(), state.rootElementStyle(), operations); 4663 4651 transformParameter->setOperations(operations); 4664 4652 return transformParameter.release(); 4665 4653 } 4666 4654 4667 PassRefPtr<CustomFilterParameter> StyleResolver::parseCustomFilterParameter( const String& name, CSSValue* parameterValue)4655 PassRefPtr<CustomFilterParameter> StyleResolver::parseCustomFilterParameter(State& state, const String& name, CSSValue* parameterValue) 4668 4656 { 4669 4657 // FIXME: Implement other parameters types parsing. … … 4688 4676 // return 0 if that assumption is incorrect. 4689 4677 if (values->itemWithoutBoundsCheck(0)->isWebKitCSSTransformValue()) 4690 return parseCustomFilterTransformParameter( name, values);4678 return parseCustomFilterTransformParameter(state, name, values); 4691 4679 4692 4680 // We can have only arrays of booleans or numbers, so use the first value to choose between those two. … … 4705 4693 } 4706 4694 4707 bool StyleResolver::parseCustomFilterParameterList( CSSValue* parametersValue, CustomFilterParameterList& parameterList)4695 bool StyleResolver::parseCustomFilterParameterList(State& state, CSSValue* parametersValue, CustomFilterParameterList& parameterList) 4708 4696 { 4709 4697 HashSet<String> knownParameterNames; … … 4730 4718 return false; 4731 4719 4732 RefPtr<CustomFilterParameter> parameter = parseCustomFilterParameter( name, iterator.value());4720 RefPtr<CustomFilterParameter> parameter = parseCustomFilterParameter(state, name, iterator.value()); 4733 4721 if (!parameter) 4734 4722 return false; … … 4749 4737 } 4750 4738 4751 PassRefPtr<CustomFilterOperation> StyleResolver::createCustomFilterOperationWithInlineSyntax( WebKitCSSFilterValue* filterValue)4739 PassRefPtr<CustomFilterOperation> StyleResolver::createCustomFilterOperationWithInlineSyntax(State& state, WebKitCSSFilterValue* filterValue) 4752 4740 { 4753 4741 CSSValue* shadersValue = filterValue->itemWithoutBoundsCheck(0); … … 4758 4746 ASSERT(shadersListLength); 4759 4747 4760 RefPtr<StyleShader> vertexShader = styleShader(s hadersList->itemWithoutBoundsCheck(0));4748 RefPtr<StyleShader> vertexShader = styleShader(state, shadersList->itemWithoutBoundsCheck(0)); 4761 4749 RefPtr<StyleShader> fragmentShader; 4762 4750 CustomFilterProgramType programType = PROGRAM_TYPE_BLENDS_ELEMENT_TEXTURE; … … 4771 4759 4772 4760 ASSERT(mixFunction->length()); 4773 fragmentShader = styleShader( iterator.value());4761 fragmentShader = styleShader(state, iterator.value()); 4774 4762 iterator.advance(); 4775 4763 … … 4787 4775 } else { 4788 4776 programType = PROGRAM_TYPE_NO_ELEMENT_TEXTURE; 4789 fragmentShader = styleShader( fragmentShaderOrMixFunction);4777 fragmentShader = styleShader(state, fragmentShaderOrMixFunction); 4790 4778 } 4791 4779 } … … 4843 4831 4844 4832 CustomFilterParameterList parameterList; 4845 if (parametersValue && !parseCustomFilterParameterList( parametersValue, parameterList))4833 if (parametersValue && !parseCustomFilterParameterList(state, parametersValue, parameterList)) 4846 4834 return 0; 4847 4835 … … 4850 4838 } 4851 4839 4852 PassRefPtr<CustomFilterOperation> StyleResolver::createCustomFilterOperation( WebKitCSSFilterValue* filterValue)4840 PassRefPtr<CustomFilterOperation> StyleResolver::createCustomFilterOperation(State& state, WebKitCSSFilterValue* filterValue) 4853 4841 { 4854 4842 ASSERT(filterValue->length()); 4855 4843 bool isAtRuleReferenceSyntax = filterValue->itemWithoutBoundsCheck(0)->isPrimitiveValue(); 4856 return isAtRuleReferenceSyntax ? createCustomFilterOperationWithAtRuleReferenceSyntax(filterValue) : createCustomFilterOperationWithInlineSyntax( filterValue);4857 } 4858 4859 #endif 4860 4861 bool StyleResolver::createFilterOperations( CSSValue* inValue, RenderStyle* style, RenderStyle* rootStyle, FilterOperations& outOperations)4844 return isAtRuleReferenceSyntax ? createCustomFilterOperationWithAtRuleReferenceSyntax(filterValue) : createCustomFilterOperationWithInlineSyntax(state, filterValue); 4845 } 4846 4847 #endif 4848 4849 bool StyleResolver::createFilterOperations(State& state, CSSValue* inValue, RenderStyle* style, RenderStyle* rootStyle, FilterOperations& outOperations) 4862 4850 { 4863 4851 ASSERT(outOperations.isEmpty()); … … 4892 4880 } 4893 4881 if (operationType == FilterOperation::CUSTOM) { 4894 RefPtr<CustomFilterOperation> operation = createCustomFilterOperation( filterValue);4882 RefPtr<CustomFilterOperation> operation = createCustomFilterOperation(state, filterValue); 4895 4883 if (!operation) 4896 4884 return false; … … 4910 4898 4911 4899 WebKitCSSSVGDocumentValue* svgDocumentValue = static_cast<WebKitCSSSVGDocumentValue*>(argument); 4912 KURL url = m_state.document()->completeURL(svgDocumentValue->url());4900 KURL url = state.document()->completeURL(svgDocumentValue->url()); 4913 4901 4914 4902 RefPtr<ReferenceFilterOperation> operation = ReferenceFilterOperation::create(svgDocumentValue->url(), url.fragmentIdentifier(), operationType); 4915 if (SVGURIReference::isExternalURIReference(svgDocumentValue->url(), m_state.document())) {4903 if (SVGURIReference::isExternalURIReference(svgDocumentValue->url(), state.document())) { 4916 4904 if (!svgDocumentValue->loadRequested()) 4917 m_state.pendingSVGDocuments().set(operation.get(), svgDocumentValue);4905 state.pendingSVGDocuments().set(operation.get(), svgDocumentValue); 4918 4906 else if (svgDocumentValue->cachedSVGDocument()) 4919 4907 operation->setCachedSVGDocumentReference(adoptPtr(new CachedSVGDocumentReference(svgDocumentValue->cachedSVGDocument()))); … … 4999 4987 Color color; 5000 4988 if (item->color) 5001 color = colorFromPrimitiveValue( item->color.get());4989 color = colorFromPrimitiveValue(state, item->color.get()); 5002 4990 5003 4991 operations.operations().append(DropShadowFilterOperation::create(location, blur, color.isValid() ? color : Color::transparent, operationType)); … … 5017 5005 #endif 5018 5006 5019 PassRefPtr<StyleImage> StyleResolver::loadPendingImage(St ylePendingImage* pendingImage)5020 { 5021 CachedResourceLoader* cachedResourceLoader = m_state.document()->cachedResourceLoader();5007 PassRefPtr<StyleImage> StyleResolver::loadPendingImage(State& state, StylePendingImage* pendingImage) 5008 { 5009 CachedResourceLoader* cachedResourceLoader = state.document()->cachedResourceLoader(); 5022 5010 5023 5011 if (pendingImage->cssImageValue()) { … … 5047 5035 } 5048 5036 5049 void StyleResolver::loadPendingImages( )5050 { 5051 if ( m_state.pendingImageProperties().isEmpty())5052 return; 5053 5054 PendingImagePropertyMap::const_iterator::Keys end = m_state.pendingImageProperties().end().keys();5055 for (PendingImagePropertyMap::const_iterator::Keys it = m_state.pendingImageProperties().begin().keys(); it != end; ++it) {5037 void StyleResolver::loadPendingImages(State& state) 5038 { 5039 if (state.pendingImageProperties().isEmpty()) 5040 return; 5041 5042 PendingImagePropertyMap::const_iterator::Keys end = state.pendingImageProperties().end().keys(); 5043 for (PendingImagePropertyMap::const_iterator::Keys it = state.pendingImageProperties().begin().keys(); it != end; ++it) { 5056 5044 CSSPropertyID currentProperty = *it; 5057 5045 5058 5046 switch (currentProperty) { 5059 5047 case CSSPropertyBackgroundImage: { 5060 for (FillLayer* backgroundLayer = m_state.style()->accessBackgroundLayers(); backgroundLayer; backgroundLayer = backgroundLayer->next()) {5048 for (FillLayer* backgroundLayer = state.style()->accessBackgroundLayers(); backgroundLayer; backgroundLayer = backgroundLayer->next()) { 5061 5049 if (backgroundLayer->image() && backgroundLayer->image()->isPendingImage()) 5062 backgroundLayer->setImage(loadPendingImage(stat ic_cast<StylePendingImage*>(backgroundLayer->image())));5050 backgroundLayer->setImage(loadPendingImage(state, static_cast<StylePendingImage*>(backgroundLayer->image()))); 5063 5051 } 5064 5052 break; 5065 5053 } 5066 5054 case CSSPropertyContent: { 5067 for (ContentData* contentData = const_cast<ContentData*>( m_state.style()->contentData()); contentData; contentData = contentData->next()) {5055 for (ContentData* contentData = const_cast<ContentData*>(state.style()->contentData()); contentData; contentData = contentData->next()) { 5068 5056 if (contentData->isImage()) { 5069 5057 StyleImage* image = static_cast<ImageContentData*>(contentData)->image(); 5070 5058 if (image->isPendingImage()) { 5071 RefPtr<StyleImage> loadedImage = loadPendingImage(stat ic_cast<StylePendingImage*>(image));5059 RefPtr<StyleImage> loadedImage = loadPendingImage(state, static_cast<StylePendingImage*>(image)); 5072 5060 if (loadedImage) 5073 5061 static_cast<ImageContentData*>(contentData)->setImage(loadedImage.release()); … … 5078 5066 } 5079 5067 case CSSPropertyCursor: { 5080 if (CursorList* cursorList = m_state.style()->cursors()) {5068 if (CursorList* cursorList = state.style()->cursors()) { 5081 5069 for (size_t i = 0; i < cursorList->size(); ++i) { 5082 5070 CursorData& currentCursor = cursorList->at(i); 5083 5071 if (StyleImage* image = currentCursor.image()) { 5084 5072 if (image->isPendingImage()) 5085 currentCursor.setImage(loadPendingImage(stat ic_cast<StylePendingImage*>(image)));5073 currentCursor.setImage(loadPendingImage(state, static_cast<StylePendingImage*>(image))); 5086 5074 } 5087 5075 } … … 5090 5078 } 5091 5079 case CSSPropertyListStyleImage: { 5092 if ( m_state.style()->listStyleImage() && m_state.style()->listStyleImage()->isPendingImage())5093 m_state.style()->setListStyleImage(loadPendingImage(static_cast<StylePendingImage*>(m_state.style()->listStyleImage())));5080 if (state.style()->listStyleImage() && state.style()->listStyleImage()->isPendingImage()) 5081 state.style()->setListStyleImage(loadPendingImage(state, static_cast<StylePendingImage*>(state.style()->listStyleImage()))); 5094 5082 break; 5095 5083 } 5096 5084 case CSSPropertyBorderImageSource: { 5097 if ( m_state.style()->borderImageSource() && m_state.style()->borderImageSource()->isPendingImage())5098 m_state.style()->setBorderImageSource(loadPendingImage(static_cast<StylePendingImage*>(m_state.style()->borderImageSource())));5085 if (state.style()->borderImageSource() && state.style()->borderImageSource()->isPendingImage()) 5086 state.style()->setBorderImageSource(loadPendingImage(state, static_cast<StylePendingImage*>(state.style()->borderImageSource()))); 5099 5087 break; 5100 5088 } 5101 5089 case CSSPropertyWebkitBoxReflect: { 5102 if (StyleReflection* reflection = m_state.style()->boxReflect()) {5090 if (StyleReflection* reflection = state.style()->boxReflect()) { 5103 5091 const NinePieceImage& maskImage = reflection->mask(); 5104 5092 if (maskImage.image() && maskImage.image()->isPendingImage()) { 5105 RefPtr<StyleImage> loadedImage = loadPendingImage(stat ic_cast<StylePendingImage*>(maskImage.image()));5093 RefPtr<StyleImage> loadedImage = loadPendingImage(state, static_cast<StylePendingImage*>(maskImage.image())); 5106 5094 reflection->setMask(NinePieceImage(loadedImage.release(), maskImage.imageSlices(), maskImage.fill(), maskImage.borderSlices(), maskImage.outset(), maskImage.horizontalRule(), maskImage.verticalRule())); 5107 5095 } … … 5110 5098 } 5111 5099 case CSSPropertyWebkitMaskBoxImageSource: { 5112 if ( m_state.style()->maskBoxImageSource() && m_state.style()->maskBoxImageSource()->isPendingImage())5113 m_state.style()->setMaskBoxImageSource(loadPendingImage(static_cast<StylePendingImage*>(m_state.style()->maskBoxImageSource())));5100 if (state.style()->maskBoxImageSource() && state.style()->maskBoxImageSource()->isPendingImage()) 5101 state.style()->setMaskBoxImageSource(loadPendingImage(state, static_cast<StylePendingImage*>(state.style()->maskBoxImageSource()))); 5114 5102 break; 5115 5103 } 5116 5104 case CSSPropertyWebkitMaskImage: { 5117 for (FillLayer* maskLayer = m_state.style()->accessMaskLayers(); maskLayer; maskLayer = maskLayer->next()) {5105 for (FillLayer* maskLayer = state.style()->accessMaskLayers(); maskLayer; maskLayer = maskLayer->next()) { 5118 5106 if (maskLayer->image() && maskLayer->image()->isPendingImage()) 5119 maskLayer->setImage(loadPendingImage(stat ic_cast<StylePendingImage*>(maskLayer->image())));5107 maskLayer->setImage(loadPendingImage(state, static_cast<StylePendingImage*>(maskLayer->image()))); 5120 5108 } 5121 5109 break; … … 5126 5114 } 5127 5115 5128 m_state.pendingImageProperties().clear();5129 } 5130 5131 void StyleResolver::loadPendingResources( )5116 state.pendingImageProperties().clear(); 5117 } 5118 5119 void StyleResolver::loadPendingResources(State& state) 5132 5120 { 5133 5121 // Start loading images referenced by this style. 5134 loadPendingImages( );5122 loadPendingImages(state); 5135 5123 5136 5124 #if ENABLE(CSS_SHADERS) 5137 5125 // Start loading the shaders referenced by this style. 5138 loadPendingShaders( );5126 loadPendingShaders(state); 5139 5127 #endif 5140 5128 5141 5129 #if ENABLE(CSS_FILTERS) && ENABLE(SVG) 5142 5130 // Start loading the SVG Documents referenced by this style. 5143 loadPendingSVGDocuments( );5131 loadPendingSVGDocuments(state); 5144 5132 #endif 5145 5133 } … … 5184 5172 info.addMember(m_scopeResolver, "scopeResolver"); 5185 5173 5186 info.addMember(m_state, "state");5187 5188 5174 // FIXME: move this to a place where it would be called only once? 5189 5175 info.addMember(CSSDefaultStyleSheets::defaultStyle, "defaultStyle"); -
trunk/Source/WebCore/css/StyleResolver.h
r142855 r143556 25 25 #include "CSSRule.h" 26 26 #include "CSSRuleList.h" 27 #include "CSSToStyleMap.h"28 27 #include "CSSValueList.h" 29 28 #include "DocumentRuleSets.h" … … 179 178 static PassRefPtr<RenderStyle> styleForDocument(Document*, CSSFontSelector* = 0); 180 179 181 RenderStyle* style() const { return m_state.style(); }182 RenderStyle* parentStyle() const { return m_state.parentStyle(); }183 RenderStyle* rootElementStyle() const { return m_state.rootElementStyle(); }184 Element* element() { return m_state.element(); }185 180 Document* document() { return m_document; } 186 181 StyleScopeResolver* scopeResolver() const { return m_scopeResolver.get(); } 187 bool hasParentNode() const { return m_state.parentNode(); }188 182 189 183 // FIXME: It could be better to call m_ruleSets.appendAuthorStyleSheets() directly after we factor StyleRsolver further. … … 211 205 } 212 206 #endif 207 class State; 213 208 214 209 private: 215 void initElement( Element*);216 RenderStyle* locateSharedStyle( );217 bool styleSharingCandidateMatchesRuleSet( RuleSet*);218 bool styleSharingCandidateMatchesHostRules( );210 void initElement(State&, Element*); 211 RenderStyle* locateSharedStyle(State&); 212 bool styleSharingCandidateMatchesRuleSet(Element*, RuleSet*); 213 bool styleSharingCandidateMatchesHostRules(State&); 219 214 Node* locateCousinList(Element* parent, unsigned& visitedNodeCount) const; 220 StyledElement* findSiblingForStyleSharing( Node*, unsigned& count) const;221 bool canShareStyleWithElement( StyledElement*) const;222 223 PassRefPtr<RenderStyle> styleForKeyframe( const RenderStyle*, const StyleKeyframe*, KeyframeValue&);215 StyledElement* findSiblingForStyleSharing(const State&, Node*, unsigned& count) const; 216 bool canShareStyleWithElement(const State&, StyledElement*) const; 217 218 PassRefPtr<RenderStyle> styleForKeyframe(State&, const RenderStyle*, const StyleKeyframe*, KeyframeValue&); 224 219 225 220 public: … … 244 239 245 240 public: 246 void applyPropertyToStyle(CSSPropertyID, CSSValue*, RenderStyle*); 247 248 void applyPropertyToCurrentStyle(CSSPropertyID, CSSValue*); 249 250 void updateFont(); 251 void initializeFontStyle(Settings*); 241 void applyFontPropertyToStyle(RenderStyle*, const StylePropertySet*); 242 243 void updateFont(State&); 244 void initializeFontStyle(State&, Settings*); 252 245 253 246 static float getComputedSizeFromSpecifiedSize(Document*, float zoomFactor, bool isAbsoluteSize, float specifiedSize, ESmartMinimumForFontSize = UseSmartMinimumForFontFize); 254 247 255 void setFontSize(FontDescription&, float size);248 static void setFontSize(State&, FontDescription&, float size); 256 249 257 250 private: … … 259 252 260 253 public: 261 bool useSVGZoomRules();262 263 254 static bool colorFromPrimitiveValueIsDerivedFromElement(CSSPrimitiveValue*); 264 Color colorFromPrimitiveValue(CSSPrimitiveValue*, bool forVisitedLink = false) const;255 static Color colorFromPrimitiveValue(const State&, CSSPrimitiveValue*, bool forVisitedLink = false); 265 256 266 257 bool hasSelectorForId(const AtomicString&) const; … … 290 281 291 282 #if ENABLE(CSS_FILTERS) 292 bool createFilterOperations( CSSValue* inValue, RenderStyle* inStyle, RenderStyle* rootStyle, FilterOperations& outOperations);283 bool createFilterOperations(State&, CSSValue* inValue, RenderStyle* inStyle, RenderStyle* rootStyle, FilterOperations& outOperations); 293 284 #if ENABLE(CSS_SHADERS) 294 StyleShader* styleShader( CSSValue*);295 StyleShader* cachedOrPendingStyleShaderFromValue( WebKitCSSShaderValue*);296 bool parseCustomFilterParameterList( CSSValue*, CustomFilterParameterList&);297 PassRefPtr<CustomFilterParameter> parseCustomFilterParameter( const String& name, CSSValue*);285 StyleShader* styleShader(State&, CSSValue*); 286 StyleShader* cachedOrPendingStyleShaderFromValue(State&, WebKitCSSShaderValue*); 287 bool parseCustomFilterParameterList(State&, CSSValue*, CustomFilterParameterList&); 288 PassRefPtr<CustomFilterParameter> parseCustomFilterParameter(State&, const String& name, CSSValue*); 298 289 PassRefPtr<CustomFilterParameter> parseCustomFilterArrayParameter(const String& name, CSSValueList*); 299 290 PassRefPtr<CustomFilterParameter> parseCustomFilterNumberParameter(const String& name, CSSValueList*); 300 PassRefPtr<CustomFilterParameter> parseCustomFilterTransformParameter( const String& name, CSSValueList*);291 PassRefPtr<CustomFilterParameter> parseCustomFilterTransformParameter(State&, const String& name, CSSValueList*); 301 292 PassRefPtr<CustomFilterOperation> createCustomFilterOperationWithAtRuleReferenceSyntax(WebKitCSSFilterValue*); 302 PassRefPtr<CustomFilterOperation> createCustomFilterOperationWithInlineSyntax( WebKitCSSFilterValue*);303 PassRefPtr<CustomFilterOperation> createCustomFilterOperation( WebKitCSSFilterValue*);304 void loadPendingShaders( );293 PassRefPtr<CustomFilterOperation> createCustomFilterOperationWithInlineSyntax(State&, WebKitCSSFilterValue*); 294 PassRefPtr<CustomFilterOperation> createCustomFilterOperation(State&, WebKitCSSFilterValue*); 295 void loadPendingShaders(State&); 305 296 #endif 306 297 #if ENABLE(SVG) 307 void loadPendingSVGDocuments( );298 void loadPendingSVGDocuments(State&); 308 299 #endif 309 300 #endif // ENABLE(CSS_FILTERS) 310 301 311 void loadPendingResources( );302 void loadPendingResources(State&); 312 303 313 304 private: 314 305 // This function fixes up the default font size if it detects that the current generic font family has changed. -dwh 315 void checkForGenericFamilyChange( RenderStyle*, RenderStyle* parentStyle);316 void checkForZoomChange( RenderStyle*, RenderStyle* parentStyle);317 void checkForTextSizeAdjust( );318 319 void adjustRenderStyle( RenderStyle* styleToAdjust, RenderStyle* parentStyle, Element*);306 void checkForGenericFamilyChange(State&, RenderStyle*, RenderStyle* parentStyle); 307 void checkForZoomChange(State&, RenderStyle*, RenderStyle* parentStyle); 308 void checkForTextSizeAdjust(State&); 309 310 void adjustRenderStyle(State&, RenderStyle* styleToAdjust, RenderStyle* parentStyle, Element*); 320 311 321 312 struct RuleRange { … … 364 355 void addElementStyleProperties(MatchResult&, const StylePropertySet*, bool isCacheable = true); 365 356 366 void matchAllRules( MatchResult&, bool includeSMILProperties);367 void matchUARules( MatchResult&);368 void matchUARules( MatchResult&, RuleSet*);369 void matchAuthorRules( MatchResult&, bool includeEmptyRules);370 void matchUserRules( MatchResult&, bool includeEmptyRules);371 void matchScopedAuthorRules( MatchResult&, bool includeEmptyRules);372 void matchHostRules( MatchResult&, bool includeEmptyRules);373 374 void collectMatchingRules( const MatchRequest&, RuleRange&);375 void collectMatchingRulesForRegion( const MatchRequest&, RuleRange&);376 void collectMatchingRulesForList( const Vector<RuleData>*, const MatchRequest&, RuleRange&);357 void matchAllRules(State&, MatchResult&, bool includeSMILProperties); 358 void matchUARules(State&, MatchResult&); 359 void matchUARules(State&, MatchResult&, RuleSet*); 360 void matchAuthorRules(State&, MatchResult&, bool includeEmptyRules); 361 void matchUserRules(State&, MatchResult&, bool includeEmptyRules); 362 void matchScopedAuthorRules(State&, MatchResult&, bool includeEmptyRules); 363 void matchHostRules(State&, MatchResult&, bool includeEmptyRules); 364 365 void collectMatchingRules(State&, const MatchRequest&, RuleRange&); 366 void collectMatchingRulesForRegion(State&, const MatchRequest&, RuleRange&); 367 void collectMatchingRulesForList(State&, const Vector<RuleData>*, const MatchRequest&, RuleRange&); 377 368 378 369 bool fastRejectSelector(const RuleData&) const; 379 void sortMatchedRules( );380 void sortAndTransferMatchedRules( MatchResult&);381 382 bool ruleMatches( const RuleData&, const ContainerNode* scope, PseudoId&, SelectorChecker::BehaviorAtBoundary = SelectorChecker::DoesNotCrossBoundary);370 void sortMatchedRules(State&); 371 void sortAndTransferMatchedRules(State&, MatchResult&); 372 373 bool ruleMatches(State&, const RuleData&, const ContainerNode* scope, PseudoId&, SelectorChecker::BehaviorAtBoundary = SelectorChecker::DoesNotCrossBoundary); 383 374 bool checkRegionSelector(const CSSSelector* regionSelector, Element* regionElement); 384 void applyMatchedProperties( const MatchResult&, const Element*);375 void applyMatchedProperties(State&, const MatchResult&, const Element*); 385 376 enum StyleApplicationPass { 386 377 #if ENABLE(CSS_VARIABLES) … … 391 382 }; 392 383 template <StyleApplicationPass pass> 393 void applyMatchedProperties( const MatchResult&, bool important, int startIndex, int endIndex, bool inheritedOnly);384 void applyMatchedProperties(State&, const MatchResult&, bool important, int startIndex, int endIndex, bool inheritedOnly); 394 385 template <StyleApplicationPass pass> 395 void applyProperties( const StylePropertySet* properties, StyleRule*, bool isImportant, bool inheritedOnly, PropertyWhitelistType = PropertyWhitelistNone);386 void applyProperties(State&, const StylePropertySet* properties, StyleRule*, bool isImportant, bool inheritedOnly, PropertyWhitelistType = PropertyWhitelistNone); 396 387 #if ENABLE(CSS_VARIABLES) 397 void resolveVariables( CSSPropertyID, CSSValue*, Vector<std::pair<CSSPropertyID, String> >& knownExpressions);388 void resolveVariables(State&, CSSPropertyID, CSSValue*, Vector<std::pair<CSSPropertyID, String> >& knownExpressions); 398 389 #endif 399 390 static bool isValidRegionStyleProperty(CSSPropertyID); … … 405 396 Settings* documentSettings() { return m_document->settings(); } 406 397 407 bool isLeftPage( int pageIndex) const;408 bool isRightPage( int pageIndex) const { return !isLeftPage(pageIndex); }398 bool isLeftPage(State&, int pageIndex) const; 399 bool isRightPage(State& state, int pageIndex) const { return !isLeftPage(state, pageIndex); } 409 400 bool isFirstPage(int pageIndex) const; 410 401 String pageName(int pageIndex) const; … … 416 407 417 408 public: 409 418 410 typedef HashMap<CSSPropertyID, RefPtr<CSSValue> > PendingImagePropertyMap; 419 411 #if ENABLE(CSS_FILTERS) && ENABLE(SVG) 420 412 typedef HashMap<FilterOperation*, RefPtr<WebKitCSSSVGDocumentValue> > PendingSVGDocumentMap; 421 413 #endif 422 423 414 class State { 424 415 WTF_MAKE_NONCOPYABLE(State); 425 416 public: 426 State() 427 : m_element(0) 417 State(Document* document) 418 : m_document(document) 419 , m_element(0) 428 420 , m_styledElement(0) 429 421 , m_parentNode(0) … … 452 444 void clear(); 453 445 454 Document* document() const { return m_ element->document(); }446 Document* document() const { return m_document; } 455 447 Element* element() const { return m_element; } 456 448 StyledElement* styledElement() const { return m_styledElement; } … … 513 505 Vector<const RuleData*, 32>& matchedRules() { return m_matchedRules; } 514 506 void addMatchedRule(const RuleData* rule) { m_matchedRules.append(rule); } 507 bool useSVGZoomRules() const { return m_element && m_element->isSVGElement(); } 515 508 516 509 private: 517 // FIXME(bug 108563): to make it easier to review, these member 518 // variables are public. However we should add methods to access 519 // these variables. 510 Document* m_document; 520 511 Element* m_element; 521 512 RefPtr<RenderStyle> m_style; … … 563 554 static RenderStyle* styleNotYetAvailable() { return s_styleNotYetAvailable; } 564 555 565 PassRefPtr<StyleImage> styleImage(CSSPropertyID, CSSValue*);566 PassRefPtr<StyleImage> cachedOrPendingFromValue(CSSPropertyID, CSSImageValue*);567 PassRefPtr<StyleImage> generatedOrPendingFromValue(CSSPropertyID, CSSImageGeneratorValue*);556 static PassRefPtr<StyleImage> styleImage(State&, CSSPropertyID, CSSValue*); 557 static PassRefPtr<StyleImage> cachedOrPendingFromValue(State&, CSSPropertyID, CSSImageValue*); 558 static PassRefPtr<StyleImage> generatedOrPendingFromValue(State&, CSSPropertyID, CSSImageGeneratorValue*); 568 559 #if ENABLE(CSS_IMAGE_SET) 569 PassRefPtr<StyleImage> setOrPendingFromValue(CSSPropertyID, CSSImageSetValue*); 570 #endif 571 PassRefPtr<StyleImage> cursorOrPendingFromValue(CSSPropertyID, CSSCursorImageValue*); 572 573 bool applyPropertyToRegularStyle() const { return m_state.applyPropertyToRegularStyle(); } 574 bool applyPropertyToVisitedLinkStyle() const { return m_state.applyPropertyToVisitedLinkStyle(); } 560 static PassRefPtr<StyleImage> setOrPendingFromValue(State&, CSSPropertyID, CSSImageSetValue*); 561 #endif 562 static PassRefPtr<StyleImage> cursorOrPendingFromValue(State&, CSSPropertyID, CSSCursorImageValue*); 575 563 576 564 static Length convertToIntLength(CSSPrimitiveValue*, RenderStyle*, RenderStyle* rootStyle, double multiplier = 1); 577 565 static Length convertToFloatLength(CSSPrimitiveValue*, RenderStyle*, RenderStyle* rootStyle, double multiplier = 1); 578 566 579 CSSToStyleMap* styleMap() { return &m_styleMap; }580 567 InspectorCSSOMWrappers& inspectorCSSOMWrappers() { return m_inspectorCSSOMWrappers; } 581 const FontDescription& fontDescription() { return m_state.fontDescription(); }582 const FontDescription& parentFontDescription() { return m_state.parentFontDescription(); }583 void setFontDescription(const FontDescription& fontDescription) { m_state.setFontDescription(fontDescription); }584 void setZoom(float f) { m_state.setZoom(f); }585 void setEffectiveZoom(float f) { m_state.setEffectiveZoom(f); }586 void setTextSizeAdjust(bool b) { m_state.setTextSizeAdjust(b); }587 void setWritingMode(WritingMode writingMode) { m_state.setWritingMode(writingMode); }588 void setTextOrientation(TextOrientation textOrientation) { m_state.setTextOrientation(textOrientation); }589 568 590 569 void reportMemoryUsage(MemoryObjectInfo*) const; … … 596 575 597 576 private: 598 bool canShareStyleWithControl(StyledElement*) const; 599 600 void applyProperty(CSSPropertyID, CSSValue*); 577 bool canShareStyleWithControl(const State&, StyledElement*) const; 578 579 void applyPropertyWithNullCheck(State&, CSSPropertyID, CSSValue*); 580 void applyProperty(State&, CSSPropertyID, CSSValue*); 601 581 602 582 #if ENABLE(SVG) 603 void applySVGProperty( CSSPropertyID, CSSValue*);604 #endif 605 606 PassRefPtr<StyleImage> loadPendingImage(St ylePendingImage*);607 void loadPendingImages( );583 void applySVGProperty(const State&, CSSPropertyID, CSSValue*); 584 #endif 585 586 PassRefPtr<StyleImage> loadPendingImage(State&, StylePendingImage*); 587 void loadPendingImages(State&); 608 588 609 589 static unsigned computeMatchedPropertiesHash(const MatchedProperties*, unsigned size); … … 623 603 624 604 bool classNamesAffectedByRules(const SpaceSplitString&) const; 625 bool sharingCandidateHasIdenticalStyleAffectingAttributes( StyledElement*) const;605 bool sharingCandidateHasIdenticalStyleAffectingAttributes(const State&, StyledElement*) const; 626 606 627 607 unsigned m_matchedPropertiesCacheAdditionsSinceLastSweep; … … 650 630 651 631 OwnPtr<StyleScopeResolver> m_scopeResolver; 652 CSSToStyleMap m_styleMap;653 632 InspectorCSSOMWrappers m_inspectorCSSOMWrappers; 654 655 State m_state;656 633 657 634 friend class StyleBuilder; -
trunk/Source/WebCore/html/canvas/CanvasRenderingContext2D.cpp
r143232 r143556 2065 2065 // Now map the font property longhands into the style. 2066 2066 StyleResolver* styleResolver = canvas()->styleResolver(); 2067 styleResolver->applyPropertyToStyle(CSSPropertyFontFamily, parsedStyle->getPropertyCSSValue(CSSPropertyFontFamily).get(), newStyle.get()); 2068 styleResolver->applyPropertyToCurrentStyle(CSSPropertyFontStyle, parsedStyle->getPropertyCSSValue(CSSPropertyFontStyle).get()); 2069 styleResolver->applyPropertyToCurrentStyle(CSSPropertyFontVariant, parsedStyle->getPropertyCSSValue(CSSPropertyFontVariant).get()); 2070 styleResolver->applyPropertyToCurrentStyle(CSSPropertyFontWeight, parsedStyle->getPropertyCSSValue(CSSPropertyFontWeight).get()); 2071 2072 // As described in BUG66291, setting font-size and line-height on a font may entail a CSSPrimitiveValue::computeLengthDouble call, 2073 // which assumes the fontMetrics are available for the affected font, otherwise a crash occurs (see http://trac.webkit.org/changeset/96122). 2074 // The updateFont() calls below update the fontMetrics and ensure the proper setting of font-size and line-height. 2075 styleResolver->updateFont(); 2076 styleResolver->applyPropertyToCurrentStyle(CSSPropertyFontSize, parsedStyle->getPropertyCSSValue(CSSPropertyFontSize).get()); 2077 styleResolver->updateFont(); 2078 styleResolver->applyPropertyToCurrentStyle(CSSPropertyLineHeight, parsedStyle->getPropertyCSSValue(CSSPropertyLineHeight).get()); 2067 styleResolver->applyFontPropertyToStyle(newStyle.get(), parsedStyle.get()); 2079 2068 2080 2069 modifiableState().m_font = newStyle->font();
Note: See TracChangeset
for help on using the changeset viewer.