WebKit Bugzilla
New
Browse
Search+
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
[patch]
WIP
bug-96421-20130125181353.patch (text/plain), 348.87 KB, created by
Takashi Sakamoto
on 2013-01-25 01:17:02 PST
(
hide
)
Description:
WIP
Filename:
MIME Type:
Creator:
Takashi Sakamoto
Created:
2013-01-25 01:17:02 PST
Size:
348.87 KB
patch
obsolete
>Subversion Revision: 140791 >diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog >index 34ae632f72b785de2ce018b3a499cbda01f3a298..6cef9adb65e32b39b4d333d16d34a857f706b79b 100644 >--- a/Source/WebCore/ChangeLog >+++ b/Source/WebCore/ChangeLog >@@ -1,3 +1,307 @@ >+2013-01-24 Takashi Sakamoto <tasak@google.com> >+ >+ Split per-resolve logic out from StyleResolver. >+ https://bugs.webkit.org/show_bug.cgi?id=96421 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ Implemented class StyleResolveState and moved all member variables >+ used only for per-resolve logic. >+ This is the first step to enable StyleResolver to resolve styles of >+ multiple elements in parallel. >+ >+ No new tests, because just refactoring. >+ >+ * GNUmakefile.list.am: >+ * Target.pri: >+ * WebCore.gypi: >+ Added StyleResolveState.h. >+ * css/BasicShapeFunctions.cpp: >+ (WebCore::convertToLength): >+ (WebCore::basicShapeForValue): >+ * css/BasicShapeFunctions.h: >+ (WebCore): >+ * css/CSSGradientValue.cpp: >+ (WebCore::CSSGradientValue::gradientWithStylesResolved): >+ * css/CSSGradientValue.h: >+ (WebCore): >+ (CSSGradientValue): >+ * css/CSSToStyleMap.cpp: >+ (WebCore::CSSToStyleMap::mapFillAttachment): >+ (WebCore::CSSToStyleMap::mapFillClip): >+ (WebCore::CSSToStyleMap::mapFillComposite): >+ (WebCore::CSSToStyleMap::mapFillOrigin): >+ (WebCore::CSSToStyleMap::mapFillImage): >+ (WebCore::CSSToStyleMap::mapFillRepeatX): >+ (WebCore::CSSToStyleMap::mapFillRepeatY): >+ (WebCore::CSSToStyleMap::mapFillSize): >+ (WebCore::CSSToStyleMap::mapFillXPosition): >+ (WebCore::CSSToStyleMap::mapFillYPosition): >+ (WebCore::CSSToStyleMap::mapNinePieceImage): >+ (WebCore::CSSToStyleMap::mapNinePieceImageSlice): >+ (WebCore::CSSToStyleMap::mapNinePieceImageQuad): >+ (WebCore::CSSToStyleMap::mapNinePieceImageRepeat): >+ * css/CSSToStyleMap.h: >+ (WebCore): >+ (CSSToStyleMap): >+ (WebCore::CSSToStyleMap::CSSToStyleMap): >+ * css/SVGCSSStyleSelector.cpp: >+ (WebCore::StyleResolver::applySVGProperty): >+ * css/SelectorChecker.cpp: >+ (WebCore): >+ (WebCore::SelectorChecker::isFastCheckableSelector): >+ (WebCore::SelectorChecker::matches): >+ (WebCore::SelectorChecker::fastCheck): >+ * css/SelectorChecker.h: >+ (SelectorChecker): >+ (WebCore::isFrameFocused): >+ (WebCore): >+ (WebCore::matchesFocusPseudoClass): >+ * css/StyleBuilder.cpp: >+ (WebCore::ApplyPropertyExpanding::applyInheritValue): >+ (WebCore::ApplyPropertyExpanding::applyInitialValue): >+ (WebCore::ApplyPropertyExpanding::applyValue): >+ (WebCore::ApplyPropertyDefaultBase::applyInheritValue): >+ (WebCore::ApplyPropertyDefaultBase::applyInitialValue): >+ (WebCore::ApplyPropertyDefaultBase::applyValue): >+ (WebCore::ApplyPropertyDefault::applyValue): >+ (WebCore::ApplyPropertyNumber::applyValue): >+ (WebCore::ApplyPropertyStyleImage::applyValue): >+ (WebCore::ApplyPropertyAuto::applyInheritValue): >+ (WebCore::ApplyPropertyAuto::applyInitialValue): >+ (WebCore::ApplyPropertyAuto::applyValue): >+ (WebCore::ApplyPropertyClip::convertToLength): >+ (WebCore::ApplyPropertyClip::applyInheritValue): >+ (WebCore::ApplyPropertyClip::applyInitialValue): >+ (WebCore::ApplyPropertyClip::applyValue): >+ (WebCore::ApplyPropertyColor::applyInheritValue): >+ (WebCore::ApplyPropertyColor::applyInitialValue): >+ (WebCore::ApplyPropertyColor::applyValue): >+ (WebCore::ApplyPropertyColor::applyColorValue): >+ (WebCore::ApplyPropertyDirection::applyValue): >+ (WebCore::ApplyPropertyLength::applyValue): >+ (WebCore::ApplyPropertyString::applyValue): >+ (WebCore::ApplyPropertyBorderRadius::applyValue): >+ (WebCore::ApplyPropertyFillLayer::applyInheritValue): >+ (WebCore::ApplyPropertyFillLayer::applyInitialValue): >+ (WebCore::ApplyPropertyFillLayer::applyValue): >+ (WebCore::ApplyPropertyComputeLength::applyValue): >+ (WebCore::ApplyPropertyFont::applyInheritValue): >+ (WebCore::ApplyPropertyFont::applyInitialValue): >+ (WebCore::ApplyPropertyFont::applyValue): >+ (WebCore::ApplyPropertyFontSize::applyInheritValue): >+ (WebCore::ApplyPropertyFontSize::applyInitialValue): >+ (WebCore::ApplyPropertyFontSize::applyValue): >+ (WebCore::ApplyPropertyFontWeight::applyValue): >+ (WebCore::ApplyPropertyFontVariantLigatures::applyInheritValue): >+ (WebCore::ApplyPropertyFontVariantLigatures::applyInitialValue): >+ (WebCore::ApplyPropertyFontVariantLigatures::applyValue): >+ (WebCore::ApplyPropertyBorderImage::applyValue): >+ (WebCore::ApplyPropertyBorderImageModifier::applyInheritValue): >+ (WebCore::ApplyPropertyBorderImageModifier::applyInitialValue): >+ (WebCore::ApplyPropertyBorderImageModifier::applyValue): >+ (WebCore::ApplyPropertyBorderImageSource::applyValue): >+ (WebCore::ApplyPropertyCounter::emptyFunction): >+ (WebCore::ApplyPropertyCounter::applyInheritValue): >+ (WebCore::ApplyPropertyCounter::applyValue): >+ (WebCore::ApplyPropertyCursor::applyInheritValue): >+ (WebCore::ApplyPropertyCursor::applyInitialValue): >+ (WebCore::ApplyPropertyCursor::applyValue): >+ (WebCore::ApplyPropertyTextAlign::applyValue): >+ (WebCore::ApplyPropertyTextDecoration::applyValue): >+ (WebCore::ApplyPropertyLineHeight::applyValue): >+ (WebCore::ApplyPropertyPageSize::applyInheritValue): >+ (WebCore::ApplyPropertyPageSize::applyInitialValue): >+ (WebCore::ApplyPropertyPageSize::applyValue): >+ (WebCore::ApplyPropertyTextEmphasisStyle::applyInheritValue): >+ (WebCore::ApplyPropertyTextEmphasisStyle::applyInitialValue): >+ (WebCore::ApplyPropertyTextEmphasisStyle::applyValue): >+ (WebCore): >+ (WebCore::ApplyPropertyAnimation::map): >+ (WebCore::ApplyPropertyAnimation::applyInheritValue): >+ (WebCore::ApplyPropertyAnimation::applyInitialValue): >+ (WebCore::ApplyPropertyAnimation::applyValue): >+ (WebCore::ApplyPropertyOutlineStyle::applyInheritValue): >+ (WebCore::ApplyPropertyOutlineStyle::applyInitialValue): >+ (WebCore::ApplyPropertyOutlineStyle::applyValue): >+ (WebCore::ApplyPropertyResize::applyValue): >+ (WebCore::ApplyPropertyVerticalAlign::applyValue): >+ (WebCore::ApplyPropertyAspectRatio::applyInheritValue): >+ (WebCore::ApplyPropertyAspectRatio::applyInitialValue): >+ (WebCore::ApplyPropertyAspectRatio::applyValue): >+ (WebCore::ApplyPropertyZoom::resetEffectiveZoom): >+ (WebCore::ApplyPropertyZoom::applyInheritValue): >+ (WebCore::ApplyPropertyZoom::applyInitialValue): >+ (WebCore::ApplyPropertyZoom::applyValue): >+ (WebCore::ApplyPropertyDisplay::isValidDisplayValue): >+ (WebCore::ApplyPropertyDisplay::applyInheritValue): >+ (WebCore::ApplyPropertyDisplay::applyInitialValue): >+ (WebCore::ApplyPropertyDisplay::applyValue): >+ (WebCore::ApplyPropertyClipPath::applyValue): >+ (WebCore::ApplyPropertyExclusionShape::applyValue): >+ (WebCore::ApplyPropertyImageResolution::applyInheritValue): >+ (WebCore::ApplyPropertyImageResolution::applyInitialValue): >+ (WebCore::ApplyPropertyImageResolution::applyValue): >+ * css/StyleBuilder.h: >+ (WebCore): >+ (PropertyHandler): >+ (WebCore::PropertyHandler::applyInheritValue): >+ (WebCore::PropertyHandler::applyInitialValue): >+ (WebCore::PropertyHandler::applyValue): >+ * css/StyleResolveState.h: Added. >+ (WebCore): >+ (StyleResolveState): >+ (WebCore::StyleResolveState::StyleResolveState): >+ (WebCore::StyleResolveState::style): >+ (WebCore::StyleResolveState::parentStyle): >+ (WebCore::StyleResolveState::rootElementStyle): >+ (WebCore::StyleResolveState::element): >+ (WebCore::StyleResolveState::styledElement): >+ (WebCore::StyleResolveState::document): >+ (WebCore::StyleResolveState::regionForStyling): >+ (WebCore::StyleResolveState::mode): >+ Moved StyleResolver's mode from m_selectorChecker to StyleResolveState. >+ So we don't need to keep SelectorChecker as a member variable of >+ StyleResolver. >+ (WebCore::StyleResolveState::pseudoStyle): >+ (WebCore::StyleResolveState::parentNode): >+ (WebCore::StyleResolveState::elementLinkState): >+ (WebCore::StyleResolveState::distributedToInsertionPoint): >+ (WebCore::StyleResolveState::setCanUseFastReject): >+ (WebCore::StyleResolveState::canUseFastReject): >+ (WebCore::StyleResolveState::setStyle): >+ (WebCore::StyleResolveState::setRootElementStyle): >+ (WebCore::StyleResolveState::setElement): >+ (WebCore::StyleResolveState::setElementLinkState): >+ (WebCore::StyleResolveState::setParentNode): >+ (WebCore::StyleResolveState::setParentStyle): >+ (WebCore::StyleResolveState::setDistributedToInsertionPoint): >+ (WebCore::StyleResolveState::setMode): >+ (WebCore::StyleResolveState::setRegionForStyling): >+ (WebCore::StyleResolveState::setPseudoStyle): >+ (WebCore::StyleResolveState::fontDescription): >+ (WebCore::StyleResolveState::parentFontDescription): >+ (WebCore::StyleResolveState::setFontDescription): >+ (WebCore::StyleResolveState::setZoom): >+ (WebCore::StyleResolveState::setEffectiveZoom): >+ (WebCore::StyleResolveState::setTextSizeAdjust): >+ (WebCore::StyleResolveState::setWritingMode): >+ (WebCore::StyleResolveState::setTextOrientation): >+ (WebCore::StyleResolveState::setApplyPropertyToRegularStyle): >+ (WebCore::StyleResolveState::setApplyPropertyToVisitedLinkStyle): >+ (WebCore::StyleResolveState::applyPropertyToRegularStyle): >+ (WebCore::StyleResolveState::applyPropertyToVisitedLinkStyle): >+ (WebCore::StyleResolveState::matchedRules): >+ (WebCore::StyleResolveState::setElementAffectedByClassRules): >+ (WebCore::StyleResolveState::elementAffectedByClassRules): >+ (WebCore::StyleResolveState::cacheBorderAndBackground): >+ (WebCore::StyleResolveState::pendingImageProperties): >+ (WebCore::StyleResolveState::pendingSVGDocuments): >+ (WebCore::StyleResolveState::setLineHeightValue): >+ (WebCore::StyleResolveState::lineHeightValue): >+ (WebCore::StyleResolveState::hasParentNode): >+ (WebCore::StyleResolveState::setFontDirty): >+ (WebCore::StyleResolveState::fontDirty): >+ (WebCore::StyleResolveState::ensureRuleList): >+ (WebCore::StyleResolveState::ruleList): >+ (WebCore::StyleResolveState::setHasPendingShaders): >+ (WebCore::StyleResolveState::hasPendingShaders): >+ (WebCore::StyleResolveState::useSVGZoomRules): >+ (WebCore::StyleResolveState::hasUAAppearance): >+ (WebCore::StyleResolveState::borderData): >+ (WebCore::StyleResolveState::backgroundData): >+ (WebCore::StyleResolveState::backgroundColor): >+ (WebCore::StyleResolveState::setIncludeEmptyRules): >+ (WebCore::StyleResolveState::setSameOriginOnly): >+ (WebCore::StyleResolveState::includeEmptyRules): >+ (WebCore::StyleResolveState::sameOriginOnly): >+ * css/StyleResolver.cpp: >+ (WebCore): >+ (WebCore::StyleResolver::StyleResolver): >+ Since StyleResolveState provides all information, no need to have >+ any instance of CSSToStyleMap and no need to make SelectorChecker >+ a member variable of StyleResolver. >+ (WebCore::StyleResolver::collectMatchingRules): >+ (WebCore::StyleResolver::collectMatchingRulesForRegion): >+ (WebCore::StyleResolver::sortAndTransferMatchedRules): >+ (WebCore::StyleResolver::matchScopedAuthorRules): >+ (WebCore::StyleResolver::styleSharingCandidateMatchesHostRules): >+ (WebCore::StyleResolver::matchHostRules): >+ (WebCore::StyleResolver::matchAuthorRules): >+ (WebCore::StyleResolver::matchUserRules): >+ (WebCore::StyleResolver::matchUARules): >+ (WebCore::StyleResolver::collectMatchingRulesForList): >+ (WebCore::StyleResolver::sortMatchedRules): >+ (WebCore::StyleResolver::matchAllRules): >+ (WebCore::StyleResolver::initElement): >+ (WebCore::StyleResolver::initForStyleResolve): >+ (WebCore::StyleResolver::styleSharingCandidateMatchesRuleSet): >+ (WebCore::StyleResolver::canShareStyleWithControl): >+ (WebCore::StyleResolver::sharingCandidateHasIdenticalStyleAffectingAttributes): >+ (WebCore::StyleResolver::canShareStyleWithElement): >+ (WebCore::StyleResolver::findSiblingForStyleSharing): >+ (WebCore::StyleResolver::locateSharedStyle): >+ (WebCore::StyleResolver::styleForElement): >+ (WebCore::StyleResolver::styleForKeyframe): >+ (WebCore::StyleResolver::keyframeStylesForAnimation): >+ (WebCore::StyleResolver::pseudoStyleForElement): >+ (WebCore::StyleResolver::styleForPage): >+ (WebCore::StyleResolver::defaultStyleForElement): >+ (WebCore::StyleResolver::adjustRenderStyle): >+ (WebCore::StyleResolver::updateFont): >+ (WebCore::StyleResolver::pseudoStyleRulesForElement): >+ (WebCore::StyleResolver::ruleMatches): >+ m_dynamicPseudo is used between this ruleMatches and >+ collectMatchingRulesForList. So added one parameter to return >+ what dynamic pseudo an element matches. Removed m_dynamicPseudo >+ from StyleResolver. >+ (WebCore::StyleResolver::checkRegionSelector): >+ (WebCore::StyleResolver::applyProperties): >+ (WebCore::StyleResolver::applyMatchedProperties): >+ (WebCore::StyleResolver::isLeftPage): >+ (WebCore::StyleResolver::applyPropertyWithValueChecking): >+ (WebCore::StyleResolver::applyFontPropertyToStyle): >+ (WebCore::createGridTrackBreadth): >+ (WebCore::createGridTrackMinMax): >+ (WebCore::createGridTrackGroup): >+ (WebCore::createGridTrackList): >+ (WebCore::StyleResolver::resolveVariables): >+ (WebCore::StyleResolver::applyProperty): >+ (WebCore::StyleResolver::styleImage): >+ (WebCore::StyleResolver::cachedOrPendingFromValue): >+ (WebCore::StyleResolver::generatedOrPendingFromValue): >+ (WebCore::StyleResolver::setOrPendingFromValue): >+ (WebCore::StyleResolver::cursorOrPendingFromValue): >+ (WebCore::StyleResolver::checkForTextSizeAdjust): >+ (WebCore::StyleResolver::checkForZoomChange): >+ (WebCore::StyleResolver::checkForGenericFamilyChange): >+ (WebCore::StyleResolver::initializeFontStyle): >+ (WebCore::StyleResolver::setFontSize): >+ (WebCore::StyleResolver::colorFromPrimitiveValue): >+ (WebCore::StyleResolver::loadPendingSVGDocuments): >+ (WebCore::StyleResolver::styleShader): >+ (WebCore::StyleResolver::cachedOrPendingStyleShaderFromValue): >+ (WebCore::StyleResolver::loadPendingShaders): >+ (WebCore::StyleResolver::parseCustomFilterTransformParameter): >+ (WebCore::StyleResolver::parseCustomFilterParameter): >+ (WebCore::StyleResolver::parseCustomFilterParameterList): >+ (WebCore::StyleResolver::createCustomFilterOperation): >+ (WebCore::StyleResolver::createFilterOperations): >+ (WebCore::StyleResolver::loadPendingImage): >+ (WebCore::StyleResolver::loadPendingImages): >+ (WebCore::StyleResolver::loadPendingResources): >+ (WebCore::StyleResolver::reportMemoryUsage): >+ * css/StyleResolver.h: >+ (StyleResolver): >+ (WebCore::StyleResolver::addMatchedRule): >+ (WebCore::StyleResolver::isRightPage): >+ * dom/StyledElement.h: >+ (WebCore::toStyledElement): >+ (WebCore): >+ * html/canvas/CanvasRenderingContext2D.cpp: >+ (WebCore::CanvasRenderingContext2D::setFont): >+ * rendering/style/RenderStyle.h: >+ > 2013-01-24 Kent Tamura <tkent@chromium.org> > > INPUT_MULTIPLE_FIELDS_UI: Refactoring: Remove confusing minimum() and maximum() of DateTimeSymbolicFieldElement >diff --git a/Source/WebCore/GNUmakefile.list.am b/Source/WebCore/GNUmakefile.list.am >index d7521d4b3d1312d1a255630f42884dcf18eaac3d..18dcd2820eed85dc0771da5b58e7bbe0bdb25cd6 100644 >--- a/Source/WebCore/GNUmakefile.list.am >+++ b/Source/WebCore/GNUmakefile.list.am >@@ -2660,6 +2660,7 @@ webcore_sources += \ > Source/WebCore/css/StylePropertySet.h \ > Source/WebCore/css/StylePropertyShorthand.cpp \ > Source/WebCore/css/StylePropertyShorthand.h \ >+ Source/WebCore/css/StyleResolveState.h \ > Source/WebCore/css/StyleResolver.cpp \ > Source/WebCore/css/StyleResolver.h \ > Source/WebCore/css/StyleRule.cpp \ >diff --git a/Source/WebCore/Target.pri b/Source/WebCore/Target.pri >index 2998c9d514d7d52b1c9badbcec976c5ea33b3446..7ec39f38d996f8360e4b487895d27b5e94cfb6cc 100644 >--- a/Source/WebCore/Target.pri >+++ b/Source/WebCore/Target.pri >@@ -1531,6 +1531,7 @@ HEADERS += \ > css/StyleInvalidationAnalysis.h \ > css/StylePropertySet.h \ > css/StylePropertyShorthand.h \ >+ css/StyleResolveState.h \ > css/StyleResolver.h \ > css/StyleRule.h \ > css/StyleRuleImport.h \ >diff --git a/Source/WebCore/WebCore.gypi b/Source/WebCore/WebCore.gypi >index 4d586812c19a7888a7032c7675711a730484be98..8efaf152a8539eea997257900510c0451374ad98 100644 >--- a/Source/WebCore/WebCore.gypi >+++ b/Source/WebCore/WebCore.gypi >@@ -1583,6 +1583,7 @@ > 'css/StylePropertySet.h', > 'css/StylePropertyShorthand.cpp', > 'css/StylePropertyShorthand.h', >+ 'css/StyleResolveState.h', > 'css/StyleResolver.cpp', > 'css/StyleResolver.h', > 'css/StyleRule.cpp', >diff --git a/Source/WebCore/css/BasicShapeFunctions.cpp b/Source/WebCore/css/BasicShapeFunctions.cpp >index 3a8f7953b6f96b012f843237a2e12a0fdf4cb121..1b35999ee193d6441e89cbb0944df681f58ef6f8 100644 >--- a/Source/WebCore/css/BasicShapeFunctions.cpp >+++ b/Source/WebCore/css/BasicShapeFunctions.cpp >@@ -100,12 +100,12 @@ PassRefPtr<CSSValue> valueForBasicShape(const BasicShape* basicShape) > return cssValuePool().createValue<PassRefPtr<CSSBasicShape> >(basicShapeValue.release()); > } > >-static Length convertToLength(const StyleResolver* styleResolver, CSSPrimitiveValue* value) >+static Length convertToLength(StyleResolveState& state, CSSPrimitiveValue* value) > { >- return value->convertToLength<FixedIntegerConversion | FixedFloatConversion | PercentConversion | ViewportPercentageConversion>(styleResolver->style(), styleResolver->rootElementStyle(), styleResolver->style()->effectiveZoom()); >+ return value->convertToLength<FixedIntegerConversion | FixedFloatConversion | PercentConversion | ViewportPercentageConversion>(state.style(), state.rootElementStyle(), state.style()->effectiveZoom()); > } > >-PassRefPtr<BasicShape> basicShapeForValue(const StyleResolver* styleResolver, const CSSBasicShape* basicShapeValue) >+PassRefPtr<BasicShape> basicShapeForValue(StyleResolveState& state, const CSSBasicShape* basicShapeValue) > { > RefPtr<BasicShape> basicShape; > >@@ -114,14 +114,14 @@ PassRefPtr<BasicShape> basicShapeForValue(const StyleResolver* styleResolver, co > const CSSBasicShapeRectangle* rectValue = static_cast<const CSSBasicShapeRectangle *>(basicShapeValue); > RefPtr<BasicShapeRectangle> rect = BasicShapeRectangle::create(); > >- rect->setX(convertToLength(styleResolver, rectValue->x())); >- rect->setY(convertToLength(styleResolver, rectValue->y())); >- rect->setWidth(convertToLength(styleResolver, rectValue->width())); >- rect->setHeight(convertToLength(styleResolver, rectValue->height())); >+ rect->setX(convertToLength(state, rectValue->x())); >+ rect->setY(convertToLength(state, rectValue->y())); >+ rect->setWidth(convertToLength(state, rectValue->width())); >+ rect->setHeight(convertToLength(state, rectValue->height())); > if (rectValue->radiusX()) { >- rect->setCornerRadiusX(convertToLength(styleResolver, rectValue->radiusX())); >+ rect->setCornerRadiusX(convertToLength(state, rectValue->radiusX())); > if (rectValue->radiusY()) >- rect->setCornerRadiusY(convertToLength(styleResolver, rectValue->radiusY())); >+ rect->setCornerRadiusY(convertToLength(state, rectValue->radiusY())); > } > basicShape = rect.release(); > break; >@@ -130,9 +130,9 @@ PassRefPtr<BasicShape> basicShapeForValue(const StyleResolver* styleResolver, co > const CSSBasicShapeCircle* circleValue = static_cast<const CSSBasicShapeCircle *>(basicShapeValue); > RefPtr<BasicShapeCircle> circle = BasicShapeCircle::create(); > >- circle->setCenterX(convertToLength(styleResolver, circleValue->centerX())); >- circle->setCenterY(convertToLength(styleResolver, circleValue->centerY())); >- circle->setRadius(convertToLength(styleResolver, circleValue->radius())); >+ circle->setCenterX(convertToLength(state, circleValue->centerX())); >+ circle->setCenterY(convertToLength(state, circleValue->centerY())); >+ circle->setRadius(convertToLength(state, circleValue->radius())); > > basicShape = circle.release(); > break; >@@ -141,10 +141,10 @@ PassRefPtr<BasicShape> basicShapeForValue(const StyleResolver* styleResolver, co > const CSSBasicShapeEllipse* ellipseValue = static_cast<const CSSBasicShapeEllipse *>(basicShapeValue); > RefPtr<BasicShapeEllipse> ellipse = BasicShapeEllipse::create(); > >- ellipse->setCenterX(convertToLength(styleResolver, ellipseValue->centerX())); >- ellipse->setCenterY(convertToLength(styleResolver, ellipseValue->centerY())); >- ellipse->setRadiusX(convertToLength(styleResolver, ellipseValue->radiusX())); >- ellipse->setRadiusY(convertToLength(styleResolver, ellipseValue->radiusY())); >+ ellipse->setCenterX(convertToLength(state, ellipseValue->centerX())); >+ ellipse->setCenterY(convertToLength(state, ellipseValue->centerY())); >+ ellipse->setRadiusX(convertToLength(state, ellipseValue->radiusX())); >+ ellipse->setRadiusY(convertToLength(state, ellipseValue->radiusY())); > > basicShape = ellipse.release(); > break; >@@ -156,7 +156,7 @@ PassRefPtr<BasicShape> basicShapeForValue(const StyleResolver* styleResolver, co > polygon->setWindRule(polygonValue->windRule()); > const Vector<RefPtr<CSSPrimitiveValue> >& values = polygonValue->values(); > for (unsigned i = 0; i < values.size(); i += 2) >- polygon->appendPoint(convertToLength(styleResolver, values.at(i).get()), convertToLength(styleResolver, values.at(i + 1).get())); >+ polygon->appendPoint(convertToLength(state, values.at(i).get()), convertToLength(state, values.at(i + 1).get())); > > basicShape = polygon.release(); > break; >diff --git a/Source/WebCore/css/BasicShapeFunctions.h b/Source/WebCore/css/BasicShapeFunctions.h >index d3607e909929c341b0c069d3e5ceb61f13f11719..81b2caa357b741fa238461f07293a06d98cc9c6c 100644 >--- a/Source/WebCore/css/BasicShapeFunctions.h >+++ b/Source/WebCore/css/BasicShapeFunctions.h >@@ -37,10 +37,10 @@ namespace WebCore { > class BasicShape; > class CSSBasicShape; > class CSSValue; >-class StyleResolver; >+class StyleResolveState; > > PassRefPtr<CSSValue> valueForBasicShape(const BasicShape*); >-PassRefPtr<BasicShape> basicShapeForValue(const StyleResolver*, const CSSBasicShape*); >+PassRefPtr<BasicShape> basicShapeForValue(StyleResolveState&, const CSSBasicShape*); > > } > #endif >diff --git a/Source/WebCore/css/CSSGradientValue.cpp b/Source/WebCore/css/CSSGradientValue.cpp >index f1518d8dac7480c4e2397e52dfa942bce8dc6a81..c2ce92070c1f1fb8120bb3f92fee8cea697c2619 100644 >--- a/Source/WebCore/css/CSSGradientValue.cpp >+++ b/Source/WebCore/css/CSSGradientValue.cpp >@@ -115,11 +115,11 @@ struct GradientStop { > { } > }; > >-PassRefPtr<CSSGradientValue> CSSGradientValue::gradientWithStylesResolved(StyleResolver* styleResolver) >+PassRefPtr<CSSGradientValue> CSSGradientValue::gradientWithStylesResolved(StyleResolveState& state) > { > bool derived = false; > for (unsigned i = 0; i < m_stops.size(); i++) >- if (styleResolver->colorFromPrimitiveValueIsDerivedFromElement(m_stops[i].m_color.get())) { >+ if (StyleResolver::colorFromPrimitiveValueIsDerivedFromElement(m_stops[i].m_color.get())) { > m_stops[i].m_colorIsDerivedFromElement = true; > derived = true; > break; >@@ -138,7 +138,7 @@ PassRefPtr<CSSGradientValue> CSSGradientValue::gradientWithStylesResolved(StyleR > } > > for (unsigned i = 0; i < result->m_stops.size(); i++) >- result->m_stops[i].m_resolvedColor = styleResolver->colorFromPrimitiveValue(result->m_stops[i].m_color.get()); >+ result->m_stops[i].m_resolvedColor = StyleResolver::colorFromPrimitiveValue(state, result->m_stops[i].m_color.get()); > > return result.release(); > } >diff --git a/Source/WebCore/css/CSSGradientValue.h b/Source/WebCore/css/CSSGradientValue.h >index 6f00535907e15779a080272c886fd6b8097c800d..0b72e2ae62da0823f6d3fbe616a7a5138259e2b4 100644 >--- a/Source/WebCore/css/CSSGradientValue.h >+++ b/Source/WebCore/css/CSSGradientValue.h >@@ -35,6 +35,7 @@ namespace WebCore { > > class FloatPoint; > class Gradient; >+class StyleResolveState; > > enum CSSGradientType { > CSSDeprecatedLinearGradient, >@@ -84,7 +85,7 @@ public: > bool hasAlpha(const RenderObject*) const; > > void loadSubimages(CachedResourceLoader*) { } >- PassRefPtr<CSSGradientValue> gradientWithStylesResolved(StyleResolver*); >+ PassRefPtr<CSSGradientValue> gradientWithStylesResolved(StyleResolveState&); > > protected: > CSSGradientValue(ClassType classType, CSSGradientRepeat repeat, CSSGradientType gradientType) >diff --git a/Source/WebCore/css/CSSToStyleMap.cpp b/Source/WebCore/css/CSSToStyleMap.cpp >index 0244d8a3ad578f6e13f6cd1dbe6a8d243ed807b0..2cdcec7d110426bdc129a32391039af156e440ee 100644 >--- a/Source/WebCore/css/CSSToStyleMap.cpp >+++ b/Source/WebCore/css/CSSToStyleMap.cpp >@@ -41,27 +41,7 @@ > > namespace WebCore { > >-RenderStyle* CSSToStyleMap::style() const >-{ >- return m_resolver->style(); >-} >- >-RenderStyle* CSSToStyleMap::rootElementStyle() const >-{ >- return m_resolver->rootElementStyle(); >-} >- >-bool CSSToStyleMap::useSVGZoomRules() const >-{ >- return m_resolver->useSVGZoomRules(); >-} >- >-PassRefPtr<StyleImage> CSSToStyleMap::styleImage(CSSPropertyID propertyId, CSSValue* value) >-{ >- return m_resolver->styleImage(propertyId, value); >-} >- >-void CSSToStyleMap::mapFillAttachment(CSSPropertyID, FillLayer* layer, CSSValue* value) >+void CSSToStyleMap::mapFillAttachment(StyleResolveState&, CSSPropertyID, FillLayer* layer, CSSValue* value) > { > if (value->isInitialValue()) { > layer->setAttachment(FillLayer::initialFillAttachment(layer->type())); >@@ -87,7 +67,7 @@ void CSSToStyleMap::mapFillAttachment(CSSPropertyID, FillLayer* layer, CSSValue* > } > } > >-void CSSToStyleMap::mapFillClip(CSSPropertyID, FillLayer* layer, CSSValue* value) >+void CSSToStyleMap::mapFillClip(StyleResolveState&, CSSPropertyID, FillLayer* layer, CSSValue* value) > { > if (value->isInitialValue()) { > layer->setClip(FillLayer::initialFillClip(layer->type())); >@@ -101,7 +81,7 @@ void CSSToStyleMap::mapFillClip(CSSPropertyID, FillLayer* layer, CSSValue* value > layer->setClip(*primitiveValue); > } > >-void CSSToStyleMap::mapFillComposite(CSSPropertyID, FillLayer* layer, CSSValue* value) >+void CSSToStyleMap::mapFillComposite(StyleResolveState&, CSSPropertyID, FillLayer* layer, CSSValue* value) > { > if (value->isInitialValue()) { > layer->setComposite(FillLayer::initialFillComposite(layer->type())); >@@ -115,7 +95,7 @@ void CSSToStyleMap::mapFillComposite(CSSPropertyID, FillLayer* layer, CSSValue* > layer->setComposite(*primitiveValue); > } > >-void CSSToStyleMap::mapFillOrigin(CSSPropertyID, FillLayer* layer, CSSValue* value) >+void CSSToStyleMap::mapFillOrigin(StyleResolveState&, CSSPropertyID, FillLayer* layer, CSSValue* value) > { > if (value->isInitialValue()) { > layer->setOrigin(FillLayer::initialFillOrigin(layer->type())); >@@ -130,17 +110,17 @@ void CSSToStyleMap::mapFillOrigin(CSSPropertyID, FillLayer* layer, CSSValue* val > } > > >-void CSSToStyleMap::mapFillImage(CSSPropertyID property, FillLayer* layer, CSSValue* value) >+void CSSToStyleMap::mapFillImage(StyleResolveState& state, CSSPropertyID property, FillLayer* layer, CSSValue* value) > { > if (value->isInitialValue()) { > layer->setImage(FillLayer::initialFillImage(layer->type())); > return; > } > >- layer->setImage(styleImage(property, value)); >+ layer->setImage(StyleResolver::styleImage(state, property, value)); > } > >-void CSSToStyleMap::mapFillRepeatX(CSSPropertyID, FillLayer* layer, CSSValue* value) >+void CSSToStyleMap::mapFillRepeatX(StyleResolveState&, CSSPropertyID, FillLayer* layer, CSSValue* value) > { > if (value->isInitialValue()) { > layer->setRepeatX(FillLayer::initialFillRepeatX(layer->type())); >@@ -154,7 +134,7 @@ void CSSToStyleMap::mapFillRepeatX(CSSPropertyID, FillLayer* layer, CSSValue* va > layer->setRepeatX(*primitiveValue); > } > >-void CSSToStyleMap::mapFillRepeatY(CSSPropertyID, FillLayer* layer, CSSValue* value) >+void CSSToStyleMap::mapFillRepeatY(StyleResolveState&, CSSPropertyID, FillLayer* layer, CSSValue* value) > { > if (value->isInitialValue()) { > layer->setRepeatY(FillLayer::initialFillRepeatY(layer->type())); >@@ -168,7 +148,7 @@ void CSSToStyleMap::mapFillRepeatY(CSSPropertyID, FillLayer* layer, CSSValue* va > layer->setRepeatY(*primitiveValue); > } > >-void CSSToStyleMap::mapFillSize(CSSPropertyID, FillLayer* layer, CSSValue* value) >+void CSSToStyleMap::mapFillSize(StyleResolveState& state, CSSPropertyID, FillLayer* layer, CSSValue* value) > { > if (!value->isPrimitiveValue()) { > layer->setSizeType(SizeNone); >@@ -190,7 +170,7 @@ void CSSToStyleMap::mapFillSize(CSSPropertyID, FillLayer* layer, CSSValue* value > return; > } > >- float zoomFactor = style()->effectiveZoom(); >+ float zoomFactor = state.style()->effectiveZoom(); > > Length firstLength; > Length secondLength; >@@ -198,10 +178,10 @@ void CSSToStyleMap::mapFillSize(CSSPropertyID, FillLayer* layer, CSSValue* value > if (Pair* pair = primitiveValue->getPairValue()) { > CSSPrimitiveValue* first = static_cast<CSSPrimitiveValue*>(pair->first()); > CSSPrimitiveValue* second = static_cast<CSSPrimitiveValue*>(pair->second()); >- firstLength = first->convertToLength<AnyConversion>(style(), rootElementStyle(), zoomFactor); >- secondLength = second->convertToLength<AnyConversion>(style(), rootElementStyle(), zoomFactor); >+ firstLength = first->convertToLength<AnyConversion>(state.style(), state.rootElementStyle(), zoomFactor); >+ secondLength = second->convertToLength<AnyConversion>(state.style(), state.rootElementStyle(), zoomFactor); > } else { >- firstLength = primitiveValue->convertToLength<AnyConversion>(style(), rootElementStyle(), zoomFactor); >+ firstLength = primitiveValue->convertToLength<AnyConversion>(state.style(), state.rootElementStyle(), zoomFactor); > secondLength = Length(); > } > >@@ -213,7 +193,7 @@ void CSSToStyleMap::mapFillSize(CSSPropertyID, FillLayer* layer, CSSValue* value > layer->setSizeLength(b); > } > >-void CSSToStyleMap::mapFillXPosition(CSSPropertyID propertyID, FillLayer* layer, CSSValue* value) >+void CSSToStyleMap::mapFillXPosition(StyleResolveState& state, CSSPropertyID propertyID, FillLayer* layer, CSSValue* value) > { > if (value->isInitialValue()) { > layer->setXPosition(FillLayer::initialFillXPosition(layer->type())); >@@ -223,7 +203,7 @@ void CSSToStyleMap::mapFillXPosition(CSSPropertyID propertyID, FillLayer* layer, > if (!value->isPrimitiveValue()) > return; > >- float zoomFactor = style()->effectiveZoom(); >+ float zoomFactor = state.style()->effectiveZoom(); > > CSSPrimitiveValue* primitiveValue = static_cast<CSSPrimitiveValue*>(value); > Pair* pair = primitiveValue->getPairValue(); >@@ -234,11 +214,11 @@ void CSSToStyleMap::mapFillXPosition(CSSPropertyID propertyID, FillLayer* layer, > > Length length; > if (primitiveValue->isLength()) >- length = primitiveValue->computeLength<Length>(style(), rootElementStyle(), zoomFactor); >+ length = primitiveValue->computeLength<Length>(state.style(), state.rootElementStyle(), zoomFactor); > else if (primitiveValue->isPercentage()) > length = Length(primitiveValue->getDoubleValue(), Percent); > else if (primitiveValue->isCalculatedPercentageWithLength()) >- length = Length(primitiveValue->cssCalcValue()->toCalcValue(style(), rootElementStyle(), zoomFactor)); >+ length = Length(primitiveValue->cssCalcValue()->toCalcValue(state.style(), state.rootElementStyle(), zoomFactor)); > else if (primitiveValue->isViewportPercentageLength()) > length = primitiveValue->viewportPercentageLength(); > else >@@ -249,7 +229,7 @@ void CSSToStyleMap::mapFillXPosition(CSSPropertyID propertyID, FillLayer* layer, > layer->setBackgroundXOrigin(*(pair->first())); > } > >-void CSSToStyleMap::mapFillYPosition(CSSPropertyID propertyID, FillLayer* layer, CSSValue* value) >+void CSSToStyleMap::mapFillYPosition(StyleResolveState& state, CSSPropertyID propertyID, FillLayer* layer, CSSValue* value) > { > if (value->isInitialValue()) { > layer->setYPosition(FillLayer::initialFillYPosition(layer->type())); >@@ -259,7 +239,7 @@ void CSSToStyleMap::mapFillYPosition(CSSPropertyID propertyID, FillLayer* layer, > if (!value->isPrimitiveValue()) > return; > >- float zoomFactor = style()->effectiveZoom(); >+ float zoomFactor = state.style()->effectiveZoom(); > > CSSPrimitiveValue* primitiveValue = static_cast<CSSPrimitiveValue*>(value); > Pair* pair = primitiveValue->getPairValue(); >@@ -270,11 +250,11 @@ void CSSToStyleMap::mapFillYPosition(CSSPropertyID propertyID, FillLayer* layer, > > Length length; > if (primitiveValue->isLength()) >- length = primitiveValue->computeLength<Length>(style(), rootElementStyle(), zoomFactor); >+ length = primitiveValue->computeLength<Length>(state.style(), state.rootElementStyle(), zoomFactor); > else if (primitiveValue->isPercentage()) > length = Length(primitiveValue->getDoubleValue(), Percent); > else if (primitiveValue->isCalculatedPercentageWithLength()) >- length = Length(primitiveValue->cssCalcValue()->toCalcValue(style(), rootElementStyle(), zoomFactor)); >+ length = Length(primitiveValue->cssCalcValue()->toCalcValue(state.style(), state.rootElementStyle(), zoomFactor)); > else if (primitiveValue->isViewportPercentageLength()) > length = primitiveValue->viewportPercentageLength(); > else >@@ -485,7 +465,7 @@ void CSSToStyleMap::mapAnimationTimingFunction(Animation* animation, CSSValue* v > animation->setTimingFunction(LinearTimingFunction::create()); > } > >-void CSSToStyleMap::mapNinePieceImage(CSSPropertyID property, CSSValue* value, NinePieceImage& image) >+void CSSToStyleMap::mapNinePieceImage(StyleResolveState& state, CSSPropertyID property, CSSValue* value, NinePieceImage& image) > { > // If we're not a value list, then we are "none" and don't need to alter the empty image at all. > if (!value || !value->isValueList()) >@@ -511,25 +491,25 @@ void CSSToStyleMap::mapNinePieceImage(CSSPropertyID property, CSSValue* value, N > || current->isImageSetValue() > #endif > ) >- image.setImage(styleImage(imageProperty, current)); >+ image.setImage(StyleResolver::styleImage(state, imageProperty, current)); > else if (current->isBorderImageSliceValue()) >- mapNinePieceImageSlice(current, image); >+ mapNinePieceImageSlice(state, current, image); > else if (current->isValueList()) { > CSSValueList* slashList = static_cast<CSSValueList*>(current); > // Map in the image slices. > if (slashList->item(0) && slashList->item(0)->isBorderImageSliceValue()) >- mapNinePieceImageSlice(slashList->item(0), image); >+ mapNinePieceImageSlice(state, slashList->item(0), image); > > // Map in the border slices. > if (slashList->item(1)) >- image.setBorderSlices(mapNinePieceImageQuad(slashList->item(1))); >+ image.setBorderSlices(mapNinePieceImageQuad(state, slashList->item(1))); > > // Map in the outset. > if (slashList->item(2)) >- image.setOutset(mapNinePieceImageQuad(slashList->item(2))); >+ image.setOutset(mapNinePieceImageQuad(state, slashList->item(2))); > } else if (current->isPrimitiveValue()) { > // Set the appropriate rules for stretch/round/repeat of the slices. >- mapNinePieceImageRepeat(current, image); >+ mapNinePieceImageRepeat(state, current, image); > } > } > >@@ -538,17 +518,17 @@ void CSSToStyleMap::mapNinePieceImage(CSSPropertyID property, CSSValue* value, N > // also set the border widths. We don't need to worry about percentages, since we don't even support > // those on real borders yet. > if (image.borderSlices().top().isFixed()) >- style()->setBorderTopWidth(image.borderSlices().top().value()); >+ state.style()->setBorderTopWidth(image.borderSlices().top().value()); > if (image.borderSlices().right().isFixed()) >- style()->setBorderRightWidth(image.borderSlices().right().value()); >+ state.style()->setBorderRightWidth(image.borderSlices().right().value()); > if (image.borderSlices().bottom().isFixed()) >- style()->setBorderBottomWidth(image.borderSlices().bottom().value()); >+ state.style()->setBorderBottomWidth(image.borderSlices().bottom().value()); > if (image.borderSlices().left().isFixed()) >- style()->setBorderLeftWidth(image.borderSlices().left().value()); >+ state.style()->setBorderLeftWidth(image.borderSlices().left().value()); > } > } > >-void CSSToStyleMap::mapNinePieceImageSlice(CSSValue* value, NinePieceImage& image) >+void CSSToStyleMap::mapNinePieceImageSlice(StyleResolveState&, CSSValue* value, NinePieceImage& image) > { > if (!value || !value->isBorderImageSliceValue()) > return; >@@ -581,13 +561,13 @@ void CSSToStyleMap::mapNinePieceImageSlice(CSSValue* value, NinePieceImage& imag > image.setFill(borderImageSlice->m_fill); > } > >-LengthBox CSSToStyleMap::mapNinePieceImageQuad(CSSValue* value) >+LengthBox CSSToStyleMap::mapNinePieceImageQuad(StyleResolveState& state, CSSValue* value) > { > if (!value || !value->isPrimitiveValue()) > return LengthBox(); > > // Get our zoom value. >- float zoom = useSVGZoomRules() ? 1.0f : style()->effectiveZoom(); >+ float zoom = state.useSVGZoomRules() ? 1.0f : state.style()->effectiveZoom(); > > // Retrieve the primitive value. > CSSPrimitiveValue* borderWidths = static_cast<CSSPrimitiveValue*>(value); >@@ -600,33 +580,33 @@ LengthBox CSSToStyleMap::mapNinePieceImageQuad(CSSValue* value) > else if (slices->top()->isPercentage()) > box.m_top = Length(slices->top()->getDoubleValue(CSSPrimitiveValue::CSS_PERCENTAGE), Percent); > else if (slices->top()->getIdent() != CSSValueAuto) >- box.m_top = slices->top()->computeLength<Length>(style(), rootElementStyle(), zoom); >+ box.m_top = slices->top()->computeLength<Length>(state.style(), state.rootElementStyle(), zoom); > > if (slices->right()->isNumber()) > box.m_right = Length(slices->right()->getIntValue(), Relative); > else if (slices->right()->isPercentage()) > box.m_right = Length(slices->right()->getDoubleValue(CSSPrimitiveValue::CSS_PERCENTAGE), Percent); > else if (slices->right()->getIdent() != CSSValueAuto) >- box.m_right = slices->right()->computeLength<Length>(style(), rootElementStyle(), zoom); >+ box.m_right = slices->right()->computeLength<Length>(state.style(), state.rootElementStyle(), zoom); > > if (slices->bottom()->isNumber()) > box.m_bottom = Length(slices->bottom()->getIntValue(), Relative); > else if (slices->bottom()->isPercentage()) > box.m_bottom = Length(slices->bottom()->getDoubleValue(CSSPrimitiveValue::CSS_PERCENTAGE), Percent); > else if (slices->bottom()->getIdent() != CSSValueAuto) >- box.m_bottom = slices->bottom()->computeLength<Length>(style(), rootElementStyle(), zoom); >+ box.m_bottom = slices->bottom()->computeLength<Length>(state.style(), state.rootElementStyle(), zoom); > > if (slices->left()->isNumber()) > box.m_left = Length(slices->left()->getIntValue(), Relative); > else if (slices->left()->isPercentage()) > box.m_left = Length(slices->left()->getDoubleValue(CSSPrimitiveValue::CSS_PERCENTAGE), Percent); > else if (slices->left()->getIdent() != CSSValueAuto) >- box.m_left = slices->left()->computeLength<Length>(style(), rootElementStyle(), zoom); >+ box.m_left = slices->left()->computeLength<Length>(state.style(), state.rootElementStyle(), zoom); > > return box; > } > >-void CSSToStyleMap::mapNinePieceImageRepeat(CSSValue* value, NinePieceImage& image) >+void CSSToStyleMap::mapNinePieceImageRepeat(StyleResolveState&, CSSValue* value, NinePieceImage& image) > { > if (!value || !value->isPrimitiveValue()) > return; >diff --git a/Source/WebCore/css/CSSToStyleMap.h b/Source/WebCore/css/CSSToStyleMap.h >index 6bab40bfcd77e125ab08f008f10e7a3e6827914e..8a55c4f286971a925015973ec4af42951dd93913 100644 >--- a/Source/WebCore/css/CSSToStyleMap.h >+++ b/Source/WebCore/css/CSSToStyleMap.h >@@ -32,56 +32,41 @@ class CSSValue; > class Animation; > class RenderStyle; > class StyleImage; >-class StyleResolver; >+class StyleResolveState; > class NinePieceImage; > > class CSSToStyleMap { > WTF_MAKE_NONCOPYABLE(CSSToStyleMap); > WTF_MAKE_FAST_ALLOCATED; >- > public: >- CSSToStyleMap(StyleResolver* resolver) : m_resolver(resolver) { } >- >- void mapFillAttachment(CSSPropertyID, FillLayer*, CSSValue*); >- void mapFillClip(CSSPropertyID, FillLayer*, CSSValue*); >- void mapFillComposite(CSSPropertyID, FillLayer*, CSSValue*); >- void mapFillOrigin(CSSPropertyID, FillLayer*, CSSValue*); >- void mapFillImage(CSSPropertyID, FillLayer*, CSSValue*); >- void mapFillRepeatX(CSSPropertyID, FillLayer*, CSSValue*); >- void mapFillRepeatY(CSSPropertyID, FillLayer*, CSSValue*); >- void mapFillSize(CSSPropertyID, FillLayer*, CSSValue*); >- void mapFillXPosition(CSSPropertyID, FillLayer*, CSSValue*); >- void mapFillYPosition(CSSPropertyID, FillLayer*, CSSValue*); >+ static void mapFillAttachment(StyleResolveState&, CSSPropertyID, FillLayer*, CSSValue*); >+ static void mapFillClip(StyleResolveState&, CSSPropertyID, FillLayer*, CSSValue*); >+ static void mapFillComposite(StyleResolveState&, CSSPropertyID, FillLayer*, CSSValue*); >+ static void mapFillOrigin(StyleResolveState&, CSSPropertyID, FillLayer*, CSSValue*); >+ static void mapFillImage(StyleResolveState&, CSSPropertyID, FillLayer*, CSSValue*); >+ static void mapFillRepeatX(StyleResolveState&, CSSPropertyID, FillLayer*, CSSValue*); >+ static void mapFillRepeatY(StyleResolveState&, CSSPropertyID, FillLayer*, CSSValue*); >+ static void mapFillSize(StyleResolveState&, CSSPropertyID, FillLayer*, CSSValue*); >+ static void mapFillXPosition(StyleResolveState&, CSSPropertyID, FillLayer*, CSSValue*); >+ static void mapFillYPosition(StyleResolveState&, CSSPropertyID, FillLayer*, CSSValue*); > >- void mapAnimationDelay(Animation*, CSSValue*); >- void mapAnimationDirection(Animation*, CSSValue*); >- void mapAnimationDuration(Animation*, CSSValue*); >- void mapAnimationFillMode(Animation*, CSSValue*); >- void mapAnimationIterationCount(Animation*, CSSValue*); >- void mapAnimationName(Animation*, CSSValue*); >- void mapAnimationPlayState(Animation*, CSSValue*); >- void mapAnimationProperty(Animation*, CSSValue*); >- void mapAnimationTimingFunction(Animation*, CSSValue*); >+ static void mapAnimationDelay(Animation*, CSSValue*); >+ static void mapAnimationDirection(Animation*, CSSValue*); >+ static void mapAnimationDuration(Animation*, CSSValue*); >+ static void mapAnimationFillMode(Animation*, CSSValue*); >+ static void mapAnimationIterationCount(Animation*, CSSValue*); >+ static void mapAnimationName(Animation*, CSSValue*); >+ static void mapAnimationPlayState(Animation*, CSSValue*); >+ static void mapAnimationProperty(Animation*, CSSValue*); >+ static void mapAnimationTimingFunction(Animation*, CSSValue*); > >- void mapNinePieceImage(CSSPropertyID, CSSValue*, NinePieceImage&); >- void mapNinePieceImageSlice(CSSValue*, NinePieceImage&); >- LengthBox mapNinePieceImageQuad(CSSValue*); >- void mapNinePieceImageRepeat(CSSValue*, NinePieceImage&); >+ static void mapNinePieceImage(StyleResolveState&, CSSPropertyID, CSSValue*, NinePieceImage&); >+ static void mapNinePieceImageSlice(StyleResolveState&, CSSValue*, NinePieceImage&); >+ static LengthBox mapNinePieceImageQuad(StyleResolveState&, CSSValue*); >+ static void mapNinePieceImageRepeat(StyleResolveState&, CSSValue*, NinePieceImage&); > > private: >- // FIXME: These accessors should be replaced by a ResolveState object >- // similar to how PaintInfo/LayoutState cache values needed for >- // the current paint/layout. >- RenderStyle* style() const; >- RenderStyle* rootElementStyle() const; >- bool useSVGZoomRules() const; >- >- // FIXME: This should be part of some sort of StyleImageCache object which >- // is held by the StyleResolver, and likely provided to this object >- // during the resolve. >- PassRefPtr<StyleImage> styleImage(CSSPropertyID, CSSValue*); >- >- StyleResolver* m_resolver; >+ CSSToStyleMap() { } > }; > > } >diff --git a/Source/WebCore/css/SVGCSSStyleSelector.cpp b/Source/WebCore/css/SVGCSSStyleSelector.cpp >index 6145bb1f1625b8fe4d167607bbba8bfd9a1b0119..db23e99402e737430d95f12a8bac607ce317367b 100644 >--- a/Source/WebCore/css/SVGCSSStyleSelector.cpp >+++ b/Source/WebCore/css/SVGCSSStyleSelector.cpp >@@ -49,7 +49,7 @@ > #define HANDLE_INHERIT(prop, Prop) \ > if (isInherit) \ > { \ >- svgstyle->set##Prop(m_parentStyle->svgStyle()->prop()); \ >+ svgstyle->set##Prop(state.parentStyle()->svgStyle()->prop()); \ > return; \ > } > >@@ -102,17 +102,17 @@ static Color colorFromSVGColorCSSValue(SVGColor* svgColor, const Color& fgColor) > return color; > } > >-void StyleResolver::applySVGProperty(CSSPropertyID id, CSSValue* value) >+void StyleResolver::applySVGProperty(StyleResolveState& state, CSSPropertyID id, CSSValue* value) > { > ASSERT(value); > CSSPrimitiveValue* primitiveValue = 0; > if (value->isPrimitiveValue()) > primitiveValue = static_cast<CSSPrimitiveValue*>(value); > >- SVGRenderStyle* svgstyle = m_style->accessSVGStyle(); >+ SVGRenderStyle* svgstyle = state.style()->accessSVGStyle(); > >- bool isInherit = m_parentNode && value->isInheritedValue(); >- bool isInitial = value->isInitialValue() || (!m_parentNode && value->isInheritedValue()); >+ bool isInherit = state.parentNode() && value->isInheritedValue(); >+ bool isInitial = value->isInitialValue() || (!state.parentNode() && value->isInheritedValue()); > > // What follows is a list that maps the CSS properties into their > // corresponding front-end RenderStyle values. Shorthands(e.g. border, >@@ -229,34 +229,34 @@ void StyleResolver::applySVGProperty(CSSPropertyID id, CSSValue* value) > case CSSPropertyFill: > { > if (isInherit) { >- const SVGRenderStyle* svgParentStyle = m_parentStyle->svgStyle(); >- svgstyle->setFillPaint(svgParentStyle->fillPaintType(), svgParentStyle->fillPaintColor(), svgParentStyle->fillPaintUri(), applyPropertyToRegularStyle(), applyPropertyToVisitedLinkStyle()); >+ const SVGRenderStyle* svgParentStyle = state.parentStyle()->svgStyle(); >+ svgstyle->setFillPaint(svgParentStyle->fillPaintType(), svgParentStyle->fillPaintColor(), svgParentStyle->fillPaintUri(), state.applyPropertyToRegularStyle(), state.applyPropertyToVisitedLinkStyle()); > return; > } > if (isInitial) { >- svgstyle->setFillPaint(SVGRenderStyle::initialFillPaintType(), SVGRenderStyle::initialFillPaintColor(), SVGRenderStyle::initialFillPaintUri(), applyPropertyToRegularStyle(), applyPropertyToVisitedLinkStyle()); >+ svgstyle->setFillPaint(SVGRenderStyle::initialFillPaintType(), SVGRenderStyle::initialFillPaintColor(), SVGRenderStyle::initialFillPaintUri(), state.applyPropertyToRegularStyle(), state.applyPropertyToVisitedLinkStyle()); > return; > } > if (value->isSVGPaint()) { > SVGPaint* svgPaint = static_cast<SVGPaint*>(value); >- svgstyle->setFillPaint(svgPaint->paintType(), colorFromSVGColorCSSValue(svgPaint, m_style->color()), svgPaint->uri(), applyPropertyToRegularStyle(), applyPropertyToVisitedLinkStyle()); >+ svgstyle->setFillPaint(svgPaint->paintType(), colorFromSVGColorCSSValue(svgPaint, state.style()->color()), svgPaint->uri(), state.applyPropertyToRegularStyle(), state.applyPropertyToVisitedLinkStyle()); > } > break; > } > case CSSPropertyStroke: > { > if (isInherit) { >- const SVGRenderStyle* svgParentStyle = m_parentStyle->svgStyle(); >- svgstyle->setStrokePaint(svgParentStyle->strokePaintType(), svgParentStyle->strokePaintColor(), svgParentStyle->strokePaintUri(), applyPropertyToRegularStyle(), applyPropertyToVisitedLinkStyle()); >+ const SVGRenderStyle* svgParentStyle = state.parentStyle()->svgStyle(); >+ svgstyle->setStrokePaint(svgParentStyle->strokePaintType(), svgParentStyle->strokePaintColor(), svgParentStyle->strokePaintUri(), state.applyPropertyToRegularStyle(), state.applyPropertyToVisitedLinkStyle()); > return; > } > if (isInitial) { >- svgstyle->setStrokePaint(SVGRenderStyle::initialStrokePaintType(), SVGRenderStyle::initialStrokePaintColor(), SVGRenderStyle::initialStrokePaintUri(), applyPropertyToRegularStyle(), applyPropertyToVisitedLinkStyle()); >+ svgstyle->setStrokePaint(SVGRenderStyle::initialStrokePaintType(), SVGRenderStyle::initialStrokePaintColor(), SVGRenderStyle::initialStrokePaintUri(), state.applyPropertyToRegularStyle(), state.applyPropertyToVisitedLinkStyle()); > return; > } > if (value->isSVGPaint()) { > SVGPaint* svgPaint = static_cast<SVGPaint*>(value); >- svgstyle->setStrokePaint(svgPaint->paintType(), colorFromSVGColorCSSValue(svgPaint, m_style->color()), svgPaint->uri(), applyPropertyToRegularStyle(), applyPropertyToVisitedLinkStyle()); >+ svgstyle->setStrokePaint(svgPaint->paintType(), colorFromSVGColorCSSValue(svgPaint, state.style()->color()), svgPaint->uri(), state.applyPropertyToRegularStyle(), state.applyPropertyToVisitedLinkStyle()); > } > break; > } >@@ -363,7 +363,7 @@ void StyleResolver::applySVGProperty(CSSPropertyID id, CSSValue* value) > if (type == CSSPrimitiveValue::CSS_URI) > s = primitiveValue->getStringValue(); > >- svgstyle->setMarkerStartResource(SVGURIReference::fragmentIdentifierFromIRIString(s, m_element->document())); >+ svgstyle->setMarkerStartResource(SVGURIReference::fragmentIdentifierFromIRIString(s, state.document())); > break; > } > case CSSPropertyMarkerMid: >@@ -377,7 +377,7 @@ void StyleResolver::applySVGProperty(CSSPropertyID id, CSSValue* value) > if (type == CSSPrimitiveValue::CSS_URI) > s = primitiveValue->getStringValue(); > >- svgstyle->setMarkerMidResource(SVGURIReference::fragmentIdentifierFromIRIString(s, m_element->document())); >+ svgstyle->setMarkerMidResource(SVGURIReference::fragmentIdentifierFromIRIString(s, state.document())); > break; > } > case CSSPropertyMarkerEnd: >@@ -391,7 +391,7 @@ void StyleResolver::applySVGProperty(CSSPropertyID id, CSSValue* value) > if (type == CSSPrimitiveValue::CSS_URI) > s = primitiveValue->getStringValue(); > >- svgstyle->setMarkerEndResource(SVGURIReference::fragmentIdentifierFromIRIString(s, m_element->document())); >+ svgstyle->setMarkerEndResource(SVGURIReference::fragmentIdentifierFromIRIString(s, state.document())); > break; > } > case CSSPropertyStrokeLinecap: >@@ -428,7 +428,7 @@ void StyleResolver::applySVGProperty(CSSPropertyID id, CSSValue* value) > if (type == CSSPrimitiveValue::CSS_URI) > s = primitiveValue->getStringValue(); > >- svgstyle->setFilterResource(SVGURIReference::fragmentIdentifierFromIRIString(s, m_element->document())); >+ svgstyle->setFilterResource(SVGURIReference::fragmentIdentifierFromIRIString(s, state.document())); > break; > } > case CSSPropertyMask: >@@ -442,7 +442,7 @@ void StyleResolver::applySVGProperty(CSSPropertyID id, CSSValue* value) > if (type == CSSPrimitiveValue::CSS_URI) > s = primitiveValue->getStringValue(); > >- svgstyle->setMaskerResource(SVGURIReference::fragmentIdentifierFromIRIString(s, m_element->document())); >+ svgstyle->setMaskerResource(SVGURIReference::fragmentIdentifierFromIRIString(s, state.document())); > break; > } > case CSSPropertyClipPath: >@@ -456,7 +456,7 @@ void StyleResolver::applySVGProperty(CSSPropertyID id, CSSValue* value) > if (type == CSSPrimitiveValue::CSS_URI) > s = primitiveValue->getStringValue(); > >- svgstyle->setClipperResource(SVGURIReference::fragmentIdentifierFromIRIString(s, m_element->document())); >+ svgstyle->setClipperResource(SVGURIReference::fragmentIdentifierFromIRIString(s, state.document())); > break; > } > case CSSPropertyTextAnchor: >@@ -477,14 +477,14 @@ void StyleResolver::applySVGProperty(CSSPropertyID id, CSSValue* value) > { > HANDLE_INHERIT_AND_INITIAL(stopColor, StopColor); > if (value->isSVGColor()) >- svgstyle->setStopColor(colorFromSVGColorCSSValue(static_cast<SVGColor*>(value), m_style->color())); >+ svgstyle->setStopColor(colorFromSVGColorCSSValue(static_cast<SVGColor*>(value), state.style()->color())); > break; > } > case CSSPropertyLightingColor: > { > HANDLE_INHERIT_AND_INITIAL(lightingColor, LightingColor); > if (value->isSVGColor()) >- svgstyle->setLightingColor(colorFromSVGColorCSSValue(static_cast<SVGColor*>(value), m_style->color())); >+ svgstyle->setLightingColor(colorFromSVGColorCSSValue(static_cast<SVGColor*>(value), state.style()->color())); > break; > } > case CSSPropertyFloodOpacity: >@@ -509,7 +509,7 @@ void StyleResolver::applySVGProperty(CSSPropertyID id, CSSValue* value) > { > HANDLE_INHERIT_AND_INITIAL(floodColor, FloodColor); > if (value->isSVGColor()) >- svgstyle->setFloodColor(colorFromSVGColorCSSValue(static_cast<SVGColor*>(value), m_style->color())); >+ svgstyle->setFloodColor(colorFromSVGColorCSSValue(static_cast<SVGColor*>(value), state.style()->color())); > break; > } > case CSSPropertyGlyphOrientationHorizontal: >@@ -549,7 +549,7 @@ void StyleResolver::applySVGProperty(CSSPropertyID id, CSSValue* value) > break; > case CSSPropertyWebkitSvgShadow: { > if (isInherit) >- return svgstyle->setShadow(adoptPtr(m_parentStyle->svgStyle()->shadow() ? new ShadowData(*m_parentStyle->svgStyle()->shadow()) : 0)); >+ return svgstyle->setShadow(adoptPtr(state.parentStyle()->svgStyle()->shadow() ? new ShadowData(*state.parentStyle()->svgStyle()->shadow()) : 0)); > if (isInitial || primitiveValue) // initial | none > return svgstyle->setShadow(nullptr); > >@@ -564,12 +564,12 @@ void StyleResolver::applySVGProperty(CSSPropertyID id, CSSValue* value) > if (!firstValue->isShadowValue()) > return; > ShadowValue* item = static_cast<ShadowValue*>(firstValue); >- IntPoint location(item->x->computeLength<int>(style(), m_rootElementStyle), >- item->y->computeLength<int>(style(), m_rootElementStyle)); >- int blur = item->blur ? item->blur->computeLength<int>(style(), m_rootElementStyle) : 0; >+ IntPoint location(item->x->computeLength<int>(state.style(), state.rootElementStyle()), >+ item->y->computeLength<int>(state.style(), state.rootElementStyle())); >+ int blur = item->blur ? item->blur->computeLength<int>(state.style(), state.rootElementStyle()) : 0; > Color color; > if (item->color) >- color = colorFromPrimitiveValue(item->color.get()); >+ color = colorFromPrimitiveValue(state, item->color.get()); > > // -webkit-svg-shadow does should not have a spread or style > ASSERT(!item->spread); >diff --git a/Source/WebCore/css/SelectorChecker.cpp b/Source/WebCore/css/SelectorChecker.cpp >index 1f5e0c02481c9829bb69ba65f518359a4487ddeb..fbd37297b6a4e9e35ef2618fe166c384d4b8dc64 100644 >--- a/Source/WebCore/css/SelectorChecker.cpp >+++ b/Source/WebCore/css/SelectorChecker.cpp >@@ -69,19 +69,90 @@ SelectorChecker::SelectorChecker(Document* document) > { > } > >-bool SelectorChecker::matches(const CSSSelector* selector, Element* element, bool isFastCheckableSelector) const >+namespace { >+ >+static inline bool isFastCheckableRelation(CSSSelector::Relation relation) > { >- if (isFastCheckableSelector && !element->isSVGElement()) { >- if (!fastCheckRightmostSelector(selector, element, VisitedMatchDisabled)) >- return false; >- return fastCheck(selector, element); >+ return relation == CSSSelector::Descendant || relation == CSSSelector::Child || relation == CSSSelector::SubSelector; >+} >+ >+static inline bool isFastCheckableMatch(const CSSSelector* selector) >+{ >+ if (selector->m_match == CSSSelector::Set) { >+ // Style attribute is generated lazily but the fast path doesn't trigger it. >+ // Disallow them here rather than making the fast path more branchy. >+ return selector->attribute() != styleAttr; > } >+ if (selector->m_match == CSSSelector::Exact) >+ return selector->attribute() != styleAttr && HTMLDocument::isCaseSensitiveAttribute(selector->attribute()); >+ return selector->m_match == CSSSelector::Tag || selector->m_match == CSSSelector::Id || selector->m_match == CSSSelector::Class; >+} > >- PseudoId ignoreDynamicPseudo = NOPSEUDO; >- return match(SelectorCheckingContext(selector, element, SelectorChecker::VisitedMatchDisabled), ignoreDynamicPseudo, DOMSiblingTraversalStrategy()) == SelectorMatches; >+static inline bool isFastCheckableRightmostSelector(const CSSSelector* selector) >+{ >+ if (!isFastCheckableRelation(selector->relation())) >+ return false; >+ return isFastCheckableMatch(selector) || SelectorChecker::isCommonPseudoClassSelector(selector); > } > >-namespace { >+inline bool checkTagValue(const Element* element, const CSSSelector* selector) >+{ >+ return SelectorChecker::tagMatches(element, selector->tagQName()); >+} >+ >+inline bool checkClassValue(const Element* element, const CSSSelector* selector) >+{ >+ return element->hasClass() && static_cast<const StyledElement*>(element)->classNames().contains(selector->value().impl()); >+} >+ >+inline bool checkIDValue(const Element* element, const CSSSelector* selector) >+{ >+ return element->hasID() && element->idForStyleResolution().impl() == selector->value().impl(); >+} >+ >+inline bool checkExactAttributeValue(const Element* element, const CSSSelector* selector) >+{ >+ return SelectorChecker::checkExactAttribute(element, selector->attribute(), selector->value().impl()); >+} >+ >+inline bool commonPseudoClassSelectorMatches(const Element* element, const CSSSelector* selector, SelectorChecker::VisitedMatchType visitedMatchType) >+{ >+ ASSERT(SelectorChecker::isCommonPseudoClassSelector(selector)); >+ switch (selector->pseudoType()) { >+ case CSSSelector::PseudoLink: >+ case CSSSelector::PseudoAnyLink: >+ return element->isLink(); >+ case CSSSelector::PseudoVisited: >+ return element->isLink() && visitedMatchType == SelectorChecker::VisitedMatchEnabled; >+ case CSSSelector::PseudoFocus: >+ return matchesFocusPseudoClass(element); >+ default: >+ ASSERT_NOT_REACHED(); >+ } >+ return true; >+} >+ >+inline bool fastCheckRightmostSelector(const CSSSelector* selector, const Element* element, SelectorChecker::VisitedMatchType visitedMatchType) >+{ >+ ASSERT(SelectorChecker::isFastCheckableSelector(selector)); >+ >+ switch (selector->m_match) { >+ case CSSSelector::Tag: >+ return checkTagValue(element, selector); >+ case CSSSelector::Class: >+ return checkClassValue(element, selector); >+ case CSSSelector::Id: >+ return checkIDValue(element, selector); >+ case CSSSelector::Exact: >+ case CSSSelector::Set: >+ return checkExactAttributeValue(element, selector); >+ case CSSSelector::PseudoClass: >+ return commonPseudoClassSelectorMatches(element, selector, visitedMatchType); >+ default: >+ ASSERT_NOT_REACHED(); >+ } >+ return false; >+} > > template <bool checkValue(const Element*, const CSSSelector*)> > inline bool fastCheckSingleSelector(const CSSSelector*& selector, const Element*& element, const CSSSelector*& topChildOrSubselector, const Element*& topChildOrSubselectorMatchElement) >@@ -117,51 +188,34 @@ inline bool fastCheckSingleSelector(const CSSSelector*& selector, const Element* > return false; > } > >-inline bool checkClassValue(const Element* element, const CSSSelector* selector) >-{ >- return element->hasClass() && static_cast<const StyledElement*>(element)->classNames().contains(selector->value().impl()); > } > >-inline bool checkIDValue(const Element* element, const CSSSelector* selector) >-{ >- return element->hasID() && element->idForStyleResolution().impl() == selector->value().impl(); >-} >- >-inline bool checkExactAttributeValue(const Element* element, const CSSSelector* selector) >-{ >- return SelectorChecker::checkExactAttribute(element, selector->attribute(), selector->value().impl()); >-} >- >-inline bool checkTagValue(const Element* element, const CSSSelector* selector) >+bool SelectorChecker::isFastCheckableSelector(const CSSSelector* selector) > { >- return SelectorChecker::tagMatches(element, selector->tagQName()); >-} >- >+ if (!isFastCheckableRightmostSelector(selector)) >+ return false; >+ for (selector = selector->tagHistory(); selector; selector = selector->tagHistory()) { >+ if (!isFastCheckableRelation(selector->relation())) >+ return false; >+ if (!isFastCheckableMatch(selector)) >+ return false; >+ } >+ return true; > } > >-inline bool SelectorChecker::fastCheckRightmostSelector(const CSSSelector* selector, const Element* element, VisitedMatchType visitedMatchType) const >+bool SelectorChecker::matches(const CSSSelector* selector, Element* element, bool isFastCheckableSelector) const > { >- ASSERT(isFastCheckableSelector(selector)); >- >- switch (selector->m_match) { >- case CSSSelector::Tag: >- return checkTagValue(element, selector); >- case CSSSelector::Class: >- return checkClassValue(element, selector); >- case CSSSelector::Id: >- return checkIDValue(element, selector); >- case CSSSelector::Exact: >- case CSSSelector::Set: >- return checkExactAttributeValue(element, selector); >- case CSSSelector::PseudoClass: >- return commonPseudoClassSelectorMatches(element, selector, visitedMatchType); >- default: >- ASSERT_NOT_REACHED(); >+ if (isFastCheckableSelector && !element->isSVGElement()) { >+ if (!fastCheckRightmostSelector(selector, element, VisitedMatchDisabled)) >+ return false; >+ return fastCheck(selector, element); > } >- return false; >+ >+ PseudoId ignoreDynamicPseudo = NOPSEUDO; >+ return match(SelectorCheckingContext(selector, element, SelectorChecker::VisitedMatchDisabled), ignoreDynamicPseudo, DOMSiblingTraversalStrategy()) == SelectorMatches; > } > >-bool SelectorChecker::fastCheck(const CSSSelector* selector, const Element* element) const >+bool SelectorChecker::fastCheck(const CSSSelector* selector, const Element* element) > { > ASSERT(fastCheckRightmostSelector(selector, element, VisitedMatchEnabled)); > >@@ -202,43 +256,6 @@ bool SelectorChecker::fastCheck(const CSSSelector* selector, const Element* elem > return true; > } > >-static inline bool isFastCheckableRelation(CSSSelector::Relation relation) >-{ >- return relation == CSSSelector::Descendant || relation == CSSSelector::Child || relation == CSSSelector::SubSelector; >-} >- >-static inline bool isFastCheckableMatch(const CSSSelector* selector) >-{ >- if (selector->m_match == CSSSelector::Set) { >- // Style attribute is generated lazily but the fast path doesn't trigger it. >- // Disallow them here rather than making the fast path more branchy. >- return selector->attribute() != styleAttr; >- } >- if (selector->m_match == CSSSelector::Exact) >- return selector->attribute() != styleAttr && HTMLDocument::isCaseSensitiveAttribute(selector->attribute()); >- return selector->m_match == CSSSelector::Tag || selector->m_match == CSSSelector::Id || selector->m_match == CSSSelector::Class; >-} >- >-static inline bool isFastCheckableRightmostSelector(const CSSSelector* selector) >-{ >- if (!isFastCheckableRelation(selector->relation())) >- return false; >- return isFastCheckableMatch(selector) || SelectorChecker::isCommonPseudoClassSelector(selector); >-} >- >-bool SelectorChecker::isFastCheckableSelector(const CSSSelector* selector) >-{ >- if (!isFastCheckableRightmostSelector(selector)) >- return false; >- for (selector = selector->tagHistory(); selector; selector = selector->tagHistory()) { >- if (!isFastCheckableRelation(selector->relation())) >- return false; >- if (!isFastCheckableMatch(selector)) >- return false; >- } >- return true; >-} >- > // Recursive check of selectors and combinators > // It can return 4 different values: > // * SelectorMatches - the selector matches the element e >@@ -993,23 +1010,6 @@ bool SelectorChecker::checkScrollbarPseudoClass(Document* document, const CSSSel > } > } > >-bool SelectorChecker::commonPseudoClassSelectorMatches(const Element* element, const CSSSelector* selector, VisitedMatchType visitedMatchType) const >-{ >- ASSERT(isCommonPseudoClassSelector(selector)); >- switch (selector->pseudoType()) { >- case CSSSelector::PseudoLink: >- case CSSSelector::PseudoAnyLink: >- return element->isLink(); >- case CSSSelector::PseudoVisited: >- return element->isLink() && visitedMatchType == VisitedMatchEnabled; >- case CSSSelector::PseudoFocus: >- return matchesFocusPseudoClass(element); >- default: >- ASSERT_NOT_REACHED(); >- } >- return true; >-} >- > unsigned SelectorChecker::determineLinkMatchType(const CSSSelector* selector) > { > unsigned linkMatchType = MatchAll; >@@ -1055,11 +1055,6 @@ unsigned SelectorChecker::determineLinkMatchType(const CSSSelector* selector) > return linkMatchType; > } > >-bool SelectorChecker::isFrameFocused(const Element* element) >-{ >- return element->document()->frame() && element->document()->frame()->selection()->isFocusedAndActive(); >-} >- > template > SelectorChecker::Match SelectorChecker::match(const SelectorCheckingContext&, PseudoId&, const DOMSiblingTraversalStrategy&) const; > >diff --git a/Source/WebCore/css/SelectorChecker.h b/Source/WebCore/css/SelectorChecker.h >index 3939bc354e4a3cd723477f38ef62afdc4d6feefb..6d62953a882fc6b6f2d6495cba754dbc008bb168 100644 >--- a/Source/WebCore/css/SelectorChecker.h >+++ b/Source/WebCore/css/SelectorChecker.h >@@ -82,7 +82,7 @@ public: > bool checkOne(const SelectorCheckingContext&, const SiblingTraversalStrategy&) const; > > static bool isFastCheckableSelector(const CSSSelector*); >- bool fastCheck(const CSSSelector*, const Element*) const; >+ static bool fastCheck(const CSSSelector*, const Element*); > > bool strictParsing() const { return m_strictParsing; } > >@@ -91,7 +91,6 @@ public: > > static bool tagMatches(const Element*, const QualifiedName&); > static bool isCommonPseudoClassSelector(const CSSSelector*); >- bool matchesFocusPseudoClass(const Element*) const; > static bool fastCheckRightmostAttributeSelector(const Element*, const CSSSelector*); > static bool checkExactAttribute(const Element*, const QualifiedName& selectorAttributeName, const AtomicStringImpl* value); > >@@ -100,10 +99,6 @@ public: > > private: > bool checkScrollbarPseudoClass(Document*, const CSSSelector*) const; >- static bool isFrameFocused(const Element*); >- >- bool fastCheckRightmostSelector(const CSSSelector*, const Element*, VisitedMatchType) const; >- bool commonPseudoClassSelectorMatches(const Element*, const CSSSelector*, VisitedMatchType) const; > > bool m_strictParsing; > bool m_documentIsHTML; >@@ -121,7 +116,12 @@ inline bool SelectorChecker::isCommonPseudoClassSelector(const CSSSelector* sele > || pseudoType == CSSSelector::PseudoFocus; > } > >-inline bool SelectorChecker::matchesFocusPseudoClass(const Element* element) const >+inline bool isFrameFocused(const Element* element) >+{ >+ return element->document()->frame() && element->document()->frame()->selection()->isFocusedAndActive(); >+} >+ >+inline bool matchesFocusPseudoClass(const Element* element) > { > if (InspectorInstrumentation::forcePseudoState(const_cast<Element*>(element), CSSSelector::PseudoFocus)) > return true; >diff --git a/Source/WebCore/css/StyleBuilder.cpp b/Source/WebCore/css/StyleBuilder.cpp >index 6d78c684442cc7e24ebf9a62867bd8899fe798e6..c3365ea80ea9bda7fde4184197946ef9ccb3052e 100644 >--- a/Source/WebCore/css/StyleBuilder.cpp >+++ b/Source/WebCore/css/StyleBuilder.cpp >@@ -61,7 +61,7 @@ class ApplyPropertyExpanding { > public: > > template <CSSPropertyID id> >- static inline void applyInheritValue(CSSPropertyID propertyID, StyleResolver* styleResolver) >+ static inline void applyInheritValue(CSSPropertyID propertyID, StyleResolveState& state) > { > if (id == CSSPropertyInvalid) > return; >@@ -69,20 +69,20 @@ public: > const StyleBuilder& table = StyleBuilder::sharedStyleBuilder(); > const PropertyHandler& handler = table.propertyHandler(id); > if (handler.isValid()) >- handler.applyInheritValue(propertyID, styleResolver); >+ handler.applyInheritValue(propertyID, state); > } > >- static void applyInheritValue(CSSPropertyID propertyID, StyleResolver* styleResolver) >+ static void applyInheritValue(CSSPropertyID propertyID, StyleResolveState& state) > { >- applyInheritValue<one>(propertyID, styleResolver); >- applyInheritValue<two>(propertyID, styleResolver); >- applyInheritValue<three>(propertyID, styleResolver); >- applyInheritValue<four>(propertyID, styleResolver); >- applyInheritValue<five>(propertyID, styleResolver); >+ applyInheritValue<one>(propertyID, state); >+ applyInheritValue<two>(propertyID, state); >+ applyInheritValue<three>(propertyID, state); >+ applyInheritValue<four>(propertyID, state); >+ applyInheritValue<five>(propertyID, state); > } > > template <CSSPropertyID id> >- static inline void applyInitialValue(CSSPropertyID propertyID, StyleResolver* styleResolver) >+ static inline void applyInitialValue(CSSPropertyID propertyID, StyleResolveState& state) > { > if (id == CSSPropertyInvalid) > return; >@@ -90,20 +90,20 @@ public: > const StyleBuilder& table = StyleBuilder::sharedStyleBuilder(); > const PropertyHandler& handler = table.propertyHandler(id); > if (handler.isValid()) >- handler.applyInitialValue(propertyID, styleResolver); >+ handler.applyInitialValue(propertyID, state); > } > >- static void applyInitialValue(CSSPropertyID propertyID, StyleResolver* styleResolver) >+ static void applyInitialValue(CSSPropertyID propertyID, StyleResolveState& state) > { >- applyInitialValue<one>(propertyID, styleResolver); >- applyInitialValue<two>(propertyID, styleResolver); >- applyInitialValue<three>(propertyID, styleResolver); >- applyInitialValue<four>(propertyID, styleResolver); >- applyInitialValue<five>(propertyID, styleResolver); >+ applyInitialValue<one>(propertyID, state); >+ applyInitialValue<two>(propertyID, state); >+ applyInitialValue<three>(propertyID, state); >+ applyInitialValue<four>(propertyID, state); >+ applyInitialValue<five>(propertyID, state); > } > > template <CSSPropertyID id> >- static inline void applyValue(CSSPropertyID propertyID, StyleResolver* styleResolver, CSSValue* value) >+ static inline void applyValue(CSSPropertyID propertyID, StyleResolveState& state, CSSValue* value) > { > if (id == CSSPropertyInvalid) > return; >@@ -111,19 +111,19 @@ public: > const StyleBuilder& table = StyleBuilder::sharedStyleBuilder(); > const PropertyHandler& handler = table.propertyHandler(id); > if (handler.isValid()) >- handler.applyValue(propertyID, styleResolver, value); >+ handler.applyValue(propertyID, state, value); > } > >- static void applyValue(CSSPropertyID propertyID, StyleResolver* styleResolver, CSSValue* value) >+ static void applyValue(CSSPropertyID propertyID, StyleResolveState& state, CSSValue* value) > { > if (!expandValue) > return; > >- applyValue<one>(propertyID, styleResolver, value); >- applyValue<two>(propertyID, styleResolver, value); >- applyValue<three>(propertyID, styleResolver, value); >- applyValue<four>(propertyID, styleResolver, value); >- applyValue<five>(propertyID, styleResolver, value); >+ applyValue<one>(propertyID, state, value); >+ applyValue<two>(propertyID, state, value); >+ applyValue<three>(propertyID, state, value); >+ applyValue<four>(propertyID, state, value); >+ applyValue<five>(propertyID, state, value); > } > static PropertyHandler createHandler() { return PropertyHandler(&applyInheritValue, &applyInitialValue, &applyValue); } > }; >@@ -134,9 +134,9 @@ public: > static void setValue(RenderStyle* style, SetterType value) { (style->*setterFunction)(value); } > static GetterType value(RenderStyle* style) { return (style->*getterFunction)(); } > static InitialType initial() { return (*initialFunction)(); } >- static void applyInheritValue(CSSPropertyID, StyleResolver* styleResolver) { setValue(styleResolver->style(), value(styleResolver->parentStyle())); } >- static void applyInitialValue(CSSPropertyID, StyleResolver* styleResolver) { setValue(styleResolver->style(), initial()); } >- static void applyValue(CSSPropertyID, StyleResolver*, CSSValue*) { } >+ static void applyInheritValue(CSSPropertyID, StyleResolveState& state) { setValue(state.style(), value(state.parentStyle())); } >+ static void applyInitialValue(CSSPropertyID, StyleResolveState& state) { setValue(state.style(), initial()); } >+ static void applyValue(CSSPropertyID, StyleResolveState&, CSSValue*) { } > static PropertyHandler createHandler() { return PropertyHandler(&applyInheritValue, &applyInitialValue, &applyValue); } > }; > >@@ -144,10 +144,10 @@ template <typename GetterType, GetterType (RenderStyle::*getterFunction)() const > class ApplyPropertyDefault { > public: > static void setValue(RenderStyle* style, SetterType value) { (style->*setterFunction)(value); } >- static void applyValue(CSSPropertyID, StyleResolver* styleResolver, CSSValue* value) >+ static void applyValue(CSSPropertyID, StyleResolveState& state, CSSValue* value) > { > if (value->isPrimitiveValue()) >- setValue(styleResolver->style(), *static_cast<CSSPrimitiveValue*>(value)); >+ setValue(state.style(), *static_cast<CSSPrimitiveValue*>(value)); > } > static PropertyHandler createHandler() > { >@@ -160,16 +160,16 @@ template <typename NumberType, NumberType (RenderStyle::*getterFunction)() const > class ApplyPropertyNumber { > public: > static void setValue(RenderStyle* style, NumberType value) { (style->*setterFunction)(value); } >- static void applyValue(CSSPropertyID, StyleResolver* styleResolver, CSSValue* value) >+ static void applyValue(CSSPropertyID, StyleResolveState& state, CSSValue* value) > { > if (!value->isPrimitiveValue()) > return; > > CSSPrimitiveValue* primitiveValue = static_cast<CSSPrimitiveValue*>(value); > if (primitiveValue->getIdent() == idMapsToMinusOne) >- setValue(styleResolver->style(), -1); >+ setValue(state.style(), -1); > else >- setValue(styleResolver->style(), primitiveValue->getValue<NumberType>(CSSPrimitiveValue::CSS_NUMBER)); >+ setValue(state.style(), primitiveValue->getValue<NumberType>(CSSPrimitiveValue::CSS_NUMBER)); > } > static PropertyHandler createHandler() > { >@@ -181,7 +181,7 @@ public: > template <StyleImage* (RenderStyle::*getterFunction)() const, void (RenderStyle::*setterFunction)(PassRefPtr<StyleImage>), StyleImage* (*initialFunction)(), CSSPropertyID property> > class ApplyPropertyStyleImage { > public: >- static void applyValue(CSSPropertyID, StyleResolver* styleResolver, CSSValue* value) { (styleResolver->style()->*setterFunction)(styleResolver->styleImage(property, value)); } >+ static void applyValue(CSSPropertyID, StyleResolveState& state, CSSValue* value) { (state.style()->*setterFunction)(StyleResolver::styleImage(state, property, value)); } > static PropertyHandler createHandler() > { > PropertyHandler handler = ApplyPropertyDefaultBase<StyleImage*, getterFunction, PassRefPtr<StyleImage>, setterFunction, StyleImage*, initialFunction>::createHandler(); >@@ -198,28 +198,28 @@ public: > static bool hasAuto(RenderStyle* style) { return (style->*hasAutoFunction)(); } > static void setAuto(RenderStyle* style) { (style->*setAutoFunction)(); } > >- static void applyInheritValue(CSSPropertyID, StyleResolver* styleResolver) >+ static void applyInheritValue(CSSPropertyID, StyleResolveState& state) > { >- if (hasAuto(styleResolver->parentStyle())) >- setAuto(styleResolver->style()); >+ if (hasAuto(state.parentStyle())) >+ setAuto(state.style()); > else >- setValue(styleResolver->style(), value(styleResolver->parentStyle())); >+ setValue(state.style(), value(state.parentStyle())); > } > >- static void applyInitialValue(CSSPropertyID, StyleResolver* styleResolver) { setAuto(styleResolver->style()); } >+ static void applyInitialValue(CSSPropertyID, StyleResolveState& state) { setAuto(state.style()); } > >- static void applyValue(CSSPropertyID, StyleResolver* styleResolver, CSSValue* value) >+ static void applyValue(CSSPropertyID, StyleResolveState& state, CSSValue* value) > { > if (!value->isPrimitiveValue()) > return; > > CSSPrimitiveValue* primitiveValue = static_cast<CSSPrimitiveValue*>(value); > if (primitiveValue->getIdent() == autoIdentity) >- setAuto(styleResolver->style()); >+ setAuto(state.style()); > else if (valueType == Number) >- setValue(styleResolver->style(), *primitiveValue); >+ setValue(state.style(), *primitiveValue); > else if (valueType == ComputeLength) >- setValue(styleResolver->style(), primitiveValue->computeLength<T>(styleResolver->style(), styleResolver->rootElementStyle(), styleResolver->style()->effectiveZoom())); >+ setValue(state.style(), primitiveValue->computeLength<T>(state.style(), state.rootElementStyle(), state.style()->effectiveZoom())); > } > > static PropertyHandler createHandler() { return PropertyHandler(&applyInheritValue, &applyInitialValue, &applyValue); } >@@ -227,27 +227,27 @@ public: > > class ApplyPropertyClip { > private: >- static Length convertToLength(StyleResolver* styleResolver, CSSPrimitiveValue* value) >+ static Length convertToLength(StyleResolveState& state, CSSPrimitiveValue* value) > { >- return value->convertToLength<FixedIntegerConversion | PercentConversion | FractionConversion | AutoConversion>(styleResolver->style(), styleResolver->rootElementStyle(), styleResolver->style()->effectiveZoom()); >+ return value->convertToLength<FixedIntegerConversion | PercentConversion | FractionConversion | AutoConversion>(state.style(), state.rootElementStyle(), state.style()->effectiveZoom()); > } > public: >- static void applyInheritValue(CSSPropertyID propertyID, StyleResolver* styleResolver) >+ static void applyInheritValue(CSSPropertyID propertyID, StyleResolveState& state) > { >- RenderStyle* parentStyle = styleResolver->parentStyle(); >+ RenderStyle* parentStyle = state.parentStyle(); > if (!parentStyle->hasClip()) >- return applyInitialValue(propertyID, styleResolver); >- styleResolver->style()->setClip(parentStyle->clipTop(), parentStyle->clipRight(), parentStyle->clipBottom(), parentStyle->clipLeft()); >- styleResolver->style()->setHasClip(true); >+ return applyInitialValue(propertyID, state); >+ state.style()->setClip(parentStyle->clipTop(), parentStyle->clipRight(), parentStyle->clipBottom(), parentStyle->clipLeft()); >+ state.style()->setHasClip(true); > } > >- static void applyInitialValue(CSSPropertyID, StyleResolver* styleResolver) >+ static void applyInitialValue(CSSPropertyID, StyleResolveState& state) > { >- styleResolver->style()->setClip(Length(), Length(), Length(), Length()); >- styleResolver->style()->setHasClip(false); >+ state.style()->setClip(Length(), Length(), Length(), Length()); >+ state.style()->setHasClip(false); > } > >- static void applyValue(CSSPropertyID, StyleResolver* styleResolver, CSSValue* value) >+ static void applyValue(CSSPropertyID, StyleResolveState& state, CSSValue* value) > { > if (!value->isPrimitiveValue()) > return; >@@ -255,15 +255,15 @@ public: > CSSPrimitiveValue* primitiveValue = static_cast<CSSPrimitiveValue*>(value); > > if (Rect* rect = primitiveValue->getRectValue()) { >- Length top = convertToLength(styleResolver, rect->top()); >- Length right = convertToLength(styleResolver, rect->right()); >- Length bottom = convertToLength(styleResolver, rect->bottom()); >- Length left = convertToLength(styleResolver, rect->left()); >- styleResolver->style()->setClip(top, right, bottom, left); >- styleResolver->style()->setHasClip(true); >+ Length top = convertToLength(state, rect->top()); >+ Length right = convertToLength(state, rect->right()); >+ Length bottom = convertToLength(state, rect->bottom()); >+ Length left = convertToLength(state, rect->left()); >+ state.style()->setClip(top, right, bottom, left); >+ state.style()->setHasClip(true); > } else if (primitiveValue->getIdent() == CSSValueAuto) { >- styleResolver->style()->setClip(Length(), Length(), Length(), Length()); >- styleResolver->style()->setHasClip(false); >+ state.style()->setClip(Length(), Length(), Length(), Length()); >+ state.style()->setHasClip(false); > } > } > >@@ -281,40 +281,40 @@ template <ColorInherit inheritColorFromParent, > Color (*initialFunction)() = &defaultInitialColor> > class ApplyPropertyColor { > public: >- static void applyInheritValue(CSSPropertyID, StyleResolver* styleResolver) >+ static void applyInheritValue(CSSPropertyID, StyleResolveState& state) > { > // Visited link style can never explicitly inherit from parent visited link style so no separate getters are needed. >- Color color = (styleResolver->parentStyle()->*getterFunction)(); >- applyColorValue(styleResolver, color.isValid() ? color : (styleResolver->parentStyle()->*defaultFunction)()); >+ Color color = (state.parentStyle()->*getterFunction)(); >+ applyColorValue(state, color.isValid() ? color : (state.parentStyle()->*defaultFunction)()); > } > >- static void applyInitialValue(CSSPropertyID, StyleResolver* styleResolver) >+ static void applyInitialValue(CSSPropertyID, StyleResolveState& state) > { >- applyColorValue(styleResolver, initialFunction()); >+ applyColorValue(state, initialFunction()); > } > >- static void applyValue(CSSPropertyID propertyID, StyleResolver* styleResolver, CSSValue* value) >+ static void applyValue(CSSPropertyID propertyID, StyleResolveState& state, CSSValue* value) > { > if (!value->isPrimitiveValue()) > return; > > CSSPrimitiveValue* primitiveValue = static_cast<CSSPrimitiveValue*>(value); > if (inheritColorFromParent && primitiveValue->getIdent() == CSSValueCurrentcolor) >- applyInheritValue(propertyID, styleResolver); >+ applyInheritValue(propertyID, state); > else { >- if (styleResolver->applyPropertyToRegularStyle()) >- (styleResolver->style()->*setterFunction)(styleResolver->colorFromPrimitiveValue(primitiveValue)); >- if (styleResolver->applyPropertyToVisitedLinkStyle()) >- (styleResolver->style()->*visitedLinkSetterFunction)(styleResolver->colorFromPrimitiveValue(primitiveValue, /* forVisitedLink */ true)); >+ if (state.applyPropertyToRegularStyle()) >+ (state.style()->*setterFunction)(StyleResolver::colorFromPrimitiveValue(state, primitiveValue)); >+ if (state.applyPropertyToVisitedLinkStyle()) >+ (state.style()->*visitedLinkSetterFunction)(StyleResolver::colorFromPrimitiveValue(state, primitiveValue, /* forVisitedLink */ true)); > } > } > >- static void applyColorValue(StyleResolver* styleResolver, const Color& color) >+ static void applyColorValue(StyleResolveState& state, const Color& color) > { >- if (styleResolver->applyPropertyToRegularStyle()) >- (styleResolver->style()->*setterFunction)(color); >- if (styleResolver->applyPropertyToVisitedLinkStyle()) >- (styleResolver->style()->*visitedLinkSetterFunction)(color); >+ if (state.applyPropertyToRegularStyle()) >+ (state.style()->*setterFunction)(color); >+ if (state.applyPropertyToVisitedLinkStyle()) >+ (state.style()->*visitedLinkSetterFunction)(color); > } > > static PropertyHandler createHandler() { return PropertyHandler(&applyInheritValue, &applyInitialValue, &applyValue); } >@@ -323,11 +323,11 @@ public: > template <TextDirection (RenderStyle::*getterFunction)() const, void (RenderStyle::*setterFunction)(TextDirection), TextDirection (*initialFunction)()> > class ApplyPropertyDirection { > public: >- static void applyValue(CSSPropertyID propertyID, StyleResolver* styleResolver, CSSValue* value) >+ static void applyValue(CSSPropertyID propertyID, StyleResolveState& state, CSSValue* value) > { >- ApplyPropertyDefault<TextDirection, getterFunction, TextDirection, setterFunction, TextDirection, initialFunction>::applyValue(propertyID, styleResolver, value); >- Element* element = styleResolver->element(); >- if (element && styleResolver->element() == element->document()->documentElement()) >+ ApplyPropertyDefault<TextDirection, getterFunction, TextDirection, setterFunction, TextDirection, initialFunction>::applyValue(propertyID, state, value); >+ Element* element = state.element(); >+ if (element && element == element->document()->documentElement()) > element->document()->setDirectionSetOnDocumentElement(true); > } > >@@ -354,7 +354,7 @@ template <Length (RenderStyle::*getterFunction)() const, > class ApplyPropertyLength { > public: > static void setValue(RenderStyle* style, Length value) { (style->*setterFunction)(value); } >- static void applyValue(CSSPropertyID, StyleResolver* styleResolver, CSSValue* value) >+ static void applyValue(CSSPropertyID, StyleResolveState& state, CSSValue* value) > { > if (!value->isPrimitiveValue()) > return; >@@ -362,39 +362,39 @@ public: > CSSPrimitiveValue* primitiveValue = static_cast<CSSPrimitiveValue*>(value); > if (noneEnabled && primitiveValue->getIdent() == CSSValueNone) { > if (noneUndefined) >- setValue(styleResolver->style(), Length(Undefined)); >+ setValue(state.style(), Length(Undefined)); > else >- setValue(styleResolver->style(), Length()); >+ setValue(state.style(), Length()); > } > if (legacyIntrinsicEnabled) { > if (primitiveValue->getIdent() == CSSValueIntrinsic) >- setValue(styleResolver->style(), Length(Intrinsic)); >+ setValue(state.style(), Length(Intrinsic)); > else if (primitiveValue->getIdent() == CSSValueMinIntrinsic) >- setValue(styleResolver->style(), Length(MinIntrinsic)); >+ setValue(state.style(), Length(MinIntrinsic)); > } > if (intrinsicEnabled) { > if (primitiveValue->getIdent() == CSSValueWebkitMinContent) >- setValue(styleResolver->style(), Length(MinContent)); >+ setValue(state.style(), Length(MinContent)); > else if (primitiveValue->getIdent() == CSSValueWebkitMaxContent) >- setValue(styleResolver->style(), Length(MaxContent)); >+ setValue(state.style(), Length(MaxContent)); > else if (primitiveValue->getIdent() == CSSValueWebkitFillAvailable) >- setValue(styleResolver->style(), Length(FillAvailable)); >+ setValue(state.style(), Length(FillAvailable)); > else if (primitiveValue->getIdent() == CSSValueWebkitFitContent) >- setValue(styleResolver->style(), Length(FitContent)); >+ setValue(state.style(), Length(FitContent)); > } > > if (autoEnabled && primitiveValue->getIdent() == CSSValueAuto) >- setValue(styleResolver->style(), Length()); >+ setValue(state.style(), Length()); > else if (primitiveValue->isLength()) { >- Length length = primitiveValue->computeLength<Length>(styleResolver->style(), styleResolver->rootElementStyle(), styleResolver->style()->effectiveZoom()); >+ Length length = primitiveValue->computeLength<Length>(state.style(), state.rootElementStyle(), state.style()->effectiveZoom()); > length.setQuirk(primitiveValue->isQuirkValue()); >- setValue(styleResolver->style(), length); >+ setValue(state.style(), length); > } else if (primitiveValue->isPercentage()) >- setValue(styleResolver->style(), Length(primitiveValue->getDoubleValue(), Percent)); >+ setValue(state.style(), Length(primitiveValue->getDoubleValue(), Percent)); > else if (primitiveValue->isCalculatedPercentageWithLength()) >- setValue(styleResolver->style(), Length(primitiveValue->cssCalcValue()->toCalcValue(styleResolver->style(), styleResolver->rootElementStyle(), styleResolver->style()->effectiveZoom()))); >+ setValue(state.style(), Length(primitiveValue->cssCalcValue()->toCalcValue(state.style(), state.rootElementStyle(), state.style()->effectiveZoom()))); > else if (primitiveValue->isViewportPercentageLength()) >- setValue(styleResolver->style(), primitiveValue->viewportPercentageLength()); >+ setValue(state.style(), primitiveValue->viewportPercentageLength()); > } > > static PropertyHandler createHandler() >@@ -409,16 +409,16 @@ template <StringIdentBehavior identBehavior, const AtomicString& (RenderStyle::* > class ApplyPropertyString { > public: > static void setValue(RenderStyle* style, const AtomicString& value) { (style->*setterFunction)(value); } >- static void applyValue(CSSPropertyID, StyleResolver* styleResolver, CSSValue* value) >+ static void applyValue(CSSPropertyID, StyleResolveState& state, CSSValue* value) > { > if (!value->isPrimitiveValue()) > return; > CSSPrimitiveValue* primitiveValue = static_cast<CSSPrimitiveValue*>(value); > if ((identBehavior == MapNoneToNull && primitiveValue->getIdent() == CSSValueNone) > || (identBehavior == MapAutoToNull && primitiveValue->getIdent() == CSSValueAuto)) >- setValue(styleResolver->style(), nullAtom); >+ setValue(state.style(), nullAtom); > else >- setValue(styleResolver->style(), primitiveValue->getStringValue()); >+ setValue(state.style(), primitiveValue->getStringValue()); > } > static PropertyHandler createHandler() > { >@@ -431,7 +431,7 @@ template <LengthSize (RenderStyle::*getterFunction)() const, void (RenderStyle:: > class ApplyPropertyBorderRadius { > public: > static void setValue(RenderStyle* style, LengthSize value) { (style->*setterFunction)(value); } >- static void applyValue(CSSPropertyID, StyleResolver* styleResolver, CSSValue* value) >+ static void applyValue(CSSPropertyID, StyleResolveState& state, CSSValue* value) > { > if (!value->isPrimitiveValue()) > return; >@@ -448,17 +448,17 @@ public: > else if (pair->first()->isViewportPercentageLength()) > radiusWidth = pair->first()->viewportPercentageLength(); > else if (pair->first()->isCalculatedPercentageWithLength()) >- radiusWidth = Length((pair->first()->cssCalcValue()->toCalcValue(styleResolver->style(), styleResolver->rootElementStyle(), styleResolver->style()->effectiveZoom()))); >+ radiusWidth = Length((pair->first()->cssCalcValue()->toCalcValue(state.style(), state.rootElementStyle(), state.style()->effectiveZoom()))); > else >- radiusWidth = pair->first()->computeLength<Length>(styleResolver->style(), styleResolver->rootElementStyle(), styleResolver->style()->effectiveZoom()); >+ radiusWidth = pair->first()->computeLength<Length>(state.style(), state.rootElementStyle(), state.style()->effectiveZoom()); > if (pair->second()->isPercentage()) > radiusHeight = Length(pair->second()->getDoubleValue(), Percent); > else if (pair->second()->isViewportPercentageLength()) > radiusHeight = pair->second()->viewportPercentageLength(); > else if (pair->second()->isCalculatedPercentageWithLength()) >- radiusHeight = Length((pair->second()->cssCalcValue()->toCalcValue(styleResolver->style(), styleResolver->rootElementStyle(), styleResolver->style()->effectiveZoom()))); >+ radiusHeight = Length((pair->second()->cssCalcValue()->toCalcValue(state.style(), state.rootElementStyle(), state.style()->effectiveZoom()))); > else >- radiusHeight = pair->second()->computeLength<Length>(styleResolver->style(), styleResolver->rootElementStyle(), styleResolver->style()->effectiveZoom()); >+ radiusHeight = pair->second()->computeLength<Length>(state.style(), state.rootElementStyle(), state.style()->effectiveZoom()); > int width = radiusWidth.value(); > int height = radiusHeight.value(); > if (width < 0 || height < 0) >@@ -469,7 +469,7 @@ public: > radiusWidth = radiusHeight; // Null out the other value. > > LengthSize size(radiusWidth, radiusHeight); >- setValue(styleResolver->style(), size); >+ setValue(state.style(), size); > } > static PropertyHandler createHandler() > { >@@ -491,23 +491,23 @@ struct FillLayerAccessorTypes<StyleImage*> { > }; > > template <typename T, >- CSSPropertyID propertyId, >- EFillLayerType fillLayerType, >- FillLayer* (RenderStyle::*accessLayersFunction)(), >- const FillLayer* (RenderStyle::*layersFunction)() const, >- bool (FillLayer::*testFunction)() const, >- typename FillLayerAccessorTypes<T>::Getter (FillLayer::*getFunction)() const, >- void (FillLayer::*setFunction)(typename FillLayerAccessorTypes<T>::Setter), >- void (FillLayer::*clearFunction)(), >- typename FillLayerAccessorTypes<T>::Getter (*initialFunction)(EFillLayerType), >- void (CSSToStyleMap::*mapFillFunction)(CSSPropertyID, FillLayer*, CSSValue*)> >+ CSSPropertyID propertyId, >+ EFillLayerType fillLayerType, >+ FillLayer* (RenderStyle::*accessLayersFunction)(), >+ const FillLayer* (RenderStyle::*layersFunction)() const, >+ bool (FillLayer::*testFunction)() const, >+ typename FillLayerAccessorTypes<T>::Getter (FillLayer::*getFunction)() const, >+ void (FillLayer::*setFunction)(typename FillLayerAccessorTypes<T>::Setter), >+ void (FillLayer::*clearFunction)(), >+ typename FillLayerAccessorTypes<T>::Getter (*initialFunction)(EFillLayerType), >+ void (*mapFillFunction)(StyleResolveState&, CSSPropertyID, FillLayer*, CSSValue*)> > class ApplyPropertyFillLayer { > public: >- static void applyInheritValue(CSSPropertyID, StyleResolver* styleResolver) >+ static void applyInheritValue(CSSPropertyID, StyleResolveState& state) > { >- FillLayer* currChild = (styleResolver->style()->*accessLayersFunction)(); >+ FillLayer* currChild = (state.style()->*accessLayersFunction)(); > FillLayer* prevChild = 0; >- const FillLayer* currParent = (styleResolver->parentStyle()->*layersFunction)(); >+ const FillLayer* currParent = (state.parentStyle()->*layersFunction)(); > while (currParent && (currParent->*testFunction)()) { > if (!currChild) { > /* Need to make a new layer.*/ >@@ -527,17 +527,17 @@ public: > } > } > >- static void applyInitialValue(CSSPropertyID, StyleResolver* styleResolver) >+ static void applyInitialValue(CSSPropertyID, StyleResolveState& state) > { >- FillLayer* currChild = (styleResolver->style()->*accessLayersFunction)(); >+ FillLayer* currChild = (state.style()->*accessLayersFunction)(); > (currChild->*setFunction)((*initialFunction)(fillLayerType)); > for (currChild = currChild->next(); currChild; currChild = currChild->next()) > (currChild->*clearFunction)(); > } > >- static void applyValue(CSSPropertyID, StyleResolver* styleResolver, CSSValue* value) >+ static void applyValue(CSSPropertyID, StyleResolveState& state, CSSValue* value) > { >- FillLayer* currChild = (styleResolver->style()->*accessLayersFunction)(); >+ FillLayer* currChild = (state.style()->*accessLayersFunction)(); > FillLayer* prevChild = 0; > if (value->isValueList() > #if ENABLE(CSS_IMAGE_SET) >@@ -552,12 +552,12 @@ public: > currChild = new FillLayer(fillLayerType); > prevChild->setNext(currChild); > } >- (styleResolver->styleMap()->*mapFillFunction)(propertyId, currChild, valueList->itemWithoutBoundsCheck(i)); >+ (*mapFillFunction)(state, propertyId, currChild, valueList->itemWithoutBoundsCheck(i)); > prevChild = currChild; > currChild = currChild->next(); > } > } else { >- (styleResolver->styleMap()->*mapFillFunction)(propertyId, currChild, value); >+ (*mapFillFunction)(state, propertyId, currChild, value); > currChild = currChild->next(); > } > while (currChild) { >@@ -583,7 +583,7 @@ template <typename T, > class ApplyPropertyComputeLength { > public: > static void setValue(RenderStyle* style, T value) { (style->*setterFunction)(value); } >- static void applyValue(CSSPropertyID, StyleResolver* styleResolver, CSSValue* value) >+ static void applyValue(CSSPropertyID, StyleResolveState& state, CSSValue* value) > { > // note: CSSPropertyLetter/WordSpacing right now sets to zero if it's not a primitive value for some reason... > if (!value->isPrimitiveValue()) >@@ -602,13 +602,13 @@ public: > } else if (thicknessEnabled && ident == CSSValueThick) { > length = 5; > } else if (ident == CSSValueInvalid) { >- float zoom = (svgZoomEnabled && styleResolver->useSVGZoomRules()) ? 1.0f : styleResolver->style()->effectiveZoom(); >+ float zoom = (svgZoomEnabled && state.useSVGZoomRules()) ? 1.0f : state.style()->effectiveZoom(); > > // Any original result that was >= 1 should not be allowed to fall below 1. > // This keeps border lines from vanishing. >- length = primitiveValue->computeLength<T>(styleResolver->style(), styleResolver->rootElementStyle(), zoom); >+ length = primitiveValue->computeLength<T>(state.style(), state.rootElementStyle(), zoom); > if (zoom < 1.0f && length < 1.0) { >- T originalLength = primitiveValue->computeLength<T>(styleResolver->style(), styleResolver->rootElementStyle(), 1.0); >+ T originalLength = primitiveValue->computeLength<T>(state.style(), state.rootElementStyle(), 1.0); > if (originalLength >= 1.0) > length = 1.0; > } >@@ -618,7 +618,7 @@ public: > length = 0; > } > >- setValue(styleResolver->style(), length); >+ setValue(state.style(), length); > } > static PropertyHandler createHandler() > { >@@ -630,28 +630,28 @@ public: > template <typename T, T (FontDescription::*getterFunction)() const, void (FontDescription::*setterFunction)(T), T initialValue> > class ApplyPropertyFont { > public: >- static void applyInheritValue(CSSPropertyID, StyleResolver* styleResolver) >+ static void applyInheritValue(CSSPropertyID, StyleResolveState& state) > { >- FontDescription fontDescription = styleResolver->fontDescription(); >- (fontDescription.*setterFunction)((styleResolver->parentFontDescription().*getterFunction)()); >- styleResolver->setFontDescription(fontDescription); >+ FontDescription fontDescription = state.fontDescription(); >+ (fontDescription.*setterFunction)((state.parentFontDescription().*getterFunction)()); >+ state.setFontDescription(fontDescription); > } > >- static void applyInitialValue(CSSPropertyID, StyleResolver* styleResolver) >+ static void applyInitialValue(CSSPropertyID, StyleResolveState& state) > { >- FontDescription fontDescription = styleResolver->fontDescription(); >+ FontDescription fontDescription = state.fontDescription(); > (fontDescription.*setterFunction)(initialValue); >- styleResolver->setFontDescription(fontDescription); >+ state.setFontDescription(fontDescription); > } > >- static void applyValue(CSSPropertyID, StyleResolver* styleResolver, CSSValue* value) >+ static void applyValue(CSSPropertyID, StyleResolveState& state, CSSValue* value) > { > if (!value->isPrimitiveValue()) > return; > CSSPrimitiveValue* primitiveValue = static_cast<CSSPrimitiveValue*>(value); >- FontDescription fontDescription = styleResolver->fontDescription(); >+ FontDescription fontDescription = state.fontDescription(); > (fontDescription.*setterFunction)(*primitiveValue); >- styleResolver->setFontDescription(fontDescription); >+ state.setFontDescription(fontDescription); > } > > static PropertyHandler createHandler() { return PropertyHandler(&applyInheritValue, &applyInitialValue, &applyValue); } >@@ -676,50 +676,50 @@ private: > return size / 1.2f; > } > public: >- static void applyInheritValue(CSSPropertyID, StyleResolver* styleResolver) >+ static void applyInheritValue(CSSPropertyID, StyleResolveState& state) > { >- float size = styleResolver->parentStyle()->fontDescription().specifiedSize(); >+ float size = state.parentFontDescription().specifiedSize(); > > if (size < 0) > return; > >- FontDescription fontDescription = styleResolver->style()->fontDescription(); >- fontDescription.setKeywordSize(styleResolver->parentStyle()->fontDescription().keywordSize()); >- styleResolver->setFontSize(fontDescription, size); >- styleResolver->setFontDescription(fontDescription); >+ FontDescription fontDescription = state.fontDescription(); >+ fontDescription.setKeywordSize(state.parentFontDescription().keywordSize()); >+ StyleResolver::setFontSize(state, fontDescription, size); >+ state.setFontDescription(fontDescription); > return; > } > >- static void applyInitialValue(CSSPropertyID, StyleResolver* styleResolver) >+ static void applyInitialValue(CSSPropertyID, StyleResolveState& state) > { >- FontDescription fontDescription = styleResolver->style()->fontDescription(); >- float size = styleResolver->fontSizeForKeyword(styleResolver->document(), CSSValueMedium, fontDescription.useFixedDefaultSize()); >+ FontDescription fontDescription = state.fontDescription(); >+ float size = StyleResolver::fontSizeForKeyword(state.document(), CSSValueMedium, fontDescription.useFixedDefaultSize()); > > if (size < 0) > return; > > fontDescription.setKeywordSize(CSSValueMedium - CSSValueXxSmall + 1); >- styleResolver->setFontSize(fontDescription, size); >- styleResolver->setFontDescription(fontDescription); >+ StyleResolver::setFontSize(state, fontDescription, size); >+ state.setFontDescription(fontDescription); > return; > } > >- static void applyValue(CSSPropertyID, StyleResolver* styleResolver, CSSValue* value) >+ static void applyValue(CSSPropertyID, StyleResolveState& state, CSSValue* value) > { > if (!value->isPrimitiveValue()) > return; > > CSSPrimitiveValue* primitiveValue = static_cast<CSSPrimitiveValue*>(value); > >- FontDescription fontDescription = styleResolver->style()->fontDescription(); >+ FontDescription fontDescription = state.fontDescription(); > fontDescription.setKeywordSize(0); > float parentSize = 0; > bool parentIsAbsoluteSize = false; > float size = 0; > >- if (styleResolver->parentStyle()) { >- parentSize = styleResolver->parentStyle()->fontDescription().specifiedSize(); >- parentIsAbsoluteSize = styleResolver->parentStyle()->fontDescription().isAbsoluteSize(); >+ if (state.parentStyle()) { >+ parentSize = state.parentFontDescription().specifiedSize(); >+ parentIsAbsoluteSize = state.parentFontDescription().isAbsoluteSize(); > } > > if (int ident = primitiveValue->getIdent()) { >@@ -733,7 +733,7 @@ public: > case CSSValueXLarge: > case CSSValueXxLarge: > case CSSValueWebkitXxxLarge: >- size = styleResolver->fontSizeForKeyword(styleResolver->document(), ident, fontDescription.useFixedDefaultSize()); >+ size = StyleResolver::fontSizeForKeyword(state.document(), ident, fontDescription.useFixedDefaultSize()); > fontDescription.setKeywordSize(ident - CSSValueXxSmall + 1); > break; > case CSSValueLarger: >@@ -751,13 +751,13 @@ public: > fontDescription.setIsAbsoluteSize(parentIsAbsoluteSize > || !(primitiveValue->isPercentage() || primitiveValue->isFontRelativeLength())); > if (primitiveValue->isLength()) >- size = primitiveValue->computeLength<float>(styleResolver->parentStyle(), styleResolver->rootElementStyle(), 1.0, true); >+ size = primitiveValue->computeLength<float>(state.parentStyle(), state.rootElementStyle(), 1.0, true); > else if (primitiveValue->isPercentage()) > size = (primitiveValue->getFloatValue() * parentSize) / 100.0f; > else if (primitiveValue->isCalculatedPercentageWithLength()) >- size = primitiveValue->cssCalcValue()->toCalcValue(styleResolver->parentStyle(), styleResolver->rootElementStyle())->evaluate(parentSize); >+ size = primitiveValue->cssCalcValue()->toCalcValue(state.parentStyle(), state.rootElementStyle())->evaluate(parentSize); > else if (primitiveValue->isViewportPercentageLength()) >- size = valueForLength(primitiveValue->viewportPercentageLength(), 0, styleResolver->document()->renderView()); >+ size = valueForLength(primitiveValue->viewportPercentageLength(), 0, state.document()->renderView()); > else > return; > } >@@ -769,8 +769,8 @@ public: > // Cap font size here to make sure that doesn't happen. > size = min(maximumAllowedFontSize, size); > >- styleResolver->setFontSize(fontDescription, size); >- styleResolver->setFontDescription(fontDescription); >+ StyleResolver::setFontSize(state, fontDescription, size); >+ state.setFontDescription(fontDescription); > return; > } > >@@ -779,12 +779,12 @@ public: > > class ApplyPropertyFontWeight { > public: >- static void applyValue(CSSPropertyID, StyleResolver* styleResolver, CSSValue* value) >+ static void applyValue(CSSPropertyID, StyleResolveState& state, CSSValue* value) > { > if (!value->isPrimitiveValue()) > return; > CSSPrimitiveValue* primitiveValue = static_cast<CSSPrimitiveValue*>(value); >- FontDescription fontDescription = styleResolver->fontDescription(); >+ FontDescription fontDescription = state.fontDescription(); > switch (primitiveValue->getIdent()) { > case CSSValueInvalid: > ASSERT_NOT_REACHED(); >@@ -798,7 +798,7 @@ public: > default: > fontDescription.setWeight(*primitiveValue); > } >- styleResolver->setFontDescription(fontDescription); >+ state.setFontDescription(fontDescription); > } > static PropertyHandler createHandler() > { >@@ -809,30 +809,30 @@ public: > > class ApplyPropertyFontVariantLigatures { > public: >- static void applyInheritValue(CSSPropertyID, StyleResolver* styleResolver) >+ static void applyInheritValue(CSSPropertyID, StyleResolveState& state) > { >- const FontDescription& parentFontDescription = styleResolver->parentFontDescription(); >- FontDescription fontDescription = styleResolver->fontDescription(); >+ const FontDescription& parentFontDescription = state.parentFontDescription(); >+ FontDescription fontDescription = state.fontDescription(); > > fontDescription.setCommonLigaturesState(parentFontDescription.commonLigaturesState()); > fontDescription.setDiscretionaryLigaturesState(parentFontDescription.discretionaryLigaturesState()); > fontDescription.setHistoricalLigaturesState(parentFontDescription.historicalLigaturesState()); > >- styleResolver->setFontDescription(fontDescription); >+ state.setFontDescription(fontDescription); > } > >- static void applyInitialValue(CSSPropertyID, StyleResolver* styleResolver) >+ static void applyInitialValue(CSSPropertyID, StyleResolveState& state) > { >- FontDescription fontDescription = styleResolver->fontDescription(); >+ FontDescription fontDescription = state.fontDescription(); > > fontDescription.setCommonLigaturesState(FontDescription::NormalLigaturesState); > fontDescription.setDiscretionaryLigaturesState(FontDescription::NormalLigaturesState); > fontDescription.setHistoricalLigaturesState(FontDescription::NormalLigaturesState); > >- styleResolver->setFontDescription(fontDescription); >+ state.setFontDescription(fontDescription); > } > >- static void applyValue(CSSPropertyID, StyleResolver* styleResolver, CSSValue* value) >+ static void applyValue(CSSPropertyID, StyleResolveState& state, CSSValue* value) > { > FontDescription::LigaturesState commonLigaturesState = FontDescription::NormalLigaturesState; > FontDescription::LigaturesState discretionaryLigaturesState = FontDescription::NormalLigaturesState; >@@ -878,11 +878,11 @@ public: > } > #endif > >- FontDescription fontDescription = styleResolver->fontDescription(); >+ FontDescription fontDescription = state.fontDescription(); > fontDescription.setCommonLigaturesState(commonLigaturesState); > fontDescription.setDiscretionaryLigaturesState(discretionaryLigaturesState); > fontDescription.setHistoricalLigaturesState(historicalLigaturesState); >- styleResolver->setFontDescription(fontDescription); >+ state.setFontDescription(fontDescription); > } > > static PropertyHandler createHandler() >@@ -898,13 +898,13 @@ template <BorderImageType borderImageType, > void (RenderStyle::*setterFunction)(const NinePieceImage&)> > class ApplyPropertyBorderImage { > public: >- static void applyValue(CSSPropertyID, StyleResolver* styleResolver, CSSValue* value) >+ static void applyValue(CSSPropertyID, StyleResolveState& state, CSSValue* value) > { > NinePieceImage image; > if (borderImageType == BorderMask) > image.setMaskDefaults(); >- styleResolver->styleMap()->mapNinePieceImage(property, value, image); >- (styleResolver->style()->*setterFunction)(image); >+ CSSToStyleMap::mapNinePieceImage(state, property, value, image); >+ (state.style()->*setterFunction)(image); > } > > static PropertyHandler createHandler() >@@ -921,29 +921,29 @@ private: > static inline const NinePieceImage& getValue(RenderStyle* style) { return type == BorderImage ? style->borderImage() : style->maskBoxImage(); } > static inline void setValue(RenderStyle* style, const NinePieceImage& value) { return type == BorderImage ? style->setBorderImage(value) : style->setMaskBoxImage(value); } > public: >- static void applyInheritValue(CSSPropertyID, StyleResolver* styleResolver) >+ static void applyInheritValue(CSSPropertyID, StyleResolveState& state) > { >- NinePieceImage image(getValue(styleResolver->style())); >+ NinePieceImage image(getValue(state.style())); > switch (modifier) { > case Outset: >- image.copyOutsetFrom(getValue(styleResolver->parentStyle())); >+ image.copyOutsetFrom(getValue(state.parentStyle())); > break; > case Repeat: >- image.copyRepeatFrom(getValue(styleResolver->parentStyle())); >+ image.copyRepeatFrom(getValue(state.parentStyle())); > break; > case Slice: >- image.copyImageSlicesFrom(getValue(styleResolver->parentStyle())); >+ image.copyImageSlicesFrom(getValue(state.parentStyle())); > break; > case Width: >- image.copyBorderSlicesFrom(getValue(styleResolver->parentStyle())); >+ image.copyBorderSlicesFrom(getValue(state.parentStyle())); > break; > } >- setValue(styleResolver->style(), image); >+ setValue(state.style(), image); > } > >- static void applyInitialValue(CSSPropertyID, StyleResolver* styleResolver) >+ static void applyInitialValue(CSSPropertyID, StyleResolveState& state) > { >- NinePieceImage image(getValue(styleResolver->style())); >+ NinePieceImage image(getValue(state.style())); > switch (modifier) { > case Outset: > image.setOutset(LengthBox(0)); >@@ -962,27 +962,27 @@ public: > image.setBorderSlices(type == BorderImage ? LengthBox(Length(1, Relative), Length(1, Relative), Length(1, Relative), Length(1, Relative)) : LengthBox()); > break; > } >- setValue(styleResolver->style(), image); >+ setValue(state.style(), image); > } > >- static void applyValue(CSSPropertyID, StyleResolver* styleResolver, CSSValue* value) >+ static void applyValue(CSSPropertyID, StyleResolveState& state, CSSValue* value) > { >- NinePieceImage image(getValue(styleResolver->style())); >+ NinePieceImage image(getValue(state.style())); > switch (modifier) { > case Outset: >- image.setOutset(styleResolver->styleMap()->mapNinePieceImageQuad(value)); >+ image.setOutset(CSSToStyleMap::mapNinePieceImageQuad(state, value)); > break; > case Repeat: >- styleResolver->styleMap()->mapNinePieceImageRepeat(value, image); >+ CSSToStyleMap::mapNinePieceImageRepeat(state, value, image); > break; > case Slice: >- styleResolver->styleMap()->mapNinePieceImageSlice(value, image); >+ CSSToStyleMap::mapNinePieceImageSlice(state, value, image); > break; > case Width: >- image.setBorderSlices(styleResolver->styleMap()->mapNinePieceImageQuad(value)); >+ image.setBorderSlices(CSSToStyleMap::mapNinePieceImageQuad(state, value)); > break; > } >- setValue(styleResolver->style(), image); >+ setValue(state.style(), image); > } > > static PropertyHandler createHandler() { return PropertyHandler(&applyInheritValue, &applyInitialValue, &applyValue); } >@@ -991,7 +991,7 @@ public: > template <CSSPropertyID id, StyleImage* (RenderStyle::*getterFunction)() const, void (RenderStyle::*setterFunction)(PassRefPtr<StyleImage>), StyleImage* (*initialFunction)()> > class ApplyPropertyBorderImageSource { > public: >- static void applyValue(CSSPropertyID, StyleResolver* styleResolver, CSSValue* value) { (styleResolver->style()->*setterFunction)(styleResolver->styleImage(id, value)); } >+ static void applyValue(CSSPropertyID, StyleResolveState& state, CSSValue* value) { (state.style()->*setterFunction)(StyleResolver::styleImage(state, id, value)); } > static PropertyHandler createHandler() > { > PropertyHandler handler = ApplyPropertyDefaultBase<StyleImage*, getterFunction, PassRefPtr<StyleImage>, setterFunction, StyleImage*, initialFunction>::createHandler(); >@@ -1003,11 +1003,11 @@ enum CounterBehavior {Increment = 0, Reset}; > template <CounterBehavior counterBehavior> > class ApplyPropertyCounter { > public: >- static void emptyFunction(CSSPropertyID, StyleResolver*) { } >- static void applyInheritValue(CSSPropertyID, StyleResolver* styleResolver) >+ static void emptyFunction(CSSPropertyID, StyleResolveState&) { } >+ static void applyInheritValue(CSSPropertyID, StyleResolveState& state) > { >- CounterDirectiveMap& map = styleResolver->style()->accessCounterDirectives(); >- CounterDirectiveMap& parentMap = styleResolver->parentStyle()->accessCounterDirectives(); >+ CounterDirectiveMap& map = state.style()->accessCounterDirectives(); >+ CounterDirectiveMap& parentMap = state.parentStyle()->accessCounterDirectives(); > > typedef CounterDirectiveMap::iterator Iterator; > Iterator end = parentMap.end(); >@@ -1020,14 +1020,14 @@ public: > } > } > } >- static void applyValue(CSSPropertyID, StyleResolver* styleResolver, CSSValue* value) >+ static void applyValue(CSSPropertyID, StyleResolveState& state, CSSValue* value) > { > if (!value->isValueList()) > return; > > CSSValueList* list = static_cast<CSSValueList*>(value); > >- CounterDirectiveMap& map = styleResolver->style()->accessCounterDirectives(); >+ CounterDirectiveMap& map = state.style()->accessCounterDirectives(); > typedef CounterDirectiveMap::iterator Iterator; > > Iterator end = map.end(); >@@ -1063,42 +1063,42 @@ public: > > class ApplyPropertyCursor { > public: >- static void applyInheritValue(CSSPropertyID, StyleResolver* styleResolver) >+ static void applyInheritValue(CSSPropertyID, StyleResolveState& state) > { >- styleResolver->style()->setCursor(styleResolver->parentStyle()->cursor()); >- styleResolver->style()->setCursorList(styleResolver->parentStyle()->cursors()); >+ state.style()->setCursor(state.parentStyle()->cursor()); >+ state.style()->setCursorList(state.parentStyle()->cursors()); > } > >- static void applyInitialValue(CSSPropertyID, StyleResolver* styleResolver) >+ static void applyInitialValue(CSSPropertyID, StyleResolveState& state) > { >- styleResolver->style()->clearCursorList(); >- styleResolver->style()->setCursor(RenderStyle::initialCursor()); >+ state.style()->clearCursorList(); >+ state.style()->setCursor(RenderStyle::initialCursor()); > } > >- static void applyValue(CSSPropertyID, StyleResolver* styleResolver, CSSValue* value) >+ static void applyValue(CSSPropertyID, StyleResolveState& state, CSSValue* value) > { >- styleResolver->style()->clearCursorList(); >+ state.style()->clearCursorList(); > if (value->isValueList()) { > CSSValueList* list = static_cast<CSSValueList*>(value); > int len = list->length(); >- styleResolver->style()->setCursor(CURSOR_AUTO); >+ state.style()->setCursor(CURSOR_AUTO); > for (int i = 0; i < len; i++) { > CSSValue* item = list->itemWithoutBoundsCheck(i); > if (item->isCursorImageValue()) { > CSSCursorImageValue* image = static_cast<CSSCursorImageValue*>(item); >- if (image->updateIfSVGCursorIsUsed(styleResolver->element())) // Elements with SVG cursors are not allowed to share style. >- styleResolver->style()->setUnique(); >- styleResolver->style()->addCursor(styleResolver->styleImage(CSSPropertyCursor, image), image->hotSpot()); >+ if (image->updateIfSVGCursorIsUsed(state.element())) // Elements with SVG cursors are not allowed to share style. >+ state.style()->setUnique(); >+ state.style()->addCursor(StyleResolver::styleImage(state, CSSPropertyCursor, image), image->hotSpot()); > } else if (item->isPrimitiveValue()) { > CSSPrimitiveValue* primitiveValue = static_cast<CSSPrimitiveValue*>(item); > if (primitiveValue->isIdent()) >- styleResolver->style()->setCursor(*primitiveValue); >+ state.style()->setCursor(*primitiveValue); > } > } > } else if (value->isPrimitiveValue()) { > CSSPrimitiveValue* primitiveValue = static_cast<CSSPrimitiveValue*>(value); >- if (primitiveValue->isIdent() && styleResolver->style()->cursor() != ECursor(*primitiveValue)) >- styleResolver->style()->setCursor(*primitiveValue); >+ if (primitiveValue->isIdent() && state.style()->cursor() != ECursor(*primitiveValue)) >+ state.style()->setCursor(*primitiveValue); > } > } > >@@ -1107,7 +1107,7 @@ public: > > class ApplyPropertyTextAlign { > public: >- static void applyValue(CSSPropertyID, StyleResolver* styleResolver, CSSValue* value) >+ static void applyValue(CSSPropertyID, StyleResolveState& state, CSSValue* value) > { > if (!value->isPrimitiveValue()) > return; >@@ -1115,13 +1115,13 @@ public: > CSSPrimitiveValue* primitiveValue = static_cast<CSSPrimitiveValue*>(value); > > if (primitiveValue->getIdent() != CSSValueWebkitMatchParent) >- styleResolver->style()->setTextAlign(*primitiveValue); >- else if (styleResolver->parentStyle()->textAlign() == TASTART) >- styleResolver->style()->setTextAlign(styleResolver->parentStyle()->isLeftToRightDirection() ? LEFT : RIGHT); >- else if (styleResolver->parentStyle()->textAlign() == TAEND) >- styleResolver->style()->setTextAlign(styleResolver->parentStyle()->isLeftToRightDirection() ? RIGHT : LEFT); >+ state.style()->setTextAlign(*primitiveValue); >+ else if (state.parentStyle()->textAlign() == TASTART) >+ state.style()->setTextAlign(state.parentStyle()->isLeftToRightDirection() ? LEFT : RIGHT); >+ else if (state.parentStyle()->textAlign() == TAEND) >+ state.style()->setTextAlign(state.parentStyle()->isLeftToRightDirection() ? RIGHT : LEFT); > else >- styleResolver->style()->setTextAlign(styleResolver->parentStyle()->textAlign()); >+ state.style()->setTextAlign(state.parentStyle()->textAlign()); > } > static PropertyHandler createHandler() > { >@@ -1132,7 +1132,7 @@ public: > > class ApplyPropertyTextDecoration { > public: >- static void applyValue(CSSPropertyID, StyleResolver* styleResolver, CSSValue* value) >+ static void applyValue(CSSPropertyID, StyleResolveState& state, CSSValue* value) > { > ETextDecoration t = RenderStyle::initialTextDecoration(); > for (CSSValueListIterator i(value); i.hasMore(); i.advance()) { >@@ -1140,7 +1140,7 @@ public: > ASSERT(item->isPrimitiveValue()); > t |= *static_cast<CSSPrimitiveValue*>(item); > } >- styleResolver->style()->setTextDecoration(t); >+ state.style()->setTextDecoration(t); > } > static PropertyHandler createHandler() > { >@@ -1151,7 +1151,7 @@ public: > > class ApplyPropertyLineHeight { > public: >- static void applyValue(CSSPropertyID, StyleResolver* styleResolver, CSSValue* value) >+ static void applyValue(CSSPropertyID, StyleResolveState& state, CSSValue* value) > { > if (!value->isPrimitiveValue()) > return; >@@ -1162,15 +1162,15 @@ public: > if (primitiveValue->getIdent() == CSSValueNormal) > lineHeight = RenderStyle::initialLineHeight(); > else if (primitiveValue->isLength()) { >- double multiplier = styleResolver->style()->effectiveZoom(); >- if (styleResolver->style()->textSizeAdjust()) { >- if (Frame* frame = styleResolver->document()->frame()) >+ double multiplier = state.style()->effectiveZoom(); >+ if (state.style()->textSizeAdjust()) { >+ if (Frame* frame = state.document()->frame()) > multiplier *= frame->textZoomFactor(); > } >- lineHeight = primitiveValue->computeLength<Length>(styleResolver->style(), styleResolver->rootElementStyle(), multiplier); >+ lineHeight = primitiveValue->computeLength<Length>(state.style(), state.rootElementStyle(), multiplier); > } else if (primitiveValue->isPercentage()) { > // FIXME: percentage should not be restricted to an integer here. >- lineHeight = Length((styleResolver->style()->fontSize() * primitiveValue->getIntValue()) / 100, Fixed); >+ lineHeight = Length((state.style()->fontSize() * primitiveValue->getIntValue()) / 100, Fixed); > } else if (primitiveValue->isNumber()) { > // FIXME: number and percentage values should produce the same type of Length (ie. Fixed or Percent). > lineHeight = Length(primitiveValue->getDoubleValue() * 100.0, Percent); >@@ -1178,7 +1178,7 @@ public: > lineHeight = primitiveValue->viewportPercentageLength(); > else > return; >- styleResolver->style()->setLineHeight(lineHeight); >+ state.style()->setLineHeight(lineHeight); > } > static PropertyHandler createHandler() > { >@@ -1265,11 +1265,11 @@ private: > return true; > } > public: >- static void applyInheritValue(CSSPropertyID, StyleResolver*) { } >- static void applyInitialValue(CSSPropertyID, StyleResolver*) { } >- static void applyValue(CSSPropertyID, StyleResolver* styleResolver, CSSValue* value) >+ static void applyInheritValue(CSSPropertyID, StyleResolveState&) { } >+ static void applyInitialValue(CSSPropertyID, StyleResolveState&) { } >+ static void applyValue(CSSPropertyID, StyleResolveState& state, CSSValue* value) > { >- styleResolver->style()->resetPageSizeType(); >+ state.style()->resetPageSizeType(); > Length width; > Length height; > PageSizeType pageSizeType = PAGE_SIZE_AUTO; >@@ -1285,8 +1285,8 @@ public: > // <length>{2} > if (!second->isLength()) > return; >- width = first->computeLength<Length>(styleResolver->style(), styleResolver->rootElementStyle()); >- height = second->computeLength<Length>(styleResolver->style(), styleResolver->rootElementStyle()); >+ width = first->computeLength<Length>(state.style(), state.rootElementStyle()); >+ height = second->computeLength<Length>(state.style(), state.rootElementStyle()); > } else { > // <page-size> <orientation> > // The value order is guaranteed. See CSSParser::parseSizeParameter. >@@ -1304,7 +1304,7 @@ public: > if (primitiveValue->isLength()) { > // <length> > pageSizeType = PAGE_SIZE_RESOLVED; >- width = height = primitiveValue->computeLength<Length>(styleResolver->style(), styleResolver->rootElementStyle()); >+ width = height = primitiveValue->computeLength<Length>(state.style(), state.rootElementStyle()); > } else { > switch (primitiveValue->getIdent()) { > case 0: >@@ -1330,29 +1330,29 @@ public: > default: > return; > } >- styleResolver->style()->setPageSizeType(pageSizeType); >- styleResolver->style()->setPageSize(LengthSize(width, height)); >+ state.style()->setPageSizeType(pageSizeType); >+ state.style()->setPageSize(LengthSize(width, height)); > } > static PropertyHandler createHandler() { return PropertyHandler(&applyInheritValue, &applyInitialValue, &applyValue); } > }; > > class ApplyPropertyTextEmphasisStyle { > public: >- static void applyInheritValue(CSSPropertyID, StyleResolver* styleResolver) >+ static void applyInheritValue(CSSPropertyID, StyleResolveState& state) > { >- styleResolver->style()->setTextEmphasisFill(styleResolver->parentStyle()->textEmphasisFill()); >- styleResolver->style()->setTextEmphasisMark(styleResolver->parentStyle()->textEmphasisMark()); >- styleResolver->style()->setTextEmphasisCustomMark(styleResolver->parentStyle()->textEmphasisCustomMark()); >+ state.style()->setTextEmphasisFill(state.parentStyle()->textEmphasisFill()); >+ state.style()->setTextEmphasisMark(state.parentStyle()->textEmphasisMark()); >+ state.style()->setTextEmphasisCustomMark(state.parentStyle()->textEmphasisCustomMark()); > } > >- static void applyInitialValue(CSSPropertyID, StyleResolver* styleResolver) >+ static void applyInitialValue(CSSPropertyID, StyleResolveState& state) > { >- styleResolver->style()->setTextEmphasisFill(RenderStyle::initialTextEmphasisFill()); >- styleResolver->style()->setTextEmphasisMark(RenderStyle::initialTextEmphasisMark()); >- styleResolver->style()->setTextEmphasisCustomMark(RenderStyle::initialTextEmphasisCustomMark()); >+ state.style()->setTextEmphasisFill(RenderStyle::initialTextEmphasisFill()); >+ state.style()->setTextEmphasisMark(RenderStyle::initialTextEmphasisMark()); >+ state.style()->setTextEmphasisCustomMark(RenderStyle::initialTextEmphasisCustomMark()); > } > >- static void applyValue(CSSPropertyID, StyleResolver* styleResolver, CSSValue* value) >+ static void applyValue(CSSPropertyID, StyleResolveState& state, CSSValue* value) > { > if (value->isValueList()) { > CSSValueList* list = static_cast<CSSValueList*>(value); >@@ -1366,11 +1366,11 @@ public: > > CSSPrimitiveValue* value = static_cast<CSSPrimitiveValue*>(item); > if (value->getIdent() == CSSValueFilled || value->getIdent() == CSSValueOpen) >- styleResolver->style()->setTextEmphasisFill(*value); >+ state.style()->setTextEmphasisFill(*value); > else >- styleResolver->style()->setTextEmphasisMark(*value); >+ state.style()->setTextEmphasisMark(*value); > } >- styleResolver->style()->setTextEmphasisCustomMark(nullAtom); >+ state.style()->setTextEmphasisCustomMark(nullAtom); > return; > } > >@@ -1379,20 +1379,20 @@ public: > CSSPrimitiveValue* primitiveValue = static_cast<CSSPrimitiveValue*>(value); > > if (primitiveValue->isString()) { >- styleResolver->style()->setTextEmphasisFill(TextEmphasisFillFilled); >- styleResolver->style()->setTextEmphasisMark(TextEmphasisMarkCustom); >- styleResolver->style()->setTextEmphasisCustomMark(primitiveValue->getStringValue()); >+ state.style()->setTextEmphasisFill(TextEmphasisFillFilled); >+ state.style()->setTextEmphasisMark(TextEmphasisMarkCustom); >+ state.style()->setTextEmphasisCustomMark(primitiveValue->getStringValue()); > return; > } > >- styleResolver->style()->setTextEmphasisCustomMark(nullAtom); >+ state.style()->setTextEmphasisCustomMark(nullAtom); > > if (primitiveValue->getIdent() == CSSValueFilled || primitiveValue->getIdent() == CSSValueOpen) { >- styleResolver->style()->setTextEmphasisFill(*primitiveValue); >- styleResolver->style()->setTextEmphasisMark(TextEmphasisMarkAuto); >+ state.style()->setTextEmphasisFill(*primitiveValue); >+ state.style()->setTextEmphasisMark(TextEmphasisMarkAuto); > } else { >- styleResolver->style()->setTextEmphasisFill(TextEmphasisFillFilled); >- styleResolver->style()->setTextEmphasisMark(*primitiveValue); >+ state.style()->setTextEmphasisFill(TextEmphasisFillFilled); >+ state.style()->setTextEmphasisMark(*primitiveValue); > } > } > >@@ -1400,14 +1400,14 @@ public: > }; > > template <typename T, >- T (Animation::*getterFunction)() const, >- void (Animation::*setterFunction)(T), >- bool (Animation::*testFunction)() const, >- void (Animation::*clearFunction)(), >- T (*initialFunction)(), >- void (CSSToStyleMap::*mapFunction)(Animation*, CSSValue*), >- AnimationList* (RenderStyle::*animationGetterFunction)(), >- const AnimationList* (RenderStyle::*immutableAnimationGetterFunction)() const> >+ T (Animation::*getterFunction)() const, >+ void (Animation::*setterFunction)(T), >+ bool (Animation::*testFunction)() const, >+ void (Animation::*clearFunction)(), >+ T (*initialFunction)(), >+ void (*mapFunction)(Animation*, CSSValue*), >+ AnimationList* (RenderStyle::*animationGetterFunction)(), >+ const AnimationList* (RenderStyle::*immutableAnimationGetterFunction)() const> > class ApplyPropertyAnimation { > public: > static void setValue(Animation* animation, T value) { (animation->*setterFunction)(value); } >@@ -1415,14 +1415,14 @@ public: > static bool test(const Animation* animation) { return (animation->*testFunction)(); } > static void clear(Animation* animation) { (animation->*clearFunction)(); } > static T initial() { return (*initialFunction)(); } >- static void map(StyleResolver* styleResolver, Animation* animation, CSSValue* value) { (styleResolver->styleMap()->*mapFunction)(animation, value); } >+ static void map(StyleResolveState& state, Animation* animation, CSSValue* value) { (*mapFunction)(animation, value); } > static AnimationList* accessAnimations(RenderStyle* style) { return (style->*animationGetterFunction)(); } > static const AnimationList* animations(RenderStyle* style) { return (style->*immutableAnimationGetterFunction)(); } > >- static void applyInheritValue(CSSPropertyID, StyleResolver* styleResolver) >+ static void applyInheritValue(CSSPropertyID, StyleResolveState& state) > { >- AnimationList* list = accessAnimations(styleResolver->style()); >- const AnimationList* parentList = animations(styleResolver->parentStyle()); >+ AnimationList* list = accessAnimations(state.style()); >+ const AnimationList* parentList = animations(state.parentStyle()); > size_t i = 0, parentSize = parentList ? parentList->size() : 0; > for ( ; i < parentSize && test(parentList->animation(i)); ++i) { > if (list->size() <= i) >@@ -1436,9 +1436,9 @@ public: > clear(list->animation(i)); > } > >- static void applyInitialValue(CSSPropertyID propertyID, StyleResolver* styleResolver) >+ static void applyInitialValue(CSSPropertyID propertyID, StyleResolveState& state) > { >- AnimationList* list = accessAnimations(styleResolver->style()); >+ AnimationList* list = accessAnimations(state.style()); > if (list->isEmpty()) > list->append(Animation::create()); > setValue(list->animation(0), initial()); >@@ -1448,22 +1448,22 @@ public: > clear(list->animation(i)); > } > >- static void applyValue(CSSPropertyID, StyleResolver* styleResolver, CSSValue* value) >+ static void applyValue(CSSPropertyID, StyleResolveState& state, CSSValue* value) > { >- AnimationList* list = accessAnimations(styleResolver->style()); >+ AnimationList* list = accessAnimations(state.style()); > size_t childIndex = 0; > if (value->isValueList()) { > /* Walk each value and put it into an animation, creating new animations as needed. */ > for (CSSValueListIterator i = value; i.hasMore(); i.advance()) { > if (childIndex <= list->size()) > list->append(Animation::create()); >- map(styleResolver, list->animation(childIndex), i.value()); >+ map(state, list->animation(childIndex), i.value()); > ++childIndex; > } > } else { > if (list->isEmpty()) > list->append(Animation::create()); >- map(styleResolver, list->animation(childIndex), value); >+ map(state, list->animation(childIndex), value); > childIndex = 1; > } > for ( ; childIndex < list->size(); ++childIndex) { >@@ -1477,22 +1477,22 @@ public: > > class ApplyPropertyOutlineStyle { > public: >- static void applyInheritValue(CSSPropertyID propertyID, StyleResolver* styleResolver) >+ static void applyInheritValue(CSSPropertyID propertyID, StyleResolveState& state) > { >- ApplyPropertyDefaultBase<OutlineIsAuto, &RenderStyle::outlineStyleIsAuto, OutlineIsAuto, &RenderStyle::setOutlineStyleIsAuto, OutlineIsAuto, &RenderStyle::initialOutlineStyleIsAuto>::applyInheritValue(propertyID, styleResolver); >- ApplyPropertyDefaultBase<EBorderStyle, &RenderStyle::outlineStyle, EBorderStyle, &RenderStyle::setOutlineStyle, EBorderStyle, &RenderStyle::initialBorderStyle>::applyInheritValue(propertyID, styleResolver); >+ ApplyPropertyDefaultBase<OutlineIsAuto, &RenderStyle::outlineStyleIsAuto, OutlineIsAuto, &RenderStyle::setOutlineStyleIsAuto, OutlineIsAuto, &RenderStyle::initialOutlineStyleIsAuto>::applyInheritValue(propertyID, state); >+ ApplyPropertyDefaultBase<EBorderStyle, &RenderStyle::outlineStyle, EBorderStyle, &RenderStyle::setOutlineStyle, EBorderStyle, &RenderStyle::initialBorderStyle>::applyInheritValue(propertyID, state); > } > >- static void applyInitialValue(CSSPropertyID propertyID, StyleResolver* styleResolver) >+ static void applyInitialValue(CSSPropertyID propertyID, StyleResolveState& state) > { >- ApplyPropertyDefaultBase<OutlineIsAuto, &RenderStyle::outlineStyleIsAuto, OutlineIsAuto, &RenderStyle::setOutlineStyleIsAuto, OutlineIsAuto, &RenderStyle::initialOutlineStyleIsAuto>::applyInitialValue(propertyID, styleResolver); >- ApplyPropertyDefaultBase<EBorderStyle, &RenderStyle::outlineStyle, EBorderStyle, &RenderStyle::setOutlineStyle, EBorderStyle, &RenderStyle::initialBorderStyle>::applyInitialValue(propertyID, styleResolver); >+ ApplyPropertyDefaultBase<OutlineIsAuto, &RenderStyle::outlineStyleIsAuto, OutlineIsAuto, &RenderStyle::setOutlineStyleIsAuto, OutlineIsAuto, &RenderStyle::initialOutlineStyleIsAuto>::applyInitialValue(propertyID, state); >+ ApplyPropertyDefaultBase<EBorderStyle, &RenderStyle::outlineStyle, EBorderStyle, &RenderStyle::setOutlineStyle, EBorderStyle, &RenderStyle::initialBorderStyle>::applyInitialValue(propertyID, state); > } > >- static void applyValue(CSSPropertyID propertyID, StyleResolver* styleResolver, CSSValue* value) >+ static void applyValue(CSSPropertyID propertyID, StyleResolveState& state, CSSValue* value) > { >- ApplyPropertyDefault<OutlineIsAuto, &RenderStyle::outlineStyleIsAuto, OutlineIsAuto, &RenderStyle::setOutlineStyleIsAuto, OutlineIsAuto, &RenderStyle::initialOutlineStyleIsAuto>::applyValue(propertyID, styleResolver, value); >- ApplyPropertyDefault<EBorderStyle, &RenderStyle::outlineStyle, EBorderStyle, &RenderStyle::setOutlineStyle, EBorderStyle, &RenderStyle::initialBorderStyle>::applyValue(propertyID, styleResolver, value); >+ ApplyPropertyDefault<OutlineIsAuto, &RenderStyle::outlineStyleIsAuto, OutlineIsAuto, &RenderStyle::setOutlineStyleIsAuto, OutlineIsAuto, &RenderStyle::initialOutlineStyleIsAuto>::applyValue(propertyID, state, value); >+ ApplyPropertyDefault<EBorderStyle, &RenderStyle::outlineStyle, EBorderStyle, &RenderStyle::setOutlineStyle, EBorderStyle, &RenderStyle::initialBorderStyle>::applyValue(propertyID, state, value); > } > > static PropertyHandler createHandler() { return PropertyHandler(&applyInheritValue, &applyInitialValue, &applyValue); } >@@ -1500,7 +1500,7 @@ public: > > class ApplyPropertyResize { > public: >- static void applyValue(CSSPropertyID, StyleResolver* styleResolver, CSSValue* value) >+ static void applyValue(CSSPropertyID, StyleResolveState& state, CSSValue* value) > { > if (!value->isPrimitiveValue()) > return; >@@ -1512,13 +1512,13 @@ public: > case 0: > return; > case CSSValueAuto: >- if (Settings* settings = styleResolver->document()->settings()) >+ if (Settings* settings = state.document()->settings()) > r = settings->textAreasAreResizable() ? RESIZE_BOTH : RESIZE_NONE; > break; > default: > r = *primitiveValue; > } >- styleResolver->style()->setResize(r); >+ state.style()->setResize(r); > } > > static PropertyHandler createHandler() >@@ -1530,7 +1530,7 @@ public: > > class ApplyPropertyVerticalAlign { > public: >- static void applyValue(CSSPropertyID, StyleResolver* styleResolver, CSSValue* value) >+ static void applyValue(CSSPropertyID, StyleResolveState& state, CSSValue* value) > { > if (!value->isPrimitiveValue()) > return; >@@ -1538,9 +1538,9 @@ public: > CSSPrimitiveValue* primitiveValue = static_cast<CSSPrimitiveValue*>(value); > > if (primitiveValue->getIdent()) >- return styleResolver->style()->setVerticalAlign(*primitiveValue); >+ return state.style()->setVerticalAlign(*primitiveValue); > >- styleResolver->style()->setVerticalAlignLength(primitiveValue->convertToLength<FixedIntegerConversion | PercentConversion | CalculatedConversion | ViewportPercentageConversion>(styleResolver->style(), styleResolver->rootElementStyle(), styleResolver->style()->effectiveZoom())); >+ state.style()->setVerticalAlignLength(primitiveValue->convertToLength<FixedIntegerConversion | PercentConversion | CalculatedConversion | ViewportPercentageConversion>(state.style(), state.rootElementStyle(), state.style()->effectiveZoom())); > } > > static PropertyHandler createHandler() >@@ -1552,32 +1552,32 @@ public: > > class ApplyPropertyAspectRatio { > public: >- static void applyInheritValue(CSSPropertyID, StyleResolver* styleResolver) >+ static void applyInheritValue(CSSPropertyID, StyleResolveState& state) > { >- if (!styleResolver->parentStyle()->hasAspectRatio()) >+ if (!state.parentStyle()->hasAspectRatio()) > return; >- styleResolver->style()->setHasAspectRatio(true); >- styleResolver->style()->setAspectRatioDenominator(styleResolver->parentStyle()->aspectRatioDenominator()); >- styleResolver->style()->setAspectRatioNumerator(styleResolver->parentStyle()->aspectRatioNumerator()); >+ state.style()->setHasAspectRatio(true); >+ state.style()->setAspectRatioDenominator(state.parentStyle()->aspectRatioDenominator()); >+ state.style()->setAspectRatioNumerator(state.parentStyle()->aspectRatioNumerator()); > } > >- static void applyInitialValue(CSSPropertyID, StyleResolver* styleResolver) >+ static void applyInitialValue(CSSPropertyID, StyleResolveState& state) > { >- styleResolver->style()->setHasAspectRatio(RenderStyle::initialHasAspectRatio()); >- styleResolver->style()->setAspectRatioDenominator(RenderStyle::initialAspectRatioDenominator()); >- styleResolver->style()->setAspectRatioNumerator(RenderStyle::initialAspectRatioNumerator()); >+ state.style()->setHasAspectRatio(RenderStyle::initialHasAspectRatio()); >+ state.style()->setAspectRatioDenominator(RenderStyle::initialAspectRatioDenominator()); >+ state.style()->setAspectRatioNumerator(RenderStyle::initialAspectRatioNumerator()); > } > >- static void applyValue(CSSPropertyID, StyleResolver* styleResolver, CSSValue* value) >+ static void applyValue(CSSPropertyID, StyleResolveState& state, CSSValue* value) > { > if (!value->isAspectRatioValue()) { >- styleResolver->style()->setHasAspectRatio(false); >+ state.style()->setHasAspectRatio(false); > return; > } > CSSAspectRatioValue* aspectRatioValue = static_cast<CSSAspectRatioValue*>(value); >- styleResolver->style()->setHasAspectRatio(true); >- styleResolver->style()->setAspectRatioDenominator(aspectRatioValue->denominatorValue()); >- styleResolver->style()->setAspectRatioNumerator(aspectRatioValue->numeratorValue()); >+ state.style()->setHasAspectRatio(true); >+ state.style()->setAspectRatioDenominator(aspectRatioValue->denominatorValue()); >+ state.style()->setAspectRatioNumerator(aspectRatioValue->numeratorValue()); > } > > static PropertyHandler createHandler() >@@ -1588,48 +1588,48 @@ public: > > class ApplyPropertyZoom { > private: >- static void resetEffectiveZoom(StyleResolver* styleResolver) >+ static void resetEffectiveZoom(StyleResolveState& state) > { > // Reset the zoom in effect. This allows the setZoom method to accurately compute a new zoom in effect. >- styleResolver->setEffectiveZoom(styleResolver->parentStyle() ? styleResolver->parentStyle()->effectiveZoom() : RenderStyle::initialZoom()); >+ state.setEffectiveZoom(state.parentStyle() ? state.parentStyle()->effectiveZoom() : RenderStyle::initialZoom()); > } > > public: >- static void applyInheritValue(CSSPropertyID, StyleResolver* styleResolver) >+ static void applyInheritValue(CSSPropertyID, StyleResolveState& state) > { >- resetEffectiveZoom(styleResolver); >- styleResolver->setZoom(styleResolver->parentStyle()->zoom()); >+ resetEffectiveZoom(state); >+ state.setZoom(state.parentStyle()->zoom()); > } > >- static void applyInitialValue(CSSPropertyID, StyleResolver* styleResolver) >+ static void applyInitialValue(CSSPropertyID, StyleResolveState& state) > { >- resetEffectiveZoom(styleResolver); >- styleResolver->setZoom(RenderStyle::initialZoom()); >+ resetEffectiveZoom(state); >+ state.setZoom(RenderStyle::initialZoom()); > } > >- static void applyValue(CSSPropertyID, StyleResolver* styleResolver, CSSValue* value) >+ static void applyValue(CSSPropertyID, StyleResolveState& state, CSSValue* value) > { > ASSERT(value->isPrimitiveValue()); > CSSPrimitiveValue* primitiveValue = static_cast<CSSPrimitiveValue*>(value); > > if (primitiveValue->getIdent() == CSSValueNormal) { >- resetEffectiveZoom(styleResolver); >- styleResolver->setZoom(RenderStyle::initialZoom()); >+ resetEffectiveZoom(state); >+ state.setZoom(RenderStyle::initialZoom()); > } else if (primitiveValue->getIdent() == CSSValueReset) { >- styleResolver->setEffectiveZoom(RenderStyle::initialZoom()); >- styleResolver->setZoom(RenderStyle::initialZoom()); >+ state.setEffectiveZoom(RenderStyle::initialZoom()); >+ state.setZoom(RenderStyle::initialZoom()); > } else if (primitiveValue->getIdent() == CSSValueDocument) { >- float docZoom = styleResolver->rootElementStyle() ? styleResolver->rootElementStyle()->zoom() : RenderStyle::initialZoom(); >- styleResolver->setEffectiveZoom(docZoom); >- styleResolver->setZoom(docZoom); >+ float docZoom = state.rootElementStyle() ? state.rootElementStyle()->zoom() : RenderStyle::initialZoom(); >+ state.setEffectiveZoom(docZoom); >+ state.setZoom(docZoom); > } else if (primitiveValue->isPercentage()) { >- resetEffectiveZoom(styleResolver); >+ resetEffectiveZoom(state); > if (float percent = primitiveValue->getFloatValue()) >- styleResolver->setZoom(percent / 100.0f); >+ state.setZoom(percent / 100.0f); > } else if (primitiveValue->isNumber()) { >- resetEffectiveZoom(styleResolver); >+ resetEffectiveZoom(state); > if (float number = primitiveValue->getFloatValue()) >- styleResolver->setZoom(number); >+ state.setZoom(number); > } > } > >@@ -1641,42 +1641,42 @@ public: > > class ApplyPropertyDisplay { > private: >- static inline bool isValidDisplayValue(StyleResolver* styleResolver, EDisplay displayPropertyValue) >+ static inline bool isValidDisplayValue(StyleResolveState& state, EDisplay displayPropertyValue) > { > #if ENABLE(SVG) >- if (styleResolver->element() && styleResolver->element()->isSVGElement() && styleResolver->style()->styleType() == NOPSEUDO) >+ if (state.element() && state.element()->isSVGElement() && state.style()->styleType() == NOPSEUDO) > return (displayPropertyValue == INLINE || displayPropertyValue == BLOCK || displayPropertyValue == NONE); > #else >- UNUSED_PARAM(styleResolver); >+ UNUSED_PARAM(state); > UNUSED_PARAM(displayPropertyValue); > #endif > return true; > } > public: >- static void applyInheritValue(CSSPropertyID, StyleResolver* styleResolver) >+ static void applyInheritValue(CSSPropertyID, StyleResolveState& state) > { >- EDisplay display = styleResolver->parentStyle()->display(); >- if (!isValidDisplayValue(styleResolver, display)) >+ EDisplay display = state.parentStyle()->display(); >+ if (!isValidDisplayValue(state, display)) > return; >- styleResolver->style()->setDisplay(display); >+ state.style()->setDisplay(display); > } > >- static void applyInitialValue(CSSPropertyID, StyleResolver* styleResolver) >+ static void applyInitialValue(CSSPropertyID, StyleResolveState& state) > { >- styleResolver->style()->setDisplay(RenderStyle::initialDisplay()); >+ state.style()->setDisplay(RenderStyle::initialDisplay()); > } > >- static void applyValue(CSSPropertyID, StyleResolver* styleResolver, CSSValue* value) >+ static void applyValue(CSSPropertyID, StyleResolveState& state, CSSValue* value) > { > if (!value->isPrimitiveValue()) > return; > > EDisplay display = *static_cast<CSSPrimitiveValue*>(value); > >- if (!isValidDisplayValue(styleResolver, display)) >+ if (!isValidDisplayValue(state, display)) > return; > >- styleResolver->style()->setDisplay(display); >+ state.style()->setDisplay(display); > } > > static PropertyHandler createHandler() >@@ -1689,21 +1689,21 @@ template <ClipPathOperation* (RenderStyle::*getterFunction)() const, void (Rende > class ApplyPropertyClipPath { > public: > static void setValue(RenderStyle* style, PassRefPtr<ClipPathOperation> value) { (style->*setterFunction)(value); } >- static void applyValue(CSSPropertyID, StyleResolver* styleResolver, CSSValue* value) >+ static void applyValue(CSSPropertyID, StyleResolveState& state, CSSValue* value) > { > if (value->isPrimitiveValue()) { > CSSPrimitiveValue* primitiveValue = static_cast<CSSPrimitiveValue*>(value); > if (primitiveValue->getIdent() == CSSValueNone) >- setValue(styleResolver->style(), 0); >+ setValue(state.style(), 0); > else if (primitiveValue->isShape()) { >- setValue(styleResolver->style(), ShapeClipPathOperation::create(basicShapeForValue(styleResolver, primitiveValue->getShapeValue()))); >+ setValue(state.style(), ShapeClipPathOperation::create(basicShapeForValue(state, primitiveValue->getShapeValue()))); > } > #if ENABLE(SVG) > else if (primitiveValue->primitiveType() == CSSPrimitiveValue::CSS_URI) { > String cssURLValue = primitiveValue->getStringValue(); >- KURL url = styleResolver->document()->completeURL(cssURLValue); >+ KURL url = state.document()->completeURL(cssURLValue); > // FIXME: It doesn't work with forward or external SVG references (see https://bugs.webkit.org/show_bug.cgi?id=90405) >- setValue(styleResolver->style(), ReferenceClipPathOperation::create(cssURLValue, url.fragmentIdentifier())); >+ setValue(state.style(), ReferenceClipPathOperation::create(cssURLValue, url.fragmentIdentifier())); > } > #endif > } >@@ -1720,18 +1720,18 @@ template <ExclusionShapeValue* (RenderStyle::*getterFunction)() const, void (Ren > class ApplyPropertyExclusionShape { > public: > static void setValue(RenderStyle* style, PassRefPtr<ExclusionShapeValue> value) { (style->*setterFunction)(value); } >- static void applyValue(CSSPropertyID, StyleResolver* styleResolver, CSSValue* value) >+ static void applyValue(CSSPropertyID, StyleResolveState& state, CSSValue* value) > { > if (value->isPrimitiveValue()) { > CSSPrimitiveValue* primitiveValue = static_cast<CSSPrimitiveValue*>(value); > if (primitiveValue->getIdent() == CSSValueAuto) >- setValue(styleResolver->style(), 0); >+ setValue(state.style(), 0); > // FIXME Bug 102571: Layout for the value 'outside-shape' is not yet implemented > else if (primitiveValue->getIdent() == CSSValueOutsideShape) >- setValue(styleResolver->style(), ExclusionShapeValue::createOutsideValue()); >+ setValue(state.style(), ExclusionShapeValue::createOutsideValue()); > else if (primitiveValue->isShape()) { >- RefPtr<ExclusionShapeValue> shape = ExclusionShapeValue::createShapeValue(basicShapeForValue(styleResolver, primitiveValue->getShapeValue())); >- setValue(styleResolver->style(), shape.release()); >+ RefPtr<ExclusionShapeValue> shape = ExclusionShapeValue::createShapeValue(basicShapeForValue(state, primitiveValue->getShapeValue())); >+ setValue(state.style(), shape.release()); > } > } > } >@@ -1746,21 +1746,21 @@ public: > #if ENABLE(CSS_IMAGE_RESOLUTION) > class ApplyPropertyImageResolution { > public: >- static void applyInheritValue(CSSPropertyID propertyID, StyleResolver* styleResolver) >+ static void applyInheritValue(CSSPropertyID propertyID, StyleResolveState& state) > { >- ApplyPropertyDefaultBase<ImageResolutionSource, &RenderStyle::imageResolutionSource, ImageResolutionSource, &RenderStyle::setImageResolutionSource, ImageResolutionSource, &RenderStyle::initialImageResolutionSource>::applyInheritValue(propertyID, styleResolver); >- ApplyPropertyDefaultBase<ImageResolutionSnap, &RenderStyle::imageResolutionSnap, ImageResolutionSnap, &RenderStyle::setImageResolutionSnap, ImageResolutionSnap, &RenderStyle::initialImageResolutionSnap>::applyInheritValue(propertyID, styleResolver); >- ApplyPropertyDefaultBase<float, &RenderStyle::imageResolution, float, &RenderStyle::setImageResolution, float, &RenderStyle::initialImageResolution>::applyInheritValue(propertyID, styleResolver); >+ ApplyPropertyDefaultBase<ImageResolutionSource, &RenderStyle::imageResolutionSource, ImageResolutionSource, &RenderStyle::setImageResolutionSource, ImageResolutionSource, &RenderStyle::initialImageResolutionSource>::applyInheritValue(propertyID, state); >+ ApplyPropertyDefaultBase<ImageResolutionSnap, &RenderStyle::imageResolutionSnap, ImageResolutionSnap, &RenderStyle::setImageResolutionSnap, ImageResolutionSnap, &RenderStyle::initialImageResolutionSnap>::applyInheritValue(propertyID, state); >+ ApplyPropertyDefaultBase<float, &RenderStyle::imageResolution, float, &RenderStyle::setImageResolution, float, &RenderStyle::initialImageResolution>::applyInheritValue(propertyID, state); > } > >- static void applyInitialValue(CSSPropertyID propertyID, StyleResolver* styleResolver) >+ static void applyInitialValue(CSSPropertyID propertyID, StyleResolveState& state) > { >- ApplyPropertyDefaultBase<ImageResolutionSource, &RenderStyle::imageResolutionSource, ImageResolutionSource, &RenderStyle::setImageResolutionSource, ImageResolutionSource, &RenderStyle::initialImageResolutionSource>::applyInitialValue(propertyID, styleResolver); >- ApplyPropertyDefaultBase<ImageResolutionSnap, &RenderStyle::imageResolutionSnap, ImageResolutionSnap, &RenderStyle::setImageResolutionSnap, ImageResolutionSnap, &RenderStyle::initialImageResolutionSnap>::applyInitialValue(propertyID, styleResolver); >- ApplyPropertyDefaultBase<float, &RenderStyle::imageResolution, float, &RenderStyle::setImageResolution, float, &RenderStyle::initialImageResolution>::applyInitialValue(propertyID, styleResolver); >+ ApplyPropertyDefaultBase<ImageResolutionSource, &RenderStyle::imageResolutionSource, ImageResolutionSource, &RenderStyle::setImageResolutionSource, ImageResolutionSource, &RenderStyle::initialImageResolutionSource>::applyInitialValue(propertyID, state); >+ ApplyPropertyDefaultBase<ImageResolutionSnap, &RenderStyle::imageResolutionSnap, ImageResolutionSnap, &RenderStyle::setImageResolutionSnap, ImageResolutionSnap, &RenderStyle::initialImageResolutionSnap>::applyInitialValue(propertyID, state); >+ ApplyPropertyDefaultBase<float, &RenderStyle::imageResolution, float, &RenderStyle::setImageResolution, float, &RenderStyle::initialImageResolution>::applyInitialValue(propertyID, state); > } > >- static void applyValue(CSSPropertyID, StyleResolver* styleResolver, CSSValue* value) >+ static void applyValue(CSSPropertyID, StyleResolveState& state, CSSValue* value) > { > if (!value->isValueList()) > return; >@@ -1780,9 +1780,9 @@ public: > else > resolution = primitiveValue->getDoubleValue(CSSPrimitiveValue::CSS_DPPX); > } >- styleResolver->style()->setImageResolutionSource(source); >- styleResolver->style()->setImageResolutionSnap(snap); >- styleResolver->style()->setImageResolution(resolution); >+ state.style()->setImageResolutionSource(source); >+ state.style()->setImageResolutionSnap(snap); >+ state.style()->setImageResolution(resolution); > } > > static PropertyHandler createHandler() >diff --git a/Source/WebCore/css/StyleBuilder.h b/Source/WebCore/css/StyleBuilder.h >index 4ffe85234c13d0fbb1446e06881c9f7fefc7067b..591dda9b628e175930f85f64ca4d9c8e8e829ff4 100644 >--- a/Source/WebCore/css/StyleBuilder.h >+++ b/Source/WebCore/css/StyleBuilder.h >@@ -33,18 +33,19 @@ namespace WebCore { > > class CSSValue; > class StyleBuilder; >+class StyleResolveState; > class StyleResolver; > > class PropertyHandler { > public: >- typedef void (*InheritFunction)(CSSPropertyID, StyleResolver*); >- typedef void (*InitialFunction)(CSSPropertyID, StyleResolver*); >- typedef void (*ApplyFunction)(CSSPropertyID, StyleResolver*, CSSValue*); >+ typedef void (*InheritFunction)(CSSPropertyID, StyleResolveState&); >+ typedef void (*InitialFunction)(CSSPropertyID, StyleResolveState&); >+ typedef void (*ApplyFunction)(CSSPropertyID, StyleResolveState&, CSSValue*); > PropertyHandler() : m_inherit(0), m_initial(0), m_apply(0) { } > PropertyHandler(InheritFunction inherit, InitialFunction initial, ApplyFunction apply) : m_inherit(inherit), m_initial(initial), m_apply(apply) { } >- void applyInheritValue(CSSPropertyID propertyID, StyleResolver* styleResolver) const { ASSERT(m_inherit); (*m_inherit)(propertyID, styleResolver); } >- void applyInitialValue(CSSPropertyID propertyID, StyleResolver* styleResolver) const { ASSERT(m_initial); (*m_initial)(propertyID, styleResolver); } >- void applyValue(CSSPropertyID propertyID, StyleResolver* styleResolver, CSSValue* value) const { ASSERT(m_apply); (*m_apply)(propertyID, styleResolver, value); } >+ void applyInheritValue(CSSPropertyID propertyID, StyleResolveState& state) const { ASSERT(m_inherit); (*m_inherit)(propertyID, state); } >+ void applyInitialValue(CSSPropertyID propertyID, StyleResolveState& state) const { ASSERT(m_initial); (*m_initial)(propertyID, state); } >+ void applyValue(CSSPropertyID propertyID, StyleResolveState& state, CSSValue* value) const { ASSERT(m_apply); (*m_apply)(propertyID, state, value); } > bool isValid() const { return m_inherit && m_initial && m_apply; } > InheritFunction inheritFunction() const { return m_inherit; } > InitialFunction initialFunction() { return m_initial; } >diff --git a/Source/WebCore/css/StyleResolveState.h b/Source/WebCore/css/StyleResolveState.h >new file mode 100644 >index 0000000000000000000000000000000000000000..85efd94ff8cd3eae8dfa67e0b5372ebca17b8bf3 >--- /dev/null >+++ b/Source/WebCore/css/StyleResolveState.h >@@ -0,0 +1,235 @@ >+/* >+ * Copyright (C) 1999 Lars Knoll (knoll@kde.org) >+ * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All rights reserved. >+ * >+ * This library is free software; you can redistribute it and/or >+ * modify it under the terms of the GNU Library General Public >+ * License as published by the Free Software Foundation; either >+ * version 2 of the License, or (at your option) any later version. >+ * >+ * This library is distributed in the hope that it will be useful, >+ * but WITHOUT ANY WARRANTY; without even the implied warranty of >+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU >+ * Library General Public License for more details. >+ * >+ * You should have received a copy of the GNU Library General Public License >+ * along with this library; see the file COPYING.LIB. If not, write to >+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, >+ * Boston, MA 02110-1301, USA. >+ * >+ */ >+ >+#ifndef StyleResolveState_h >+#define StyleResolveState_h >+ >+#include "CSSRuleList.h" >+#include "Element.h" >+#include "RenderStyle.h" >+#include "SelectorChecker.h" >+#if ENABLE(CSS_FILTERS) && ENABLE(SVG) >+#include "WebKitCSSSVGDocumentValue.h" >+#endif >+#include <wtf/HashMap.h> >+#include <wtf/RefPtr.h> >+#include <wtf/Vector.h> >+ >+namespace WebCore { >+ >+typedef HashMap<CSSPropertyID, RefPtr<CSSValue> > PendingImagePropertyMap; >+#if ENABLE(CSS_FILTERS) && ENABLE(SVG) >+typedef HashMap<FilterOperation*, RefPtr<WebKitCSSSVGDocumentValue> > PendingSVGDocumentMap; >+#endif >+ >+class RenderRegion; >+class RuleData; >+ >+class StyleResolveState { >+ WTF_MAKE_NONCOPYABLE(StyleResolveState); >+public: >+ StyleResolveState() >+ : m_element(0) >+ , m_style(0) >+ , m_includeEmptyRules(false) >+ , m_sameOriginOnly(false) >+ , m_pseudoStyle(NOPSEUDO) >+ , m_mode(SelectorChecker::ResolvingStyle) >+ , m_regionForStyling(0) >+ , m_elementLinkState(NotInsideLink) >+ , m_parentNode(0) >+ , m_parentStyle(0) >+ , m_distributedToInsertionPoint(false) >+ , m_rootElementStyle(0) >+ , m_canUseFastReject(false) >+ , m_elementAffectedByClassRules(false) >+ , m_applyPropertyToRegularStyle(true) >+ , m_applyPropertyToVisitedLinkStyle(false) >+#if ENABLE(CSS_SHADERS) >+ , m_hasPendingShaders(false) >+#endif >+ , m_lineHeightValue(0) >+ , m_fontDirty(false) >+ , m_hasUAAppearance(false) >+ , m_backgroundData(BackgroundFillLayer) { } >+ >+public: >+ RenderStyle* style() const { return m_style; } >+ RenderStyle* parentStyle() const { return m_parentStyle; } >+ RenderStyle* rootElementStyle() const { return m_rootElementStyle; } >+ Element* element() const { return m_element; } >+ StyledElement* styledElement() const { return m_styledElement; } >+ Document* document() const { return m_element->document(); } >+ RenderRegion* regionForStyling() const { return m_regionForStyling; } >+ SelectorChecker::Mode mode() const { return m_mode; } >+ PseudoId pseudoStyle() const { return m_pseudoStyle; } >+ const ContainerNode* parentNode() const { return m_parentNode; } >+ EInsideLink elementLinkState() const { return m_elementLinkState; } >+ bool distributedToInsertionPoint() const { return m_distributedToInsertionPoint; } >+ >+ void setCanUseFastReject(bool canUseFastReject) { m_canUseFastReject = canUseFastReject; } >+ bool canUseFastReject() const { return m_canUseFastReject; } >+ >+ void setStyle(RenderStyle* style) { m_style = style; } >+ void setRootElementStyle(RenderStyle* rootElementStyle) { m_rootElementStyle = rootElementStyle; } >+ void setElement(Element* e) { m_element = e; m_styledElement = e && e->isStyledElement() ? toStyledElement(e) : 0; } >+ void setElementLinkState(EInsideLink elementLinkState) { m_elementLinkState = elementLinkState; } >+ void setParentNode(ContainerNode* parentNode) { m_parentNode = parentNode; } >+ void setParentStyle(RenderStyle* parentStyle) { m_parentStyle = parentStyle; } >+ void setDistributedToInsertionPoint(bool distributedToInsertionPoint) { m_distributedToInsertionPoint = distributedToInsertionPoint; } >+ void setMode(SelectorChecker::Mode mode) { m_mode = mode; } >+ void setRegionForStyling(RenderRegion* regionForStyling) { m_regionForStyling = regionForStyling; } >+ void setPseudoStyle(PseudoId pseudoStyle) { m_pseudoStyle = pseudoStyle; } >+ >+ const FontDescription& fontDescription() { return style()->fontDescription(); } >+ const FontDescription& parentFontDescription() { return parentStyle()->fontDescription(); } >+ >+ void setFontDescription(const FontDescription& fontDescription) { m_fontDirty |= style()->setFontDescription(fontDescription); } >+ >+ void setZoom(float f) { m_fontDirty |= style()->setZoom(f); } >+ void setEffectiveZoom(float f) { m_fontDirty |= style()->setEffectiveZoom(f); } >+ >+ void setTextSizeAdjust(bool b) { m_fontDirty |= style()->setTextSizeAdjust(b); } >+ void setWritingMode(WritingMode writingMode) { m_fontDirty |= style()->setWritingMode(writingMode); } >+ void setTextOrientation(TextOrientation textOrientation) { m_fontDirty |= style()->setTextOrientation(textOrientation); } >+ >+ void setApplyPropertyToRegularStyle(bool applyPropertyToRegularStyle) { m_applyPropertyToRegularStyle = applyPropertyToRegularStyle; } >+ void setApplyPropertyToVisitedLinkStyle(bool applyPropertyToVisitedLinkStyle) { m_applyPropertyToVisitedLinkStyle = applyPropertyToVisitedLinkStyle; } >+ bool applyPropertyToRegularStyle() const { return m_applyPropertyToRegularStyle; } >+ bool applyPropertyToVisitedLinkStyle() const { return m_applyPropertyToVisitedLinkStyle; } >+ >+ Vector<const RuleData*, 32>& matchedRules() { return m_matchedRules; } >+ const RuleData* matchedRuleAt(int index) { return m_matchedRules[index]; } >+ >+ void setElementAffectedByClassRules(bool affectedByClassRules) { m_elementAffectedByClassRules = affectedByClassRules; } >+ bool elementAffectedByClassRules() const { return m_elementAffectedByClassRules; } >+ >+ void cacheBorderAndBackground(RenderStyle* style) >+ { >+ ASSERT(style); >+ m_hasUAAppearance = style->hasAppearance(); >+ if (m_hasUAAppearance) { >+ m_borderData = style->border(); >+ m_backgroundData = *style->backgroundLayers(); >+ m_backgroundColor = style->backgroundColor(); >+ } >+ } >+ >+ PendingImagePropertyMap& pendingImageProperties() { return m_pendingImageProperties; } >+ >+#if ENABLE(CSS_FILTERS) && ENABLE(SVG) >+ PendingSVGDocumentMap& pendingSVGDocuments() { return m_pendingSVGDocuments; } >+#endif >+ >+ void setLineHeightValue(CSSValue* value) { m_lineHeightValue = value; } >+ CSSValue* lineHeightValue() { return m_lineHeightValue; } >+ >+ bool hasParentNode() const { return m_parentNode; } >+ >+ void setFontDirty(bool dirty) { m_fontDirty = dirty; } >+ bool fontDirty() const { return m_fontDirty; } >+ >+ StaticCSSRuleList* ensureRuleList() >+ { >+ if (!m_ruleList) >+ m_ruleList = StaticCSSRuleList::create(); >+ return m_ruleList.get(); >+ } >+ >+ RefPtr<StaticCSSRuleList>& ruleList() { return m_ruleList; } >+ >+#if ENABLE(CSS_SHADERS) >+ void setHasPendingShaders(bool hasPendingShaders) { m_hasPendingShaders = hasPendingShaders; } >+ bool hasPendingShaders() const { return m_hasPendingShaders; } >+#endif >+ >+// SVG handles zooming in a different way compared to CSS. The whole document is scaled instead >+// of each individual length value in the render style / tree. CSSPrimitiveValue::computeLength*() >+// multiplies each resolved length with the zoom multiplier - so for SVG we need to disable that. >+// Though all CSS values that can be applied to outermost <svg> elements (width/height/border/padding...) >+// need to respect the scaling. RenderBox (the parent class of RenderSVGRoot) grabs values like >+// width/height/border/padding/... from the RenderStyle -> for SVG these values would never scale, >+// if we'd pass a 1.0 zoom factor everyhwere. So we only pass a zoom factor of 1.0 for specific >+// properties that are NOT allowed to scale within a zoomed SVG document (letter/word-spacing/font-size). >+ bool useSVGZoomRules() const { return m_element && m_element->isSVGElement(); } >+ >+ bool hasUAAppearance() const { return m_hasUAAppearance; } >+ const BorderData& borderData() const { return m_borderData; } >+ const FillLayer& backgroundData() const { return m_backgroundData; } >+ Color backgroundColor() const { return m_backgroundColor; } >+ >+ void setIncludeEmptyRules(bool includeEmptyRules) { m_includeEmptyRules = includeEmptyRules; } >+ void setSameOriginOnly(bool sameOriginOnly) { m_sameOriginOnly = sameOriginOnly; } >+ bool includeEmptyRules() const { return m_includeEmptyRules; } >+ bool sameOriginOnly() const { return m_sameOriginOnly; } >+ >+private: >+ Element* m_element; >+ RenderStyle* m_style; >+ StyledElement* m_styledElement; >+ >+ bool m_includeEmptyRules; // should be moved to MatchRequest? >+ bool m_sameOriginOnly; // should be moved to MatchRequest? >+ PseudoId m_pseudoStyle; // should be moved to MatchRequest? >+ SelectorChecker::Mode m_mode; >+ >+ RenderRegion* m_regionForStyling; >+ EInsideLink m_elementLinkState; >+ >+ ContainerNode* m_parentNode; >+ RenderStyle* m_parentStyle; >+ bool m_distributedToInsertionPoint; // only styleForElement needs. >+ RenderStyle* m_rootElementStyle; // applyProperty needs. >+ >+ bool m_canUseFastReject; // collectMatchedRulesForList uses. >+ bool m_elementAffectedByClassRules; // sibling style sharing needs. >+ >+ // A buffer used to hold the set of matched rules for an element, >+ // and a temporary buffer used for merge sorting. >+ Vector<const RuleData*, 32> m_matchedRules; >+ RefPtr<StaticCSSRuleList> m_ruleList; >+ >+ // applyProperty needs. >+ bool m_applyPropertyToRegularStyle; >+ bool m_applyPropertyToVisitedLinkStyle; >+ >+ // PendingImageProperties are per-resolving member. >+ PendingImagePropertyMap m_pendingImageProperties; >+#if ENABLE(CSS_SHADERS) >+ bool m_hasPendingShaders; >+#endif >+#if ENABLE(CSS_FILTERS) && ENABLE(SVG) >+ PendingSVGDocumentMap m_pendingSVGDocuments; >+#endif >+ CSSValue* m_lineHeightValue; // cache; updated in applyProperty. >+ bool m_fontDirty; >+ >+ // border-and-background cache, it is better to move to another place? >+ bool m_hasUAAppearance; >+ BorderData m_borderData; >+ FillLayer m_backgroundData; >+ Color m_backgroundColor; >+}; >+ >+} // namespace WebCore >+ >+#endif // StyleResolveState_h >+ >diff --git a/Source/WebCore/css/StyleResolver.cpp b/Source/WebCore/css/StyleResolver.cpp >index b263d806b859586c7c14cff31f980a43252365ba..e2d406bd85d600d42fe5178a01b345abc84ca5ef 100644 >--- a/Source/WebCore/css/StyleResolver.cpp >+++ b/Source/WebCore/css/StyleResolver.cpp >@@ -44,7 +44,6 @@ > #include "CSSPrimitiveValueMappings.h" > #include "CSSPropertyNames.h" > #include "CSSReflectValue.h" >-#include "CSSRuleList.h" > #include "CSSSelector.h" > #include "CSSSelectorList.h" > #include "CSSStyleRule.h" >@@ -120,6 +119,7 @@ > #include "StyleRuleImport.h" > #include "StyleSheetContents.h" > #include "StyleSheetList.h" >+#include "StyledElement.h" > #include "Text.h" > #include "TransformationMatrix.h" > #include "TranslateTransformOperation.h" >@@ -198,14 +198,14 @@ using namespace HTMLNames; > > #define HANDLE_INHERIT(prop, Prop) \ > if (isInherit) { \ >- m_style->set##Prop(m_parentStyle->prop()); \ >+ state.style()->set##Prop(state.parentStyle()->prop()); \ > return; \ > } > > #define HANDLE_INHERIT_AND_INITIAL(prop, Prop) \ > HANDLE_INHERIT(prop, Prop) \ > if (isInitial) { \ >- m_style->set##Prop(RenderStyle::initial##Prop()); \ >+ state.style()->set##Prop(RenderStyle::initial##Prop()); \ > return; \ > } > >@@ -266,35 +266,15 @@ static StylePropertySet* rightToLeftDeclaration() > > > StyleResolver::StyleResolver(Document* document, bool matchAuthorAndUserStyles) >- : m_hasUAAppearance(false) >- , m_backgroundData(BackgroundFillLayer) >- , m_matchedPropertiesCacheAdditionsSinceLastSweep(0) >+ : m_matchedPropertiesCacheAdditionsSinceLastSweep(0) > , m_matchedPropertiesCacheSweepTimer(this, &StyleResolver::sweepMatchedPropertiesCache) > , m_document(document) >- , m_selectorChecker(document) >- , m_parentStyle(0) >- , m_rootElementStyle(0) >- , m_element(0) >- , m_styledElement(0) >- , m_regionForStyling(0) >- , m_elementLinkState(NotInsideLink) >- , m_parentNode(0) >- , m_lineHeightValue(0) >- , m_fontDirty(false) > , m_matchAuthorAndUserStyles(matchAuthorAndUserStyles) >- , m_sameOriginOnly(false) >- , m_distributedToInsertionPoint(false) > , m_fontSelector(CSSFontSelector::create(document)) > #if ENABLE(CSS_DEVICE_ADAPTATION) > , m_viewportStyleResolver(ViewportStyleResolver::create(document)) > #endif >- , m_applyPropertyToRegularStyle(true) >- , m_applyPropertyToVisitedLinkStyle(false) > , m_styleBuilder(StyleBuilder::sharedStyleBuilder()) >-#if ENABLE(CSS_SHADERS) >- , m_hasPendingShaders(false) >-#endif >- , m_styleMap(this) > { > Element* root = document->documentElement(); > >@@ -648,100 +628,102 @@ inline bool MatchingUARulesScope::isMatchingUARules() > > bool MatchingUARulesScope::m_matchingUARules = false; > >-void StyleResolver::collectMatchingRules(const MatchRequest& matchRequest, RuleRange& ruleRange) >+void StyleResolver::collectMatchingRules(RuleSet* ruleSet, StyleResolveState& state, RuleRange& ruleRange, const ContainerNode* scope) > { >- ASSERT(matchRequest.ruleSet); >- ASSERT(m_element); >+ ASSERT(ruleSet); >+ ASSERT(state.element()); > >- const AtomicString& pseudoId = m_element->shadowPseudoId(); >+ Element* element = state.element(); >+ const AtomicString& pseudoId = element->shadowPseudoId(); > if (!pseudoId.isEmpty()) { >- ASSERT(m_styledElement); >- collectMatchingRulesForList(matchRequest.ruleSet->shadowPseudoElementRules(pseudoId.impl()), matchRequest, ruleRange); >+ ASSERT(element->isStyledElement()); >+ collectMatchingRulesForList(ruleSet->shadowPseudoElementRules(pseudoId.impl()), state, ruleRange, scope); > } > > #if ENABLE(VIDEO_TRACK) >- if (m_element->isWebVTTElement() && toWebVTTElement(m_element)->webVTTNodeType()) >- collectMatchingRulesForList(matchRequest.ruleSet->cuePseudoRules(), matchRequest, ruleRange); >+ if (element->isWebVTTElement() && toWebVTTElement(element)->webVTTNodeType()) >+ collectMatchingRulesForList(ruleSet->cuePseudoRules(), state, ruleRange, scope); > #endif > // Check whether other types of rules are applicable in the current tree scope. Criteria for this: > // a) it's a UA rule > // b) the tree scope allows author rules > // c) the rules comes from a scoped style sheet within the same tree scope >- TreeScope* treeScope = m_element->treeScope(); >+ TreeScope* treeScope = element->treeScope(); > if (!MatchingUARulesScope::isMatchingUARules() > && !treeScope->applyAuthorStyles() >- && (!matchRequest.scope || matchRequest.scope->treeScope() != treeScope)) >+ && (!scope || scope->treeScope() != treeScope)) > return; > > // We need to collect the rules for id, class, tag, and everything else into a buffer and > // then sort the buffer. >- if (m_element->hasID()) >- collectMatchingRulesForList(matchRequest.ruleSet->idRules(m_element->idForStyleResolution().impl()), matchRequest, ruleRange); >- if (m_styledElement && m_styledElement->hasClass()) { >- for (size_t i = 0; i < m_styledElement->classNames().size(); ++i) >- collectMatchingRulesForList(matchRequest.ruleSet->classRules(m_styledElement->classNames()[i].impl()), matchRequest, ruleRange); >+ if (element->hasID()) >+ collectMatchingRulesForList(ruleSet->idRules(element->idForStyleResolution().impl()), state, ruleRange, scope); >+ if (state.styledElement() && state.styledElement()->hasClass()) { >+ for (size_t i = 0; i < state.styledElement()->classNames().size(); ++i) >+ collectMatchingRulesForList(ruleSet->classRules(state.styledElement()->classNames()[i].impl()), state, ruleRange, scope); > } > >- if (m_element->isLink()) >- collectMatchingRulesForList(matchRequest.ruleSet->linkPseudoClassRules(), matchRequest, ruleRange); >- if (m_selectorChecker.matchesFocusPseudoClass(m_element)) >- collectMatchingRulesForList(matchRequest.ruleSet->focusPseudoClassRules(), matchRequest, ruleRange); >- collectMatchingRulesForList(matchRequest.ruleSet->tagRules(m_element->localName().impl()), matchRequest, ruleRange); >- collectMatchingRulesForList(matchRequest.ruleSet->universalRules(), matchRequest, ruleRange); >+ if (element->isLink()) >+ collectMatchingRulesForList(ruleSet->linkPseudoClassRules(), state, ruleRange, scope); >+ if (matchesFocusPseudoClass(element)) >+ collectMatchingRulesForList(ruleSet->focusPseudoClassRules(), state, ruleRange, scope); >+ collectMatchingRulesForList(ruleSet->tagRules(element->localName().impl()), state, ruleRange, scope); >+ collectMatchingRulesForList(ruleSet->universalRules(), state, ruleRange, scope); > } > >-void StyleResolver::collectMatchingRulesForRegion(const MatchRequest& matchRequest, RuleRange& ruleRange) >+void StyleResolver::collectMatchingRulesForRegion(RuleSet* ruleSet, StyleResolveState& state, RuleRange& ruleRange, const ContainerNode* scope) > { >- if (!m_regionForStyling) >+ if (!state.regionForStyling()) > return; > >- unsigned size = matchRequest.ruleSet->m_regionSelectorsAndRuleSets.size(); >+ Element* regionStylingElement = toElement(state.regionForStyling()->node()); >+ unsigned size = ruleSet->m_regionSelectorsAndRuleSets.size(); > for (unsigned i = 0; i < size; ++i) { >- const CSSSelector* regionSelector = matchRequest.ruleSet->m_regionSelectorsAndRuleSets.at(i).selector; >- if (checkRegionSelector(regionSelector, static_cast<Element*>(m_regionForStyling->node()))) { >- RuleSet* regionRules = matchRequest.ruleSet->m_regionSelectorsAndRuleSets.at(i).ruleSet.get(); >+ const CSSSelector* regionSelector = ruleSet->m_regionSelectorsAndRuleSets.at(i).selector; >+ if (checkRegionSelector(regionSelector, regionStylingElement)) { >+ RuleSet* regionRules = ruleSet->m_regionSelectorsAndRuleSets.at(i).ruleSet.get(); > ASSERT(regionRules); >- collectMatchingRules(MatchRequest(regionRules, matchRequest.includeEmptyRules, matchRequest.scope), ruleRange); >+ collectMatchingRules(regionRules, state, ruleRange, scope); > } > } > } > >-void StyleResolver::sortAndTransferMatchedRules(MatchResult& result) >+void StyleResolver::sortAndTransferMatchedRules(StyleResolveState& state, MatchResult& result) > { >- if (m_matchedRules.isEmpty()) >+ if (state.matchedRules().isEmpty()) > return; > >- sortMatchedRules(); >+ sortMatchedRules(state.matchedRules()); > >- if (m_selectorChecker.mode() == SelectorChecker::CollectingRules) { >- if (!m_ruleList) >- m_ruleList = StaticCSSRuleList::create(); >- for (unsigned i = 0; i < m_matchedRules.size(); ++i) >- m_ruleList->rules().append(m_matchedRules[i]->rule()->createCSSOMWrapper()); >+ if (state.mode() == SelectorChecker::CollectingRules) { >+ // Should move ruleList from state to result? >+ StaticCSSRuleList* ruleList = state.ensureRuleList(); >+ for (unsigned i = 0; i < state.matchedRules().size(); ++i) >+ ruleList->rules().append(state.matchedRuleAt(i)->rule()->createCSSOMWrapper()); > return; > } > > // Now transfer the set of matched rules over to our list of declarations. >- for (unsigned i = 0; i < m_matchedRules.size(); i++) { >- if (m_style && m_matchedRules[i]->containsUncommonAttributeSelector()) >- m_style->setUnique(); >- addMatchedProperties(result, m_matchedRules[i]->rule()->properties(), m_matchedRules[i]->rule(), m_matchedRules[i]->linkMatchType(), m_matchedRules[i]->propertyWhitelistType()); >+ for (unsigned i = 0; i < state.matchedRules().size(); i++) { >+ if (state.style() && state.matchedRuleAt(i)->containsUncommonAttributeSelector()) >+ state.style()->setUnique(); >+ addMatchedProperties(result, state.matchedRuleAt(i)->rule()->properties(), state.matchedRuleAt(i)->rule(), state.matchedRuleAt(i)->linkMatchType(), state.matchedRuleAt(i)->propertyWhitelistType()); > } > } > >-void StyleResolver::matchScopedAuthorRules(MatchResult& result, bool includeEmptyRules) >+void StyleResolver::matchScopedAuthorRules(StyleResolveState& state, MatchResult& result) > { > #if ENABLE(STYLE_SCOPED) || ENABLE(SHADOW_DOM) > if (!m_scopeResolver) > return; > > // Match scoped author rules by traversing the scoped element stack (rebuild it if it got inconsistent). >- if (m_scopeResolver->hasScopedStyles() && m_scopeResolver->ensureStackConsistency(m_element)) { >- bool applyAuthorStyles = m_element->treeScope()->applyAuthorStyles(); >+ if (m_scopeResolver->hasScopedStyles() && m_scopeResolver->ensureStackConsistency(state.element())) { >+ bool applyAuthorStyles = state.element()->treeScope()->applyAuthorStyles(); > bool documentScope = true; > unsigned scopeSize = m_scopeResolver->stackSize(); > for (unsigned i = 0; i < scopeSize; ++i) { >- m_matchedRules.clear(); >+ state.matchedRules().clear(); > result.ranges.lastAuthorRule = result.matchedProperties.size() - 1; > > const StyleScopeResolver::StackFrame& frame = m_scopeResolver->stackFrameAt(i); >@@ -754,137 +736,131 @@ void StyleResolver::matchScopedAuthorRules(MatchResult& result, bool includeEmpt > continue; > } > >- MatchRequest matchRequest(frame.m_ruleSet, includeEmptyRules, frame.m_scope); > RuleRange ruleRange = result.ranges.authorRuleRange(); >- collectMatchingRules(matchRequest, ruleRange); >- collectMatchingRulesForRegion(matchRequest, ruleRange); >- sortAndTransferMatchedRules(result); >+ collectMatchingRules(frame.m_ruleSet, state, ruleRange, frame.m_scope); >+ collectMatchingRulesForRegion(frame.m_ruleSet, state, ruleRange, frame.m_scope); >+ sortAndTransferMatchedRules(state, result); > } > } > >- matchHostRules(result, includeEmptyRules); >+ matchHostRules(state, result); > #else > UNUSED_PARAM(result); > UNUSED_PARAM(includeEmptyRules); > #endif > } > >-inline bool StyleResolver::styleSharingCandidateMatchesHostRules() >+inline bool StyleResolver::styleSharingCandidateMatchesHostRules(Element* element) > { > #if ENABLE(SHADOW_DOM) >- return m_scopeResolver && m_scopeResolver->styleSharingCandidateMatchesHostRules(m_element); >+ return m_scopeResolver && m_scopeResolver->styleSharingCandidateMatchesHostRules(element); > #else > return false; > #endif > } > >-void StyleResolver::matchHostRules(MatchResult& result, bool includeEmptyRules) >+void StyleResolver::matchHostRules(StyleResolveState& state, MatchResult& result) > { > #if ENABLE(SHADOW_DOM) > ASSERT(m_scopeResolver); > >- m_matchedRules.clear(); >+ state.matchedRules().clear(); > result.ranges.lastAuthorRule = result.matchedProperties.size() - 1; > > Vector<RuleSet*> matchedRules; >- m_scopeResolver->matchHostRules(m_element, matchedRules); >+ m_scopeResolver->matchHostRules(state.element(), matchedRules); > if (matchedRules.isEmpty()) > return; > > for (unsigned i = matchedRules.size(); i > 0; --i) { > RuleRange ruleRange = result.ranges.authorRuleRange(); >- collectMatchingRules(MatchRequest(matchedRules.at(i-1), includeEmptyRules, m_element), ruleRange); >+ collectMatchingRules(matchedRules.at(i-1), state, ruleRange, state.element()); > } >- sortAndTransferMatchedRules(result); >+ sortAndTransferMatchedRules(state, result); > #else > UNUSED_PARAM(result); > UNUSED_PARAM(includeEmptyRules); > #endif > } > >-void StyleResolver::matchAuthorRules(MatchResult& result, bool includeEmptyRules) >+void StyleResolver::matchAuthorRules(StyleResolveState& state, MatchResult& result) > { >- m_matchedRules.clear(); >+ state.matchedRules().clear(); > result.ranges.lastAuthorRule = result.matchedProperties.size() - 1; > >- if (!m_element) >+ if (!state.element()) > return; > > // Match global author rules. >- MatchRequest matchRequest(m_authorStyle.get(), includeEmptyRules); > RuleRange ruleRange = result.ranges.authorRuleRange(); >- collectMatchingRules(matchRequest, ruleRange); >- collectMatchingRulesForRegion(matchRequest, ruleRange); >- sortAndTransferMatchedRules(result); >+ collectMatchingRules(m_authorStyle.get(), state, ruleRange); >+ collectMatchingRulesForRegion(m_authorStyle.get(), state, ruleRange); >+ sortAndTransferMatchedRules(state, result); > >- matchScopedAuthorRules(result, includeEmptyRules); >+ matchScopedAuthorRules(state, result); > } > >-void StyleResolver::matchUserRules(MatchResult& result, bool includeEmptyRules) >+void StyleResolver::matchUserRules(StyleResolveState& state, MatchResult& result) > { > if (!m_userStyle) > return; > >- m_matchedRules.clear(); >+ state.matchedRules().clear(); > > result.ranges.lastUserRule = result.matchedProperties.size() - 1; >- MatchRequest matchRequest(m_userStyle.get(), includeEmptyRules); > RuleRange ruleRange = result.ranges.userRuleRange(); >- collectMatchingRules(matchRequest, ruleRange); >- collectMatchingRulesForRegion(matchRequest, ruleRange); >+ collectMatchingRules(m_userStyle.get(), state, ruleRange); >+ collectMatchingRulesForRegion(m_userStyle.get(), state, ruleRange); > >- sortAndTransferMatchedRules(result); >+ sortAndTransferMatchedRules(state, result); > } > >-void StyleResolver::matchUARules(MatchResult& result, RuleSet* rules) >+void StyleResolver::matchUARules(StyleResolveState& state, MatchResult& result, RuleSet* rules) > { >- m_matchedRules.clear(); >+ state.matchedRules().clear(); > > result.ranges.lastUARule = result.matchedProperties.size() - 1; > RuleRange ruleRange = result.ranges.UARuleRange(); >- collectMatchingRules(MatchRequest(rules), ruleRange); >+ collectMatchingRules(rules, state, ruleRange); > >- sortAndTransferMatchedRules(result); >+ sortAndTransferMatchedRules(state, result); > } > >-void StyleResolver::collectMatchingRulesForList(const Vector<RuleData>* rules, const MatchRequest& matchRequest, RuleRange& ruleRange) >+void StyleResolver::collectMatchingRulesForList(const Vector<RuleData>* rules, StyleResolveState& state, RuleRange& ruleRange, const ContainerNode* scope) > { > if (!rules) > return; > >- // In some cases we may end up looking up style for random elements in the middle of a recursive tree resolve. >- // Ancestor identifier filter won't be up-to-date in that case and we can't use the fast path. >- bool canUseFastReject = m_selectorFilter.parentStackIsConsistent(m_parentNode); >- > unsigned size = rules->size(); > for (unsigned i = 0; i < size; ++i) { > const RuleData& ruleData = rules->at(i); >- if (canUseFastReject && m_selectorFilter.fastRejectSelector<RuleData::maximumIdentifierCount>(ruleData.descendantSelectorIdentifierHashes())) >+ if (state.canUseFastReject() && m_selectorFilter.fastRejectSelector<RuleData::maximumIdentifierCount>(ruleData.descendantSelectorIdentifierHashes())) > continue; > > StyleRule* rule = ruleData.rule(); > InspectorInstrumentationCookie cookie = InspectorInstrumentation::willMatchRule(document(), rule, this); >- if (ruleMatches(ruleData, matchRequest.scope)) { >+ PseudoId dynamicPseudo = NOPSEUDO; >+ if (ruleMatches(state, ruleData, scope, dynamicPseudo)) { > // If the rule has no properties to apply, then ignore it in the non-debug mode. > const StylePropertySet* properties = rule->properties(); >- if (!properties || (properties->isEmpty() && !matchRequest.includeEmptyRules)) { >+ if (!properties || (properties->isEmpty() && !state.includeEmptyRules())) { > InspectorInstrumentation::didMatchRule(cookie, false); > continue; > } > // FIXME: Exposing the non-standard getMatchedCSSRules API to web is the only reason this is needed. >- if (m_sameOriginOnly && !ruleData.hasDocumentSecurityOrigin()) { >+ if (state.sameOriginOnly() && !ruleData.hasDocumentSecurityOrigin()) { > InspectorInstrumentation::didMatchRule(cookie, false); > continue; > } > // If we're matching normal rules, set a pseudo bit if > // we really just matched a pseudo-element. >- if (m_dynamicPseudo != NOPSEUDO && m_pseudoStyle == NOPSEUDO) { >- if (m_selectorChecker.mode() == SelectorChecker::CollectingRules) { >+ if (dynamicPseudo != NOPSEUDO && state.pseudoStyle() == NOPSEUDO) { >+ if (state.mode() == SelectorChecker::CollectingRules) { > InspectorInstrumentation::didMatchRule(cookie, false); > continue; > } >- if (m_dynamicPseudo < FIRST_INTERNAL_PSEUDOID) >- m_style->setHasPseudoStyle(m_dynamicPseudo); >+ if (dynamicPseudo < FIRST_INTERNAL_PSEUDOID) >+ state.style()->setHasPseudoStyle(dynamicPseudo); > } else { > // Update our first/last rule indices in the matched rules array. > ++ruleRange.lastRuleIndex; >@@ -892,7 +868,7 @@ void StyleResolver::collectMatchingRulesForList(const Vector<RuleData>* rules, c > ruleRange.firstRuleIndex = ruleRange.lastRuleIndex; > > // Add this rule to our list of matched rules. >- addMatchedRule(&ruleData); >+ addMatchedRule(state, &ruleData); > InspectorInstrumentation::didMatchRule(cookie, true); > continue; > } >@@ -908,31 +884,33 @@ static inline bool compareRules(const RuleData* r1, const RuleData* r2) > return (specificity1 == specificity2) ? r1->position() < r2->position() : specificity1 < specificity2; > } > >-void StyleResolver::sortMatchedRules() >+void StyleResolver::sortMatchedRules(Vector<const RuleData*, 32>& matchedRules) > { >- std::sort(m_matchedRules.begin(), m_matchedRules.end(), compareRules); >+ std::sort(matchedRules.begin(), matchedRules.end(), compareRules); > } > >-void StyleResolver::matchAllRules(MatchResult& result, bool includeSMILProperties) >+void StyleResolver::matchAllRules(StyleResolveState& state, MatchResult& result, bool includeSMILProperties) > { >- matchUARules(result); >+ matchUARules(state, result); >+ // .... bad? >+ state.setIncludeEmptyRules(false); > > // Now we check user sheet rules. > if (m_matchAuthorAndUserStyles) >- matchUserRules(result, false); >- >+ matchUserRules(state, result); >+ > // Now check author rules, beginning first with presentational attributes mapped from HTML. >- if (m_styledElement) { >- addElementStyleProperties(result, m_styledElement->presentationAttributeStyle()); >+ if (state.styledElement()) { >+ addElementStyleProperties(result, state.styledElement()->presentationAttributeStyle()); > > // Now we check additional mapped declarations. > // Tables and table cells share an additional mapped rule that must be applied > // after all attributes, since their mapped style depends on the values of multiple attributes. >- addElementStyleProperties(result, m_styledElement->additionalPresentationAttributeStyle()); >+ addElementStyleProperties(result, state.styledElement()->additionalPresentationAttributeStyle()); > >- if (m_styledElement->isHTMLElement()) { >+ if (state.element()->isHTMLElement()) { > bool isAuto; >- TextDirection textDirection = toHTMLElement(m_styledElement)->directionalityIfhasDirAutoAttribute(isAuto); >+ TextDirection textDirection = toHTMLElement(state.element())->directionalityIfhasDirAutoAttribute(isAuto); > if (isAuto) > addMatchedProperties(result, textDirection == LTR ? leftToRightDeclaration() : rightToLeftDeclaration()); > } >@@ -940,21 +918,21 @@ void StyleResolver::matchAllRules(MatchResult& result, bool includeSMILPropertie > > // Check the rules in author sheets next. > if (m_matchAuthorAndUserStyles) >- matchAuthorRules(result, false); >+ matchAuthorRules(state, result); > > // Now check our inline style attribute. >- if (m_matchAuthorAndUserStyles && m_styledElement && m_styledElement->inlineStyle()) { >+ if (m_matchAuthorAndUserStyles && state.styledElement() && state.styledElement()->inlineStyle()) { > // Inline style is immutable as long as there is no CSSOM wrapper. > // FIXME: Media control shadow trees seem to have problems with caching. >- bool isInlineStyleCacheable = !m_styledElement->inlineStyle()->isMutable() && !m_styledElement->isInShadowTree(); >+ bool isInlineStyleCacheable = !state.styledElement()->inlineStyle()->isMutable() && !state.styledElement()->isInShadowTree(); > // FIXME: Constify. >- addElementStyleProperties(result, m_styledElement->inlineStyle(), isInlineStyleCacheable); >+ addElementStyleProperties(result, state.styledElement()->inlineStyle(), isInlineStyleCacheable); > } > > #if ENABLE(SVG) > // Now check SMIL animation override style. >- if (includeSMILProperties && m_matchAuthorAndUserStyles && m_styledElement && m_styledElement->isSVGElement()) >- addElementStyleProperties(result, static_cast<SVGElement*>(m_styledElement)->animatedSMILStyleProperties(), false /* isCacheable */); >+ if (includeSMILProperties && m_matchAuthorAndUserStyles && state.styledElement() && state.element()->isSVGElement()) >+ addElementStyleProperties(result, static_cast<SVGElement*>(state.element())->animatedSMILStyleProperties(), false /* isCacheable */); > #else > UNUSED_PARAM(includeSMILProperties); > #endif >@@ -969,47 +947,38 @@ bool StyleResolver::classNamesAffectedByRules(const SpaceSplitString& classNames > return false; > } > >-inline void StyleResolver::initElement(Element* e) >+inline void StyleResolver::initElement(StyleResolveState& state, Element* e) > { >- if (m_element != e) { >- m_element = e; >- m_styledElement = m_element && m_element->isStyledElement() ? static_cast<StyledElement*>(m_element) : 0; >- m_elementLinkState = document()->visitedLinkState()->determineLinkState(m_element); >- if (e && e == e->document()->documentElement()) { >- e->document()->setDirectionSetOnDocumentElement(false); >- e->document()->setWritingModeSetOnDocumentElement(false); >- } >+ state.setElement(e); >+ state.setElementLinkState(document()->visitedLinkState()->determineLinkState(e)); >+ if (e && e == e->document()->documentElement()) { >+ e->document()->setDirectionSetOnDocumentElement(false); >+ e->document()->setWritingModeSetOnDocumentElement(false); > } > } > >-inline void StyleResolver::initForStyleResolve(Element* e, RenderStyle* parentStyle, PseudoId pseudoID) >+inline void StyleResolver::initForStyleResolve(StyleResolveState& state, Element* e, RenderStyle* parentStyle) > { >- m_pseudoStyle = pseudoID; >- > if (e) { > NodeRenderingContext context(e); >- m_parentNode = context.parentNodeForRenderingAndStyle(); >- m_parentStyle = context.resetStyleInheritance() ? 0 : >+ state.setParentNode(context.parentNodeForRenderingAndStyle()); >+ state.setParentStyle(context.resetStyleInheritance() ? 0 : > parentStyle ? parentStyle : >- m_parentNode ? m_parentNode->renderStyle() : 0; >- m_distributedToInsertionPoint = context.insertionPoint(); >- } else { >- m_parentNode = 0; >- m_parentStyle = parentStyle; >- m_distributedToInsertionPoint = false; >- } >+ state.parentNode() ? state.parentNode()->renderStyle() : 0); >+ state.setDistributedToInsertionPoint(context.insertionPoint()); >+ } else >+ state.setParentStyle(parentStyle); > >+ // In some cases we may end up looking up style for random elements in the middle of a recursive tree resolve. >+ // Ancestor identifier filter won't be up-to-date in that case and we can't use the fast path. >+ state.setCanUseFastReject(m_selectorFilter.parentStackIsConsistent(state.parentNode())); >+ > Node* docElement = e ? e->document()->documentElement() : 0; > RenderStyle* docStyle = document()->renderStyle(); >- m_rootElementStyle = docElement && e != docElement ? docElement->renderStyle() : docStyle; >+ state.setRootElementStyle(docElement && e != docElement ? docElement->renderStyle() : docStyle); > >- m_style = 0; >- >- m_pendingImageProperties.clear(); >- >- m_ruleList = 0; >- >- m_fontDirty = false; >+ state.pendingImageProperties().clear(); >+ state.setFontDirty(false); > } > > static const unsigned cStyleSearchThreshold = 10; >@@ -1060,27 +1029,24 @@ Node* StyleResolver::locateCousinList(Element* parent, unsigned& visitedNodeCoun > return 0; > } > >-bool StyleResolver::styleSharingCandidateMatchesRuleSet(RuleSet* ruleSet) >+bool StyleResolver::styleSharingCandidateMatchesRuleSet(Element* element, RuleSet* ruleSet) > { > if (!ruleSet) > return false; >- m_matchedRules.clear(); > >- m_selectorChecker.setMode(SelectorChecker::SharingRules); > int firstRuleIndex = -1, lastRuleIndex = -1; > RuleRange ruleRange(firstRuleIndex, lastRuleIndex); >- collectMatchingRules(MatchRequest(ruleSet), ruleRange); >- m_selectorChecker.setMode(SelectorChecker::ResolvingStyle); >- if (m_matchedRules.isEmpty()) >- return false; >- m_matchedRules.clear(); >- return true; >+ StyleResolveState state; >+ state.setElement(element); >+ state.setMode(SelectorChecker::SharingRules); >+ collectMatchingRules(ruleSet, state, ruleRange); >+ return !state.matchedRules().isEmpty(); > } > >-bool StyleResolver::canShareStyleWithControl(StyledElement* element) const >+bool StyleResolver::canShareStyleWithControl(Element* element, StyledElement* sharingCandidate) const > { >- HTMLInputElement* thisInputElement = element->toInputElement(); >- HTMLInputElement* otherInputElement = m_element->toInputElement(); >+ HTMLInputElement* thisInputElement = sharingCandidate->toInputElement(); >+ HTMLInputElement* otherInputElement = element->toInputElement(); > > if (!thisInputElement || !otherInputElement) > return false; >@@ -1101,25 +1067,25 @@ bool StyleResolver::canShareStyleWithControl(StyledElement* element) const > if (thisInputElement->isRequired() != otherInputElement->isRequired()) > return false; > >- if (element->isEnabledFormControl() != m_element->isEnabledFormControl()) >+ if (sharingCandidate->isEnabledFormControl() != element->isEnabledFormControl()) > return false; > >- if (element->isDefaultButtonForForm() != m_element->isDefaultButtonForForm()) >+ if (sharingCandidate->isDefaultButtonForForm() != element->isDefaultButtonForForm()) > return false; > >- if (m_element->document()->containsValidityStyleRules()) { >- bool willValidate = element->willValidate(); >+ if (element->document()->containsValidityStyleRules()) { >+ bool willValidate = sharingCandidate->willValidate(); > >- if (willValidate != m_element->willValidate()) >+ if (willValidate != element->willValidate()) > return false; > >- if (willValidate && (element->isValidFormControlElement() != m_element->isValidFormControlElement())) >+ if (willValidate && (sharingCandidate->isValidFormControlElement() != element->isValidFormControlElement())) > return false; > >- if (element->isInRange() != m_element->isInRange()) >+ if (sharingCandidate->isInRange() != element->isInRange()) > return false; > >- if (element->isOutOfRange() != m_element->isOutOfRange()) >+ if (sharingCandidate->isOutOfRange() != element->isOutOfRange()) > return false; > } > >@@ -1132,27 +1098,27 @@ static inline bool elementHasDirectionAuto(Element* element) > return element->isHTMLElement() && toHTMLElement(element)->hasDirectionAuto(); > } > >-bool StyleResolver::sharingCandidateHasIdenticalStyleAffectingAttributes(StyledElement* sharingCandidate) const >+bool StyleResolver::sharingCandidateHasIdenticalStyleAffectingAttributes(StyleResolveState& state, Element* element, StyledElement* sharingCandidate) const > { >- if (m_element->attributeData() == sharingCandidate->attributeData()) >+ if (element->attributeData() == sharingCandidate->attributeData()) > return true; >- if (m_element->fastGetAttribute(XMLNames::langAttr) != sharingCandidate->fastGetAttribute(XMLNames::langAttr)) >+ if (element->fastGetAttribute(XMLNames::langAttr) != sharingCandidate->fastGetAttribute(XMLNames::langAttr)) > return false; >- if (m_element->fastGetAttribute(langAttr) != sharingCandidate->fastGetAttribute(langAttr)) >+ if (element->fastGetAttribute(langAttr) != sharingCandidate->fastGetAttribute(langAttr)) > return false; > >- if (!m_elementAffectedByClassRules) { >+ if (!state.elementAffectedByClassRules()) { > if (sharingCandidate->hasClass() && classNamesAffectedByRules(sharingCandidate->classNames())) > return false; > } else if (sharingCandidate->hasClass()) { > #if ENABLE(SVG) > // SVG elements require a (slow!) getAttribute comparision because "class" is an animatable attribute for SVG. >- if (m_element->isSVGElement()) { >- if (m_element->getAttribute(classAttr) != sharingCandidate->getAttribute(classAttr)) >+ if (element->isSVGElement()) { >+ if (element->getAttribute(classAttr) != sharingCandidate->getAttribute(classAttr)) > return false; > } else { > #endif >- if (m_element->classNames() != sharingCandidate->classNames()) >+ if (element->classNames() != sharingCandidate->classNames()) > return false; > #if ENABLE(SVG) > } >@@ -1160,12 +1126,12 @@ bool StyleResolver::sharingCandidateHasIdenticalStyleAffectingAttributes(StyledE > } else > return false; > >- if (m_styledElement->presentationAttributeStyle() != sharingCandidate->presentationAttributeStyle()) >+ if (toStyledElement(element)->presentationAttributeStyle() != sharingCandidate->presentationAttributeStyle()) > return false; > > #if ENABLE(PROGRESS_ELEMENT) >- if (m_element->hasTagName(progressTag)) { >- if (static_cast<HTMLProgressElement*>(m_element)->isDeterminate() != static_cast<HTMLProgressElement*>(sharingCandidate)->isDeterminate()) >+ if (element->hasTagName(progressTag)) { >+ if (static_cast<HTMLProgressElement*>(element)->isDeterminate() != static_cast<HTMLProgressElement*>(sharingCandidate)->isDeterminate()) > return false; > } > #endif >@@ -1173,58 +1139,59 @@ bool StyleResolver::sharingCandidateHasIdenticalStyleAffectingAttributes(StyledE > return true; > } > >-bool StyleResolver::canShareStyleWithElement(StyledElement* element) const >+bool StyleResolver::canShareStyleWithElement(StyleResolveState& state, StyledElement* sharingCandidate) const > { >- RenderStyle* style = element->renderStyle(); >+ Element* element = state.element(); >+ RenderStyle* style = sharingCandidate->renderStyle(); > > if (!style) > return false; > if (style->unique()) > return false; >- if (element->tagQName() != m_element->tagQName()) >+ if (sharingCandidate->tagQName() != element->tagQName()) > return false; >- if (element->inlineStyle()) >+ if (sharingCandidate->inlineStyle()) > return false; >- if (element->needsStyleRecalc()) >+ if (sharingCandidate->needsStyleRecalc()) > return false; > #if ENABLE(SVG) >- if (element->isSVGElement() && static_cast<SVGElement*>(element)->animatedSMILStyleProperties()) >+ if (sharingCandidate->isSVGElement() && static_cast<SVGElement*>(element)->animatedSMILStyleProperties()) > return false; > #endif >- if (element->isLink() != m_element->isLink()) >+ if (sharingCandidate->isLink() != element->isLink()) > return false; >- if (element->hovered() != m_element->hovered()) >+ if (sharingCandidate->hovered() != element->hovered()) > return false; >- if (element->active() != m_element->active()) >+ if (sharingCandidate->active() != element->active()) > return false; >- if (element->focused() != m_element->focused()) >+ if (sharingCandidate->focused() != element->focused()) > return false; >- if (element->shadowPseudoId() != m_element->shadowPseudoId()) >+ if (sharingCandidate->shadowPseudoId() != element->shadowPseudoId()) > return false; >- if (element == element->document()->cssTarget()) >+ if (element == sharingCandidate->document()->cssTarget()) > return false; >- if (!sharingCandidateHasIdenticalStyleAffectingAttributes(element)) >+ if (!sharingCandidateHasIdenticalStyleAffectingAttributes(state, element, sharingCandidate)) > return false; >- if (element->additionalPresentationAttributeStyle() != m_styledElement->additionalPresentationAttributeStyle()) >+ if (sharingCandidate->additionalPresentationAttributeStyle() != state.styledElement()->additionalPresentationAttributeStyle()) > return false; > >- if (element->hasID() && m_features.idsInRules.contains(element->idForStyleResolution().impl())) >+ if (sharingCandidate->hasID() && m_features.idsInRules.contains(sharingCandidate->idForStyleResolution().impl())) > return false; >- if (element->hasScopedHTMLStyleChild()) >+ if (sharingCandidate->hasScopedHTMLStyleChild()) > return false; > > // FIXME: We should share style for option and optgroup whenever possible. > // Before doing so, we need to resolve issues in HTMLSelectElement::recalcListItems > // and RenderMenuList::setText. See also https://bugs.webkit.org/show_bug.cgi?id=88405 >- if (element->hasTagName(optionTag) || element->hasTagName(optgroupTag)) >+ if (sharingCandidate->hasTagName(optionTag) || sharingCandidate->hasTagName(optgroupTag)) > return false; > >- bool isControl = element->isFormControlElement(); >+ bool isControl = sharingCandidate->isFormControlElement(); > >- if (isControl != m_element->isFormControlElement()) >+ if (isControl != element->isFormControlElement()) > return false; > >- if (isControl && !canShareStyleWithControl(element)) >+ if (isControl && !canShareStyleWithControl(element, sharingCandidate)) > return false; > > if (style->transitions() || style->animations()) >@@ -1233,10 +1200,10 @@ bool StyleResolver::canShareStyleWithElement(StyledElement* element) const > #if USE(ACCELERATED_COMPOSITING) > // Turn off style sharing for elements that can gain layers for reasons outside of the style system. > // See comments in RenderObject::setStyle(). >- if (element->hasTagName(iframeTag) || element->hasTagName(frameTag) || element->hasTagName(embedTag) || element->hasTagName(objectTag) || element->hasTagName(appletTag) || element->hasTagName(canvasTag) >+ if (sharingCandidate->hasTagName(iframeTag) || sharingCandidate->hasTagName(frameTag) || sharingCandidate->hasTagName(embedTag) || sharingCandidate->hasTagName(objectTag) || sharingCandidate->hasTagName(appletTag) || sharingCandidate->hasTagName(canvasTag) > #if ENABLE(PLUGIN_PROXY_FOR_VIDEO) > // With proxying, the media elements are backed by a RenderEmbeddedObject. >- || element->hasTagName(videoTag) || element->hasTagName(audioTag) >+ || sharingCandidate->hasTagName(videoTag) || sharingCandidate->hasTagName(audioTag) > #endif > ) > return false; >@@ -1245,31 +1212,31 @@ bool StyleResolver::canShareStyleWithElement(StyledElement* element) const > if (elementHasDirectionAuto(element)) > return false; > >- if (element->isLink() && m_elementLinkState != style->insideLink()) >+ if (sharingCandidate->isLink() && state.elementLinkState() != style->insideLink()) > return false; > > #if ENABLE(VIDEO_TRACK) > // Deny sharing styles between WebVTT and non-WebVTT nodes. >- if (element->isWebVTTElement() != m_element->isWebVTTElement()) >+ if (sharingCandidate->isWebVTTElement() != element->isWebVTTElement()) > return false; > >- if (element->isWebVTTElement() && m_element->isWebVTTElement() && toWebVTTElement(element)->webVTTNodeType() != toWebVTTElement(m_element)->webVTTNodeType()) >+ if (sharingCandidate->isWebVTTElement() && element->isWebVTTElement() && toWebVTTElement(element)->webVTTNodeType() != toWebVTTElement(element)->webVTTNodeType()) > return false; > #endif > > #if ENABLE(FULLSCREEN_API) >- if (element == element->document()->webkitCurrentFullScreenElement() || m_element == m_element->document()->webkitCurrentFullScreenElement()) >+ if (element == sharingCandidate->document()->webkitCurrentFullScreenElement() || element == element->document()->webkitCurrentFullScreenElement()) > return false; > #endif > return true; > } > >-inline StyledElement* StyleResolver::findSiblingForStyleSharing(Node* node, unsigned& count) const >+inline StyledElement* StyleResolver::findSiblingForStyleSharing(StyleResolveState& state, Node* node, unsigned& count) const > { > for (; node; node = node->previousSibling()) { > if (!node->isStyledElement()) > continue; >- if (canShareStyleWithElement(static_cast<StyledElement*>(node))) >+ if (canShareStyleWithElement(state, static_cast<StyledElement*>(node))) > break; > if (count++ == cStyleSearchThreshold) > return 0; >@@ -1287,40 +1254,41 @@ static inline bool parentElementPreventsSharing(const Element* parentElement) > || parentElement->childrenAffectedByDirectAdjacentRules(); > } > >-RenderStyle* StyleResolver::locateSharedStyle() >+RenderStyle* StyleResolver::locateSharedStyle(StyleResolveState& state) > { >- if (!m_styledElement || !m_parentStyle) >+ if (!state.styledElement() || !state.parentStyle()) > return 0; >+ > // If the element has inline style it is probably unique. >- if (m_styledElement->inlineStyle()) >+ if (state.styledElement()->inlineStyle()) > return 0; > #if ENABLE(SVG) >- if (m_styledElement->isSVGElement() && static_cast<SVGElement*>(m_styledElement)->animatedSMILStyleProperties()) >+ if (state.styledElement()->isSVGElement() && static_cast<SVGElement*>(state.styledElement())->animatedSMILStyleProperties()) > return 0; > #endif > // Ids stop style sharing if they show up in the stylesheets. >- if (m_styledElement->hasID() && m_features.idsInRules.contains(m_styledElement->idForStyleResolution().impl())) >+ if (state.styledElement()->hasID() && m_features.idsInRules.contains(state.styledElement()->idForStyleResolution().impl())) > return 0; >- if (parentElementPreventsSharing(m_element->parentElement())) >+ if (parentElementPreventsSharing(state.element()->parentElement())) > return 0; >- if (m_styledElement->hasScopedHTMLStyleChild()) >+ if (state.styledElement()->hasScopedHTMLStyleChild()) > return 0; >- if (m_element == m_element->document()->cssTarget()) >+ if (state.element() == state.document()->cssTarget()) > return 0; >- if (elementHasDirectionAuto(m_element)) >+ if (elementHasDirectionAuto(state.element())) > return 0; > > // Cache whether m_element is affected by any known class selectors. > // FIXME: This shouldn't be a member variable. The style sharing code could be factored out of StyleResolver. >- m_elementAffectedByClassRules = m_element && m_element->hasClass() && classNamesAffectedByRules(m_element->classNames()); >+ state.setElementAffectedByClassRules(state.element() && state.element()->hasClass() && classNamesAffectedByRules(state.element()->classNames())); > > // Check previous siblings and their cousins. > unsigned count = 0; > unsigned visitedNodeCount = 0; > StyledElement* shareElement = 0; >- Node* cousinList = m_styledElement->previousSibling(); >+ Node* cousinList = state.styledElement()->previousSibling(); > while (cousinList) { >- shareElement = findSiblingForStyleSharing(cousinList, count); >+ shareElement = findSiblingForStyleSharing(state, cousinList, count); > if (shareElement) > break; > cousinList = locateCousinList(cousinList->parentElement(), visitedNodeCount); >@@ -1331,21 +1299,21 @@ RenderStyle* StyleResolver::locateSharedStyle() > return 0; > > // Can't share if sibling rules apply. This is checked at the end as it should rarely fail. >- if (styleSharingCandidateMatchesRuleSet(m_siblingRuleSet.get())) >+ if (styleSharingCandidateMatchesRuleSet(state.element(), m_siblingRuleSet.get())) > return 0; > // Can't share if attribute rules apply. >- if (styleSharingCandidateMatchesRuleSet(m_uncommonAttributeRuleSet.get())) >+ if (styleSharingCandidateMatchesRuleSet(state.element(), m_uncommonAttributeRuleSet.get())) > return 0; > // Can't share if @host @-rules apply. >- if (styleSharingCandidateMatchesHostRules()) >+ if (styleSharingCandidateMatchesHostRules(state.element())) > return 0; > // Tracking child index requires unique style for each node. This may get set by the sibling rule match above. >- if (parentElementPreventsSharing(m_element->parentElement())) >+ if (parentElementPreventsSharing(state.element()->parentElement())) > return 0; > return shareElement->renderStyle(); > } > >-void StyleResolver::matchUARules(MatchResult& result) >+void StyleResolver::matchUARules(StyleResolveState& state, MatchResult& result) > { > MatchingUARulesScope scope; > >@@ -1354,15 +1322,15 @@ void StyleResolver::matchUARules(MatchResult& result) > result.isCacheable = false; > RuleSet* userAgentStyleSheet = m_medium->mediaTypeMatchSpecific("print") > ? defaultPrintStyle : defaultStyle; >- matchUARules(result, userAgentStyleSheet); >+ matchUARules(state, result, userAgentStyleSheet); > > // In quirks mode, we match rules from the quirks user agent sheet. >- if (!m_selectorChecker.strictParsing()) >- matchUARules(result, defaultQuirksStyle); >+ if (document()->inQuirksMode()) >+ matchUARules(state, result, defaultQuirksStyle); > > // 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. > if (document()->isViewSource()) >- matchUARules(result, viewSourceStyle()); >+ matchUARules(state, result, viewSourceStyle()); > } > > static void setStylesForPaginationMode(Pagination::Mode paginationMode, RenderStyle* style) >@@ -1560,106 +1528,104 @@ PassRefPtr<RenderStyle> StyleResolver::styleForElement(Element* element, RenderS > return s_styleNotYetAvailable; > } > >- initElement(element); >- initForStyleResolve(element, defaultParent); >- m_regionForStyling = regionForStyling; >- if (sharingBehavior == AllowStyleSharing && !m_distributedToInsertionPoint) { >- RenderStyle* sharedStyle = locateSharedStyle(); >+ StyleResolveState state; >+ initElement(state, element); >+ initForStyleResolve(state, element, defaultParent); >+ state.setRegionForStyling(regionForStyling); >+ >+ if (sharingBehavior == AllowStyleSharing && !state.distributedToInsertionPoint()) { >+ RenderStyle* sharedStyle = locateSharedStyle(state); > if (sharedStyle) > return sharedStyle; > } > > RefPtr<RenderStyle> cloneForParent; >+ RefPtr<RenderStyle> style; > >- if (m_parentStyle) { >- m_style = RenderStyle::create(); >- m_style->inheritFrom(m_parentStyle, isAtShadowBoundary(element) ? RenderStyle::AtShadowBoundary : RenderStyle::NotAtShadowBoundary); >+ if (state.parentStyle()) { >+ style = RenderStyle::create(); >+ style->inheritFrom(state.parentStyle(), isAtShadowBoundary(element) ? RenderStyle::AtShadowBoundary : RenderStyle::NotAtShadowBoundary); > } else { >- m_style = defaultStyleForElement(); >- cloneForParent = RenderStyle::clone(style()); >- m_parentStyle = cloneForParent.get(); >+ style = defaultStyleForElement(); >+ cloneForParent = RenderStyle::clone(style.get()); >+ state.setParentStyle(cloneForParent.get()); > } > // contenteditable attribute (implemented by -webkit-user-modify) should > // be propagated from shadow host to distributed node. >- if (m_distributedToInsertionPoint) { >+ if (state.distributedToInsertionPoint()) { > if (Element* parent = element->parentElement()) { > if (RenderStyle* styleOfShadowHost = parent->renderStyle()) >- m_style->setUserModify(styleOfShadowHost->userModify()); >+ style->setUserModify(styleOfShadowHost->userModify()); > } > } > > if (element->isLink()) { >- m_style->setIsLink(true); >- EInsideLink linkState = m_elementLinkState; >- if (m_elementLinkState != NotInsideLink) { >+ style->setIsLink(true); >+ EInsideLink linkState = state.elementLinkState(); >+ if (linkState != NotInsideLink) { > bool forceVisited = InspectorInstrumentation::forcePseudoState(element, CSSSelector::PseudoVisited); > if (forceVisited) > linkState = InsideVisitedLink; > } >- >- m_style->setInsideLink(linkState); >+ style->setInsideLink(linkState); > } > > ensureDefaultStyleSheetsForElement(element); > >+ state.setStyle(style.get()); >+ > MatchResult matchResult; > if (matchingBehavior == MatchOnlyUserAgentRules) >- matchUARules(matchResult); >+ matchUARules(state, matchResult); > else >- matchAllRules(matchResult, matchingBehavior != MatchAllRulesExcludingSMIL); >+ matchAllRules(state, matchResult, matchingBehavior != MatchAllRulesExcludingSMIL); > >- applyMatchedProperties(matchResult, element); >+ applyMatchedProperties(state, matchResult, element); > > // Clean up our style object's display and text decorations (among other fixups). >- adjustRenderStyle(style(), m_parentStyle, element); >- >- initElement(0); // Clear out for the next resolve. >- >- if (cloneForParent) >- m_parentStyle = 0; >+ adjustRenderStyle(state, style.get(), state.parentStyle(), element); > > document()->didAccessStyleResolver(); > > // Now return the style. >- return m_style.release(); >+ return style.release(); > } > >-PassRefPtr<RenderStyle> StyleResolver::styleForKeyframe(const RenderStyle* elementStyle, const StyleKeyframe* keyframe, KeyframeValue& keyframeValue) >+PassRefPtr<RenderStyle> StyleResolver::styleForKeyframe(StyleResolveState& state, const RenderStyle* elementStyle, const StyleKeyframe* keyframe, KeyframeValue& keyframeValue) > { > MatchResult result; > if (keyframe->properties()) > addMatchedProperties(result, keyframe->properties()); > >- ASSERT(!m_style); >- > // Create the style >- m_style = RenderStyle::clone(elementStyle); >+ RefPtr<RenderStyle> style = RenderStyle::clone(elementStyle); > >- m_lineHeightValue = 0; >+ state.setStyle(style.get()); >+ state.setLineHeightValue(0); > > // We don't need to bother with !important. Since there is only ever one > // decl, there's nothing to override. So just add the first properties. > bool inheritedOnly = false; > if (keyframe->properties()) >- applyMatchedProperties<HighPriorityProperties>(result, false, 0, result.matchedProperties.size() - 1, inheritedOnly); >+ applyMatchedProperties<HighPriorityProperties>(state, result, false, 0, result.matchedProperties.size() - 1, inheritedOnly); > > // If our font got dirtied, go ahead and update it now. >- updateFont(); >+ updateFont(state); > > // Line-height is set when we are sure we decided on the font-size >- if (m_lineHeightValue) >- applyProperty(CSSPropertyLineHeight, m_lineHeightValue); >+ if (state.lineHeightValue()) >+ applyProperty(state, CSSPropertyLineHeight, state.lineHeightValue()); > > // Now do rest of the properties. > if (keyframe->properties()) >- applyMatchedProperties<LowPriorityProperties>(result, false, 0, result.matchedProperties.size() - 1, inheritedOnly); >+ applyMatchedProperties<LowPriorityProperties>(state, result, false, 0, result.matchedProperties.size() - 1, inheritedOnly); > > // If our font got dirtied by one of the non-essential font props, > // go ahead and update it a second time. >- updateFont(); >+ updateFont(state); > > // Start loading resources referenced by this style. >- loadPendingResources(); >+ loadPendingResources(state); > > // Add all the animating properties to the keyframe. > if (const StylePropertySet* styleDeclaration = keyframe->properties()) { >@@ -1675,7 +1641,7 @@ PassRefPtr<RenderStyle> StyleResolver::styleForKeyframe(const RenderStyle* eleme > > document()->didAccessStyleResolver(); > >- return m_style.release(); >+ return style.release(); > } > > void StyleResolver::keyframeStylesForAnimation(Element* e, const RenderStyle* elementStyle, KeyframeList& list) >@@ -1696,15 +1662,16 @@ void StyleResolver::keyframeStylesForAnimation(Element* e, const RenderStyle* el > > // Construct and populate the style for each keyframe > const Vector<RefPtr<StyleKeyframe> >& keyframes = keyframesRule->keyframes(); >+ StyleResolveState state; >+ initElement(state, e); >+ initForStyleResolve(state, e); >+ > for (unsigned i = 0; i < keyframes.size(); ++i) { > // Apply the declaration to the style. This is a simplified version of the logic in styleForElement >- initElement(e); >- initForStyleResolve(e); >- > const StyleKeyframe* keyframe = keyframes[i].get(); > > KeyframeValue keyframeValue(0, 0); >- keyframeValue.setStyle(styleForKeyframe(elementStyle, keyframe, keyframeValue)); >+ keyframeValue.setStyle(styleForKeyframe(state, elementStyle, keyframe, keyframeValue)); > > // Add this keyframe style to all the indicated key times > Vector<float> keys; >@@ -1724,7 +1691,7 @@ void StyleResolver::keyframeStylesForAnimation(Element* e, const RenderStyle* el > zeroPercentKeyframe->setKeyText("0%"); > } > KeyframeValue keyframeValue(0, 0); >- keyframeValue.setStyle(styleForKeyframe(elementStyle, zeroPercentKeyframe, keyframeValue)); >+ keyframeValue.setStyle(styleForKeyframe(state, elementStyle, zeroPercentKeyframe, keyframeValue)); > list.insert(keyframeValue); > } > >@@ -1736,62 +1703,68 @@ void StyleResolver::keyframeStylesForAnimation(Element* e, const RenderStyle* el > hundredPercentKeyframe->setKeyText("100%"); > } > KeyframeValue keyframeValue(1, 0); >- keyframeValue.setStyle(styleForKeyframe(elementStyle, hundredPercentKeyframe, keyframeValue)); >+ keyframeValue.setStyle(styleForKeyframe(state, elementStyle, hundredPercentKeyframe, keyframeValue)); > list.insert(keyframeValue); > } > } > > PassRefPtr<RenderStyle> StyleResolver::pseudoStyleForElement(PseudoId pseudo, Element* e, RenderStyle* parentStyle) > { >- ASSERT(m_parentStyle); > if (!e) > return 0; > >- initElement(e); >+ StyleResolveState state; >+ initElement(state, e); >+ initForStyleResolve(state, e, parentStyle); > >- initForStyleResolve(e, parentStyle, pseudo); >- m_style = RenderStyle::create(); >- m_style->inheritFrom(m_parentStyle); >+ RefPtr<RenderStyle> style = RenderStyle::create(); >+ style->inheritFrom(state.parentStyle()); >+ state.setPseudoStyle(pseudo); >+ state.setStyle(style.get()); > > // Since we don't use pseudo-elements in any of our quirk/print user agent rules, don't waste time walking > // those rules. > > // Check UA, user and author rules. >+ > MatchResult matchResult; >- matchUARules(matchResult); >+ matchUARules(state, matchResult); > > if (m_matchAuthorAndUserStyles) { >- matchUserRules(matchResult, false); >- matchAuthorRules(matchResult, false); >+ matchUserRules(state, matchResult); >+ matchAuthorRules(state, matchResult); > } > > if (matchResult.matchedProperties.isEmpty()) > return 0; > >- m_style->setStyleType(pseudo); >+ style->setStyleType(pseudo); > >- applyMatchedProperties(matchResult, e); >+ applyMatchedProperties(state, matchResult, e); > > // Clean up our style object's display and text decorations (among other fixups). >- adjustRenderStyle(style(), parentStyle, 0); >+ adjustRenderStyle(state, style.get(), state.parentStyle(), 0); > > // Start loading resources referenced by this style. >- loadPendingResources(); >+ loadPendingResources(state); > > document()->didAccessStyleResolver(); > > // Now return the style. >- return m_style.release(); >+ return style.release(); > } > > PassRefPtr<RenderStyle> StyleResolver::styleForPage(int pageIndex) > { >- initForStyleResolve(document()->documentElement()); // m_rootElementStyle will be set to the document style. >+ StyleResolveState state; >+ initForStyleResolve(state, document()->documentElement()); // m_rootElementStyle will be set to the document style. > >- m_style = RenderStyle::create(); >- m_style->inheritFrom(m_rootElementStyle); >+ RefPtr<RenderStyle> style = RenderStyle::create(); >+ style->inheritFrom(state.rootElementStyle()); >+ state.setElement(document()->documentElement()); >+ state.setStyle(style.get()); > >- const bool isLeft = isLeftPage(pageIndex); >+ const bool isLeft = isLeftPage(state.rootElementStyle(), pageIndex); > const bool isFirst = isFirstPage(pageIndex); > const String page = pageName(pageIndex); > >@@ -1800,42 +1773,45 @@ PassRefPtr<RenderStyle> StyleResolver::styleForPage(int pageIndex) > matchPageRules(result, m_userStyle.get(), isLeft, isFirst, page); > // Only consider the global author RuleSet for @page rules, as per the HTML5 spec. > matchPageRules(result, m_authorStyle.get(), isLeft, isFirst, page); >- m_lineHeightValue = 0; >+ state.setLineHeightValue(0); > bool inheritedOnly = false; > #if ENABLE(CSS_VARIABLES) >- applyMatchedProperties<VariableDefinitions>(result, false, 0, result.matchedProperties.size() - 1, inheritedOnly); >+ applyMatchedProperties<VariableDefinitions>(state, result, false, 0, result.matchedProperties.size() - 1, inheritedOnly); > #endif >- applyMatchedProperties<HighPriorityProperties>(result, false, 0, result.matchedProperties.size() - 1, inheritedOnly); >+ applyMatchedProperties<HighPriorityProperties>(state, result, false, 0, result.matchedProperties.size() - 1, inheritedOnly); > > // If our font got dirtied, go ahead and update it now. >- updateFont(); >+ updateFont(state); > > // Line-height is set when we are sure we decided on the font-size. >- if (m_lineHeightValue) >- applyProperty(CSSPropertyLineHeight, m_lineHeightValue); >+ if (state.lineHeightValue()) >+ applyProperty(state, CSSPropertyLineHeight, state.lineHeightValue()); > >- applyMatchedProperties<LowPriorityProperties>(result, false, 0, result.matchedProperties.size() - 1, inheritedOnly); >+ applyMatchedProperties<LowPriorityProperties>(state, result, false, 0, result.matchedProperties.size() - 1, inheritedOnly); > > // Start loading resources referenced by this style. >- loadPendingResources(); >+ loadPendingResources(state); > > document()->didAccessStyleResolver(); > > // Now return the style. >- return m_style.release(); >+ return style.release(); > } > > PassRefPtr<RenderStyle> StyleResolver::defaultStyleForElement() > { >- m_style = RenderStyle::create(); >+ RefPtr<RenderStyle> style = RenderStyle::create(); >+ StyleResolveState state; >+ state.setElement(document()->documentElement()); >+ state.setStyle(style.get()); > // Make sure our fonts are initialized if we don't inherit them from our parent style. > if (Settings* settings = documentSettings()) { >- initializeFontStyle(settings); >- m_style->font().update(fontSelector()); >+ initializeFontStyle(state, settings); >+ style->font().update(fontSelector()); > } else >- m_style->font().update(0); >+ style->font().update(0); > >- return m_style.release(); >+ return style.release(); > } > > PassRefPtr<RenderStyle> StyleResolver::styleForText(Text* textNode) >@@ -1930,7 +1906,7 @@ static bool isDisplayFlexibleBox(EDisplay display) > return display == FLEX || display == INLINE_FLEX; > } > >-void StyleResolver::adjustRenderStyle(RenderStyle* style, RenderStyle* parentStyle, Element *e) >+void StyleResolver::adjustRenderStyle(StyleResolveState& state, RenderStyle* style, RenderStyle* parentStyle, Element *e) > { > ASSERT(parentStyle); > >@@ -1942,7 +1918,7 @@ void StyleResolver::adjustRenderStyle(RenderStyle* style, RenderStyle* parentSty > // property. > // Sites also commonly use display:inline/block on <td>s and <table>s. In quirks mode we force > // these tags to retain their display types. >- if (!m_selectorChecker.strictParsing() && e) { >+ if (document()->inQuirksMode() && e) { > if (e->hasTagName(tdTag)) { > style->setDisplay(TABLE_CELL); > style->setFloating(NoFloat); >@@ -1989,7 +1965,7 @@ void StyleResolver::adjustRenderStyle(RenderStyle* style, RenderStyle* parentSty > > // Absolute/fixed positioned elements, floating elements and the document element need block-like outside display. > if (style->hasOutOfFlowPosition() || style->isFloating() || (e && e->document()->documentElement() == e)) >- style->setDisplay(equivalentBlockDisplay(style->display(), style->isFloating(), m_selectorChecker.strictParsing())); >+ style->setDisplay(equivalentBlockDisplay(style->display(), style->isFloating(), !document()->inQuirksMode())); > > // FIXME: Don't support this mutation for pseudo styles like first-letter or first-line, since it's not completely > // clear how that should work. >@@ -2019,7 +1995,7 @@ void StyleResolver::adjustRenderStyle(RenderStyle* style, RenderStyle* parentSty > > if (isDisplayFlexibleBox(parentStyle->display())) { > style->setFloating(NoFloat); >- style->setDisplay(equivalentBlockDisplay(style->display(), style->isFloating(), m_selectorChecker.strictParsing())); >+ style->setDisplay(equivalentBlockDisplay(style->display(), style->isFloating(), !document()->inQuirksMode())); > } > > #if ENABLE(DIALOG_ELEMENT) >@@ -2123,7 +2099,7 @@ void StyleResolver::adjustRenderStyle(RenderStyle* style, RenderStyle* parentSty > > // Let the theme also have a crack at adjusting the style. > if (style->hasAppearance()) >- RenderTheme::defaultTheme()->adjustStyle(this, style, e, m_hasUAAppearance, m_borderData, m_backgroundData, m_backgroundColor); >+ RenderTheme::defaultTheme()->adjustStyle(this, style, e, state.hasUAAppearance(), state.borderData(), state.backgroundData(), state.backgroundColor()); > > // If we have first-letter pseudo style, do not share this style. > if (style->hasPseudoStyle(FIRST_LETTER)) >@@ -2204,27 +2180,17 @@ static void checkForOrientationChange(RenderStyle* style) > style->setFontDescription(newFontDescription); > } > >-void StyleResolver::updateFont() >+void StyleResolver::updateFont(StyleResolveState& state) > { >- if (!m_fontDirty) >+ if (!state.fontDirty()) > return; > >- checkForTextSizeAdjust(); >- checkForGenericFamilyChange(style(), m_parentStyle); >- checkForZoomChange(style(), m_parentStyle); >- checkForOrientationChange(style()); >- m_style->font().update(m_fontSelector); >- m_fontDirty = false; >-} >- >-void StyleResolver::cacheBorderAndBackground() >-{ >- m_hasUAAppearance = m_style->hasAppearance(); >- if (m_hasUAAppearance) { >- m_borderData = m_style->border(); >- m_backgroundData = *m_style->backgroundLayers(); >- m_backgroundColor = m_style->backgroundColor(); >- } >+ checkForTextSizeAdjust(state.style()); >+ checkForGenericFamilyChange(state, state.style(), state.parentStyle()); >+ checkForZoomChange(state, state.style(), state.parentStyle()); >+ checkForOrientationChange(state.style()); >+ state.style()->font().update(m_fontSelector); >+ state.setFontDirty(false); > } > > PassRefPtr<CSSRuleList> StyleResolver::styleRulesForElement(Element* e, unsigned rulesToInclude) >@@ -2237,65 +2203,69 @@ PassRefPtr<CSSRuleList> StyleResolver::pseudoStyleRulesForElement(Element* e, Ps > if (!e || !e->document()->haveStylesheetsLoaded()) > return 0; > >- m_selectorChecker.setMode(SelectorChecker::CollectingRules); >- >- initElement(e); >- initForStyleResolve(e, 0, pseudoId); >+ StyleResolveState state; >+ initElement(state, e); >+ initForStyleResolve(state, e); >+ state.setPseudoStyle(pseudoId); >+ state.setMode(SelectorChecker::CollectingRules); > > MatchResult dummy; > if (rulesToInclude & UAAndUserCSSRules) { > // First we match rules from the user agent sheet. >- matchUARules(dummy); >+ matchUARules(state, dummy); > > // Now we check user sheet rules. >- if (m_matchAuthorAndUserStyles) >- matchUserRules(dummy, rulesToInclude & EmptyCSSRules); >+ if (m_matchAuthorAndUserStyles) { >+ state.setIncludeEmptyRules(rulesToInclude & EmptyCSSRules); >+ matchUserRules(state, dummy); >+ } > } > > if (m_matchAuthorAndUserStyles && (rulesToInclude & AuthorCSSRules)) { >- m_sameOriginOnly = !(rulesToInclude & CrossOriginCSSRules); >- >+ state.setSameOriginOnly(!(rulesToInclude & CrossOriginCSSRules)); >+ state.setIncludeEmptyRules(rulesToInclude & EmptyCSSRules); >+ > // Check the rules in author sheets. >- matchAuthorRules(dummy, rulesToInclude & EmptyCSSRules); >- >- m_sameOriginOnly = false; >+ matchAuthorRules(state, dummy); > } >- >- m_selectorChecker.setMode(SelectorChecker::ResolvingStyle); >- >- return m_ruleList.release(); >+ return state.ruleList().release(); > } > >-inline bool StyleResolver::ruleMatches(const RuleData& ruleData, const ContainerNode* scope) >+inline bool StyleResolver::ruleMatches(StyleResolveState& state, const RuleData& ruleData, const ContainerNode* scope, PseudoId& dynamicPseudo) > { >- m_dynamicPseudo = NOPSEUDO; >+ Element* element = state.element(); > > if (ruleData.hasFastCheckableSelector()) { > // We know this selector does not include any pseudo elements. >- if (m_pseudoStyle != NOPSEUDO) >+ if (state.pseudoStyle() != NOPSEUDO) > return false; > // We know a sufficiently simple single part selector matches simply because we found it from the rule hash. > // This is limited to HTML only so we don't need to check the namespace. >- if (ruleData.hasRightmostSelectorMatchingHTMLBasedOnRuleHash() && m_element->isHTMLElement()) { >+ if (ruleData.hasRightmostSelectorMatchingHTMLBasedOnRuleHash() && element->isHTMLElement()) { > if (!ruleData.hasMultipartSelector()) > return true; > } >- if (ruleData.selector()->m_match == CSSSelector::Tag && !SelectorChecker::tagMatches(m_element, ruleData.selector()->tagQName())) >+ if (ruleData.selector()->m_match == CSSSelector::Tag && !SelectorChecker::tagMatches(element, ruleData.selector()->tagQName())) > return false; >- if (!SelectorChecker::fastCheckRightmostAttributeSelector(m_element, ruleData.selector())) >+ if (!SelectorChecker::fastCheckRightmostAttributeSelector(element, ruleData.selector())) > return false; >- return m_selectorChecker.fastCheck(ruleData.selector(), m_element); >+ >+ return SelectorChecker::fastCheck(ruleData.selector(), element); > } > > // Slow path. >- SelectorChecker::SelectorCheckingContext context(ruleData.selector(), m_element, SelectorChecker::VisitedMatchEnabled); >- context.elementStyle = style(); >+ SelectorChecker::SelectorCheckingContext context(ruleData.selector(), element, SelectorChecker::VisitedMatchEnabled); >+ context.elementStyle = state.style(); > context.scope = scope; >- context.pseudoStyle = m_pseudoStyle; >- SelectorChecker::Match match = m_selectorChecker.match(context, m_dynamicPseudo, DOMSiblingTraversalStrategy()); >+ context.pseudoStyle = state.pseudoStyle(); >+ >+ // on-stack >+ SelectorChecker selectorChecker(document()); >+ selectorChecker.setMode(state.mode()); >+ SelectorChecker::Match match = selectorChecker.match(context, dynamicPseudo, DOMSiblingTraversalStrategy()); > if (match != SelectorChecker::SelectorMatches) > return false; >- if (m_pseudoStyle != NOPSEUDO && m_pseudoStyle != m_dynamicPseudo) >+ if (state.pseudoStyle() != NOPSEUDO && state.pseudoStyle() != dynamicPseudo) > return false; > return true; > } >@@ -2305,10 +2275,9 @@ bool StyleResolver::checkRegionSelector(const CSSSelector* regionSelector, Eleme > if (!regionSelector || !regionElement) > return false; > >- m_pseudoStyle = NOPSEUDO; >- >+ SelectorChecker selectorChecker(document()); > for (const CSSSelector* s = regionSelector; s; s = CSSSelectorList::next(s)) >- if (m_selectorChecker.matches(s, regionElement)) >+ if (selectorChecker.matches(s, regionElement)) > return true; > > return false; >@@ -2328,9 +2297,9 @@ Length StyleResolver::convertToFloatLength(CSSPrimitiveValue* primitiveValue, Re > } > > template <StyleResolver::StyleApplicationPass pass> >-void StyleResolver::applyProperties(const StylePropertySet* properties, StyleRule* rule, bool isImportant, bool inheritedOnly, PropertyWhitelistType propertyWhitelistType) >+void StyleResolver::applyProperties(StyleResolveState& state, const StylePropertySet* properties, StyleRule* rule, bool isImportant, bool inheritedOnly, PropertyWhitelistType propertyWhitelistType) > { >- ASSERT((propertyWhitelistType != PropertyWhitelistRegion) || m_regionForStyling); >+ ASSERT((propertyWhitelistType != PropertyWhitelistRegion) || state.regionForStyling()); > InspectorInstrumentationCookie cookie = InspectorInstrumentation::willProcessRule(document(), rule, this); > > unsigned propertyCount = properties->propertyCount(); >@@ -2358,7 +2327,7 @@ void StyleResolver::applyProperties(const StylePropertySet* properties, StyleRul > case VariableDefinitions: > COMPILE_ASSERT(CSSPropertyVariable < firstCSSProperty, CSS_variable_is_before_first_property); > if (property == CSSPropertyVariable) >- applyProperty(current.id(), current.value()); >+ applyProperty(state, current.id(), current.value()); > break; > #endif > case HighPriorityProperties: >@@ -2371,42 +2340,43 @@ void StyleResolver::applyProperties(const StylePropertySet* properties, StyleRul > #endif > // give special priority to font-xxx, color properties, etc > if (property < CSSPropertyLineHeight) >- applyProperty(current.id(), current.value()); >+ applyProperty(state, current.id(), current.value()); > // we apply line-height later > else if (property == CSSPropertyLineHeight) >- m_lineHeightValue = current.value(); >+ state.setLineHeightValue(current.value()); > break; > case LowPriorityProperties: > if (property > CSSPropertyLineHeight) >- applyProperty(current.id(), current.value()); >+ applyProperty(state, current.id(), current.value()); > } > } > InspectorInstrumentation::didProcessRule(cookie); > } > > template <StyleResolver::StyleApplicationPass pass> >-void StyleResolver::applyMatchedProperties(const MatchResult& matchResult, bool isImportant, int startIndex, int endIndex, bool inheritedOnly) >+void StyleResolver::applyMatchedProperties(StyleResolveState& state, const MatchResult& matchResult, bool isImportant, int startIndex, int endIndex, bool inheritedOnly) > { > if (startIndex == -1) > return; > >- if (m_style->insideLink() != NotInsideLink) { >+ if (state.style()->insideLink() != NotInsideLink) { > for (int i = startIndex; i <= endIndex; ++i) { > const MatchedProperties& matchedProperties = matchResult.matchedProperties[i]; > unsigned linkMatchType = matchedProperties.linkMatchType; > // FIXME: It would be nicer to pass these as arguments but that requires changes in many places. >- m_applyPropertyToRegularStyle = linkMatchType & SelectorChecker::MatchLink; >- m_applyPropertyToVisitedLinkStyle = linkMatchType & SelectorChecker::MatchVisited; >+ state.setApplyPropertyToRegularStyle(linkMatchType & SelectorChecker::MatchLink); >+ state.setApplyPropertyToVisitedLinkStyle(linkMatchType & SelectorChecker::MatchVisited); > >- applyProperties<pass>(matchedProperties.properties.get(), matchResult.matchedRules[i], isImportant, inheritedOnly, static_cast<PropertyWhitelistType>(matchedProperties.whitelistType)); >+ applyProperties<pass>(state, matchedProperties.properties.get(), matchResult.matchedRules[i], isImportant, inheritedOnly, static_cast<PropertyWhitelistType>(matchedProperties.whitelistType)); > } >- m_applyPropertyToRegularStyle = true; >- m_applyPropertyToVisitedLinkStyle = false; >+ // need to revert? I think, we don't need... >+ state.setApplyPropertyToRegularStyle(true); >+ state.setApplyPropertyToVisitedLinkStyle(false); > return; > } > for (int i = startIndex; i <= endIndex; ++i) { > const MatchedProperties& matchedProperties = matchResult.matchedProperties[i]; >- applyProperties<pass>(matchedProperties.properties.get(), matchResult.matchedRules[i], isImportant, inheritedOnly, static_cast<PropertyWhitelistType>(matchedProperties.whitelistType)); >+ applyProperties<pass>(state, matchedProperties.properties.get(), matchResult.matchedRules[i], isImportant, inheritedOnly, static_cast<PropertyWhitelistType>(matchedProperties.whitelistType)); > } > } > >@@ -2505,9 +2475,11 @@ static bool isCacheableInMatchedPropertiesCache(const Element* element, const Re > return true; > } > >-void StyleResolver::applyMatchedProperties(const MatchResult& matchResult, const Element* element) >+void StyleResolver::applyMatchedProperties(StyleResolveState& state, const MatchResult& matchResult, const Element* element) > { > ASSERT(element); >+ RenderStyle* style = state.style(); >+ RenderStyle* parentStyle = state.parentStyle(); > unsigned cacheHash = matchResult.isCacheable ? computeMatchedPropertiesHash(matchResult.matchedProperties.data(), matchResult.matchedProperties.size()) : 0; > bool applyInheritedOnly = false; > const MatchedPropertiesCacheItem* cacheItem = 0; >@@ -2515,15 +2487,16 @@ void StyleResolver::applyMatchedProperties(const MatchResult& matchResult, const > // We can build up the style by copying non-inherited properties from an earlier style object built using the same exact > // style declarations. We then only need to apply the inherited properties, if any, as their values can depend on the > // element context. This is fast and saves memory by reusing the style data structures. >- m_style->copyNonInheritedFrom(cacheItem->renderStyle.get()); >- if (m_parentStyle->inheritedDataShared(cacheItem->parentRenderStyle.get()) && !isAtShadowBoundary(element)) { >- EInsideLink linkStatus = m_style->insideLink(); >+ style->copyNonInheritedFrom(cacheItem->renderStyle.get()); >+ // orz >+ if (parentStyle->inheritedDataShared(cacheItem->parentRenderStyle.get()) && !isAtShadowBoundary(element)) { >+ EInsideLink linkStatus = style->insideLink(); > // If the cache item parent style has identical inherited properties to the current parent style then the > // resulting style will be identical too. We copy the inherited properties over from the cache and are done. >- m_style->inheritFrom(cacheItem->renderStyle.get()); >+ style->inheritFrom(cacheItem->renderStyle.get()); > > // Unfortunately the link status is treated like an inherited property. We need to explicitly restore it. >- m_style->setInsideLink(linkStatus); >+ style->setInsideLink(linkStatus); > return; > } > applyInheritedOnly = true; >@@ -2531,60 +2504,60 @@ void StyleResolver::applyMatchedProperties(const MatchResult& matchResult, const > > #if ENABLE(CSS_VARIABLES) > // First apply all variable definitions, as they may be used during application of later properties. >- applyMatchedProperties<VariableDefinitions>(matchResult, false, 0, matchResult.matchedProperties.size() - 1, applyInheritedOnly); >- applyMatchedProperties<VariableDefinitions>(matchResult, true, matchResult.ranges.firstAuthorRule, matchResult.ranges.lastAuthorRule, applyInheritedOnly); >- applyMatchedProperties<VariableDefinitions>(matchResult, true, matchResult.ranges.firstUserRule, matchResult.ranges.lastUserRule, applyInheritedOnly); >- applyMatchedProperties<VariableDefinitions>(matchResult, true, matchResult.ranges.firstUARule, matchResult.ranges.lastUARule, applyInheritedOnly); >+ applyMatchedProperties<VariableDefinitions>(state, matchResult, false, 0, matchResult.matchedProperties.size() - 1, applyInheritedOnly); >+ applyMatchedProperties<VariableDefinitions>(state, matchResult, true, matchResult.ranges.firstAuthorRule, matchResult.ranges.lastAuthorRule, applyInheritedOnly); >+ applyMatchedProperties<VariableDefinitions>(state, matchResult, true, matchResult.ranges.firstUserRule, matchResult.ranges.lastUserRule, applyInheritedOnly); >+ applyMatchedProperties<VariableDefinitions>(state, matchResult, true, matchResult.ranges.firstUARule, matchResult.ranges.lastUARule, applyInheritedOnly); > #endif > > // Now we have all of the matched rules in the appropriate order. Walk the rules and apply > // high-priority properties first, i.e., those properties that other properties depend on. > // The order is (1) high-priority not important, (2) high-priority important, (3) normal not important > // and (4) normal important. >- m_lineHeightValue = 0; >- applyMatchedProperties<HighPriorityProperties>(matchResult, false, 0, matchResult.matchedProperties.size() - 1, applyInheritedOnly); >- applyMatchedProperties<HighPriorityProperties>(matchResult, true, matchResult.ranges.firstAuthorRule, matchResult.ranges.lastAuthorRule, applyInheritedOnly); >- applyMatchedProperties<HighPriorityProperties>(matchResult, true, matchResult.ranges.firstUserRule, matchResult.ranges.lastUserRule, applyInheritedOnly); >- applyMatchedProperties<HighPriorityProperties>(matchResult, true, matchResult.ranges.firstUARule, matchResult.ranges.lastUARule, applyInheritedOnly); >- >- if (cacheItem && cacheItem->renderStyle->effectiveZoom() != m_style->effectiveZoom()) { >- m_fontDirty = true; >+ state.setLineHeightValue(0); >+ applyMatchedProperties<HighPriorityProperties>(state, matchResult, false, 0, matchResult.matchedProperties.size() - 1, applyInheritedOnly); >+ applyMatchedProperties<HighPriorityProperties>(state, matchResult, true, matchResult.ranges.firstAuthorRule, matchResult.ranges.lastAuthorRule, applyInheritedOnly); >+ applyMatchedProperties<HighPriorityProperties>(state, matchResult, true, matchResult.ranges.firstUserRule, matchResult.ranges.lastUserRule, applyInheritedOnly); >+ applyMatchedProperties<HighPriorityProperties>(state, matchResult, true, matchResult.ranges.firstUARule, matchResult.ranges.lastUARule, applyInheritedOnly); >+ >+ if (cacheItem && cacheItem->renderStyle->effectiveZoom() != style->effectiveZoom()) { >+ state.setFontDirty(true); > applyInheritedOnly = false; > } > > // If our font got dirtied, go ahead and update it now. >- updateFont(); >+ updateFont(state); > > // Line-height is set when we are sure we decided on the font-size. >- if (m_lineHeightValue) >- applyProperty(CSSPropertyLineHeight, m_lineHeightValue); >+ if (state.lineHeightValue()) >+ applyProperty(state, CSSPropertyLineHeight, state.lineHeightValue()); > > // Many properties depend on the font. If it changes we just apply all properties. >- if (cacheItem && cacheItem->renderStyle->fontDescription() != m_style->fontDescription()) >+ if (cacheItem && cacheItem->renderStyle->fontDescription() != style->fontDescription()) > applyInheritedOnly = false; > > // Now do the normal priority UA properties. >- applyMatchedProperties<LowPriorityProperties>(matchResult, false, matchResult.ranges.firstUARule, matchResult.ranges.lastUARule, applyInheritedOnly); >+ applyMatchedProperties<LowPriorityProperties>(state, matchResult, false, matchResult.ranges.firstUARule, matchResult.ranges.lastUARule, applyInheritedOnly); > > // Cache our border and background so that we can examine them later. >- cacheBorderAndBackground(); >+ state.cacheBorderAndBackground(state.style()); > > // Now do the author and user normal priority properties and all the !important properties. >- applyMatchedProperties<LowPriorityProperties>(matchResult, false, matchResult.ranges.lastUARule + 1, matchResult.matchedProperties.size() - 1, applyInheritedOnly); >- applyMatchedProperties<LowPriorityProperties>(matchResult, true, matchResult.ranges.firstAuthorRule, matchResult.ranges.lastAuthorRule, applyInheritedOnly); >- applyMatchedProperties<LowPriorityProperties>(matchResult, true, matchResult.ranges.firstUserRule, matchResult.ranges.lastUserRule, applyInheritedOnly); >- applyMatchedProperties<LowPriorityProperties>(matchResult, true, matchResult.ranges.firstUARule, matchResult.ranges.lastUARule, applyInheritedOnly); >+ applyMatchedProperties<LowPriorityProperties>(state, matchResult, false, matchResult.ranges.lastUARule + 1, matchResult.matchedProperties.size() - 1, applyInheritedOnly); >+ applyMatchedProperties<LowPriorityProperties>(state, matchResult, true, matchResult.ranges.firstAuthorRule, matchResult.ranges.lastAuthorRule, applyInheritedOnly); >+ applyMatchedProperties<LowPriorityProperties>(state, matchResult, true, matchResult.ranges.firstUserRule, matchResult.ranges.lastUserRule, applyInheritedOnly); >+ applyMatchedProperties<LowPriorityProperties>(state, matchResult, true, matchResult.ranges.firstUARule, matchResult.ranges.lastUARule, applyInheritedOnly); > > // Start loading resources referenced by this style. >- loadPendingResources(); >+ loadPendingResources(state); > >- ASSERT(!m_fontDirty); >+ ASSERT(!state.fontDirty()); > > if (cacheItem || !cacheHash) > return; >- if (!isCacheableInMatchedPropertiesCache(m_element, m_style.get(), m_parentStyle)) >+ if (!isCacheableInMatchedPropertiesCache(element, style, parentStyle)) > return; >- addToMatchedPropertiesCache(m_style.get(), m_parentStyle, cacheHash, matchResult); >+ addToMatchedPropertiesCache(style, parentStyle, cacheHash, matchResult); > } > > static inline bool comparePageRules(const StyleRulePage* r1, const StyleRulePage* r2) >@@ -2646,10 +2619,10 @@ void StyleResolver::matchPageRulesForList(Vector<StyleRulePage*>& matchedRules, > } > } > >-bool StyleResolver::isLeftPage(int pageIndex) const >+bool StyleResolver::isLeftPage(RenderStyle* rootElementStyle, int pageIndex) const > { > bool isFirstPageLeft = false; >- if (!m_rootElementStyle->isLeftToRightDirection()) >+ if (!rootElementStyle->isLeftToRightDirection()) > isFirstPageLeft = true; > > return (pageIndex + (isFirstPageLeft ? 1 : 0)) % 2; >@@ -2745,18 +2718,32 @@ CSSStyleRule* StyleResolver::ensureFullCSSOMWrapperForInspector(StyleRule* rule) > return m_styleRuleToCSSOMWrapperMap.get(rule).get(); > } > >-void StyleResolver::applyPropertyToStyle(CSSPropertyID id, CSSValue* value, RenderStyle* style) >+void StyleResolver::applyPropertyWithValueChecking(StyleResolveState& state, CSSPropertyID id, CSSValue* value) > { >- initElement(0); >- initForStyleResolve(0, style); >- m_style = style; >- applyPropertyToCurrentStyle(id, value); >+ if (value) >+ applyProperty(state, id, value); > } > >-void StyleResolver::applyPropertyToCurrentStyle(CSSPropertyID id, CSSValue* value) >+void StyleResolver::applyFontPropertyToStyle(RenderStyle* target, const StylePropertySet* reference) > { >- if (value) >- applyProperty(id, value); >+ StyleResolveState state; >+ initElement(state, 0); >+ initForStyleResolve(state, 0, target); >+ state.setElement(document()->documentElement()); >+ state.setStyle(target); >+ >+ applyPropertyWithValueChecking(state, CSSPropertyFontFamily, reference->getPropertyCSSValue(CSSPropertyFontFamily).get()); >+ applyPropertyWithValueChecking(state, CSSPropertyFontStyle, reference->getPropertyCSSValue(CSSPropertyFontStyle).get()); >+ applyPropertyWithValueChecking(state, CSSPropertyFontVariant, reference->getPropertyCSSValue(CSSPropertyFontVariant).get()); >+ applyPropertyWithValueChecking(state, CSSPropertyFontWeight, reference->getPropertyCSSValue(CSSPropertyFontWeight).get()); >+ >+ // As described in BUG66291, setting font-size and line-height on a font may entail a CSSPrimitiveValue::computeLengthDouble call, >+ // which assumes the fontMetrics are available for the affected font, otherwise a crash occurs (see http://trac.webkit.org/changeset/96122). >+ // The updateFont() calls below update the fontMetrics and ensure the proper setting of font-size and line-height. >+ updateFont(state); >+ applyPropertyWithValueChecking(state, CSSPropertyFontSize, reference->getPropertyCSSValue(CSSPropertyFontSize).get()); >+ updateFont(state); >+ applyPropertyWithValueChecking(state, CSSPropertyLineHeight, reference->getPropertyCSSValue(CSSPropertyLineHeight).get()); > } > > inline bool isValidVisitedLinkProperty(CSSPropertyID id) >@@ -2851,20 +2838,7 @@ inline bool StyleResolver::isValidCueStyleProperty(CSSPropertyID id) > return false; > } > #endif >-// SVG handles zooming in a different way compared to CSS. The whole document is scaled instead >-// of each individual length value in the render style / tree. CSSPrimitiveValue::computeLength*() >-// multiplies each resolved length with the zoom multiplier - so for SVG we need to disable that. >-// Though all CSS values that can be applied to outermost <svg> elements (width/height/border/padding...) >-// need to respect the scaling. RenderBox (the parent class of RenderSVGRoot) grabs values like >-// width/height/border/padding/... from the RenderStyle -> for SVG these values would never scale, >-// if we'd pass a 1.0 zoom factor everyhwere. So we only pass a zoom factor of 1.0 for specific >-// properties that are NOT allowed to scale within a zoomed SVG document (letter/word-spacing/font-size). >-bool StyleResolver::useSVGZoomRules() >-{ >- return m_element && m_element->isSVGElement(); >-} >- >-static bool createGridTrackBreadth(CSSPrimitiveValue* primitiveValue, StyleResolver* selector, Length& workingLength) >+static bool createGridTrackBreadth(CSSPrimitiveValue* primitiveValue, StyleResolveState& state, Length& workingLength) > { > if (primitiveValue->getIdent() == CSSValueWebkitMinContent) { > workingLength = Length(MinContent); >@@ -2876,7 +2850,7 @@ static bool createGridTrackBreadth(CSSPrimitiveValue* primitiveValue, StyleResol > return true; > } > >- workingLength = primitiveValue->convertToLength<FixedIntegerConversion | PercentConversion | ViewportPercentageConversion | AutoConversion>(selector->style(), selector->rootElementStyle(), selector->style()->effectiveZoom()); >+ workingLength = primitiveValue->convertToLength<FixedIntegerConversion | PercentConversion | ViewportPercentageConversion | AutoConversion>(state.style(), state.rootElementStyle(), state.style()->effectiveZoom()); > if (workingLength.isUndefined()) > return false; > >@@ -2886,12 +2860,12 @@ static bool createGridTrackBreadth(CSSPrimitiveValue* primitiveValue, StyleResol > return true; > } > >-static bool createGridTrackMinMax(CSSPrimitiveValue* primitiveValue, StyleResolver* selector, GridTrackSize& trackSize) >+static bool createGridTrackMinMax(CSSPrimitiveValue* primitiveValue, StyleResolveState& state, GridTrackSize& trackSize) > { > Pair* minMaxTrackBreadth = primitiveValue->getPairValue(); > if (!minMaxTrackBreadth) { > Length workingLength; >- if (!createGridTrackBreadth(primitiveValue, selector, workingLength)) >+ if (!createGridTrackBreadth(primitiveValue, state, workingLength)) > return false; > > trackSize.setLength(workingLength); >@@ -2900,14 +2874,14 @@ static bool createGridTrackMinMax(CSSPrimitiveValue* primitiveValue, StyleResolv > > Length minTrackBreadth; > Length maxTrackBreadth; >- if (!createGridTrackBreadth(minMaxTrackBreadth->first(), selector, minTrackBreadth) || !createGridTrackBreadth(minMaxTrackBreadth->second(), selector, maxTrackBreadth)) >+ if (!createGridTrackBreadth(minMaxTrackBreadth->first(), state, minTrackBreadth) || !createGridTrackBreadth(minMaxTrackBreadth->second(), state, maxTrackBreadth)) > return false; > > trackSize.setMinMax(minTrackBreadth, maxTrackBreadth); > return true; > } > >-static bool createGridTrackGroup(CSSValue* value, StyleResolver* selector, Vector<GridTrackSize>& trackSizes) >+static bool createGridTrackGroup(CSSValue* value, StyleResolveState& state, Vector<GridTrackSize>& trackSizes) > { > if (!value->isValueList()) > return false; >@@ -2918,7 +2892,7 @@ static bool createGridTrackGroup(CSSValue* value, StyleResolver* selector, Vecto > return false; > > GridTrackSize trackSize; >- if (!createGridTrackMinMax(static_cast<CSSPrimitiveValue*>(currValue), selector, trackSize)) >+ if (!createGridTrackMinMax(static_cast<CSSPrimitiveValue*>(currValue), state, trackSize)) > return false; > > trackSizes.append(trackSize); >@@ -2926,7 +2900,7 @@ static bool createGridTrackGroup(CSSValue* value, StyleResolver* selector, Vecto > return true; > } > >-static bool createGridTrackList(CSSValue* value, Vector<GridTrackSize>& trackSizes, StyleResolver* selector) >+static bool createGridTrackList(CSSValue* value, Vector<GridTrackSize>& trackSizes, StyleResolveState& state) > { > // Handle 'none'. > if (value->isPrimitiveValue()) { >@@ -2934,7 +2908,7 @@ static bool createGridTrackList(CSSValue* value, Vector<GridTrackSize>& trackSiz > return primitiveValue->getIdent() == CSSValueNone; > } > >- return createGridTrackGroup(value, selector, trackSizes); >+ return createGridTrackGroup(value, state, trackSizes); > } > > >@@ -2980,9 +2954,9 @@ static bool hasVariableReference(CSSValue* value) > return false; > } > >-void StyleResolver::resolveVariables(CSSPropertyID id, CSSValue* value, Vector<std::pair<CSSPropertyID, String> >& knownExpressions) >+void StyleResolver::resolveVariables(StyleResolveState& state, CSSPropertyID id, CSSValue* value, Vector<std::pair<CSSPropertyID, String> >& knownExpressions) > { >- std::pair<CSSPropertyID, String> expression(id, value->serializeResolvingVariables(*style()->variables())); >+ std::pair<CSSPropertyID, String> expression(id, value->serializeResolvingVariables(*state.style()->variables())); > > if (knownExpressions.contains(expression)) > return; // cycle detected. >@@ -2997,36 +2971,36 @@ void StyleResolver::resolveVariables(CSSPropertyID id, CSSValue* value, Vector<s > for (unsigned i = 0; i < resultSet->propertyCount(); i++) { > StylePropertySet::PropertyReference property = resultSet->propertyAt(i); > if (property.id() != CSSPropertyVariable && hasVariableReference(property.value())) >- resolveVariables(property.id(), property.value(), knownExpressions); >+ resolveVariables(state, property.id(), property.value(), knownExpressions); > else >- applyProperty(property.id(), property.value()); >+ applyProperty(state, property.id(), property.value()); > } > } > #endif > >-void StyleResolver::applyProperty(CSSPropertyID id, CSSValue* value) >+void StyleResolver::applyProperty(StyleResolveState& state, CSSPropertyID id, CSSValue* value) > { > #if ENABLE(CSS_VARIABLES) > if (id != CSSPropertyVariable && hasVariableReference(value)) { > Vector<std::pair<CSSPropertyID, String> > knownExpressions; >- resolveVariables(id, value, knownExpressions); >+ resolveVariables(state, id, value, knownExpressions); > return; > } > #endif > >- bool isInherit = m_parentNode && value->isInheritedValue(); >- bool isInitial = value->isInitialValue() || (!m_parentNode && value->isInheritedValue()); >+ bool isInherit = state.parentNode() && value->isInheritedValue(); >+ bool isInitial = value->isInitialValue() || (!state.parentNode() && value->isInheritedValue()); > >- ASSERT(!isInherit || !isInitial); // isInherit -> !isInitial && isInitial -> !isInherit >- ASSERT(!isInherit || (m_parentNode && m_parentStyle)); // isInherit -> (m_parentNode && m_parentStyle) >+ ASSERT(!isInherit || !isInitial); >+ ASSERT(!isInherit || (state.parentNode() && state.parentStyle())); > >- if (!applyPropertyToRegularStyle() && (!applyPropertyToVisitedLinkStyle() || !isValidVisitedLinkProperty(id))) { >+ if (!state.applyPropertyToRegularStyle() && (!state.applyPropertyToVisitedLinkStyle() || !isValidVisitedLinkProperty(id))) { > // Limit the properties that can be applied to only the ones honored by :visited. > return; > } > >- if (isInherit && !m_parentStyle->hasExplicitlyInheritedProperties() && !CSSProperty::isInheritedProperty(id)) >- m_parentStyle->setHasExplicitlyInheritedProperties(); >+ if (isInherit && !state.parentStyle()->hasExplicitlyInheritedProperties() && !CSSProperty::isInheritedProperty(id)) >+ state.parentStyle()->setHasExplicitlyInheritedProperties(); > > #if ENABLE(CSS_VARIABLES) > if (id == CSSPropertyVariable) { >@@ -3034,7 +3008,7 @@ void StyleResolver::applyProperty(CSSPropertyID id, CSSValue* value) > CSSVariableValue* variable = static_cast<CSSVariableValue*>(value); > ASSERT(!variable->name().isEmpty()); > ASSERT(!variable->value().isEmpty()); >- m_style->setVariable(variable->name(), variable->value()); >+ state.style()->setVariable(variable->name(), variable->value()); > return; > } > #endif >@@ -3043,17 +3017,17 @@ void StyleResolver::applyProperty(CSSPropertyID id, CSSValue* value) > const PropertyHandler& handler = m_styleBuilder.propertyHandler(id); > if (handler.isValid()) { > if (isInherit) >- handler.applyInheritValue(id, this); >+ handler.applyInheritValue(id, state); > else if (isInitial) >- handler.applyInitialValue(id, this); >+ handler.applyInitialValue(id, state); > else >- handler.applyValue(id, this, value); >+ handler.applyValue(id, state, value); > return; > } > > CSSPrimitiveValue* primitiveValue = value->isPrimitiveValue() ? static_cast<CSSPrimitiveValue*>(value) : 0; > >- float zoomFactor = m_style->effectiveZoom(); >+ float zoomFactor = state.style()->effectiveZoom(); > > // What follows is a list that maps the CSS properties into their corresponding front-end > // RenderStyle values. Shorthands (e.g. border, background) occur in this list as well and >@@ -3067,7 +3041,7 @@ void StyleResolver::applyProperty(CSSPropertyID id, CSSValue* value) > // note is a reminder that eventually "inherit" needs to be supported. > > if (isInitial) { >- m_style->clearContent(); >+ state.style()->clearContent(); > return; > } > >@@ -3079,19 +3053,19 @@ void StyleResolver::applyProperty(CSSPropertyID id, CSSValue* value) > CSSValue* item = i.value(); > if (item->isImageGeneratorValue()) { > if (item->isGradientValue()) >- m_style->setContent(StyleGeneratedImage::create(static_cast<CSSGradientValue*>(item)->gradientWithStylesResolved(this).get()), didSet); >+ state.style()->setContent(StyleGeneratedImage::create(static_cast<CSSGradientValue*>(item)->gradientWithStylesResolved(state).get()), didSet); > else >- m_style->setContent(StyleGeneratedImage::create(static_cast<CSSImageGeneratorValue*>(item)), didSet); >+ state.style()->setContent(StyleGeneratedImage::create(static_cast<CSSImageGeneratorValue*>(item)), didSet); > didSet = true; > #if ENABLE(CSS_IMAGE_SET) > } else if (item->isImageSetValue()) { >- m_style->setContent(setOrPendingFromValue(CSSPropertyContent, static_cast<CSSImageSetValue*>(item)), didSet); >+ state.style()->setContent(setOrPendingFromValue(state, CSSPropertyContent, static_cast<CSSImageSetValue*>(item)), didSet); > didSet = true; > #endif > } > > if (item->isImageValue()) { >- m_style->setContent(cachedOrPendingFromValue(CSSPropertyContent, static_cast<CSSImageValue*>(item)), didSet); >+ state.style()->setContent(cachedOrPendingFromValue(state, CSSPropertyContent, static_cast<CSSImageValue*>(item)), didSet); > didSet = true; > continue; > } >@@ -3102,17 +3076,17 @@ void StyleResolver::applyProperty(CSSPropertyID id, CSSValue* value) > CSSPrimitiveValue* contentValue = static_cast<CSSPrimitiveValue*>(item); > > if (contentValue->isString()) { >- m_style->setContent(contentValue->getStringValue().impl(), didSet); >+ state.style()->setContent(contentValue->getStringValue().impl(), didSet); > didSet = true; > } else if (contentValue->isAttr()) { > // FIXME: Can a namespace be specified for an attr(foo)? >- if (m_style->styleType() == NOPSEUDO) >- m_style->setUnique(); >+ if (state.style()->styleType() == NOPSEUDO) >+ state.style()->setUnique(); > else >- m_parentStyle->setUnique(); >+ state.parentStyle()->setUnique(); > QualifiedName attr(nullAtom, contentValue->getStringValue().impl(), nullAtom); >- const AtomicString& value = m_element->getAttribute(attr); >- m_style->setContent(value.isNull() ? emptyAtom : value.impl(), didSet); >+ const AtomicString& value = state.element()->getAttribute(attr); >+ state.style()->setContent(value.isNull() ? emptyAtom : value.impl(), didSet); > didSet = true; > // register the fact that the attribute value affects the style > m_features.attrsInRules.add(attr.localName().impl()); >@@ -3123,24 +3097,24 @@ void StyleResolver::applyProperty(CSSPropertyID id, CSSValue* value) > if (listStyleIdent != CSSValueNone) > listStyleType = static_cast<EListStyleType>(listStyleIdent - CSSValueDisc); > OwnPtr<CounterContent> counter = adoptPtr(new CounterContent(counterValue->identifier(), listStyleType, counterValue->separator())); >- m_style->setContent(counter.release(), didSet); >+ state.style()->setContent(counter.release(), didSet); > didSet = true; > } else { > switch (contentValue->getIdent()) { > case CSSValueOpenQuote: >- m_style->setContent(OPEN_QUOTE, didSet); >+ state.style()->setContent(OPEN_QUOTE, didSet); > didSet = true; > break; > case CSSValueCloseQuote: >- m_style->setContent(CLOSE_QUOTE, didSet); >+ state.style()->setContent(CLOSE_QUOTE, didSet); > didSet = true; > break; > case CSSValueNoOpenQuote: >- m_style->setContent(NO_OPEN_QUOTE, didSet); >+ state.style()->setContent(NO_OPEN_QUOTE, didSet); > didSet = true; > break; > case CSSValueNoCloseQuote: >- m_style->setContent(NO_CLOSE_QUOTE, didSet); >+ state.style()->setContent(NO_CLOSE_QUOTE, didSet); > didSet = true; > break; > default: >@@ -3150,16 +3124,16 @@ void StyleResolver::applyProperty(CSSPropertyID id, CSSValue* value) > } > } > if (!didSet) >- m_style->clearContent(); >+ state.style()->clearContent(); > return; > } > case CSSPropertyQuotes: > if (isInherit) { >- m_style->setQuotes(m_parentStyle->quotes()); >+ state.style()->setQuotes(state.parentStyle()->quotes()); > return; > } > if (isInitial) { >- m_style->setQuotes(0); >+ state.style()->setQuotes(0); > return; > } > if (value->isValueList()) { >@@ -3177,43 +3151,43 @@ void StyleResolver::applyProperty(CSSPropertyID id, CSSValue* value) > String endQuote = static_cast<CSSPrimitiveValue*>(second)->getStringValue(); > quotes->addPair(std::make_pair(startQuote, endQuote)); > } >- m_style->setQuotes(quotes); >+ state.style()->setQuotes(quotes); > return; > } > if (primitiveValue) { > if (primitiveValue->getIdent() == CSSValueNone) >- m_style->setQuotes(QuotesData::create()); >+ state.style()->setQuotes(QuotesData::create()); > } > return; > case CSSPropertyFontFamily: { > // list of strings and ids > if (isInherit) { >- FontDescription parentFontDescription = m_parentStyle->fontDescription(); >- FontDescription fontDescription = m_style->fontDescription(); >+ FontDescription parentFontDescription = state.parentFontDescription(); >+ FontDescription fontDescription = state.fontDescription(); > fontDescription.setGenericFamily(parentFontDescription.genericFamily()); > fontDescription.setFamily(parentFontDescription.firstFamily()); > fontDescription.setIsSpecifiedFont(parentFontDescription.isSpecifiedFont()); >- setFontDescription(fontDescription); >+ state.setFontDescription(fontDescription); > return; > } > > if (isInitial) { > FontDescription initialDesc = FontDescription(); >- FontDescription fontDescription = m_style->fontDescription(); >+ FontDescription fontDescription = state.fontDescription(); > // We need to adjust the size to account for the generic family change from monospace > // to non-monospace. > if (fontDescription.keywordSize() && fontDescription.useFixedDefaultSize()) >- setFontSize(fontDescription, fontSizeForKeyword(document(), CSSValueXxSmall + fontDescription.keywordSize() - 1, false)); >+ setFontSize(state, fontDescription, fontSizeForKeyword(document(), CSSValueXxSmall + fontDescription.keywordSize() - 1, false)); > fontDescription.setGenericFamily(initialDesc.genericFamily()); > if (!initialDesc.firstFamily().familyIsEmpty()) > fontDescription.setFamily(initialDesc.firstFamily()); >- setFontDescription(fontDescription); >+ state.setFontDescription(fontDescription); > return; > } > > if (!value->isValueList()) > return; >- FontDescription fontDescription = m_style->fontDescription(); >+ FontDescription fontDescription = state.fontDescription(); > FontFamily& firstFamily = fontDescription.firstFamily(); > FontFamily* currFamily = 0; > >@@ -3282,43 +3256,43 @@ void StyleResolver::applyProperty(CSSPropertyID id, CSSValue* value) > // If currFamily is non-zero then we set at least one family on this description. > if (currFamily) { > if (fontDescription.keywordSize() && fontDescription.useFixedDefaultSize() != oldFamilyUsedFixedDefaultSize) >- setFontSize(fontDescription, fontSizeForKeyword(document(), CSSValueXxSmall + fontDescription.keywordSize() - 1, !oldFamilyUsedFixedDefaultSize)); >+ setFontSize(state, fontDescription, fontSizeForKeyword(document(), CSSValueXxSmall + fontDescription.keywordSize() - 1, !oldFamilyUsedFixedDefaultSize)); > >- setFontDescription(fontDescription); >+ state.setFontDescription(fontDescription); > } > return; > } > // shorthand properties > case CSSPropertyBackground: > if (isInitial) { >- m_style->clearBackgroundLayers(); >- m_style->setBackgroundColor(Color()); >+ state.style()->clearBackgroundLayers(); >+ state.style()->setBackgroundColor(Color()); > } else if (isInherit) { >- m_style->inheritBackgroundLayers(*m_parentStyle->backgroundLayers()); >- m_style->setBackgroundColor(m_parentStyle->backgroundColor()); >+ state.style()->inheritBackgroundLayers(*state.parentStyle()->backgroundLayers()); >+ state.style()->setBackgroundColor(state.parentStyle()->backgroundColor()); > } > return; > case CSSPropertyWebkitMask: > if (isInitial) >- m_style->clearMaskLayers(); >+ state.style()->clearMaskLayers(); > else if (isInherit) >- m_style->inheritMaskLayers(*m_parentStyle->maskLayers()); >+ state.style()->inheritMaskLayers(*state.parentStyle()->maskLayers()); > return; > case CSSPropertyFont: > if (isInherit) { >- FontDescription fontDescription = m_parentStyle->fontDescription(); >- m_style->setLineHeight(m_parentStyle->specifiedLineHeight()); >- m_lineHeightValue = 0; >- setFontDescription(fontDescription); >+ FontDescription fontDescription = state.parentFontDescription(); >+ state.style()->setLineHeight(state.parentStyle()->specifiedLineHeight()); >+ state.setLineHeightValue(0); >+ state.setFontDescription(fontDescription); > } else if (isInitial) { > Settings* settings = documentSettings(); > ASSERT(settings); // If we're doing style resolution, this document should always be in a frame and thus have settings > if (!settings) > return; >- initializeFontStyle(settings); >+ initializeFontStyle(state, settings); > } else if (primitiveValue) { >- m_style->setLineHeight(RenderStyle::initialLineHeight()); >- m_lineHeightValue = 0; >+ state.style()->setLineHeight(RenderStyle::initialLineHeight()); >+ state.setLineHeightValue(0); > > FontDescription fontDescription; > RenderTheme::defaultTheme()->systemFont(primitiveValue->getIdent(), fontDescription); >@@ -3334,27 +3308,27 @@ void StyleResolver::applyProperty(CSSPropertyID id, CSSValue* value) > fontDescription.setUsePrinterFont(document()->printing() || !settings->screenFontSubstitutionEnabled()); > > // Handle the zoom factor. >- fontDescription.setComputedSize(getComputedSizeFromSpecifiedSize(document(), m_style.get(), fontDescription.isAbsoluteSize(), fontDescription.specifiedSize(), useSVGZoomRules())); >- setFontDescription(fontDescription); >+ fontDescription.setComputedSize(getComputedSizeFromSpecifiedSize(document(), state.style(), fontDescription.isAbsoluteSize(), fontDescription.specifiedSize(), state.useSVGZoomRules())); >+ state.setFontDescription(fontDescription); > } > } else if (value->isFontValue()) { > FontValue* font = static_cast<FontValue*>(value); > if (!font->style || !font->variant || !font->weight > || !font->size || !font->lineHeight || !font->family) > return; >- applyProperty(CSSPropertyFontStyle, font->style.get()); >- applyProperty(CSSPropertyFontVariant, font->variant.get()); >- applyProperty(CSSPropertyFontWeight, font->weight.get()); >+ applyProperty(state, CSSPropertyFontStyle, font->style.get()); >+ applyProperty(state, CSSPropertyFontVariant, font->variant.get()); >+ applyProperty(state, CSSPropertyFontWeight, font->weight.get()); > // The previous properties can dirty our font but they don't try to read the font's > // properties back, which is safe. However if font-size is using the 'ex' unit, it will > // need query the dirtied font's x-height to get the computed size. To be safe in this > // case, let's just update the font now. >- updateFont(); >- applyProperty(CSSPropertyFontSize, font->size.get()); >+ updateFont(state); >+ applyProperty(state, CSSPropertyFontSize, font->size.get()); > >- m_lineHeightValue = font->lineHeight.get(); >+ state.setLineHeightValue(font->lineHeight.get()); > >- applyProperty(CSSPropertyFontFamily, font->family.get()); >+ applyProperty(state, CSSPropertyFontFamily, font->family.get()); > } > return; > >@@ -3364,11 +3338,11 @@ void StyleResolver::applyProperty(CSSPropertyID id, CSSValue* value) > case CSSPropertyWebkitBoxShadow: { > if (isInherit) { > if (id == CSSPropertyTextShadow) >- return m_style->setTextShadow(m_parentStyle->textShadow() ? adoptPtr(new ShadowData(*m_parentStyle->textShadow())) : nullptr); >- return m_style->setBoxShadow(m_parentStyle->boxShadow() ? adoptPtr(new ShadowData(*m_parentStyle->boxShadow())) : nullptr); >+ return state.style()->setTextShadow(state.parentStyle()->textShadow() ? adoptPtr(new ShadowData(*state.parentStyle()->textShadow())) : nullptr); >+ return state.style()->setBoxShadow(state.parentStyle()->boxShadow() ? adoptPtr(new ShadowData(*state.parentStyle()->boxShadow())) : nullptr); > } > if (isInitial || primitiveValue) // initial | none >- return id == CSSPropertyTextShadow ? m_style->setTextShadow(nullptr) : m_style->setBoxShadow(nullptr); >+ return id == CSSPropertyTextShadow ? state.style()->setTextShadow(nullptr) : state.style()->setBoxShadow(nullptr); > > if (!value->isValueList()) > return; >@@ -3378,29 +3352,29 @@ void StyleResolver::applyProperty(CSSPropertyID id, CSSValue* value) > if (!currValue->isShadowValue()) > continue; > ShadowValue* item = static_cast<ShadowValue*>(currValue); >- int x = item->x->computeLength<int>(style(), m_rootElementStyle, zoomFactor); >- int y = item->y->computeLength<int>(style(), m_rootElementStyle, zoomFactor); >- int blur = item->blur ? item->blur->computeLength<int>(style(), m_rootElementStyle, zoomFactor) : 0; >- int spread = item->spread ? item->spread->computeLength<int>(style(), m_rootElementStyle, zoomFactor) : 0; >+ int x = item->x->computeLength<int>(state.style(), state.rootElementStyle(), zoomFactor); >+ int y = item->y->computeLength<int>(state.style(), state.rootElementStyle(), zoomFactor); >+ int blur = item->blur ? item->blur->computeLength<int>(state.style(), state.rootElementStyle(), zoomFactor) : 0; >+ int spread = item->spread ? item->spread->computeLength<int>(state.style(), state.rootElementStyle(), zoomFactor) : 0; > ShadowStyle shadowStyle = item->style && item->style->getIdent() == CSSValueInset ? Inset : Normal; > Color color; > if (item->color) >- color = colorFromPrimitiveValue(item->color.get()); >- else if (m_style) >- color = m_style->color(); >+ color = colorFromPrimitiveValue(state, item->color.get()); >+ else if (state.style()) >+ color = state.style()->color(); > > OwnPtr<ShadowData> shadowData = adoptPtr(new ShadowData(IntPoint(x, y), blur, spread, shadowStyle, id == CSSPropertyWebkitBoxShadow, color.isValid() ? color : Color::transparent)); > if (id == CSSPropertyTextShadow) >- m_style->setTextShadow(shadowData.release(), i.index()); // add to the list if this is not the first entry >+ state.style()->setTextShadow(shadowData.release(), i.index()); // add to the list if this is not the first entry > else >- m_style->setBoxShadow(shadowData.release(), i.index()); // add to the list if this is not the first entry >+ state.style()->setBoxShadow(shadowData.release(), i.index()); // add to the list if this is not the first entry > } > return; > } > case CSSPropertyWebkitBoxReflect: { > HANDLE_INHERIT_AND_INITIAL(boxReflect, BoxReflect) > if (primitiveValue) { >- m_style->setBoxReflect(RenderStyle::initialBoxReflect()); >+ state.style()->setBoxReflect(RenderStyle::initialBoxReflect()); > return; > } > >@@ -3411,13 +3385,14 @@ void StyleResolver::applyProperty(CSSPropertyID id, CSSValue* value) > RefPtr<StyleReflection> reflection = StyleReflection::create(); > reflection->setDirection(*reflectValue->direction()); > if (reflectValue->offset()) >- reflection->setOffset(reflectValue->offset()->convertToLength<FixedIntegerConversion | PercentConversion | CalculatedConversion>(style(), m_rootElementStyle, zoomFactor)); >+ reflection->setOffset(reflectValue->offset()->convertToLength<FixedIntegerConversion | PercentConversion | CalculatedConversion>(state.style(), state.rootElementStyle(), zoomFactor)); > NinePieceImage mask; > mask.setMaskDefaults(); >- m_styleMap.mapNinePieceImage(id, reflectValue->mask(), mask); >+ // m_styleMap. >+ CSSToStyleMap::mapNinePieceImage(state, id, reflectValue->mask(), mask); > reflection->setMask(mask); > >- m_style->setBoxReflect(reflection.release()); >+ state.style()->setBoxReflect(reflection.release()); > return; > } > case CSSPropertySrc: // Only used in @font-face rules. >@@ -3426,29 +3401,29 @@ void StyleResolver::applyProperty(CSSPropertyID id, CSSValue* value) > return; > case CSSPropertyWebkitColumnRule: > if (isInherit) { >- m_style->setColumnRuleColor(m_parentStyle->columnRuleColor().isValid() ? m_parentStyle->columnRuleColor() : m_parentStyle->color()); >- m_style->setColumnRuleStyle(m_parentStyle->columnRuleStyle()); >- m_style->setColumnRuleWidth(m_parentStyle->columnRuleWidth()); >+ state.style()->setColumnRuleColor(state.parentStyle()->columnRuleColor().isValid() ? state.parentStyle()->columnRuleColor() : state.parentStyle()->color()); >+ state.style()->setColumnRuleStyle(state.parentStyle()->columnRuleStyle()); >+ state.style()->setColumnRuleWidth(state.parentStyle()->columnRuleWidth()); > } else if (isInitial) >- m_style->resetColumnRule(); >+ state.style()->resetColumnRule(); > return; > case CSSPropertyWebkitMarquee: > if (!isInherit) > return; >- m_style->setMarqueeDirection(m_parentStyle->marqueeDirection()); >- m_style->setMarqueeIncrement(m_parentStyle->marqueeIncrement()); >- m_style->setMarqueeSpeed(m_parentStyle->marqueeSpeed()); >- m_style->setMarqueeLoopCount(m_parentStyle->marqueeLoopCount()); >- m_style->setMarqueeBehavior(m_parentStyle->marqueeBehavior()); >+ state.style()->setMarqueeDirection(state.parentStyle()->marqueeDirection()); >+ state.style()->setMarqueeIncrement(state.parentStyle()->marqueeIncrement()); >+ state.style()->setMarqueeSpeed(state.parentStyle()->marqueeSpeed()); >+ state.style()->setMarqueeLoopCount(state.parentStyle()->marqueeLoopCount()); >+ state.style()->setMarqueeBehavior(state.parentStyle()->marqueeBehavior()); > return; > case CSSPropertyWebkitMarqueeRepetition: { > HANDLE_INHERIT_AND_INITIAL(marqueeLoopCount, MarqueeLoopCount) > if (!primitiveValue) > return; > if (primitiveValue->getIdent() == CSSValueInfinite) >- m_style->setMarqueeLoopCount(-1); // -1 means repeat forever. >+ state.style()->setMarqueeLoopCount(-1); // -1 means repeat forever. > else if (primitiveValue->isNumber()) >- m_style->setMarqueeLoopCount(primitiveValue->getIntValue()); >+ state.style()->setMarqueeLoopCount(primitiveValue->getIntValue()); > return; > } > case CSSPropertyWebkitMarqueeSpeed: { >@@ -3458,19 +3433,19 @@ void StyleResolver::applyProperty(CSSPropertyID id, CSSValue* value) > if (int ident = primitiveValue->getIdent()) { > switch (ident) { > case CSSValueSlow: >- m_style->setMarqueeSpeed(500); // 500 msec. >+ state.style()->setMarqueeSpeed(500); // 500 msec. > break; > case CSSValueNormal: >- m_style->setMarqueeSpeed(85); // 85msec. The WinIE default. >+ state.style()->setMarqueeSpeed(85); // 85msec. The WinIE default. > break; > case CSSValueFast: >- m_style->setMarqueeSpeed(10); // 10msec. Super fast. >+ state.style()->setMarqueeSpeed(10); // 10msec. Super fast. > break; > } > } else if (primitiveValue->isTime()) >- m_style->setMarqueeSpeed(primitiveValue->computeTime<int, CSSPrimitiveValue::Milliseconds>()); >+ state.style()->setMarqueeSpeed(primitiveValue->computeTime<int, CSSPrimitiveValue::Milliseconds>()); > else if (primitiveValue->isNumber()) // For scrollamount support. >- m_style->setMarqueeSpeed(primitiveValue->getIntValue()); >+ state.style()->setMarqueeSpeed(primitiveValue->getIntValue()); > return; > } > case CSSPropertyWebkitMarqueeIncrement: { >@@ -3480,19 +3455,19 @@ void StyleResolver::applyProperty(CSSPropertyID id, CSSValue* value) > if (primitiveValue->getIdent()) { > switch (primitiveValue->getIdent()) { > case CSSValueSmall: >- m_style->setMarqueeIncrement(Length(1, Fixed)); // 1px. >+ state.style()->setMarqueeIncrement(Length(1, Fixed)); // 1px. > break; > case CSSValueNormal: >- m_style->setMarqueeIncrement(Length(6, Fixed)); // 6px. The WinIE default. >+ state.style()->setMarqueeIncrement(Length(6, Fixed)); // 6px. The WinIE default. > break; > case CSSValueLarge: >- m_style->setMarqueeIncrement(Length(36, Fixed)); // 36px. >+ state.style()->setMarqueeIncrement(Length(36, Fixed)); // 36px. > break; > } > } else { >- Length marqueeLength = convertToIntLength(primitiveValue, style(), m_rootElementStyle); >+ Length marqueeLength = convertToIntLength(primitiveValue, state.style(), state.rootElementStyle()); > if (!marqueeLength.isUndefined()) >- m_style->setMarqueeIncrement(marqueeLength); >+ state.style()->setMarqueeIncrement(marqueeLength); > } > return; > } >@@ -3501,19 +3476,19 @@ void StyleResolver::applyProperty(CSSPropertyID id, CSSValue* value) > if (!primitiveValue) > return; > if (primitiveValue->getIdent() == CSSValueAuto) >- m_style->setLocale(nullAtom); >+ state.style()->setLocale(nullAtom); > else >- m_style->setLocale(primitiveValue->getStringValue()); >- FontDescription fontDescription = m_style->fontDescription(); >- fontDescription.setScript(localeToScriptCodeForFontSelection(m_style->locale())); >- setFontDescription(fontDescription); >+ state.style()->setLocale(primitiveValue->getStringValue()); >+ FontDescription fontDescription = state.fontDescription(); >+ fontDescription.setScript(localeToScriptCodeForFontSelection(state.style()->locale())); >+ state.setFontDescription(fontDescription); > return; > } > case CSSPropertyWebkitTextSizeAdjust: { > HANDLE_INHERIT_AND_INITIAL(textSizeAdjust, TextSizeAdjust) > if (!primitiveValue || !primitiveValue->getIdent()) > return; >- setTextSizeAdjust(primitiveValue->getIdent() == CSSValueAuto); >+ state.setTextSizeAdjust(primitiveValue->getIdent() == CSSValueAuto); > return; > } > #if ENABLE(DASHBOARD_SUPPORT) >@@ -3524,7 +3499,7 @@ void StyleResolver::applyProperty(CSSPropertyID id, CSSValue* value) > return; > > if (primitiveValue->getIdent() == CSSValueNone) { >- m_style->setDashboardRegions(RenderStyle::noneDashboardRegions()); >+ state.style()->setDashboardRegions(RenderStyle::noneDashboardRegions()); > return; > } > >@@ -3549,9 +3524,9 @@ void StyleResolver::applyProperty(CSSPropertyID id, CSSValue* value) > left = Length(); > > if (region->m_isCircle) >- m_style->setDashboardRegion(StyleDashboardRegion::Circle, region->m_label, top, right, bottom, left, region == first ? false : true); >+ state.style()->setDashboardRegion(StyleDashboardRegion::Circle, region->m_label, top, right, bottom, left, region == first ? false : true); > else if (region->m_isRectangle) >- m_style->setDashboardRegion(StyleDashboardRegion::Rectangle, region->m_label, top, right, bottom, left, region == first ? false : true); >+ state.style()->setDashboardRegion(StyleDashboardRegion::Rectangle, region->m_label, top, right, bottom, left, region == first ? false : true); > region = region->m_next.get(); > } > >@@ -3564,8 +3539,8 @@ void StyleResolver::applyProperty(CSSPropertyID id, CSSValue* value) > case CSSPropertyWebkitAppRegion: { > if (!primitiveValue || !primitiveValue->getIdent()) > return; >- m_style->setDraggableRegionMode(primitiveValue->getIdent() == CSSValueDrag ? DraggableRegionDrag : DraggableRegionNoDrag); >- m_element->document()->setHasAnnotatedRegions(true); >+ state.style()->setDraggableRegionMode(primitiveValue->getIdent() == CSSValueDrag ? DraggableRegionDrag : DraggableRegionNoDrag); >+ state.document()->setHasAnnotatedRegions(true); > return; > } > #endif >@@ -3581,21 +3556,21 @@ void StyleResolver::applyProperty(CSSPropertyID id, CSSValue* value) > result *= 3; > else if (primitiveValue->getIdent() == CSSValueThick) > result *= 5; >- width = CSSPrimitiveValue::create(result, CSSPrimitiveValue::CSS_EMS)->computeLength<float>(style(), m_rootElementStyle, zoomFactor); >+ width = CSSPrimitiveValue::create(result, CSSPrimitiveValue::CSS_EMS)->computeLength<float>(state.style(), state.rootElementStyle(), zoomFactor); > break; > } > default: >- width = primitiveValue->computeLength<float>(style(), m_rootElementStyle, zoomFactor); >+ width = primitiveValue->computeLength<float>(state.style(), state.rootElementStyle(), zoomFactor); > break; > } >- m_style->setTextStrokeWidth(width); >+ state.style()->setTextStrokeWidth(width); > return; > } > case CSSPropertyWebkitTransform: { > HANDLE_INHERIT_AND_INITIAL(transform, Transform); > TransformOperations operations; >- createTransformOperations(value, style(), m_rootElementStyle, operations); >- m_style->setTransform(operations); >+ createTransformOperations(value, state.style(), state.rootElementStyle(), operations); >+ state.style()->setTransform(operations); > return; > } > case CSSPropertyWebkitPerspective: { >@@ -3605,34 +3580,34 @@ void StyleResolver::applyProperty(CSSPropertyID id, CSSValue* value) > return; > > if (primitiveValue->getIdent() == CSSValueNone) { >- m_style->setPerspective(0); >+ state.style()->setPerspective(0); > return; > } > > float perspectiveValue; > if (primitiveValue->isLength()) >- perspectiveValue = primitiveValue->computeLength<float>(style(), m_rootElementStyle, zoomFactor); >+ perspectiveValue = primitiveValue->computeLength<float>(state.style(), state.rootElementStyle(), zoomFactor); > else if (primitiveValue->isNumber()) { > // For backward compatibility, treat valueless numbers as px. >- perspectiveValue = CSSPrimitiveValue::create(primitiveValue->getDoubleValue(), CSSPrimitiveValue::CSS_PX)->computeLength<float>(style(), m_rootElementStyle, zoomFactor); >+ perspectiveValue = CSSPrimitiveValue::create(primitiveValue->getDoubleValue(), CSSPrimitiveValue::CSS_PX)->computeLength<float>(state.style(), state.rootElementStyle(), zoomFactor); > } else > return; > > if (perspectiveValue >= 0.0f) >- m_style->setPerspective(perspectiveValue); >+ state.style()->setPerspective(perspectiveValue); > return; > } > case CSSPropertyWebkitAnimation: > if (isInitial) >- m_style->clearAnimations(); >+ state.style()->clearAnimations(); > else if (isInherit) >- m_style->inheritAnimations(m_parentStyle->animations()); >+ state.style()->inheritAnimations(state.parentStyle()->animations()); > return; > case CSSPropertyWebkitTransition: > if (isInitial) >- m_style->clearTransitions(); >+ state.style()->clearTransitions(); > else if (isInherit) >- m_style->inheritTransitions(m_parentStyle->transitions()); >+ state.style()->inheritTransitions(state.parentStyle()->transitions()); > return; > #if ENABLE(TOUCH_EVENTS) > case CSSPropertyWebkitTapHighlightColor: { >@@ -3640,8 +3615,8 @@ void StyleResolver::applyProperty(CSSPropertyID id, CSSValue* value) > if (!primitiveValue) > break; > >- Color col = colorFromPrimitiveValue(primitiveValue); >- m_style->setTapHighlightColor(col); >+ Color col = colorFromPrimitiveValue(state, primitiveValue); >+ state.style()->setTapHighlightColor(col); > return; > } > #endif >@@ -3650,7 +3625,7 @@ void StyleResolver::applyProperty(CSSPropertyID id, CSSValue* value) > HANDLE_INHERIT_AND_INITIAL(useTouchOverflowScrolling, UseTouchOverflowScrolling); > if (!primitiveValue) > break; >- m_style->setUseTouchOverflowScrolling(primitiveValue->getIdent() == CSSValueTouch); >+ state.style()->setUseTouchOverflowScrolling(primitiveValue->getIdent() == CSSValueTouch); > return; > } > #endif >@@ -3693,9 +3668,9 @@ void StyleResolver::applyProperty(CSSPropertyID id, CSSValue* value) > case CSSPropertyWebkitMaxLogicalWidth: > case CSSPropertyWebkitMaxLogicalHeight: > { >- CSSPropertyID newId = CSSProperty::resolveDirectionAwareProperty(id, m_style->direction(), m_style->writingMode()); >+ CSSPropertyID newId = CSSProperty::resolveDirectionAwareProperty(id, state.style()->direction(), state.style()->writingMode()); > ASSERT(newId != id); >- return applyProperty(newId, value); >+ return applyProperty(state, newId, value); > } > case CSSPropertyFontStretch: > case CSSPropertyPage: >@@ -3725,12 +3700,11 @@ void StyleResolver::applyProperty(CSSPropertyID id, CSSValue* value) > HANDLE_INHERIT_AND_INITIAL(writingMode, WritingMode); > > if (primitiveValue) >- setWritingMode(*primitiveValue); >+ state.setWritingMode(*primitiveValue); > > // FIXME: It is not ok to modify document state while applying style. >- if (m_element && m_element == m_element->document()->documentElement()) >- m_element->document()->setWritingModeSetOnDocumentElement(true); >- >+ if (state.element() && state.element() == state.document()->documentElement()) >+ state.document()->setWritingModeSetOnDocumentElement(true); > return; > } > >@@ -3738,7 +3712,7 @@ void StyleResolver::applyProperty(CSSPropertyID id, CSSValue* value) > HANDLE_INHERIT_AND_INITIAL(textOrientation, TextOrientation); > > if (primitiveValue) >- setTextOrientation(*primitiveValue); >+ state.setTextOrientation(*primitiveValue); > > return; > } >@@ -3746,7 +3720,7 @@ void StyleResolver::applyProperty(CSSPropertyID id, CSSValue* value) > case CSSPropertyWebkitLineBoxContain: { > HANDLE_INHERIT_AND_INITIAL(lineBoxContain, LineBoxContain) > if (primitiveValue && primitiveValue->getIdent() == CSSValueNone) { >- m_style->setLineBoxContain(LineBoxContainNone); >+ state.style()->setLineBoxContain(LineBoxContainNone); > return; > } > >@@ -3754,21 +3728,21 @@ void StyleResolver::applyProperty(CSSPropertyID id, CSSValue* value) > return; > > CSSLineBoxContainValue* lineBoxContainValue = static_cast<CSSLineBoxContainValue*>(value); >- m_style->setLineBoxContain(lineBoxContainValue->value()); >+ state.style()->setLineBoxContain(lineBoxContainValue->value()); > return; > } > > // CSS Fonts Module Level 3 > case CSSPropertyWebkitFontFeatureSettings: { > if (primitiveValue && primitiveValue->getIdent() == CSSValueNormal) { >- setFontDescription(m_style->fontDescription().makeNormalFeatureSettings()); >+ state.setFontDescription(state.fontDescription().makeNormalFeatureSettings()); > return; > } > > if (!value->isValueList()) > return; > >- FontDescription fontDescription = m_style->fontDescription(); >+ FontDescription fontDescription = state.fontDescription(); > CSSValueList* list = static_cast<CSSValueList*>(value); > RefPtr<FontFeatureSettings> settings = FontFeatureSettings::create(); > int len = list->length(); >@@ -3780,7 +3754,7 @@ void StyleResolver::applyProperty(CSSPropertyID id, CSSValue* value) > settings->append(FontFeature(feature->tag(), feature->value())); > } > fontDescription.setFeatureSettings(settings.release()); >- setFontDescription(fontDescription); >+ state.setFontDescription(fontDescription); > return; > } > >@@ -3788,23 +3762,23 @@ void StyleResolver::applyProperty(CSSPropertyID id, CSSValue* value) > case CSSPropertyWebkitFilter: { > HANDLE_INHERIT_AND_INITIAL(filter, Filter); > FilterOperations operations; >- if (createFilterOperations(value, style(), m_rootElementStyle, operations)) >- m_style->setFilter(operations); >+ if (createFilterOperations(state, value, state.style(), state.rootElementStyle(), operations)) >+ state.style()->setFilter(operations); > return; > } > #endif > case CSSPropertyWebkitGridColumns: { > Vector<GridTrackSize> trackSizes; >- if (!createGridTrackList(value, trackSizes, this)) >+ if (!createGridTrackList(value, trackSizes, state)) > return; >- m_style->setGridColumns(trackSizes); >+ state.style()->setGridColumns(trackSizes); > return; > } > case CSSPropertyWebkitGridRows: { > Vector<GridTrackSize> trackSizes; >- if (!createGridTrackList(value, trackSizes, this)) >+ if (!createGridTrackList(value, trackSizes, state)) > return; >- m_style->setGridRows(trackSizes); >+ state.style()->setGridRows(trackSizes); > return; > } > >@@ -3812,14 +3786,14 @@ void StyleResolver::applyProperty(CSSPropertyID id, CSSValue* value) > GridPosition column; > if (!createGridPosition(value, column)) > return; >- m_style->setGridItemColumn(column); >+ state.style()->setGridItemColumn(column); > return; > } > case CSSPropertyWebkitGridRow: { > GridPosition row; > if (!createGridPosition(value, row)) > return; >- m_style->setGridItemRow(row); >+ state.style()->setGridItemRow(row); > return; > } > // These properties are implemented in the StyleBuilder lookup table. >@@ -4109,91 +4083,91 @@ void StyleResolver::applyProperty(CSSPropertyID id, CSSValue* value) > #if ENABLE(SVG) > default: > // Try the SVG properties >- applySVGProperty(id, value); >+ applySVGProperty(state, id, value); > return; > #endif > } > } > >-PassRefPtr<StyleImage> StyleResolver::styleImage(CSSPropertyID property, CSSValue* value) >+PassRefPtr<StyleImage> StyleResolver::styleImage(StyleResolveState& state, CSSPropertyID property, CSSValue* value) > { > if (value->isImageValue()) >- return cachedOrPendingFromValue(property, static_cast<CSSImageValue*>(value)); >+ return cachedOrPendingFromValue(state, property, static_cast<CSSImageValue*>(value)); > > if (value->isImageGeneratorValue()) { > if (value->isGradientValue()) >- return generatedOrPendingFromValue(property, static_cast<CSSGradientValue*>(value)->gradientWithStylesResolved(this).get()); >- return generatedOrPendingFromValue(property, static_cast<CSSImageGeneratorValue*>(value)); >+ return generatedOrPendingFromValue(state, property, static_cast<CSSGradientValue*>(value)->gradientWithStylesResolved(state).get()); >+ return generatedOrPendingFromValue(state, property, static_cast<CSSImageGeneratorValue*>(value)); > } > > #if ENABLE(CSS_IMAGE_SET) > if (value->isImageSetValue()) >- return setOrPendingFromValue(property, static_cast<CSSImageSetValue*>(value)); >+ return setOrPendingFromValue(state, property, static_cast<CSSImageSetValue*>(value)); > #endif > > if (value->isCursorImageValue()) >- return cursorOrPendingFromValue(property, static_cast<CSSCursorImageValue*>(value)); >+ return cursorOrPendingFromValue(state, property, static_cast<CSSCursorImageValue*>(value)); > > return 0; > } > >-PassRefPtr<StyleImage> StyleResolver::cachedOrPendingFromValue(CSSPropertyID property, CSSImageValue* value) >+PassRefPtr<StyleImage> StyleResolver::cachedOrPendingFromValue(StyleResolveState& state, CSSPropertyID property, CSSImageValue* value) > { > RefPtr<StyleImage> image = value->cachedOrPendingImage(); > if (image && image->isPendingImage()) >- m_pendingImageProperties.set(property, value); >+ state.pendingImageProperties().set(property, value); > return image.release(); > } > >-PassRefPtr<StyleImage> StyleResolver::generatedOrPendingFromValue(CSSPropertyID property, CSSImageGeneratorValue* value) >+PassRefPtr<StyleImage> StyleResolver::generatedOrPendingFromValue(StyleResolveState& state, CSSPropertyID property, CSSImageGeneratorValue* value) > { > if (value->isPending()) { >- m_pendingImageProperties.set(property, value); >+ state.pendingImageProperties().set(property, value); > return StylePendingImage::create(value); > } > return StyleGeneratedImage::create(value); > } > > #if ENABLE(CSS_IMAGE_SET) >-PassRefPtr<StyleImage> StyleResolver::setOrPendingFromValue(CSSPropertyID property, CSSImageSetValue* value) >+PassRefPtr<StyleImage> StyleResolver::setOrPendingFromValue(StyleResolveState& state, CSSPropertyID property, CSSImageSetValue* value) > { >- RefPtr<StyleImage> image = value->cachedOrPendingImageSet(document()); >+ RefPtr<StyleImage> image = value->cachedOrPendingImageSet(state.document()); > if (image && image->isPendingImage()) >- m_pendingImageProperties.set(property, value); >+ state.pendingImageProperties().set(property, value); > return image.release(); > } > #endif > >-PassRefPtr<StyleImage> StyleResolver::cursorOrPendingFromValue(CSSPropertyID property, CSSCursorImageValue* value) >+PassRefPtr<StyleImage> StyleResolver::cursorOrPendingFromValue(StyleResolveState& state, CSSPropertyID property, CSSCursorImageValue* value) > { >- RefPtr<StyleImage> image = value->cachedOrPendingImage(document()); >+ RefPtr<StyleImage> image = value->cachedOrPendingImage(state.document()); > if (image && image->isPendingImage()) >- m_pendingImageProperties.set(property, value); >+ state.pendingImageProperties().set(property, value); > return image.release(); > } > >-void StyleResolver::checkForTextSizeAdjust() >+void StyleResolver::checkForTextSizeAdjust(RenderStyle* style) > { >- if (m_style->textSizeAdjust()) >+ if (style->textSizeAdjust()) > return; > >- FontDescription newFontDescription(m_style->fontDescription()); >+ FontDescription newFontDescription(style->fontDescription()); > newFontDescription.setComputedSize(newFontDescription.specifiedSize()); >- m_style->setFontDescription(newFontDescription); >+ style->setFontDescription(newFontDescription); > } > >-void StyleResolver::checkForZoomChange(RenderStyle* style, RenderStyle* parentStyle) >+void StyleResolver::checkForZoomChange(StyleResolveState& state, RenderStyle* style, RenderStyle* parentStyle) > { > if (style->effectiveZoom() == parentStyle->effectiveZoom()) > return; > > const FontDescription& childFont = style->fontDescription(); > FontDescription newFontDescription(childFont); >- setFontSize(newFontDescription, childFont.specifiedSize()); >+ setFontSize(state, newFontDescription, childFont.specifiedSize()); > style->setFontDescription(newFontDescription); > } > >-void StyleResolver::checkForGenericFamilyChange(RenderStyle* style, RenderStyle* parentStyle) >+void StyleResolver::checkForGenericFamilyChange(StyleResolveState& state, RenderStyle* style, RenderStyle* parentStyle) > { > const FontDescription& childFont = style->fontDescription(); > >@@ -4227,11 +4201,11 @@ void StyleResolver::checkForGenericFamilyChange(RenderStyle* style, RenderStyle* > } > > FontDescription newFontDescription(childFont); >- setFontSize(newFontDescription, size); >+ setFontSize(state, newFontDescription, size); > style->setFontDescription(newFontDescription); > } > >-void StyleResolver::initializeFontStyle(Settings* settings) >+void StyleResolver::initializeFontStyle(StyleResolveState& state, Settings* settings) > { > FontDescription fontDescription; > fontDescription.setGenericFamily(FontDescription::StandardFamily); >@@ -4243,16 +4217,17 @@ void StyleResolver::initializeFontStyle(Settings* settings) > fontDescription.firstFamily().appendFamily(0); > } > fontDescription.setKeywordSize(CSSValueMedium - CSSValueXxSmall + 1); >- setFontSize(fontDescription, fontSizeForKeyword(document(), CSSValueMedium, false)); >- m_style->setLineHeight(RenderStyle::initialLineHeight()); >- m_lineHeightValue = 0; >- setFontDescription(fontDescription); >+ setFontSize(state, fontDescription, fontSizeForKeyword(document(), CSSValueMedium, false)); >+ state.style()->setLineHeight(RenderStyle::initialLineHeight()); >+ state.setLineHeightValue(0); >+ state.setFontDescription(fontDescription); > } > >-void StyleResolver::setFontSize(FontDescription& fontDescription, float size) >+void StyleResolver::setFontSize(StyleResolveState& state, FontDescription& fontDescription, float size) > { >+ ASSERT(state.element()); > fontDescription.setSpecifiedSize(size); >- fontDescription.setComputedSize(getComputedSizeFromSpecifiedSize(document(), m_style.get(), fontDescription.isAbsoluteSize(), size, useSVGZoomRules())); >+ fontDescription.setComputedSize(getComputedSizeFromSpecifiedSize(state.document(), state.style(), fontDescription.isAbsoluteSize(), size, state.useSVGZoomRules())); > } > > float StyleResolver::getComputedSizeFromSpecifiedSize(Document* document, RenderStyle* style, bool isAbsoluteSize, float specifiedSize, bool useSVGZoomRules) >@@ -4450,7 +4425,7 @@ bool StyleResolver::colorFromPrimitiveValueIsDerivedFromElement(CSSPrimitiveValu > } > } > >-Color StyleResolver::colorFromPrimitiveValue(CSSPrimitiveValue* value, bool forVisitedLink) const >+Color StyleResolver::colorFromPrimitiveValue(StyleResolveState& state, CSSPrimitiveValue* value, bool forVisitedLink) > { > if (value->isRGBColor()) > return Color(value->getRGBA32Value()); >@@ -4460,15 +4435,15 @@ Color StyleResolver::colorFromPrimitiveValue(CSSPrimitiveValue* value, bool forV > case 0: > return Color(); > case CSSValueWebkitText: >- return m_element->document()->textColor(); >+ return state.document()->textColor(); > case CSSValueWebkitLink: >- return (m_element->isLink() && forVisitedLink) ? m_element->document()->visitedLinkColor() : m_element->document()->linkColor(); >+ return (state.element()->isLink() && forVisitedLink) ? state.document()->visitedLinkColor() : state.document()->linkColor(); > case CSSValueWebkitActivelink: >- return m_element->document()->activeLinkColor(); >+ return state.document()->activeLinkColor(); > case CSSValueWebkitFocusRingColor: > return RenderTheme::focusRingColor(); > case CSSValueCurrentcolor: >- return m_style->color(); >+ return state.style()->color(); > default: > return colorForCSSValue(ident); > } >@@ -4800,19 +4775,19 @@ static FilterOperation::OperationType filterOperationForType(WebKitCSSFilterValu > } > > #if ENABLE(CSS_FILTERS) && ENABLE(SVG) >-void StyleResolver::loadPendingSVGDocuments() >+void StyleResolver::loadPendingSVGDocuments(StyleResolveState& state) > { >- if (!m_style->hasFilter() || m_pendingSVGDocuments.isEmpty()) >+ if (!state.style()->hasFilter() || state.pendingSVGDocuments().isEmpty()) > return; > >- CachedResourceLoader* cachedResourceLoader = m_element->document()->cachedResourceLoader(); >- Vector<RefPtr<FilterOperation> >& filterOperations = m_style->mutableFilter().operations(); >+ CachedResourceLoader* cachedResourceLoader = state.document()->cachedResourceLoader(); >+ Vector<RefPtr<FilterOperation> >& filterOperations = state.style()->mutableFilter().operations(); > for (unsigned i = 0; i < filterOperations.size(); ++i) { > RefPtr<FilterOperation> filterOperation = filterOperations.at(i); > if (filterOperation->getOperationType() == FilterOperation::REFERENCE) { > ReferenceFilterOperation* referenceFilter = static_cast<ReferenceFilterOperation*>(filterOperation.get()); > >- WebKitCSSSVGDocumentValue* value = m_pendingSVGDocuments.get(referenceFilter).get(); >+ WebKitCSSSVGDocumentValue* value = state.pendingSVGDocuments().get(referenceFilter).get(); > if (!value) > continue; > CachedSVGDocument* cachedDocument = value->load(cachedResourceLoader); >@@ -4823,34 +4798,34 @@ void StyleResolver::loadPendingSVGDocuments() > referenceFilter->setCachedSVGDocumentReference(adoptPtr(new CachedSVGDocumentReference(cachedDocument))); > } > } >- m_pendingSVGDocuments.clear(); >+ state.pendingSVGDocuments().clear(); > } > #endif > > #if ENABLE(CSS_SHADERS) >-StyleShader* StyleResolver::styleShader(CSSValue* value) >+StyleShader* StyleResolver::styleShader(StyleResolveState& state, CSSValue* value) > { > if (value->isWebKitCSSShaderValue()) >- return cachedOrPendingStyleShaderFromValue(static_cast<WebKitCSSShaderValue*>(value)); >+ return cachedOrPendingStyleShaderFromValue(state, static_cast<WebKitCSSShaderValue*>(value)); > return 0; > } > >-StyleShader* StyleResolver::cachedOrPendingStyleShaderFromValue(WebKitCSSShaderValue* value) >+StyleShader* StyleResolver::cachedOrPendingStyleShaderFromValue(StyleResolveState& state, WebKitCSSShaderValue* value) > { > StyleShader* shader = value->cachedOrPendingShader(); > if (shader && shader->isPendingShader()) >- m_hasPendingShaders = true; >+ state.setHasPendingShaders(true); > return shader; > } > >-void StyleResolver::loadPendingShaders() >+void StyleResolver::loadPendingShaders(StyleResolveState& state) > { >- if (!m_style->hasFilter() || !m_hasPendingShaders) >+ if (!state.style()->hasFilter() || !state.hasPendingShaders()) > return; > >- CachedResourceLoader* cachedResourceLoader = m_element->document()->cachedResourceLoader(); >+ CachedResourceLoader* cachedResourceLoader = state.element()->document()->cachedResourceLoader(); > >- Vector<RefPtr<FilterOperation> >& filterOperations = m_style->mutableFilter().operations(); >+ Vector<RefPtr<FilterOperation> >& filterOperations = state.style()->mutableFilter().operations(); > for (unsigned i = 0; i < filterOperations.size(); ++i) { > RefPtr<FilterOperation> filterOperation = filterOperations.at(i); > if (filterOperation->getOperationType() == FilterOperation::CUSTOM) { >@@ -4867,7 +4842,7 @@ void StyleResolver::loadPendingShaders() > } > } > } >- m_hasPendingShaders = false; >+ state.setHasPendingShaders(false); > } > > static bool sortParametersByNameComparator(const RefPtr<CustomFilterParameter>& a, const RefPtr<CustomFilterParameter>& b) >@@ -4905,16 +4880,16 @@ PassRefPtr<CustomFilterParameter> StyleResolver::parseCustomFilterNumberParamete > return numberParameter.release(); > } > >-PassRefPtr<CustomFilterParameter> StyleResolver::parseCustomFilterTransformParameter(const String& name, CSSValueList* values) >+PassRefPtr<CustomFilterParameter> StyleResolver::parseCustomFilterTransformParameter(StyleResolveState& state, const String& name, CSSValueList* values) > { > RefPtr<CustomFilterTransformParameter> transformParameter = CustomFilterTransformParameter::create(name); > TransformOperations operations; >- createTransformOperations(values, style(), m_rootElementStyle, operations); >+ createTransformOperations(values, state.style(), state.rootElementStyle(), operations); > transformParameter->setOperations(operations); > return transformParameter.release(); > } > >-PassRefPtr<CustomFilterParameter> StyleResolver::parseCustomFilterParameter(const String& name, CSSValue* parameterValue) >+PassRefPtr<CustomFilterParameter> StyleResolver::parseCustomFilterParameter(StyleResolveState& state, const String& name, CSSValue* parameterValue) > { > // FIXME: Implement other parameters types parsing. > // booleans: https://bugs.webkit.org/show_bug.cgi?id=76438 >@@ -4937,7 +4912,7 @@ PassRefPtr<CustomFilterParameter> StyleResolver::parseCustomFilterParameter(cons > // are transforms. parseCustomFilterTransformParameter will > // return 0 if that assumption is incorrect. > if (values->itemWithoutBoundsCheck(0)->isWebKitCSSTransformValue()) >- return parseCustomFilterTransformParameter(name, values); >+ return parseCustomFilterTransformParameter(state, name, values); > > // We can have only arrays of booleans or numbers, so use the first value to choose between those two. > // We need up to 4 values (all booleans or all numbers). >@@ -4954,7 +4929,7 @@ PassRefPtr<CustomFilterParameter> StyleResolver::parseCustomFilterParameter(cons > return 0; > } > >-bool StyleResolver::parseCustomFilterParameterList(CSSValue* parametersValue, CustomFilterParameterList& parameterList) >+bool StyleResolver::parseCustomFilterParameterList(StyleResolveState& state, CSSValue* parametersValue, CustomFilterParameterList& parameterList) > { > HashSet<String> knownParameterNames; > CSSValueListIterator parameterIterator(parametersValue); >@@ -4979,7 +4954,7 @@ bool StyleResolver::parseCustomFilterParameterList(CSSValue* parametersValue, Cu > if (!iterator.hasMore()) > return false; > >- RefPtr<CustomFilterParameter> parameter = parseCustomFilterParameter(name, iterator.value()); >+ RefPtr<CustomFilterParameter> parameter = parseCustomFilterParameter(state, name, iterator.value()); > if (!parameter) > return false; > parameterList.append(parameter.release()); >@@ -4991,7 +4966,7 @@ bool StyleResolver::parseCustomFilterParameterList(CSSValue* parametersValue, Cu > return true; > } > >-PassRefPtr<CustomFilterOperation> StyleResolver::createCustomFilterOperation(WebKitCSSFilterValue* filterValue) >+PassRefPtr<CustomFilterOperation> StyleResolver::createCustomFilterOperation(StyleResolveState& state, WebKitCSSFilterValue* filterValue) > { > ASSERT(filterValue->length()); > >@@ -5002,7 +4977,7 @@ PassRefPtr<CustomFilterOperation> StyleResolver::createCustomFilterOperation(Web > unsigned shadersListLength = shadersList->length(); > ASSERT(shadersListLength); > >- RefPtr<StyleShader> vertexShader = styleShader(shadersList->itemWithoutBoundsCheck(0)); >+ RefPtr<StyleShader> vertexShader = styleShader(state, shadersList->itemWithoutBoundsCheck(0)); > RefPtr<StyleShader> fragmentShader; > CustomFilterProgramType programType = PROGRAM_TYPE_BLENDS_ELEMENT_TEXTURE; > CustomFilterProgramMixSettings mixSettings; >@@ -5015,7 +4990,7 @@ PassRefPtr<CustomFilterOperation> StyleResolver::createCustomFilterOperation(Web > CSSValueListIterator iterator(mixFunction); > > ASSERT(mixFunction->length()); >- fragmentShader = styleShader(iterator.value()); >+ fragmentShader = styleShader(state, iterator.value()); > iterator.advance(); > > ASSERT(mixFunction->length() <= 3); >@@ -5031,7 +5006,7 @@ PassRefPtr<CustomFilterOperation> StyleResolver::createCustomFilterOperation(Web > } > } else { > programType = PROGRAM_TYPE_NO_ELEMENT_TEXTURE; >- fragmentShader = styleShader(fragmentShaderOrMixFunction); >+ fragmentShader = styleShader(state, fragmentShaderOrMixFunction); > } > } > >@@ -5087,7 +5062,7 @@ PassRefPtr<CustomFilterOperation> StyleResolver::createCustomFilterOperation(Web > parametersValue = filterValue->itemWithoutBoundsCheck(2); > > CustomFilterParameterList parameterList; >- if (parametersValue && !parseCustomFilterParameterList(parametersValue, parameterList)) >+ if (parametersValue && !parseCustomFilterParameterList(state, parametersValue, parameterList)) > return 0; > > RefPtr<StyleCustomFilterProgram> program = StyleCustomFilterProgram::create(vertexShader.release(), fragmentShader.release(), programType, mixSettings, meshType); >@@ -5095,7 +5070,7 @@ PassRefPtr<CustomFilterOperation> StyleResolver::createCustomFilterOperation(Web > } > #endif > >-bool StyleResolver::createFilterOperations(CSSValue* inValue, RenderStyle* style, RenderStyle* rootStyle, FilterOperations& outOperations) >+bool StyleResolver::createFilterOperations(StyleResolveState& state, CSSValue* inValue, RenderStyle* style, RenderStyle* rootStyle, FilterOperations& outOperations) > { > ASSERT(outOperations.isEmpty()); > >@@ -5128,7 +5103,7 @@ bool StyleResolver::createFilterOperations(CSSValue* inValue, RenderStyle* style > continue; > } > if (operationType == FilterOperation::CUSTOM) { >- RefPtr<CustomFilterOperation> operation = createCustomFilterOperation(filterValue); >+ RefPtr<CustomFilterOperation> operation = createCustomFilterOperation(state, filterValue); > if (!operation) > return false; > >@@ -5146,12 +5121,12 @@ bool StyleResolver::createFilterOperations(CSSValue* inValue, RenderStyle* style > continue; > > WebKitCSSSVGDocumentValue* svgDocumentValue = static_cast<WebKitCSSSVGDocumentValue*>(argument); >- KURL url = m_element->document()->completeURL(svgDocumentValue->url()); >+ KURL url = /*m_element->*/document()->completeURL(svgDocumentValue->url()); > > RefPtr<ReferenceFilterOperation> operation = ReferenceFilterOperation::create(svgDocumentValue->url(), url.fragmentIdentifier(), operationType); >- if (SVGURIReference::isExternalURIReference(svgDocumentValue->url(), m_element->document())) { >+ if (SVGURIReference::isExternalURIReference(svgDocumentValue->url(), state.document())) { > if (!svgDocumentValue->loadRequested()) >- m_pendingSVGDocuments.set(operation.get(), svgDocumentValue); >+ state.pendingSVGDocuments().set(operation.get(), svgDocumentValue); > else if (svgDocumentValue->cachedSVGDocument()) > operation->setCachedSVGDocumentReference(adoptPtr(new CachedSVGDocumentReference(svgDocumentValue->cachedSVGDocument()))); > } >@@ -5235,7 +5210,7 @@ bool StyleResolver::createFilterOperations(CSSValue* inValue, RenderStyle* style > int blur = item->blur ? item->blur->computeLength<int>(style, rootStyle, zoomFactor) : 0; > Color color; > if (item->color) >- color = colorFromPrimitiveValue(item->color.get()); >+ color = colorFromPrimitiveValue(state, item->color.get()); > > operations.operations().append(DropShadowFilterOperation::create(location, blur, color.isValid() ? color : Color::transparent, operationType)); > break; >@@ -5255,7 +5230,7 @@ bool StyleResolver::createFilterOperations(CSSValue* inValue, RenderStyle* style > > PassRefPtr<StyleImage> StyleResolver::loadPendingImage(StylePendingImage* pendingImage) > { >- CachedResourceLoader* cachedResourceLoader = m_element->document()->cachedResourceLoader(); >+ CachedResourceLoader* cachedResourceLoader = document()->cachedResourceLoader(); > > if (pendingImage->cssImageValue()) { > CSSImageValue* imageValue = pendingImage->cssImageValue(); >@@ -5283,25 +5258,25 @@ PassRefPtr<StyleImage> StyleResolver::loadPendingImage(StylePendingImage* pendin > return 0; > } > >-void StyleResolver::loadPendingImages() >+void StyleResolver::loadPendingImages(StyleResolveState& state) > { >- if (m_pendingImageProperties.isEmpty()) >+ if (state.pendingImageProperties().isEmpty()) > return; > >- PendingImagePropertyMap::const_iterator::Keys end = m_pendingImageProperties.end().keys(); >- for (PendingImagePropertyMap::const_iterator::Keys it = m_pendingImageProperties.begin().keys(); it != end; ++it) { >+ PendingImagePropertyMap::const_iterator::Keys end = state.pendingImageProperties().end().keys(); >+ for (PendingImagePropertyMap::const_iterator::Keys it = state.pendingImageProperties().begin().keys(); it != end; ++it) { > CSSPropertyID currentProperty = *it; > > switch (currentProperty) { > case CSSPropertyBackgroundImage: { >- for (FillLayer* backgroundLayer = m_style->accessBackgroundLayers(); backgroundLayer; backgroundLayer = backgroundLayer->next()) { >+ for (FillLayer* backgroundLayer = state.style()->accessBackgroundLayers(); backgroundLayer; backgroundLayer = backgroundLayer->next()) { > if (backgroundLayer->image() && backgroundLayer->image()->isPendingImage()) > backgroundLayer->setImage(loadPendingImage(static_cast<StylePendingImage*>(backgroundLayer->image()))); > } > break; > } > case CSSPropertyContent: { >- for (ContentData* contentData = const_cast<ContentData*>(m_style->contentData()); contentData; contentData = contentData->next()) { >+ for (ContentData* contentData = const_cast<ContentData*>(state.style()->contentData()); contentData; contentData = contentData->next()) { > if (contentData->isImage()) { > StyleImage* image = static_cast<ImageContentData*>(contentData)->image(); > if (image->isPendingImage()) { >@@ -5314,7 +5289,7 @@ void StyleResolver::loadPendingImages() > break; > } > case CSSPropertyCursor: { >- if (CursorList* cursorList = m_style->cursors()) { >+ if (CursorList* cursorList = state.style()->cursors()) { > for (size_t i = 0; i < cursorList->size(); ++i) { > CursorData& currentCursor = cursorList->at(i); > if (StyleImage* image = currentCursor.image()) { >@@ -5326,17 +5301,17 @@ void StyleResolver::loadPendingImages() > break; > } > case CSSPropertyListStyleImage: { >- if (m_style->listStyleImage() && m_style->listStyleImage()->isPendingImage()) >- m_style->setListStyleImage(loadPendingImage(static_cast<StylePendingImage*>(m_style->listStyleImage()))); >+ if (state.style()->listStyleImage() && state.style()->listStyleImage()->isPendingImage()) >+ state.style()->setListStyleImage(loadPendingImage(static_cast<StylePendingImage*>(state.style()->listStyleImage()))); > break; > } > case CSSPropertyBorderImageSource: { >- if (m_style->borderImageSource() && m_style->borderImageSource()->isPendingImage()) >- m_style->setBorderImageSource(loadPendingImage(static_cast<StylePendingImage*>(m_style->borderImageSource()))); >+ if (state.style()->borderImageSource() && state.style()->borderImageSource()->isPendingImage()) >+ state.style()->setBorderImageSource(loadPendingImage(static_cast<StylePendingImage*>(state.style()->borderImageSource()))); > break; > } > case CSSPropertyWebkitBoxReflect: { >- if (StyleReflection* reflection = m_style->boxReflect()) { >+ if (StyleReflection* reflection = state.style()->boxReflect()) { > const NinePieceImage& maskImage = reflection->mask(); > if (maskImage.image() && maskImage.image()->isPendingImage()) { > RefPtr<StyleImage> loadedImage = loadPendingImage(static_cast<StylePendingImage*>(maskImage.image())); >@@ -5346,12 +5321,12 @@ void StyleResolver::loadPendingImages() > break; > } > case CSSPropertyWebkitMaskBoxImageSource: { >- if (m_style->maskBoxImageSource() && m_style->maskBoxImageSource()->isPendingImage()) >- m_style->setMaskBoxImageSource(loadPendingImage(static_cast<StylePendingImage*>(m_style->maskBoxImageSource()))); >+ if (state.style()->maskBoxImageSource() && state.style()->maskBoxImageSource()->isPendingImage()) >+ state.style()->setMaskBoxImageSource(loadPendingImage(static_cast<StylePendingImage*>(state.style()->maskBoxImageSource()))); > break; > } > case CSSPropertyWebkitMaskImage: { >- for (FillLayer* maskLayer = m_style->accessMaskLayers(); maskLayer; maskLayer = maskLayer->next()) { >+ for (FillLayer* maskLayer = state.style()->accessMaskLayers(); maskLayer; maskLayer = maskLayer->next()) { > if (maskLayer->image() && maskLayer->image()->isPendingImage()) > maskLayer->setImage(loadPendingImage(static_cast<StylePendingImage*>(maskLayer->image()))); > } >@@ -5362,22 +5337,22 @@ void StyleResolver::loadPendingImages() > } > } > >- m_pendingImageProperties.clear(); >+ state.pendingImageProperties().clear(); > } > >-void StyleResolver::loadPendingResources() >+void StyleResolver::loadPendingResources(StyleResolveState& state) > { > // Start loading images referenced by this style. >- loadPendingImages(); >+ loadPendingImages(state); > > #if ENABLE(CSS_SHADERS) > // Start loading the shaders referenced by this style. >- loadPendingShaders(); >+ loadPendingShaders(state); > #endif > > #if ENABLE(CSS_FILTERS) && ENABLE(SVG) > // Start loading the SVG Documents referenced by this style. >- loadPendingSVGDocuments(); >+ loadPendingSVGDocuments(state); > #endif > } > >@@ -5425,7 +5400,6 @@ void MediaQueryResult::reportMemoryUsage(MemoryObjectInfo* memoryObjectInfo) con > void StyleResolver::reportMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const > { > MemoryClassInfo info(memoryObjectInfo, this, WebCoreMemoryTypes::CSS); >- info.addMember(m_style); > info.addMember(m_authorStyle); > info.addMember(m_userStyle); > info.addMember(m_features); >@@ -5434,31 +5408,16 @@ void StyleResolver::reportMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const > info.addMember(m_keyframesRuleMap); > info.addMember(m_matchedPropertiesCache); > info.addMember(m_matchedPropertiesCacheSweepTimer); >- info.addMember(m_matchedRules); > >- info.addMember(m_ruleList); >- info.addMember(m_pendingImageProperties); > info.addMember(m_medium); > info.addMember(m_rootDefaultStyle); > info.addMember(m_document); > >- // FIXME: pointer to RenderStyle could point to an already deleted object. >- info.ignoreMember(m_parentStyle); >- info.ignoreMember(m_rootElementStyle); >- >- info.addMember(m_element); >- info.addMember(m_styledElement); >- info.addMember(m_regionForStyling); >- info.addMember(m_parentNode); >- info.addMember(m_lineHeightValue); > info.addMember(m_fontSelector); > info.addMember(m_viewportDependentMediaQueryResults); > info.ignoreMember(m_styleBuilder); > info.addMember(m_styleRuleToCSSOMWrapperMap); > info.addMember(m_styleSheetCSSOMWrapperSet); >-#if ENABLE(CSS_FILTERS) && ENABLE(SVG) >- info.addMember(m_pendingSVGDocuments); >-#endif > info.addMember(m_scopeResolver); > > // FIXME: move this to a place where it would be called only once? >diff --git a/Source/WebCore/css/StyleResolver.h b/Source/WebCore/css/StyleResolver.h >index 33366c767911e73019f9494bceb4dc8b0c874758..786898a65012e4d25968bf38654ebddfaa3e5c16 100644 >--- a/Source/WebCore/css/StyleResolver.h >+++ b/Source/WebCore/css/StyleResolver.h >@@ -23,6 +23,7 @@ > #define StyleResolver_h > > #include "CSSRule.h" >+#include "CSSRuleList.h" > #include "CSSToStyleMap.h" > #include "CSSValueList.h" > #include "LinkHash.h" >@@ -34,8 +35,12 @@ > #include "SelectorChecker.h" > #include "SelectorFilter.h" > #include "StyleInheritedData.h" >+#include "StyleResolveState.h" > #include "StyleScopeResolver.h" > #include "ViewportStyleResolver.h" >+#if ENABLE(CSS_FILTERS) && ENABLE(SVG) >+#include "WebKitCSSSVGDocumentValue.h" >+#endif > #include <wtf/HashMap.h> > #include <wtf/HashSet.h> > #include <wtf/RefPtr.h> >@@ -86,6 +91,7 @@ class StyleImage; > class StyleKeyframe; > class StylePendingImage; > class StylePropertySet; >+class StyleResolveState; > class StyleRule; > #if ENABLE(SHADOW_DOM) > class StyleRuleHost; >@@ -132,6 +138,9 @@ enum RuleMatchingBehavior { > MatchOnlyUserAgentRules, > }; > >+#ifndef TASAK >+#endif >+ > // This class selects a RenderStyle for a given element based on a collection of stylesheets. > class StyleResolver { > WTF_MAKE_NONCOPYABLE(StyleResolver); WTF_MAKE_FAST_ALLOCATED; >@@ -161,20 +170,7 @@ public: > > static PassRefPtr<RenderStyle> styleForDocument(Document*, CSSFontSelector* = 0); > >- RenderStyle* style() const { return m_style.get(); } >- RenderStyle* parentStyle() const { return m_parentStyle; } >- RenderStyle* rootElementStyle() const { return m_rootElementStyle; } >- Element* element() const { return m_element; } > Document* document() const { return m_document; } >- const FontDescription& fontDescription() { return style()->fontDescription(); } >- const FontDescription& parentFontDescription() { return parentStyle()->fontDescription(); } >- void setFontDescription(const FontDescription& fontDescription) { m_fontDirty |= style()->setFontDescription(fontDescription); } >- void setZoom(float f) { m_fontDirty |= style()->setZoom(f); } >- void setEffectiveZoom(float f) { m_fontDirty |= style()->setEffectiveZoom(f); } >- void setTextSizeAdjust(bool b) { m_fontDirty |= style()->setTextSizeAdjust(b); } >- void setWritingMode(WritingMode writingMode) { m_fontDirty |= style()->setWritingMode(writingMode); } >- void setTextOrientation(TextOrientation textOrientation) { m_fontDirty |= style()->setTextOrientation(textOrientation); } >- bool hasParentNode() const { return m_parentNode; } > > void resetAuthorStyle(); > void appendAuthorStyleSheets(unsigned firstNew, const Vector<RefPtr<CSSStyleSheet> >&); >@@ -198,17 +194,17 @@ private: > } > #endif > >- void initForStyleResolve(Element*, RenderStyle* parentStyle = 0, PseudoId = NOPSEUDO); >- void initElement(Element*); >+ void initForStyleResolve(StyleResolveState&, Element*, RenderStyle* parentStyle = 0); >+ void initElement(StyleResolveState&, Element*); > void collectFeatures(); >- RenderStyle* locateSharedStyle(); >- bool styleSharingCandidateMatchesRuleSet(RuleSet*); >- bool styleSharingCandidateMatchesHostRules(); >+ RenderStyle* locateSharedStyle(StyleResolveState&); >+ bool styleSharingCandidateMatchesRuleSet(Element*, RuleSet*); >+ bool styleSharingCandidateMatchesHostRules(Element*); > Node* locateCousinList(Element* parent, unsigned& visitedNodeCount) const; >- StyledElement* findSiblingForStyleSharing(Node*, unsigned& count) const; >- bool canShareStyleWithElement(StyledElement*) const; >+ StyledElement* findSiblingForStyleSharing(StyleResolveState&, Node*, unsigned& count) const; >+ bool canShareStyleWithElement(StyleResolveState&, StyledElement*) const; > >- PassRefPtr<RenderStyle> styleForKeyframe(const RenderStyle*, const StyleKeyframe*, KeyframeValue&); >+ PassRefPtr<RenderStyle> styleForKeyframe(StyleResolveState&, const RenderStyle*, const StyleKeyframe*, KeyframeValue&); > > public: > // These methods will give back the set of rules that matched for a given element (or a pseudo-element). >@@ -231,25 +227,28 @@ public: > static int legacyFontSize(Document*, int pixelFontSize, bool shouldUseFixedDefaultSize); > > public: >+ void applyPropertyWithValueChecking(StyleResolveState&, CSSPropertyID, CSSValue*); >+ void applyFontPropertyToStyle(RenderStyle* target, const StylePropertySet* reference); >+#if 0 >+ // bad methods ... I think. > void applyPropertyToStyle(CSSPropertyID, CSSValue*, RenderStyle*); > > void applyPropertyToCurrentStyle(CSSPropertyID, CSSValue*); >+#endif > >- void updateFont(); >- void initializeFontStyle(Settings*); >+ void updateFont(StyleResolveState&); >+ void initializeFontStyle(StyleResolveState&, Settings*); > > static float getComputedSizeFromSpecifiedSize(Document*, float zoomFactor, bool isAbsoluteSize, float specifiedSize, ESmartMinimumForFontSize = UseSmartMinimumForFontFize); > >- void setFontSize(FontDescription&, float size); >+ static void setFontSize(StyleResolveState&, FontDescription&, float size); > > private: > static float getComputedSizeFromSpecifiedSize(Document*, RenderStyle*, bool isAbsoluteSize, float specifiedSize, bool useSVGZoomRules); > > public: >- bool useSVGZoomRules(); >- > static bool colorFromPrimitiveValueIsDerivedFromElement(CSSPrimitiveValue*); >- Color colorFromPrimitiveValue(CSSPrimitiveValue*, bool forVisitedLink = false) const; >+ static Color colorFromPrimitiveValue(StyleResolveState&, CSSPrimitiveValue*, bool forVisitedLink = false); > > bool hasSelectorForId(const AtomicString&) const; > bool hasSelectorForClass(const AtomicString&) const; >@@ -281,34 +280,34 @@ public: > CSSStyleRule* ensureFullCSSOMWrapperForInspector(StyleRule*); > > #if ENABLE(CSS_FILTERS) >- bool createFilterOperations(CSSValue* inValue, RenderStyle* inStyle, RenderStyle* rootStyle, FilterOperations& outOperations); >+ bool createFilterOperations(StyleResolveState&, CSSValue* inValue, RenderStyle* inStyle, RenderStyle* rootStyle, FilterOperations& outOperations); > #if ENABLE(CSS_SHADERS) >- StyleShader* styleShader(CSSValue*); >- StyleShader* cachedOrPendingStyleShaderFromValue(WebKitCSSShaderValue*); >- bool parseCustomFilterParameterList(CSSValue*, CustomFilterParameterList&); >- PassRefPtr<CustomFilterParameter> parseCustomFilterParameter(const String& name, CSSValue*); >+ StyleShader* styleShader(StyleResolveState&, CSSValue*); >+ StyleShader* cachedOrPendingStyleShaderFromValue(StyleResolveState&, WebKitCSSShaderValue*); >+ bool parseCustomFilterParameterList(StyleResolveState&, CSSValue*, CustomFilterParameterList&); >+ PassRefPtr<CustomFilterParameter> parseCustomFilterParameter(StyleResolveState&, const String& name, CSSValue*); > PassRefPtr<CustomFilterParameter> parseCustomFilterArrayParameter(const String& name, CSSValueList*); > PassRefPtr<CustomFilterParameter> parseCustomFilterNumberParameter(const String& name, CSSValueList*); >- PassRefPtr<CustomFilterParameter> parseCustomFilterTransformParameter(const String& name, CSSValueList*); >- PassRefPtr<CustomFilterOperation> createCustomFilterOperation(WebKitCSSFilterValue*); >- void loadPendingShaders(); >+ PassRefPtr<CustomFilterParameter> parseCustomFilterTransformParameter(StyleResolveState&, const String& name, CSSValueList*); >+ PassRefPtr<CustomFilterOperation> createCustomFilterOperation(StyleResolveState&, WebKitCSSFilterValue*); >+ void loadPendingShaders(StyleResolveState&); > #endif > #if ENABLE(SVG) >- void loadPendingSVGDocuments(); >+ void loadPendingSVGDocuments(StyleResolveState&); > #endif > #endif // ENABLE(CSS_FILTERS) > >- void loadPendingResources(); >+ void loadPendingResources(StyleResolveState&); > > private: > // This function fixes up the default font size if it detects that the current generic font family has changed. -dwh >- void checkForGenericFamilyChange(RenderStyle*, RenderStyle* parentStyle); >- void checkForZoomChange(RenderStyle*, RenderStyle* parentStyle); >- void checkForTextSizeAdjust(); >+ void checkForGenericFamilyChange(StyleResolveState&, RenderStyle*, RenderStyle* parentStyle); >+ void checkForZoomChange(StyleResolveState&, RenderStyle*, RenderStyle* parentStyle); >+ void checkForTextSizeAdjust(RenderStyle*); > >- void adjustRenderStyle(RenderStyle* styleToAdjust, RenderStyle* parentStyle, Element*); >+ void adjustRenderStyle(StyleResolveState&, RenderStyle* styleToAdjust, RenderStyle* parentStyle, Element*); > >- void addMatchedRule(const RuleData* rule) { m_matchedRules.append(rule); } >+ void addMatchedRule(StyleResolveState& state, const RuleData* rule) { state.matchedRules().append(rule); } > > struct RuleRange { > RuleRange(int& firstRuleIndex, int& lastRuleIndex): firstRuleIndex(firstRuleIndex), lastRuleIndex(lastRuleIndex) { } >@@ -352,38 +351,28 @@ private: > bool isCacheable; > }; > >- struct MatchRequest { >- MatchRequest(RuleSet* ruleSet, bool includeEmptyRules = false, const ContainerNode* scope = 0) >- : ruleSet(ruleSet) >- , includeEmptyRules(includeEmptyRules) >- , scope(scope) { } >- const RuleSet* ruleSet; >- const bool includeEmptyRules; >- const ContainerNode* scope; >- }; >- > static void addMatchedProperties(MatchResult&, const StylePropertySet* properties, StyleRule* = 0, unsigned linkMatchType = SelectorChecker::MatchAll, PropertyWhitelistType = PropertyWhitelistNone); > void addElementStyleProperties(MatchResult&, const StylePropertySet*, bool isCacheable = true); > >- void matchAllRules(MatchResult&, bool includeSMILProperties); >- void matchUARules(MatchResult&); >- void matchUARules(MatchResult&, RuleSet*); >- void matchAuthorRules(MatchResult&, bool includeEmptyRules); >- void matchUserRules(MatchResult&, bool includeEmptyRules); >- void matchScopedAuthorRules(MatchResult&, bool includeEmptyRules); >- void matchHostRules(MatchResult&, bool includeEmptyRules); >+ void matchAllRules(StyleResolveState& request, MatchResult&, bool includeSMILProperties); >+ void matchUARules(StyleResolveState&, MatchResult&); >+ void matchUARules(StyleResolveState&, MatchResult&, RuleSet*); >+ void matchAuthorRules(StyleResolveState&, MatchResult&); >+ void matchUserRules(StyleResolveState&, MatchResult&); >+ void matchScopedAuthorRules(StyleResolveState&, MatchResult&); >+ void matchHostRules(StyleResolveState&, MatchResult&); > >- void collectMatchingRules(const MatchRequest&, RuleRange&); >- void collectMatchingRulesForRegion(const MatchRequest&, RuleRange&); >- void collectMatchingRulesForList(const Vector<RuleData>*, const MatchRequest&, RuleRange&); >+ void collectMatchingRules(RuleSet*, StyleResolveState&, RuleRange&, const ContainerNode* scope = 0); >+ void collectMatchingRulesForRegion(RuleSet*, StyleResolveState&, RuleRange&, const ContainerNode* scope = 0); >+ void collectMatchingRulesForList(const Vector<RuleData>*, StyleResolveState&, RuleRange&, const ContainerNode*); > > bool fastRejectSelector(const RuleData&) const; >- void sortMatchedRules(); >- void sortAndTransferMatchedRules(MatchResult&); >+ void sortMatchedRules(Vector<const RuleData*, 32>& matchedRules); >+ void sortAndTransferMatchedRules(StyleResolveState&, MatchResult&); > >- bool ruleMatches(const RuleData&, const ContainerNode* scope); >+ bool ruleMatches(StyleResolveState&, const RuleData&, const ContainerNode* scope, PseudoId& dynamicPseudo); > bool checkRegionSelector(const CSSSelector* regionSelector, Element* regionElement); >- void applyMatchedProperties(const MatchResult&, const Element*); >+ void applyMatchedProperties(StyleResolveState&, const MatchResult&, const Element*); > enum StyleApplicationPass { > #if ENABLE(CSS_VARIABLES) > VariableDefinitions, >@@ -392,11 +381,11 @@ private: > LowPriorityProperties > }; > template <StyleApplicationPass pass> >- void applyMatchedProperties(const MatchResult&, bool important, int startIndex, int endIndex, bool inheritedOnly); >+ void applyMatchedProperties(StyleResolveState&, const MatchResult&, bool important, int startIndex, int endIndex, bool inheritedOnly); > template <StyleApplicationPass pass> >- void applyProperties(const StylePropertySet* properties, StyleRule*, bool isImportant, bool inheritedOnly, PropertyWhitelistType = PropertyWhitelistNone); >+ void applyProperties(StyleResolveState&, const StylePropertySet* properties, StyleRule*, bool isImportant, bool inheritedOnly, PropertyWhitelistType = PropertyWhitelistNone); > #if ENABLE(CSS_VARIABLES) >- void resolveVariables(CSSPropertyID, CSSValue*, Vector<std::pair<CSSPropertyID, String> >& knownExpressions); >+ void resolveVariables(StyleResolveState&, CSSPropertyID, CSSValue*, Vector<std::pair<CSSPropertyID, String> >& knownExpressions); > #endif > static bool isValidRegionStyleProperty(CSSPropertyID); > #if ENABLE(VIDEO_TRACK) >@@ -406,8 +395,8 @@ private: > void matchPageRulesForList(Vector<StyleRulePage*>& matchedRules, const Vector<StyleRulePage*>&, bool isLeftPage, bool isFirstPage, const String& pageName); > Settings* documentSettings() { return m_document->settings(); } > >- bool isLeftPage(int pageIndex) const; >- bool isRightPage(int pageIndex) const { return !isLeftPage(pageIndex); } >+ bool isLeftPage(RenderStyle*, int pageIndex) const; >+ bool isRightPage(RenderStyle* rootElementStyle, int pageIndex) const { return !isLeftPage(rootElementStyle, pageIndex); } > bool isFirstPage(int pageIndex) const; > String pageName(int pageIndex) const; > >@@ -418,33 +407,23 @@ private: > OwnPtr<RuleSet> m_siblingRuleSet; > OwnPtr<RuleSet> m_uncommonAttributeRuleSet; > >- bool m_hasUAAppearance; >- BorderData m_borderData; >- FillLayer m_backgroundData; >- Color m_backgroundColor; >- > typedef HashMap<AtomicStringImpl*, RefPtr<StyleRuleKeyframes> > KeyframesRuleMap; > KeyframesRuleMap m_keyframesRuleMap; > > public: > static RenderStyle* styleNotYetAvailable() { return s_styleNotYetAvailable; } > >- PassRefPtr<StyleImage> styleImage(CSSPropertyID, CSSValue*); >- PassRefPtr<StyleImage> cachedOrPendingFromValue(CSSPropertyID, CSSImageValue*); >- PassRefPtr<StyleImage> generatedOrPendingFromValue(CSSPropertyID, CSSImageGeneratorValue*); >+ static PassRefPtr<StyleImage> styleImage(StyleResolveState&, CSSPropertyID, CSSValue*); >+ static PassRefPtr<StyleImage> cachedOrPendingFromValue(StyleResolveState&, CSSPropertyID, CSSImageValue*); >+ static PassRefPtr<StyleImage> generatedOrPendingFromValue(StyleResolveState&, CSSPropertyID, CSSImageGeneratorValue*); > #if ENABLE(CSS_IMAGE_SET) >- PassRefPtr<StyleImage> setOrPendingFromValue(CSSPropertyID, CSSImageSetValue*); >+ static PassRefPtr<StyleImage> setOrPendingFromValue(StyleResolveState&, CSSPropertyID, CSSImageSetValue*); > #endif >- PassRefPtr<StyleImage> cursorOrPendingFromValue(CSSPropertyID, CSSCursorImageValue*); >- >- bool applyPropertyToRegularStyle() const { return m_applyPropertyToRegularStyle; } >- bool applyPropertyToVisitedLinkStyle() const { return m_applyPropertyToVisitedLinkStyle; } >+ static PassRefPtr<StyleImage> cursorOrPendingFromValue(StyleResolveState&, CSSPropertyID, CSSCursorImageValue*); > > static Length convertToIntLength(CSSPrimitiveValue*, RenderStyle*, RenderStyle* rootStyle, double multiplier = 1); > static Length convertToFloatLength(CSSPrimitiveValue*, RenderStyle*, RenderStyle* rootStyle, double multiplier = 1); > >- CSSToStyleMap* styleMap() { return &m_styleMap; } >- > void reportMemoryUsage(MemoryObjectInfo*) const; > > private: >@@ -452,19 +431,19 @@ private: > > void collectRulesFromUserStyleSheets(const Vector<RefPtr<CSSStyleSheet> >&, RuleSet& userStyle); > >- void cacheBorderAndBackground(); >+ void cacheBorderAndBackground(StyleResolveState&, RenderStyle*); > > private: >- bool canShareStyleWithControl(StyledElement*) const; >+ bool canShareStyleWithControl(Element*, StyledElement*) const; > >- void applyProperty(CSSPropertyID, CSSValue*); >+ void applyProperty(StyleResolveState&, CSSPropertyID, CSSValue*); > > #if ENABLE(SVG) >- void applySVGProperty(CSSPropertyID, CSSValue*); >+ void applySVGProperty(StyleResolveState&, CSSPropertyID, CSSValue*); > #endif > > PassRefPtr<StyleImage> loadPendingImage(StylePendingImage*); >- void loadPendingImages(); >+ void loadPendingImages(StyleResolveState&); > > static unsigned computeMatchedPropertiesHash(const MatchedProperties*, unsigned size); > struct MatchedPropertiesCacheItem { >@@ -482,7 +461,7 @@ private: > void sweepMatchedPropertiesCache(Timer<StyleResolver>*); > > bool classNamesAffectedByRules(const SpaceSplitString&) const; >- bool sharingCandidateHasIdenticalStyleAffectingAttributes(StyledElement*) const; >+ bool sharingCandidateHasIdenticalStyleAffectingAttributes(StyleResolveState&, Element*, StyledElement*) const; > > unsigned m_matchedPropertiesCacheAdditionsSinceLastSweep; > >@@ -491,39 +470,13 @@ private: > > Timer<StyleResolver> m_matchedPropertiesCacheSweepTimer; > >- // A buffer used to hold the set of matched rules for an element, and a temporary buffer used for >- // merge sorting. >- Vector<const RuleData*, 32> m_matchedRules; >- >- RefPtr<StaticCSSRuleList> m_ruleList; >- >- typedef HashMap<CSSPropertyID, RefPtr<CSSValue> > PendingImagePropertyMap; >- PendingImagePropertyMap m_pendingImageProperties; >- > OwnPtr<MediaQueryEvaluator> m_medium; > RefPtr<RenderStyle> m_rootDefaultStyle; > >- PseudoId m_dynamicPseudo; >- PseudoId m_pseudoStyle; >- > Document* m_document; >- SelectorChecker m_selectorChecker; > SelectorFilter m_selectorFilter; > >- RefPtr<RenderStyle> m_style; >- RenderStyle* m_parentStyle; >- RenderStyle* m_rootElementStyle; >- Element* m_element; >- StyledElement* m_styledElement; >- RenderRegion* m_regionForStyling; >- EInsideLink m_elementLinkState; >- bool m_elementAffectedByClassRules; >- ContainerNode* m_parentNode; >- CSSValue* m_lineHeightValue; >- bool m_fontDirty; > bool m_matchAuthorAndUserStyles; >- bool m_sameOriginOnly; >- bool m_distributedToInsertionPoint; > > RefPtr<CSSFontSelector> m_fontSelector; > Vector<OwnPtr<MediaQueryResult> > m_viewportDependentMediaQueryResults; >@@ -532,23 +485,12 @@ private: > RefPtr<ViewportStyleResolver> m_viewportStyleResolver; > #endif > >- bool m_applyPropertyToRegularStyle; >- bool m_applyPropertyToVisitedLinkStyle; > const StyleBuilder& m_styleBuilder; > > HashMap<StyleRule*, RefPtr<CSSStyleRule> > m_styleRuleToCSSOMWrapperMap; > HashSet<RefPtr<CSSStyleSheet> > m_styleSheetCSSOMWrapperSet; > >-#if ENABLE(CSS_SHADERS) >- bool m_hasPendingShaders; >-#endif >- >-#if ENABLE(CSS_FILTERS) && ENABLE(SVG) >- HashMap<FilterOperation*, RefPtr<WebKitCSSSVGDocumentValue> > m_pendingSVGDocuments; >-#endif >- > OwnPtr<StyleScopeResolver> m_scopeResolver; >- CSSToStyleMap m_styleMap; > > friend class StyleBuilder; > friend bool operator==(const MatchedProperties&, const MatchedProperties&); >diff --git a/Source/WebCore/dom/StyledElement.h b/Source/WebCore/dom/StyledElement.h >index e41aaef4a1eb508e8b563aa85bbeff3983290e7d..f58402fa9fad3b21f70b1deba8385bf9ce8be517 100644 >--- a/Source/WebCore/dom/StyledElement.h >+++ b/Source/WebCore/dom/StyledElement.h >@@ -99,6 +99,18 @@ inline const StylePropertySet* StyledElement::presentationAttributeStyle() > return attributeData()->presentationAttributeStyle(); > } > >+inline StyledElement* toStyledElement(Node* node) >+{ >+ ASSERT(!node || node->isStyledElement()); >+ return static_cast<StyledElement*>(node); >+} >+ >+inline const StyledElement* toStyledElement(const Node* node) >+{ >+ ASSERT(!node || node->isStyledElement()); >+ return static_cast<const StyledElement*>(node); >+} >+ > } //namespace > > #endif >diff --git a/Source/WebCore/html/canvas/CanvasRenderingContext2D.cpp b/Source/WebCore/html/canvas/CanvasRenderingContext2D.cpp >index 720ca73bcec9c3edb169c2f47b6f8c2687599923..d8f3e2bf2518daf56a371d243b27e42d9a1097f9 100644 >--- a/Source/WebCore/html/canvas/CanvasRenderingContext2D.cpp >+++ b/Source/WebCore/html/canvas/CanvasRenderingContext2D.cpp >@@ -2009,19 +2009,9 @@ void CanvasRenderingContext2D::setFont(const String& newFont) > > // Now map the font property longhands into the style. > StyleResolver* styleResolver = canvas()->styleResolver(); >- styleResolver->applyPropertyToStyle(CSSPropertyFontFamily, parsedStyle->getPropertyCSSValue(CSSPropertyFontFamily).get(), newStyle.get()); >- styleResolver->applyPropertyToCurrentStyle(CSSPropertyFontStyle, parsedStyle->getPropertyCSSValue(CSSPropertyFontStyle).get()); >- styleResolver->applyPropertyToCurrentStyle(CSSPropertyFontVariant, parsedStyle->getPropertyCSSValue(CSSPropertyFontVariant).get()); >- styleResolver->applyPropertyToCurrentStyle(CSSPropertyFontWeight, parsedStyle->getPropertyCSSValue(CSSPropertyFontWeight).get()); >- >- // As described in BUG66291, setting font-size and line-height on a font may entail a CSSPrimitiveValue::computeLengthDouble call, >- // which assumes the fontMetrics are available for the affected font, otherwise a crash occurs (see http://trac.webkit.org/changeset/96122). >- // The updateFont() calls below update the fontMetrics and ensure the proper setting of font-size and line-height. >- styleResolver->updateFont(); >- styleResolver->applyPropertyToCurrentStyle(CSSPropertyFontSize, parsedStyle->getPropertyCSSValue(CSSPropertyFontSize).get()); >- styleResolver->updateFont(); >- styleResolver->applyPropertyToCurrentStyle(CSSPropertyLineHeight, parsedStyle->getPropertyCSSValue(CSSPropertyLineHeight).get()); >+ styleResolver->applyFontPropertyToStyle(newStyle.get(), parsedStyle.get()); > >+ // ok > modifiableState().m_font = newStyle->font(); > modifiableState().m_font.update(styleResolver->fontSelector()); > modifiableState().m_realizedFont = true; >diff --git a/Source/WebCore/rendering/style/RenderStyle.h b/Source/WebCore/rendering/style/RenderStyle.h >index d09a5515d8305ce7ae608a90df7f884f45d4e50d..73a735e80c870c18f1862c1f0756f4be2d4f72b5 100644 >--- a/Source/WebCore/rendering/style/RenderStyle.h >+++ b/Source/WebCore/rendering/style/RenderStyle.h >@@ -130,6 +130,7 @@ class RenderStyle: public RefCounted<RenderStyle> { > friend class RenderSVGResource; // FIXME: Needs to alter the visited state by hand. Should clean the SVG code up and move it into RenderStyle perhaps. > friend class RenderTreeAsText; // FIXME: Only needed so the render tree can keep lying and dump the wrong colors. Rebaselining would allow this to be yanked. > friend class StyleBuilder; // Sets members directly. >+ friend class StyleResolveState; // Sets members directly. > friend class StyleResolver; // Sets members directly. > protected: >
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Formatted Diff
|
Diff
Attachments on
bug 96421
:
163428
|
184683
|
184684
|
184695
|
184702
|
184714
|
184927
|
185211
|
185416
|
185427
|
185696
|
185930
|
185933
|
186284
|
186303