Move style building state to a class of its own
authorantti@apple.com <antti@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 30 Oct 2019 20:13:30 +0000 (20:13 +0000)
committerantti@apple.com <antti@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 30 Oct 2019 20:13:30 +0000 (20:13 +0000)
https://bugs.webkit.org/show_bug.cgi?id=203562

Reviewed by Zalan Bujtas.

Move most of the state needed for applying properties from StyleResolver::State and PropertyCascade::ApplyState to
new Style::BuilderState. Pass BuilderState around in all functions invoked during style building
instead of StyleResolver.

Unlike StyleResolver, BuilderState is a stack-allocated object that exists during style building only.

* Sources.txt:
* WebCore.xcodeproj/project.pbxproj:
* css/CSSToStyleMap.cpp:
(WebCore::CSSToStyleMap::CSSToStyleMap):
(WebCore::CSSToStyleMap::style const):
(WebCore::CSSToStyleMap::useSVGZoomRules const):
(WebCore::CSSToStyleMap::styleImage):
(WebCore::CSSToStyleMap::mapFillSize):
(WebCore::CSSToStyleMap::mapFillXPosition):
(WebCore::CSSToStyleMap::mapFillYPosition):
(WebCore::CSSToStyleMap::mapAnimationName):
(WebCore::CSSToStyleMap::mapNinePieceImageQuad):
(WebCore::CSSToStyleMap::rootElementStyle const): Deleted.
* css/CSSToStyleMap.h:
* css/CSSVariableReferenceValue.cpp:
(WebCore::resolveVariableFallback):
(WebCore::resolveVariableReference):
(WebCore::resolveTokenRange):
(WebCore::CSSVariableReferenceValue::resolveVariableReferences const):
* css/CSSVariableReferenceValue.h:
* css/DOMCSSRegisterCustomProperty.cpp:
(WebCore::DOMCSSRegisterCustomProperty::registerProperty):
* css/StyleBuilder.h:
* css/StyleBuilderConverter.h:
(WebCore::StyleBuilderConverter::convertLength):
(WebCore::StyleBuilderConverter::convertLengthOrAuto):
(WebCore::StyleBuilderConverter::convertLengthSizing):
(WebCore::StyleBuilderConverter::convertLengthMaxSizing):
(WebCore::StyleBuilderConverter::convertTabSize):
(WebCore::StyleBuilderConverter::convertComputedLength):
(WebCore::StyleBuilderConverter::convertLineWidth):
(WebCore::StyleBuilderConverter::convertSpacing):
(WebCore::StyleBuilderConverter::convertRadius):
(WebCore::StyleBuilderConverter::convertPositionComponentX):
(WebCore::StyleBuilderConverter::convertPositionComponentY):
(WebCore::StyleBuilderConverter::convertPositionComponent):
(WebCore::StyleBuilderConverter::convertObjectPosition):
(WebCore::StyleBuilderConverter::convertTextDecoration):
(WebCore::StyleBuilderConverter::convertNumber):
(WebCore::StyleBuilderConverter::convertNumberOrAuto):
(WebCore::StyleBuilderConverter::convertWebkitHyphenateLimitLines):
(WebCore::StyleBuilderConverter::convertBorderImage):
(WebCore::StyleBuilderConverter::convertBorderMask):
(WebCore::StyleBuilderConverter::convertStyleImage):
(WebCore::StyleBuilderConverter::convertTransform):
(WebCore::StyleBuilderConverter::convertColorScheme):
(WebCore::StyleBuilderConverter::convertString):
(WebCore::StyleBuilderConverter::convertStringOrAuto):
(WebCore::StyleBuilderConverter::convertStringOrNone):
(WebCore::StyleBuilderConverter::convertTextEmphasisPosition):
(WebCore::StyleBuilderConverter::convertTextAlign):
(WebCore::StyleBuilderConverter::convertClipPath):
(WebCore::StyleBuilderConverter::convertResize):
(WebCore::StyleBuilderConverter::convertMarqueeRepetition):
(WebCore::StyleBuilderConverter::convertMarqueeSpeed):
(WebCore::StyleBuilderConverter::convertQuotes):
(WebCore::StyleBuilderConverter::convertTextUnderlinePosition):
(WebCore::StyleBuilderConverter::convertTextUnderlineOffset):
(WebCore::StyleBuilderConverter::convertTextDecorationThickness):
(WebCore::StyleBuilderConverter::convertReflection):
(WebCore::StyleBuilderConverter::convertInitialLetter):
(WebCore::StyleBuilderConverter::convertTextStrokeWidth):
(WebCore::StyleBuilderConverter::convertLineBoxContain):
(WebCore::StyleBuilderConverter::convertTextDecorationSkip):
(WebCore::StyleBuilderConverter::convertShapeValue):
(WebCore::StyleBuilderConverter::convertScrollSnapType):
(WebCore::StyleBuilderConverter::convertScrollSnapAlign):
(WebCore::StyleBuilderConverter::createGridTrackBreadth):
(WebCore::StyleBuilderConverter::createGridTrackSize):
(WebCore::StyleBuilderConverter::createGridTrackList):
(WebCore::StyleBuilderConverter::convertGridTrackSizeList):
(WebCore::StyleBuilderConverter::convertGridTrackSize):
(WebCore::StyleBuilderConverter::convertGridPosition):
(WebCore::StyleBuilderConverter::convertGridAutoFlow):
(WebCore::StyleBuilderConverter::csstoLengthConversionDataWithTextZoomFactor):
(WebCore::StyleBuilderConverter::convertWordSpacing):
(WebCore::StyleBuilderConverter::convertPerspective):
(WebCore::StyleBuilderConverter::convertMarqueeIncrement):
(WebCore::StyleBuilderConverter::convertFilterOperations):
(WebCore::StyleBuilderConverter::convertFontFeatureSettings):
(WebCore::StyleBuilderConverter::convertFontWeight):
(WebCore::StyleBuilderConverter::convertFontStretch):
(WebCore::StyleBuilderConverter::convertFontVariationSettings):
(WebCore::StyleBuilderConverter::convertTouchCallout):
(WebCore::StyleBuilderConverter::convertTapHighlightColor):
(WebCore::StyleBuilderConverter::convertTouchAction):
(WebCore::StyleBuilderConverter::convertOverflowScrolling):
(WebCore::StyleBuilderConverter::convertSVGLengthValue):
(WebCore::StyleBuilderConverter::convertSVGLengthVector):
(WebCore::StyleBuilderConverter::convertStrokeDashArray):
(WebCore::StyleBuilderConverter::convertPaintOrder):
(WebCore::StyleBuilderConverter::convertOpacity):
(WebCore::StyleBuilderConverter::convertSVGURIReference):
(WebCore::StyleBuilderConverter::convertSVGColor):
(WebCore::StyleBuilderConverter::convertSelfOrDefaultAlignmentData):
(WebCore::StyleBuilderConverter::convertContentAlignmentData):
(WebCore::StyleBuilderConverter::convertGlyphOrientation):
(WebCore::StyleBuilderConverter::convertGlyphOrientationOrAuto):
(WebCore::StyleBuilderConverter::convertLineHeight):
(WebCore::StyleBuilderConverter::convertFontSynthesis):
(WebCore::StyleBuilderConverter::convertSpeakAs):
(WebCore::StyleBuilderConverter::convertHangingPunctuation):
(WebCore::StyleBuilderConverter::convertGapLength):
* css/StyleBuilderCustom.h:
(WebCore::StyleBuilderCustom::applyInitialWebkitMaskImage):
(WebCore::StyleBuilderCustom::applyInheritWebkitMaskImage):
(WebCore::StyleBuilderCustom::applyInitialFontFeatureSettings):
(WebCore::StyleBuilderCustom::applyInheritFontFeatureSettings):
(WebCore::StyleBuilderCustom::applyInitialFontVariationSettings):
(WebCore::StyleBuilderCustom::applyInheritFontVariationSettings):
(WebCore::StyleBuilderCustom::applyValueDirection):
(WebCore::StyleBuilderCustom::applyInitialTextAlign):
(WebCore::StyleBuilderCustom::applyValueTextAlign):
(WebCore::StyleBuilderCustom::resetEffectiveZoom):
(WebCore::StyleBuilderCustom::applyInitialZoom):
(WebCore::StyleBuilderCustom::applyInheritZoom):
(WebCore::StyleBuilderCustom::applyValueZoom):
(WebCore::StyleBuilderCustom::applyValueVerticalAlign):
(WebCore::StyleBuilderCustom::applyInheritImageResolution):
(WebCore::StyleBuilderCustom::applyInitialImageResolution):
(WebCore::StyleBuilderCustom::applyValueImageResolution):
(WebCore::StyleBuilderCustom::applyInheritSize):
(WebCore::StyleBuilderCustom::applyInitialSize):
(WebCore::StyleBuilderCustom::applyValueSize):
(WebCore::StyleBuilderCustom::applyInheritTextIndent):
(WebCore::StyleBuilderCustom::applyInitialTextIndent):
(WebCore::StyleBuilderCustom::applyValueTextIndent):
(WebCore::ApplyPropertyBorderImageModifier::applyInheritValue):
(WebCore::ApplyPropertyBorderImageModifier::applyInitialValue):
(WebCore::ApplyPropertyBorderImageModifier::applyValue):
(WebCore::ApplyPropertyBorderImageModifier::getValue):
(WebCore::ApplyPropertyBorderImageModifier::setValue):
(WebCore::StyleBuilderCustom::applyInheritLineHeight):
(WebCore::StyleBuilderCustom::applyInitialLineHeight):
(WebCore::StyleBuilderCustom::applyValueLineHeight):
(WebCore::StyleBuilderCustom::applyInheritOutlineStyle):
(WebCore::StyleBuilderCustom::applyInitialOutlineStyle):
(WebCore::StyleBuilderCustom::applyValueOutlineStyle):
(WebCore::StyleBuilderCustom::applyInitialClip):
(WebCore::StyleBuilderCustom::applyInheritClip):
(WebCore::StyleBuilderCustom::applyValueClip):
(WebCore::StyleBuilderCustom::applyValueWebkitLocale):
(WebCore::StyleBuilderCustom::applyValueWritingMode):
(WebCore::StyleBuilderCustom::applyValueWebkitTextOrientation):
(WebCore::StyleBuilderCustom::applyValueWebkitTextSizeAdjust):
(WebCore::StyleBuilderCustom::applyValueWebkitTextZoom):
(WebCore::StyleBuilderCustom::applyValueColorScheme):
(WebCore::StyleBuilderCustom::applyTextOrBoxShadowValue):
(WebCore::StyleBuilderCustom::applyInitialTextShadow):
(WebCore::StyleBuilderCustom::applyInheritTextShadow):
(WebCore::StyleBuilderCustom::applyValueTextShadow):
(WebCore::StyleBuilderCustom::applyInitialBoxShadow):
(WebCore::StyleBuilderCustom::applyInheritBoxShadow):
(WebCore::StyleBuilderCustom::applyValueBoxShadow):
(WebCore::StyleBuilderCustom::applyInitialWebkitBoxShadow):
(WebCore::StyleBuilderCustom::applyInheritWebkitBoxShadow):
(WebCore::StyleBuilderCustom::applyValueWebkitBoxShadow):
(WebCore::StyleBuilderCustom::applyInitialFontFamily):
(WebCore::StyleBuilderCustom::applyInheritFontFamily):
(WebCore::StyleBuilderCustom::applyValueFontFamily):
(WebCore::StyleBuilderCustom::isValidDisplayValue):
(WebCore::StyleBuilderCustom::applyInheritDisplay):
(WebCore::StyleBuilderCustom::applyValueDisplay):
(WebCore::StyleBuilderCustom::applyValueBaselineShift):
(WebCore::StyleBuilderCustom::applyInitialWebkitAspectRatio):
(WebCore::StyleBuilderCustom::applyInheritWebkitAspectRatio):
(WebCore::StyleBuilderCustom::applyValueWebkitAspectRatio):
(WebCore::StyleBuilderCustom::applyInitialWebkitTextEmphasisStyle):
(WebCore::StyleBuilderCustom::applyInheritWebkitTextEmphasisStyle):
(WebCore::StyleBuilderCustom::applyValueWebkitTextEmphasisStyle):
(WebCore::StyleBuilderCustom::applyInheritCounter):
(WebCore::StyleBuilderCustom::applyValueCounter):
(WebCore::StyleBuilderCustom::applyInitialCounterIncrement):
(WebCore::StyleBuilderCustom::applyInheritCounterIncrement):
(WebCore::StyleBuilderCustom::applyValueCounterIncrement):
(WebCore::StyleBuilderCustom::applyInitialCounterReset):
(WebCore::StyleBuilderCustom::applyInheritCounterReset):
(WebCore::StyleBuilderCustom::applyValueCounterReset):
(WebCore::StyleBuilderCustom::applyInitialCursor):
(WebCore::StyleBuilderCustom::applyInheritCursor):
(WebCore::StyleBuilderCustom::applyValueCursor):
(WebCore::StyleBuilderCustom::applyInitialFill):
(WebCore::StyleBuilderCustom::applyInheritFill):
(WebCore::StyleBuilderCustom::applyValueFill):
(WebCore::StyleBuilderCustom::applyInitialStroke):
(WebCore::StyleBuilderCustom::applyInheritStroke):
(WebCore::StyleBuilderCustom::applyValueStroke):
(WebCore::StyleBuilderCustom::applyInitialContent):
(WebCore::StyleBuilderCustom::applyInheritContent):
(WebCore::StyleBuilderCustom::applyValueContent):
(WebCore::StyleBuilderCustom::applyInheritFontVariantLigatures):
(WebCore::StyleBuilderCustom::applyInitialFontVariantLigatures):
(WebCore::StyleBuilderCustom::applyValueFontVariantLigatures):
(WebCore::StyleBuilderCustom::applyInheritFontVariantNumeric):
(WebCore::StyleBuilderCustom::applyInitialFontVariantNumeric):
(WebCore::StyleBuilderCustom::applyValueFontVariantNumeric):
(WebCore::StyleBuilderCustom::applyInheritFontVariantEastAsian):
(WebCore::StyleBuilderCustom::applyInitialFontVariantEastAsian):
(WebCore::StyleBuilderCustom::applyValueFontVariantEastAsian):
(WebCore::StyleBuilderCustom::applyInitialFontSize):
(WebCore::StyleBuilderCustom::applyInheritFontSize):
(WebCore::StyleBuilderCustom::determineRubyTextSizeMultiplier):
(WebCore::StyleBuilderCustom::applyInitialFontStyle):
(WebCore::StyleBuilderCustom::applyInheritFontStyle):
(WebCore::StyleBuilderCustom::applyValueFontStyle):
(WebCore::StyleBuilderCustom::applyValueFontSize):
(WebCore::StyleBuilderCustom::applyInitialGridTemplateAreas):
(WebCore::StyleBuilderCustom::applyInheritGridTemplateAreas):
(WebCore::StyleBuilderCustom::applyValueGridTemplateAreas):
(WebCore::StyleBuilderCustom::applyInitialGridTemplateColumns):
(WebCore::StyleBuilderCustom::applyInheritGridTemplateColumns):
(WebCore::StyleBuilderCustom::applyValueGridTemplateColumns):
(WebCore::StyleBuilderCustom::applyInitialGridTemplateRows):
(WebCore::StyleBuilderCustom::applyInheritGridTemplateRows):
(WebCore::StyleBuilderCustom::applyValueGridTemplateRows):
(WebCore::StyleBuilderCustom::applyValueAlt):
(WebCore::StyleBuilderCustom::applyValueWillChange):
(WebCore::StyleBuilderCustom::applyValueStrokeWidth):
(WebCore::StyleBuilderCustom::applyValueStrokeColor):
(WebCore::StyleBuilderCustom::applyInitialCustomProperty):
(WebCore::StyleBuilderCustom::applyInheritCustomProperty):
(WebCore::StyleBuilderCustom::applyValueCustomProperty):
* css/StyleResolver.cpp:
(WebCore::StyleResolver::StyleResolver):
(WebCore::StyleResolver::State::State):
(WebCore::StyleResolver::styleForKeyframe):
(WebCore::StyleResolver::styleForPage):
(WebCore::StyleResolver::updateFont):
(WebCore::StyleResolver::applyMatchedProperties):
(WebCore::StyleResolver::applyPropertyToCurrentStyle):
(WebCore::StyleResolver::initializeFontStyle):
* css/StyleResolver.h:
(WebCore::StyleResolver::inspectorCSSOMWrappers):
(WebCore::StyleResolver::State::setApplyPropertyToRegularStyle): Deleted.
(WebCore::StyleResolver::State::setApplyPropertyToVisitedLinkStyle): Deleted.
(WebCore::StyleResolver::State::applyPropertyToRegularStyle const): Deleted.
(WebCore::StyleResolver::State::applyPropertyToVisitedLinkStyle const): Deleted.
(WebCore::StyleResolver::State::setFontDirty): Deleted.
(WebCore::StyleResolver::State::fontDirty const): Deleted.
(WebCore::StyleResolver::State::fontDescription): Deleted.
(WebCore::StyleResolver::State::parentFontDescription): Deleted.
(WebCore::StyleResolver::State::setFontDescription): Deleted.
(WebCore::StyleResolver::State::setZoom): Deleted.
(WebCore::StyleResolver::State::setEffectiveZoom): Deleted.
(WebCore::StyleResolver::State::setWritingMode): Deleted.
(WebCore::StyleResolver::State::setTextOrientation): Deleted.
(WebCore::StyleResolver::State::cascadeLevel const): Deleted.
(WebCore::StyleResolver::State::setCascadeLevel): Deleted.
(WebCore::StyleResolver::State::styleScopeOrdinal const): Deleted.
(WebCore::StyleResolver::State::setStyleScopeOrdinal): Deleted.
(WebCore::StyleResolver::applyPropertyToRegularStyle const): Deleted.
(WebCore::StyleResolver::applyPropertyToVisitedLinkStyle const): Deleted.
(WebCore::StyleResolver::styleMap): Deleted.
(WebCore::StyleResolver::fontDescription): Deleted.
(WebCore::StyleResolver::parentFontDescription): Deleted.
(WebCore::StyleResolver::setFontDescription): Deleted.
(WebCore::StyleResolver::setZoom): Deleted.
(WebCore::StyleResolver::setEffectiveZoom): Deleted.
(WebCore::StyleResolver::setWritingMode): Deleted.
(WebCore::StyleResolver::setTextOrientation): Deleted.
* css/makeprop.pl:
(getAutoGetter):
(getAutoSetter):
(getVisitedLinkSetter):
(colorFromPrimitiveValue):
(generateColorValueSetter):
(handleCurrentColorValue):
(generateAnimationPropertyInitialValueSetter):
(generateAnimationPropertyInheritValueSetter):
(generateAnimationPropertyValueSetter):
(generateFillLayerPropertyInitialValueSetter):
(generateFillLayerPropertyInheritValueSetter):
(generateFillLayerPropertyValueSetter):
(generateSetValueStatement):
(generateInitialValueSetter):
(generateInheritValueSetter):
(generateValueSetter):
* css/parser/CSSParser.cpp:
(WebCore::CSSParser::parseValueWithVariableReferences):
* css/parser/CSSParser.h:
* css/parser/CSSPropertyParser.cpp:
(WebCore::CSSPropertyParser::parseTypedCustomPropertyValue):
* css/parser/CSSPropertyParser.h:
* html/canvas/CanvasRenderingContext2D.cpp:
(WebCore::CanvasRenderingContext2D::setFont):
* platform/graphics/GraphicsContext.cpp:
(WebCore::GraphicsContext::builderState):
(WebCore::GraphicsContext::applyState): Deleted.
* platform/graphics/GraphicsContext.h:
* platform/graphics/displaylists/DisplayListItems.h:
* style/CascadeLevel.h: Copied from Source/WebCore/css/StyleBuilder.h.
(WebCore::Style::allCascadeLevels):
* style/PropertyCascade.cpp:
(WebCore::Style::PropertyCascade::PropertyCascade):
(WebCore::Style::PropertyCascade::applyPropertiesImpl):
(WebCore::Style::PropertyCascade::applyCustomProperty):
(WebCore::Style::PropertyCascade::applyProperty):
(WebCore::Style::PropertyCascade::resolveValue):
(WebCore::Style::PropertyCascade::resolvedVariableValue):
(WebCore::Style::PropertyCascade::resolveDirectionAndWritingMode):
* style/PropertyCascade.h:
(WebCore::Style::PropertyCascade::builderState):
(WebCore::Style::allCascadeLevels): Deleted.
(WebCore::Style::PropertyCascade::styleResolver): Deleted.
* style/StyleBuilderState.cpp: Added.
(WebCore::Style::BuilderState::BuilderState):
(WebCore::Style::BuilderState::useSVGZoomRules const):
(WebCore::Style::BuilderState::useSVGZoomRulesForLength const):
(WebCore::Style::BuilderState::createStyleImage):
(WebCore::Style::BuilderState::createFilterOperations):
(WebCore::Style::BuilderState::colorFromPrimitiveValue const):
(WebCore::Style::BuilderState::setFontSize):
* style/StyleBuilderState.h: Added.
(WebCore::Style::BuilderState::cascade):
(WebCore::Style::BuilderState::styleResolver):
(WebCore::Style::BuilderState::style):
(WebCore::Style::BuilderState::parentStyle const):
(WebCore::Style::BuilderState::rootElementStyle const):
(WebCore::Style::BuilderState::document const):
(WebCore::Style::BuilderState::element const):
(WebCore::Style::BuilderState::setFontDescription):
(WebCore::Style::BuilderState::setZoom):
(WebCore::Style::BuilderState::setEffectiveZoom):
(WebCore::Style::BuilderState::setWritingMode):
(WebCore::Style::BuilderState::setTextOrientation):
(WebCore::Style::BuilderState::fontDirty const):
(WebCore::Style::BuilderState::setFontDirty):
(WebCore::Style::BuilderState::clearFontDirty):
(WebCore::Style::BuilderState::fontDescription):
(WebCore::Style::BuilderState::parentFontDescription):
(WebCore::Style::BuilderState::applyPropertyToRegularStyle const):
(WebCore::Style::BuilderState::applyPropertyToVisitedLinkStyle const):
(WebCore::Style::BuilderState::styleScopeOrdinal const):
(WebCore::Style::BuilderState::cssToLengthConversionData const):
(WebCore::Style::BuilderState::styleMap):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@251796 268f45cc-cd09-0410-ab3c-d52691b4dbfc

27 files changed:
Source/WebCore/ChangeLog
Source/WebCore/Sources.txt
Source/WebCore/WebCore.xcodeproj/project.pbxproj
Source/WebCore/css/CSSToStyleMap.cpp
Source/WebCore/css/CSSToStyleMap.h
Source/WebCore/css/CSSVariableReferenceValue.cpp
Source/WebCore/css/CSSVariableReferenceValue.h
Source/WebCore/css/DOMCSSRegisterCustomProperty.cpp
Source/WebCore/css/StyleBuilder.h
Source/WebCore/css/StyleBuilderConverter.h
Source/WebCore/css/StyleBuilderCustom.h
Source/WebCore/css/StyleResolver.cpp
Source/WebCore/css/StyleResolver.h
Source/WebCore/css/makeprop.pl
Source/WebCore/css/parser/CSSParser.cpp
Source/WebCore/css/parser/CSSParser.h
Source/WebCore/css/parser/CSSPropertyParser.cpp
Source/WebCore/css/parser/CSSPropertyParser.h
Source/WebCore/html/canvas/CanvasRenderingContext2D.cpp
Source/WebCore/platform/graphics/GraphicsContext.cpp
Source/WebCore/platform/graphics/GraphicsContext.h
Source/WebCore/platform/graphics/displaylists/DisplayListItems.h
Source/WebCore/style/CascadeLevel.h [new file with mode: 0644]
Source/WebCore/style/PropertyCascade.cpp
Source/WebCore/style/PropertyCascade.h
Source/WebCore/style/StyleBuilderState.cpp [new file with mode: 0644]
Source/WebCore/style/StyleBuilderState.h [new file with mode: 0644]

index 3520dd4..e46641b 100644 (file)
@@ -1,3 +1,352 @@
+2019-10-30  Antti Koivisto  <antti@apple.com>
+
+        Move style building state to a class of its own
+        https://bugs.webkit.org/show_bug.cgi?id=203562
+
+        Reviewed by Zalan Bujtas.
+
+        Move most of the state needed for applying properties from StyleResolver::State and PropertyCascade::ApplyState to
+        new Style::BuilderState. Pass BuilderState around in all functions invoked during style building
+        instead of StyleResolver.
+
+        Unlike StyleResolver, BuilderState is a stack-allocated object that exists during style building only.
+
+        * Sources.txt:
+        * WebCore.xcodeproj/project.pbxproj:
+        * css/CSSToStyleMap.cpp:
+        (WebCore::CSSToStyleMap::CSSToStyleMap):
+        (WebCore::CSSToStyleMap::style const):
+        (WebCore::CSSToStyleMap::useSVGZoomRules const):
+        (WebCore::CSSToStyleMap::styleImage):
+        (WebCore::CSSToStyleMap::mapFillSize):
+        (WebCore::CSSToStyleMap::mapFillXPosition):
+        (WebCore::CSSToStyleMap::mapFillYPosition):
+        (WebCore::CSSToStyleMap::mapAnimationName):
+        (WebCore::CSSToStyleMap::mapNinePieceImageQuad):
+        (WebCore::CSSToStyleMap::rootElementStyle const): Deleted.
+        * css/CSSToStyleMap.h:
+        * css/CSSVariableReferenceValue.cpp:
+        (WebCore::resolveVariableFallback):
+        (WebCore::resolveVariableReference):
+        (WebCore::resolveTokenRange):
+        (WebCore::CSSVariableReferenceValue::resolveVariableReferences const):
+        * css/CSSVariableReferenceValue.h:
+        * css/DOMCSSRegisterCustomProperty.cpp:
+        (WebCore::DOMCSSRegisterCustomProperty::registerProperty):
+        * css/StyleBuilder.h:
+        * css/StyleBuilderConverter.h:
+        (WebCore::StyleBuilderConverter::convertLength):
+        (WebCore::StyleBuilderConverter::convertLengthOrAuto):
+        (WebCore::StyleBuilderConverter::convertLengthSizing):
+        (WebCore::StyleBuilderConverter::convertLengthMaxSizing):
+        (WebCore::StyleBuilderConverter::convertTabSize):
+        (WebCore::StyleBuilderConverter::convertComputedLength):
+        (WebCore::StyleBuilderConverter::convertLineWidth):
+        (WebCore::StyleBuilderConverter::convertSpacing):
+        (WebCore::StyleBuilderConverter::convertRadius):
+        (WebCore::StyleBuilderConverter::convertPositionComponentX):
+        (WebCore::StyleBuilderConverter::convertPositionComponentY):
+        (WebCore::StyleBuilderConverter::convertPositionComponent):
+        (WebCore::StyleBuilderConverter::convertObjectPosition):
+        (WebCore::StyleBuilderConverter::convertTextDecoration):
+        (WebCore::StyleBuilderConverter::convertNumber):
+        (WebCore::StyleBuilderConverter::convertNumberOrAuto):
+        (WebCore::StyleBuilderConverter::convertWebkitHyphenateLimitLines):
+        (WebCore::StyleBuilderConverter::convertBorderImage):
+        (WebCore::StyleBuilderConverter::convertBorderMask):
+        (WebCore::StyleBuilderConverter::convertStyleImage):
+        (WebCore::StyleBuilderConverter::convertTransform):
+        (WebCore::StyleBuilderConverter::convertColorScheme):
+        (WebCore::StyleBuilderConverter::convertString):
+        (WebCore::StyleBuilderConverter::convertStringOrAuto):
+        (WebCore::StyleBuilderConverter::convertStringOrNone):
+        (WebCore::StyleBuilderConverter::convertTextEmphasisPosition):
+        (WebCore::StyleBuilderConverter::convertTextAlign):
+        (WebCore::StyleBuilderConverter::convertClipPath):
+        (WebCore::StyleBuilderConverter::convertResize):
+        (WebCore::StyleBuilderConverter::convertMarqueeRepetition):
+        (WebCore::StyleBuilderConverter::convertMarqueeSpeed):
+        (WebCore::StyleBuilderConverter::convertQuotes):
+        (WebCore::StyleBuilderConverter::convertTextUnderlinePosition):
+        (WebCore::StyleBuilderConverter::convertTextUnderlineOffset):
+        (WebCore::StyleBuilderConverter::convertTextDecorationThickness):
+        (WebCore::StyleBuilderConverter::convertReflection):
+        (WebCore::StyleBuilderConverter::convertInitialLetter):
+        (WebCore::StyleBuilderConverter::convertTextStrokeWidth):
+        (WebCore::StyleBuilderConverter::convertLineBoxContain):
+        (WebCore::StyleBuilderConverter::convertTextDecorationSkip):
+        (WebCore::StyleBuilderConverter::convertShapeValue):
+        (WebCore::StyleBuilderConverter::convertScrollSnapType):
+        (WebCore::StyleBuilderConverter::convertScrollSnapAlign):
+        (WebCore::StyleBuilderConverter::createGridTrackBreadth):
+        (WebCore::StyleBuilderConverter::createGridTrackSize):
+        (WebCore::StyleBuilderConverter::createGridTrackList):
+        (WebCore::StyleBuilderConverter::convertGridTrackSizeList):
+        (WebCore::StyleBuilderConverter::convertGridTrackSize):
+        (WebCore::StyleBuilderConverter::convertGridPosition):
+        (WebCore::StyleBuilderConverter::convertGridAutoFlow):
+        (WebCore::StyleBuilderConverter::csstoLengthConversionDataWithTextZoomFactor):
+        (WebCore::StyleBuilderConverter::convertWordSpacing):
+        (WebCore::StyleBuilderConverter::convertPerspective):
+        (WebCore::StyleBuilderConverter::convertMarqueeIncrement):
+        (WebCore::StyleBuilderConverter::convertFilterOperations):
+        (WebCore::StyleBuilderConverter::convertFontFeatureSettings):
+        (WebCore::StyleBuilderConverter::convertFontWeight):
+        (WebCore::StyleBuilderConverter::convertFontStretch):
+        (WebCore::StyleBuilderConverter::convertFontVariationSettings):
+        (WebCore::StyleBuilderConverter::convertTouchCallout):
+        (WebCore::StyleBuilderConverter::convertTapHighlightColor):
+        (WebCore::StyleBuilderConverter::convertTouchAction):
+        (WebCore::StyleBuilderConverter::convertOverflowScrolling):
+        (WebCore::StyleBuilderConverter::convertSVGLengthValue):
+        (WebCore::StyleBuilderConverter::convertSVGLengthVector):
+        (WebCore::StyleBuilderConverter::convertStrokeDashArray):
+        (WebCore::StyleBuilderConverter::convertPaintOrder):
+        (WebCore::StyleBuilderConverter::convertOpacity):
+        (WebCore::StyleBuilderConverter::convertSVGURIReference):
+        (WebCore::StyleBuilderConverter::convertSVGColor):
+        (WebCore::StyleBuilderConverter::convertSelfOrDefaultAlignmentData):
+        (WebCore::StyleBuilderConverter::convertContentAlignmentData):
+        (WebCore::StyleBuilderConverter::convertGlyphOrientation):
+        (WebCore::StyleBuilderConverter::convertGlyphOrientationOrAuto):
+        (WebCore::StyleBuilderConverter::convertLineHeight):
+        (WebCore::StyleBuilderConverter::convertFontSynthesis):
+        (WebCore::StyleBuilderConverter::convertSpeakAs):
+        (WebCore::StyleBuilderConverter::convertHangingPunctuation):
+        (WebCore::StyleBuilderConverter::convertGapLength):
+        * css/StyleBuilderCustom.h:
+        (WebCore::StyleBuilderCustom::applyInitialWebkitMaskImage):
+        (WebCore::StyleBuilderCustom::applyInheritWebkitMaskImage):
+        (WebCore::StyleBuilderCustom::applyInitialFontFeatureSettings):
+        (WebCore::StyleBuilderCustom::applyInheritFontFeatureSettings):
+        (WebCore::StyleBuilderCustom::applyInitialFontVariationSettings):
+        (WebCore::StyleBuilderCustom::applyInheritFontVariationSettings):
+        (WebCore::StyleBuilderCustom::applyValueDirection):
+        (WebCore::StyleBuilderCustom::applyInitialTextAlign):
+        (WebCore::StyleBuilderCustom::applyValueTextAlign):
+        (WebCore::StyleBuilderCustom::resetEffectiveZoom):
+        (WebCore::StyleBuilderCustom::applyInitialZoom):
+        (WebCore::StyleBuilderCustom::applyInheritZoom):
+        (WebCore::StyleBuilderCustom::applyValueZoom):
+        (WebCore::StyleBuilderCustom::applyValueVerticalAlign):
+        (WebCore::StyleBuilderCustom::applyInheritImageResolution):
+        (WebCore::StyleBuilderCustom::applyInitialImageResolution):
+        (WebCore::StyleBuilderCustom::applyValueImageResolution):
+        (WebCore::StyleBuilderCustom::applyInheritSize):
+        (WebCore::StyleBuilderCustom::applyInitialSize):
+        (WebCore::StyleBuilderCustom::applyValueSize):
+        (WebCore::StyleBuilderCustom::applyInheritTextIndent):
+        (WebCore::StyleBuilderCustom::applyInitialTextIndent):
+        (WebCore::StyleBuilderCustom::applyValueTextIndent):
+        (WebCore::ApplyPropertyBorderImageModifier::applyInheritValue):
+        (WebCore::ApplyPropertyBorderImageModifier::applyInitialValue):
+        (WebCore::ApplyPropertyBorderImageModifier::applyValue):
+        (WebCore::ApplyPropertyBorderImageModifier::getValue):
+        (WebCore::ApplyPropertyBorderImageModifier::setValue):
+        (WebCore::StyleBuilderCustom::applyInheritLineHeight):
+        (WebCore::StyleBuilderCustom::applyInitialLineHeight):
+        (WebCore::StyleBuilderCustom::applyValueLineHeight):
+        (WebCore::StyleBuilderCustom::applyInheritOutlineStyle):
+        (WebCore::StyleBuilderCustom::applyInitialOutlineStyle):
+        (WebCore::StyleBuilderCustom::applyValueOutlineStyle):
+        (WebCore::StyleBuilderCustom::applyInitialClip):
+        (WebCore::StyleBuilderCustom::applyInheritClip):
+        (WebCore::StyleBuilderCustom::applyValueClip):
+        (WebCore::StyleBuilderCustom::applyValueWebkitLocale):
+        (WebCore::StyleBuilderCustom::applyValueWritingMode):
+        (WebCore::StyleBuilderCustom::applyValueWebkitTextOrientation):
+        (WebCore::StyleBuilderCustom::applyValueWebkitTextSizeAdjust):
+        (WebCore::StyleBuilderCustom::applyValueWebkitTextZoom):
+        (WebCore::StyleBuilderCustom::applyValueColorScheme):
+        (WebCore::StyleBuilderCustom::applyTextOrBoxShadowValue):
+        (WebCore::StyleBuilderCustom::applyInitialTextShadow):
+        (WebCore::StyleBuilderCustom::applyInheritTextShadow):
+        (WebCore::StyleBuilderCustom::applyValueTextShadow):
+        (WebCore::StyleBuilderCustom::applyInitialBoxShadow):
+        (WebCore::StyleBuilderCustom::applyInheritBoxShadow):
+        (WebCore::StyleBuilderCustom::applyValueBoxShadow):
+        (WebCore::StyleBuilderCustom::applyInitialWebkitBoxShadow):
+        (WebCore::StyleBuilderCustom::applyInheritWebkitBoxShadow):
+        (WebCore::StyleBuilderCustom::applyValueWebkitBoxShadow):
+        (WebCore::StyleBuilderCustom::applyInitialFontFamily):
+        (WebCore::StyleBuilderCustom::applyInheritFontFamily):
+        (WebCore::StyleBuilderCustom::applyValueFontFamily):
+        (WebCore::StyleBuilderCustom::isValidDisplayValue):
+        (WebCore::StyleBuilderCustom::applyInheritDisplay):
+        (WebCore::StyleBuilderCustom::applyValueDisplay):
+        (WebCore::StyleBuilderCustom::applyValueBaselineShift):
+        (WebCore::StyleBuilderCustom::applyInitialWebkitAspectRatio):
+        (WebCore::StyleBuilderCustom::applyInheritWebkitAspectRatio):
+        (WebCore::StyleBuilderCustom::applyValueWebkitAspectRatio):
+        (WebCore::StyleBuilderCustom::applyInitialWebkitTextEmphasisStyle):
+        (WebCore::StyleBuilderCustom::applyInheritWebkitTextEmphasisStyle):
+        (WebCore::StyleBuilderCustom::applyValueWebkitTextEmphasisStyle):
+        (WebCore::StyleBuilderCustom::applyInheritCounter):
+        (WebCore::StyleBuilderCustom::applyValueCounter):
+        (WebCore::StyleBuilderCustom::applyInitialCounterIncrement):
+        (WebCore::StyleBuilderCustom::applyInheritCounterIncrement):
+        (WebCore::StyleBuilderCustom::applyValueCounterIncrement):
+        (WebCore::StyleBuilderCustom::applyInitialCounterReset):
+        (WebCore::StyleBuilderCustom::applyInheritCounterReset):
+        (WebCore::StyleBuilderCustom::applyValueCounterReset):
+        (WebCore::StyleBuilderCustom::applyInitialCursor):
+        (WebCore::StyleBuilderCustom::applyInheritCursor):
+        (WebCore::StyleBuilderCustom::applyValueCursor):
+        (WebCore::StyleBuilderCustom::applyInitialFill):
+        (WebCore::StyleBuilderCustom::applyInheritFill):
+        (WebCore::StyleBuilderCustom::applyValueFill):
+        (WebCore::StyleBuilderCustom::applyInitialStroke):
+        (WebCore::StyleBuilderCustom::applyInheritStroke):
+        (WebCore::StyleBuilderCustom::applyValueStroke):
+        (WebCore::StyleBuilderCustom::applyInitialContent):
+        (WebCore::StyleBuilderCustom::applyInheritContent):
+        (WebCore::StyleBuilderCustom::applyValueContent):
+        (WebCore::StyleBuilderCustom::applyInheritFontVariantLigatures):
+        (WebCore::StyleBuilderCustom::applyInitialFontVariantLigatures):
+        (WebCore::StyleBuilderCustom::applyValueFontVariantLigatures):
+        (WebCore::StyleBuilderCustom::applyInheritFontVariantNumeric):
+        (WebCore::StyleBuilderCustom::applyInitialFontVariantNumeric):
+        (WebCore::StyleBuilderCustom::applyValueFontVariantNumeric):
+        (WebCore::StyleBuilderCustom::applyInheritFontVariantEastAsian):
+        (WebCore::StyleBuilderCustom::applyInitialFontVariantEastAsian):
+        (WebCore::StyleBuilderCustom::applyValueFontVariantEastAsian):
+        (WebCore::StyleBuilderCustom::applyInitialFontSize):
+        (WebCore::StyleBuilderCustom::applyInheritFontSize):
+        (WebCore::StyleBuilderCustom::determineRubyTextSizeMultiplier):
+        (WebCore::StyleBuilderCustom::applyInitialFontStyle):
+        (WebCore::StyleBuilderCustom::applyInheritFontStyle):
+        (WebCore::StyleBuilderCustom::applyValueFontStyle):
+        (WebCore::StyleBuilderCustom::applyValueFontSize):
+        (WebCore::StyleBuilderCustom::applyInitialGridTemplateAreas):
+        (WebCore::StyleBuilderCustom::applyInheritGridTemplateAreas):
+        (WebCore::StyleBuilderCustom::applyValueGridTemplateAreas):
+        (WebCore::StyleBuilderCustom::applyInitialGridTemplateColumns):
+        (WebCore::StyleBuilderCustom::applyInheritGridTemplateColumns):
+        (WebCore::StyleBuilderCustom::applyValueGridTemplateColumns):
+        (WebCore::StyleBuilderCustom::applyInitialGridTemplateRows):
+        (WebCore::StyleBuilderCustom::applyInheritGridTemplateRows):
+        (WebCore::StyleBuilderCustom::applyValueGridTemplateRows):
+        (WebCore::StyleBuilderCustom::applyValueAlt):
+        (WebCore::StyleBuilderCustom::applyValueWillChange):
+        (WebCore::StyleBuilderCustom::applyValueStrokeWidth):
+        (WebCore::StyleBuilderCustom::applyValueStrokeColor):
+        (WebCore::StyleBuilderCustom::applyInitialCustomProperty):
+        (WebCore::StyleBuilderCustom::applyInheritCustomProperty):
+        (WebCore::StyleBuilderCustom::applyValueCustomProperty):
+        * css/StyleResolver.cpp:
+        (WebCore::StyleResolver::StyleResolver):
+        (WebCore::StyleResolver::State::State):
+        (WebCore::StyleResolver::styleForKeyframe):
+        (WebCore::StyleResolver::styleForPage):
+        (WebCore::StyleResolver::updateFont):
+        (WebCore::StyleResolver::applyMatchedProperties):
+        (WebCore::StyleResolver::applyPropertyToCurrentStyle):
+        (WebCore::StyleResolver::initializeFontStyle):
+        * css/StyleResolver.h:
+        (WebCore::StyleResolver::inspectorCSSOMWrappers):
+        (WebCore::StyleResolver::State::setApplyPropertyToRegularStyle): Deleted.
+        (WebCore::StyleResolver::State::setApplyPropertyToVisitedLinkStyle): Deleted.
+        (WebCore::StyleResolver::State::applyPropertyToRegularStyle const): Deleted.
+        (WebCore::StyleResolver::State::applyPropertyToVisitedLinkStyle const): Deleted.
+        (WebCore::StyleResolver::State::setFontDirty): Deleted.
+        (WebCore::StyleResolver::State::fontDirty const): Deleted.
+        (WebCore::StyleResolver::State::fontDescription): Deleted.
+        (WebCore::StyleResolver::State::parentFontDescription): Deleted.
+        (WebCore::StyleResolver::State::setFontDescription): Deleted.
+        (WebCore::StyleResolver::State::setZoom): Deleted.
+        (WebCore::StyleResolver::State::setEffectiveZoom): Deleted.
+        (WebCore::StyleResolver::State::setWritingMode): Deleted.
+        (WebCore::StyleResolver::State::setTextOrientation): Deleted.
+        (WebCore::StyleResolver::State::cascadeLevel const): Deleted.
+        (WebCore::StyleResolver::State::setCascadeLevel): Deleted.
+        (WebCore::StyleResolver::State::styleScopeOrdinal const): Deleted.
+        (WebCore::StyleResolver::State::setStyleScopeOrdinal): Deleted.
+        (WebCore::StyleResolver::applyPropertyToRegularStyle const): Deleted.
+        (WebCore::StyleResolver::applyPropertyToVisitedLinkStyle const): Deleted.
+        (WebCore::StyleResolver::styleMap): Deleted.
+        (WebCore::StyleResolver::fontDescription): Deleted.
+        (WebCore::StyleResolver::parentFontDescription): Deleted.
+        (WebCore::StyleResolver::setFontDescription): Deleted.
+        (WebCore::StyleResolver::setZoom): Deleted.
+        (WebCore::StyleResolver::setEffectiveZoom): Deleted.
+        (WebCore::StyleResolver::setWritingMode): Deleted.
+        (WebCore::StyleResolver::setTextOrientation): Deleted.
+        * css/makeprop.pl:
+        (getAutoGetter):
+        (getAutoSetter):
+        (getVisitedLinkSetter):
+        (colorFromPrimitiveValue):
+        (generateColorValueSetter):
+        (handleCurrentColorValue):
+        (generateAnimationPropertyInitialValueSetter):
+        (generateAnimationPropertyInheritValueSetter):
+        (generateAnimationPropertyValueSetter):
+        (generateFillLayerPropertyInitialValueSetter):
+        (generateFillLayerPropertyInheritValueSetter):
+        (generateFillLayerPropertyValueSetter):
+        (generateSetValueStatement):
+        (generateInitialValueSetter):
+        (generateInheritValueSetter):
+        (generateValueSetter):
+        * css/parser/CSSParser.cpp:
+        (WebCore::CSSParser::parseValueWithVariableReferences):
+        * css/parser/CSSParser.h:
+        * css/parser/CSSPropertyParser.cpp:
+        (WebCore::CSSPropertyParser::parseTypedCustomPropertyValue):
+        * css/parser/CSSPropertyParser.h:
+        * html/canvas/CanvasRenderingContext2D.cpp:
+        (WebCore::CanvasRenderingContext2D::setFont):
+        * platform/graphics/GraphicsContext.cpp:
+        (WebCore::GraphicsContext::builderState):
+        (WebCore::GraphicsContext::applyState): Deleted.
+        * platform/graphics/GraphicsContext.h:
+        * platform/graphics/displaylists/DisplayListItems.h:
+        * style/CascadeLevel.h: Copied from Source/WebCore/css/StyleBuilder.h.
+        (WebCore::Style::allCascadeLevels):
+        * style/PropertyCascade.cpp:
+        (WebCore::Style::PropertyCascade::PropertyCascade):
+        (WebCore::Style::PropertyCascade::applyPropertiesImpl):
+        (WebCore::Style::PropertyCascade::applyCustomProperty):
+        (WebCore::Style::PropertyCascade::applyProperty):
+        (WebCore::Style::PropertyCascade::resolveValue):
+        (WebCore::Style::PropertyCascade::resolvedVariableValue):
+        (WebCore::Style::PropertyCascade::resolveDirectionAndWritingMode):
+        * style/PropertyCascade.h:
+        (WebCore::Style::PropertyCascade::builderState):
+        (WebCore::Style::allCascadeLevels): Deleted.
+        (WebCore::Style::PropertyCascade::styleResolver): Deleted.
+        * style/StyleBuilderState.cpp: Added.
+        (WebCore::Style::BuilderState::BuilderState):
+        (WebCore::Style::BuilderState::useSVGZoomRules const):
+        (WebCore::Style::BuilderState::useSVGZoomRulesForLength const):
+        (WebCore::Style::BuilderState::createStyleImage):
+        (WebCore::Style::BuilderState::createFilterOperations):
+        (WebCore::Style::BuilderState::colorFromPrimitiveValue const):
+        (WebCore::Style::BuilderState::setFontSize):
+        * style/StyleBuilderState.h: Added.
+        (WebCore::Style::BuilderState::cascade):
+        (WebCore::Style::BuilderState::styleResolver):
+        (WebCore::Style::BuilderState::style):
+        (WebCore::Style::BuilderState::parentStyle const):
+        (WebCore::Style::BuilderState::rootElementStyle const):
+        (WebCore::Style::BuilderState::document const):
+        (WebCore::Style::BuilderState::element const):
+        (WebCore::Style::BuilderState::setFontDescription):
+        (WebCore::Style::BuilderState::setZoom):
+        (WebCore::Style::BuilderState::setEffectiveZoom):
+        (WebCore::Style::BuilderState::setWritingMode):
+        (WebCore::Style::BuilderState::setTextOrientation):
+        (WebCore::Style::BuilderState::fontDirty const):
+        (WebCore::Style::BuilderState::setFontDirty):
+        (WebCore::Style::BuilderState::clearFontDirty):
+        (WebCore::Style::BuilderState::fontDescription):
+        (WebCore::Style::BuilderState::parentFontDescription):
+        (WebCore::Style::BuilderState::applyPropertyToRegularStyle const):
+        (WebCore::Style::BuilderState::applyPropertyToVisitedLinkStyle const):
+        (WebCore::Style::BuilderState::styleScopeOrdinal const):
+        (WebCore::Style::BuilderState::cssToLengthConversionData const):
+        (WebCore::Style::BuilderState::styleMap):
+
 2019-10-30  Ryosuke Niwa  <rniwa@webkit.org>
 
         Introduce WorkerEventLoop and use it in FetchBodyOwner::runNetworkTaskWhenPossible
index 91ce3ab..3dc8bf1 100644 (file)
@@ -2345,6 +2345,7 @@ style/ClassChangeInvalidation.cpp
 style/IdChangeInvalidation.cpp
 style/InlineTextBoxStyle.cpp
 style/PropertyCascade.cpp
+style/StyleBuilderState.cpp
 style/StyleChange.cpp
 style/StyleFontSizeFunctions.cpp
 style/StyleInvalidator.cpp
index c4633f0..9e27e62 100644 (file)
                E4A814E01C7338EB00BF85AC /* IdChangeInvalidation.h in Headers */ = {isa = PBXBuildFile; fileRef = E4A814DF1C7338EB00BF85AC /* IdChangeInvalidation.h */; };
                E4A8D21622578DB700A8463C /* EventRegion.h in Headers */ = {isa = PBXBuildFile; fileRef = E4A8D21422578DA000A8463C /* EventRegion.h */; settings = {ATTRIBUTES = (Private, ); }; };
                E4ABABE42361A32900FA4345 /* PropertyCascade.h in Headers */ = {isa = PBXBuildFile; fileRef = E4ABABE22361A32900FA4345 /* PropertyCascade.h */; };
+               E4ABABF32368B95900FA4345 /* StyleBuilderState.h in Headers */ = {isa = PBXBuildFile; fileRef = E4ABABF22368B95800FA4345 /* StyleBuilderState.h */; };
+               E4ABABF52368C6EF00FA4345 /* CascadeLevel.h in Headers */ = {isa = PBXBuildFile; fileRef = E4ABABF42368C6EF00FA4345 /* CascadeLevel.h */; };
                E4AE7C1617D1BB950009FB31 /* ElementIterator.h in Headers */ = {isa = PBXBuildFile; fileRef = E4AE7C1517D1BB950009FB31 /* ElementIterator.h */; settings = {ATTRIBUTES = (Private, ); }; };
                E4AE7C1A17D232350009FB31 /* ElementAncestorIterator.h in Headers */ = {isa = PBXBuildFile; fileRef = E4AE7C1917D232350009FB31 /* ElementAncestorIterator.h */; settings = {ATTRIBUTES = (Private, ); }; };
                E4AFCFA50DAF29A300F5F55C /* UnitBezier.h in Headers */ = {isa = PBXBuildFile; fileRef = E4AFCFA40DAF29A300F5F55C /* UnitBezier.h */; };
                E4A8D21522578DA000A8463C /* EventRegion.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = EventRegion.cpp; sourceTree = "<group>"; };
                E4ABABE22361A32900FA4345 /* PropertyCascade.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PropertyCascade.h; sourceTree = "<group>"; };
                E4ABABE52361A34200FA4345 /* PropertyCascade.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = PropertyCascade.cpp; sourceTree = "<group>"; };
+               E4ABABF02368B91800FA4345 /* StyleBuilderState.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = StyleBuilderState.cpp; sourceTree = "<group>"; };
+               E4ABABF22368B95800FA4345 /* StyleBuilderState.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = StyleBuilderState.h; sourceTree = "<group>"; };
+               E4ABABF42368C6EF00FA4345 /* CascadeLevel.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CascadeLevel.h; sourceTree = "<group>"; };
                E4AE7C1517D1BB950009FB31 /* ElementIterator.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ElementIterator.h; sourceTree = "<group>"; };
                E4AE7C1917D232350009FB31 /* ElementAncestorIterator.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ElementAncestorIterator.h; sourceTree = "<group>"; };
                E4AFCFA40DAF29A300F5F55C /* UnitBezier.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = UnitBezier.h; sourceTree = "<group>"; };
                        children = (
                                E4A814D71C70E10500BF85AC /* AttributeChangeInvalidation.cpp */,
                                E4A814D91C70E10D00BF85AC /* AttributeChangeInvalidation.h */,
+                               E4ABABF42368C6EF00FA4345 /* CascadeLevel.h */,
                                E4A814D51C6DEE8D00BF85AC /* ClassChangeInvalidation.cpp */,
                                E4A814D31C6DEC4000BF85AC /* ClassChangeInvalidation.h */,
                                E4A814DD1C7338D100BF85AC /* IdChangeInvalidation.cpp */,
                                1C0106FF192594DF008A4201 /* InlineTextBoxStyle.h */,
                                E4ABABE52361A34200FA4345 /* PropertyCascade.cpp */,
                                E4ABABE22361A32900FA4345 /* PropertyCascade.h */,
+                               E4ABABF02368B91800FA4345 /* StyleBuilderState.cpp */,
+                               E4ABABF22368B95800FA4345 /* StyleBuilderState.h */,
                                E401E0A51C3C0CF700F34D10 /* StyleChange.cpp */,
                                E401E0A31C3C0B8300F34D10 /* StyleChange.h */,
                                E4D58EB617B4ED8900CBDCA8 /* StyleFontSizeFunctions.cpp */,
                                BE8EF045171C8FF9009B48C3 /* JSAudioTrackList.h in Headers */,
                                57D1352A2294AA3900827401 /* JSAuthenticationExtensionsClientInputs.h in Headers */,
                                57303C2F2009B7E100355965 /* JSAuthenticatorAssertionResponse.h in Headers */,
+                               E4ABABF32368B95900FA4345 /* StyleBuilderState.h in Headers */,
                                57303C222009AF0300355965 /* JSAuthenticatorAttestationResponse.h in Headers */,
                                57303BE120095D6100355965 /* JSAuthenticatorResponse.h in Headers */,
                                57DCED98214882160016B847 /* JSAuthenticatorTransport.h in Headers */,
                                BC3BE12B0E98092F00835588 /* PopupMenuStyle.h in Headers */,
                                37F567CE165358F400DDE92B /* PopupOpeningObserver.h in Headers */,
                                93F199DE08245E59001E9ABC /* Position.h in Headers */,
+                               E4ABABF52368C6EF00FA4345 /* CascadeLevel.h in Headers */,
                                9746AF2C14F4DDE6003E7A70 /* PositionCallback.h in Headers */,
                                9746AF3014F4DDE6003E7A70 /* PositionErrorCallback.h in Headers */,
                                37919C240B7D188600A56998 /* PositionIterator.h in Headers */,
index c85920b..633f2b5 100644 (file)
 
 namespace WebCore {
 
-CSSToStyleMap::CSSToStyleMap(StyleResolver* resolver)
-    : m_resolver(resolver)
+CSSToStyleMap::CSSToStyleMap(Style::BuilderState& builderState)
+    : m_builderState(builderState)
 {
 }
 
 RenderStyle* CSSToStyleMap::style() const
 {
-    return m_resolver->style();
-}
-
-const RenderStyle* CSSToStyleMap::rootElementStyle() const
-{
-    return m_resolver->rootElementStyle();
+    return &m_builderState.style();
 }
 
 bool CSSToStyleMap::useSVGZoomRules() const
 {
-    return m_resolver->useSVGZoomRules();
+    return m_builderState.useSVGZoomRules();
 }
 
 RefPtr<StyleImage> CSSToStyleMap::styleImage(CSSValue& value)
 {
-    return m_resolver->styleImage(value);
+    return m_builderState.createStyleImage(value);
 }
 
 void CSSToStyleMap::mapFillAttachment(CSSPropertyID propertyID, FillLayer& layer, const CSSValue& value)
@@ -214,7 +209,7 @@ void CSSToStyleMap::mapFillSize(CSSPropertyID propertyID, FillLayer& layer, cons
         break;
     default:
         ASSERT(fillSize.type == FillSizeType::Size);
-        if (!convertToLengthSize(primitiveValue, m_resolver->state().cssToLengthConversionData(), fillSize.size))
+        if (!convertToLengthSize(primitiveValue, m_builderState.cssToLengthConversionData(), fillSize.size))
             return;
         break;
     }
@@ -236,9 +231,9 @@ void CSSToStyleMap::mapFillXPosition(CSSPropertyID propertyID, FillLayer& layer,
     Length length;
     if (pair) {
         ASSERT_UNUSED(propertyID, propertyID == CSSPropertyBackgroundPositionX || propertyID == CSSPropertyWebkitMaskPositionX);
-        length = StyleBuilderConverter::convertLength(*m_resolver, *pair->second());
+        length = StyleBuilderConverter::convertLength(m_builderState, *pair->second());
     } else
-        length = StyleBuilderConverter::convertPositionComponentX(*m_resolver, value);
+        length = StyleBuilderConverter::convertPositionComponentX(m_builderState, value);
 
     layer.setXPosition(length);
     if (pair)
@@ -260,9 +255,9 @@ void CSSToStyleMap::mapFillYPosition(CSSPropertyID propertyID, FillLayer& layer,
     Length length;
     if (pair) {
         ASSERT_UNUSED(propertyID, propertyID == CSSPropertyBackgroundPositionY || propertyID == CSSPropertyWebkitMaskPositionY);
-        length = StyleBuilderConverter::convertLength(*m_resolver, *pair->second());
+        length = StyleBuilderConverter::convertLength(m_builderState, *pair->second());
     } else
-        length = StyleBuilderConverter::convertPositionComponentY(*m_resolver, value);
+        length = StyleBuilderConverter::convertPositionComponentY(m_builderState, value);
     
     layer.setYPosition(length);
     if (pair)
@@ -409,7 +404,7 @@ void CSSToStyleMap::mapAnimationName(Animation& layer, const CSSValue& value)
     if (primitiveValue.valueID() == CSSValueNone)
         layer.setIsNoneAnimation(true);
     else
-        layer.setName(primitiveValue.stringValue(), m_resolver->state().styleScopeOrdinal());
+        layer.setName(primitiveValue.stringValue(), m_builderState.styleScopeOrdinal());
 }
 
 void CSSToStyleMap::mapAnimationPlayState(Animation& layer, const CSSValue& value)
@@ -593,7 +588,7 @@ LengthBox CSSToStyleMap::mapNinePieceImageQuad(CSSValue& value)
         return LengthBox();
 
     // Get our zoom value.
-    CSSToLengthConversionData conversionData = useSVGZoomRules() ? m_resolver->state().cssToLengthConversionData().copyWithAdjustedZoom(1.0f) : m_resolver->state().cssToLengthConversionData();
+    CSSToLengthConversionData conversionData = useSVGZoomRules() ? m_builderState.cssToLengthConversionData().copyWithAdjustedZoom(1.0f) : m_builderState.cssToLengthConversionData();
 
     // Retrieve the primitive value.
     auto& borderWidths = downcast<CSSPrimitiveValue>(value);
index 4fb29a9..a1c4421 100644 (file)
@@ -34,14 +34,17 @@ class LengthBox;
 class NinePieceImage;
 class RenderStyle;
 class StyleImage;
-class StyleResolver;
+
+namespace Style {
+class BuilderState;
+}
 
 class CSSToStyleMap {
     WTF_MAKE_NONCOPYABLE(CSSToStyleMap);
     WTF_MAKE_FAST_ALLOCATED;
 
 public:
-    CSSToStyleMap(StyleResolver*);
+    CSSToStyleMap(Style::BuilderState&);
 
     void mapFillAttachment(CSSPropertyID, FillLayer&, const CSSValue&);
     void mapFillClip(CSSPropertyID, FillLayer&, const CSSValue&);
@@ -72,19 +75,12 @@ public:
     void mapNinePieceImageRepeat(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;
-    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.
     RefPtr<StyleImage> styleImage(CSSValue&);
 
-    StyleResolver* m_resolver;
+    // FIXME: This type can merge into BuilderState.
+    Style::BuilderState& m_builderState;
 };
 
 } // namespace WebCore
index f84b8b6..fe60dcf 100644 (file)
@@ -45,21 +45,21 @@ String CSSVariableReferenceValue::customCSSText() const
     return m_stringValue;
 }
 
-static bool resolveTokenRange(CSSParserTokenRange, Vector<CSSParserToken>&, Style::PropertyCascade&);
+static bool resolveTokenRange(CSSParserTokenRange, Vector<CSSParserToken>&, Style::BuilderState&);
 
-static bool resolveVariableFallback(CSSParserTokenRange range, Vector<CSSParserToken>& result, Style::PropertyCascade& cascade)
+static bool resolveVariableFallback(CSSParserTokenRange range, Vector<CSSParserToken>& result, Style::BuilderState& builderState)
 {
     if (range.atEnd())
         return false;
     ASSERT(range.peek().type() == CommaToken);
     range.consume();
-    return resolveTokenRange(range, result, cascade);
+    return resolveTokenRange(range, result, builderState);
 }
 
-static bool resolveVariableReference(CSSParserTokenRange range, Vector<CSSParserToken>& result, Style::PropertyCascade& cascade)
+static bool resolveVariableReference(CSSParserTokenRange range, Vector<CSSParserToken>& result, Style::BuilderState& builderState)
 {
-    auto& registeredProperties = cascade.styleResolver().document().getCSSRegisteredCustomPropertySet();
-    auto& style = *cascade.styleResolver().style();
+    auto& registeredProperties = builderState.document().getCSSRegisteredCustomPropertySet();
+    auto& style = builderState.style();
 
     range.consumeWhitespace();
     ASSERT(range.peek().type() == IdentToken);
@@ -67,11 +67,11 @@ static bool resolveVariableReference(CSSParserTokenRange range, Vector<CSSParser
     ASSERT(range.atEnd() || (range.peek().type() == CommaToken));
 
     // Apply this variable first, in case it is still unresolved
-    cascade.applyCustomProperty(variableName);
+    builderState.cascade().applyCustomProperty(variableName);
 
     // Apply fallback to detect cycles
     Vector<CSSParserToken> fallbackResult;
-    bool fallbackReturn = resolveVariableFallback(CSSParserTokenRange(range), fallbackResult, cascade);
+    bool fallbackReturn = resolveVariableFallback(CSSParserTokenRange(range), fallbackResult, builderState);
 
     auto* property = style.getCustomProperty(variableName);
 
@@ -93,24 +93,24 @@ static bool resolveVariableReference(CSSParserTokenRange range, Vector<CSSParser
     return true;
 }
 
-static bool resolveTokenRange(CSSParserTokenRange range, Vector<CSSParserToken>& result, Style::PropertyCascade& cascade)
+static bool resolveTokenRange(CSSParserTokenRange range, Vector<CSSParserToken>& result, Style::BuilderState& builderState)
 {
     bool success = true;
     while (!range.atEnd()) {
         if (range.peek().functionId() == CSSValueVar || range.peek().functionId() == CSSValueEnv)
-            success &= resolveVariableReference(range.consumeBlock(), result, cascade);
+            success &= resolveVariableReference(range.consumeBlock(), result, builderState);
         else
             result.append(range.consume());
     }
     return success;
 }
 
-RefPtr<CSSVariableData> CSSVariableReferenceValue::resolveVariableReferences(Style::PropertyCascade& cascade) const
+RefPtr<CSSVariableData> CSSVariableReferenceValue::resolveVariableReferences(Style::BuilderState& builderState) const
 {
     Vector<CSSParserToken> resolvedTokens;
     CSSParserTokenRange range = m_data->tokenRange();
 
-    if (!resolveTokenRange(range, resolvedTokens, cascade))
+    if (!resolveTokenRange(range, resolvedTokens, builderState))
         return nullptr;
 
     return CSSVariableData::create(resolvedTokens);
index 9a120c3..c56f3be 100644 (file)
@@ -42,7 +42,7 @@ namespace WebCore {
 class CSSParserTokenRange;
 
 namespace Style {
-class PropertyCascade;
+class BuilderState;
 }
 
 class CSSVariableReferenceValue : public CSSValue {
@@ -55,7 +55,7 @@ public:
     bool equals(const CSSVariableReferenceValue& other) const { return m_data.get() == other.m_data.get(); }
     String customCSSText() const;
 
-    RefPtr<CSSVariableData> resolveVariableReferences(Style::PropertyCascade&) const;
+    RefPtr<CSSVariableData> resolveVariableReferences(Style::BuilderState&) const;
 
 private:
     CSSVariableReferenceValue(Ref<CSSVariableData>&& data)
index 0df6aae..1e7a53b 100644 (file)
@@ -33,6 +33,7 @@
 #include "CSSTokenizer.h"
 #include "DOMCSSNamespace.h"
 #include "Document.h"
+#include "PropertyCascade.h"
 #include "StyleBuilderConverter.h"
 #include <wtf/text/WTFString.h>
 
@@ -51,7 +52,6 @@ ExceptionOr<void> DOMCSSRegisterCustomProperty::registerProperty(Document& docum
         // We need to initialize this so that we can successfully parse computationally dependent values (like em units).
         // We don't actually need the values to be accurate, since they will be rejected later anyway
         styleResolver.applyPropertyToStyle(CSSPropertyInvalid, nullptr, styleResolver.defaultStyleForElement());
-        styleResolver.updateFont();
 
         HashSet<CSSPropertyID> dependencies;
         CSSPropertyParser::collectParsedCustomPropertyValueDependencies(descriptor.syntax, false, dependencies, tokenizer.tokenRange(), strictCSSParserContext());
@@ -59,7 +59,9 @@ ExceptionOr<void> DOMCSSRegisterCustomProperty::registerProperty(Document& docum
         if (!dependencies.isEmpty())
             return Exception { SyntaxError, "The given initial value must be computationally independent." };
 
-        initialValue = CSSPropertyParser::parseTypedCustomPropertyValue(descriptor.name, descriptor.syntax, tokenizer.tokenRange(), styleResolver, strictCSSParserContext());
+        MatchResult matchResult;
+        Style::PropertyCascade dummyCascade(styleResolver, matchResult, { });
+        initialValue = CSSPropertyParser::parseTypedCustomPropertyValue(descriptor.name, descriptor.syntax, tokenizer.tokenRange(), dummyCascade.builderState(), strictCSSParserContext());
 
         if (!initialValue || !initialValue->isResolved())
             return Exception { SyntaxError, "The given initial value does not parse for the given syntax." };
index 8ee583e..64918ac 100644 (file)
 
 namespace WebCore {
 
-struct CSSRegisteredCustomProperty;
 class CSSValue;
-class StyleResolver;
 struct CSSRegisteredCustomProperty;
 
+namespace Style {
+class BuilderState;
+}
+
 class StyleBuilder {
 public:
-    static void applyProperty(CSSPropertyID, StyleResolver&, CSSValue&, bool isInitial, bool isInherit, const CSSRegisteredCustomProperty*);
+    static void applyProperty(CSSPropertyID, Style::BuilderState&, CSSValue&, bool isInitial, bool isInherit, const CSSRegisteredCustomProperty*);
 };
 
 } // namespace WebCore
index 089957d..bb5ca64 100644 (file)
@@ -51,7 +51,7 @@
 #include "RuntimeEnabledFeatures.h"
 #include "SVGURIReference.h"
 #include "Settings.h"
-#include "StyleResolver.h"
+#include "StyleBuilderState.h"
 #include "StyleScrollSnapPoints.h"
 #include "TabSize.h"
 #include "TouchAction.h"
@@ -63,107 +63,107 @@ namespace WebCore {
 // Note that we assume the CSS parser only allows valid CSSValue types.
 class StyleBuilderConverter {
 public:
-    static Length convertLength(const StyleResolver&, const CSSValue&);
-    static Length convertLengthOrAuto(const StyleResolver&, const CSSValue&);
-    static Length convertLengthSizing(const StyleResolver&, const CSSValue&);
-    static Length convertLengthMaxSizing(const StyleResolver&, const CSSValue&);
-    static TabSize convertTabSize(const StyleResolver&, const CSSValue&);
-    template<typename T> static T convertComputedLength(StyleResolver&, const CSSValue&);
-    template<typename T> static T convertLineWidth(StyleResolver&, const CSSValue&);
-    static float convertSpacing(StyleResolver&, const CSSValue&);
-    static LengthSize convertRadius(StyleResolver&, const CSSValue&);
-    static LengthPoint convertObjectPosition(StyleResolver&, const CSSValue&);
-    static OptionSet<TextDecoration> convertTextDecoration(StyleResolver&, const CSSValue&);
-    template<typename T> static T convertNumber(StyleResolver&, const CSSValue&);
-    template<typename T> static T convertNumberOrAuto(StyleResolver&, const CSSValue&);
-    static short convertWebkitHyphenateLimitLines(StyleResolver&, const CSSValue&);
-    template<CSSPropertyID> static NinePieceImage convertBorderImage(StyleResolver&, CSSValue&);
-    template<CSSPropertyID> static NinePieceImage convertBorderMask(StyleResolver&, CSSValue&);
-    template<CSSPropertyID> static RefPtr<StyleImage> convertStyleImage(StyleResolver&, CSSValue&);
-    static TransformOperations convertTransform(StyleResolver&, const CSSValue&);
+    static Length convertLength(const Style::BuilderState&, const CSSValue&);
+    static Length convertLengthOrAuto(const Style::BuilderState&, const CSSValue&);
+    static Length convertLengthSizing(const Style::BuilderState&, const CSSValue&);
+    static Length convertLengthMaxSizing(const Style::BuilderState&, const CSSValue&);
+    static TabSize convertTabSize(const Style::BuilderState&, const CSSValue&);
+    template<typename T> static T convertComputedLength(Style::BuilderState&, const CSSValue&);
+    template<typename T> static T convertLineWidth(Style::BuilderState&, const CSSValue&);
+    static float convertSpacing(Style::BuilderState&, const CSSValue&);
+    static LengthSize convertRadius(Style::BuilderState&, const CSSValue&);
+    static LengthPoint convertObjectPosition(Style::BuilderState&, const CSSValue&);
+    static OptionSet<TextDecoration> convertTextDecoration(Style::BuilderState&, const CSSValue&);
+    template<typename T> static T convertNumber(Style::BuilderState&, const CSSValue&);
+    template<typename T> static T convertNumberOrAuto(Style::BuilderState&, const CSSValue&);
+    static short convertWebkitHyphenateLimitLines(Style::BuilderState&, const CSSValue&);
+    template<CSSPropertyID> static NinePieceImage convertBorderImage(Style::BuilderState&, CSSValue&);
+    template<CSSPropertyID> static NinePieceImage convertBorderMask(Style::BuilderState&, CSSValue&);
+    template<CSSPropertyID> static RefPtr<StyleImage> convertStyleImage(Style::BuilderState&, CSSValue&);
+    static TransformOperations convertTransform(Style::BuilderState&, const CSSValue&);
 #if ENABLE(DARK_MODE_CSS)
-    static StyleColorScheme convertColorScheme(StyleResolver&, const CSSValue&);
+    static StyleColorScheme convertColorScheme(Style::BuilderState&, const CSSValue&);
 #endif
-    static String convertString(StyleResolver&, const CSSValue&);
-    static String convertStringOrAuto(StyleResolver&, const CSSValue&);
-    static String convertStringOrNone(StyleResolver&, const CSSValue&);
-    static OptionSet<TextEmphasisPosition> convertTextEmphasisPosition(StyleResolver&, const CSSValue&);
-    static TextAlignMode convertTextAlign(StyleResolver&, const CSSValue&);
-    static RefPtr<ClipPathOperation> convertClipPath(StyleResolver&, const CSSValue&);
-    static Resize convertResize(StyleResolver&, const CSSValue&);
-    static int convertMarqueeRepetition(StyleResolver&, const CSSValue&);
-    static int convertMarqueeSpeed(StyleResolver&, const CSSValue&);
-    static Ref<QuotesData> convertQuotes(StyleResolver&, const CSSValue&);
-    static TextUnderlinePosition convertTextUnderlinePosition(StyleResolver&, const CSSValue&);
-    static TextUnderlineOffset convertTextUnderlineOffset(StyleResolver&, const CSSValue&);
-    static TextDecorationThickness convertTextDecorationThickness(StyleResolver&, const CSSValue&);
-    static RefPtr<StyleReflection> convertReflection(StyleResolver&, const CSSValue&);
-    static IntSize convertInitialLetter(StyleResolver&, const CSSValue&);
-    static float convertTextStrokeWidth(StyleResolver&, const CSSValue&);
-    static OptionSet<LineBoxContain> convertLineBoxContain(StyleResolver&, const CSSValue&);
-    static OptionSet<TextDecorationSkip> convertTextDecorationSkip(StyleResolver&, const CSSValue&);
-    static RefPtr<ShapeValue> convertShapeValue(StyleResolver&, CSSValue&);
+    static String convertString(Style::BuilderState&, const CSSValue&);
+    static String convertStringOrAuto(Style::BuilderState&, const CSSValue&);
+    static String convertStringOrNone(Style::BuilderState&, const CSSValue&);
+    static OptionSet<TextEmphasisPosition> convertTextEmphasisPosition(Style::BuilderState&, const CSSValue&);
+    static TextAlignMode convertTextAlign(Style::BuilderState&, const CSSValue&);
+    static RefPtr<ClipPathOperation> convertClipPath(Style::BuilderState&, const CSSValue&);
+    static Resize convertResize(Style::BuilderState&, const CSSValue&);
+    static int convertMarqueeRepetition(Style::BuilderState&, const CSSValue&);
+    static int convertMarqueeSpeed(Style::BuilderState&, const CSSValue&);
+    static Ref<QuotesData> convertQuotes(Style::BuilderState&, const CSSValue&);
+    static TextUnderlinePosition convertTextUnderlinePosition(Style::BuilderState&, const CSSValue&);
+    static TextUnderlineOffset convertTextUnderlineOffset(Style::BuilderState&, const CSSValue&);
+    static TextDecorationThickness convertTextDecorationThickness(Style::BuilderState&, const CSSValue&);
+    static RefPtr<StyleReflection> convertReflection(Style::BuilderState&, const CSSValue&);
+    static IntSize convertInitialLetter(Style::BuilderState&, const CSSValue&);
+    static float convertTextStrokeWidth(Style::BuilderState&, const CSSValue&);
+    static OptionSet<LineBoxContain> convertLineBoxContain(Style::BuilderState&, const CSSValue&);
+    static OptionSet<TextDecorationSkip> convertTextDecorationSkip(Style::BuilderState&, const CSSValue&);
+    static RefPtr<ShapeValue> convertShapeValue(Style::BuilderState&, CSSValue&);
 #if ENABLE(CSS_SCROLL_SNAP)
-    static ScrollSnapType convertScrollSnapType(StyleResolver&, const CSSValue&);
-    static ScrollSnapAlign convertScrollSnapAlign(StyleResolver&, const CSSValue&);
+    static ScrollSnapType convertScrollSnapType(Style::BuilderState&, const CSSValue&);
+    static ScrollSnapAlign convertScrollSnapAlign(Style::BuilderState&, const CSSValue&);
 #endif
-    static GridTrackSize convertGridTrackSize(StyleResolver&, const CSSValue&);
-    static Vector<GridTrackSize> convertGridTrackSizeList(StyleResolver&, const CSSValue&);
-    static Optional<GridPosition> convertGridPosition(StyleResolver&, const CSSValue&);
-    static GridAutoFlow convertGridAutoFlow(StyleResolver&, const CSSValue&);
-    static Optional<Length> convertWordSpacing(StyleResolver&, const CSSValue&);
-    static Optional<float> convertPerspective(StyleResolver&, const CSSValue&);
-    static Optional<Length> convertMarqueeIncrement(StyleResolver&, const CSSValue&);
-    static Optional<FilterOperations> convertFilterOperations(StyleResolver&, const CSSValue&);
+    static GridTrackSize convertGridTrackSize(Style::BuilderState&, const CSSValue&);
+    static Vector<GridTrackSize> convertGridTrackSizeList(Style::BuilderState&, const CSSValue&);
+    static Optional<GridPosition> convertGridPosition(Style::BuilderState&, const CSSValue&);
+    static GridAutoFlow convertGridAutoFlow(Style::BuilderState&, const CSSValue&);
+    static Optional<Length> convertWordSpacing(Style::BuilderState&, const CSSValue&);
+    static Optional<float> convertPerspective(Style::BuilderState&, const CSSValue&);
+    static Optional<Length> convertMarqueeIncrement(Style::BuilderState&, const CSSValue&);
+    static Optional<FilterOperations> convertFilterOperations(Style::BuilderState&, const CSSValue&);
 #if PLATFORM(IOS_FAMILY)
-    static bool convertTouchCallout(StyleResolver&, const CSSValue&);
+    static bool convertTouchCallout(Style::BuilderState&, const CSSValue&);
 #endif
 #if ENABLE(TOUCH_EVENTS)
-    static Color convertTapHighlightColor(StyleResolver&, const CSSValue&);
+    static Color convertTapHighlightColor(Style::BuilderState&, const CSSValue&);
 #endif
 #if ENABLE(POINTER_EVENTS)
-    static OptionSet<TouchAction> convertTouchAction(StyleResolver&, const CSSValue&);
+    static OptionSet<TouchAction> convertTouchAction(Style::BuilderState&, const CSSValue&);
 #endif
 #if ENABLE(OVERFLOW_SCROLLING_TOUCH)
-    static bool convertOverflowScrolling(StyleResolver&, const CSSValue&);
+    static bool convertOverflowScrolling(Style::BuilderState&, const CSSValue&);
 #endif
-    static FontFeatureSettings convertFontFeatureSettings(StyleResolver&, const CSSValue&);
+    static FontFeatureSettings convertFontFeatureSettings(Style::BuilderState&, const CSSValue&);
     static FontSelectionValue convertFontWeightFromValue(const CSSValue&);
     static FontSelectionValue convertFontStretchFromValue(const CSSValue&);
     static Optional<FontSelectionValue> convertFontStyleFromValue(const CSSValue&);
-    static FontSelectionValue convertFontWeight(StyleResolver&, const CSSValue&);
-    static FontSelectionValue convertFontStretch(StyleResolver&, const CSSValue&);
-    static FontSelectionValue convertFontStyle(StyleResolver&, const CSSValue&);
+    static FontSelectionValue convertFontWeight(Style::BuilderState&, const CSSValue&);
+    static FontSelectionValue convertFontStretch(Style::BuilderState&, const CSSValue&);
+    static FontSelectionValue convertFontStyle(Style::BuilderState&, const CSSValue&);
 #if ENABLE(VARIATION_FONTS)
-    static FontVariationSettings convertFontVariationSettings(StyleResolver&, const CSSValue&);
+    static FontVariationSettings convertFontVariationSettings(Style::BuilderState&, const CSSValue&);
 #endif
-    static SVGLengthValue convertSVGLengthValue(StyleResolver&, const CSSValue&);
-    static Vector<SVGLengthValue> convertSVGLengthVector(StyleResolver&, const CSSValue&);
-    static Vector<SVGLengthValue> convertStrokeDashArray(StyleResolver&, const CSSValue&);
-    static PaintOrder convertPaintOrder(StyleResolver&, const CSSValue&);
-    static float convertOpacity(StyleResolver&, const CSSValue&);
-    static String convertSVGURIReference(StyleResolver&, const CSSValue&);
-    static Color convertSVGColor(StyleResolver&, const CSSValue&);
-    static StyleSelfAlignmentData convertSelfOrDefaultAlignmentData(StyleResolver&, const CSSValue&);
-    static StyleContentAlignmentData convertContentAlignmentData(StyleResolver&, const CSSValue&);
-    static GlyphOrientation convertGlyphOrientation(StyleResolver&, const CSSValue&);
-    static GlyphOrientation convertGlyphOrientationOrAuto(StyleResolver&, const CSSValue&);
-    static Optional<Length> convertLineHeight(StyleResolver&, const CSSValue&, float multiplier = 1.f);
-    static FontSynthesis convertFontSynthesis(StyleResolver&, const CSSValue&);
+    static SVGLengthValue convertSVGLengthValue(Style::BuilderState&, const CSSValue&);
+    static Vector<SVGLengthValue> convertSVGLengthVector(Style::BuilderState&, const CSSValue&);
+    static Vector<SVGLengthValue> convertStrokeDashArray(Style::BuilderState&, const CSSValue&);
+    static PaintOrder convertPaintOrder(Style::BuilderState&, const CSSValue&);
+    static float convertOpacity(Style::BuilderState&, const CSSValue&);
+    static String convertSVGURIReference(Style::BuilderState&, const CSSValue&);
+    static Color convertSVGColor(Style::BuilderState&, const CSSValue&);
+    static StyleSelfAlignmentData convertSelfOrDefaultAlignmentData(Style::BuilderState&, const CSSValue&);
+    static StyleContentAlignmentData convertContentAlignmentData(Style::BuilderState&, const CSSValue&);
+    static GlyphOrientation convertGlyphOrientation(Style::BuilderState&, const CSSValue&);
+    static GlyphOrientation convertGlyphOrientationOrAuto(Style::BuilderState&, const CSSValue&);
+    static Optional<Length> convertLineHeight(Style::BuilderState&, const CSSValue&, float multiplier = 1.f);
+    static FontSynthesis convertFontSynthesis(Style::BuilderState&, const CSSValue&);
     
-    static BreakBetween convertPageBreakBetween(StyleResolver&, const CSSValue&);
-    static BreakInside convertPageBreakInside(StyleResolver&, const CSSValue&);
-    static BreakBetween convertColumnBreakBetween(StyleResolver&, const CSSValue&);
-    static BreakInside convertColumnBreakInside(StyleResolver&, const CSSValue&);
+    static BreakBetween convertPageBreakBetween(Style::BuilderState&, const CSSValue&);
+    static BreakInside convertPageBreakInside(Style::BuilderState&, const CSSValue&);
+    static BreakBetween convertColumnBreakBetween(Style::BuilderState&, const CSSValue&);
+    static BreakInside convertColumnBreakInside(Style::BuilderState&, const CSSValue&);
 
-    static OptionSet<HangingPunctuation> convertHangingPunctuation(StyleResolver&, const CSSValue&);
+    static OptionSet<HangingPunctuation> convertHangingPunctuation(Style::BuilderState&, const CSSValue&);
 
-    static OptionSet<SpeakAs> convertSpeakAs(StyleResolver&, const CSSValue&);
+    static OptionSet<SpeakAs> convertSpeakAs(Style::BuilderState&, const CSSValue&);
 
-    static Length convertPositionComponentX(StyleResolver&, const CSSValue&);
-    static Length convertPositionComponentY(StyleResolver&, const CSSValue&);
+    static Length convertPositionComponentX(Style::BuilderState&, const CSSValue&);
+    static Length convertPositionComponentY(Style::BuilderState&, const CSSValue&);
 
-    static GapLength convertGapLength(StyleResolver&, const CSSValue&);
+    static GapLength convertGapLength(Style::BuilderState&, const CSSValue&);
     
 private:
     friend class StyleBuilderCustom;
@@ -172,7 +172,7 @@ private:
     static OptionSet<TextEmphasisPosition> valueToEmphasisPosition(const CSSPrimitiveValue&);
     static OptionSet<TextDecorationSkip> valueToDecorationSkip(const CSSPrimitiveValue&);
 #if ENABLE(CSS_SCROLL_SNAP)
-    static Length parseSnapCoordinate(StyleResolver&, const CSSValue&);
+    static Length parseSnapCoordinate(Style::BuilderState&, const CSSValue&);
 #endif
 
 #if ENABLE(DARK_MODE_CSS)
@@ -180,23 +180,23 @@ private:
 #endif
 
     static Length convertTo100PercentMinusLength(const Length&);
-    template<CSSValueID, CSSValueID> static Length convertPositionComponent(StyleResolver&, const CSSPrimitiveValue&);
+    template<CSSValueID, CSSValueID> static Length convertPositionComponent(Style::BuilderState&, const CSSPrimitiveValue&);
 
-    static GridLength createGridTrackBreadth(const CSSPrimitiveValue&, StyleResolver&);
-    static GridTrackSize createGridTrackSize(const CSSValue&, StyleResolver&);
+    static GridLength createGridTrackBreadth(const CSSPrimitiveValue&, Style::BuilderState&);
+    static GridTrackSize createGridTrackSize(const CSSValue&, Style::BuilderState&);
     struct TracksData;
-    static bool createGridTrackList(const CSSValue&, TracksData&, StyleResolver&);
+    static bool createGridTrackList(const CSSValue&, TracksData&, Style::BuilderState&);
     static bool createGridPosition(const CSSValue&, GridPosition&);
     static void createImplicitNamedGridLinesFromGridArea(const NamedGridAreaMap&, NamedGridLinesMap&, GridTrackSizingDirection);
-    static CSSToLengthConversionData csstoLengthConversionDataWithTextZoomFactor(StyleResolver&);
+    static CSSToLengthConversionData csstoLengthConversionDataWithTextZoomFactor(Style::BuilderState&);
 };
 
-inline Length StyleBuilderConverter::convertLength(const StyleResolver& styleResolver, const CSSValue& value)
+inline Length StyleBuilderConverter::convertLength(const Style::BuilderState& builderState, const CSSValue& value)
 {
     auto& primitiveValue = downcast<CSSPrimitiveValue>(value);
-    CSSToLengthConversionData conversionData = styleResolver.useSVGZoomRulesForLength() ?
-        styleResolver.state().cssToLengthConversionData().copyWithAdjustedZoom(1.0f)
-        : styleResolver.state().cssToLengthConversionData();
+    CSSToLengthConversionData conversionData = builderState.useSVGZoomRulesForLength() ?
+        builderState.cssToLengthConversionData().copyWithAdjustedZoom(1.0f)
+        : builderState.cssToLengthConversionData();
 
     if (primitiveValue.isLength()) {
         Length length = primitiveValue.computeLength<Length>(conversionData);
@@ -214,19 +214,19 @@ inline Length StyleBuilderConverter::convertLength(const StyleResolver& styleRes
     return Length(0, Fixed);
 }
 
-inline Length StyleBuilderConverter::convertLengthOrAuto(const StyleResolver& styleResolver, const CSSValue& value)
+inline Length StyleBuilderConverter::convertLengthOrAuto(const Style::BuilderState& builderState, const CSSValue& value)
 {
     if (downcast<CSSPrimitiveValue>(value).valueID() == CSSValueAuto)
         return Length(Auto);
-    return convertLength(styleResolver, value);
+    return convertLength(builderState, value);
 }
 
-inline Length StyleBuilderConverter::convertLengthSizing(const StyleResolver& styleResolver, const CSSValue& value)
+inline Length StyleBuilderConverter::convertLengthSizing(const Style::BuilderState& builderState, const CSSValue& value)
 {
     auto& primitiveValue = downcast<CSSPrimitiveValue>(value);
     switch (primitiveValue.valueID()) {
     case CSSValueInvalid:
-        return convertLength(styleResolver, value);
+        return convertLength(builderState, value);
     case CSSValueIntrinsic:
         return Length(Intrinsic);
     case CSSValueMinIntrinsic:
@@ -250,29 +250,29 @@ inline Length StyleBuilderConverter::convertLengthSizing(const StyleResolver& st
     }
 }
 
-inline Length StyleBuilderConverter::convertLengthMaxSizing(const StyleResolver& styleResolver, const CSSValue& value)
+inline Length StyleBuilderConverter::convertLengthMaxSizing(const Style::BuilderState& builderState, const CSSValue& value)
 {
     if (downcast<CSSPrimitiveValue>(value).valueID() == CSSValueNone)
         return Length(Undefined);
-    return convertLengthSizing(styleResolver, value);
+    return convertLengthSizing(builderState, value);
 }
 
-inline TabSize StyleBuilderConverter::convertTabSize(const StyleResolver& styleResolver, const CSSValue& value)
+inline TabSize StyleBuilderConverter::convertTabSize(const Style::BuilderState& builderState, const CSSValue& value)
 {
     auto& primitiveValue = downcast<CSSPrimitiveValue>(value);
     if (primitiveValue.isNumber())
         return TabSize(primitiveValue.floatValue(), SpaceValueType);
-    return TabSize(primitiveValue.computeLength<float>(styleResolver.state().cssToLengthConversionData()), LengthValueType);
+    return TabSize(primitiveValue.computeLength<float>(builderState.cssToLengthConversionData()), LengthValueType);
 }
 
 template<typename T>
-inline T StyleBuilderConverter::convertComputedLength(StyleResolver& styleResolver, const CSSValue& value)
+inline T StyleBuilderConverter::convertComputedLength(Style::BuilderState& builderState, const CSSValue& value)
 {
-    return downcast<CSSPrimitiveValue>(value).computeLength<T>(styleResolver.state().cssToLengthConversionData());
+    return downcast<CSSPrimitiveValue>(value).computeLength<T>(builderState.cssToLengthConversionData());
 }
 
 template<typename T>
-inline T StyleBuilderConverter::convertLineWidth(StyleResolver& styleResolver, const CSSValue& value)
+inline T StyleBuilderConverter::convertLineWidth(Style::BuilderState& builderState, const CSSValue& value)
 {
     auto& primitiveValue = downcast<CSSPrimitiveValue>(value);
     switch (primitiveValue.valueID()) {
@@ -285,16 +285,16 @@ inline T StyleBuilderConverter::convertLineWidth(StyleResolver& styleResolver, c
     case CSSValueInvalid: {
         // Any original result that was >= 1 should not be allowed to fall below 1.
         // This keeps border lines from vanishing.
-        T result = convertComputedLength<T>(styleResolver, value);
-        if (styleResolver.state().style()->effectiveZoom() < 1.0f && result < 1.0) {
-            T originalLength = primitiveValue.computeLength<T>(styleResolver.state().cssToLengthConversionData().copyWithAdjustedZoom(1.0));
+        T result = convertComputedLength<T>(builderState, value);
+        if (builderState.style().effectiveZoom() < 1.0f && result < 1.0) {
+            T originalLength = primitiveValue.computeLength<T>(builderState.cssToLengthConversionData().copyWithAdjustedZoom(1.0));
             if (originalLength >= 1.0)
                 return 1;
         }
-        float minimumLineWidth = 1 / styleResolver.document().deviceScaleFactor();
+        float minimumLineWidth = 1 / builderState.document().deviceScaleFactor();
         if (result > 0 && result < minimumLineWidth)
             return minimumLineWidth;
-        return floorToDevicePixel(result, styleResolver.document().deviceScaleFactor());
+        return floorToDevicePixel(result, builderState.document().deviceScaleFactor());
     }
     default:
         ASSERT_NOT_REACHED();
@@ -302,15 +302,15 @@ inline T StyleBuilderConverter::convertLineWidth(StyleResolver& styleResolver, c
     }
 }
 
-inline float StyleBuilderConverter::convertSpacing(StyleResolver& styleResolver, const CSSValue& value)
+inline float StyleBuilderConverter::convertSpacing(Style::BuilderState& builderState, const CSSValue& value)
 {
     auto& primitiveValue = downcast<CSSPrimitiveValue>(value);
     if (primitiveValue.valueID() == CSSValueNormal)
         return 0.f;
 
-    CSSToLengthConversionData conversionData = styleResolver.useSVGZoomRulesForLength() ?
-        styleResolver.state().cssToLengthConversionData().copyWithAdjustedZoom(1.0f)
-        : styleResolver.state().cssToLengthConversionData();
+    CSSToLengthConversionData conversionData = builderState.useSVGZoomRulesForLength() ?
+        builderState.cssToLengthConversionData().copyWithAdjustedZoom(1.0f)
+        : builderState.cssToLengthConversionData();
     return primitiveValue.computeLength<float>(conversionData);
 }
 
@@ -323,13 +323,13 @@ inline Length StyleBuilderConverter::convertToRadiusLength(CSSToLengthConversion
     return value.computeLength<Length>(conversionData);
 }
 
-inline LengthSize StyleBuilderConverter::convertRadius(StyleResolver& styleResolver, const CSSValue& value)
+inline LengthSize StyleBuilderConverter::convertRadius(Style::BuilderState& builderState, const CSSValue& value)
 {
     auto* pair = downcast<CSSPrimitiveValue>(value).pairValue();
     if (!pair || !pair->first() || !pair->second())
         return { { 0, Fixed }, { 0, Fixed } };
 
-    CSSToLengthConversionData conversionData = styleResolver.state().cssToLengthConversionData();
+    CSSToLengthConversionData conversionData = builderState.cssToLengthConversionData();
     LengthSize radius { convertToRadiusLength(conversionData, *pair->first()), convertToRadiusLength(conversionData, *pair->second()) };
 
     ASSERT(!radius.width.isNegative());
@@ -354,18 +354,18 @@ inline Length StyleBuilderConverter::convertTo100PercentMinusLength(const Length
     return Length(CalculationValue::create(WTFMove(op), ValueRangeAll));
 }
 
-inline Length StyleBuilderConverter::convertPositionComponentX(StyleResolver& styleResolver, const CSSValue& value)
+inline Length StyleBuilderConverter::convertPositionComponentX(Style::BuilderState& builderState, const CSSValue& value)
 {
-    return convertPositionComponent<CSSValueLeft, CSSValueRight>(styleResolver, downcast<CSSPrimitiveValue>(value));
+    return convertPositionComponent<CSSValueLeft, CSSValueRight>(builderState, downcast<CSSPrimitiveValue>(value));
 }
 
-inline Length StyleBuilderConverter::convertPositionComponentY(StyleResolver& styleResolver, const CSSValue& value)
+inline Length StyleBuilderConverter::convertPositionComponentY(Style::BuilderState& builderState, const CSSValue& value)
 {
-    return convertPositionComponent<CSSValueTop, CSSValueBottom>(styleResolver, downcast<CSSPrimitiveValue>(value));
+    return convertPositionComponent<CSSValueTop, CSSValueBottom>(builderState, downcast<CSSPrimitiveValue>(value));
 }
 
 template<CSSValueID cssValueFor0, CSSValueID cssValueFor100>
-inline Length StyleBuilderConverter::convertPositionComponent(StyleResolver& styleResolver, const CSSPrimitiveValue& value)
+inline Length StyleBuilderConverter::convertPositionComponent(Style::BuilderState& builderState, const CSSPrimitiveValue& value)
 {
     Length length;
 
@@ -392,7 +392,7 @@ inline Length StyleBuilderConverter::convertPositionComponent(StyleResolver& sty
         }
     }
         
-    length = convertLength(styleResolver, *lengthValue);
+    length = convertLength(builderState, *lengthValue);
 
     if (relativeToTrailingEdge)
         length = convertTo100PercentMinusLength(length);
@@ -400,20 +400,20 @@ inline Length StyleBuilderConverter::convertPositionComponent(StyleResolver& sty
     return length;
 }
 
-inline LengthPoint StyleBuilderConverter::convertObjectPosition(StyleResolver& styleResolver, const CSSValue& value)
+inline LengthPoint StyleBuilderConverter::convertObjectPosition(Style::BuilderState& builderState, const CSSValue& value)
 {
     auto& primitiveValue = downcast<CSSPrimitiveValue>(value);
     Pair* pair = primitiveValue.pairValue();
     if (!pair || !pair->first() || !pair->second())
         return RenderStyle::initialObjectPosition();
 
-    Length lengthX = convertPositionComponent<CSSValueLeft, CSSValueRight>(styleResolver, *pair->first());
-    Length lengthY = convertPositionComponent<CSSValueTop, CSSValueBottom>(styleResolver, *pair->second());
+    Length lengthX = convertPositionComponent<CSSValueLeft, CSSValueRight>(builderState, *pair->first());
+    Length lengthY = convertPositionComponent<CSSValueTop, CSSValueBottom>(builderState, *pair->second());
 
     return LengthPoint(lengthX, lengthY);
 }
 
-inline OptionSet<TextDecoration> StyleBuilderConverter::convertTextDecoration(StyleResolver&, const CSSValue& value)
+inline OptionSet<TextDecoration> StyleBuilderConverter::convertTextDecoration(Style::BuilderState&, const CSSValue& value)
 {
     auto result = RenderStyle::initialTextDecoration();
     if (is<CSSValueList>(value)) {
@@ -424,20 +424,20 @@ inline OptionSet<TextDecoration> StyleBuilderConverter::convertTextDecoration(St
 }
 
 template<typename T>
-inline T StyleBuilderConverter::convertNumber(StyleResolver&, const CSSValue& value)
+inline T StyleBuilderConverter::convertNumber(Style::BuilderState&, const CSSValue& value)
 {
     return downcast<CSSPrimitiveValue>(value).value<T>(CSSPrimitiveValue::CSS_NUMBER);
 }
 
 template<typename T>
-inline T StyleBuilderConverter::convertNumberOrAuto(StyleResolver& styleResolver, const CSSValue& value)
+inline T StyleBuilderConverter::convertNumberOrAuto(Style::BuilderState& builderState, const CSSValue& value)
 {
     if (downcast<CSSPrimitiveValue>(value).valueID() == CSSValueAuto)
         return -1;
-    return convertNumber<T>(styleResolver, value);
+    return convertNumber<T>(builderState, value);
 }
 
-inline short StyleBuilderConverter::convertWebkitHyphenateLimitLines(StyleResolver&, const CSSValue& value)
+inline short StyleBuilderConverter::convertWebkitHyphenateLimitLines(Style::BuilderState&, const CSSValue& value)
 {
     auto& primitiveValue = downcast<CSSPrimitiveValue>(value);
     if (primitiveValue.valueID() == CSSValueNoLimit)
@@ -446,31 +446,31 @@ inline short StyleBuilderConverter::convertWebkitHyphenateLimitLines(StyleResolv
 }
 
 template<CSSPropertyID property>
-inline NinePieceImage StyleBuilderConverter::convertBorderImage(StyleResolver& styleResolver, CSSValue& value)
+inline NinePieceImage StyleBuilderConverter::convertBorderImage(Style::BuilderState& builderState, CSSValue& value)
 {
     NinePieceImage image;
-    styleResolver.styleMap()->mapNinePieceImage(property, &value, image);
+    builderState.styleMap().mapNinePieceImage(property, &value, image);
     return image;
 }
 
 template<CSSPropertyID property>
-inline NinePieceImage StyleBuilderConverter::convertBorderMask(StyleResolver& styleResolver, CSSValue& value)
+inline NinePieceImage StyleBuilderConverter::convertBorderMask(Style::BuilderState& builderState, CSSValue& value)
 {
     NinePieceImage image(NinePieceImage::Type::Mask);
-    styleResolver.styleMap()->mapNinePieceImage(property, &value, image);
+    builderState.styleMap().mapNinePieceImage(property, &value, image);
     return image;
 }
 
 template<CSSPropertyID>
-inline RefPtr<StyleImage> StyleBuilderConverter::convertStyleImage(StyleResolver& styleResolver, CSSValue& value)
+inline RefPtr<StyleImage> StyleBuilderConverter::convertStyleImage(Style::BuilderState& builderState, CSSValue& value)
 {
-    return styleResolver.styleImage(value);
+    return builderState.createStyleImage(value);
 }
 
-inline TransformOperations StyleBuilderConverter::convertTransform(StyleResolver& styleResolver, const CSSValue& value)
+inline TransformOperations StyleBuilderConverter::convertTransform(Style::BuilderState& builderState, const CSSValue& value)
 {
     TransformOperations operations;
-    transformsForValue(value, styleResolver.state().cssToLengthConversionData(), operations);
+    transformsForValue(value, builderState.cssToLengthConversionData(), operations);
     return operations;
 }
 
@@ -498,7 +498,7 @@ inline void StyleBuilderConverter::updateColorScheme(const CSSPrimitiveValue& pr
     }
 }
 
-inline StyleColorScheme StyleBuilderConverter::convertColorScheme(StyleResolver&, const CSSValue& value)
+inline StyleColorScheme StyleBuilderConverter::convertColorScheme(Style::BuilderState&, const CSSValue& value)
 {
     StyleColorScheme colorScheme;
 
@@ -516,23 +516,23 @@ inline StyleColorScheme StyleBuilderConverter::convertColorScheme(StyleResolver&
 }
 #endif
 
-inline String StyleBuilderConverter::convertString(StyleResolver&, const CSSValue& value)
+inline String StyleBuilderConverter::convertString(Style::BuilderState&, const CSSValue& value)
 {
     return downcast<CSSPrimitiveValue>(value).stringValue();
 }
 
-inline String StyleBuilderConverter::convertStringOrAuto(StyleResolver& styleResolver, const CSSValue& value)
+inline String StyleBuilderConverter::convertStringOrAuto(Style::BuilderState& builderState, const CSSValue& value)
 {
     if (downcast<CSSPrimitiveValue>(value).valueID() == CSSValueAuto)
         return nullAtom();
-    return convertString(styleResolver, value);
+    return convertString(builderState, value);
 }
 
-inline String StyleBuilderConverter::convertStringOrNone(StyleResolver& styleResolver, const CSSValue& value)
+inline String StyleBuilderConverter::convertStringOrNone(Style::BuilderState& builderState, const CSSValue& value)
 {
     if (downcast<CSSPrimitiveValue>(value).valueID() == CSSValueNone)
         return nullAtom();
-    return convertString(styleResolver, value);
+    return convertString(builderState, value);
 }
 
 inline OptionSet<TextEmphasisPosition> StyleBuilderConverter::valueToEmphasisPosition(const CSSPrimitiveValue& primitiveValue)
@@ -556,7 +556,7 @@ inline OptionSet<TextEmphasisPosition> StyleBuilderConverter::valueToEmphasisPos
     return RenderStyle::initialTextEmphasisPosition();
 }
 
-inline OptionSet<TextEmphasisPosition> StyleBuilderConverter::convertTextEmphasisPosition(StyleResolver&, const CSSValue& value)
+inline OptionSet<TextEmphasisPosition> StyleBuilderConverter::convertTextEmphasisPosition(Style::BuilderState&, const CSSValue& value)
 {
     if (is<CSSPrimitiveValue>(value))
         return valueToEmphasisPosition(downcast<CSSPrimitiveValue>(value));
@@ -567,7 +567,7 @@ inline OptionSet<TextEmphasisPosition> StyleBuilderConverter::convertTextEmphasi
     return position;
 }
 
-inline TextAlignMode StyleBuilderConverter::convertTextAlign(StyleResolver& styleResolver, const CSSValue& value)
+inline TextAlignMode StyleBuilderConverter::convertTextAlign(Style::BuilderState& builderState, const CSSValue& value)
 {
     auto& primitiveValue = downcast<CSSPrimitiveValue>(value);
     ASSERT(primitiveValue.isValueID());
@@ -575,21 +575,21 @@ inline TextAlignMode StyleBuilderConverter::convertTextAlign(StyleResolver& styl
     if (primitiveValue.valueID() != CSSValueWebkitMatchParent)
         return primitiveValue;
 
-    auto* parentStyle = styleResolver.parentStyle();
-    if (parentStyle->textAlign() == TextAlignMode::Start)
-        return parentStyle->isLeftToRightDirection() ? TextAlignMode::Left : TextAlignMode::Right;
-    if (parentStyle->textAlign() == TextAlignMode::End)
-        return parentStyle->isLeftToRightDirection() ? TextAlignMode::Right : TextAlignMode::Left;
-    return parentStyle->textAlign();
+    auto& parentStyle = builderState.parentStyle();
+    if (parentStyle.textAlign() == TextAlignMode::Start)
+        return parentStyle.isLeftToRightDirection() ? TextAlignMode::Left : TextAlignMode::Right;
+    if (parentStyle.textAlign() == TextAlignMode::End)
+        return parentStyle.isLeftToRightDirection() ? TextAlignMode::Right : TextAlignMode::Left;
+    return parentStyle.textAlign();
 }
 
-inline RefPtr<ClipPathOperation> StyleBuilderConverter::convertClipPath(StyleResolver& styleResolver, const CSSValue& value)
+inline RefPtr<ClipPathOperation> StyleBuilderConverter::convertClipPath(Style::BuilderState& builderState, const CSSValue& value)
 {
     if (is<CSSPrimitiveValue>(value)) {
         auto& primitiveValue = downcast<CSSPrimitiveValue>(value);
         if (primitiveValue.primitiveType() == CSSPrimitiveValue::CSS_URI) {
             String cssURLValue = primitiveValue.stringValue();
-            String fragment = SVGURIReference::fragmentIdentifierFromIRIString(cssURLValue, styleResolver.document());
+            String fragment = SVGURIReference::fragmentIdentifierFromIRIString(cssURLValue, builderState.document());
             // FIXME: It doesn't work with external SVG references (see https://bugs.webkit.org/show_bug.cgi?id=126133)
             return ReferenceClipPathOperation::create(cssURLValue, fragment);
         }
@@ -604,7 +604,7 @@ inline RefPtr<ClipPathOperation> StyleBuilderConverter::convertClipPath(StyleRes
         auto& primitiveValue = downcast<CSSPrimitiveValue>(currentValue.get());
         if (primitiveValue.isShape()) {
             ASSERT(!operation);
-            operation = ShapeClipPathOperation::create(basicShapeForValue(styleResolver.state().cssToLengthConversionData(), *primitiveValue.shapeValue()));
+            operation = ShapeClipPathOperation::create(basicShapeForValue(builderState.cssToLengthConversionData(), *primitiveValue.shapeValue()));
         } else {
             ASSERT(primitiveValue.valueID() == CSSValueContentBox
                 || primitiveValue.valueID() == CSSValueBorderBox
@@ -627,20 +627,20 @@ inline RefPtr<ClipPathOperation> StyleBuilderConverter::convertClipPath(StyleRes
     return operation;
 }
 
-inline Resize StyleBuilderConverter::convertResize(StyleResolver& styleResolver, const CSSValue& value)
+inline Resize StyleBuilderConverter::convertResize(Style::BuilderState& builderState, const CSSValue& value)
 {
     auto& primitiveValue = downcast<CSSPrimitiveValue>(value);
 
     Resize resize = Resize::None;
     if (primitiveValue.valueID() == CSSValueAuto)
-        resize = styleResolver.settings().textAreasAreResizable() ? Resize::Both : Resize::None;
+        resize = builderState.document().settings().textAreasAreResizable() ? Resize::Both : Resize::None;
     else
         resize = primitiveValue;
 
     return resize;
 }
 
-inline int StyleBuilderConverter::convertMarqueeRepetition(StyleResolver&, const CSSValue& value)
+inline int StyleBuilderConverter::convertMarqueeRepetition(Style::BuilderState&, const CSSValue& value)
 {
     auto& primitiveValue = downcast<CSSPrimitiveValue>(value);
     if (primitiveValue.valueID() == CSSValueInfinite)
@@ -650,7 +650,7 @@ inline int StyleBuilderConverter::convertMarqueeRepetition(StyleResolver&, const
     return primitiveValue.intValue();
 }
 
-inline int StyleBuilderConverter::convertMarqueeSpeed(StyleResolver&, const CSSValue& value)
+inline int StyleBuilderConverter::convertMarqueeSpeed(Style::BuilderState&, const CSSValue& value)
 {
     auto& primitiveValue = downcast<CSSPrimitiveValue>(value);
     int speed = 85;
@@ -679,7 +679,7 @@ inline int StyleBuilderConverter::convertMarqueeSpeed(StyleResolver&, const CSSV
     return speed;
 }
 
-inline Ref<QuotesData> StyleBuilderConverter::convertQuotes(StyleResolver&, const CSSValue& value)
+inline Ref<QuotesData> StyleBuilderConverter::convertQuotes(Style::BuilderState&, const CSSValue& value)
 {
     if (is<CSSPrimitiveValue>(value)) {
         ASSERT(downcast<CSSPrimitiveValue>(value).valueID() == CSSValueNone);
@@ -702,13 +702,13 @@ inline Ref<QuotesData> StyleBuilderConverter::convertQuotes(StyleResolver&, cons
     return QuotesData::create(quotes);
 }
 
-inline TextUnderlinePosition StyleBuilderConverter::convertTextUnderlinePosition(StyleResolver&, const CSSValue& value)
+inline TextUnderlinePosition StyleBuilderConverter::convertTextUnderlinePosition(Style::BuilderState&, const CSSValue& value)
 {
     ASSERT(is<CSSPrimitiveValue>(value));
     return downcast<CSSPrimitiveValue>(value);
 }
 
-inline TextUnderlineOffset StyleBuilderConverter::convertTextUnderlineOffset(StyleResolver& styleResolver, const CSSValue& value)
+inline TextUnderlineOffset StyleBuilderConverter::convertTextUnderlineOffset(Style::BuilderState& builderState, const CSSValue& value)
 {
     ASSERT(is<CSSPrimitiveValue>(value));
     auto& primitiveValue = downcast<CSSPrimitiveValue>(value);
@@ -717,12 +717,12 @@ inline TextUnderlineOffset StyleBuilderConverter::convertTextUnderlineOffset(Sty
         return TextUnderlineOffset::createWithAuto();
     default:
         ASSERT(primitiveValue.isLength());
-        auto computedLength = convertComputedLength<float>(styleResolver, primitiveValue);
+        auto computedLength = convertComputedLength<float>(builderState, primitiveValue);
         return TextUnderlineOffset::createWithLength(computedLength);
     }
 }
 
-inline TextDecorationThickness StyleBuilderConverter::convertTextDecorationThickness(StyleResolver& styleResolver, const CSSValue& value)
+inline TextDecorationThickness StyleBuilderConverter::convertTextDecorationThickness(Style::BuilderState& builderState, const CSSValue& value)
 {
     ASSERT(is<CSSPrimitiveValue>(value));
     auto& primitiveValue = downcast<CSSPrimitiveValue>(value);
@@ -733,12 +733,12 @@ inline TextDecorationThickness StyleBuilderConverter::convertTextDecorationThick
         return TextDecorationThickness::createFromFont();
     default:
         ASSERT(primitiveValue.isLength());
-        auto computedLength = convertComputedLength<float>(styleResolver, primitiveValue);
+        auto computedLength = convertComputedLength<float>(builderState, primitiveValue);
         return TextDecorationThickness::createWithLength(computedLength);
     }
 }
 
-inline RefPtr<StyleReflection> StyleBuilderConverter::convertReflection(StyleResolver& styleResolver, const CSSValue& value)
+inline RefPtr<StyleReflection> StyleBuilderConverter::convertReflection(Style::BuilderState& builderState, const CSSValue& value)
 {
     if (is<CSSPrimitiveValue>(value)) {
         ASSERT(downcast<CSSPrimitiveValue>(value).valueID() == CSSValueNone);
@@ -749,16 +749,16 @@ inline RefPtr<StyleReflection> StyleBuilderConverter::convertReflection(StyleRes
 
     auto reflection = StyleReflection::create();
     reflection->setDirection(reflectValue.direction());
-    reflection->setOffset(reflectValue.offset().convertToLength<FixedIntegerConversion | PercentConversion | CalculatedConversion>(styleResolver.state().cssToLengthConversionData()));
+    reflection->setOffset(reflectValue.offset().convertToLength<FixedIntegerConversion | PercentConversion | CalculatedConversion>(builderState.cssToLengthConversionData()));
 
     NinePieceImage mask(NinePieceImage::Type::Mask);
-    styleResolver.styleMap()->mapNinePieceImage(CSSPropertyWebkitBoxReflect, reflectValue.mask(), mask);
+    builderState.styleMap().mapNinePieceImage(CSSPropertyWebkitBoxReflect, reflectValue.mask(), mask);
     reflection->setMask(mask);
 
     return reflection;
 }
 
-inline IntSize StyleBuilderConverter::convertInitialLetter(StyleResolver&, const CSSValue& value)
+inline IntSize StyleBuilderConverter::convertInitialLetter(Style::BuilderState&, const CSSValue& value)
 {
     auto& primitiveValue = downcast<CSSPrimitiveValue>(value);
 
@@ -773,7 +773,7 @@ inline IntSize StyleBuilderConverter::convertInitialLetter(StyleResolver&, const
     return IntSize(pair->first()->intValue(), pair->second()->intValue());
 }
 
-inline float StyleBuilderConverter::convertTextStrokeWidth(StyleResolver& styleResolver, const CSSValue& value)
+inline float StyleBuilderConverter::convertTextStrokeWidth(Style::BuilderState& builderState, const CSSValue& value)
 {
     auto& primitiveValue = downcast<CSSPrimitiveValue>(value);
 
@@ -788,11 +788,11 @@ inline float StyleBuilderConverter::convertTextStrokeWidth(StyleResolver& styleR
         else if (primitiveValue.valueID() == CSSValueThick)
             result *= 5;
         Ref<CSSPrimitiveValue> emsValue(CSSPrimitiveValue::create(result, CSSPrimitiveValue::CSS_EMS));
-        width = convertComputedLength<float>(styleResolver, emsValue);
+        width = convertComputedLength<float>(builderState, emsValue);
         break;
     }
     case CSSValueInvalid: {
-        width = convertComputedLength<float>(styleResolver, primitiveValue);
+        width = convertComputedLength<float>(builderState, primitiveValue);
         break;
     }
     default:
@@ -803,7 +803,7 @@ inline float StyleBuilderConverter::convertTextStrokeWidth(StyleResolver& styleR
     return width;
 }
 
-inline OptionSet<LineBoxContain> StyleBuilderConverter::convertLineBoxContain(StyleResolver&, const CSSValue& value)
+inline OptionSet<LineBoxContain> StyleBuilderConverter::convertLineBoxContain(Style::BuilderState&, const CSSValue& value)
 {
     if (is<CSSPrimitiveValue>(value)) {
         ASSERT(downcast<CSSPrimitiveValue>(value).valueID() == CSSValueNone);
@@ -834,7 +834,7 @@ inline OptionSet<TextDecorationSkip> StyleBuilderConverter::valueToDecorationSki
     return OptionSet<TextDecorationSkip> { };
 }
 
-inline OptionSet<TextDecorationSkip> StyleBuilderConverter::convertTextDecorationSkip(StyleResolver&, const CSSValue& value)
+inline OptionSet<TextDecorationSkip> StyleBuilderConverter::convertTextDecorationSkip(Style::BuilderState&, const CSSValue& value)
 {
     if (is<CSSPrimitiveValue>(value))
         return valueToDecorationSkip(downcast<CSSPrimitiveValue>(value));
@@ -850,7 +850,7 @@ static inline bool isImageShape(const CSSValue& value)
     return is<CSSImageValue>(value) || is<CSSImageSetValue>(value) || is<CSSImageGeneratorValue>(value);
 }
 
-inline RefPtr<ShapeValue> StyleBuilderConverter::convertShapeValue(StyleResolver& styleResolver, CSSValue& value)
+inline RefPtr<ShapeValue> StyleBuilderConverter::convertShapeValue(Style::BuilderState& builderState, CSSValue& value)
 {
     if (is<CSSPrimitiveValue>(value)) {
         ASSERT(downcast<CSSPrimitiveValue>(value).valueID() == CSSValueNone);
@@ -858,14 +858,14 @@ inline RefPtr<ShapeValue> StyleBuilderConverter::convertShapeValue(StyleResolver
     }
 
     if (isImageShape(value))
-        return ShapeValue::create(styleResolver.styleImage(value).releaseNonNull());
+        return ShapeValue::create(builderState.createStyleImage(value).releaseNonNull());
 
     RefPtr<BasicShape> shape;
     CSSBoxType referenceBox = CSSBoxType::BoxMissing;
     for (auto& currentValue : downcast<CSSValueList>(value)) {
         auto& primitiveValue = downcast<CSSPrimitiveValue>(currentValue.get());
         if (primitiveValue.isShape())
-            shape = basicShapeForValue(styleResolver.state().cssToLengthConversionData(), *primitiveValue.shapeValue());
+            shape = basicShapeForValue(builderState.cssToLengthConversionData(), *primitiveValue.shapeValue());
         else if (primitiveValue.valueID() == CSSValueContentBox
             || primitiveValue.valueID() == CSSValueBorderBox
             || primitiveValue.valueID() == CSSValuePaddingBox
@@ -889,7 +889,7 @@ inline RefPtr<ShapeValue> StyleBuilderConverter::convertShapeValue(StyleResolver
 
 #if ENABLE(CSS_SCROLL_SNAP)
 
-inline ScrollSnapType StyleBuilderConverter::convertScrollSnapType(StyleResolver&, const CSSValue& value)
+inline ScrollSnapType StyleBuilderConverter::convertScrollSnapType(Style::BuilderState&, const CSSValue& value)
 {
     ScrollSnapType type;
     auto& values = downcast<CSSValueList>(value);
@@ -914,7 +914,7 @@ inline ScrollSnapType StyleBuilderConverter::convertScrollSnapType(StyleResolver
     return type;
 }
 
-inline ScrollSnapAlign StyleBuilderConverter::convertScrollSnapAlign(StyleResolver&, const CSSValue& value)
+inline ScrollSnapAlign StyleBuilderConverter::convertScrollSnapAlign(Style::BuilderState&, const CSSValue& value)
 {
     auto& values = downcast<CSSValueList>(value);
     ScrollSnapAlign alignment;
@@ -928,7 +928,7 @@ inline ScrollSnapAlign StyleBuilderConverter::convertScrollSnapAlign(StyleResolv
 
 #endif
 
-inline GridLength StyleBuilderConverter::createGridTrackBreadth(const CSSPrimitiveValue& primitiveValue, StyleResolver& styleResolver)
+inline GridLength StyleBuilderConverter::createGridTrackBreadth(const CSSPrimitiveValue& primitiveValue, Style::BuilderState& builderState)
 {
     if (primitiveValue.valueID() == CSSValueMinContent || primitiveValue.valueID() == CSSValueWebkitMinContent)
         return Length(MinContent);
@@ -940,23 +940,23 @@ inline GridLength StyleBuilderConverter::createGridTrackBreadth(const CSSPrimiti
     if (primitiveValue.isFlex())
         return GridLength(primitiveValue.doubleValue());
 
-    return primitiveValue.convertToLength<FixedIntegerConversion | PercentConversion | CalculatedConversion | AutoConversion>(styleResolver.state().cssToLengthConversionData());
+    return primitiveValue.convertToLength<FixedIntegerConversion | PercentConversion | CalculatedConversion | AutoConversion>(builderState.cssToLengthConversionData());
 }
 
-inline GridTrackSize StyleBuilderConverter::createGridTrackSize(const CSSValue& value, StyleResolver& styleResolver)
+inline GridTrackSize StyleBuilderConverter::createGridTrackSize(const CSSValue& value, Style::BuilderState& builderState)
 {
     if (is<CSSPrimitiveValue>(value))
-        return GridTrackSize(createGridTrackBreadth(downcast<CSSPrimitiveValue>(value), styleResolver));
+        return GridTrackSize(createGridTrackBreadth(downcast<CSSPrimitiveValue>(value), builderState));
 
     ASSERT(is<CSSFunctionValue>(value));
     const auto& function = downcast<CSSFunctionValue>(value);
 
     if (function.length() == 1)
-        return GridTrackSize(createGridTrackBreadth(downcast<CSSPrimitiveValue>(*function.itemWithoutBoundsCheck(0)), styleResolver), FitContentTrackSizing);
+        return GridTrackSize(createGridTrackBreadth(downcast<CSSPrimitiveValue>(*function.itemWithoutBoundsCheck(0)), builderState), FitContentTrackSizing);
 
     ASSERT_WITH_SECURITY_IMPLICATION(function.length() == 2);
-    GridLength minTrackBreadth(createGridTrackBreadth(downcast<CSSPrimitiveValue>(*function.itemWithoutBoundsCheck(0)), styleResolver));
-    GridLength maxTrackBreadth(createGridTrackBreadth(downcast<CSSPrimitiveValue>(*function.itemWithoutBoundsCheck(1)), styleResolver));
+    GridLength minTrackBreadth(createGridTrackBreadth(downcast<CSSPrimitiveValue>(*function.itemWithoutBoundsCheck(0)), builderState));
+    GridLength maxTrackBreadth(createGridTrackBreadth(downcast<CSSPrimitiveValue>(*function.itemWithoutBoundsCheck(1)), builderState));
     return GridTrackSize(minTrackBreadth, maxTrackBreadth);
 }
 
@@ -988,7 +988,7 @@ public:
     AutoRepeatType m_autoRepeatType { RenderStyle::initialGridAutoRepeatType() };
 };
 
-inline bool StyleBuilderConverter::createGridTrackList(const CSSValue& value, TracksData& tracksData, StyleResolver& styleResolver)
+inline bool StyleBuilderConverter::createGridTrackList(const CSSValue& value, TracksData& tracksData, Style::BuilderState& builderState)
 {
     // Handle 'none'.
     if (is<CSSPrimitiveValue>(value))
@@ -1003,7 +1003,7 @@ inline bool StyleBuilderConverter::createGridTrackList(const CSSValue& value, Tr
             createGridLineNamesList(currentValue, currentNamedGridLine, tracksData.m_namedGridLines, tracksData.m_orderedNamedGridLines);
         else {
             ++currentNamedGridLine;
-            tracksData.m_trackSizes.append(createGridTrackSize(currentValue, styleResolver));
+            tracksData.m_trackSizes.append(createGridTrackSize(currentValue, builderState));
         }
     };
 
@@ -1020,7 +1020,7 @@ inline bool StyleBuilderConverter::createGridTrackList(const CSSValue& value, Tr
                     continue;
                 }
                 ++autoRepeatIndex;
-                tracksData.m_autoRepeatTrackSizes.append(createGridTrackSize(autoRepeatValue.get(), styleResolver));
+                tracksData.m_autoRepeatTrackSizes.append(createGridTrackSize(autoRepeatValue.get(), builderState));
             }
             tracksData.m_autoRepeatInsertionPoint = currentNamedGridLine++;
             continue;
@@ -1111,7 +1111,7 @@ inline void StyleBuilderConverter::createImplicitNamedGridLinesFromGridArea(cons
     }
 }
 
-inline Vector<GridTrackSize> StyleBuilderConverter::convertGridTrackSizeList(StyleResolver& styleResolver, const CSSValue& value)
+inline Vector<GridTrackSize> StyleBuilderConverter::convertGridTrackSizeList(Style::BuilderState& builderState, const CSSValue& value)
 {
     ASSERT(value.isValueList());
     auto& valueList = downcast<CSSValueList>(value);
@@ -1121,17 +1121,17 @@ inline Vector<GridTrackSize> StyleBuilderConverter::convertGridTrackSizeList(Sty
         ASSERT(!currValue->isGridLineNamesValue());
         ASSERT(!currValue->isGridAutoRepeatValue());
         ASSERT(!currValue->isGridIntegerRepeatValue());
-        trackSizes.uncheckedAppend(convertGridTrackSize(styleResolver, currValue));
+        trackSizes.uncheckedAppend(convertGridTrackSize(builderState, currValue));
     }
     return trackSizes;
 }
 
-inline GridTrackSize StyleBuilderConverter::convertGridTrackSize(StyleResolver& styleResolver, const CSSValue& value)
+inline GridTrackSize StyleBuilderConverter::convertGridTrackSize(Style::BuilderState& builderState, const CSSValue& value)
 {
-    return createGridTrackSize(value, styleResolver);
+    return createGridTrackSize(value, builderState);
 }
 
-inline Optional<GridPosition> StyleBuilderConverter::convertGridPosition(StyleResolver&, const CSSValue& value)
+inline Optional<GridPosition> StyleBuilderConverter::convertGridPosition(Style::BuilderState&, const CSSValue& value)
 {
     GridPosition gridPosition;
     if (createGridPosition(value, gridPosition))
@@ -1139,7 +1139,7 @@ inline Optional<GridPosition> StyleBuilderConverter::convertGridPosition(StyleRe
     return WTF::nullopt;
 }
 
-inline GridAutoFlow StyleBuilderConverter::convertGridAutoFlow(StyleResolver&, const CSSValue& value)
+inline GridAutoFlow StyleBuilderConverter::convertGridAutoFlow(Style::BuilderState&, const CSSValue& value)
 {
     auto& list = downcast<CSSValueList>(value);
     if (!list.length())
@@ -1177,23 +1177,23 @@ inline GridAutoFlow StyleBuilderConverter::convertGridAutoFlow(StyleResolver&, c
     return autoFlow;
 }
 
-inline CSSToLengthConversionData StyleBuilderConverter::csstoLengthConversionDataWithTextZoomFactor(StyleResolver& styleResolver)
+inline CSSToLengthConversionData StyleBuilderConverter::csstoLengthConversionDataWithTextZoomFactor(Style::BuilderState& builderState)
 {
-    if (auto* frame = styleResolver.document().frame()) {
-        float textZoomFactor = styleResolver.style()->textZoom() != TextZoom::Reset ? frame->textZoomFactor() : 1.0f;
-        return styleResolver.state().cssToLengthConversionData().copyWithAdjustedZoom(styleResolver.style()->effectiveZoom() * textZoomFactor);
+    if (auto* frame = builderState.document().frame()) {
+        float textZoomFactor = builderState.style().textZoom() != TextZoom::Reset ? frame->textZoomFactor() : 1.0f;
+        return builderState.cssToLengthConversionData().copyWithAdjustedZoom(builderState.style().effectiveZoom() * textZoomFactor);
     }
-    return styleResolver.state().cssToLengthConversionData();
+    return builderState.cssToLengthConversionData();
 }
 
-inline Optional<Length> StyleBuilderConverter::convertWordSpacing(StyleResolver& styleResolver, const CSSValue& value)
+inline Optional<Length> StyleBuilderConverter::convertWordSpacing(Style::BuilderState& builderState, const CSSValue& value)
 {
     Optional<Length> wordSpacing;
     auto& primitiveValue = downcast<CSSPrimitiveValue>(value);
     if (primitiveValue.valueID() == CSSValueNormal)
         wordSpacing = RenderStyle::initialWordSpacing();
     else if (primitiveValue.isLength())
-        wordSpacing = primitiveValue.computeLength<Length>(csstoLengthConversionDataWithTextZoomFactor(styleResolver));
+        wordSpacing = primitiveValue.computeLength<Length>(csstoLengthConversionDataWithTextZoomFactor(builderState));
     else if (primitiveValue.isPercentage())
         wordSpacing = Length(clampTo<float>(primitiveValue.doubleValue(), minValueForCssLength, maxValueForCssLength), Percent);
     else if (primitiveValue.isNumber())
@@ -1202,7 +1202,7 @@ inline Optional<Length> StyleBuilderConverter::convertWordSpacing(StyleResolver&
     return wordSpacing;
 }
 
-inline Optional<float> StyleBuilderConverter::convertPerspective(StyleResolver& styleResolver, const CSSValue& value)
+inline Optional<float> StyleBuilderConverter::convertPerspective(Style::BuilderState& builderState, const CSSValue& value)
 {
     auto& primitiveValue = downcast<CSSPrimitiveValue>(value);
     if (primitiveValue.valueID() == CSSValueNone)
@@ -1210,16 +1210,16 @@ inline Optional<float> StyleBuilderConverter::convertPerspective(StyleResolver&
 
     float perspective = -1;
     if (primitiveValue.isLength())
-        perspective = primitiveValue.computeLength<float>(styleResolver.state().cssToLengthConversionData());
+        perspective = primitiveValue.computeLength<float>(builderState.cssToLengthConversionData());
     else if (primitiveValue.isNumber())
-        perspective = primitiveValue.doubleValue() * styleResolver.state().cssToLengthConversionData().zoom();
+        perspective = primitiveValue.doubleValue() * builderState.cssToLengthConversionData().zoom();
     else
         ASSERT_NOT_REACHED();
 
     return perspective < 0 ? Optional<float>(WTF::nullopt) : Optional<float>(perspective);
 }
 
-inline Optional<Length> StyleBuilderConverter::convertMarqueeIncrement(StyleResolver& styleResolver, const CSSValue& value)
+inline Optional<Length> StyleBuilderConverter::convertMarqueeIncrement(Style::BuilderState& builderState, const CSSValue& value)
 {
     Optional<Length> marqueeLength;
     auto& primitiveValue = downcast<CSSPrimitiveValue>(value);
@@ -1234,7 +1234,7 @@ inline Optional<Length> StyleBuilderConverter::convertMarqueeIncrement(StyleReso
         marqueeLength = Length(36, Fixed); // 36px.
         break;
     case CSSValueInvalid: {
-        Length length = primitiveValue.convertToLength<FixedIntegerConversion | PercentConversion | CalculatedConversion>(styleResolver.state().cssToLengthConversionData().copyWithAdjustedZoom(1.0f));
+        Length length = primitiveValue.convertToLength<FixedIntegerConversion | PercentConversion | CalculatedConversion>(builderState.cssToLengthConversionData().copyWithAdjustedZoom(1.0f));
         if (!length.isUndefined())
             marqueeLength = length;
         break;
@@ -1245,15 +1245,15 @@ inline Optional<Length> StyleBuilderConverter::convertMarqueeIncrement(StyleReso
     return marqueeLength;
 }
 
-inline Optional<FilterOperations> StyleBuilderConverter::convertFilterOperations(StyleResolver& styleResolver, const CSSValue& value)
+inline Optional<FilterOperations> StyleBuilderConverter::convertFilterOperations(Style::BuilderState& builderState, const CSSValue& value)
 {
     FilterOperations operations;
-    if (styleResolver.createFilterOperations(value, operations))
+    if (builderState.createFilterOperations(value, operations))
         return operations;
     return WTF::nullopt;
 }
 
-inline FontFeatureSettings StyleBuilderConverter::convertFontFeatureSettings(StyleResolver&, const CSSValue& value)
+inline FontFeatureSettings StyleBuilderConverter::convertFontFeatureSettings(Style::BuilderState&, const CSSValue& value)
 {
     if (is<CSSPrimitiveValue>(value)) {
         ASSERT(downcast<CSSPrimitiveValue>(value).valueID() == CSSValueNormal);
@@ -1323,27 +1323,27 @@ inline Optional<FontSelectionValue> StyleBuilderConverter::convertFontStyleFromV
     return italicValue();
 }
 
-inline FontSelectionValue StyleBuilderConverter::convertFontWeight(StyleResolver& styleResolver, const CSSValue& value)
+inline FontSelectionValue StyleBuilderConverter::convertFontWeight(Style::BuilderState& builderState, const CSSValue& value)
 {
     ASSERT(is<CSSPrimitiveValue>(value));
     auto& primitiveValue = downcast<CSSPrimitiveValue>(value);
     if (primitiveValue.isValueID()) {
         auto valueID = primitiveValue.valueID();
         if (valueID == CSSValueBolder)
-            return FontCascadeDescription::bolderWeight(styleResolver.parentStyle()->fontDescription().weight());
+            return FontCascadeDescription::bolderWeight(builderState.parentStyle().fontDescription().weight());
         if (valueID == CSSValueLighter)
-            return FontCascadeDescription::lighterWeight(styleResolver.parentStyle()->fontDescription().weight());
+            return FontCascadeDescription::lighterWeight(builderState.parentStyle().fontDescription().weight());
     }
     return convertFontWeightFromValue(value);
 }
 
-inline FontSelectionValue StyleBuilderConverter::convertFontStretch(StyleResolver&, const CSSValue& value)
+inline FontSelectionValue StyleBuilderConverter::convertFontStretch(Style::BuilderState&, const CSSValue& value)
 {
     return convertFontStretchFromValue(value);
 }
 
 #if ENABLE(VARIATION_FONTS)
-inline FontVariationSettings StyleBuilderConverter::convertFontVariationSettings(StyleResolver&, const CSSValue& value)
+inline FontVariationSettings StyleBuilderConverter::convertFontVariationSettings(Style::BuilderState&, const CSSValue& value)
 {
     if (is<CSSPrimitiveValue>(value)) {
         ASSERT(downcast<CSSPrimitiveValue>(value).valueID() == CSSValueNormal);
@@ -1360,21 +1360,21 @@ inline FontVariationSettings StyleBuilderConverter::convertFontVariationSettings
 #endif
 
 #if PLATFORM(IOS_FAMILY)
-inline bool StyleBuilderConverter::convertTouchCallout(StyleResolver&, const CSSValue& value)
+inline bool StyleBuilderConverter::convertTouchCallout(Style::BuilderState&, const CSSValue& value)
 {
     return !equalLettersIgnoringASCIICase(downcast<CSSPrimitiveValue>(value).stringValue(), "none");
 }
 #endif
 
 #if ENABLE(TOUCH_EVENTS)
-inline Color StyleBuilderConverter::convertTapHighlightColor(StyleResolver& styleResolver, const CSSValue& value)
+inline Color StyleBuilderConverter::convertTapHighlightColor(Style::BuilderState& builderState, const CSSValue& value)
 {
-    return styleResolver.colorFromPrimitiveValue(downcast<CSSPrimitiveValue>(value));
+    return builderState.colorFromPrimitiveValue(downcast<CSSPrimitiveValue>(value));
 }
 #endif
 
 #if ENABLE(POINTER_EVENTS)
-inline OptionSet<TouchAction> StyleBuilderConverter::convertTouchAction(StyleResolver&, const CSSValue& value)
+inline OptionSet<TouchAction> StyleBuilderConverter::convertTouchAction(Style::BuilderState&, const CSSValue& value)
 {
     if (is<CSSPrimitiveValue>(value))
         return downcast<CSSPrimitiveValue>(value);
@@ -1396,40 +1396,40 @@ inline OptionSet<TouchAction> StyleBuilderConverter::convertTouchAction(StyleRes
 #endif
 
 #if ENABLE(OVERFLOW_SCROLLING_TOUCH)
-inline bool StyleBuilderConverter::convertOverflowScrolling(StyleResolver&, const CSSValue& value)
+inline bool StyleBuilderConverter::convertOverflowScrolling(Style::BuilderState&, const CSSValue& value)
 {
     return downcast<CSSPrimitiveValue>(value).valueID() == CSSValueTouch;
 }
 #endif
 
-inline SVGLengthValue StyleBuilderConverter::convertSVGLengthValue(StyleResolver&, const CSSValue& value)
+inline SVGLengthValue StyleBuilderConverter::convertSVGLengthValue(Style::BuilderState&, const CSSValue& value)
 {
     return SVGLengthValue::fromCSSPrimitiveValue(downcast<CSSPrimitiveValue>(value));
 }
 
-inline Vector<SVGLengthValue> StyleBuilderConverter::convertSVGLengthVector(StyleResolver& styleResolver, const CSSValue& value)
+inline Vector<SVGLengthValue> StyleBuilderConverter::convertSVGLengthVector(Style::BuilderState& builderState, const CSSValue& value)
 {
     auto& valueList = downcast<CSSValueList>(value);
 
     Vector<SVGLengthValue> svgLengths;
     svgLengths.reserveInitialCapacity(valueList.length());
     for (auto& item : valueList)
-        svgLengths.uncheckedAppend(convertSVGLengthValue(styleResolver, item));
+        svgLengths.uncheckedAppend(convertSVGLengthValue(builderState, item));
 
     return svgLengths;
 }
 
-inline Vector<SVGLengthValue> StyleBuilderConverter::convertStrokeDashArray(StyleResolver& styleResolver, const CSSValue& value)
+inline Vector<SVGLengthValue> StyleBuilderConverter::convertStrokeDashArray(Style::BuilderState& builderState, const CSSValue& value)
 {
     if (is<CSSPrimitiveValue>(value)) {
         ASSERT(downcast<CSSPrimitiveValue>(value).valueID() == CSSValueNone);
         return SVGRenderStyle::initialStrokeDashArray();
     }
 
-    return convertSVGLengthVector(styleResolver, value);
+    return convertSVGLengthVector(builderState, value);
 }
 
-inline PaintOrder StyleBuilderConverter::convertPaintOrder(StyleResolver&, const CSSValue& value)
+inline PaintOrder StyleBuilderConverter::convertPaintOrder(Style::BuilderState&, const CSSValue& value)
 {
     if (is<CSSPrimitiveValue>(value)) {
         ASSERT(downcast<CSSPrimitiveValue>(value).valueID() == CSSValueNormal);
@@ -1450,7 +1450,7 @@ inline PaintOrder StyleBuilderConverter::convertPaintOrder(StyleResolver&, const
     }
 }
 
-inline float StyleBuilderConverter::convertOpacity(StyleResolver&, const CSSValue& value)
+inline float StyleBuilderConverter::convertOpacity(Style::BuilderState&, const CSSValue& value)
 {
     auto& primitiveValue = downcast<CSSPrimitiveValue>(value);
     float opacity = primitiveValue.floatValue();
@@ -1459,22 +1459,22 @@ inline float StyleBuilderConverter::convertOpacity(StyleResolver&, const CSSValu
     return std::max(0.0f, std::min(1.0f, opacity));
 }
 
-inline String StyleBuilderConverter::convertSVGURIReference(StyleResolver& styleResolver, const CSSValue& value)
+inline String StyleBuilderConverter::convertSVGURIReference(Style::BuilderState& builderState, const CSSValue& value)
 {
     String s;
     auto& primitiveValue = downcast<CSSPrimitiveValue>(value);
     if (primitiveValue.isURI())
         s = primitiveValue.stringValue();
 
-    return SVGURIReference::fragmentIdentifierFromIRIString(s, styleResolver.document());
+    return SVGURIReference::fragmentIdentifierFromIRIString(s, builderState.document());
 }
 
-inline Color StyleBuilderConverter::convertSVGColor(StyleResolver& styleResolver, const CSSValue& value)
+inline Color StyleBuilderConverter::convertSVGColor(Style::BuilderState& builderState, const CSSValue& value)
 {
-    return styleResolver.colorFromPrimitiveValue(downcast<CSSPrimitiveValue>(value));
+    return builderState.colorFromPrimitiveValue(downcast<CSSPrimitiveValue>(value));
 }
 
-inline StyleSelfAlignmentData StyleBuilderConverter::convertSelfOrDefaultAlignmentData(StyleResolver&, const CSSValue& value)
+inline StyleSelfAlignmentData StyleBuilderConverter::convertSelfOrDefaultAlignmentData(Style::BuilderState&, const CSSValue& value)
 {
     StyleSelfAlignmentData alignmentData = RenderStyle::initialSelfAlignment();
     auto& primitiveValue = downcast<CSSPrimitiveValue>(value);
@@ -1495,7 +1495,7 @@ inline StyleSelfAlignmentData StyleBuilderConverter::convertSelfOrDefaultAlignme
     return alignmentData;
 }
 
-inline StyleContentAlignmentData StyleBuilderConverter::convertContentAlignmentData(StyleResolver&, const CSSValue& value)
+inline StyleContentAlignmentData StyleBuilderConverter::convertContentAlignmentData(Style::BuilderState&, const CSSValue& value)
 {
     StyleContentAlignmentData alignmentData = RenderStyle::initialContentAlignment();
     if (!is<CSSContentDistributionValue>(value))
@@ -1510,7 +1510,7 @@ inline StyleContentAlignmentData StyleBuilderConverter::convertContentAlignmentD
     return alignmentData;
 }
 
-inline GlyphOrientation StyleBuilderConverter::convertGlyphOrientation(StyleResolver&, const CSSValue& value)
+inline GlyphOrientation StyleBuilderConverter::convertGlyphOrientation(Style::BuilderState&, const CSSValue& value)
 {
     float angle = fabsf(fmodf(downcast<CSSPrimitiveValue>(value).floatValue(), 360.0f));
     if (angle <= 45.0f || angle > 315.0f)
@@ -1522,21 +1522,21 @@ inline GlyphOrientation StyleBuilderConverter::convertGlyphOrientation(StyleReso
     return GlyphOrientation::Degrees270;
 }
 
-inline GlyphOrientation StyleBuilderConverter::convertGlyphOrientationOrAuto(StyleResolver& styleResolver, const CSSValue& value)
+inline GlyphOrientation StyleBuilderConverter::convertGlyphOrientationOrAuto(Style::BuilderState& builderState, const CSSValue& value)
 {
     if (downcast<CSSPrimitiveValue>(value).valueID() == CSSValueAuto)
         return GlyphOrientation::Auto;
-    return convertGlyphOrientation(styleResolver, value);
+    return convertGlyphOrientation(builderState, value);
 }
 
-inline Optional<Length> StyleBuilderConverter::convertLineHeight(StyleResolver& styleResolver, const CSSValue& value, float multiplier)
+inline Optional<Length> StyleBuilderConverter::convertLineHeight(Style::BuilderState& builderState, const CSSValue& value, float multiplier)
 {
     auto& primitiveValue = downcast<CSSPrimitiveValue>(value);
     if (primitiveValue.valueID() == CSSValueNormal)
         return RenderStyle::initialLineHeight();
 
     if (primitiveValue.isLength()) {
-        Length length = primitiveValue.computeLength<Length>(StyleBuilderConverter::csstoLengthConversionDataWithTextZoomFactor(styleResolver));
+        Length length = primitiveValue.computeLength<Length>(StyleBuilderConverter::csstoLengthConversionDataWithTextZoomFactor(builderState));
         if (multiplier != 1.f)
             length = Length(length.value() * multiplier, Fixed);
         return length;
@@ -1550,7 +1550,7 @@ inline Optional<Length> StyleBuilderConverter::convertLineHeight(StyleResolver&
     // values and raw numbers to percentages.
     if (primitiveValue.isPercentage()) {
         // FIXME: percentage should not be restricted to an integer here.
-        return Length((styleResolver.style()->computedFontSize() * primitiveValue.intValue()) / 100, Fixed);
+        return Length((builderState.style().computedFontSize() * primitiveValue.intValue()) / 100, Fixed);
     }
     if (primitiveValue.isNumber())
         return Length(primitiveValue.doubleValue() * 100.0, Percent);
@@ -1560,7 +1560,7 @@ inline Optional<Length> StyleBuilderConverter::convertLineHeight(StyleResolver&
     return WTF::nullopt;
 }
 
-inline FontSynthesis StyleBuilderConverter::convertFontSynthesis(StyleResolver&, const CSSValue& value)
+inline FontSynthesis StyleBuilderConverter::convertFontSynthesis(Style::BuilderState&, const CSSValue& value)
 {
     if (is<CSSPrimitiveValue>(value)) {
         ASSERT(downcast<CSSPrimitiveValue>(value).valueID() == CSSValueNone);
@@ -1589,7 +1589,7 @@ inline FontSynthesis StyleBuilderConverter::convertFontSynthesis(StyleResolver&,
     return result;
 }
     
-inline OptionSet<SpeakAs> StyleBuilderConverter::convertSpeakAs(StyleResolver&, const CSSValue& value)
+inline OptionSet<SpeakAs> StyleBuilderConverter::convertSpeakAs(Style::BuilderState&, const CSSValue& value)
 {
     auto result = RenderStyle::initialSpeakAs();
     if (is<CSSValueList>(value)) {
@@ -1599,7 +1599,7 @@ inline OptionSet<SpeakAs> StyleBuilderConverter::convertSpeakAs(StyleResolver&,
     return result;
 }
 
-inline OptionSet<HangingPunctuation> StyleBuilderConverter::convertHangingPunctuation(StyleResolver&, const CSSValue& value)
+inline OptionSet<HangingPunctuation> StyleBuilderConverter::convertHangingPunctuation(Style::BuilderState&, const CSSValue& value)
 {
     auto result = RenderStyle::initialHangingPunctuation();
     if (is<CSSValueList>(value)) {
@@ -1609,9 +1609,9 @@ inline OptionSet<HangingPunctuation> StyleBuilderConverter::convertHangingPunctu
     return result;
 }
 
-inline GapLength StyleBuilderConverter::convertGapLength(StyleResolver& styleResolver, const CSSValue& value)
+inline GapLength StyleBuilderConverter::convertGapLength(Style::BuilderState& builderState, const CSSValue& value)
 {
-    return (downcast<CSSPrimitiveValue>(value).valueID() == CSSValueNormal) ? GapLength() : GapLength(convertLength(styleResolver, value));
+    return (downcast<CSSPrimitiveValue>(value).valueID() == CSSValueNormal) ? GapLength() : GapLength(convertLength(builderState, value));
 }
 
 } // namespace WebCore
index 28de116..50df231 100644 (file)
@@ -54,9 +54,9 @@
 namespace WebCore {
 
 #define DECLARE_PROPERTY_CUSTOM_HANDLERS(property) \
-    static void applyInherit##property(StyleResolver&); \
-    static void applyInitial##property(StyleResolver&); \
-    static void applyValue##property(StyleResolver&, CSSValue&)
+    static void applyInherit##property(Style::BuilderState&); \
+    static void applyInitial##property(Style::BuilderState&); \
+    static void applyValue##property(Style::BuilderState&, CSSValue&)
 
 template<typename T> inline T forwardInheritedValue(T&& value) { return std::forward<T>(value); }
 inline Length forwardInheritedValue(const Length& value) { auto copy = value; return copy; }
@@ -109,126 +109,126 @@ public:
     DECLARE_PROPERTY_CUSTOM_HANDLERS(Zoom);
 
     // Custom handling of initial + inherit value setting only.
-    static void applyInitialWebkitMaskImage(StyleResolver&) { }
-    static void applyInheritWebkitMaskImage(StyleResolver&) { }
-    static void applyInitialFontFeatureSettings(StyleResolver&) { }
-    static void applyInheritFontFeatureSettings(StyleResolver&) { }
+    static void applyInitialWebkitMaskImage(Style::BuilderState&) { }
+    static void applyInheritWebkitMaskImage(Style::BuilderState&) { }
+    static void applyInitialFontFeatureSettings(Style::BuilderState&) { }
+    static void applyInheritFontFeatureSettings(Style::BuilderState&) { }
 #if ENABLE(VARIATION_FONTS)
-    static void applyInitialFontVariationSettings(StyleResolver&) { }
-    static void applyInheritFontVariationSettings(StyleResolver&) { }
+    static void applyInitialFontVariationSettings(Style::BuilderState&) { }
+    static void applyInheritFontVariationSettings(Style::BuilderState&) { }
 #endif
 
     // Custom handling of inherit + value setting only.
-    static void applyInheritDisplay(StyleResolver&);
-    static void applyValueDisplay(StyleResolver&, CSSValue&);
+    static void applyInheritDisplay(Style::BuilderState&);
+    static void applyValueDisplay(Style::BuilderState&, CSSValue&);
 
     // Custom handling of value setting only.
-    static void applyValueBaselineShift(StyleResolver&, CSSValue&);
-    static void applyValueDirection(StyleResolver&, CSSValue&);
-    static void applyValueVerticalAlign(StyleResolver&, CSSValue&);
-    static void applyInitialTextAlign(StyleResolver&);
-    static void applyValueTextAlign(StyleResolver&, CSSValue&);
-    static void applyValueWebkitLocale(StyleResolver&, CSSValue&);
-    static void applyValueWebkitTextOrientation(StyleResolver&, CSSValue&);
+    static void applyValueBaselineShift(Style::BuilderState&, CSSValue&);
+    static void applyValueDirection(Style::BuilderState&, CSSValue&);
+    static void applyValueVerticalAlign(Style::BuilderState&, CSSValue&);
+    static void applyInitialTextAlign(Style::BuilderState&);
+    static void applyValueTextAlign(Style::BuilderState&, CSSValue&);
+    static void applyValueWebkitLocale(Style::BuilderState&, CSSValue&);
+    static void applyValueWebkitTextOrientation(Style::BuilderState&, CSSValue&);
 #if ENABLE(TEXT_AUTOSIZING)
-    static void applyValueWebkitTextSizeAdjust(StyleResolver&, CSSValue&);
+    static void applyValueWebkitTextSizeAdjust(Style::BuilderState&, CSSValue&);
 #endif
-    static void applyValueWebkitTextZoom(StyleResolver&, CSSValue&);
-    static void applyValueWritingMode(StyleResolver&, CSSValue&);
-    static void applyValueAlt(StyleResolver&, CSSValue&);
-    static void applyValueWillChange(StyleResolver&, CSSValue&);
+    static void applyValueWebkitTextZoom(Style::BuilderState&, CSSValue&);
+    static void applyValueWritingMode(Style::BuilderState&, CSSValue&);
+    static void applyValueAlt(Style::BuilderState&, CSSValue&);
+    static void applyValueWillChange(Style::BuilderState&, CSSValue&);
 
 #if ENABLE(DARK_MODE_CSS)
-    static void applyValueColorScheme(StyleResolver&, CSSValue&);
+    static void applyValueColorScheme(Style::BuilderState&, CSSValue&);
 #endif
 
-    static void applyValueStrokeWidth(StyleResolver&, CSSValue&);
-    static void applyValueStrokeColor(StyleResolver&, CSSValue&);
+    static void applyValueStrokeWidth(Style::BuilderState&, CSSValue&);
+    static void applyValueStrokeColor(Style::BuilderState&, CSSValue&);
 
-    static void applyInitialCustomProperty(StyleResolver&, const CSSRegisteredCustomProperty*, const AtomString& name);
-    static void applyInheritCustomProperty(StyleResolver&, const CSSRegisteredCustomProperty*, const AtomString& name);
-    static void applyValueCustomProperty(StyleResolver&, const CSSRegisteredCustomProperty*, CSSCustomPropertyValue&);
+    static void applyInitialCustomProperty(Style::BuilderState&, const CSSRegisteredCustomProperty*, const AtomString& name);
+    static void applyInheritCustomProperty(Style::BuilderState&, const CSSRegisteredCustomProperty*, const AtomString& name);
+    static void applyValueCustomProperty(Style::BuilderState&, const CSSRegisteredCustomProperty*, CSSCustomPropertyValue&);
 
 private:
-    static void resetEffectiveZoom(StyleResolver&);
+    static void resetEffectiveZoom(Style::BuilderState&);
 
     static Length mmLength(double mm);
     static Length inchLength(double inch);
     static bool getPageSizeFromName(CSSPrimitiveValue* pageSizeName, CSSPrimitiveValue* pageOrientation, Length& width, Length& height);
 
     template <CSSPropertyID id>
-    static void applyTextOrBoxShadowValue(StyleResolver&, CSSValue&);
-    static bool isValidDisplayValue(StyleResolver&, DisplayType);
+    static void applyTextOrBoxShadowValue(Style::BuilderState&, CSSValue&);
+    static bool isValidDisplayValue(Style::BuilderState&, DisplayType);
 
     enum CounterBehavior {Increment = 0, Reset};
     template <CounterBehavior counterBehavior>
-    static void applyInheritCounter(StyleResolver&);
+    static void applyInheritCounter(Style::BuilderState&);
     template <CounterBehavior counterBehavior>
-    static void applyValueCounter(StyleResolver&, CSSValue&);
+    static void applyValueCounter(Style::BuilderState&, CSSValue&);
 
     static float largerFontSize(float size);
     static float smallerFontSize(float size);
-    static float determineRubyTextSizeMultiplier(StyleResolver&);
+    static float determineRubyTextSizeMultiplier(Style::BuilderState&);
 };
 
-inline void StyleBuilderCustom::applyValueDirection(StyleResolver& styleResolver, CSSValue& value)
+inline void StyleBuilderCustom::applyValueDirection(Style::BuilderState& builderState, CSSValue& value)
 {
-    styleResolver.style()->setDirection(downcast<CSSPrimitiveValue>(value));
-    styleResolver.style()->setHasExplicitlySetDirection(true);
+    builderState.style().setDirection(downcast<CSSPrimitiveValue>(value));
+    builderState.style().setHasExplicitlySetDirection(true);
 }
 
-inline void StyleBuilderCustom::applyInitialTextAlign(StyleResolver& styleResolver)
+inline void StyleBuilderCustom::applyInitialTextAlign(Style::BuilderState& builderState)
 {
-    styleResolver.style()->setTextAlign(RenderStyle::initialTextAlign());
-    styleResolver.style()->setHasExplicitlySetTextAlign(true);
+    builderState.style().setTextAlign(RenderStyle::initialTextAlign());
+    builderState.style().setHasExplicitlySetTextAlign(true);
 }
 
-inline void StyleBuilderCustom::applyValueTextAlign(StyleResolver& styleResolver, CSSValue& value)
+inline void StyleBuilderCustom::applyValueTextAlign(Style::BuilderState& builderState, CSSValue& value)
 {
-    styleResolver.style()->setTextAlign(StyleBuilderConverter::convertTextAlign(styleResolver, value));
-    styleResolver.style()->setHasExplicitlySetTextAlign(true);
+    builderState.style().setTextAlign(StyleBuilderConverter::convertTextAlign(builderState, value));
+    builderState.style().setHasExplicitlySetTextAlign(true);
 }
 
-inline void StyleBuilderCustom::resetEffectiveZoom(StyleResolver& styleResolver)
+inline void StyleBuilderCustom::resetEffectiveZoom(Style::BuilderState& builderState)
 {
     // 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());
+    builderState.setEffectiveZoom(builderState.parentStyle().effectiveZoom());
 }
 
-inline void StyleBuilderCustom::applyInitialZoom(StyleResolver& styleResolver)
+inline void StyleBuilderCustom::applyInitialZoom(Style::BuilderState& builderState)
 {
-    resetEffectiveZoom(styleResolver);
-    styleResolver.setZoom(RenderStyle::initialZoom());
+    resetEffectiveZoom(builderState);
+    builderState.setZoom(RenderStyle::initialZoom());
 }
 
-inline void StyleBuilderCustom::applyInheritZoom(StyleResolver& styleResolver)
+inline void StyleBuilderCustom::applyInheritZoom(Style::BuilderState& builderState)
 {
-    resetEffectiveZoom(styleResolver);
-    styleResolver.setZoom(styleResolver.parentStyle()->zoom());
+    resetEffectiveZoom(builderState);
+    builderState.setZoom(builderState.parentStyle().zoom());
 }
 
-inline void StyleBuilderCustom::applyValueZoom(StyleResolver& styleResolver, CSSValue& value)
+inline void StyleBuilderCustom::applyValueZoom(Style::BuilderState& builderState, CSSValue& value)
 {
     auto& primitiveValue = downcast<CSSPrimitiveValue>(value);
 
     if (primitiveValue.valueID() == CSSValueNormal) {
-        resetEffectiveZoom(styleResolver);
-        styleResolver.setZoom(RenderStyle::initialZoom());
+        resetEffectiveZoom(builderState);
+        builderState.setZoom(RenderStyle::initialZoom());
     } else if (primitiveValue.valueID() == CSSValueReset) {
-        styleResolver.setEffectiveZoom(RenderStyle::initialZoom());
-        styleResolver.setZoom(RenderStyle::initialZoom());
+        builderState.setEffectiveZoom(RenderStyle::initialZoom());
+        builderState.setZoom(RenderStyle::initialZoom());
     } else if (primitiveValue.valueID() == CSSValueDocument) {
-        float docZoom = styleResolver.rootElementStyle() ? styleResolver.rootElementStyle()->zoom() : RenderStyle::initialZoom();
-        styleResolver.setEffectiveZoom(docZoom);
-        styleResolver.setZoom(docZoom);
+        float docZoom = builderState.rootElementStyle().zoom();
+        builderState.setEffectiveZoom(docZoom);
+        builderState.setZoom(docZoom);
     } else if (primitiveValue.isPercentage()) {
-        resetEffectiveZoom(styleResolver);
+        resetEffectiveZoom(builderState);
         if (float percent = primitiveValue.floatValue())
-            styleResolver.setZoom(percent / 100.0f);
+            builderState.setZoom(percent / 100.0f);
     } else if (primitiveValue.isNumber()) {
-        resetEffectiveZoom(styleResolver);
+        resetEffectiveZoom(builderState);
         if (float number = primitiveValue.floatValue())
-            styleResolver.setZoom(number);
+            builderState.setZoom(number);
     }
 }
 inline Length StyleBuilderCustom::mmLength(double mm)
@@ -315,32 +315,32 @@ bool StyleBuilderCustom::getPageSizeFromName(CSSPrimitiveValue* pageSizeName, CS
     return true;
 }
 
-inline void StyleBuilderCustom::applyValueVerticalAlign(StyleResolver& styleResolver, CSSValue& value)
+inline void StyleBuilderCustom::applyValueVerticalAlign(Style::BuilderState& builderState, CSSValue& value)
 {
     auto& primitiveValue = downcast<CSSPrimitiveValue>(value);
     if (primitiveValue.valueID())
-        styleResolver.style()->setVerticalAlign(primitiveValue);
+        builderState.style().setVerticalAlign(primitiveValue);
     else
-        styleResolver.style()->setVerticalAlignLength(primitiveValue.convertToLength<FixedIntegerConversion | PercentConversion | CalculatedConversion>(styleResolver.state().cssToLengthConversionData()));
+        builderState.style().setVerticalAlignLength(primitiveValue.convertToLength<FixedIntegerConversion | PercentConversion | CalculatedConversion>(builderState.cssToLengthConversionData()));
 }
 
 #if ENABLE(CSS_IMAGE_RESOLUTION)
 
-inline void StyleBuilderCustom::applyInheritImageResolution(StyleResolver& styleResolver)
+inline void StyleBuilderCustom::applyInheritImageResolution(Style::BuilderState& builderState)
 {
-    styleResolver.style()->setImageResolutionSource(styleResolver.parentStyle()->imageResolutionSource());
-    styleResolver.style()->setImageResolutionSnap(styleResolver.parentStyle()->imageResolutionSnap());
-    styleResolver.style()->setImageResolution(styleResolver.parentStyle()->imageResolution());
+    builderState.style().setImageResolutionSource(builderState.parentStyle().imageResolutionSource());
+    builderState.style().setImageResolutionSnap(builderState.parentStyle().imageResolutionSnap());
+    builderState.style().setImageResolution(builderState.parentStyle().imageResolution());
 }
 
-inline void StyleBuilderCustom::applyInitialImageResolution(StyleResolver& styleResolver)
+inline void StyleBuilderCustom::applyInitialImageResolution(Style::BuilderState& builderState)
 {
-    styleResolver.style()->setImageResolutionSource(RenderStyle::initialImageResolutionSource());
-    styleResolver.style()->setImageResolutionSnap(RenderStyle::initialImageResolutionSnap());
-    styleResolver.style()->setImageResolution(RenderStyle::initialImageResolution());
+    builderState.style().setImageResolutionSource(RenderStyle::initialImageResolutionSource());
+    builderState.style().setImageResolutionSnap(RenderStyle::initialImageResolutionSnap());
+    builderState.style().setImageResolution(RenderStyle::initialImageResolution());
 }
 
-inline void StyleBuilderCustom::applyValueImageResolution(StyleResolver& styleResolver, CSSValue& value)
+inline void StyleBuilderCustom::applyValueImageResolution(Style::BuilderState& builderState, CSSValue& value)
 {
     ImageResolutionSource source = RenderStyle::initialImageResolutionSource();
     ImageResolutionSnap snap = RenderStyle::initialImageResolutionSnap();
@@ -354,20 +354,20 @@ inline void StyleBuilderCustom::applyValueImageResolution(StyleResolver& styleRe
         else
             resolution = primitiveValue.doubleValue(CSSPrimitiveValue::CSS_DPPX);
     }
-    styleResolver.style()->setImageResolutionSource(source);
-    styleResolver.style()->setImageResolutionSnap(snap);
-    styleResolver.style()->setImageResolution(resolution);
+    builderState.style().setImageResolutionSource(source);
+    builderState.style().setImageResolutionSnap(snap);
+    builderState.style().setImageResolution(resolution);
 }
 
 #endif // ENABLE(CSS_IMAGE_RESOLUTION)
 
-inline void StyleBuilderCustom::applyInheritSize(StyleResolver&) { }
+inline void StyleBuilderCustom::applyInheritSize(Style::BuilderState&) { }
 
-inline void StyleBuilderCustom::applyInitialSize(StyleResolver&) { }
+inline void StyleBuilderCustom::applyInitialSize(Style::BuilderState&) { }
 
-inline void StyleBuilderCustom::applyValueSize(StyleResolver& styleResolver, CSSValue& value)
+inline void StyleBuilderCustom::applyValueSize(Style::BuilderState& builderState, CSSValue& value)
 {
-    styleResolver.style()->resetPageSizeType();
+    builderState.style().resetPageSizeType();
 
     if (!is<CSSValueList>(value))
         return;
@@ -390,7 +390,7 @@ inline void StyleBuilderCustom::applyValueSize(StyleResolver& styleResolver, CSS
             // <length>{2}
             if (!secondPrimitiveValue.isLength())
                 return;
-            CSSToLengthConversionData conversionData = styleResolver.state().cssToLengthConversionData().copyWithAdjustedZoom(1.0f);
+            CSSToLengthConversionData conversionData = builderState.cssToLengthConversionData().copyWithAdjustedZoom(1.0f);
             width = firstPrimitiveValue.computeLength<Length>(conversionData);
             height = secondPrimitiveValue.computeLength<Length>(conversionData);
         } else {
@@ -411,7 +411,7 @@ inline void StyleBuilderCustom::applyValueSize(StyleResolver& styleResolver, CSS
         if (primitiveValue.isLength()) {
             // <length>
             pageSizeType = PAGE_SIZE_RESOLVED;
-            width = height = primitiveValue.computeLength<Length>(styleResolver.state().cssToLengthConversionData().copyWithAdjustedZoom(1.0f));
+            width = height = primitiveValue.computeLength<Length>(builderState.cssToLengthConversionData().copyWithAdjustedZoom(1.0f));
         } else {
             switch (primitiveValue.valueID()) {
             case 0:
@@ -437,29 +437,29 @@ inline void StyleBuilderCustom::applyValueSize(StyleResolver& styleResolver, CSS
     default:
         return;
     }
-    styleResolver.style()->setPageSizeType(pageSizeType);
-    styleResolver.style()->setPageSize({ WTFMove(width), WTFMove(height) });
+    builderState.style().setPageSizeType(pageSizeType);
+    builderState.style().setPageSize({ WTFMove(width), WTFMove(height) });
 }
 
-inline void StyleBuilderCustom::applyInheritTextIndent(StyleResolver& styleResolver)
+inline void StyleBuilderCustom::applyInheritTextIndent(Style::BuilderState& builderState)
 {
-    styleResolver.style()->setTextIndent(Length { styleResolver.parentStyle()->textIndent() });
+    builderState.style().setTextIndent(Length { builderState.parentStyle().textIndent() });
 #if ENABLE(CSS3_TEXT)
-    styleResolver.style()->setTextIndentLine(styleResolver.parentStyle()->textIndentLine());
-    styleResolver.style()->setTextIndentType(styleResolver.parentStyle()->textIndentType());
+    builderState.style().setTextIndentLine(builderState.parentStyle().textIndentLine());
+    builderState.style().setTextIndentType(builderState.parentStyle().textIndentType());
 #endif
 }
 
-inline void StyleBuilderCustom::applyInitialTextIndent(StyleResolver& styleResolver)
+inline void StyleBuilderCustom::applyInitialTextIndent(Style::BuilderState& builderState)
 {
-    styleResolver.style()->setTextIndent(RenderStyle::initialTextIndent());
+    builderState.style().setTextIndent(RenderStyle::initialTextIndent());
 #if ENABLE(CSS3_TEXT)
-    styleResolver.style()->setTextIndentLine(RenderStyle::initialTextIndentLine());
-    styleResolver.style()->setTextIndentType(RenderStyle::initialTextIndentType());
+    builderState.style().setTextIndentLine(RenderStyle::initialTextIndentLine());
+    builderState.style().setTextIndentType(RenderStyle::initialTextIndentType());
 #endif
 }
 
-inline void StyleBuilderCustom::applyValueTextIndent(StyleResolver& styleResolver, CSSValue& value)
+inline void StyleBuilderCustom::applyValueTextIndent(Style::BuilderState& builderState, CSSValue& value)
 {
     Length lengthOrPercentageValue;
 #if ENABLE(CSS3_TEXT)
@@ -469,7 +469,7 @@ inline void StyleBuilderCustom::applyValueTextIndent(StyleResolver& styleResolve
     for (auto& item : downcast<CSSValueList>(value)) {
         auto& primitiveValue = downcast<CSSPrimitiveValue>(item.get());
         if (!primitiveValue.valueID())
-            lengthOrPercentageValue = primitiveValue.convertToLength<FixedIntegerConversion | PercentConversion | CalculatedConversion>(styleResolver.state().cssToLengthConversionData());
+            lengthOrPercentageValue = primitiveValue.convertToLength<FixedIntegerConversion | PercentConversion | CalculatedConversion>(builderState.cssToLengthConversionData());
 #if ENABLE(CSS3_TEXT)
         else if (primitiveValue.valueID() == CSSValueWebkitEachLine)
             textIndentLineValue = TextIndentLine::EachLine;
@@ -481,10 +481,10 @@ inline void StyleBuilderCustom::applyValueTextIndent(StyleResolver& styleResolve
     if (lengthOrPercentageValue.isUndefined())
         return;
 
-    styleResolver.style()->setTextIndent(WTFMove(lengthOrPercentageValue));
+    builderState.style().setTextIndent(WTFMove(lengthOrPercentageValue));
 #if ENABLE(CSS3_TEXT)
-    styleResolver.style()->setTextIndentLine(textIndentLineValue);
-    styleResolver.style()->setTextIndentType(textIndentTypeValue);
+    builderState.style().setTextIndentLine(textIndentLineValue);
+    builderState.style().setTextIndentType(textIndentTypeValue);
 #endif
 }
 
@@ -493,29 +493,29 @@ enum BorderImageModifierType { Outset, Repeat, Slice, Width };
 template <BorderImageType type, BorderImageModifierType modifier>
 class ApplyPropertyBorderImageModifier {
 public:
-    static void applyInheritValue(StyleResolver& styleResolver)
+    static void applyInheritValue(Style::BuilderState& builderState)
     {
-        NinePieceImage image(getValue(styleResolver.style()));
+        NinePieceImage image(getValue(builderState.style()));
         switch (modifier) {
         case Outset:
-            image.copyOutsetFrom(getValue(styleResolver.parentStyle()));
+            image.copyOutsetFrom(getValue(builderState.parentStyle()));
             break;
         case Repeat:
-            image.copyRepeatFrom(getValue(styleResolver.parentStyle()));
+            image.copyRepeatFrom(getValue(builderState.parentStyle()));
             break;
         case Slice:
-            image.copyImageSlicesFrom(getValue(styleResolver.parentStyle()));
+            image.copyImageSlicesFrom(getValue(builderState.parentStyle()));
             break;
         case Width:
-            image.copyBorderSlicesFrom(getValue(styleResolver.parentStyle()));
+            image.copyBorderSlicesFrom(getValue(builderState.parentStyle()));
             break;
         }
-        setValue(styleResolver.style(), image);
+        setValue(builderState.style(), image);
     }
 
-    static void applyInitialValue(StyleResolver& styleResolver)
+    static void applyInitialValue(Style::BuilderState& builderState)
     {
-        NinePieceImage image(getValue(styleResolver.style()));
+        NinePieceImage image(getValue(builderState.style()));
         switch (modifier) {
         case Outset:
             image.setOutset(LengthBox(0));
@@ -538,53 +538,53 @@ public:
             image.setBorderSlices(type == BorderImage ? lengthBox : LengthBox());
             break;
         }
-        setValue(styleResolver.style(), image);
+        setValue(builderState.style(), image);
     }
 
-    static void applyValue(StyleResolver& styleResolver, CSSValue& value)
+    static void applyValue(Style::BuilderState& builderState, CSSValue& value)
     {
-        NinePieceImage image(getValue(styleResolver.style()));
+        NinePieceImage image(getValue(builderState.style()));
         switch (modifier) {
         case Outset:
-            image.setOutset(styleResolver.styleMap()->mapNinePieceImageQuad(value));
+            image.setOutset(builderState.styleMap().mapNinePieceImageQuad(value));
             break;
         case Repeat:
-            styleResolver.styleMap()->mapNinePieceImageRepeat(value, image);
+            builderState.styleMap().mapNinePieceImageRepeat(value, image);
             break;
         case Slice:
-            styleResolver.styleMap()->mapNinePieceImageSlice(value, image);
+            builderState.styleMap().mapNinePieceImageSlice(value, image);
             break;
         case Width:
-            image.setBorderSlices(styleResolver.styleMap()->mapNinePieceImageQuad(value));
+            image.setBorderSlices(builderState.styleMap().mapNinePieceImageQuad(value));
             break;
         }
-        setValue(styleResolver.style(), image);
+        setValue(builderState.style(), image);
     }
 
 private:
-    static const NinePieceImage& getValue(const RenderStyle* style)
+    static const NinePieceImage& getValue(const RenderStyle& style)
     {
-        return type == BorderImage ? style->borderImage() : style->maskBoxImage();
+        return type == BorderImage ? style.borderImage() : style.maskBoxImage();
     }
 
-    static void setValue(RenderStyle* style, const NinePieceImage& value)
+    static void setValue(RenderStyle& style, const NinePieceImage& value)
     {
-        return type == BorderImage ? style->setBorderImage(value) : style->setMaskBoxImage(value);
+        return type == BorderImage ? style.setBorderImage(value) : style.setMaskBoxImage(value);
     }
 };
 
 #define DEFINE_BORDER_IMAGE_MODIFIER_HANDLER(type, modifier) \
-inline void StyleBuilderCustom::applyInherit##type##modifier(StyleResolver& styleResolver) \
+inline void StyleBuilderCustom::applyInherit##type##modifier(Style::BuilderState& builderState) \
 { \
-    ApplyPropertyBorderImageModifier<type, modifier>::applyInheritValue(styleResolver); \
+    ApplyPropertyBorderImageModifier<type, modifier>::applyInheritValue(builderState); \
 } \
-inline void StyleBuilderCustom::applyInitial##type##modifier(StyleResolver& styleResolver) \
+inline void StyleBuilderCustom::applyInitial##type##modifier(Style::BuilderState& builderState) \
 { \
-    ApplyPropertyBorderImageModifier<type, modifier>::applyInitialValue(styleResolver); \
+    ApplyPropertyBorderImageModifier<type, modifier>::applyInitialValue(builderState); \
 } \
-inline void StyleBuilderCustom::applyValue##type##modifier(StyleResolver& styleResolver, CSSValue& value) \
+inline void StyleBuilderCustom::applyValue##type##modifier(Style::BuilderState& builderState, CSSValue& value) \
 { \
-    ApplyPropertyBorderImageModifier<type, modifier>::applyValue(styleResolver, value); \
+    ApplyPropertyBorderImageModifier<type, modifier>::applyValue(builderState, value); \
 }
 
 DEFINE_BORDER_IMAGE_MODIFIER_HANDLER(BorderImage, Outset)
@@ -598,16 +598,16 @@ DEFINE_BORDER_IMAGE_MODIFIER_HANDLER(WebkitMaskBoxImage, Width)
 
 #if ENABLE(TEXT_AUTOSIZING)
 
-inline void StyleBuilderCustom::applyInheritLineHeight(StyleResolver& styleResolver)
+inline void StyleBuilderCustom::applyInheritLineHeight(Style::BuilderState& builderState)
 {
-    styleResolver.style()->setLineHeight(Length { styleResolver.parentStyle()->lineHeight() });
-    styleResolver.style()->setSpecifiedLineHeight(Length { styleResolver.parentStyle()->specifiedLineHeight() });
+    builderState.style().setLineHeight(Length { builderState.parentStyle().lineHeight() });
+    builderState.style().setSpecifiedLineHeight(Length { builderState.parentStyle().specifiedLineHeight() });
 }
 
-inline void StyleBuilderCustom::applyInitialLineHeight(StyleResolver& styleResolver)
+inline void StyleBuilderCustom::applyInitialLineHeight(Style::BuilderState& builderState)
 {
-    styleResolver.style()->setLineHeight(RenderStyle::initialLineHeight());
-    styleResolver.style()->setSpecifiedLineHeight(RenderStyle::initialSpecifiedLineHeight());
+    builderState.style().setLineHeight(RenderStyle::initialLineHeight());
+    builderState.style().setSpecifiedLineHeight(RenderStyle::initialSpecifiedLineHeight());
 }
 
 static inline float computeBaseSpecifiedFontSize(const Document& document, const RenderStyle& style, bool percentageAutosizingEnabled)
@@ -654,9 +654,9 @@ static inline float computeLineHeightMultiplierDueToFontSize(const Document& doc
     return 1;
 }
 
-inline void StyleBuilderCustom::applyValueLineHeight(StyleResolver& styleResolver, CSSValue& value)
+inline void StyleBuilderCustom::applyValueLineHeight(Style::BuilderState& builderState, CSSValue& value)
 {
-    Optional<Length> lineHeight = StyleBuilderConverter::convertLineHeight(styleResolver, value, 1);
+    Optional<Length> lineHeight = StyleBuilderConverter::convertLineHeight(builderState, value, 1);
     if (!lineHeight)
         return;
 
@@ -665,144 +665,144 @@ inline void StyleBuilderCustom::applyValueLineHeight(StyleResolver& styleResolve
         computedLineHeight = lineHeight.value();
     else {
         auto& primitiveValue = downcast<CSSPrimitiveValue>(value);
-        auto multiplier = computeLineHeightMultiplierDueToFontSize(styleResolver.document(), *styleResolver.style(), primitiveValue);
+        auto multiplier = computeLineHeightMultiplierDueToFontSize(builderState.document(), builderState.style(), primitiveValue);
         if (multiplier == 1)
             computedLineHeight = lineHeight.value();
         else
-            computedLineHeight = StyleBuilderConverter::convertLineHeight(styleResolver, value, multiplier).value();
+            computedLineHeight = StyleBuilderConverter::convertLineHeight(builderState, value, multiplier).value();
     }
 
-    styleResolver.style()->setLineHeight(WTFMove(computedLineHeight));
-    styleResolver.style()->setSpecifiedLineHeight(WTFMove(lineHeight.value()));
+    builderState.style().setLineHeight(WTFMove(computedLineHeight));
+    builderState.style().setSpecifiedLineHeight(WTFMove(lineHeight.value()));
 }
 
 #endif
 
-inline void StyleBuilderCustom::applyInheritOutlineStyle(StyleResolver& styleResolver)
+inline void StyleBuilderCustom::applyInheritOutlineStyle(Style::BuilderState& builderState)
 {
-    styleResolver.style()->setOutlineStyleIsAuto(styleResolver.parentStyle()->outlineStyleIsAuto());
-    styleResolver.style()->setOutlineStyle(styleResolver.parentStyle()->outlineStyle());
+    builderState.style().setOutlineStyleIsAuto(builderState.parentStyle().outlineStyleIsAuto());
+    builderState.style().setOutlineStyle(builderState.parentStyle().outlineStyle());
 }
 
-inline void StyleBuilderCustom::applyInitialOutlineStyle(StyleResolver& styleResolver)
+inline void StyleBuilderCustom::applyInitialOutlineStyle(Style::BuilderState& builderState)
 {
-    styleResolver.style()->setOutlineStyleIsAuto(RenderStyle::initialOutlineStyleIsAuto());
-    styleResolver.style()->setOutlineStyle(RenderStyle::initialBorderStyle());
+    builderState.style().setOutlineStyleIsAuto(RenderStyle::initialOutlineStyleIsAuto());
+    builderState.style().setOutlineStyle(RenderStyle::initialBorderStyle());
 }
 
-inline void StyleBuilderCustom::applyValueOutlineStyle(StyleResolver& styleResolver, CSSValue& value)
+inline void StyleBuilderCustom::applyValueOutlineStyle(Style::BuilderState& builderState, CSSValue& value)
 {
     auto& primitiveValue = downcast<CSSPrimitiveValue>(value);
 
-    styleResolver.style()->setOutlineStyleIsAuto(primitiveValue);
-    styleResolver.style()->setOutlineStyle(primitiveValue);
+    builderState.style().setOutlineStyleIsAuto(primitiveValue);
+    builderState.style().setOutlineStyle(primitiveValue);
 }
 
-inline void StyleBuilderCustom::applyInitialClip(StyleResolver& styleResolver)
+inline void StyleBuilderCustom::applyInitialClip(Style::BuilderState& builderState)
 {
-    styleResolver.style()->setClip(Length(), Length(), Length(), Length());
-    styleResolver.style()->setHasClip(false);
+    builderState.style().setClip(Length(), Length(), Length(), Length());
+    builderState.style().setHasClip(false);
 }
 
-inline void StyleBuilderCustom::applyInheritClip(StyleResolver& styleResolver)
+inline void StyleBuilderCustom::applyInheritClip(Style::BuilderState& builderState)
 {
-    auto* parentStyle = styleResolver.parentStyle();
-    if (!parentStyle->hasClip())
-        return applyInitialClip(styleResolver);
-    styleResolver.style()->setClip(Length { parentStyle->clipTop() }, Length { parentStyle->clipRight() },
-        Length { parentStyle->clipBottom() }, Length { parentStyle->clipLeft() });
-    styleResolver.style()->setHasClip(true);
+    auto& parentStyle = builderState.parentStyle();
+    if (!parentStyle.hasClip())
+        return applyInitialClip(builderState);
+    builderState.style().setClip(Length { parentStyle.clipTop() }, Length { parentStyle.clipRight() },
+        Length { parentStyle.clipBottom() }, Length { parentStyle.clipLeft() });
+    builderState.style().setHasClip(true);
 }
 
-inline void StyleBuilderCustom::applyValueClip(StyleResolver& styleResolver, CSSValue& value)
+inline void StyleBuilderCustom::applyValueClip(Style::BuilderState& builderState, CSSValue& value)
 {
     auto& primitiveValue = downcast<CSSPrimitiveValue>(value);
     if (auto* rect = primitiveValue.rectValue()) {
-        auto conversionData = styleResolver.state().cssToLengthConversionData();
+        auto conversionData = builderState.cssToLengthConversionData();
         auto top = rect->top()->convertToLength<FixedIntegerConversion | PercentConversion | AutoConversion>(conversionData);
         auto right = rect->right()->convertToLength<FixedIntegerConversion | PercentConversion | AutoConversion>(conversionData);
         auto bottom = rect->bottom()->convertToLength<FixedIntegerConversion | PercentConversion | AutoConversion>(conversionData);
         auto left = rect->left()->convertToLength<FixedIntegerConversion | PercentConversion | AutoConversion>(conversionData);
-        styleResolver.style()->setClip(WTFMove(top), WTFMove(right), WTFMove(bottom), WTFMove(left));
-        styleResolver.style()->setHasClip(true);
+        builderState.style().setClip(WTFMove(top), WTFMove(right), WTFMove(bottom), WTFMove(left));
+        builderState.style().setHasClip(true);
     } else {
         ASSERT(primitiveValue.valueID() == CSSValueAuto);
-        applyInitialClip(styleResolver);
+        applyInitialClip(builderState);
     }
 }
 
-inline void StyleBuilderCustom::applyValueWebkitLocale(StyleResolver& styleResolver, CSSValue& value)
+inline void StyleBuilderCustom::applyValueWebkitLocale(Style::BuilderState& builderState, CSSValue& value)
 {
     auto& primitiveValue = downcast<CSSPrimitiveValue>(value);
 
-    FontCascadeDescription fontDescription = styleResolver.style()->fontDescription();
+    FontCascadeDescription fontDescription = builderState.style().fontDescription();
     if (primitiveValue.valueID() == CSSValueAuto)
         fontDescription.setLocale(nullAtom());
     else
         fontDescription.setLocale(primitiveValue.stringValue());
-    styleResolver.setFontDescription(WTFMove(fontDescription));
+    builderState.setFontDescription(WTFMove(fontDescription));
 }
 
-inline void StyleBuilderCustom::applyValueWritingMode(StyleResolver& styleResolver, CSSValue& value)
+inline void StyleBuilderCustom::applyValueWritingMode(Style::BuilderState& builderState, CSSValue& value)
 {
-    styleResolver.setWritingMode(downcast<CSSPrimitiveValue>(value));
-    styleResolver.style()->setHasExplicitlySetWritingMode(true);
+    builderState.setWritingMode(downcast<CSSPrimitiveValue>(value));
+    builderState.style().setHasExplicitlySetWritingMode(true);
 }
 
-inline void StyleBuilderCustom::applyValueWebkitTextOrientation(StyleResolver& styleResolver, CSSValue& value)
+inline void StyleBuilderCustom::applyValueWebkitTextOrientation(Style::BuilderState& builderState, CSSValue& value)
 {
-    styleResolver.setTextOrientation(downcast<CSSPrimitiveValue>(value));
+    builderState.setTextOrientation(downcast<CSSPrimitiveValue>(value));
 }
 
 #if ENABLE(TEXT_AUTOSIZING)
-inline void StyleBuilderCustom::applyValueWebkitTextSizeAdjust(StyleResolver& styleResolver, CSSValue& value)
+inline void StyleBuilderCustom::applyValueWebkitTextSizeAdjust(Style::BuilderState& builderState, CSSValue& value)
 {
     auto& primitiveValue = downcast<CSSPrimitiveValue>(value);
     if (primitiveValue.valueID() == CSSValueAuto)
-        styleResolver.style()->setTextSizeAdjust(TextSizeAdjustment(AutoTextSizeAdjustment));
+        builderState.style().setTextSizeAdjust(TextSizeAdjustment(AutoTextSizeAdjustment));
     else if (primitiveValue.valueID() == CSSValueNone)
-        styleResolver.style()->setTextSizeAdjust(TextSizeAdjustment(NoTextSizeAdjustment));
+        builderState.style().setTextSizeAdjust(TextSizeAdjustment(NoTextSizeAdjustment));
     else
-        styleResolver.style()->setTextSizeAdjust(TextSizeAdjustment(primitiveValue.floatValue()));
+        builderState.style().setTextSizeAdjust(TextSizeAdjustment(primitiveValue.floatValue()));
 
-    styleResolver.state().setFontDirty(true);
+    builderState.setFontDirty();
 }
 #endif
 
-inline void StyleBuilderCustom::applyValueWebkitTextZoom(StyleResolver& styleResolver, CSSValue& value)
+inline void StyleBuilderCustom::applyValueWebkitTextZoom(Style::BuilderState& builderState, CSSValue& value)
 {
     auto& primitiveValue = downcast<CSSPrimitiveValue>(value);
     if (primitiveValue.valueID() == CSSValueNormal)
-        styleResolver.style()->setTextZoom(TextZoom::Normal);
+        builderState.style().setTextZoom(TextZoom::Normal);
     else if (primitiveValue.valueID() == CSSValueReset)
-        styleResolver.style()->setTextZoom(TextZoom::Reset);
-    styleResolver.state().setFontDirty(true);
+        builderState.style().setTextZoom(TextZoom::Reset);
+    builderState.setFontDirty();
 }
 
 #if ENABLE(DARK_MODE_CSS)
-inline void StyleBuilderCustom::applyValueColorScheme(StyleResolver& styleResolver, CSSValue& value)
+inline void StyleBuilderCustom::applyValueColorScheme(Style::BuilderState& builderState, CSSValue& value)
 {
-    styleResolver.style()->setColorScheme(StyleBuilderConverter::convertColorScheme(styleResolver, value));
-    styleResolver.style()->setHasExplicitlySetColorScheme(true);
+    builderState.style().setColorScheme(StyleBuilderConverter::convertColorScheme(builderState, value));
+    builderState.style().setHasExplicitlySetColorScheme(true);
 }
 #endif
 
 template<CSSPropertyID property>
-inline void StyleBuilderCustom::applyTextOrBoxShadowValue(StyleResolver& styleResolver, CSSValue& value)
+inline void StyleBuilderCustom::applyTextOrBoxShadowValue(Style::BuilderState& builderState, CSSValue& value)
 {
     if (is<CSSPrimitiveValue>(value)) {
         ASSERT(downcast<CSSPrimitiveValue>(value).valueID() == CSSValueNone);
         if (property == CSSPropertyTextShadow)
-            styleResolver.style()->setTextShadow(nullptr);
+            builderState.style().setTextShadow(nullptr);
         else
-            styleResolver.style()->setBoxShadow(nullptr);
+            builderState.style().setBoxShadow(nullptr);
         return;
     }
 
     bool isFirstEntry = true;
     for (auto& item : downcast<CSSValueList>(value)) {
         auto& shadowValue = downcast<CSSShadowValue>(item.get());
-        auto conversionData = styleResolver.state().cssToLengthConversionData();
+        auto conversionData = builderState.cssToLengthConversionData();
         int x = shadowValue.x->computeLength<int>(conversionData);
         int y = shadowValue.y->computeLength<int>(conversionData);
         int blur = shadowValue.blur ? shadowValue.blur->computeLength<int>(conversionData) : 0;
@@ -810,94 +810,94 @@ inline void StyleBuilderCustom::applyTextOrBoxShadowValue(StyleResolver& styleRe
         ShadowStyle shadowStyle = shadowValue.style && shadowValue.style->valueID() == CSSValueInset ? Inset : Normal;
         Color color;
         if (shadowValue.color)
-            color = styleResolver.colorFromPrimitiveValue(*shadowValue.color);
+            color = builderState.colorFromPrimitiveValue(*shadowValue.color);
         else
-            color = styleResolver.style()->color();
+            color = builderState.style().color();
         auto shadowData = makeUnique<ShadowData>(IntPoint(x, y), blur, spread, shadowStyle, property == CSSPropertyWebkitBoxShadow, color.isValid() ? color : Color::transparent);
         if (property == CSSPropertyTextShadow)
-            styleResolver.style()->setTextShadow(WTFMove(shadowData), !isFirstEntry); // add to the list if this is not the first entry
+            builderState.style().setTextShadow(WTFMove(shadowData), !isFirstEntry); // add to the list if this is not the first entry
         else
-            styleResolver.style()->setBoxShadow(WTFMove(shadowData), !isFirstEntry); // add to the list if this is not the first entry
+            builderState.style().setBoxShadow(WTFMove(shadowData), !isFirstEntry); // add to the list if this is not the first entry
         isFirstEntry = false;
     }
 }
 
-inline void StyleBuilderCustom::applyInitialTextShadow(StyleResolver& styleResolver)
+inline void StyleBuilderCustom::applyInitialTextShadow(Style::BuilderState& builderState)
 {
-    styleResolver.style()->setTextShadow(nullptr);
+    builderState.style().setTextShadow(nullptr);
 }
 
-inline void StyleBuilderCustom::applyInheritTextShadow(StyleResolver& styleResolver)
+inline void StyleBuilderCustom::applyInheritTextShadow(Style::BuilderState& builderState)
 {
-    styleResolver.style()->setTextShadow(styleResolver.parentStyle()->textShadow() ? makeUnique<ShadowData>(*styleResolver.parentStyle()->textShadow()) : nullptr);
+    builderState.style().setTextShadow(builderState.parentStyle().textShadow() ? makeUnique<ShadowData>(*builderState.parentStyle().textShadow()) : nullptr);
 }
 
-inline void StyleBuilderCustom::applyValueTextShadow(StyleResolver& styleResolver, CSSValue& value)
+inline void StyleBuilderCustom::applyValueTextShadow(Style::BuilderState& builderState, CSSValue& value)
 {
-    applyTextOrBoxShadowValue<CSSPropertyTextShadow>(styleResolver, value);
+    applyTextOrBoxShadowValue<CSSPropertyTextShadow>(builderState, value);
 }
 
-inline void StyleBuilderCustom::applyInitialBoxShadow(StyleResolver& styleResolver)
+inline void StyleBuilderCustom::applyInitialBoxShadow(Style::BuilderState& builderState)
 {
-    styleResolver.style()->setBoxShadow(nullptr);
+    builderState.style().setBoxShadow(nullptr);
 }
 
-inline void StyleBuilderCustom::applyInheritBoxShadow(StyleResolver& styleResolver)
+inline void StyleBuilderCustom::applyInheritBoxShadow(Style::BuilderState& builderState)
 {
-    styleResolver.style()->setBoxShadow(styleResolver.parentStyle()->boxShadow() ? makeUnique<ShadowData>(*styleResolver.parentStyle()->boxShadow()) : nullptr);
+    builderState.style().setBoxShadow(builderState.parentStyle().boxShadow() ? makeUnique<ShadowData>(*builderState.parentStyle().boxShadow()) : nullptr);
 }
 
-inline void StyleBuilderCustom::applyValueBoxShadow(StyleResolver& styleResolver, CSSValue& value)
+inline void StyleBuilderCustom::applyValueBoxShadow(Style::BuilderState& builderState, CSSValue& value)
 {
-    applyTextOrBoxShadowValue<CSSPropertyBoxShadow>(styleResolver, value);
+    applyTextOrBoxShadowValue<CSSPropertyBoxShadow>(builderState, value);
 }
 
-inline void StyleBuilderCustom::applyInitialWebkitBoxShadow(StyleResolver& styleResolver)
+inline void StyleBuilderCustom::applyInitialWebkitBoxShadow(Style::BuilderState& builderState)
 {
-    applyInitialBoxShadow(styleResolver);
+    applyInitialBoxShadow(builderState);
 }
 
-inline void StyleBuilderCustom::applyInheritWebkitBoxShadow(StyleResolver& styleResolver)
+inline void StyleBuilderCustom::applyInheritWebkitBoxShadow(Style::BuilderState& builderState)
 {
-    applyInheritBoxShadow(styleResolver);
+    applyInheritBoxShadow(builderState);
 }
 
-inline void StyleBuilderCustom::applyValueWebkitBoxShadow(StyleResolver& styleResolver, CSSValue& value)
+inline void StyleBuilderCustom::applyValueWebkitBoxShadow(Style::BuilderState& builderState, CSSValue& value)
 {
-    applyTextOrBoxShadowValue<CSSPropertyWebkitBoxShadow>(styleResolver, value);
+    applyTextOrBoxShadowValue<CSSPropertyWebkitBoxShadow>(builderState, value);
 }
 
-inline void StyleBuilderCustom::applyInitialFontFamily(StyleResolver& styleResolver)
+inline void StyleBuilderCustom::applyInitialFontFamily(Style::BuilderState& builderState)
 {
-    auto fontDescription = styleResolver.style()->fontDescription();
+    auto fontDescription = builderState.style().fontDescription();
     auto initialDesc = FontCascadeDescription();
 
     // We need to adjust the size to account for the generic family change from monospace to non-monospace.
     if (fontDescription.useFixedDefaultSize()) {
         if (CSSValueID sizeIdentifier = fontDescription.keywordSizeAsIdentifier())
-            styleResolver.setFontSize(fontDescription, Style::fontSizeForKeyword(sizeIdentifier, false, styleResolver.document()));
+            builderState.setFontSize(fontDescription, Style::fontSizeForKeyword(sizeIdentifier, false, builderState.document()));
     }
     if (!initialDesc.firstFamily().isEmpty())
         fontDescription.setFamilies(initialDesc.families());
 
-    styleResolver.setFontDescription(WTFMove(fontDescription));
+    builderState.setFontDescription(WTFMove(fontDescription));
 }
 
-inline void StyleBuilderCustom::applyInheritFontFamily(StyleResolver& styleResolver)
+inline void StyleBuilderCustom::applyInheritFontFamily(Style::BuilderState& builderState)
 {
-    auto fontDescription = styleResolver.style()->fontDescription();
-    auto parentFontDescription = styleResolver.parentStyle()->fontDescription();
+    auto fontDescription = builderState.style().fontDescription();
+    auto parentFontDescription = builderState.parentStyle().fontDescription();
 
     fontDescription.setFamilies(parentFontDescription.families());
     fontDescription.setIsSpecifiedFont(parentFontDescription.isSpecifiedFont());
-    styleResolver.setFontDescription(WTFMove(fontDescription));
+    builderState.setFontDescription(WTFMove(fontDescription));
 }
 
-inline void StyleBuilderCustom::applyValueFontFamily(StyleResolver& styleResolver, CSSValue& value)
+inline void StyleBuilderCustom::applyValueFontFamily(Style::BuilderState& builderState, CSSValue& value)
 {
     auto& valueList = downcast<CSSValueList>(value);
 
-    auto fontDescription = styleResolver.style()->fontDescription();
+    auto fontDescription = builderState.style().fontDescription();
     // Before mapping in a new font-family property, we should reset the generic family.
     bool oldFamilyUsedFixedDefaultSize = fontDescription.useFixedDefaultSize();
 
@@ -916,7 +916,7 @@ inline void StyleBuilderCustom::applyValueFontFamily(StyleResolver& styleResolve
         } else {
             switch (contentValue.valueID()) {
             case CSSValueWebkitBody:
-                family = styleResolver.settings().standardFontFamily();
+                family = builderState.document().settings().standardFontFamily();
                 break;
             case CSSValueSerif:
                 family = serifFamily;
@@ -964,36 +964,36 @@ inline void StyleBuilderCustom::applyValueFontFamily(StyleResolver& styleResolve
 
     if (fontDescription.useFixedDefaultSize() != oldFamilyUsedFixedDefaultSize) {
         if (CSSValueID sizeIdentifier = fontDescription.keywordSizeAsIdentifier())
-            styleResolver.setFontSize(fontDescription, Style::fontSizeForKeyword(sizeIdentifier, !oldFamilyUsedFixedDefaultSize, styleResolver.document()));
+            builderState.setFontSize(fontDescription, Style::fontSizeForKeyword(sizeIdentifier, !oldFamilyUsedFixedDefaultSize, builderState.document()));
     }
 
-    styleResolver.setFontDescription(WTFMove(fontDescription));
+    builderState.setFontDescription(WTFMove(fontDescription));
 }
 
-inline bool StyleBuilderCustom::isValidDisplayValue(StyleResolver& styleResolver, DisplayType display)
+inline bool StyleBuilderCustom::isValidDisplayValue(Style::BuilderState& builderState, DisplayType display)
 {
-    if (is<SVGElement>(styleResolver.element()) && styleResolver.style()->styleType() == PseudoId::None)
+    if (is<SVGElement>(builderState.element()) && builderState.style().styleType() == PseudoId::None)
         return display == DisplayType::Inline || display == DisplayType::Block || display == DisplayType::None;
     return true;
 }
 
-inline void StyleBuilderCustom::applyInheritDisplay(StyleResolver& styleResolver)
+inline void StyleBuilderCustom::applyInheritDisplay(Style::BuilderState& builderState)
 {
-    DisplayType display = styleResolver.parentStyle()->display();
-    if (isValidDisplayValue(styleResolver, display))
-        styleResolver.style()->setDisplay(display);
+    DisplayType display = builderState.parentStyle().display();
+    if (isValidDisplayValue(builderState, display))
+        builderState.style().setDisplay(display);
 }
 
-inline void StyleBuilderCustom::applyValueDisplay(StyleResolver& styleResolver, CSSValue& value)
+inline void StyleBuilderCustom::applyValueDisplay(Style::BuilderState& builderState, CSSValue& value)
 {
     DisplayType display = downcast<CSSPrimitiveValue>(value);
-    if (isValidDisplayValue(styleResolver, display))
-        styleResolver.style()->setDisplay(display);
+    if (isValidDisplayValue(builderState, display))
+        builderState.style().setDisplay(display);
 }
 
-inline void StyleBuilderCustom::applyValueBaselineShift(StyleResolver& styleResolver, CSSValue& value)
+inline void StyleBuilderCustom::applyValueBaselineShift(Style::BuilderState& builderState, CSSValue& value)
 {
-    SVGRenderStyle& svgStyle = styleResolver.style()->accessSVGStyle();
+    SVGRenderStyle& svgStyle = builderState.style().accessSVGStyle();
     auto& primitiveValue = downcast<CSSPrimitiveValue>(value);
     if (primitiveValue.isValueID()) {
         switch (primitiveValue.valueID()) {
@@ -1015,57 +1015,57 @@ inline void StyleBuilderCustom::applyValueBaselineShift(StyleResolver& styleReso
     }
 }
 
-inline void StyleBuilderCustom::applyInitialWebkitAspectRatio(StyleResolver& styleResolver)
+inline void StyleBuilderCustom::applyInitialWebkitAspectRatio(Style::BuilderState& builderState)
 {
-    styleResolver.style()->setAspectRatioType(RenderStyle::initialAspectRatioType());
-    styleResolver.style()->setAspectRatioDenominator(RenderStyle::initialAspectRatioDenominator());
-    styleResolver.style()->setAspectRatioNumerator(RenderStyle::initialAspectRatioNumerator());
+    builderState.style().setAspectRatioType(RenderStyle::initialAspectRatioType());
+    builderState.style().setAspectRatioDenominator(RenderStyle::initialAspectRatioDenominator());
+    builderState.style().setAspectRatioNumerator(RenderStyle::initialAspectRatioNumerator());
 }
 
-inline void StyleBuilderCustom::applyInheritWebkitAspectRatio(StyleResolver& styleResolver)
+inline void StyleBuilderCustom::applyInheritWebkitAspectRatio(Style::BuilderState& builderState)
 {
-    if (styleResolver.parentStyle()->aspectRatioType() == AspectRatioType::Auto)
+    if (builderState.parentStyle().aspectRatioType() == AspectRatioType::Auto)
         return;
-    styleResolver.style()->setAspectRatioType(styleResolver.parentStyle()->aspectRatioType());
-    styleResolver.style()->setAspectRatioDenominator(styleResolver.parentStyle()->aspectRatioDenominator());
-    styleResolver.style()->setAspectRatioNumerator(styleResolver.parentStyle()->aspectRatioNumerator());
+    builderState.style().setAspectRatioType(builderState.parentStyle().aspectRatioType());
+    builderState.style().setAspectRatioDenominator(builderState.parentStyle().aspectRatioDenominator());
+    builderState.style().setAspectRatioNumerator(builderState.parentStyle().aspectRatioNumerator());
 }
 
-inline void StyleBuilderCustom::applyValueWebkitAspectRatio(StyleResolver& styleResolver, CSSValue& value)
+inline void StyleBuilderCustom::applyValueWebkitAspectRatio(Style::BuilderState& builderState, CSSValue& value)
 {
     if (is<CSSPrimitiveValue>(value)) {
         auto& primitiveValue = downcast<CSSPrimitiveValue>(value);
 
         if (primitiveValue.valueID() == CSSValueFromDimensions)
-            return styleResolver.style()->setAspectRatioType(AspectRatioType::FromDimensions);
+            return builderState.style().setAspectRatioType(AspectRatioType::FromDimensions);
         if (primitiveValue.valueID() == CSSValueFromIntrinsic)
-            return styleResolver.style()->setAspectRatioType(AspectRatioType::FromIntrinsic);
+            return builderState.style().setAspectRatioType(AspectRatioType::FromIntrinsic);
 
         ASSERT(primitiveValue.valueID() == CSSValueAuto);
-        return styleResolver.style()->setAspectRatioType(AspectRatioType::Auto);
+        return builderState.style().setAspectRatioType(AspectRatioType::Auto);
     }
 
     auto& aspectRatioValue = downcast<CSSAspectRatioValue>(value);
-    styleResolver.style()->setAspectRatioType(AspectRatioType::Specified);
-    styleResolver.style()->setAspectRatioDenominator(aspectRatioValue.denominatorValue());
-    styleResolver.style()->setAspectRatioNumerator(aspectRatioValue.numeratorValue());
+    builderState.style().setAspectRatioType(AspectRatioType::Specified);
+    builderState.style().setAspectRatioDenominator(aspectRatioValue.denominatorValue());
+    builderState.style().setAspectRatioNumerator(aspectRatioValue.numeratorValue());
 }
 
-inline void StyleBuilderCustom::applyInitialWebkitTextEmphasisStyle(StyleResolver& styleResolver)
+inline void StyleBuilderCustom::applyInitialWebkitTextEmphasisStyle(Style::BuilderState& builderState)
 {
-    styleResolver.style()->setTextEmphasisFill(RenderStyle::initialTextEmphasisFill());
-    styleResolver.style()->setTextEmphasisMark(RenderStyle::initialTextEmphasisMark());
-    styleResolver.style()->setTextEmphasisCustomMark(RenderStyle::initialTextEmphasisCustomMark());
+    builderState.style().setTextEmphasisFill(RenderStyle::initialTextEmphasisFill());
+    builderState.style().setTextEmphasisMark(RenderStyle::initialTextEmphasisMark());
+    builderState.style().setTextEmphasisCustomMark(RenderStyle::initialTextEmphasisCustomMark());
 }
 
-inline void StyleBuilderCustom::applyInheritWebkitTextEmphasisStyle(StyleResolver& styleResolver)
+inline void StyleBuilderCustom::applyInheritWebkitTextEmphasisStyle(Style::BuilderState& builderState)
 {
-    styleResolver.style()->setTextEmphasisFill(styleResolver.parentStyle()->textEmphasisFill());
-    styleResolver.style()->setTextEmphasisMark(styleResolver.parentStyle()->textEmphasisMark());
-    styleResolver.style()->setTextEmphasisCustomMark(styleResolver.parentStyle()->textEmphasisCustomMark());
+    builderState.style().setTextEmphasisFill(builderState.parentStyle().textEmphasisFill());
+    builderState.style().setTextEmphasisMark(builderState.parentStyle().textEmphasisMark());
+    builderState.style().setTextEmphasisCustomMark(builderState.parentStyle().textEmphasisCustomMark());
 }
 
-inline void StyleBuilderCustom::applyValueWebkitTextEmphasisStyle(StyleResolver& styleResolver, CSSValue& value)
+inline void StyleBuilderCustom::applyValueWebkitTextEmphasisStyle(Style::BuilderState& builderState, CSSValue& value)
 {
     if (is<CSSValueList>(value)) {
         auto& list = downcast<CSSValueList>(value);
@@ -1074,38 +1074,38 @@ inline void StyleBuilderCustom::applyValueWebkitTextEmphasisStyle(StyleResolver&
         for (auto& item : list) {
             CSSPrimitiveValue& value = downcast<CSSPrimitiveValue>(item.get());
             if (value.valueID() == CSSValueFilled || value.valueID() == CSSValueOpen)
-                styleResolver.style()->setTextEmphasisFill(value);
+                builderState.style().setTextEmphasisFill(value);
             else
-                styleResolver.style()->setTextEmphasisMark(value);
+                builderState.style().setTextEmphasisMark(value);
         }
-        styleResolver.style()->setTextEmphasisCustomMark(nullAtom());
+        builderState.style().setTextEmphasisCustomMark(nullAtom());
         return;
     }
 
     auto& primitiveValue = downcast<CSSPrimitiveValue>(value);
     if (primitiveValue.isString()) {
-        styleResolver.style()->setTextEmphasisFill(TextEmphasisFill::Filled);
-        styleResolver.style()->setTextEmphasisMark(TextEmphasisMark::Custom);
-        styleResolver.style()->setTextEmphasisCustomMark(primitiveValue.stringValue());
+        builderState.style().setTextEmphasisFill(TextEmphasisFill::Filled);
+        builderState.style().setTextEmphasisMark(TextEmphasisMark::Custom);
+        builderState.style().setTextEmphasisCustomMark(primitiveValue.stringValue());
         return;
     }
 
-    styleResolver.style()->setTextEmphasisCustomMark(nullAtom());
+    builderState.style().setTextEmphasisCustomMark(nullAtom());
 
     if (primitiveValue.valueID() == CSSValueFilled || primitiveValue.valueID() == CSSValueOpen) {
-        styleResolver.style()->setTextEmphasisFill(primitiveValue);
-        styleResolver.style()->setTextEmphasisMark(TextEmphasisMark::Auto);
+        builderState.style().setTextEmphasisFill(primitiveValue);
+        builderState.style().setTextEmphasisMark(TextEmphasisMark::Auto);
     } else {
-        styleResolver.style()->setTextEmphasisFill(TextEmphasisFill::Filled);
-        styleResolver.style()->setTextEmphasisMark(primitiveValue);
+        builderState.style().setTextEmphasisFill(TextEmphasisFill::Filled);
+        builderState.style().setTextEmphasisMark(primitiveValue);
     }
 }
 
 template <StyleBuilderCustom::CounterBehavior counterBehavior>
-inline void StyleBuilderCustom::applyInheritCounter(StyleResolver& styleResolver)
+inline void StyleBuilderCustom::applyInheritCounter(Style::BuilderState& builderState)
 {
-    auto& map = styleResolver.style()->accessCounterDirectives();
-    for (auto& keyValue : const_cast<RenderStyle*>(styleResolver.parentStyle())->accessCounterDirectives()) {
+    auto& map = builderState.style().accessCounterDirectives();
+    for (auto& keyValue : const_cast<RenderStyle&>(builderState.parentStyle()).accessCounterDirectives()) {
         auto& directives = map.add(keyValue.key, CounterDirectives { }).iterator->value;
         if (counterBehavior == Reset)
             directives.resetValue = keyValue.value.resetValue;
@@ -1115,14 +1115,14 @@ inline void StyleBuilderCustom::applyInheritCounter(StyleResolver& styleResolver
 }
 
 template <StyleBuilderCustom::CounterBehavior counterBehavior>
-inline void StyleBuilderCustom::applyValueCounter(StyleResolver& styleResolver, CSSValue& value)
+inline void StyleBuilderCustom::applyValueCounter(Style::BuilderState& builderState, CSSValue& value)
 {
     bool setCounterIncrementToNone = counterBehavior == Increment && is<CSSPrimitiveValue>(value) && downcast<CSSPrimitiveValue>(value).valueID() == CSSValueNone;
 
     if (!is<CSSValueList>(value) && !setCounterIncrementToNone)
         return;
 
-    CounterDirectiveMap& map = styleResolver.style()->accessCounterDirectives();
+    CounterDirectiveMap& map = builderState.style().accessCounterDirectives();
     for (auto& keyValue : map) {
         if (counterBehavior == Reset)
             keyValue.value.resetValue = WTF::nullopt;
@@ -1145,84 +1145,84 @@ inline void StyleBuilderCustom::applyValueCounter(StyleResolver& styleResolver,
     }
 }
 
-inline void StyleBuilderCustom::applyInitialCounterIncrement(StyleResolver&) { }
+inline void StyleBuilderCustom::applyInitialCounterIncrement(Style::BuilderState&) { }
 
-inline void StyleBuilderCustom::applyInheritCounterIncrement(StyleResolver& styleResolver)
+inline void StyleBuilderCustom::applyInheritCounterIncrement(Style::BuilderState& builderState)
 {
-    applyInheritCounter<Increment>(styleResolver);
+    applyInheritCounter<Increment>(builderState);
 }
 
-inline void StyleBuilderCustom::applyValueCounterIncrement(StyleResolver& styleResolver, CSSValue& value)
+inline void StyleBuilderCustom::applyValueCounterIncrement(Style::BuilderState& builderState, CSSValue& value)
 {
-    applyValueCounter<Increment>(styleResolver, value);
+    applyValueCounter<Increment>(builderState, value);
 }
 
-inline void StyleBuilderCustom::applyInitialCounterReset(StyleResolver&) { }
+inline void StyleBuilderCustom::applyInitialCounterReset(Style::BuilderState&) { }
 
-inline void StyleBuilderCustom::applyInheritCounterReset(StyleResolver& styleResolver)
+inline void StyleBuilderCustom::applyInheritCounterReset(Style::BuilderState& builderState)
 {
-    applyInheritCounter<Reset>(styleResolver);
+    applyInheritCounter<Reset>(builderState);
 }
 
-inline void StyleBuilderCustom::applyValueCounterReset(StyleResolver& styleResolver, CSSValue& value)
+inline void StyleBuilderCustom::applyValueCounterReset(Style::BuilderState& builderState, CSSValue& value)
 {
-    applyValueCounter<Reset>(styleResolver, value);
+    applyValueCounter<Reset>(builderState, value);
 }
 
-inline void StyleBuilderCustom::applyInitialCursor(StyleResolver& styleResolver)
+inline void StyleBuilderCustom::applyInitialCursor(Style::BuilderState& builderState)
 {
-    styleResolver.style()->clearCursorList();
-    styleResolver.style()->setCursor(RenderStyle::initialCursor());
+    builderState.style().clearCursorList();
+    builderState.style().setCursor(RenderStyle::initialCursor());
 }
 
-inline void StyleBuilderCustom::applyInheritCursor(StyleResolver& styleResolver)
+inline void StyleBuilderCustom::applyInheritCursor(Style::BuilderState& builderState)
 {
-    styleResolver.style()->setCursor(styleResolver.parentStyle()->cursor());
-    styleResolver.style()->setCursorList(styleResolver.parentStyle()->cursors());
+    builderState.style().setCursor(builderState.parentStyle().cursor());
+    builderState.style().setCursorList(builderState.parentStyle().cursors());
 }
 
-inline void StyleBuilderCustom::applyValueCursor(StyleResolver& styleResolver, CSSValue& value)
+inline void StyleBuilderCustom::applyValueCursor(Style::BuilderState& builderState, CSSValue& value)
 {
-    styleResolver.style()->clearCursorList();
+    builderState.style().clearCursorList();
     if (is<CSSPrimitiveValue>(value)) {
         CursorType cursor = downcast<CSSPrimitiveValue>(value);
-        if (styleResolver.style()->cursor() != cursor)
-            styleResolver.style()->setCursor(cursor);
+        if (builderState.style().cursor() != cursor)
+            builderState.style().setCursor(cursor);
         return;
     }
 
-    styleResolver.style()->setCursor(CursorType::Auto);
+    builderState.style().setCursor(CursorType::Auto);
     auto& list = downcast<CSSValueList>(value);
     for (auto& item : list) {
         if (is<CSSCursorImageValue>(item)) {
             auto& image = downcast<CSSCursorImageValue>(item.get());
-            styleResolver.style()->addCursor(styleResolver.styleImage(image), image.hotSpot());
+            builderState.style().addCursor(builderState.createStyleImage(image), image.hotSpot());
             continue;
         }
 
-        styleResolver.style()->setCursor(downcast<CSSPrimitiveValue>(item.get()));
+        builderState.style().setCursor(downcast<CSSPrimitiveValue>(item.get()));
         ASSERT_WITH_MESSAGE(item.ptr() == list.item(list.length() - 1), "Cursor ID fallback should always be last in the list");
         return;
     }
 }
 
-inline void StyleBuilderCustom::applyInitialFill(StyleResolver& styleResolver)
+inline void StyleBuilderCustom::applyInitialFill(Style::BuilderState& builderState)
 {
-    auto& svgStyle = styleResolver.style()->accessSVGStyle();
-    svgStyle.setFillPaint(SVGRenderStyle::initialFillPaintType(), SVGRenderStyle::initialFillPaintColor(), SVGRenderStyle::initialFillPaintUri(), styleResolver.applyPropertyToRegularStyle(), styleResolver.applyPropertyToVisitedLinkStyle());
+    auto& svgStyle = builderState.style().accessSVGStyle();
+    svgStyle.setFillPaint(SVGRenderStyle::initialFillPaintType(), SVGRenderStyle::initialFillPaintColor(), SVGRenderStyle::initialFillPaintUri(), builderState.applyPropertyToRegularStyle(), builderState.applyPropertyToVisitedLinkStyle());
 }
 
-inline void StyleBuilderCustom::applyInheritFill(StyleResolver& styleResolver)
+inline void StyleBuilderCustom::applyInheritFill(Style::BuilderState& builderState)
 {
-    auto& svgStyle = styleResolver.style()->accessSVGStyle();
-    auto& svgParentStyle = styleResolver.parentStyle()->svgStyle();
-    svgStyle.setFillPaint(svgParentStyle.fillPaintType(), svgParentStyle.fillPaintColor(), svgParentStyle.fillPaintUri(), styleResolver.applyPropertyToRegularStyle(), styleResolver.applyPropertyToVisitedLinkStyle());
+    auto& svgStyle = builderState.style().accessSVGStyle();
+    auto& svgParentStyle = builderState.parentStyle().svgStyle();
+    svgStyle.setFillPaint(svgParentStyle.fillPaintType(), svgParentStyle.fillPaintColor(), svgParentStyle.fillPaintUri(), builderState.applyPropertyToRegularStyle(), builderState.applyPropertyToVisitedLinkStyle());
 
 }
 
-inline void StyleBuilderCustom::applyValueFill(StyleResolver& styleResolver, CSSValue& value)
+inline void StyleBuilderCustom::applyValueFill(Style::BuilderState& builderState, CSSValue& value)
 {
-    auto& svgStyle = styleResolver.style()->accessSVGStyle();
+    auto& svgStyle = builderState.style().accessSVGStyle();
     const auto* localValue = value.isPrimitiveValue() ? &downcast<CSSPrimitiveValue>(value) : nullptr;
     String url;
     if (value.isValueList()) {
@@ -1242,31 +1242,31 @@ inline void StyleBuilderCustom::applyValueFill(StyleResolver& styleResolver, CSS
     } else if (localValue->isValueID() && localValue->valueID() == CSSValueNone)
         paintType = url.isEmpty() ? SVGPaintType::None : SVGPaintType::URINone;
     else if (localValue->isValueID() && localValue->valueID() == CSSValueCurrentcolor) {
-        color = styleResolver.style()->color();
+        color = builderState.style().color();
         paintType = url.isEmpty() ? SVGPaintType::CurrentColor : SVGPaintType::URICurrentColor;
     } else {
-        color = styleResolver.colorFromPrimitiveValue(*localValue);
+        color = builderState.colorFromPrimitiveValue(*localValue);
         paintType = url.isEmpty() ? SVGPaintType::RGBColor : SVGPaintType::URIRGBColor;
     }
-    svgStyle.setFillPaint(paintType, color, url, styleResolver.applyPropertyToRegularStyle(), styleResolver.applyPropertyToVisitedLinkStyle());
+    svgStyle.setFillPaint(paintType, color, url, builderState.applyPropertyToRegularStyle(), builderState.applyPropertyToVisitedLinkStyle());
 }
 
-inline void StyleBuilderCustom::applyInitialStroke(StyleResolver& styleResolver)
+inline void StyleBuilderCustom::applyInitialStroke(Style::BuilderState& builderState)
 {
-    SVGRenderStyle& svgStyle = styleResolver.style()->accessSVGStyle();
-    svgStyle.setStrokePaint(SVGRenderStyle::initialStrokePaintType(), SVGRenderStyle::initialStrokePaintColor(), SVGRenderStyle::initialStrokePaintUri(), styleResolver.applyPropertyToRegularStyle(), styleResolver.applyPropertyToVisitedLinkStyle());
+    SVGRenderStyle& svgStyle = builderState.style().accessSVGStyle();
+    svgStyle.setStrokePaint(SVGRenderStyle::initialStrokePaintType(), SVGRenderStyle::initialStrokePaintColor(), SVGRenderStyle::initialStrokePaintUri(), builderState.applyPropertyToRegularStyle(), builderState.applyPropertyToVisitedLinkStyle());
 }
 
-inline void StyleBuilderCustom::applyInheritStroke(StyleResolver& styleResolver)
+inline void StyleBuilderCustom::applyInheritStroke(Style::BuilderState& builderState)
 {
-    auto& svgStyle = styleResolver.style()->accessSVGStyle();
-    auto& svgParentStyle = styleResolver.parentStyle()->svgStyle();
-    svgStyle.setStrokePaint(svgParentStyle.strokePaintType(), svgParentStyle.strokePaintColor(), svgParentStyle.strokePaintUri(), styleResolver.applyPropertyToRegularStyle(), styleResolver.applyPropertyToVisitedLinkStyle());
+    auto& svgStyle = builderState.style().accessSVGStyle();
+    auto& svgParentStyle = builderState.parentStyle().svgStyle();
+    svgStyle.setStrokePaint(svgParentStyle.strokePaintType(), svgParentStyle.strokePaintColor(), svgParentStyle.strokePaintUri(), builderState.applyPropertyToRegularStyle(), builderState.applyPropertyToVisitedLinkStyle());
 }
 
-inline void StyleBuilderCustom::applyValueStroke(StyleResolver& styleResolver, CSSValue& value)
+inline void StyleBuilderCustom::applyValueStroke(Style::BuilderState& builderState, CSSValue& value)
 {
-    auto& svgStyle = styleResolver.style()->accessSVGStyle();
+    auto& svgStyle = builderState.style().accessSVGStyle();
     const auto* localValue = value.isPrimitiveValue() ? &downcast<CSSPrimitiveValue>(value) : nullptr;
     String url;
     if (value.isValueList()) {
@@ -1286,32 +1286,32 @@ inline void StyleBuilderCustom::applyValueStroke(StyleResolver& styleResolver, C
     } else if (localValue->isValueID() && localValue->valueID() == CSSValueNone)
         paintType = url.isEmpty() ? SVGPaintType::None : SVGPaintType::URINone;
     else if (localValue->isValueID() && localValue->valueID() == CSSValueCurrentcolor) {
-        color = styleResolver.style()->color();
+        color = builderState.style().color();
         paintType = url.isEmpty() ? SVGPaintType::CurrentColor : SVGPaintType::URICurrentColor;
     } else {
-        color = styleResolver.colorFromPrimitiveValue(*localValue);
+        color = builderState.colorFromPrimitiveValue(*localValue);
         paintType = url.isEmpty() ? SVGPaintType::RGBColor : SVGPaintType::URIRGBColor;
     }
-    svgStyle.setStrokePaint(paintType, color, url, styleResolver.applyPropertyToRegularStyle(), styleResolver.applyPropertyToVisitedLinkStyle());
+    svgStyle.setStrokePaint(paintType, color, url, builderState.applyPropertyToRegularStyle(), builderState.applyPropertyToVisitedLinkStyle());
 }
 
-inline void StyleBuilderCustom::applyInitialContent(StyleResolver& styleResolver)
+inline void StyleBuilderCustom::applyInitialContent(Style::BuilderState& builderState)
 {
-    styleResolver.style()->clearContent();
+    builderState.style().clearContent();
 }
 
-inline void StyleBuilderCustom::applyInheritContent(StyleResolver&)
+inline void StyleBuilderCustom::applyInheritContent(Style::BuilderState&)
 {
     // FIXME: In CSS3, it will be possible to inherit content. In CSS2 it is not. This
     // note is a reminder that eventually "inherit" needs to be supported.
 }
 
-inline void StyleBuilderCustom::applyValueContent(StyleResolver& styleResolver, CSSValue& value)
+inline void StyleBuilderCustom::applyValueContent(Style::BuilderState& builderState, CSSValue& value)
 {
     if (is<CSSPrimitiveValue>(value)) {
         const auto& primitiveValue = downcast<CSSPrimitiveValue>(value);
         ASSERT_UNUSED(primitiveValue, primitiveValue.valueID() == CSSValueNormal || primitiveValue.valueID() == CSSValueNone);
-        styleResolver.style()->clearContent();
+        builderState.style().clearContent();
         return;
     }
 
@@ -1319,17 +1319,17 @@ inline void StyleBuilderCustom::applyValueContent(StyleResolver& styleResolver,
     for (auto& item : downcast<CSSValueList>(value)) {
         if (is<CSSImageGeneratorValue>(item)) {
             if (is<CSSGradientValue>(item))
-                styleResolver.style()->setContent(StyleGeneratedImage::create(downcast<CSSGradientValue>(item.get()).gradientWithStylesResolved(styleResolver)), didSet);
+                builderState.style().setContent(StyleGeneratedImage::create(downcast<CSSGradientValue>(item.get()).gradientWithStylesResolved(builderState.styleResolver())), didSet);
             else
-                styleResolver.style()->setContent(StyleGeneratedImage::create(downcast<CSSImageGeneratorValue>(item.get())), didSet);
+                builderState.style().setContent(StyleGeneratedImage::create(downcast<CSSImageGeneratorValue>(item.get())), didSet);
             didSet = true;
         } else if (is<CSSImageSetValue>(item)) {
-            styleResolver.style()->setContent(StyleCachedImage::create(item), didSet);
+            builderState.style().setContent(StyleCachedImage::create(item), didSet);
             didSet = true;
         }
 
         if (is<CSSImageValue>(item)) {
-            styleResolver.style()->setContent(StyleCachedImage::create(item), didSet);
+            builderState.style().setContent(StyleCachedImage::create(item), didSet);
             didSet = true;
             continue;
         }
@@ -1339,20 +1339,20 @@ inline void StyleBuilderCustom::applyValueContent(StyleResolver& styleResolver,
 
         auto& contentValue = downcast<CSSPrimitiveValue>(item.get());
         if (contentValue.isString()) {
-            styleResolver.style()->setContent(contentValue.stringValue().impl(), didSet);
+            builderState.style().setContent(contentValue.stringValue().impl(), didSet);
             didSet = true;
         } else if (contentValue.isAttr()) {
             // FIXME: Can a namespace be specified for an attr(foo)?
-            if (styleResolver.style()->styleType() == PseudoId::None)
-                styleResolver.style()->setHasAttrContent();
+            if (builderState.style().styleType() == PseudoId::None)
+                builderState.style().setHasAttrContent();
             else
-                const_cast<RenderStyle*>(styleResolver.parentStyle())->setHasAttrContent();
+                const_cast<RenderStyle&>(builderState.parentStyle()).setHasAttrContent();
             QualifiedName attr(nullAtom(), contentValue.stringValue().impl(), nullAtom());
-            const AtomString& value = styleResolver.element()->getAttribute(attr);
-            styleResolver.style()->setContent(value.isNull() ? emptyAtom() : value.impl(), didSet);
+            const AtomString& value = builderState.element() ? builderState.element()->getAttribute(attr) : nullAtom();
+            builderState.style().setContent(value.isNull() ? emptyAtom() : value.impl(), didSet);
             didSet = true;
             // Register the fact that the attribute value affects the style.
-            styleResolver.ruleSets().mutableFeatures().registerContentAttribute(attr.localName());
+            builderState.styleResolver().ruleSets().mutableFeatures().registerContentAttribute(attr.localName());
         } else if (contentValue.isCounter()) {
             auto* counterValue = contentValue.counterValue();
             ListStyleType listStyleType = ListStyleType::None;
@@ -1360,24 +1360,24 @@ inline void StyleBuilderCustom::applyValueContent(StyleResolver& styleResolver,
             if (listStyleIdent != CSSValueNone)
                 listStyleType = static_cast<ListStyleType>(listStyleIdent - CSSValueDisc);
             auto counter = makeUnique<CounterContent>(counterValue->identifier(), listStyleType, counterValue->separator());
-            styleResolver.style()->setContent(WTFMove(counter), didSet);
+            builderState.style().setContent(WTFMove(counter), didSet);
             didSet = true;
         } else {
             switch (contentValue.valueID()) {
             case CSSValueOpenQuote:
-                styleResolver.style()->setContent(QuoteType::OpenQuote, didSet);
+                builderState.style().setContent(QuoteType::OpenQuote, didSet);
                 didSet = true;
                 break;
             case CSSValueCloseQuote:
-                styleResolver.style()->setContent(QuoteType::CloseQuote, didSet);
+                builderState.style().setContent(QuoteType::CloseQuote, didSet);
                 didSet = true;
                 break;
             case CSSValueNoOpenQuote:
-                styleResolver.style()->setContent(QuoteType::NoOpenQuote, didSet);
+                builderState.style().setContent(QuoteType::NoOpenQuote, didSet);
                 didSet = true;
                 break;
             case CSSValueNoCloseQuote:
-                styleResolver.style()->setContent(QuoteType::NoCloseQuote, didSet);
+                builderState.style().setContent(QuoteType::NoCloseQuote, didSet);
                 didSet = true;
                 break;
             default:
@@ -1387,127 +1387,127 @@ inline void StyleBuilderCustom::applyValueContent(StyleResolver& styleResolver,
         }
     }
     if (!didSet)
-        styleResolver.style()->clearContent();
+        builderState.style().clearContent();
 }
 
-inline void StyleBuilderCustom::applyInheritFontVariantLigatures(StyleResolver& styleResolver)
+inline void StyleBuilderCustom::applyInheritFontVariantLigatures(Style::BuilderState& builderState)
 {
-    auto fontDescription = styleResolver.fontDescription();
-    fontDescription.setVariantCommonLigatures(styleResolver.parentFontDescription().variantCommonLigatures());
-    fontDescription.setVariantDiscretionaryLigatures(styleResolver.parentFontDescription().variantDiscretionaryLigatures());
-    fontDescription.setVariantHistoricalLigatures(styleResolver.parentFontDescription().variantHistoricalLigatures());
-    fontDescription.setVariantContextualAlternates(styleResolver.parentFontDescription().variantContextualAlternates());
-    styleResolver.setFontDescription(WTFMove(fontDescription));
+    auto fontDescription = builderState.fontDescription();
+    fontDescription.setVariantCommonLigatures(builderState.parentFontDescription().variantCommonLigatures());
+    fontDescription.setVariantDiscretionaryLigatures(builderState.parentFontDescription().variantDiscretionaryLigatures());
+    fontDescription.setVariantHistoricalLigatures(builderState.parentFontDescription().variantHistoricalLigatures());
+    fontDescription.setVariantContextualAlternates(builderState.parentFontDescription().variantContextualAlternates());
+    builderState.setFontDescription(WTFMove(fontDescription));
 }
 
-inline void StyleBuilderCustom::applyInitialFontVariantLigatures(StyleResolver& styleResolver)
+inline void StyleBuilderCustom::applyInitialFontVariantLigatures(Style::BuilderState& builderState)
 {
-    auto fontDescription = styleResolver.fontDescription();
+    auto fontDescription = builderState.fontDescription();
     fontDescription.setVariantCommonLigatures(FontVariantLigatures::Normal);
     fontDescription.setVariantDiscretionaryLigatures(FontVariantLigatures::Normal);
     fontDescription.setVariantHistoricalLigatures(FontVariantLigatures::Normal);
     fontDescription.setVariantContextualAlternates(FontVariantLigatures::Normal);
-    styleResolver.setFontDescription(WTFMove(fontDescription));
+    builderState.setFontDescription(WTFMove(fontDescription));
 }
 
-inline void StyleBuilderCustom::applyValueFontVariantLigatures(StyleResolver& styleResolver, CSSValue& value)
+inline void StyleBuilderCustom::applyValueFontVariantLigatures(Style::BuilderState& builderState, CSSValue& value)
 {
-    auto fontDescription = styleResolver.fontDescription();
+    auto fontDescription = builderState.fontDescription();
     auto variantLigatures = extractFontVariantLigatures(value);
     fontDescription.setVariantCommonLigatures(variantLigatures.commonLigatures);
     fontDescription.setVariantDiscretionaryLigatures(variantLigatures.discretionaryLigatures);
     fontDescription.setVariantHistoricalLigatures(variantLigatures.historicalLigatures);
     fontDescription.setVariantContextualAlternates(variantLigatures.contextualAlternates);
-    styleResolver.setFontDescription(WTFMove(fontDescription));
+    builderState.setFontDescription(WTFMove(fontDescription));
 }
 
-inline void StyleBuilderCustom::applyInheritFontVariantNumeric(StyleResolver& styleResolver)
+inline void StyleBuilderCustom::applyInheritFontVariantNumeric(Style::BuilderState& builderState)
 {
-    auto fontDescription = styleResolver.fontDescription();
-    fontDescription.setVariantNumericFigure(styleResolver.parentFontDescription().variantNumericFigure());
-    fontDescription.setVariantNumericSpacing(styleResolver.parentFontDescription().variantNumericSpacing());
-    fontDescription.setVariantNumericFraction(styleResolver.parentFontDescription().variantNumericFraction());
-    fontDescription.setVariantNumericOrdinal(styleResolver.parentFontDescription().variantNumericOrdinal());
-    fontDescription.setVariantNumericSlashedZero(styleResolver.parentFontDescription().variantNumericSlashedZero());
-    styleResolver.setFontDescription(WTFMove(fontDescription));
+    auto fontDescription = builderState.fontDescription();
+    fontDescription.setVariantNumericFigure(builderState.parentFontDescription().variantNumericFigure());
+    fontDescription.setVariantNumericSpacing(builderState.parentFontDescription().variantNumericSpacing());
+    fontDescription.setVariantNumericFraction(builderState.parentFontDescription().variantNumericFraction());
+    fontDescription.setVariantNumericOrdinal(builderState.parentFontDescription().variantNumericOrdinal());
+    fontDescription.setVariantNumericSlashedZero(builderState.parentFontDescription().variantNumericSlashedZero());
+    builderState.setFontDescription(WTFMove(fontDescription));
 }
 
-inline void StyleBuilderCustom::applyInitialFontVariantNumeric(StyleResolver& styleResolver)
+inline void StyleBuilderCustom::applyInitialFontVariantNumeric(Style::BuilderState& builderState)
 {
-    auto fontDescription = styleResolver.fontDescription();
+    auto fontDescription = builderState.fontDescription();
     fontDescription.setVariantNumericFigure(FontVariantNumericFigure::Normal);
     fontDescription.setVariantNumericSpacing(FontVariantNumericSpacing::Normal);
     fontDescription.setVariantNumericFraction(FontVariantNumericFraction::Normal);
     fontDescription.setVariantNumericOrdinal(FontVariantNumericOrdinal::Normal);
     fontDescription.setVariantNumericSlashedZero(FontVariantNumericSlashedZero::Normal);
-    styleResolver.setFontDescription(WTFMove(fontDescription));
+    builderState.setFontDescription(WTFMove(fontDescription));
 }
 
-inline void StyleBuilderCustom::applyValueFontVariantNumeric(StyleResolver& styleResolver, CSSValue& value)
+inline void StyleBuilderCustom::applyValueFontVariantNumeric(Style::BuilderState& builderState, CSSValue& value)
 {
-    auto fontDescription = styleResolver.fontDescription();
+    auto fontDescription = builderState.fontDescription();
     auto variantNumeric = extractFontVariantNumeric(value);
     fontDescription.setVariantNumericFigure(variantNumeric.figure);
     fontDescription.setVariantNumericSpacing(variantNumeric.spacing);
     fontDescription.setVariantNumericFraction(variantNumeric.fraction);
     fontDescription.setVariantNumericOrdinal(variantNumeric.ordinal);
     fontDescription.setVariantNumericSlashedZero(variantNumeric.slashedZero);
-    styleResolver.setFontDescription(WTFMove(fontDescription));
+    builderState.setFontDescription(WTFMove(fontDescription));
 }
 
-inline void StyleBuilderCustom::applyInheritFontVariantEastAsian(StyleResolver& styleResolver)
+inline void StyleBuilderCustom::applyInheritFontVariantEastAsian(Style::BuilderState& builderState)
 {
-    auto fontDescription = styleResolver.fontDescription();
-    fontDescription.setVariantEastAsianVariant(styleResolver.parentFontDescription().variantEastAsianVariant());
-    fontDescription.setVariantEastAsianWidth(styleResolver.parentFontDescription().variantEastAsianWidth());
-    fontDescription.setVariantEastAsianRuby(styleResolver.parentFontDescription().variantEastAsianRuby());
-    styleResolver.setFontDescription(WTFMove(fontDescription));
+    auto fontDescription = builderState.fontDescription();
+    fontDescription.setVariantEastAsianVariant(builderState.parentFontDescription().variantEastAsianVariant());
+    fontDescription.setVariantEastAsianWidth(builderState.parentFontDescription().variantEastAsianWidth());
+    fontDescription.setVariantEastAsianRuby(builderState.parentFontDescription().variantEastAsianRuby());
+    builderState.setFontDescription(WTFMove(fontDescription));
 }
 
-inline void StyleBuilderCustom::applyInitialFontVariantEastAsian(StyleResolver& styleResolver)
+inline void StyleBuilderCustom::applyInitialFontVariantEastAsian(Style::BuilderState& builderState)
 {
-    auto fontDescription = styleResolver.fontDescription();
+    auto fontDescription = builderState.fontDescription();
     fontDescription.setVariantEastAsianVariant(FontVariantEastAsianVariant::Normal);
     fontDescription.setVariantEastAsianWidth(FontVariantEastAsianWidth::Normal);
     fontDescription.setVariantEastAsianRuby(FontVariantEastAsianRuby::Normal);
-    styleResolver.setFontDescription(WTFMove(fontDescription));
+    builderState.setFontDescription(WTFMove(fontDescription));
 }
 
-inline void StyleBuilderCustom::applyValueFontVariantEastAsian(StyleResolver& styleResolver, CSSValue& value)
+inline void StyleBuilderCustom::applyValueFontVariantEastAsian(Style::BuilderState& builderState, CSSValue& value)
 {
-    auto fontDescription = styleResolver.fontDescription();
+    auto fontDescription = builderState.fontDescription();
     auto variantEastAsian = extractFontVariantEastAsian(value);
     fontDescription.setVariantEastAsianVariant(variantEastAsian.variant);
     fontDescription.setVariantEastAsianWidth(variantEastAsian.width);
     fontDescription.setVariantEastAsianRuby(variantEastAsian.ruby);
-    styleResolver.setFontDescription(WTFMove(fontDescription));
+    builderState.setFontDescription(WTFMove(fontDescription));
 }
 
-inline void StyleBuilderCustom::applyInitialFontSize(StyleResolver& styleResolver)
+inline void StyleBuilderCustom::applyInitialFontSize(Style::BuilderState& builderState)
 {
-    auto fontDescription = styleResolver.style()->fontDescription();
-    float size = Style::fontSizeForKeyword(CSSValueMedium, fontDescription.useFixedDefaultSize(), styleResolver.document());
+    auto fontDescription = builderState.style().fontDescription();
+    float size = Style::fontSizeForKeyword(CSSValueMedium, fontDescription.useFixedDefaultSize(), builderState.document());
 
     if (size < 0)
         return;
 
     fontDescription.setKeywordSizeFromIdentifier(CSSValueMedium);
-    styleResolver.setFontSize(fontDescription, size);
-    styleResolver.setFontDescription(WTFMove(fontDescription));
+    builderState.setFontSize(fontDescription, size);
+    builderState.setFontDescription(WTFMove(fontDescription));
 }
 
-inline void StyleBuilderCustom::applyInheritFontSize(StyleResolver& styleResolver)
+inline void StyleBuilderCustom::applyInheritFontSize(Style::BuilderState& builderState)
 {
-    const auto& parentFontDescription = styleResolver.parentStyle()->fontDescription();
+    const auto& parentFontDescription = builderState.parentStyle().fontDescription();
     float size = parentFontDescription.specifiedSize();
 
     if (size < 0)
         return;
 
-    auto fontDescription = styleResolver.style()->fontDescription();
+    auto fontDescription = builderState.style().fontDescription();
     fontDescription.setKeywordSize(parentFontDescription.keywordSize());
-    styleResolver.setFontSize(fontDescription, size);
-    styleResolver.setFontDescription(WTFMove(fontDescription));
+    builderState.setFontSize(fontDescription, size);
+    builderState.setFontDescription(WTFMove(fontDescription));
 }
 
 // When the CSS keyword "larger" is used, this function will attempt to match within the keyword
@@ -1527,15 +1527,15 @@ inline float StyleBuilderCustom::smallerFontSize(float size)
     return size / 1.2f;
 }
 
-inline float StyleBuilderCustom::determineRubyTextSizeMultiplier(StyleResolver& styleResolver)
+inline float StyleBuilderCustom::determineRubyTextSizeMultiplier(Style::BuilderState& builderState)
 {
-    if (styleResolver.style()->rubyPosition() != RubyPosition::InterCharacter)
+    if (builderState.style().rubyPosition() != RubyPosition::InterCharacter)
         return 0.5f;
 
     // FIXME: This hack is to ensure tone marks are the same size as
     // the bopomofo. This code will go away if we make a special renderer
     // for the tone marks eventually.
-    if (auto* element = styleResolver.state().element()) {
+    if (auto* element = builderState.element()) {
         for (auto& ancestor : ancestorsOfType<HTMLElement>(*element)) {
             if (ancestor.hasTagName(HTMLNames::rtTag))
                 return 1.0f;
@@ -1544,42 +1544,38 @@ inline float StyleBuilderCustom::determineRubyTextSizeMultiplier(StyleResolver&
     return 0.25f;
 }
 
-inline void StyleBuilderCustom::applyInitialFontStyle(StyleResolver& styleResolver)
+inline void StyleBuilderCustom::applyInitialFontStyle(Style::BuilderState& builderState)
 {
-    auto fontDescription = styleResolver.fontDescription();
+    auto fontDescription = builderState.fontDescription();
     fontDescription.setItalic(FontCascadeDescription::initialItalic());
     fontDescription.setFontStyleAxis(FontCascadeDescription::initialFontStyleAxis());
-    styleResolver.setFontDescription(WTFMove(fontDescription));
+    builderState.setFontDescription(WTFMove(fontDescription));
 }
 
-inline void StyleBuilderCustom::applyInheritFontStyle(StyleResolver& styleResolver)
+inline void StyleBuilderCustom::applyInheritFontStyle(Style::BuilderState& builderState)
 {
-    auto fontDescription = styleResolver.fontDescription();
-    fontDescription.setItalic(styleResolver.parentFontDescription().italic());
-    fontDescription.setFontStyleAxis(styleResolver.parentFontDescription().fontStyleAxis());
-    styleResolver.setFontDescription(WTFMove(fontDescription));
+    auto fontDescription = builderState.fontDescription();
+    fontDescription.setItalic(builderState.parentFontDescription().italic());
+    fontDescription.setFontStyleAxis(builderState.parentFontDescription().fontStyleAxis());
+    builderState.setFontDescription(WTFMove(fontDescription));
 }
 
-inline void StyleBuilderCustom::applyValueFontStyle(StyleResolver& styleResolver, CSSValue& value)
+inline void StyleBuilderCustom::applyValueFontStyle(Style::BuilderState& builderState, CSSValue& value)
 {
     auto& fontStyleValue = downcast<CSSFontStyleValue>(value);
-    auto fontDescription = styleResolver.fontDescription();
+    auto fontDescription = builderState.fontDescription();
     fontDescription.setItalic(StyleBuilderConverter::convertFontStyleFromValue(fontStyleValue));
     fontDescription.setFontStyleAxis(fontStyleValue.fontStyleValue->valueID() == CSSValueItalic ? FontStyleAxis::ital : FontStyleAxis::slnt);
-    styleResolver.setFontDescription(WTFMove(fontDescription));
+    builderState.setFontDescription(WTFMove(fontDescription));
 }
 
-inline void StyleBuilderCustom::applyValueFontSize(StyleResolver& styleResolver, CSSValue& value)
+inline void StyleBuilderCustom::applyValueFontSize(Style::BuilderState& builderState, CSSValue& value)
 {
-    auto fontDescription = styleResolver.style()->fontDescription();
+    auto fontDescription = builderState.style().fontDescription();
     fontDescription.setKeywordSizeFromIdentifier(CSSValueInvalid);
 
-    float parentSize = 0;
-    bool parentIsAbsoluteSize = false;
-    if (auto* parentStyle = styleResolver.parentStyle()) {
-        parentSize = parentStyle->fontDescription().specifiedSize();
-        parentIsAbsoluteSize = parentStyle->fontDescription().isAbsoluteSize();
-    }
+    float parentSize = builderState.parentStyle().fontDescription().specifiedSize();
+    bool parentIsAbsoluteSize = builderState.parentStyle().fontDescription().isAbsoluteSize();
 
     auto& primitiveValue = downcast<CSSPrimitiveValue>(value);
     float size;
@@ -1596,7 +1592,7 @@ inline void StyleBuilderCustom::applyValueFontSize(StyleResolver& styleResolver,
         case CSSValueXLarge:
         case CSSValueXxLarge:
         case CSSValueWebkitXxxLarge:
-            size = Style::fontSizeForKeyword(ident, fontDescription.useFixedDefaultSize(), styleResolver.document());
+            size = Style::fontSizeForKeyword(ident, fontDescription.useFixedDefaultSize(), builderState.document());
             fontDescription.setKeywordSizeFromIdentifier(ident);
             break;
         case CSSValueLarger:
@@ -1606,7 +1602,7 @@ inline void StyleBuilderCustom::applyValueFontSize(StyleResolver& styleResolver,
             size = smallerFontSize(parentSize);
             break;
         case CSSValueWebkitRubyText:
-            size = determineRubyTextSizeMultiplier(styleResolver) * parentSize;
+            size = determineRubyTextSizeMultiplier(builderState) * parentSize;
             break;
         default:
             return;
@@ -1614,13 +1610,13 @@ inline void StyleBuilderCustom::applyValueFontSize(StyleResolver& styleResolver,
     } else {
         fontDescription.setIsAbsoluteSize(parentIsAbsoluteSize || !(primitiveValue.isPercentage() || primitiveValue.isFontRelativeLength()));
         if (primitiveValue.isLength()) {
-            size = primitiveValue.computeLength<float>(CSSToLengthConversionData(styleResolver.parentStyle(), styleResolver.rootElementStyle(), styleResolver.document().renderView(), 1.0f, true));
-            styleResolver.state().setFontSizeHasViewportUnits(primitiveValue.isViewportPercentageLength());
+            size = primitiveValue.computeLength<float>(CSSToLengthConversionData(&builderState.parentStyle(), &builderState.rootElementStyle(), builderState.document().renderView(), 1.0f, true));
+            builderState.styleResolver().state().setFontSizeHasViewportUnits(primitiveValue.isViewportPercentageLength());
         } else if (primitiveValue.isPercentage())
             size = (primitiveValue.floatValue() * parentSize) / 100.0f;
         else if (primitiveValue.isCalculatedPercentageWithLength()) {
-            const auto& conversionData = styleResolver.state().cssToLengthConversionData();
-            CSSToLengthConversionData parentConversionData { styleResolver.parentStyle(), conversionData.rootStyle(), styleResolver.document().renderView(), 1.0f, true };
+            const auto& conversionData = builderState.cssToLengthConversionData();
+            CSSToLengthConversionData parentConversionData { &builderState.parentStyle(), conversionData.rootStyle(), builderState.document().renderView(), 1.0f, true };
             size = primitiveValue.cssCalcValue()->createCalculationValue(parentConversionData)->evaluate(parentSize);
         } else
             return;
@@ -1629,25 +1625,25 @@ inline void StyleBuilderCustom::applyValueFontSize(StyleResolver& styleResolver,
     if (size < 0)
         return;
 
-    styleResolver.setFontSize(fontDescription, std::min(maximumAllowedFontSize, size));
-    styleResolver.setFontDescription(WTFMove(fontDescription));
+    builderState.setFontSize(fontDescription, std::min(maximumAllowedFontSize, size));
+    builderState.setFontDescription(WTFMove(fontDescription));
 }
 
-inline void StyleBuilderCustom::applyInitialGridTemplateAreas(StyleResolver& styleResolver)
+inline void StyleBuilderCustom::applyInitialGridTemplateAreas(Style::BuilderState& builderState)
 {
-    styleResolver.style()->setNamedGridArea(RenderStyle::initialNamedGridArea());
-    styleResolver.style()->setNamedGridAreaRowCount(RenderStyle::initialNamedGridAreaCount());
-    styleResolver.style()->setNamedGridAreaColumnCount(RenderStyle::initialNamedGridAreaCount());
+    builderState.style().setNamedGridArea(RenderStyle::initialNamedGridArea());
+    builderState.style().setNamedGridAreaRowCount(RenderStyle::initialNamedGridAreaCount());
+    builderState.style().setNamedGridAreaColumnCount(RenderStyle::initialNamedGridAreaCount());
 }
 
-inline void StyleBuilderCustom::applyInheritGridTemplateAreas(StyleResolver& styleResolver)
+inline void StyleBuilderCustom::applyInheritGridTemplateAreas(Style::BuilderState& builderState)
 {
-    styleResolver.style()->setNamedGridArea(styleResolver.parentStyle()->namedGridArea());
-    styleResolver.style()->setNamedGridAreaRowCount(styleResolver.parentStyle()->namedGridAreaRowCount());
-    styleResolver.style()->setNamedGridAreaColumnCount(styleResolver.parentStyle()->namedGridAreaColumnCount());
+    builderState.style().setNamedGridArea(builderState.parentStyle().namedGridArea());
+    builderState.style().setNamedGridAreaRowCount(builderState.parentStyle().namedGridAreaRowCount());
+    builderState.style().setNamedGridAreaColumnCount(builderState.parentStyle().namedGridAreaColumnCount());
 }
 
-inline void StyleBuilderCustom::applyValueGridTemplateAreas(StyleResolver& styleResolver, CSSValue& value)
+inline void StyleBuilderCustom::applyValueGridTemplateAreas(Style::BuilderState& builderState, CSSValue& value)
 {
     if (is<CSSPrimitiveValue>(value)) {
         ASSERT(downcast<CSSPrimitiveValue>(value).valueID() == CSSValueNone);
@@ -1657,108 +1653,108 @@ inline void StyleBuilderCustom::applyValueGridTemplateAreas(StyleResolver& style
     auto& gridTemplateAreasValue = downcast<CSSGridTemplateAreasValue>(value);
     const NamedGridAreaMap& newNamedGridAreas = gridTemplateAreasValue.gridAreaMap();
 
-    NamedGridLinesMap namedGridColumnLines = styleResolver.style()->namedGridColumnLines();
-    NamedGridLinesMap namedGridRowLines = styleResolver.style()->namedGridRowLines();
+    NamedGridLinesMap namedGridColumnLines = builderState.style().namedGridColumnLines();
+    NamedGridLinesMap namedGridRowLines = builderState.style().namedGridRowLines();
     StyleBuilderConverter::createImplicitNamedGridLinesFromGridArea(newNamedGridAreas, namedGridColumnLines, ForColumns);
     StyleBuilderConverter::createImplicitNamedGridLinesFromGridArea(newNamedGridAreas, namedGridRowLines, ForRows);
-    styleResolver.style()->setNamedGridColumnLines(namedGridColumnLines);
-    styleResolver.style()->setNamedGridRowLines(namedGridRowLines);
+    builderState.style().setNamedGridColumnLines(namedGridColumnLines);
+    builderState.style().setNamedGridRowLines(namedGridRowLines);
 
-    styleResolver.style()->setNamedGridArea(gridTemplateAreasValue.gridAreaMap());
-    styleResolver.style()->setNamedGridAreaRowCount(gridTemplateAreasValue.rowCount());
-    styleResolver.style()->setNamedGridAreaColumnCount(gridTemplateAreasValue.columnCount());
+    builderState.style().setNamedGridArea(gridTemplateAreasValue.gridAreaMap());
+    builderState.style().setNamedGridAreaRowCount(gridTemplateAreasValue.rowCount());
+    builderState.style().setNamedGridAreaColumnCount(gridTemplateAreasValue.columnCount());
 }
 
-inline void StyleBuilderCustom::applyInitialGridTemplateColumns(StyleResolver& styleResolver)
+inline void StyleBuilderCustom::applyInitialGridTemplateColumns(Style::BuilderState& builderState)
 {
-    styleResolver.style()->setGridColumns(RenderStyle::initialGridColumns());
-    styleResolver.style()->setNamedGridColumnLines(RenderStyle::initialNamedGridColumnLines());
-    styleResolver.style()->setOrderedNamedGridColumnLines(RenderStyle::initialOrderedNamedGridColumnLines());
+    builderState.style().setGridColumns(RenderStyle::initialGridColumns());
+    builderState.style().setNamedGridColumnLines(RenderStyle::initialNamedGridColumnLines());
+    builderState.style().setOrderedNamedGridColumnLines(RenderStyle::initialOrderedNamedGridColumnLines());
 }
 
-inline void StyleBuilderCustom::applyInheritGridTemplateColumns(StyleResolver& styleResolver)
+inline void StyleBuilderCustom::applyInheritGridTemplateColumns(Style::BuilderState& builderState)
 {
-    styleResolver.style()->setGridColumns(styleResolver.parentStyle()->gridColumns());
-    styleResolver.style()->setNamedGridColumnLines(styleResolver.parentStyle()->namedGridColumnLines());
-    styleResolver.style()->setOrderedNamedGridColumnLines(styleResolver.parentStyle()->orderedNamedGridColumnLines());
+    builderState.style().setGridColumns(builderState.parentStyle().gridColumns());
+    builderState.style().setNamedGridColumnLines(builderState.parentStyle().namedGridColumnLines());
+    builderState.style().setOrderedNamedGridColumnLines(builderState.parentStyle().orderedNamedGridColumnLines());
 }
 
 #define SET_TRACKS_DATA(tracksData, style, TrackType) \
-    style->setGrid##TrackType##s(tracksData.m_trackSizes); \
-    style->setNamedGrid##TrackType##Lines(tracksData.m_namedGridLines); \
-    style->setOrderedNamedGrid##TrackType##Lines(tracksData.m_orderedNamedGridLines); \
-    style->setGridAutoRepeat##TrackType##s(tracksData.m_autoRepeatTrackSizes); \
-    style->setGridAutoRepeat##TrackType##sInsertionPoint(tracksData.m_autoRepeatInsertionPoint); \
-    style->setAutoRepeatNamedGrid##TrackType##Lines(tracksData.m_autoRepeatNamedGridLines); \
-    style->setAutoRepeatOrderedNamedGrid##TrackType##Lines(tracksData.m_autoRepeatOrderedNamedGridLines); \
-    style->setGridAutoRepeat##TrackType##sType(tracksData.m_autoRepeatType); \
-    style->setGridAutoRepeat##TrackType##sInsertionPoint(tracksData.m_autoRepeatInsertionPoint);
-
-inline void StyleBuilderCustom::applyValueGridTemplateColumns(StyleResolver& styleResolver, CSSValue& value)
+    style.setGrid##TrackType##s(tracksData.m_trackSizes); \
+    style.setNamedGrid##TrackType##Lines(tracksData.m_namedGridLines); \
+    style.setOrderedNamedGrid##TrackType##Lines(tracksData.m_orderedNamedGridLines); \
+    style.setGridAutoRepeat##TrackType##s(tracksData.m_autoRepeatTrackSizes); \
+    style.setGridAutoRepeat##TrackType##sInsertionPoint(tracksData.m_autoRepeatInsertionPoint); \
+    style.setAutoRepeatNamedGrid##TrackType##Lines(tracksData.m_autoRepeatNamedGridLines); \
+    style.setAutoRepeatOrderedNamedGrid##TrackType##Lines(tracksData.m_autoRepeatOrderedNamedGridLines); \
+    style.setGridAutoRepeat##TrackType##sType(tracksData.m_autoRepeatType); \
+    style.setGridAutoRepeat##TrackType##sInsertionPoint(tracksData.m_autoRepeatInsertionPoint);
+
+inline void StyleBuilderCustom::applyValueGridTemplateColumns(Style::BuilderState& builderState, CSSValue& value)
 {
     StyleBuilderConverter::TracksData tracksData;
-    if (!StyleBuilderConverter::createGridTrackList(value, tracksData, styleResolver))
+    if (!StyleBuilderConverter::createGridTrackList(value, tracksData, builderState))
         return;
-    const NamedGridAreaMap& namedGridAreas = styleResolver.style()->namedGridArea();
+    const NamedGridAreaMap& namedGridAreas = builderState.style().namedGridArea();
     if (!namedGridAreas.isEmpty())
         StyleBuilderConverter::createImplicitNamedGridLinesFromGridArea(namedGridAreas, tracksData.m_namedGridLines, ForColumns);
 
-    SET_TRACKS_DATA(tracksData, styleResolver.style(), Column);
+    SET_TRACKS_DATA(tracksData, builderState.style(), Column);
 }
 
-inline void StyleBuilderCustom::applyInitialGridTemplateRows(StyleResolver& styleResolver)
+inline void StyleBuilderCustom::applyInitialGridTemplateRows(Style::BuilderState& builderState)
 {
-    styleResolver.style()->setGridRows(RenderStyle::initialGridRows());
-    styleResolver.style()->setNamedGridRowLines(RenderStyle::initialNamedGridRowLines());
-    styleResolver.style()->setOrderedNamedGridRowLines(RenderStyle::initialOrderedNamedGridRowLines());
+    builderState.style().setGridRows(RenderStyle::initialGridRows());
+    builderState.style().setNamedGridRowLines(RenderStyle::initialNamedGridRowLines());
+    builderState.style().setOrderedNamedGridRowLines(RenderStyle::initialOrderedNamedGridRowLines());
 }
 
-inline void StyleBuilderCustom::applyInheritGridTemplateRows(StyleResolver& styleResolver)
+inline void StyleBuilderCustom::applyInheritGridTemplateRows(Style::BuilderState& builderState)
 {
-    styleResolver.style()->setGridRows(styleResolver.parentStyle()->gridRows());
-    styleResolver.style()->setNamedGridRowLines(styleResolver.parentStyle()->namedGridRowLines());
-    styleResolver.style()->setOrderedNamedGridRowLines(styleResolver.parentStyle()->orderedNamedGridRowLines());
+    builderState.style().setGridRows(builderState.parentStyle().gridRows());
+    builderState.style().setNamedGridRowLines(builderState.parentStyle().namedGridRowLines());
+    builderState.style().setOrderedNamedGridRowLines(builderState.parentStyle().orderedNamedGridRowLines());
 }
 
-inline void StyleBuilderCustom::applyValueGridTemplateRows(StyleResolver& styleResolver, CSSValue& value)
+inline void StyleBuilderCustom::applyValueGridTemplateRows(Style::BuilderState& builderState, CSSValue& value)
 {
     StyleBuilderConverter::TracksData tracksData;
-    if (!StyleBuilderConverter::createGridTrackList(value, tracksData, styleResolver))
+    if (!StyleBuilderConverter::createGridTrackList(value, tracksData, builderState))
         return;
-    const NamedGridAreaMap& namedGridAreas = styleResolver.style()->namedGridArea();
+    const NamedGridAreaMap& namedGridAreas = builderState.style().namedGridArea();
     if (!namedGridAreas.isEmpty())
         StyleBuilderConverter::createImplicitNamedGridLinesFromGridArea(namedGridAreas, tracksData.m_namedGridLines, ForRows);
 
-    SET_TRACKS_DATA(tracksData, styleResolver.style(), Row);
+    SET_TRACKS_DATA(tracksData, builderState.style(), Row);
 }
 
-void StyleBuilderCustom::applyValueAlt(StyleResolver& styleResolver, CSSValue& value)
+void StyleBuilderCustom::applyValueAlt(Style::BuilderState& builderState, CSSValue& value)
 {
     auto& primitiveValue = downcast<CSSPrimitiveValue>(value);
     if (primitiveValue.isString())
-        styleResolver.style()->setContentAltText(primitiveValue.stringValue());
+        builderState.style().setContentAltText(primitiveValue.stringValue());
     else if (primitiveValue.isAttr()) {
         // FIXME: Can a namespace be specified for an attr(foo)?
-        if (styleResolver.style()->styleType() == PseudoId::None)
-            styleResolver.style()->setUnique();
+        if (builderState.style().styleType() == PseudoId::None)
+            builderState.style().setUnique();
         else
-            const_cast<RenderStyle*>(styleResolver.parentStyle())->setUnique();
+            const_cast<RenderStyle&>(builderState.parentStyle()).setUnique();
 
         QualifiedName attr(nullAtom(), primitiveValue.stringValue(), nullAtom());
-        const AtomString& value = styleResolver.element()->getAttribute(attr);
-        styleResolver.style()->setContentAltText(value.isNull() ? emptyAtom() : value);
+        const AtomString& value = builderState.element() ? builderState.element()->getAttribute(attr) : nullAtom();
+        builderState.style().setContentAltText(value.isNull() ? emptyAtom() : value);
 
         // Register the fact that the attribute value affects the style.
-        styleResolver.ruleSets().mutableFeatures().registerContentAttribute(attr.localName());
+        builderState.styleResolver().ruleSets().mutableFeatures().registerContentAttribute(attr.localName());
     } else
-        styleResolver.style()->setContentAltText(emptyAtom());
+        builderState.style().setContentAltText(emptyAtom());
 }
 
-inline void StyleBuilderCustom::applyValueWillChange(StyleResolver& styleResolver, CSSValue& value)
+inline void StyleBuilderCustom::applyValueWillChange(Style::BuilderState& builderState, CSSValue& value)
 {
     if (is<CSSPrimitiveValue>(value)) {
         ASSERT(downcast<CSSPrimitiveValue>(value).valueID() == CSSValueAuto);
-        styleResolver.style()->setWillChange(nullptr);
+        builderState.style().setWillChange(nullptr);
         return;
     }
 
@@ -1780,55 +1776,55 @@ inline void StyleBuilderCustom::applyValueWillChange(StyleResolver& styleResolve
             break;
         }
     }
-    styleResolver.style()->setWillChange(WTFMove(willChange));
+    builderState.style().setWillChange(WTFMove(willChange));
 }
 
-inline void StyleBuilderCustom::applyValueStrokeWidth(StyleResolver& styleResolver, CSSValue& value)
+inline void StyleBuilderCustom::applyValueStrokeWidth(Style::BuilderState& builderState, CSSValue& value)
 {
-    styleResolver.style()->setStrokeWidth(StyleBuilderConverter::convertLength(styleResolver, value));
-    styleResolver.style()->setHasExplicitlySetStrokeWidth(true);
+    builderState.style().setStrokeWidth(StyleBuilderConverter::convertLength(builderState, value));
+    builderState.style().setHasExplicitlySetStrokeWidth(true);
 }
 
-inline void StyleBuilderCustom::applyValueStrokeColor(StyleResolver& styleResolver, CSSValue& value)
+inline void StyleBuilderCustom::applyValueStrokeColor(Style::BuilderState& builderState, CSSValue& value)
 {
     auto& primitiveValue = downcast<CSSPrimitiveValue>(value);
-    if (styleResolver.applyPropertyToRegularStyle())
-        styleResolver.style()->setStrokeColor(styleResolver.colorFromPrimitiveValue(primitiveValue, /* forVisitedLink */ false));
-    if (styleResolver.applyPropertyToVisitedLinkStyle())
-        styleResolver.style()->setVisitedLinkStrokeColor(styleResolver.colorFromPrimitiveValue(primitiveValue, /* forVisitedLink */ true));
-    styleResolver.style()->setHasExplicitlySetStrokeColor(true);
+    if (builderState.applyPropertyToRegularStyle())
+        builderState.style().setStrokeColor(builderState.colorFromPrimitiveValue(primitiveValue, /* forVisitedLink */ false));
+    if (builderState.applyPropertyToVisitedLinkStyle())
+        builderState.style().setVisitedLinkStrokeColor(builderState.colorFromPrimitiveValue(primitiveValue, /* forVisitedLink */ true));
+    builderState.style().setHasExplicitlySetStrokeColor(true);
 }
 
-inline void StyleBuilderCustom::applyInitialCustomProperty(StyleResolver& styleResolver, const CSSRegisteredCustomProperty* registered, const AtomString& name)
+inline void StyleBuilderCustom::applyInitialCustomProperty(Style::BuilderState& builderState, const CSSRegisteredCustomProperty* registered, const AtomString& name)
 {
     if (registered && registered->initialValue()) {
         auto initialValue = registered->initialValueCopy();
-        applyValueCustomProperty(styleResolver, registered, *initialValue);
+        applyValueCustomProperty(builderState, registered, *initialValue);
         return;
     }
 
     auto invalid = CSSCustomPropertyValue::createUnresolved(name, CSSValueInvalid);
-    applyValueCustomProperty(styleResolver, registered, invalid.get());
+    applyValueCustomProperty(builderState, registered, invalid.get());
 }
 
-inline void StyleBuilderCustom::applyInheritCustomProperty(StyleResolver& styleResolver, const CSSRegisteredCustomProperty* registered, const AtomString& name)
+inline void StyleBuilderCustom::applyInheritCustomProperty(Style::BuilderState& builderState, const CSSRegisteredCustomProperty* registered, const AtomString& name)
 {
-    auto* parentValue = styleResolver.parentStyle() ? styleResolver.parentStyle()->inheritedCustomProperties().get(name) : nullptr;
+    auto* parentValue = builderState.parentStyle().inheritedCustomProperties().get(name);
     if (parentValue && !(registered && !registered->inherits))
-        applyValueCustomProperty(styleResolver, registered, *parentValue);
+        applyValueCustomProperty(builderState, registered, *parentValue);
     else
-        applyInitialCustomProperty(styleResolver, registered, name);
+        applyInitialCustomProperty(builderState, registered, name);
 }
 
-inline void StyleBuilderCustom::applyValueCustomProperty(StyleResolver& styleResolver, const CSSRegisteredCustomProperty* registered, CSSCustomPropertyValue& value)
+inline void StyleBuilderCustom::applyValueCustomProperty(Style::BuilderState& builderState, const CSSRegisteredCustomProperty* registered, CSSCustomPropertyValue& value)
 {
     ASSERT(value.isResolved());
     const auto& name = value.name();
 
     if (!registered || registered->inherits)
-        styleResolver.style()->setInheritedCustomPropertyValue(name, makeRef(value));
+        builderState.style().setInheritedCustomPropertyValue(name, makeRef(value));
     else
-        styleResolver.style()->setNonInheritedCustomPropertyValue(name, makeRef(value));
+        builderState.style().setNonInheritedCustomPropertyValue(name, makeRef(value));
 }
 
 } // namespace WebCore
index 5867e3e..20cc56b 100644 (file)
@@ -98,6 +98,7 @@
 #include "StyleGeneratedImage.h"
 #include "StyleProperties.h"
 #include "StylePropertyShorthand.h"
+#include "StyleResolveForDocument.h"
 #include "StyleRule.h"
 #include "StyleSheetContents.h"
 #include "TransformFunctions.h"
@@ -143,7 +144,6 @@ StyleResolver::StyleResolver(Document& document)
 #if ENABLE(CSS_DEVICE_ADAPTATION)
     , m_viewportStyleResolver(ViewportStyleResolver::create(&document))
 #endif
-    , m_styleMap(this)
     , m_matchAuthorAndUserStyles(m_document.settings().authorAndUserStylesEnabled())
 {
     Element* root = m_document.documentElement();
@@ -244,7 +244,6 @@ StyleResolver::State::State(const Element& element, const RenderStyle* parentSty
     : m_element(&element)
     , m_parentStyle(parentStyle)
     , m_selectorFilter(selectorFilter)
-    , m_elementLinkState(element.document().visitedLinkState().determineLinkState(element))
 {
     bool resetStyleInheritance = hasShadowRootParent(element) && downcast<ShadowRoot>(element.parentNode())->resetStyleInheritance();
     if (resetStyleInheritance)
@@ -308,7 +307,7 @@ ElementStyle StyleResolver::styleForElement(const Element& element, const Render
 
     if (element.isLink()) {
         style.setIsLink(true);
-        InsideLink linkState = state.elementLinkState();
+        InsideLink linkState = document().visitedLinkState().determineLinkState(element);
         if (linkState != InsideLink::NotInside) {
             bool forceVisited = InspectorInstrumentation::forcePseudoState(element, CSSSelector::PseudoClassVisited);
             if (forceVisited)
@@ -369,7 +368,7 @@ std::unique_ptr<RenderStyle> StyleResolver::styleForKeyframe(const RenderStyle*
     cascade.applyProperties(firstCSSProperty, lastHighPriorityProperty);
 
     // If our font got dirtied, update it now.
-    updateFont();
+    updateFont(cascade);
 
     // Now resolve remaining custom properties and the rest, in any order
     cascade.applyCustomProperties();
@@ -377,7 +376,7 @@ std::unique_ptr<RenderStyle> StyleResolver::styleForKeyframe(const RenderStyle*
     cascade.applyProperties(firstLowPriorityProperty, lastCSSProperty);
 
     // If our font got dirtied by one of the non-essential font props, update it a second time.
-    updateFont();
+    updateFont(cascade);
 
     cascade.applyDeferredProperties();
 
@@ -569,7 +568,7 @@ std::unique_ptr<RenderStyle> StyleResolver::styleForPage(int pageIndex)
     cascade.applyProperties(firstCSSProperty, lastHighPriorityProperty);
 
     // If our font got dirtied, update it now.
-    updateFont();
+    updateFont(cascade);
 
     // Now resolve remaining custom properties and the rest, in any order
     cascade.applyCustomProperties();
@@ -1156,12 +1155,12 @@ static void checkForOrientationChange(RenderStyle& style)
     style.setFontDescription(WTFMove(newFontDescription));
 }
 
-void StyleResolver::updateFont()
+void StyleResolver::updateFont(Style::PropertyCascade& cascade)
 {
-    if (!m_state.fontDirty())
+    auto& style = *m_state.style();
+    if (!cascade.builderState().fontDirty() && style.fontCascade().fonts())
         return;
 
-    auto& style = *m_state.style();
 #if ENABLE(TEXT_AUTOSIZING)
     checkForTextSizeAdjust(style);
 #endif
@@ -1171,7 +1170,8 @@ void StyleResolver::updateFont()
     style.fontCascade().update(&document().fontSelector());
     if (m_state.fontSizeHasViewportUnits())
         style.setHasViewportUnits(true);
-    m_state.setFontDirty(false);
+
+    cascade.builderState().clearFontDirty();
 }
 
 Vector<RefPtr<StyleRule>> StyleResolver::styleRulesForElement(const Element* element, unsigned rulesToInclude)
@@ -1338,7 +1338,7 @@ void StyleResolver::applyMatchedProperties(const MatchResult& matchResult, const
         cascade.applyProperties(firstCSSProperty, lastHighPriorityProperty);
 
         // If our font got dirtied, update it now.
-        updateFont();
+        updateFont(cascade);
 
         // Now resolve remaining custom properties and the rest, in any order
         cascade.applyCustomProperties();
@@ -1365,7 +1365,7 @@ void StyleResolver::applyMatchedProperties(const MatchResult& matchResult, const
         return applyMatchedProperties(matchResult, element, DoNotUseMatchedPropertiesCache);
 
     // If our font got dirtied, update it now.
-    updateFont();
+    updateFont(cascade);
 
     // If the font changed, we can't use the matched properties cache. Start over.
     if (cacheItem && cacheItem->renderStyle->fontDescription() != state.style()->fontDescription())
@@ -1381,7 +1381,7 @@ void StyleResolver::applyMatchedProperties(const MatchResult& matchResult, const
     // so to preserve behavior, we queue them up during cascade and flush here.
     cascade.applyDeferredProperties();
 
-    ASSERT(!state.fontDirty());
+    ASSERT(!cascade.builderState().fontDirty());
 
     if (cacheItem || !cacheHash)
         return;
@@ -1402,10 +1402,11 @@ void StyleResolver::applyPropertyToCurrentStyle(CSSPropertyID id, CSSValue* valu
 {
     if (!value)
         return;
+
     MatchResult matchResult;
     Style::PropertyCascade cascade(*this, matchResult, { });
-    if (value)
-        cascade.applyProperty(id, *value);
+    cascade.applyProperty(id, *value);
+    updateFont(cascade);
 }
 
 // SVG handles zooming in a different way compared to CSS. The whole document is scaled instead
@@ -1516,7 +1517,7 @@ void StyleResolver::initializeFontStyle()
     fontDescription.setKeywordSizeFromIdentifier(CSSValueMedium);
     setFontSize(fontDescription, Style::fontSizeForKeyword(CSSValueMedium, false, document()));
     fontDescription.setShouldAllowUserInstalledFonts(settings().shouldAllowUserInstalledFonts() ? AllowUserInstalledFonts::Yes : AllowUserInstalledFonts::No);
-    setFontDescription(WTFMove(fontDescription));
+    style()->setFontDescription(WTFMove(fontDescription));
 }
 
 void StyleResolver::setFontSize(FontCascadeDescription& fontDescription, float size)
index 270041f..d64c2ce 100644 (file)
@@ -28,7 +28,6 @@
 #include "ElementRuleCollector.h"
 #include "InspectorCSSOMWrappers.h"
 #include "MediaQueryEvaluator.h"
-#include "PropertyCascade.h"
 #include "RenderStyle.h"
 #include "RuleSet.h"
 #include "SelectorChecker.h"
@@ -85,6 +84,10 @@ class SVGSVGElement;
 class ViewportStyleResolver;
 struct ResourceLoaderOptions;
 
+namespace Style {
+class PropertyCascade;
+}
+
 // MatchOnlyUserAgentRules is used in media queries, where relative units
 // are interpreted according to the document root element style, and styled only
 // from the User Agent Stylesheet rules.
@@ -160,7 +163,7 @@ public:
     void applyPropertyToStyle(CSSPropertyID, CSSValue*, std::unique_ptr<RenderStyle>);
     void applyPropertyToCurrentStyle(CSSPropertyID, CSSValue*);
 
-    void updateFont();
+    void updateFont(Style::PropertyCascade&);
     void initializeFontStyle();
 
     void setFontSize(FontCascadeDescription&, float size);
@@ -243,15 +246,6 @@ public:
         const RenderStyle* parentStyle() const { return m_parentStyle; }
         const RenderStyle* rootElementStyle() const { return m_rootElementStyle; }
 
-        InsideLink elementLinkState() const { return m_elementLinkState; }
-
-        void setApplyPropertyToRegularStyle(bool isApply) { m_applyPropertyToRegularStyle = isApply; }
-        void setApplyPropertyToVisitedLinkStyle(bool isApply) { m_applyPropertyToVisitedLinkStyle = isApply; }
-        bool applyPropertyToRegularStyle() const { return m_applyPropertyToRegularStyle; }
-        bool applyPropertyToVisitedLinkStyle() const { return m_applyPropertyToVisitedLinkStyle; }
-
-        void setFontDirty(bool isDirty) { m_fontDirty = isDirty; }
-        bool fontDirty() const { return m_fontDirty; }
         void setFontSizeHasViewportUnits(bool hasViewportUnits) { m_fontSizeHasViewportUnits = hasViewportUnits; }
         bool fontSizeHasViewportUnits() const { return m_fontSizeHasViewportUnits; }
 
@@ -261,23 +255,10 @@ public:
         FillLayer backgroundData() const { return m_backgroundData; }
         const Color& backgroundColor() const { return m_backgroundColor; }
 
-        const FontCascadeDescription& fontDescription() { return m_style->fontDescription(); }
-        const FontCascadeDescription& parentFontDescription() { return m_parentStyle->fontDescription(); }
-        void setFontDescription(FontCascadeDescription&& fontDescription) { m_fontDirty |= m_style->setFontDescription(WTFMove(fontDescription)); }
-        void setZoom(float f) { m_fontDirty |= m_style->setZoom(f); }
-        void setEffectiveZoom(float f) { m_fontDirty |= m_style->setEffectiveZoom(f); }
-        void setWritingMode(WritingMode writingMode) { m_fontDirty |= m_style->setWritingMode(writingMode); }
-        void setTextOrientation(TextOrientation textOrientation) { m_fontDirty |= m_style->setTextOrientation(textOrientation); }
-
         bool useSVGZoomRules() const { return m_element && m_element->isSVGElement(); }
 
         const CSSToLengthConversionData& cssToLengthConversionData() const { return m_cssToLengthConversionData; }
 
-        Style::CascadeLevel cascadeLevel() const { return m_cascadeLevel; }
-        void setCascadeLevel(Style::CascadeLevel level) { m_cascadeLevel = level; }
-        Style::ScopeOrdinal styleScopeOrdinal() const { return m_styleScopeOrdinal; }
-        void setStyleScopeOrdinal(Style::ScopeOrdinal styleScopeOrdinal) { m_styleScopeOrdinal = styleScopeOrdinal; }
-
         const SelectorFilter* selectorFilter() const { return m_selectorFilter; }
         
     private:
@@ -297,14 +278,6 @@ public:
 
         CSSToLengthConversionData m_cssToLengthConversionData;
 
-        Style::ScopeOrdinal m_styleScopeOrdinal { Style::ScopeOrdinal::Element };
-
-        InsideLink m_elementLinkState { InsideLink::NotInside };
-        Style::CascadeLevel m_cascadeLevel { Style::CascadeLevel::UserAgent };
-
-        bool m_applyPropertyToRegularStyle { true };
-        bool m_applyPropertyToVisitedLinkStyle { false };
-        bool m_fontDirty { false };
         bool m_fontSizeHasViewportUnits { false };
         bool m_hasUAAppearance { false };
     };
@@ -314,18 +287,7 @@ public:
 
     RefPtr<StyleImage> styleImage(CSSValue&);
 
-    bool applyPropertyToRegularStyle() const { return m_state.applyPropertyToRegularStyle(); }
-    bool applyPropertyToVisitedLinkStyle() const { return m_state.applyPropertyToVisitedLinkStyle(); }
-
-    CSSToStyleMap* styleMap() { return &m_styleMap; }
     InspectorCSSOMWrappers& inspectorCSSOMWrappers() { return m_inspectorCSSOMWrappers; }
-    const FontCascadeDescription& fontDescription() { return m_state.fontDescription(); }
-    const FontCascadeDescription& parentFontDescription() { return m_state.parentFontDescription(); }
-    void setFontDescription(FontCascadeDescription&& fontDescription) { m_state.setFontDescription(WTFMove(fontDescription)); }
-    void setZoom(float f) { m_state.setZoom(f); }
-    void setEffectiveZoom(float f) { m_state.setEffectiveZoom(f); }
-    void setWritingMode(WritingMode writingMode) { m_state.setWritingMode(writingMode); }
-    void setTextOrientation(TextOrientation textOrientation) { m_state.setTextOrientation(textOrientation); }
 
     bool adjustRenderStyleForTextAutosizing(RenderStyle&, const Element&);
 
@@ -380,7 +342,6 @@ private:
     RefPtr<ViewportStyleResolver> m_viewportStyleResolver;
 #endif
 
-    CSSToStyleMap m_styleMap;
     InspectorCSSOMWrappers m_inspectorCSSOMWrappers;
 
     State m_state;
index bedb824..b1f227d 100755 (executable)
@@ -579,21 +579,21 @@ sub getAutoGetter {
   my $name = shift;
   my $renderStyle = shift;
 
-  return $renderStyle . "->hasAuto" . getNameForMethods($name) . "()";
+  return $renderStyle . ".hasAuto" . getNameForMethods($name) . "()";
 }
 
 sub getAutoSetter {
   my $name = shift;
   my $renderStyle = shift;
 
-  return $renderStyle . "->setHasAuto" . getNameForMethods($name) . "()";
+  return $renderStyle . ".setHasAuto" . getNameForMethods($name) . "()";
 }
 
 sub getVisitedLinkSetter {
   my $name = shift;
   my $renderStyle = shift;
 
-  return $renderStyle . "->setVisitedLink" . getNameForMethods($name);
+  return $renderStyle . ".setVisitedLink" . getNameForMethods($name);
 }
 
 sub getClearFunction {
@@ -699,7 +699,7 @@ sub colorFromPrimitiveValue {
   my $primitiveValue = shift;
   my $forVisitedLink = @_ ? shift : NOT_FOR_VISITED_LINK;
 
-  return "styleResolver.colorFromPrimitiveValue(" . $primitiveValue . ", /* forVisitedLink */ " . ($forVisitedLink ? "true" : "false") . ")";
+  return "builderState.colorFromPrimitiveValue(" . $primitiveValue . ", /* forVisitedLink */ " . ($forVisitedLink ? "true" : "false") . ")";
 }
 
 use constant {
@@ -713,12 +713,12 @@ sub generateColorValueSetter {
   my $indent = shift;
   my $valueIsPrimitive = @_ ? shift : VALUE_IS_COLOR;
 
-  my $style = "styleResolver.style()";
-  my $setterContent .= $indent . "if (styleResolver.applyPropertyToRegularStyle())\n";
-  my $setValue = $style . "->" . $propertiesWithStyleBuilderOptions{$name}{"setter"};
+  my $style = "builderState.style()";
+  my $setterContent .= $indent . "if (builderState.applyPropertyToRegularStyle())\n";
+  my $setValue = $style . "." . $propertiesWithStyleBuilderOptions{$name}{"setter"};
   my $color = $valueIsPrimitive ? colorFromPrimitiveValue($value) : $value;
   $setterContent .= $indent . "    " . $setValue . "(" . $color . ");\n";
-  $setterContent .= $indent . "if (styleResolver.applyPropertyToVisitedLinkStyle())\n";
+  $setterContent .= $indent . "if (builderState.applyPropertyToVisitedLinkStyle())\n";
   $color = $valueIsPrimitive ? colorFromPrimitiveValue($value, FOR_VISITED_LINK) : $value;
   $setterContent .= $indent . "    " . getVisitedLinkSetter($name, $style) . "(" . $color . ");\n";
 
@@ -731,7 +731,7 @@ sub handleCurrentColorValue {
   my $indent = shift;
 
   my $code = $indent . "if (" . $primitiveValue . ".valueID() == CSSValueCurrentcolor) {\n";
-  $code .= $indent . "    applyInherit" . $nameToId{$name} . "(styleResolver);\n";
+  $code .= $indent . "    applyInherit" . $nameToId{$name} . "(builderState);\n";
   $code .= $indent . "    return;\n";
   $code .= $indent . "}\n";
   return $code;
@@ -742,7 +742,7 @@ sub generateAnimationPropertyInitialValueSetter {
   my $indent = shift;
 
   my $setterContent = "";
-  $setterContent .= $indent . "AnimationList& list = styleResolver.style()->" . getEnsureAnimationsOrTransitionsMethod($name) . "();\n";
+  $setterContent .= $indent . "AnimationList& list = builderState.style()." . getEnsureAnimationsOrTransitionsMethod($name) . "();\n";
   $setterContent .= $indent . "if (list.isEmpty())\n";
   $setterContent .= $indent . "    list.append(Animation::create());\n";
   my $setter = $propertiesWithStyleBuilderOptions{$name}{"setter"};
@@ -762,8 +762,8 @@ sub generateAnimationPropertyInheritValueSetter {
   my $indent = shift;
 
   my $setterContent = "";
-  $setterContent .= $indent . "auto& list = styleResolver.style()->" . getEnsureAnimationsOrTransitionsMethod($name) . "();\n";
-  $setterContent .= $indent . "auto* parentList = styleResolver.parentStyle()->" . getAnimationsOrTransitionsMethod($name) . "();\n";
+  $setterContent .= $indent . "auto& list = builderState.style()." . getEnsureAnimationsOrTransitionsMethod($name) . "();\n";
+  $setterContent .= $indent . "auto* parentList = builderState.parentStyle()." . getAnimationsOrTransitionsMethod($name) . "();\n";
   $setterContent .= $indent . "size_t i = 0, parentSize = parentList ? parentList->size() : 0;\n";
   $setterContent .= $indent . "for ( ; i < parentSize && parentList->animation(i)." . getTestFunction($name) . "(); ++i) {\n";
   $setterContent .= $indent . "    if (list.size() <= i)\n";
@@ -786,20 +786,20 @@ sub generateAnimationPropertyValueSetter {
   my $indent = shift;
 
   my $setterContent = "";
-  $setterContent .= $indent . "AnimationList& list = styleResolver.style()->" . getEnsureAnimationsOrTransitionsMethod($name) . "();\n";
+  $setterContent .= $indent . "AnimationList& list = builderState.style()." . getEnsureAnimationsOrTransitionsMethod($name) . "();\n";
   $setterContent .= $indent . "size_t childIndex = 0;\n";
   $setterContent .= $indent . "if (is<CSSValueList>(value)) {\n";
   $setterContent .= $indent . "    /* Walk each value and put it into an animation, creating new animations as needed. */\n";
   $setterContent .= $indent . "    for (auto& currentValue : downcast<CSSValueList>(value)) {\n";
   $setterContent .= $indent . "        if (childIndex <= list.size())\n";
   $setterContent .= $indent . "            list.append(Animation::create());\n";
-  $setterContent .= $indent . "        styleResolver.styleMap()->" . getAnimationMapfunction($name) . "(list.animation(childIndex), currentValue);\n";
+  $setterContent .= $indent . "        builderState.styleMap()." . getAnimationMapfunction($name) . "(list.animation(childIndex), currentValue);\n";
   $setterContent .= $indent . "        ++childIndex;\n";
   $setterContent .= $indent . "    }\n";
   $setterContent .= $indent . "} else {\n";
   $setterContent .= $indent . "    if (list.isEmpty())\n";
   $setterContent .= $indent . "        list.append(Animation::create());\n";
-  $setterContent .= $indent . "    styleResolver.styleMap()->" . getAnimationMapfunction($name) . "(list.animation(childIndex), value);\n";
+  $setterContent .= $indent . "    builderState.styleMap()." . getAnimationMapfunction($name) . "(list.animation(childIndex), value);\n";
   $setterContent .= $indent . "    childIndex = 1;\n";
   $setterContent .= $indent . "}\n";
   $setterContent .= $indent . "for ( ; childIndex < list.size(); ++childIndex) {\n";
@@ -822,11 +822,11 @@ sub generateFillLayerPropertyInitialValueSetter {
 
   my $setterContent = "";
   $setterContent .= $indent . "// Check for (single-layer) no-op before clearing anything.\n";
-  $setterContent .= $indent . "auto& layers = styleResolver.style()->" . getLayersFunction($name) . "();\n";
+  $setterContent .= $indent . "auto& layers = builderState.style()." . getLayersFunction($name) . "();\n";
   $setterContent .= $indent . "if (!layers.next() && (!layers." . $testFunction . "() || layers." . $getter . "() == $initial))\n";
   $setterContent .= $indent . "    return;\n";
   $setterContent .= "\n";
-  $setterContent .= $indent . "auto* child = &styleResolver.style()->" . getLayersAccessorFunction($name) . "();\n";
+  $setterContent .= $indent . "auto* child = &builderState.style()." . getLayersAccessorFunction($name) . "();\n";
   $setterContent .= $indent . "child->" . $setter . "(" . $initial . ");\n";
   $setterContent .= $indent . "for (child = child->next(); child; child = child->next())\n";
   $setterContent .= $indent . "    child->" . $clearFunction . "();\n";
@@ -845,12 +845,12 @@ sub generateFillLayerPropertyInheritValueSetter {
 
   my $setterContent = "";
   $setterContent .= $indent . "// Check for no-op before copying anything.\n";
-  $setterContent .= $indent . "if (styleResolver.parentStyle()->" . getLayersFunction($name) ."() == styleResolver.style()->" . getLayersFunction($name) . "())\n";
+  $setterContent .= $indent . "if (builderState.parentStyle()." . getLayersFunction($name) ."() == builderState.style()." . getLayersFunction($name) . "())\n";
   $setterContent .= $indent . "    return;\n";
   $setterContent .= "\n";
-  $setterContent .= $indent . "auto* child = &styleResolver.style()->" . getLayersAccessorFunction($name) . "();\n";
+  $setterContent .= $indent . "auto* child = &builderState.style()." . getLayersAccessorFunction($name) . "();\n";
   $setterContent .= $indent . "FillLayer* previousChild = nullptr;\n";
-  $setterContent .= $indent . "for (auto* parent = &styleResolver.parentStyle()->" . getLayersFunction($name) . "(); parent && parent->" . $testFunction . "(); parent = parent->next()) {\n";
+  $setterContent .= $indent . "for (auto* parent = &builderState.parentStyle()." . getLayersFunction($name) . "(); parent && parent->" . $testFunction . "(); parent = parent->next()) {\n";
   $setterContent .= $indent . "    if (!child) {\n";
   $setterContent .= $indent . "        previousChild->setNext(makeUnique<FillLayer>(" . getFillLayerType($name) . "));\n";
   $setterContent .= $indent . "        child = previousChild->next();\n";
@@ -872,7 +872,7 @@ sub generateFillLayerPropertyValueSetter {
   my $CSSPropertyId = "CSSProperty" . $nameToId{$name};
 
   my $setterContent = "";
-  $setterContent .= $indent . "auto* child = &styleResolver.style()->" . getLayersAccessorFunction($name) . "();\n";
+  $setterContent .= $indent . "auto* child = &builderState.style()." . getLayersAccessorFunction($name) . "();\n";
   $setterContent .= $indent . "FillLayer* previousChild = nullptr;\n";
   $setterContent .= $indent . "if (is<CSSValueList>(value) && !is<CSSImageSetValue>(value)) {\n";
   $setterContent .= $indent . "    // Walk each value and put it into a layer, creating new layers as needed.\n";
@@ -881,12 +881,12 @@ sub generateFillLayerPropertyValueSetter {
   $setterContent .= $indent . "            previousChild->setNext(makeUnique<FillLayer>(" . getFillLayerType($name) . "));\n";
   $setterContent .= $indent . "            child = previousChild->next();\n";
   $setterContent .= $indent . "        }\n";
-  $setterContent .= $indent . "        styleResolver.styleMap()->" . getFillLayerMapfunction($name) . "(" . $CSSPropertyId . ", *child, item);\n";
+  $setterContent .= $indent . "        builderState.styleMap()." . getFillLayerMapfunction($name) . "(" . $CSSPropertyId . ", *child, item);\n";
   $setterContent .= $indent . "        previousChild = child;\n";
   $setterContent .= $indent . "        child = child->next();\n";
   $setterContent .= $indent . "    }\n";
   $setterContent .= $indent . "} else {\n";
-  $setterContent .= $indent . "    styleResolver.styleMap()->" . getFillLayerMapfunction($name) . "(" . $CSSPropertyId . ", *child, value);\n";
+  $setterContent .= $indent . "    builderState.styleMap()." . getFillLayerMapfunction($name) . "(" . $CSSPropertyId . ", *child, value);\n";
   $setterContent .= $indent . "    child = child->next();\n";
   $setterContent .= $indent . "}\n";
   $setterContent .= $indent . "for (; child; child = child->next())\n";
@@ -902,7 +902,7 @@ sub generateSetValueStatement
 
   my $isSVG = exists $propertiesWithStyleBuilderOptions{$name}{"svg"};
   my $setter = $propertiesWithStyleBuilderOptions{$name}{"setter"};
-  return "styleResolver.style()->" .  ($isSVG ? "accessSVGStyle()." : "") . $setter . "(" . $value . ")";
+  return "builderState.style()." .  ($isSVG ? "accessSVGStyle()." : "") . $setter . "(" . $value . ")";
 }
 
 sub generateInitialValueSetter {
@@ -913,9 +913,9 @@ sub generateInitialValueSetter {
   my $initial = $propertiesWithStyleBuilderOptions{$name}{"initial"};
   my $isSVG = exists $propertiesWithStyleBuilderOptions{$name}{"svg"};
   my $setterContent = "";
-  $setterContent .= $indent . "static void applyInitial" . $nameToId{$name} . "(StyleResolver& styleResolver)\n";
+  $setterContent .= $indent . "static void applyInitial" . $nameToId{$name} . "(Style::BuilderState& builderState)\n";
   $setterContent .= $indent . "{\n";
-  my $style = "styleResolver.style()";
+  my $style = "builderState.style()";
   if (exists $propertiesWithStyleBuilderOptions{$name}{"auto-functions"}) {
     $setterContent .= $indent . "    " . getAutoSetter($name, $style) . ";\n";
   } elsif (exists $propertiesWithStyleBuilderOptions{$name}{"visited-link-color-support"}) {
@@ -924,9 +924,9 @@ sub generateInitialValueSetter {
   } elsif (exists $propertiesWithStyleBuilderOptions{$name}{"animatable"}) {
     $setterContent .= generateAnimationPropertyInitialValueSetter($name, $indent . "    ");
   } elsif (exists $propertiesWithStyleBuilderOptions{$name}{"font-property"}) {
-    $setterContent .= $indent . "    auto fontDescription = styleResolver.fontDescription();\n";
+    $setterContent .= $indent . "    auto fontDescription = builderState.fontDescription();\n";
     $setterContent .= $indent . "    fontDescription." . $setter . "(FontCascadeDescription::" . $initial . "());\n";
-    $setterContent .= $indent . "    styleResolver.setFontDescription(WTFMove(fontDescription));\n";
+    $setterContent .= $indent . "    builderState.setFontDescription(WTFMove(fontDescription));\n";
   } elsif (exists $propertiesWithStyleBuilderOptions{$name}{"fill-layer-property"}) {
     $setterContent .= generateFillLayerPropertyInitialValueSetter($name, $indent . "    ");
   } else {
@@ -943,11 +943,11 @@ sub generateInheritValueSetter {
   my $indent = shift;
 
   my $setterContent = "";
-  $setterContent .= $indent . "static void applyInherit" . $nameToId{$name} . "(StyleResolver& styleResolver)\n";
+  $setterContent .= $indent . "static void applyInherit" . $nameToId{$name} . "(Style::BuilderState& builderState)\n";
   $setterContent .= $indent . "{\n";
   my $isSVG = exists $propertiesWithStyleBuilderOptions{$name}{"svg"};
-  my $parentStyle = "styleResolver.parentStyle()";
-  my $style = "styleResolver.style()";
+  my $parentStyle = "builderState.parentStyle()";
+  my $style = "builderState.style()";
   my $getter = $propertiesWithStyleBuilderOptions{$name}{"getter"};
   my $setter = $propertiesWithStyleBuilderOptions{$name}{"setter"};
   my $didCallSetValue = 0;
@@ -957,10 +957,10 @@ sub generateInheritValueSetter {
     $setterContent .= $indent . "        return;\n";
     $setterContent .= $indent . "    }\n";
   } elsif (exists $propertiesWithStyleBuilderOptions{$name}{"visited-link-color-support"}) {
-    $setterContent .= $indent . "    Color color = " . $parentStyle . "->" . $getter . "();\n";
+    $setterContent .= $indent . "    Color color = " . $parentStyle . "." . $getter . "();\n";
     if (!exists($propertiesWithStyleBuilderOptions{$name}{"no-default-color"})) {
       $setterContent .= $indent . "    if (!color.isValid())\n";
-      $setterContent .= $indent . "        color = " . $parentStyle . "->color();\n";
+      $setterContent .= $indent . "        color = " . $parentStyle . ".color();\n";
     }
     $setterContent .= generateColorValueSetter($name, "color", $indent . "    ");
     $didCallSetValue = 1;
@@ -968,16 +968,16 @@ sub generateInheritValueSetter {
     $setterContent .= generateAnimationPropertyInheritValueSetter($name, $indent . "    ");
     $didCallSetValue = 1;
   } elsif (exists $propertiesWithStyleBuilderOptions{$name}{"font-property"}) {
-    $setterContent .= $indent . "    auto fontDescription = styleResolver.fontDescription();\n";
-    $setterContent .= $indent . "    fontDescription." . $setter . "(styleResolver.parentFontDescription()." . $getter . "());\n";
-    $setterContent .= $indent . "    styleResolver.setFontDescription(WTFMove(fontDescription));\n";
+    $setterContent .= $indent . "    auto fontDescription = builderState.fontDescription();\n";
+    $setterContent .= $indent . "    fontDescription." . $setter . "(builderState.parentFontDescription()." . $getter . "());\n";
+    $setterContent .= $indent . "    builderState.setFontDescription(WTFMove(fontDescription));\n";
     $didCallSetValue = 1;
   } elsif (exists $propertiesWithStyleBuilderOptions{$name}{"fill-layer-property"}) {
     $setterContent .= generateFillLayerPropertyInheritValueSetter($name, $indent . "    ");
     $didCallSetValue = 1;
   }
   if (!$didCallSetValue) {
-    my $inheritedValue = $parentStyle . "->" . ($isSVG ? "svgStyle()." : "") .  $getter . "()";
+    my $inheritedValue = $parentStyle . "." . ($isSVG ? "svgStyle()." : "") .  $getter . "()";
     $setterContent .= $indent . "    " . generateSetValueStatement($name, "forwardInheritedValue(" . $inheritedValue . ")") . ";\n";
   }
   $setterContent .= $indent . "}\n";
@@ -990,20 +990,20 @@ sub generateValueSetter {
   my $indent = shift;
 
   my $setterContent = "";
-  $setterContent .= $indent . "static void applyValue" . $nameToId{$name} . "(StyleResolver& styleResolver, CSSValue& value)\n";
+  $setterContent .= $indent . "static void applyValue" . $nameToId{$name} . "(Style::BuilderState& builderState, CSSValue& value)\n";
   $setterContent .= $indent . "{\n";
   my $convertedValue;
   if (exists($propertiesWithStyleBuilderOptions{$name}{"converter"})) {
-    $convertedValue = "StyleBuilderConverter::convert" . $propertiesWithStyleBuilderOptions{$name}{"converter"} . "(styleResolver, value)";
+    $convertedValue = "StyleBuilderConverter::convert" . $propertiesWithStyleBuilderOptions{$name}{"converter"} . "(builderState, value)";
   } elsif (exists($propertiesWithStyleBuilderOptions{$name}{"conditional-converter"})) {
-    $setterContent .= $indent . "    auto convertedValue = StyleBuilderConverter::convert" . $propertiesWithStyleBuilderOptions{$name}{"conditional-converter"} . "(styleResolver, value);\n";
+    $setterContent .= $indent . "    auto convertedValue = StyleBuilderConverter::convert" . $propertiesWithStyleBuilderOptions{$name}{"conditional-converter"} . "(builderState, value);\n";
     $convertedValue = "WTFMove(convertedValue.value())";
   } else {
     $convertedValue = "downcast<CSSPrimitiveValue>(value)";
   }
 
   my $setter = $propertiesWithStyleBuilderOptions{$name}{"setter"};
-  my $style = "styleResolver.style()";
+  my $style = "builderState.style()";
   my $didCallSetValue = 0;
   if (exists $propertiesWithStyleBuilderOptions{$name}{"auto-functions"}) {
     $setterContent .= $indent . "    if (downcast<CSSPrimitiveValue>(value).valueID() == CSSValueAuto) {\n";
@@ -1022,9 +1022,9 @@ sub generateValueSetter {
     $setterContent .= generateAnimationPropertyValueSetter($name, $indent . "    ");
     $didCallSetValue = 1;
   } elsif (exists $propertiesWithStyleBuilderOptions{$name}{"font-property"}) {
-    $setterContent .= $indent . "    auto fontDescription = styleResolver.fontDescription();\n";
+    $setterContent .= $indent . "    auto fontDescription = builderState.fontDescription();\n";
     $setterContent .= $indent . "    fontDescription." . $setter . "(" . $convertedValue . ");\n";
-    $setterContent .= $indent . "    styleResolver.setFontDescription(WTFMove(fontDescription));\n";
+    $setterContent .= $indent . "    builderState.setFontDescription(WTFMove(fontDescription));\n";
     $didCallSetValue = 1;
   } elsif (exists $propertiesWithStyleBuilderOptions{$name}{"fill-layer-property"}) {
     $setterContent .= generateFillLayerPropertyValueSetter($name, $indent . "    ");
@@ -1052,10 +1052,10 @@ print STYLEBUILDER << "EOF";
 #include "CSSPrimitiveValueMappings.h"
 #include "CSSProperty.h"
 #include "RenderStyle.h"
+#include "StyleBuilderState.h"
 #include "StyleBuilderConverter.h"
 #include "StyleBuilderCustom.h"
 #include "StylePropertyShorthand.h"
-#include "StyleResolver.h"
 
 namespace WebCore {
 
@@ -1083,7 +1083,7 @@ foreach my $name (@names) {
 print STYLEBUILDER << "EOF";
 };
 
-void StyleBuilder::applyProperty(CSSPropertyID property, StyleResolver& styleResolver, CSSValue& value, bool isInitial, bool isInherit, const CSSRegisteredCustomProperty* registered)
+void StyleBuilder::applyProperty(CSSPropertyID property, Style::BuilderState& builderState, CSSValue& value, bool isInitial, bool isInherit, const CSSRegisteredCustomProperty* registered)
 {
     switch (property) {
     case CSSPropertyInvalid:
@@ -1091,11 +1091,11 @@ void StyleBuilder::applyProperty(CSSPropertyID property, StyleResolver& styleRes
     case CSSPropertyCustom: {
         auto& customProperty = downcast<CSSCustomPropertyValue>(value);
         if (isInitial)
-            StyleBuilderCustom::applyInitialCustomProperty(styleResolver, registered, customProperty.name());
+            StyleBuilderCustom::applyInitialCustomProperty(builderState, registered, customProperty.name());
         else if (isInherit)
-            StyleBuilderCustom::applyInheritCustomProperty(styleResolver, registered, customProperty.name());
+            StyleBuilderCustom::applyInheritCustomProperty(builderState, registered, customProperty.name());
         else
-            StyleBuilderCustom::applyValueCustomProperty(styleResolver, registered, customProperty);
+            StyleBuilderCustom::applyValueCustomProperty(builderState, registered, customProperty);
         break;
     }
 EOF
@@ -1107,11 +1107,11 @@ foreach my $name (@names) {
     print STYLEBUILDER "        ASSERT_NOT_REACHED();\n";
   } elsif (!exists $propertiesWithStyleBuilderOptions{$name}{"skip-builder"}) {
     print STYLEBUILDER "        if (isInitial)\n";
-    print STYLEBUILDER "            " . getScopeForFunction($name, "Initial") . "::applyInitial" . $nameToId{$name} . "(styleResolver);\n";
+    print STYLEBUILDER "            " . getScopeForFunction($name, "Initial") . "::applyInitial" . $nameToId{$name} . "(builderState);\n";
     print STYLEBUILDER "        else if (isInherit)\n";
-    print STYLEBUILDER "            " . getScopeForFunction($name, "Inherit") . "::applyInherit" . $nameToId{$name} . "(styleResolver);\n";
+    print STYLEBUILDER "            " . getScopeForFunction($name, "Inherit") . "::applyInherit" . $nameToId{$name} . "(builderState);\n";
     print STYLEBUILDER "        else\n";
-    print STYLEBUILDER "            " . getScopeForFunction($name, "Value") . "::applyValue" . $nameToId{$name} . "(styleResolver, value);\n";
+    print STYLEBUILDER "            " . getScopeForFunction($name, "Value") . "::applyValue" . $nameToId{$name} . "(builderState, value);\n";
   }
   print STYLEBUILDER "        break;\n";
 }
index 1f931bb..39b9f65 100644 (file)
@@ -177,10 +177,10 @@ void CSSParser::parseDeclarationForInspector(const CSSParserContext& context, co
     CSSParserImpl::parseDeclarationListForInspector(string, context, observer);
 }
 
-RefPtr<CSSValue> CSSParser::parseValueWithVariableReferences(CSSPropertyID propID, const CSSValue& value, Style::PropertyCascade& cascade)
+RefPtr<CSSValue> CSSParser::parseValueWithVariableReferences(CSSPropertyID propID, const CSSValue& value, Style::BuilderState& builderState)
 {
     ASSERT((propID == CSSPropertyCustom && value.isCustomPropertyValue()) || (propID != CSSPropertyCustom && !value.isCustomPropertyValue()));
-    auto& style = *cascade.styleResolver().style();
+    auto& style = builderState.style();
     auto direction = style.direction();
     auto writingMode = style.writingMode();
 
@@ -193,7 +193,7 @@ RefPtr<CSSValue> CSSParser::parseValueWithVariableReferences(CSSPropertyID propI
             shorthandID = CSSProperty::resolveDirectionAwareProperty(shorthandID, direction, writingMode);
         CSSVariableReferenceValue* shorthandValue = pendingSubstitution.shorthandValue();
 
-        auto resolvedData = shorthandValue->resolveVariableReferences(cascade);
+        auto resolvedData = shorthandValue->resolveVariableReferences(builderState);
         if (!resolvedData)
             return nullptr;
         Vector<CSSParserToken> resolvedTokens = resolvedData->tokens();
@@ -212,7 +212,7 @@ RefPtr<CSSValue> CSSParser::parseValueWithVariableReferences(CSSPropertyID propI
 
     if (value.isVariableReferenceValue()) {
         const CSSVariableReferenceValue& valueWithReferences = downcast<CSSVariableReferenceValue>(value);
-        auto resolvedData = valueWithReferences.resolveVariableReferences(cascade);
+        auto resolvedData = valueWithReferences.resolveVariableReferences(builderState);
         if (!resolvedData)
             return nullptr;
         return CSSPropertyParser::parseSingleValue(propID, resolvedData->tokens(), m_context);
@@ -222,9 +222,9 @@ RefPtr<CSSValue> CSSParser::parseValueWithVariableReferences(CSSPropertyID propI
     const auto& valueWithReferences = WTF::get<Ref<CSSVariableReferenceValue>>(customPropValue.value()).get();
 
     auto& name = downcast<CSSCustomPropertyValue>(value).name();
-    auto* registered = cascade.styleResolver().document().getCSSRegisteredCustomPropertySet().get(name);
+    auto* registered = builderState.document().getCSSRegisteredCustomPropertySet().get(name);
     auto& syntax = registered ? registered->syntax : "*";
-    auto resolvedData = valueWithReferences.resolveVariableReferences(cascade);
+    auto resolvedData = valueWithReferences.resolveVariableReferences(builderState);
 
     if (!resolvedData)
         return nullptr;
@@ -234,9 +234,9 @@ RefPtr<CSSValue> CSSParser::parseValueWithVariableReferences(CSSPropertyID propI
     CSSPropertyParser::collectParsedCustomPropertyValueDependencies(syntax, false, dependencies, resolvedData->tokens(), m_context);
 
     for (auto id : dependencies)
-        cascade.applyProperties(id, id);
+        builderState.cascade().applyProperties(id, id);
 
-    return CSSPropertyParser::parseTypedCustomPropertyValue(name, syntax, resolvedData->tokens(), cascade.styleResolver(), m_context);
+    return CSSPropertyParser::parseTypedCustomPropertyValue(name, syntax, resolvedData->tokens(), builderState, m_context);
 }
 
 std::unique_ptr<Vector<double>> CSSParser::parseKeyframeKeyList(const String& selector)
index d269551..5cf360a 100644 (file)
@@ -42,7 +42,7 @@ class StyleSheetContents;
 class RenderStyle;
 
 namespace Style {
-class PropertyCascade;
+class BuilderState;
 }
 
 class CSSParser {
@@ -81,7 +81,7 @@ public:
 
     void parseSelector(const String&, CSSSelectorList&);
 
-    RefPtr<CSSValue> parseValueWithVariableReferences(CSSPropertyID, const CSSValue&, Style::PropertyCascade&);
+    RefPtr<CSSValue> parseValueWithVariableReferences(CSSPropertyID, const CSSValue&, Style::BuilderState&);
 
     static Color parseColor(const String&, bool strict = false);
     static Color parseSystemColor(const String&, const CSSParserContext*);
index a4f2899..1ae7bc9 100644 (file)
@@ -67,6 +67,7 @@
 #include "HashTools.h"
 // FIXME-NEWPARSER: Replace Pair and Rect with actual CSSValue subclasses (CSSValuePair and CSSQuadValue).
 #include "Pair.h"
+#include "PropertyCascade.h"
 #include "Rect.h"
 #include "RenderTheme.h"
 #include "RuntimeEnabledFeatures.h"
@@ -75,7 +76,6 @@
 #include "StyleBuilderConverter.h"
 #include "StylePropertyShorthand.h"
 #include "StylePropertyShorthandFunctions.h"
-#include "StyleResolver.h"
 #include <bitset>
 #include <memory>
 #include <wtf/text/StringBuilder.h>
@@ -297,10 +297,10 @@ bool CSSPropertyParser::canParseTypedCustomPropertyValue(const String& syntax, c
     return parser.canParseTypedCustomPropertyValue(syntax);
 }
 
-RefPtr<CSSCustomPropertyValue> CSSPropertyParser::parseTypedCustomPropertyValue(const String& name, const String& syntax, const CSSParserTokenRange& tokens, const StyleResolver& styleResolver, const CSSParserContext& context)
+RefPtr<CSSCustomPropertyValue> CSSPropertyParser::parseTypedCustomPropertyValue(const String& name, const String& syntax, const CSSParserTokenRange& tokens, const Style::BuilderState& builderState, const CSSParserContext& context)
 {
     CSSPropertyParser parser(tokens, context, nullptr, false);
-    RefPtr<CSSCustomPropertyValue> value = parser.parseTypedCustomPropertyValue(name, syntax, styleResolver);
+    RefPtr<CSSCustomPropertyValue> value = parser.parseTypedCustomPropertyValue(name, syntax, builderState);
     if (!value || !parser.m_range.atEnd())
         return nullptr;
     return value;
@@ -4294,13 +4294,13 @@ void CSSPropertyParser::collectParsedCustomPropertyValueDependencies(const Strin
     }
 }
 
-RefPtr<CSSCustomPropertyValue> CSSPropertyParser::parseTypedCustomPropertyValue(const String& name, const String& syntax, const StyleResolver& styleResolver)
+RefPtr<CSSCustomPropertyValue> CSSPropertyParser::parseTypedCustomPropertyValue(const String& name, const String& syntax, const Style::BuilderState& builderState)
 {
     if (syntax != "*") {
         m_range.consumeWhitespace();
         auto primitiveVal = consumeWidthOrHeight(m_range, m_context);
         if (primitiveVal && primitiveVal->isPrimitiveValue() && downcast<CSSPrimitiveValue>(*primitiveVal).isLength()) {
-            auto length = StyleBuilderConverter::convertLength(styleResolver, *primitiveVal);
+            auto length = StyleBuilderConverter::convertLength(builderState, *primitiveVal);
             if (!length.isCalculated() && !length.isUndefined())
                 return CSSCustomPropertyValue::createSyntaxLength(name, WTFMove(length));
         }
index 56520d9..c67c202 100644 (file)
@@ -32,7 +32,10 @@ class CSSProperty;
 class CSSValue;
 class StylePropertyShorthand;
 class StyleSheetContents;
-class StyleResolver;
+
+namespace Style {
+class BuilderState;
+}
     
 // Inputs: PropertyID, isImportant bool, CSSParserTokenRange.
 // Outputs: Vector of CSSProperties
@@ -47,7 +50,7 @@ public:
     // Parses a non-shorthand CSS property
     static RefPtr<CSSValue> parseSingleValue(CSSPropertyID, const CSSParserTokenRange&, const CSSParserContext&);
     static bool canParseTypedCustomPropertyValue(const String& syntax, const CSSParserTokenRange&, const CSSParserContext&);
-    static RefPtr<CSSCustomPropertyValue> parseTypedCustomPropertyValue(const String& name, const String& syntax, const CSSParserTokenRange&, const StyleResolver&, const CSSParserContext&);
+    static RefPtr<CSSCustomPropertyValue> parseTypedCustomPropertyValue(const String& name, const String& syntax, const CSSParserTokenRange&, const Style::BuilderState&, const CSSParserContext&);
     static void collectParsedCustomPropertyValueDependencies(const String& syntax, bool isRoot, HashSet<CSSPropertyID>& dependencies, const CSSParserTokenRange&, const CSSParserContext&);
 
 private:
@@ -58,7 +61,7 @@ private:
     bool consumeCSSWideKeyword(CSSPropertyID, bool important);
     RefPtr<CSSValue> parseSingleValue(CSSPropertyID, CSSPropertyID = CSSPropertyInvalid);
     bool canParseTypedCustomPropertyValue(const String& syntax);
-    RefPtr<CSSCustomPropertyValue> parseTypedCustomPropertyValue(const String& name, const String& syntax, const StyleResolver&);
+    RefPtr<CSSCustomPropertyValue> parseTypedCustomPropertyValue(const String& name, const String& syntax, const Style::BuilderState&);
     void collectParsedCustomPropertyValueDependencies(const String& syntax, bool isRoot, HashSet<CSSPropertyID>& dependencies);
 
     bool inQuirksMode() const { return m_context.mode == HTMLQuirksMode; }
index 95b7b1c..adc0361 100644 (file)
@@ -176,13 +176,7 @@ void CanvasRenderingContext2D::setFont(const String& newFont)
     styleResolver.applyPropertyToCurrentStyle(CSSPropertyFontStyle, parsedStyle->getPropertyCSSValue(CSSPropertyFontStyle).get());
     styleResolver.applyPropertyToCurrentStyle(CSSPropertyFontVariantCaps, parsedStyle->getPropertyCSSValue(CSSPropertyFontVariantCaps).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());
 
     modifiableState().font.initialize(document.fontSelector(), *styleResolver.style());
index 33513df..7388d9f 100644 (file)
@@ -1133,7 +1133,7 @@ FloatRect GraphicsContext::computeLineBoundsAndAntialiasingModeForText(const Flo
     return FloatRect(origin, FloatSize(rect.width(), thickness));
 }
 
-void GraphicsContext::applyState(const GraphicsContextState& state)
+void GraphicsContext::builderState(const GraphicsContextState& state)
 {
     setPlatformShadow(state.shadowOffset, state.shadowBlur, state.shadowColor);
     setPlatformStrokeThickness(state.strokeThickness);
index 13f5a2f..0879145 100644 (file)
@@ -402,7 +402,7 @@ public:
     void drawEmphasisMarks(const FontCascade&, const TextRun&, const AtomString& mark, const FloatPoint&, unsigned from = 0, Optional<unsigned> to = WTF::nullopt);
     void drawBidiText(const FontCascade&, const TextRun&, const FloatPoint&, FontCascade::CustomFontNotReadyAction = FontCascade::DoNotPaintIfFontNotReady);
 
-    void applyState(const GraphicsContextState&);
+    void builderState(const GraphicsContextState&);
 
     enum RoundingMode {
         RoundAllSides,
index cf3cf92..fb73a67 100644 (file)
@@ -316,7 +316,7 @@ public:
 
     void accumulate(GraphicsContextState&) const;
 
-    static void applyState(GraphicsContext&, const GraphicsContextState&, GraphicsContextState::StateChangeFlags);
+    static void builderState(GraphicsContext&, const GraphicsContextState&, GraphicsContextState::StateChangeFlags);
 
     static void dumpStateChanges(WTF::TextStream&, const GraphicsContextState&, GraphicsContextState::StateChangeFlags);
 private:
diff --git a/Source/WebCore/style/CascadeLevel.h b/Source/WebCore/style/CascadeLevel.h
new file mode 100644 (file)
index 0000000..a2e32a8
--- /dev/null
@@ -0,0 +1,42 @@
+/*
+ * Copyright (C) 2019 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#pragma once
+
+#include <wtf/OptionSet.h>
+
+namespace WebCore {
+namespace Style {
+
+enum class CascadeLevel : uint8_t {
+    UserAgent   = 1 << 0,
+    User        = 1 << 1,
+    Author      = 1 << 2
+};
+
+static constexpr OptionSet<CascadeLevel> allCascadeLevels() { return { CascadeLevel::UserAgent, CascadeLevel::User, CascadeLevel::Author }; }
+
+}
+}
index a439811..3e8bc9c 100644 (file)
@@ -174,9 +174,9 @@ static inline bool isValidCueStyleProperty(CSSPropertyID id)
 #endif
 
 PropertyCascade::PropertyCascade(StyleResolver& styleResolver, const MatchResult& matchResult, OptionSet<CascadeLevel> cascadeLevels, IncludedProperties includedProperties)
-    : m_styleResolver(styleResolver)
-    , m_matchResult(matchResult)
+    : m_matchResult(matchResult)
     , m_includedProperties(includedProperties)
+    , m_builderState(std::in_place, *this, styleResolver)
 {
     // Directional properties (*-before/after) are aliases that depend on the TextDirection and WritingMode.
     // These must be resolved before we can begin building the property cascade.
@@ -186,8 +186,7 @@ PropertyCascade::PropertyCascade(StyleResolver& styleResolver, const MatchResult
 }
 
 PropertyCascade::PropertyCascade(const PropertyCascade& parent, OptionSet<CascadeLevel> cascadeLevels)
-    : m_styleResolver(parent.m_styleResolver)
-    , m_matchResult(parent.m_matchResult)
+    :  m_matchResult(parent.m_matchResult)
     , m_includedProperties(parent.m_includedProperties)
     , m_direction(parent.m_direction)
     , m_writingMode(parent.m_writingMode)
@@ -403,19 +402,19 @@ inline void PropertyCascade::applyPropertiesImpl(int firstProperty, int lastProp
         auto& property = m_properties[propertyID];
 
         if (trackCycles == CustomPropertyCycleTracking::Enabled) {
-            if (UNLIKELY(m_applyState.inProgressProperties.get(propertyID))) {
+            if (UNLIKELY(builderState().m_inProgressProperties.get(propertyID))) {
                 // We are in a cycle (eg. setting font size using registered custom property value containing em).
                 // So this value should be unset.
-                m_applyState.appliedProperties.set(propertyID);
+                builderState().m_appliedProperties.set(propertyID);
                 // This property is in a cycle, and only the root of the call stack will have firstProperty != lastProperty.
                 ASSERT(firstProperty == lastProperty);
                 continue;
             }
-
-            m_applyState.inProgressProperties.set(propertyID);
+            auto& builderState = *m_builderState;
+            builderState.m_inProgressProperties.set(propertyID);
             applyProperty(property);
-            m_applyState.appliedProperties.set(propertyID);
-            m_applyState.inProgressProperties.set(propertyID, false);
+            builderState.m_appliedProperties.set(propertyID);
+            builderState.m_inProgressProperties.set(propertyID, false);
             continue;
         }
 
@@ -432,31 +431,32 @@ void PropertyCascade::applyCustomProperties()
 
 void PropertyCascade::applyCustomProperty(const String& name)
 {
-    if (m_applyState.appliedCustomProperties.contains(name) || !m_customProperties.contains(name))
+    auto& builderState = *m_builderState;
+    if (builderState.m_appliedCustomProperties.contains(name) || !m_customProperties.contains(name))
         return;
 
     auto property = customProperty(name);
-    bool inCycle = m_applyState.inProgressPropertiesCustom.contains(name);
+    bool inCycle = builderState.m_inProgressPropertiesCustom.contains(name);
 
     for (auto index : { SelectorChecker::MatchDefault, SelectorChecker::MatchLink, SelectorChecker::MatchVisited }) {
         if (!property.cssValue[index])
             continue;
-        if (index != SelectorChecker::MatchDefault && m_styleResolver.state().style()->insideLink() == InsideLink::NotInside)
+        if (index != SelectorChecker::MatchDefault && builderState.style().insideLink() == InsideLink::NotInside)
             continue;
 
         Ref<CSSCustomPropertyValue> valueToApply = CSSCustomPropertyValue::create(downcast<CSSCustomPropertyValue>(*property.cssValue[index]));
 
         if (inCycle) {
-            m_applyState.appliedCustomProperties.add(name); // Make sure we do not try to apply this property again while resolving it.
+            builderState.m_appliedCustomProperties.add(name); // Make sure we do not try to apply this property again while resolving it.
             valueToApply = CSSCustomPropertyValue::createWithID(name, CSSValueInvalid);
         }
 
-        m_applyState.inProgressPropertiesCustom.add(name);
+        builderState.m_inProgressPropertiesCustom.add(name);
 
         if (WTF::holds_alternative<Ref<CSSVariableReferenceValue>>(valueToApply->value())) {
             RefPtr<CSSValue> parsedValue = resolvedVariableValue(CSSPropertyCustom, valueToApply.get());
 
-            if (m_applyState.appliedCustomProperties.contains(name))
+            if (builderState.m_appliedCustomProperties.contains(name))
                 return; // There was a cycle and the value was reset, so bail.
 
             if (!parsedValue)
@@ -465,32 +465,20 @@ void PropertyCascade::applyCustomProperty(const String& name)
             valueToApply = downcast<CSSCustomPropertyValue>(*parsedValue);
         }
 
-        if (m_applyState.inProgressPropertiesCustom.contains(name)) {
-            if (index == SelectorChecker::MatchDefault) {
-                m_styleResolver.state().setApplyPropertyToRegularStyle(true);
-                m_styleResolver.state().setApplyPropertyToVisitedLinkStyle(false);
-            }
-
-            if (index == SelectorChecker::MatchLink) {
-                m_styleResolver.state().setApplyPropertyToRegularStyle(true);
-                m_styleResolver.state().setApplyPropertyToVisitedLinkStyle(false);
-            }
-
-            if (index == SelectorChecker::MatchVisited) {
-                m_styleResolver.state().setApplyPropertyToRegularStyle(false);
-                m_styleResolver.state().setApplyPropertyToVisitedLinkStyle(true);
-            }
+        if (builderState.m_inProgressPropertiesCustom.contains(name)) {
+            builderState.m_linkMatch = index;
             applyProperty(CSSPropertyCustom, valueToApply.get(), index);
         }
     }
 
-    m_applyState.inProgressPropertiesCustom.remove(name);
-    m_applyState.appliedCustomProperties.add(name);
+    builderState.m_linkMatch = SelectorChecker::MatchDefault;
+    builderState.m_inProgressPropertiesCustom.remove(name);
+    builderState.m_appliedCustomProperties.add(name);
 
     for (auto index : { SelectorChecker::MatchDefault, SelectorChecker::MatchLink, SelectorChecker::MatchVisited }) {
         if (!property.cssValue[index])
             continue;
-        if (index != SelectorChecker::MatchDefault && m_styleResolver.state().style()->insideLink() == InsideLink::NotInside)
+        if (index != SelectorChecker::MatchDefault && builderState.style().insideLink() == InsideLink::NotInside)
             continue;
 
         Ref<CSSCustomPropertyValue> valueToApply = CSSCustomPropertyValue::create(downcast<CSSCustomPropertyValue>(*property.cssValue[index]));
@@ -528,33 +516,26 @@ const PropertyCascade* PropertyCascade::propertyCascadeForRollback(CascadeLevel
 
 inline void PropertyCascade::applyProperty(const Property& property)
 {
-    StyleResolver::State& state = m_styleResolver.state();
-    state.setCascadeLevel(property.level);
-    state.setStyleScopeOrdinal(property.styleScopeOrdinal);
-
-    if (property.cssValue[SelectorChecker::MatchDefault]) {
-        state.setApplyPropertyToRegularStyle(true);
-        state.setApplyPropertyToVisitedLinkStyle(false);
-        applyProperty(property.id, *property.cssValue[SelectorChecker::MatchDefault], SelectorChecker::MatchDefault);
-    }
+    auto& builderState = *m_builderState;
+    builderState.m_cascadeLevel = property.level;
+    builderState.m_styleScopeOrdinal = property.styleScopeOrdinal;
+
+    auto applyWithLinkMatch = [&](SelectorChecker::LinkMatchMask linkMatch) {
+        if (property.cssValue[linkMatch]) {
+            builderState.m_linkMatch = linkMatch;
+            applyProperty(property.id, *property.cssValue[linkMatch], linkMatch);
+        }
+    };
 
-    if (state.style()->insideLink() == InsideLink::NotInside)
-        return;
+    applyWithLinkMatch(SelectorChecker::MatchDefault);
 
-    if (property.cssValue[SelectorChecker::MatchLink]) {
-        state.setApplyPropertyToRegularStyle(true);
-        state.setApplyPropertyToVisitedLinkStyle(false);
-        applyProperty(property.id, *property.cssValue[SelectorChecker::MatchLink], SelectorChecker::MatchLink);
-    }
+    if (builderState.style().insideLink() == InsideLink::NotInside)
+        return;
 
-    if (property.cssValue[SelectorChecker::MatchVisited]) {
-        state.setApplyPropertyToRegularStyle(false);
-        state.setApplyPropertyToVisitedLinkStyle(true);
-        applyProperty(property.id, *property.cssValue[SelectorChecker::MatchVisited], SelectorChecker::MatchVisited);
-    }
+    applyWithLinkMatch(SelectorChecker::MatchLink);
+    applyWithLinkMatch(SelectorChecker::MatchVisited);
 
-    state.setApplyPropertyToRegularStyle(true);
-    state.setApplyPropertyToVisitedLinkStyle(false);
+    builderState.m_linkMatch = SelectorChecker::MatchDefault;
 }
 
 void PropertyCascade::applyProperty(CSSPropertyID id, CSSValue& value, SelectorChecker::LinkMatchMask linkMatchMask)
@@ -569,6 +550,8 @@ void PropertyCascade::applyProperty(CSSPropertyID id, CSSValue& value, SelectorC
         return applyProperty(newId, valueToApply.get(), linkMatchMask);
     }
 
+    auto& builderState = *m_builderState;
+
     CSSCustomPropertyValue* customPropertyValue = nullptr;
     CSSValueID customPropertyValueID = CSSValueInvalid;
     CSSRegisteredCustomProperty* customPropertyRegistered = nullptr;
@@ -579,18 +562,17 @@ void PropertyCascade::applyProperty(CSSPropertyID id, CSSValue& value, SelectorC
         if (WTF::holds_alternative<CSSValueID>(customPropertyValue->value()))
             customPropertyValueID = WTF::get<CSSValueID>(customPropertyValue->value());
         auto& name = customPropertyValue->name();
-        customPropertyRegistered = m_styleResolver.document().getCSSRegisteredCustomPropertySet().get(name);
+        customPropertyRegistered = builderState.document().getCSSRegisteredCustomPropertySet().get(name);
     }
 
-    auto& state = m_styleResolver.state();
-    bool isInherit = state.parentStyle() ? valueToApply->isInheritedValue() || customPropertyValueID == CSSValueInherit : false;
-    bool isInitial = valueToApply->isInitialValue() || customPropertyValueID == CSSValueInitial || (!state.parentStyle() && (valueToApply->isInheritedValue() || customPropertyValueID == CSSValueInherit));
+    bool isInherit = valueToApply->isInheritedValue() || customPropertyValueID == CSSValueInherit;
+    bool isInitial = valueToApply->isInitialValue() || customPropertyValueID == CSSValueInitial;
 
     bool isUnset = valueToApply->isUnsetValue() || customPropertyValueID == CSSValueUnset;
     bool isRevert = valueToApply->isRevertValue() || customPropertyValueID == CSSValueRevert;
 
     if (isRevert) {
-        if (auto* rollback = propertyCascadeForRollback(state.cascadeLevel())) {
+        if (auto* rollback = propertyCascadeForRollback(builderState.m_cascadeLevel)) {
             // With the rollback cascade built, we need to obtain the property and apply it. If the property is
             // not present, then we behave like "unset." Otherwise we apply the property instead of
             // our own.
@@ -621,29 +603,29 @@ void PropertyCascade::applyProperty(CSSPropertyID id, CSSValue& value, SelectorC
 
     ASSERT(!isInherit || !isInitial); // isInherit -> !isInitial && isInitial -> !isInherit
 
-    if (!state.applyPropertyToRegularStyle() && (!state.applyPropertyToVisitedLinkStyle() || !isValidVisitedLinkProperty(id))) {
+    if (builderState.applyPropertyToVisitedLinkStyle() && !isValidVisitedLinkProperty(id)) {
         // Limit the properties that can be applied to only the ones honored by :visited.
         return;
     }
 
     if (isInherit && !CSSProperty::isInheritedProperty(id))
-        state.style()->setHasExplicitlyInheritedProperties();
+        builderState.style().setHasExplicitlyInheritedProperties();
 
 #if ENABLE(CSS_PAINTING_API)
     if (is<CSSPaintImageValue>(valueToApply)) {
         auto& name = downcast<CSSPaintImageValue>(valueToApply.get()).name();
-        if (auto* paintWorklet = m_styleResolver.document().paintWorkletGlobalScopeForName(name)) {
+        if (auto* paintWorklet = const_cast<Document&>(builderState.document()).paintWorkletGlobalScopeForName(name)) {
             auto locker = holdLock(paintWorklet->paintDefinitionLock());
             if (auto* registration = paintWorklet->paintDefinitionMap().get(name)) {
                 for (auto& property : registration->inputProperties)
-                    state.style()->addCustomPaintWatchProperty(property);
+                    builderState.style().addCustomPaintWatchProperty(property);
             }
         }
     }
 #endif
 
     // Use the generated StyleBuilder.
-    StyleBuilder::applyProperty(id, m_styleResolver, valueToApply.get(), isInitial, isInherit, customPropertyRegistered);
+    StyleBuilder::applyProperty(id, builderState, valueToApply.get(), isInitial, isInherit, customPropertyRegistered);
 }
 
 Ref<CSSValue> PropertyCascade::resolveValue(CSSPropertyID propertyID, CSSValue& value)
@@ -653,7 +635,7 @@ Ref<CSSValue> PropertyCascade::resolveValue(CSSPropertyID propertyID, CSSValue&
     
     auto variableValue = resolvedVariableValue(propertyID, value);
     // If the cascade has already applied this id, then we detected a cycle, and this value should be unset.
-    if (!variableValue || m_applyState.appliedProperties.get(propertyID)) {
+    if (!variableValue || builderState().m_appliedProperties.get(propertyID)) {
         if (CSSProperty::isInheritedProperty(propertyID))
             return CSSValuePool::singleton().createInheritedValue();
         return CSSValuePool::singleton().createExplicitInitialValue();
@@ -664,13 +646,13 @@ Ref<CSSValue> PropertyCascade::resolveValue(CSSPropertyID propertyID, CSSValue&
 
 RefPtr<CSSValue> PropertyCascade::resolvedVariableValue(CSSPropertyID propID, const CSSValue& value)
 {
-    CSSParser parser(m_styleResolver.document());
-    return parser.parseValueWithVariableReferences(propID, value, *this);
+    CSSParser parser(builderState().document());
+    return parser.parseValueWithVariableReferences(propID, value, builderState());
 }
 
 void PropertyCascade::resolveDirectionAndWritingMode()
 {
-    auto& style = *m_styleResolver.style();
+    auto& style = builderState().style();
 
     m_direction = style.direction();
     m_writingMode = style.writingMode();
index 42c5085..9f55cff 100644 (file)
 
 #pragma once
 
+#include "CascadeLevel.h"
 #include "ElementRuleCollector.h"
+#include "StyleBuilderState.h"
 #include <bitset>
-#include <wtf/Bitmap.h>
 
 namespace WebCore {
 
@@ -35,14 +36,6 @@ class StyleResolver;
 
 namespace Style {
 
-enum class CascadeLevel : uint8_t {
-    UserAgent   = 1 << 0,
-    User        = 1 << 1,
-    Author      = 1 << 2
-};
-
-static constexpr OptionSet<CascadeLevel> allCascadeLevels() { return { Style::CascadeLevel::UserAgent, Style::CascadeLevel::User, Style::CascadeLevel::Author }; }
-
 class PropertyCascade {
     WTF_MAKE_FAST_ALLOCATED;
 public:
@@ -52,8 +45,6 @@ public:
 
     ~PropertyCascade();
 
-    StyleResolver& styleResolver() { return m_styleResolver; }
-
     struct Property {
         CSSPropertyID id;
         CascadeLevel level;
@@ -69,12 +60,12 @@ public:
 
     void applyProperties(int firstProperty, int lastProperty);
     void applyDeferredProperties();
-
     void applyCustomProperties();
     void applyCustomProperty(const String& name);
-
     void applyProperty(CSSPropertyID, CSSValue&, SelectorChecker::LinkMatchMask = SelectorChecker::MatchDefault);
 
+    BuilderState& builderState() { return *m_builderState; }
+
 private:
     void buildCascade(OptionSet<CascadeLevel>);
     bool addNormalMatches(CascadeLevel);
@@ -97,11 +88,9 @@ private:
 
     void resolveDirectionAndWritingMode();
 
-    StyleResolver& m_styleResolver;
-
     const MatchResult& m_matchResult;
     const IncludedProperties m_includedProperties;
-    
+
     TextDirection m_direction;
     WritingMode m_writingMode;
 
@@ -111,19 +100,10 @@ private:
     Vector<Property, 8> m_deferredProperties;
     HashMap<AtomString, Property> m_customProperties;
 
-    // State to use when applying properties, to keep track of which custom and high-priority
-    // properties have been resolved.
-    struct ApplyState {
-        Bitmap<numCSSProperties> appliedProperties = { };
-        HashSet<String> appliedCustomProperties = { };
-        Bitmap<numCSSProperties> inProgressProperties = { };
-        HashSet<String> inProgressPropertiesCustom = { };
-    };
-
-    ApplyState m_applyState;
-
     std::unique_ptr<const PropertyCascade> m_authorRollbackCascade;
     std::unique_ptr<const PropertyCascade> m_userRollbackCascade;
+
+    Optional<BuilderState> m_builderState;
 };
 
 inline bool PropertyCascade::hasProperty(CSSPropertyID id) const
diff --git a/Source/WebCore/style/StyleBuilderState.cpp b/Source/WebCore/style/StyleBuilderState.cpp
new file mode 100644 (file)
index 0000000..1841d27
--- /dev/null
@@ -0,0 +1,80 @@
+/*
+ * Copyright (C) 2019 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "StyleBuilderState.h"
+
+#include "StyleResolver.h"
+
+namespace WebCore {
+namespace Style {
+
+BuilderState::BuilderState(PropertyCascade& cascade, StyleResolver& styleResolver)
+    : m_cascade(cascade)
+    , m_styleMap(*this)
+    , m_cssToLengthConversionData(styleResolver.state().cssToLengthConversionData())
+    , m_styleResolver(styleResolver)
+    , m_style(*styleResolver.style())
+    , m_parentStyle(*styleResolver.parentStyle())
+    , m_rootElementStyle(styleResolver.rootElementStyle() ? *styleResolver.rootElementStyle() : RenderStyle::defaultStyle())
+    , m_document(m_styleResolver.document())
+    , m_element(m_styleResolver.element())
+{
+    ASSERT(styleResolver.style());
+    ASSERT(styleResolver.parentStyle());
+}
+
+bool BuilderState::useSVGZoomRules() const
+{
+    return m_styleResolver.useSVGZoomRules();
+}
+
+bool BuilderState::useSVGZoomRulesForLength() const
+{
+    return m_styleResolver.useSVGZoomRulesForLength();
+}
+
+RefPtr<StyleImage> BuilderState::createStyleImage(CSSValue& value)
+{
+    return m_styleResolver.styleImage(value);
+}
+
+bool BuilderState::createFilterOperations(const CSSValue& value, FilterOperations& outOperations)
+{
+    return m_styleResolver.createFilterOperations(value, outOperations);
+}
+
+Color BuilderState::colorFromPrimitiveValue(const CSSPrimitiveValue& value, bool forVisitedLink) const
+{
+    return m_styleResolver.colorFromPrimitiveValue(value, forVisitedLink);
+}
+
+void BuilderState::setFontSize(FontCascadeDescription& description, float size)
+{
+    m_styleResolver.setFontSize(description, size);
+}
+
+}
+}
diff --git a/Source/WebCore/style/StyleBuilderState.h b/Source/WebCore/style/StyleBuilderState.h
new file mode 100644 (file)
index 0000000..f273814
--- /dev/null
@@ -0,0 +1,118 @@
+/*
+ * Copyright (C) 2019 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#pragma once
+
+#include "CSSToLengthConversionData.h"
+#include "CSSToStyleMap.h"
+#include "CascadeLevel.h"
+#include "RenderStyle.h"
+#include "SelectorChecker.h"
+#include <wtf/Bitmap.h>
+
+namespace WebCore {
+
+class StyleImage;
+class StyleResolver;
+
+namespace Style {
+
+class PropertyCascade;
+
+class BuilderState {
+public:
+    BuilderState(PropertyCascade&, StyleResolver&);
+
+    PropertyCascade& cascade() { return m_cascade; }
+    StyleResolver& styleResolver() { return m_styleResolver; }
+
+    RenderStyle& style() { return m_style; }
+    const RenderStyle& parentStyle() const { return m_parentStyle; }
+    const RenderStyle& rootElementStyle() const { return m_rootElementStyle; }
+
+    const Document& document() const { return m_document.get(); }
+    const Element* element() const { return m_element.get(); }
+
+    void setFontDescription(FontCascadeDescription&& fontDescription) { m_fontDirty |= m_style.setFontDescription(WTFMove(fontDescription)); }
+    void setFontSize(FontCascadeDescription&, float size);
+    void setZoom(float f) { m_fontDirty |= m_style.setZoom(f); }
+    void setEffectiveZoom(float f) { m_fontDirty |= m_style.setEffectiveZoom(f); }
+    void setWritingMode(WritingMode writingMode) { m_fontDirty |= m_style.setWritingMode(writingMode); }
+    void setTextOrientation(TextOrientation textOrientation) { m_fontDirty |= m_style.setTextOrientation(textOrientation); }
+
+    bool fontDirty() const { return m_fontDirty; }
+    void setFontDirty() { m_fontDirty = true; }
+    void clearFontDirty() { m_fontDirty = false; }
+
+    const FontCascadeDescription& fontDescription() { return m_style.fontDescription(); }
+    const FontCascadeDescription& parentFontDescription() { return m_parentStyle.fontDescription(); }
+
+    // FIXME: These are mutually exclusive, clean up the code to take that into account.
+    bool applyPropertyToRegularStyle() const { return m_linkMatch != SelectorChecker::MatchVisited; }
+    bool applyPropertyToVisitedLinkStyle() const { return m_linkMatch == SelectorChecker::MatchVisited; }
+
+    bool useSVGZoomRules() const;
+    bool useSVGZoomRulesForLength() const;
+    ScopeOrdinal styleScopeOrdinal() const { return m_styleScopeOrdinal; }
+
+    RefPtr<StyleImage> createStyleImage(CSSValue&);
+    bool createFilterOperations(const CSSValue&, FilterOperations& outOperations);
+    Color colorFromPrimitiveValue(const CSSPrimitiveValue&, bool forVisitedLink = false) const;
+
+    const CSSToLengthConversionData& cssToLengthConversionData() const { return m_cssToLengthConversionData; }
+    CSSToStyleMap& styleMap() { return m_styleMap; }
+
+private:
+    friend class PropertyCascade;
+
+    PropertyCascade& m_cascade;
+
+    CSSToStyleMap m_styleMap;
+    CSSToLengthConversionData m_cssToLengthConversionData;
+
+    // FIXME: Remove.
+    StyleResolver& m_styleResolver;
+
+    RenderStyle& m_style;
+    const RenderStyle& m_parentStyle;
+    const RenderStyle& m_rootElementStyle;
+
+    Ref<const Document> m_document;
+    RefPtr<const Element> m_element;
+
+    Bitmap<numCSSProperties> m_appliedProperties;
+    HashSet<String> m_appliedCustomProperties;
+    Bitmap<numCSSProperties> m_inProgressProperties;
+    HashSet<String> m_inProgressPropertiesCustom;
+
+    CascadeLevel m_cascadeLevel { };
+    ScopeOrdinal m_styleScopeOrdinal { };
+    SelectorChecker::LinkMatchMask m_linkMatch { };
+
+    bool m_fontDirty { false };
+};
+
+}
+}