Changeset 142757 in webkit


Ignore:
Timestamp:
Feb 13, 2013 9:26:41 AM (11 years ago)
Author:
tasak@google.com
Message:

Source/WebCore: [Refactoring] StyleResolver::State should have methods to access its member variables.
https://bugs.webkit.org/show_bug.cgi?id=108563

Reviewed by Antti Koivisto.

Made all member variables private and added methods to access the
variables, because most of the member variables are read-only.
We don't need to update those read-only variables while resolving
styles.

No new tests, because just refactoring.

  • css/SVGCSSStyleSelector.cpp:

(WebCore::StyleResolver::applySVGProperty):

  • css/StyleResolver.cpp:

(WebCore):
(WebCore::StyleResolver::collectMatchingRules):
(WebCore::StyleResolver::collectMatchingRulesForRegion):
(WebCore::StyleResolver::sortAndTransferMatchedRules):
(WebCore::StyleResolver::matchScopedAuthorRules):
(WebCore::StyleResolver::styleSharingCandidateMatchesHostRules):
(WebCore::StyleResolver::matchHostRules):
(WebCore::StyleResolver::matchAuthorRules):
(WebCore::StyleResolver::matchUserRules):
(WebCore::StyleResolver::matchUARules):
(WebCore::StyleResolver::collectMatchingRulesForList):
(WebCore::StyleResolver::sortMatchedRules):
(WebCore::StyleResolver::matchAllRules):
(WebCore::StyleResolver::State::initElement):
(WebCore::StyleResolver::initElement):
Modified to invoke m_state.initElement if a given element is
different from current m_state's element.
(WebCore::StyleResolver::State::initForStyleResolve):
Moved from StyleResolver.
(WebCore::StyleResolver::styleSharingCandidateMatchesRuleSet):
(WebCore::StyleResolver::canShareStyleWithControl):
(WebCore::StyleResolver::sharingCandidateHasIdenticalStyleAffectingAttributes):
(WebCore::StyleResolver::canShareStyleWithElement):
(WebCore::StyleResolver::locateSharedStyle):
(WebCore::StyleResolver::styleForElement):
(WebCore::StyleResolver::styleForKeyframe):
(WebCore::StyleResolver::keyframeStylesForAnimation):
(WebCore::StyleResolver::pseudoStyleForElement):
Changed ASSERT in the first line. ASSERT(m_state.parentStyle) would be
wrong, because it depends on previous resolving. However,
initForStyleResolve will also update m_state.parentStyle. No code in
pseudoStyleForElement depends on previous resolving state.
(WebCore::StyleResolver::styleForPage):
(WebCore::StyleResolver::defaultStyleForElement):
(WebCore::StyleResolver::adjustRenderStyle):
(WebCore::StyleResolver::updateFont):
(WebCore::StyleResolver::pseudoStyleRulesForElement):
(WebCore::StyleResolver::ruleMatches):
Added one more parameter, dynamicPseudo, because dynamicPseudo in
State class is just used for returning matched pseudo style from
this ruleMatches to collectMatchingRulesForList. No need to keep
dynamicPseudo while resolving styles.
(WebCore::StyleResolver::checkRegionSelector):
Removed m_pseudoStyle = NOPSEUDO, because this method uses just
SelectorChecker::matched. SelectorChecker doesn't see StyleResolver's
m_pseudoStyle directly. Need to use SelectorCheckerContext. So no
need to set m_pseudoStyle to be NOPSEUDO.
(WebCore::StyleResolver::applyProperties):
(WebCore::StyleResolver::applyMatchedProperties):
(WebCore::StyleResolver::isLeftPage):
(WebCore::StyleResolver::applyPropertyToStyle):
(WebCore::StyleResolver::useSVGZoomRules):
(WebCore::createGridTrackBreadth):
(WebCore::StyleResolver::resolveVariables):
(WebCore::StyleResolver::applyProperty):
(WebCore::StyleResolver::cachedOrPendingFromValue):
(WebCore::StyleResolver::generatedOrPendingFromValue):
(WebCore::StyleResolver::setOrPendingFromValue):
(WebCore::StyleResolver::cursorOrPendingFromValue):
(WebCore::StyleResolver::checkForTextSizeAdjust):
(WebCore::StyleResolver::initializeFontStyle):
(WebCore::StyleResolver::setFontSize):
(WebCore::StyleResolver::colorFromPrimitiveValue):
(WebCore::StyleResolver::loadPendingSVGDocuments):
(WebCore::StyleResolver::cachedOrPendingStyleShaderFromValue):
(WebCore::StyleResolver::loadPendingShaders):
(WebCore::StyleResolver::parseCustomFilterTransformParameter):
(WebCore::StyleResolver::createFilterOperations):
(WebCore::StyleResolver::loadPendingImage):
(WebCore::StyleResolver::loadPendingImages):

  • css/StyleResolver.h:

(WebCore::StyleResolver::style):
(WebCore::StyleResolver::parentStyle):
(WebCore::StyleResolver::rootElementStyle):
(WebCore::StyleResolver::element):
(WebCore::StyleResolver::hasParentNode):
(StyleResolver):
(WebCore::StyleResolver::State::State):
(State):
(WebCore::StyleResolver::State::clear):
Modified to use clear at the end of styleForElement.
(WebCore::StyleResolver::State::document):
(WebCore::StyleResolver::State::element):
(WebCore::StyleResolver::State::styledElement):
(WebCore::StyleResolver::State::setStyle):
(WebCore::StyleResolver::State::style):
(WebCore::StyleResolver::State::takeStyle):
(WebCore::StyleResolver::State::ensureRuleList):
(WebCore::StyleResolver::State::takeRuleList):
(WebCore::StyleResolver::State::parentNode):
(WebCore::StyleResolver::State::setParentStyle):
(WebCore::StyleResolver::State::parentStyle):
(WebCore::StyleResolver::State::rootElementStyle):
(WebCore::StyleResolver::State::regionForStyling):
(WebCore::StyleResolver::State::setSameOriginOnly):
(WebCore::StyleResolver::State::isSameOriginOnly):
(WebCore::StyleResolver::State::pseudoStyle):
(WebCore::StyleResolver::State::elementLinkState):
(WebCore::StyleResolver::State::distributedToInsertionPoint):
(WebCore::StyleResolver::State::setElementAffectedByClassRules):
(WebCore::StyleResolver::State::elementAffectedByClassRules):
(WebCore::StyleResolver::State::setApplyPropertyToRegularStyle):
(WebCore::StyleResolver::State::setApplyPropertyToVisitedLinkStyle):
(WebCore::StyleResolver::State::applyPropertyToRegularStyle):
(WebCore::StyleResolver::State::applyPropertyToVisitedLinkStyle):
(WebCore::StyleResolver::State::pendingImageProperties):
(WebCore::StyleResolver::State::pendingSVGDocuments):
(WebCore::StyleResolver::State::setHasPendingShaders):
(WebCore::StyleResolver::State::hasPendingShaders):
(WebCore::StyleResolver::State::setLineHeightValue):
(WebCore::StyleResolver::State::lineHeightValue):
(WebCore::StyleResolver::State::setFontDirty):
(WebCore::StyleResolver::State::fontDirty):
(WebCore::StyleResolver::State::cacheBorderAndBackground):
(WebCore::StyleResolver::State::hasUAAppearance):
(WebCore::StyleResolver::State::borderData):
(WebCore::StyleResolver::State::backgroundData):
(WebCore::StyleResolver::State::backgroundColor):
(WebCore::StyleResolver::State::fontDescription):
(WebCore::StyleResolver::State::parentFontDescription):
(WebCore::StyleResolver::State::setFontDescription):
(WebCore::StyleResolver::State::setZoom):
(WebCore::StyleResolver::State::setEffectiveZoom):
(WebCore::StyleResolver::State::setTextSizeAdjust):
(WebCore::StyleResolver::State::setWritingMode):
(WebCore::StyleResolver::State::setTextOrientation):
fontDescription, ... and setTextOrientation were moved from
StyleResolver.
(WebCore::StyleResolver::State::matchedRules):
(WebCore::StyleResolver::State::addMatchedRule):
Moved from StyleResolver.
(WebCore::StyleResolver::applyPropertyToRegularStyle):
(WebCore::StyleResolver::applyPropertyToVisitedLinkStyle):
(WebCore::StyleResolver::fontDescription):
(WebCore::StyleResolver::parentFontDescription):
(WebCore::StyleResolver::setFontDescription):
(WebCore::StyleResolver::setZoom):
(WebCore::StyleResolver::setEffectiveZoom):
(WebCore::StyleResolver::setTextSizeAdjust):
(WebCore::StyleResolver::setWritingMode):
(WebCore::StyleResolver::setTextOrientation):
These fontDescription, ..., setTextOrientation are wrappers to
invoke State's methods. StyleBuilder still depends on StyleResolver
and invokes these methods. So we need these wrappers.

LayoutTests: [Refactoring] StyleResolver::State should have methods to access its me
https://bugs.webkit.org/show_bug.cgi?id=108563

Reviewed by Antti Koivisto.

  • inspector/styles/region-style-crash-expected.txt:

Rebaseline. Since inspector hasn't supported CSS region styles yet,
region-style-crash.html has no CSS region styles as its result.

Location:
trunk
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r142754 r142757  
     12013-02-13  Takashi Sakamoto  <tasak@google.com>
     2
     3        [Refactoring] StyleResolver::State should have methods to access its me
     4        https://bugs.webkit.org/show_bug.cgi?id=108563
     5
     6        Reviewed by Antti Koivisto.
     7
     8        * inspector/styles/region-style-crash-expected.txt:
     9        Rebaseline. Since inspector hasn't supported CSS region styles yet,
     10        region-style-crash.html has no CSS region styles as its result.
     11
    1122013-02-13  Rashmi Shyamasundar  <rashmi.s2@samsung.com>
    213
  • trunk/LayoutTests/inspector/styles/region-style-crash-expected.txt

    r131188 r142757  
    1414======== Matched CSS Rules ========
    1515[expanded]
    16 #p1  { (region-style-crash.html:8)
    17 
    18 [expanded]
    1916#p1  { (region-style-crash.html:6)
    2017color: #ff0000;
     
    2926
    3027
    31 ======== Pseudo ::first-line element ========
    32 [expanded]
    33 #p1  { (region-style-crash.html:8)
    3428
    35 
    36 ======== Pseudo ::first-letter element ========
    37 [expanded]
    38 #p1  { (region-style-crash.html:8)
    39 
    40 
    41 ======== Pseudo ::before element ========
    42 [expanded]
    43 #p1  { (region-style-crash.html:8)
    44 
    45 
    46 ======== Pseudo ::after element ========
    47 [expanded]
    48 #p1  { (region-style-crash.html:8)
    49 
    50 
    51 ======== Pseudo ::selection element ========
    52 [expanded]
    53 #p1  { (region-style-crash.html:8)
    54 
    55 
    56 ======== Pseudo element ========
    57 [expanded]
    58 #p1  { (region-style-crash.html:8)
    59 
    60 
    61 ======== Pseudo ::-webkit-scrollbar element ========
    62 [expanded]
    63 #p1  { (region-style-crash.html:8)
    64 
    65 
    66 ======== Pseudo ::-webkit-file-upload-button element ========
    67 [expanded]
    68 #p1  { (region-style-crash.html:8)
    69 
    70 
    71 ======== Pseudo ::-webkit-input-placeholder element ========
    72 [expanded]
    73 #p1  { (region-style-crash.html:8)
    74 
    75 
    76 ======== Pseudo ::-webkit-slider-thumb element ========
    77 [expanded]
    78 #p1  { (region-style-crash.html:8)
    79 
    80 
    81 ======== Pseudo ::-webkit-search-cancel-button element ========
    82 [expanded]
    83 #p1  { (region-style-crash.html:8)
    84 
    85 
    86 ======== Pseudo ::-webkit-search-decoration element ========
    87 [expanded]
    88 #p1  { (region-style-crash.html:8)
    89 
    90 
    91 ======== Pseudo ::-webkit-search-results-decoration element ========
    92 [expanded]
    93 #p1  { (region-style-crash.html:8)
    94 
    95 
    96 ======== Pseudo ::-webkit-search-results-button element ========
    97 [expanded]
    98 #p1  { (region-style-crash.html:8)
    99 
    100 
    101 
  • trunk/Source/WebCore/ChangeLog

    r142755 r142757  
     12013-02-13  Takashi Sakamoto  <tasak@google.com>
     2
     3        [Refactoring] StyleResolver::State should have methods to access its member variables.
     4        https://bugs.webkit.org/show_bug.cgi?id=108563
     5
     6        Reviewed by Antti Koivisto.
     7
     8        Made all member variables private and added methods to access the
     9        variables, because most of the member variables are read-only.
     10        We don't need to update those read-only variables while resolving
     11        styles.
     12
     13        No new tests, because just refactoring.
     14
     15        * css/SVGCSSStyleSelector.cpp:
     16        (WebCore::StyleResolver::applySVGProperty):
     17        * css/StyleResolver.cpp:
     18        (WebCore):
     19        (WebCore::StyleResolver::collectMatchingRules):
     20        (WebCore::StyleResolver::collectMatchingRulesForRegion):
     21        (WebCore::StyleResolver::sortAndTransferMatchedRules):
     22        (WebCore::StyleResolver::matchScopedAuthorRules):
     23        (WebCore::StyleResolver::styleSharingCandidateMatchesHostRules):
     24        (WebCore::StyleResolver::matchHostRules):
     25        (WebCore::StyleResolver::matchAuthorRules):
     26        (WebCore::StyleResolver::matchUserRules):
     27        (WebCore::StyleResolver::matchUARules):
     28        (WebCore::StyleResolver::collectMatchingRulesForList):
     29        (WebCore::StyleResolver::sortMatchedRules):
     30        (WebCore::StyleResolver::matchAllRules):
     31        (WebCore::StyleResolver::State::initElement):
     32        (WebCore::StyleResolver::initElement):
     33        Modified to invoke m_state.initElement if a given element is
     34        different from current m_state's element.
     35        (WebCore::StyleResolver::State::initForStyleResolve):
     36        Moved from StyleResolver.
     37        (WebCore::StyleResolver::styleSharingCandidateMatchesRuleSet):
     38        (WebCore::StyleResolver::canShareStyleWithControl):
     39        (WebCore::StyleResolver::sharingCandidateHasIdenticalStyleAffectingAttributes):
     40        (WebCore::StyleResolver::canShareStyleWithElement):
     41        (WebCore::StyleResolver::locateSharedStyle):
     42        (WebCore::StyleResolver::styleForElement):
     43        (WebCore::StyleResolver::styleForKeyframe):
     44        (WebCore::StyleResolver::keyframeStylesForAnimation):
     45        (WebCore::StyleResolver::pseudoStyleForElement):
     46        Changed ASSERT in the first line. ASSERT(m_state.parentStyle) would be
     47        wrong, because it depends on previous resolving. However,
     48        initForStyleResolve will also update m_state.parentStyle. No code in
     49        pseudoStyleForElement depends on previous resolving state.
     50        (WebCore::StyleResolver::styleForPage):
     51        (WebCore::StyleResolver::defaultStyleForElement):
     52        (WebCore::StyleResolver::adjustRenderStyle):
     53        (WebCore::StyleResolver::updateFont):
     54        (WebCore::StyleResolver::pseudoStyleRulesForElement):
     55        (WebCore::StyleResolver::ruleMatches):
     56        Added one more parameter, dynamicPseudo, because dynamicPseudo in
     57        State class is just used for returning matched pseudo style from
     58        this ruleMatches to collectMatchingRulesForList. No need to keep
     59        dynamicPseudo while resolving styles.
     60        (WebCore::StyleResolver::checkRegionSelector):
     61        Removed m_pseudoStyle = NOPSEUDO, because this method uses just
     62        SelectorChecker::matched. SelectorChecker doesn't see StyleResolver's
     63        m_pseudoStyle directly. Need to use SelectorCheckerContext. So no
     64        need to set m_pseudoStyle to be NOPSEUDO.
     65        (WebCore::StyleResolver::applyProperties):
     66        (WebCore::StyleResolver::applyMatchedProperties):
     67        (WebCore::StyleResolver::isLeftPage):
     68        (WebCore::StyleResolver::applyPropertyToStyle):
     69        (WebCore::StyleResolver::useSVGZoomRules):
     70        (WebCore::createGridTrackBreadth):
     71        (WebCore::StyleResolver::resolveVariables):
     72        (WebCore::StyleResolver::applyProperty):
     73        (WebCore::StyleResolver::cachedOrPendingFromValue):
     74        (WebCore::StyleResolver::generatedOrPendingFromValue):
     75        (WebCore::StyleResolver::setOrPendingFromValue):
     76        (WebCore::StyleResolver::cursorOrPendingFromValue):
     77        (WebCore::StyleResolver::checkForTextSizeAdjust):
     78        (WebCore::StyleResolver::initializeFontStyle):
     79        (WebCore::StyleResolver::setFontSize):
     80        (WebCore::StyleResolver::colorFromPrimitiveValue):
     81        (WebCore::StyleResolver::loadPendingSVGDocuments):
     82        (WebCore::StyleResolver::cachedOrPendingStyleShaderFromValue):
     83        (WebCore::StyleResolver::loadPendingShaders):
     84        (WebCore::StyleResolver::parseCustomFilterTransformParameter):
     85        (WebCore::StyleResolver::createFilterOperations):
     86        (WebCore::StyleResolver::loadPendingImage):
     87        (WebCore::StyleResolver::loadPendingImages):
     88        * css/StyleResolver.h:
     89        (WebCore::StyleResolver::style):
     90        (WebCore::StyleResolver::parentStyle):
     91        (WebCore::StyleResolver::rootElementStyle):
     92        (WebCore::StyleResolver::element):
     93        (WebCore::StyleResolver::hasParentNode):
     94        (StyleResolver):
     95        (WebCore::StyleResolver::State::State):
     96        (State):
     97        (WebCore::StyleResolver::State::clear):
     98        Modified to use clear at the end of styleForElement.
     99        (WebCore::StyleResolver::State::document):
     100        (WebCore::StyleResolver::State::element):
     101        (WebCore::StyleResolver::State::styledElement):
     102        (WebCore::StyleResolver::State::setStyle):
     103        (WebCore::StyleResolver::State::style):
     104        (WebCore::StyleResolver::State::takeStyle):
     105        (WebCore::StyleResolver::State::ensureRuleList):
     106        (WebCore::StyleResolver::State::takeRuleList):
     107        (WebCore::StyleResolver::State::parentNode):
     108        (WebCore::StyleResolver::State::setParentStyle):
     109        (WebCore::StyleResolver::State::parentStyle):
     110        (WebCore::StyleResolver::State::rootElementStyle):
     111        (WebCore::StyleResolver::State::regionForStyling):
     112        (WebCore::StyleResolver::State::setSameOriginOnly):
     113        (WebCore::StyleResolver::State::isSameOriginOnly):
     114        (WebCore::StyleResolver::State::pseudoStyle):
     115        (WebCore::StyleResolver::State::elementLinkState):
     116        (WebCore::StyleResolver::State::distributedToInsertionPoint):
     117        (WebCore::StyleResolver::State::setElementAffectedByClassRules):
     118        (WebCore::StyleResolver::State::elementAffectedByClassRules):
     119        (WebCore::StyleResolver::State::setApplyPropertyToRegularStyle):
     120        (WebCore::StyleResolver::State::setApplyPropertyToVisitedLinkStyle):
     121        (WebCore::StyleResolver::State::applyPropertyToRegularStyle):
     122        (WebCore::StyleResolver::State::applyPropertyToVisitedLinkStyle):
     123        (WebCore::StyleResolver::State::pendingImageProperties):
     124        (WebCore::StyleResolver::State::pendingSVGDocuments):
     125        (WebCore::StyleResolver::State::setHasPendingShaders):
     126        (WebCore::StyleResolver::State::hasPendingShaders):
     127        (WebCore::StyleResolver::State::setLineHeightValue):
     128        (WebCore::StyleResolver::State::lineHeightValue):
     129        (WebCore::StyleResolver::State::setFontDirty):
     130        (WebCore::StyleResolver::State::fontDirty):
     131        (WebCore::StyleResolver::State::cacheBorderAndBackground):
     132        (WebCore::StyleResolver::State::hasUAAppearance):
     133        (WebCore::StyleResolver::State::borderData):
     134        (WebCore::StyleResolver::State::backgroundData):
     135        (WebCore::StyleResolver::State::backgroundColor):
     136        (WebCore::StyleResolver::State::fontDescription):
     137        (WebCore::StyleResolver::State::parentFontDescription):
     138        (WebCore::StyleResolver::State::setFontDescription):
     139        (WebCore::StyleResolver::State::setZoom):
     140        (WebCore::StyleResolver::State::setEffectiveZoom):
     141        (WebCore::StyleResolver::State::setTextSizeAdjust):
     142        (WebCore::StyleResolver::State::setWritingMode):
     143        (WebCore::StyleResolver::State::setTextOrientation):
     144        fontDescription, ... and setTextOrientation were moved from
     145        StyleResolver.
     146        (WebCore::StyleResolver::State::matchedRules):
     147        (WebCore::StyleResolver::State::addMatchedRule):
     148        Moved from StyleResolver.
     149        (WebCore::StyleResolver::applyPropertyToRegularStyle):
     150        (WebCore::StyleResolver::applyPropertyToVisitedLinkStyle):
     151        (WebCore::StyleResolver::fontDescription):
     152        (WebCore::StyleResolver::parentFontDescription):
     153        (WebCore::StyleResolver::setFontDescription):
     154        (WebCore::StyleResolver::setZoom):
     155        (WebCore::StyleResolver::setEffectiveZoom):
     156        (WebCore::StyleResolver::setTextSizeAdjust):
     157        (WebCore::StyleResolver::setWritingMode):
     158        (WebCore::StyleResolver::setTextOrientation):
     159        These fontDescription, ..., setTextOrientation are wrappers to
     160        invoke State's methods. StyleBuilder still depends on StyleResolver
     161        and invokes these methods. So we need these wrappers.
     162
    11632013-02-13  Allan Sandfeld Jensen  <allan.jensen@digia.com>
    2164
  • trunk/Source/WebCore/css/SVGCSSStyleSelector.cpp

    r141742 r142757  
    5050if (isInherit) \
    5151{ \
    52     svgstyle->set##Prop(state.parentStyle->svgStyle()->prop()); \
     52    svgstyle->set##Prop(state.parentStyle()->svgStyle()->prop()); \
    5353    return; \
    5454}
     
    111111
    112112    const State& state = m_state;
    113     SVGRenderStyle* svgstyle = state.style->accessSVGStyle();
    114 
    115     bool isInherit = state.parentNode && value->isInheritedValue();
    116     bool isInitial = value->isInitialValue() || (!state.parentNode && value->isInheritedValue());
     113    SVGRenderStyle* svgstyle = state.style()->accessSVGStyle();
     114
     115    bool isInherit = state.parentNode() && value->isInheritedValue();
     116    bool isInitial = value->isInitialValue() || (!state.parentNode() && value->isInheritedValue());
    117117
    118118    // What follows is a list that maps the CSS properties into their
     
    231231        {
    232232            if (isInherit) {
    233                 const SVGRenderStyle* svgParentStyle = state.parentStyle->svgStyle();
     233                const SVGRenderStyle* svgParentStyle = state.parentStyle()->svgStyle();
    234234                svgstyle->setFillPaint(svgParentStyle->fillPaintType(), svgParentStyle->fillPaintColor(), svgParentStyle->fillPaintUri(), applyPropertyToRegularStyle(), applyPropertyToVisitedLinkStyle());
    235235                return;
     
    241241            if (value->isSVGPaint()) {
    242242                SVGPaint* svgPaint = static_cast<SVGPaint*>(value);
    243                 svgstyle->setFillPaint(svgPaint->paintType(), colorFromSVGColorCSSValue(svgPaint, state.style->color()), svgPaint->uri(), applyPropertyToRegularStyle(), applyPropertyToVisitedLinkStyle());
     243                svgstyle->setFillPaint(svgPaint->paintType(), colorFromSVGColorCSSValue(svgPaint, state.style()->color()), svgPaint->uri(), applyPropertyToRegularStyle(), applyPropertyToVisitedLinkStyle());
    244244            }
    245245            break;
     
    248248        {
    249249            if (isInherit) {
    250                 const SVGRenderStyle* svgParentStyle = state.parentStyle->svgStyle();
     250                const SVGRenderStyle* svgParentStyle = state.parentStyle()->svgStyle();
    251251                svgstyle->setStrokePaint(svgParentStyle->strokePaintType(), svgParentStyle->strokePaintColor(), svgParentStyle->strokePaintUri(), applyPropertyToRegularStyle(), applyPropertyToVisitedLinkStyle());
    252252                return;
     
    258258            if (value->isSVGPaint()) {
    259259                SVGPaint* svgPaint = static_cast<SVGPaint*>(value);
    260                 svgstyle->setStrokePaint(svgPaint->paintType(), colorFromSVGColorCSSValue(svgPaint, state.style->color()), svgPaint->uri(), applyPropertyToRegularStyle(), applyPropertyToVisitedLinkStyle());
     260                svgstyle->setStrokePaint(svgPaint->paintType(), colorFromSVGColorCSSValue(svgPaint, state.style()->color()), svgPaint->uri(), applyPropertyToRegularStyle(), applyPropertyToVisitedLinkStyle());
    261261            }
    262262            break;
     
    365365                s = primitiveValue->getStringValue();
    366366
    367             svgstyle->setMarkerStartResource(SVGURIReference::fragmentIdentifierFromIRIString(s, state.element->document()));
     367            svgstyle->setMarkerStartResource(SVGURIReference::fragmentIdentifierFromIRIString(s, state.document()));
    368368            break;
    369369        }
     
    379379                s = primitiveValue->getStringValue();
    380380
    381             svgstyle->setMarkerMidResource(SVGURIReference::fragmentIdentifierFromIRIString(s, state.element->document()));
     381            svgstyle->setMarkerMidResource(SVGURIReference::fragmentIdentifierFromIRIString(s, state.document()));
    382382            break;
    383383        }
     
    393393                s = primitiveValue->getStringValue();
    394394
    395             svgstyle->setMarkerEndResource(SVGURIReference::fragmentIdentifierFromIRIString(s, state.element->document()));
     395            svgstyle->setMarkerEndResource(SVGURIReference::fragmentIdentifierFromIRIString(s, state.document()));
    396396            break;
    397397        }
     
    430430                s = primitiveValue->getStringValue();
    431431
    432             svgstyle->setFilterResource(SVGURIReference::fragmentIdentifierFromIRIString(s, state.element->document()));
     432            svgstyle->setFilterResource(SVGURIReference::fragmentIdentifierFromIRIString(s, state.document()));
    433433            break;
    434434        }
     
    444444                s = primitiveValue->getStringValue();
    445445
    446             svgstyle->setMaskerResource(SVGURIReference::fragmentIdentifierFromIRIString(s, state.element->document()));
     446            svgstyle->setMaskerResource(SVGURIReference::fragmentIdentifierFromIRIString(s, state.document()));
    447447            break;
    448448        }
     
    458458                s = primitiveValue->getStringValue();
    459459
    460             svgstyle->setClipperResource(SVGURIReference::fragmentIdentifierFromIRIString(s, state.element->document()));
     460            svgstyle->setClipperResource(SVGURIReference::fragmentIdentifierFromIRIString(s, state.document()));
    461461            break;
    462462        }
     
    479479            HANDLE_INHERIT_AND_INITIAL(stopColor, StopColor);
    480480            if (value->isSVGColor())
    481                 svgstyle->setStopColor(colorFromSVGColorCSSValue(static_cast<SVGColor*>(value), state.style->color()));
     481                svgstyle->setStopColor(colorFromSVGColorCSSValue(static_cast<SVGColor*>(value), state.style()->color()));
    482482            break;
    483483        }
     
    486486            HANDLE_INHERIT_AND_INITIAL(lightingColor, LightingColor);
    487487            if (value->isSVGColor())
    488                 svgstyle->setLightingColor(colorFromSVGColorCSSValue(static_cast<SVGColor*>(value), state.style->color()));
     488                svgstyle->setLightingColor(colorFromSVGColorCSSValue(static_cast<SVGColor*>(value), state.style()->color()));
    489489            break;
    490490        }
     
    511511            HANDLE_INHERIT_AND_INITIAL(floodColor, FloodColor);
    512512            if (value->isSVGColor())
    513                 svgstyle->setFloodColor(colorFromSVGColorCSSValue(static_cast<SVGColor*>(value), state.style->color()));
     513                svgstyle->setFloodColor(colorFromSVGColorCSSValue(static_cast<SVGColor*>(value), state.style()->color()));
    514514            break;
    515515        }
     
    551551        case CSSPropertyWebkitSvgShadow: {
    552552            if (isInherit)
    553                 return svgstyle->setShadow(adoptPtr(state.parentStyle->svgStyle()->shadow() ? new ShadowData(*state.parentStyle->svgStyle()->shadow()) : 0));
     553                return svgstyle->setShadow(adoptPtr(state.parentStyle()->svgStyle()->shadow() ? new ShadowData(*state.parentStyle()->svgStyle()->shadow()) : 0));
    554554            if (isInitial || primitiveValue) // initial | none
    555555                return svgstyle->setShadow(nullptr);
     
    566566                return;
    567567            ShadowValue* item = static_cast<ShadowValue*>(firstValue);
    568             IntPoint location(item->x->computeLength<int>(state.style.get(), state.rootElementStyle),
    569                 item->y->computeLength<int>(state.style.get(), state.rootElementStyle));
    570             int blur = item->blur ? item->blur->computeLength<int>(state.style.get(), state.rootElementStyle) : 0;
     568            IntPoint location(item->x->computeLength<int>(state.style(), state.rootElementStyle()),
     569                item->y->computeLength<int>(state.style(), state.rootElementStyle()));
     570            int blur = item->blur ? item->blur->computeLength<int>(state.style(), state.rootElementStyle()) : 0;
    571571            Color color;
    572572            if (item->color)
  • trunk/Source/WebCore/css/StyleResolver.cpp

    r142717 r142757  
    195195#define HANDLE_INHERIT(prop, Prop) \
    196196if (isInherit) { \
    197     m_state.style->set##Prop(m_state.parentStyle->prop()); \
     197    m_state.style()->set##Prop(m_state.parentStyle()->prop()); \
    198198    return; \
    199199}
     
    202202HANDLE_INHERIT(prop, Prop) \
    203203if (isInitial) { \
    204     m_state.style->set##Prop(RenderStyle::initial##Prop()); \
     204    m_state.style()->set##Prop(RenderStyle::initial##Prop()); \
    205205    return; \
    206206}
     
    224224}
    225225
     226
     227inline StaticCSSRuleList* StyleResolver::State::ensureRuleList()
     228{
     229    if (!m_ruleList)
     230        m_ruleList = StaticCSSRuleList::create();
     231    return m_ruleList.get();
     232}
     233
     234inline void StyleResolver::State::cacheBorderAndBackground()
     235{
     236    m_hasUAAppearance = m_style->hasAppearance();
     237    if (m_hasUAAppearance) {
     238        m_borderData = m_style->border();
     239        m_backgroundData = *m_style->backgroundLayers();
     240        m_backgroundColor = m_style->backgroundColor();
     241    }
     242}
     243
     244inline void StyleResolver::State::clear()
     245{
     246    m_element = 0;
     247    m_styledElement = 0;
     248    m_parentStyle = 0;
     249    m_parentNode = 0;
     250    m_regionForStyling = 0;
     251    m_ruleList = 0;
     252    m_matchedRules.clear();
     253    m_pendingImageProperties.clear();
     254#if ENABLE(CSS_SHADERS)
     255    m_hasPendingShaders = false;
     256#endif
     257#if ENABLE(CSS_FILTERS) && ENABLE(SVG)
     258    m_pendingSVGDocuments.clear();
     259#endif
     260}
    226261
    227262StyleResolver::StyleResolver(Document* document, bool matchAuthorAndUserStyles)
     
    422457{
    423458    ASSERT(matchRequest.ruleSet);
    424     ASSERT(m_state.element);
     459    ASSERT(m_state.element());
    425460
    426461    State& state = m_state;
    427     Element* element = state.element;
    428     StyledElement* styledElement = state.styledElement;
     462    Element* element = state.element();
     463    const StyledElement* styledElement = state.styledElement();
    429464    const AtomicString& pseudoId = element->shadowPseudoId();
    430465    if (!pseudoId.isEmpty()) {
     
    466501void StyleResolver::collectMatchingRulesForRegion(const MatchRequest& matchRequest, RuleRange& ruleRange)
    467502{
    468     if (!m_state.regionForStyling)
     503    if (!m_state.regionForStyling())
    469504        return;
    470505
     
    472507    for (unsigned i = 0; i < size; ++i) {
    473508        const CSSSelector* regionSelector = matchRequest.ruleSet->m_regionSelectorsAndRuleSets.at(i).selector;
    474         if (checkRegionSelector(regionSelector, static_cast<Element*>(m_state.regionForStyling->node()))) {
     509        if (checkRegionSelector(regionSelector, static_cast<Element*>(m_state.regionForStyling()->node()))) {
    475510            RuleSet* regionRules = matchRequest.ruleSet->m_regionSelectorsAndRuleSets.at(i).ruleSet.get();
    476511            ASSERT(regionRules);
     
    483518{
    484519    State& state = m_state;
    485     if (state.matchedRules.isEmpty())
     520    Vector<const RuleData*, 32>& matchedRules = state.matchedRules();
     521    if (matchedRules.isEmpty())
    486522        return;
    487523
    488524    sortMatchedRules();
    489525
    490     if (state.mode == SelectorChecker::CollectingRules) {
    491         if (!state.ruleList)
    492             state.ruleList = StaticCSSRuleList::create();
    493         for (unsigned i = 0; i < state.matchedRules.size(); ++i)
    494             state.ruleList->rules().append(state.matchedRules[i]->rule()->createCSSOMWrapper());
     526    if (state.mode() == SelectorChecker::CollectingRules) {
     527        for (unsigned i = 0; i < matchedRules.size(); ++i)
     528            state.ensureRuleList()->rules().append(matchedRules[i]->rule()->createCSSOMWrapper());
    495529        return;
    496530    }
    497531
    498532    // Now transfer the set of matched rules over to our list of declarations.
    499     for (unsigned i = 0; i < state.matchedRules.size(); i++) {
    500         if (state.style && state.matchedRules[i]->containsUncommonAttributeSelector())
    501             state.style->setUnique();
    502         addMatchedProperties(result, state.matchedRules[i]->rule()->properties(), state.matchedRules[i]->rule(), state.matchedRules[i]->linkMatchType(), state.matchedRules[i]->propertyWhitelistType());
     533    for (unsigned i = 0; i < matchedRules.size(); i++) {
     534        if (state.style() && matchedRules[i]->containsUncommonAttributeSelector())
     535            state.style()->setUnique();
     536        addMatchedProperties(result, matchedRules[i]->rule()->properties(), matchedRules[i]->rule(), matchedRules[i]->linkMatchType(), matchedRules[i]->propertyWhitelistType());
    503537    }
    504538}
     
    511545
    512546    // Match scoped author rules by traversing the scoped element stack (rebuild it if it got inconsistent).
    513     if (m_scopeResolver->hasScopedStyles() && m_scopeResolver->ensureStackConsistency(m_state.element)) {
    514         bool applyAuthorStyles = m_state.element->treeScope()->applyAuthorStyles();
     547    if (m_scopeResolver->hasScopedStyles() && m_scopeResolver->ensureStackConsistency(m_state.element())) {
     548        bool applyAuthorStyles = m_state.element()->treeScope()->applyAuthorStyles();
    515549        bool documentScope = true;
    516550        unsigned scopeSize = m_scopeResolver->stackSize();
    517551        for (unsigned i = 0; i < scopeSize; ++i) {
    518             m_state.matchedRules.clear();
     552            m_state.matchedRules().clear();
    519553            result.ranges.lastAuthorRule = result.matchedProperties.size() - 1;
    520554
     
    547581{
    548582#if ENABLE(SHADOW_DOM)
    549     return m_scopeResolver && m_scopeResolver->styleSharingCandidateMatchesHostRules(m_state.element);
     583    return m_scopeResolver && m_scopeResolver->styleSharingCandidateMatchesHostRules(m_state.element());
    550584#else
    551585    return false;
     
    558592    ASSERT(m_scopeResolver);
    559593
    560     m_state.matchedRules.clear();
     594    m_state.matchedRules().clear();
    561595    result.ranges.lastAuthorRule = result.matchedProperties.size() - 1;
    562596
    563597    Vector<RuleSet*> matchedRules;
    564     m_scopeResolver->matchHostRules(m_state.element, matchedRules);
     598    m_scopeResolver->matchHostRules(m_state.element(), matchedRules);
    565599    if (matchedRules.isEmpty())
    566600        return;
     
    568602    for (unsigned i = matchedRules.size(); i > 0; --i) {
    569603        RuleRange ruleRange = result.ranges.authorRuleRange();
    570         collectMatchingRules(MatchRequest(matchedRules.at(i-1), includeEmptyRules, m_state.element), ruleRange);
     604        collectMatchingRules(MatchRequest(matchedRules.at(i-1), includeEmptyRules, m_state.element()), ruleRange);
    571605    }
    572606    sortAndTransferMatchedRules(result);
     
    579613void StyleResolver::matchAuthorRules(MatchResult& result, bool includeEmptyRules)
    580614{
    581     m_state.matchedRules.clear();
     615    m_state.matchedRules().clear();
    582616    result.ranges.lastAuthorRule = result.matchedProperties.size() - 1;
    583617
    584     if (!m_state.element)
     618    if (!m_state.element())
    585619        return;
    586620
     
    600634        return;
    601635   
    602     m_state.matchedRules.clear();
     636    m_state.matchedRules().clear();
    603637
    604638    result.ranges.lastUserRule = result.matchedProperties.size() - 1;
     
    613647void StyleResolver::matchUARules(MatchResult& result, RuleSet* rules)
    614648{
    615     m_state.matchedRules.clear();
     649    m_state.matchedRules().clear();
    616650   
    617651    result.ranges.lastUARule = result.matchedProperties.size() - 1;
     
    630664    // In some cases we may end up looking up style for random elements in the middle of a recursive tree resolve.
    631665    // Ancestor identifier filter won't be up-to-date in that case and we can't use the fast path.
    632     bool canUseFastReject = m_selectorFilter.parentStackIsConsistent(state.parentNode);
     666    bool canUseFastReject = m_selectorFilter.parentStackIsConsistent(state.parentNode());
    633667
    634668    unsigned size = rules->size();
     
    640674        StyleRule* rule = ruleData.rule();
    641675        InspectorInstrumentationCookie cookie = InspectorInstrumentation::willMatchRule(document(), rule, this);
    642         if (ruleMatches(ruleData, matchRequest.scope)) {
     676        PseudoId dynamicPseudo = NOPSEUDO;
     677        if (ruleMatches(ruleData, matchRequest.scope, dynamicPseudo)) {
    643678            // If the rule has no properties to apply, then ignore it in the non-debug mode.
    644679            const StylePropertySet* properties = rule->properties();
     
    648683            }
    649684            // FIXME: Exposing the non-standard getMatchedCSSRules API to web is the only reason this is needed.
    650             if (state.sameOriginOnly && !ruleData.hasDocumentSecurityOrigin()) {
     685            if (state.isSameOriginOnly() && !ruleData.hasDocumentSecurityOrigin()) {
    651686                InspectorInstrumentation::didMatchRule(cookie, false);
    652687                continue;
     
    654689            // If we're matching normal rules, set a pseudo bit if
    655690            // we really just matched a pseudo-element.
    656             if (state.dynamicPseudo != NOPSEUDO && state.pseudoStyle == NOPSEUDO) {
    657                 if (state.mode == SelectorChecker::CollectingRules) {
     691            if (dynamicPseudo != NOPSEUDO && state.pseudoStyle() == NOPSEUDO) {
     692                if (state.mode() == SelectorChecker::CollectingRules) {
    658693                    InspectorInstrumentation::didMatchRule(cookie, false);
    659694                    continue;
    660695                }
    661                 if (state.dynamicPseudo < FIRST_INTERNAL_PSEUDOID)
    662                     state.style->setHasPseudoStyle(state.dynamicPseudo);
     696                if (dynamicPseudo < FIRST_INTERNAL_PSEUDOID)
     697                    state.style()->setHasPseudoStyle(dynamicPseudo);
    663698            } else {
    664699                // Update our first/last rule indices in the matched rules array.
     
    668703
    669704                // Add this rule to our list of matched rules.
    670                 addMatchedRule(&ruleData);
     705                m_state.addMatchedRule(&ruleData);
    671706                InspectorInstrumentation::didMatchRule(cookie, true);
    672707                continue;
     
    686721void StyleResolver::sortMatchedRules()
    687722{
    688     std::sort(m_state.matchedRules.begin(), m_state.matchedRules.end(), compareRules);
     723    std::sort(m_state.matchedRules().begin(), m_state.matchedRules().end(), compareRules);
    689724}
    690725
     
    698733
    699734    // Now check author rules, beginning first with presentational attributes mapped from HTML.
    700     if (m_state.styledElement) {
    701         addElementStyleProperties(result, m_state.styledElement->presentationAttributeStyle());
     735    if (m_state.styledElement()) {
     736        addElementStyleProperties(result, m_state.styledElement()->presentationAttributeStyle());
    702737
    703738        // Now we check additional mapped declarations.
    704739        // Tables and table cells share an additional mapped rule that must be applied
    705740        // after all attributes, since their mapped style depends on the values of multiple attributes.
    706         addElementStyleProperties(result, m_state.styledElement->additionalPresentationAttributeStyle());
    707 
    708         if (m_state.styledElement->isHTMLElement()) {
     741        addElementStyleProperties(result, m_state.styledElement()->additionalPresentationAttributeStyle());
     742
     743        if (m_state.styledElement()->isHTMLElement()) {
    709744            bool isAuto;
    710             TextDirection textDirection = toHTMLElement(m_state.styledElement)->directionalityIfhasDirAutoAttribute(isAuto);
     745            TextDirection textDirection = toHTMLElement(m_state.styledElement())->directionalityIfhasDirAutoAttribute(isAuto);
    711746            if (isAuto)
    712747                addMatchedProperties(result, textDirection == LTR ? leftToRightDeclaration() : rightToLeftDeclaration());
     
    719754
    720755    // Now check our inline style attribute.
    721     if (m_matchAuthorAndUserStyles && m_state.styledElement && m_state.styledElement->inlineStyle()) {
     756    if (m_matchAuthorAndUserStyles && m_state.styledElement() && m_state.styledElement()->inlineStyle()) {
    722757        // Inline style is immutable as long as there is no CSSOM wrapper.
    723758        // FIXME: Media control shadow trees seem to have problems with caching.
    724         bool isInlineStyleCacheable = !m_state.styledElement->inlineStyle()->isMutable() && !m_state.styledElement->isInShadowTree();
     759        bool isInlineStyleCacheable = !m_state.styledElement()->inlineStyle()->isMutable() && !m_state.styledElement()->isInShadowTree();
    725760        // FIXME: Constify.
    726         addElementStyleProperties(result, m_state.styledElement->inlineStyle(), isInlineStyleCacheable);
     761        addElementStyleProperties(result, m_state.styledElement()->inlineStyle(), isInlineStyleCacheable);
    727762    }
    728763
    729764#if ENABLE(SVG)
    730765    // Now check SMIL animation override style.
    731     if (includeSMILProperties && m_matchAuthorAndUserStyles && m_state.styledElement && m_state.styledElement->isSVGElement())
    732         addElementStyleProperties(result, static_cast<SVGElement*>(m_state.styledElement)->animatedSMILStyleProperties(), false /* isCacheable */);
     766    if (includeSMILProperties && m_matchAuthorAndUserStyles && m_state.styledElement() && m_state.styledElement()->isSVGElement())
     767        addElementStyleProperties(result, static_cast<SVGElement*>(m_state.styledElement())->animatedSMILStyleProperties(), false /* isCacheable */);
    733768#else
    734769    UNUSED_PARAM(includeSMILProperties);
     
    745780}
    746781
     782inline void StyleResolver::State::initElement(Element* e)
     783{
     784    m_element = e;
     785    m_styledElement = e && e->isStyledElement() ? static_cast<StyledElement*>(e) : 0;
     786    m_elementLinkState = e ? e->document()->visitedLinkState()->determineLinkState(e) : NotInsideLink;
     787}
     788
    747789inline void StyleResolver::initElement(Element* e)
    748790{
    749     if (m_state.element != e) {
    750         m_state.element = e;
    751         m_state.styledElement = m_state.element && m_state.element->isStyledElement() ? static_cast<StyledElement*>(m_state.element) : 0;
    752         m_state.elementLinkState = document()->visitedLinkState()->determineLinkState(e);
     791    if (m_state.element() != e) {
     792        m_state.initElement(e);
    753793        if (e && e == e->document()->documentElement()) {
    754794            e->document()->setDirectionSetOnDocumentElement(false);
     
    758798}
    759799
    760 inline void StyleResolver::initForStyleResolve(Element* e, RenderStyle* parentStyle, PseudoId pseudoID)
    761 {
    762     State& state = m_state;
    763     state.pseudoStyle = pseudoID;
     800inline void StyleResolver::State::initForStyleResolve(Document* document, Element* e, RenderStyle* parentStyle, PseudoId pseudoId, RenderRegion* regionForStyling)
     801{
     802    m_pseudoStyle = pseudoId;
     803    m_regionForStyling = regionForStyling;
    764804
    765805    if (e) {
    766806        NodeRenderingContext context(e);
    767         state.parentNode = context.parentNodeForRenderingAndStyle();
    768         state.parentStyle = context.resetStyleInheritance() ? 0 :
     807        m_parentNode = context.parentNodeForRenderingAndStyle();
     808        m_parentStyle = context.resetStyleInheritance() ? 0 :
    769809            parentStyle ? parentStyle :
    770             state.parentNode ? state.parentNode->renderStyle() : 0;
    771         state.distributedToInsertionPoint = context.insertionPoint();
     810            m_parentNode ? m_parentNode->renderStyle() : 0;
     811        m_distributedToInsertionPoint = context.insertionPoint();
    772812    } else {
    773         state.parentNode = 0;
    774         state.parentStyle = parentStyle;
    775         state.distributedToInsertionPoint = false;
     813        m_parentNode = 0;
     814        m_parentStyle = parentStyle;
     815        m_distributedToInsertionPoint = false;
    776816    }
    777817
    778818    Node* docElement = e ? e->document()->documentElement() : 0;
    779     RenderStyle* docStyle = document()->renderStyle();
    780     state.rootElementStyle = docElement && e != docElement ? docElement->renderStyle() : docStyle;
    781 
    782     state.style = 0;
    783 
    784     state.pendingImageProperties.clear();
    785 
    786     state.ruleList = 0;
    787 
    788     state.fontDirty = false;
     819    RenderStyle* docStyle = document->renderStyle();
     820    m_rootElementStyle = docElement && e != docElement ? docElement->renderStyle() : docStyle;
     821
     822    m_style = 0;
     823    m_pendingImageProperties.clear();
     824    m_ruleList = 0;
     825    m_fontDirty = false;
    789826}
    790827
     
    849886    if (!ruleSet)
    850887        return false;
    851     m_state.matchedRules.clear();
    852 
    853     m_state.mode = SelectorChecker::SharingRules;
     888    m_state.matchedRules().clear();
     889
     890    m_state.setMode(SelectorChecker::SharingRules);
    854891    int firstRuleIndex = -1, lastRuleIndex = -1;
    855892    RuleRange ruleRange(firstRuleIndex, lastRuleIndex);
    856893    collectMatchingRules(MatchRequest(ruleSet), ruleRange);
    857     m_state.mode = SelectorChecker::ResolvingStyle;
    858     if (m_state.matchedRules.isEmpty())
    859         return false;
    860     m_state.matchedRules.clear();
     894    m_state.setMode(SelectorChecker::ResolvingStyle);
     895    if (m_state.matchedRules().isEmpty())
     896        return false;
     897    m_state.matchedRules().clear();
    861898    return true;
    862899}
     
    866903    const State& state = m_state;
    867904    HTMLInputElement* thisInputElement = element->toInputElement();
    868     HTMLInputElement* otherInputElement = state.element->toInputElement();
     905    HTMLInputElement* otherInputElement = state.element()->toInputElement();
    869906
    870907    if (!thisInputElement || !otherInputElement)
     
    887924        return false;
    888925
    889     if (element->isEnabledFormControl() != state.element->isEnabledFormControl())
    890         return false;
    891 
    892     if (element->isDefaultButtonForForm() != state.element->isDefaultButtonForForm())
    893         return false;
    894 
    895     if (state.element->document()->containsValidityStyleRules()) {
     926    if (element->isEnabledFormControl() != state.element()->isEnabledFormControl())
     927        return false;
     928
     929    if (element->isDefaultButtonForForm() != state.element()->isDefaultButtonForForm())
     930        return false;
     931
     932    if (state.document()->containsValidityStyleRules()) {
    896933        bool willValidate = element->willValidate();
    897934
    898         if (willValidate != state.element->willValidate())
     935        if (willValidate != state.element()->willValidate())
    899936            return false;
    900937
    901         if (willValidate && (element->isValidFormControlElement() != state.element->isValidFormControlElement()))
     938        if (willValidate && (element->isValidFormControlElement() != state.element()->isValidFormControlElement()))
    902939            return false;
    903940
    904         if (element->isInRange() != state.element->isInRange())
     941        if (element->isInRange() != state.element()->isInRange())
    905942            return false;
    906943
    907         if (element->isOutOfRange() != state.element->isOutOfRange())
     944        if (element->isOutOfRange() != state.element()->isOutOfRange())
    908945            return false;
    909946    }
     
    921958{
    922959    const State& state = m_state;
    923     if (state.element->attributeData() == sharingCandidate->attributeData())
     960    if (state.element()->attributeData() == sharingCandidate->attributeData())
    924961        return true;
    925     if (state.element->fastGetAttribute(XMLNames::langAttr) != sharingCandidate->fastGetAttribute(XMLNames::langAttr))
    926         return false;
    927     if (state.element->fastGetAttribute(langAttr) != sharingCandidate->fastGetAttribute(langAttr))
    928         return false;
    929 
    930     if (!state.elementAffectedByClassRules) {
     962    if (state.element()->fastGetAttribute(XMLNames::langAttr) != sharingCandidate->fastGetAttribute(XMLNames::langAttr))
     963        return false;
     964    if (state.element()->fastGetAttribute(langAttr) != sharingCandidate->fastGetAttribute(langAttr))
     965        return false;
     966
     967    if (!state.elementAffectedByClassRules()) {
    931968        if (sharingCandidate->hasClass() && classNamesAffectedByRules(sharingCandidate->classNames()))
    932969            return false;
     
    934971#if ENABLE(SVG)
    935972        // SVG elements require a (slow!) getAttribute comparision because "class" is an animatable attribute for SVG.
    936         if (state.element->isSVGElement()) {
    937             if (state.element->getAttribute(classAttr) != sharingCandidate->getAttribute(classAttr))
     973        if (state.element()->isSVGElement()) {
     974            if (state.element()->getAttribute(classAttr) != sharingCandidate->getAttribute(classAttr))
    938975                return false;
    939976        } else {
    940977#endif
    941             if (state.element->classNames() != sharingCandidate->classNames())
     978            if (state.element()->classNames() != sharingCandidate->classNames())
    942979                return false;
    943980#if ENABLE(SVG)
     
    947984        return false;
    948985
    949     if (state.styledElement->presentationAttributeStyle() != sharingCandidate->presentationAttributeStyle())
     986    if (state.styledElement()->presentationAttributeStyle() != sharingCandidate->presentationAttributeStyle())
    950987        return false;
    951988
    952989#if ENABLE(PROGRESS_ELEMENT)
    953     if (state.element->hasTagName(progressTag)) {
    954         if (static_cast<HTMLProgressElement*>(state.element)->isDeterminate() != static_cast<HTMLProgressElement*>(sharingCandidate)->isDeterminate())
     990    if (state.element()->hasTagName(progressTag)) {
     991        if (static_cast<HTMLProgressElement*>(state.element())->isDeterminate() != static_cast<HTMLProgressElement*>(sharingCandidate)->isDeterminate())
    955992            return false;
    956993    }
     
    9691006    if (style->unique())
    9701007        return false;
    971     if (element->tagQName() != state.element->tagQName())
     1008    if (element->tagQName() != state.element()->tagQName())
    9721009        return false;
    9731010    if (element->inlineStyle())
     
    9791016        return false;
    9801017#endif
    981     if (element->isLink() != state.element->isLink())
    982         return false;
    983     if (element->hovered() != state.element->hovered())
    984         return false;
    985     if (element->active() != state.element->active())
    986         return false;
    987     if (element->focused() != state.element->focused())
    988         return false;
    989     if (element->shadowPseudoId() != state.element->shadowPseudoId())
     1018    if (element->isLink() != state.element()->isLink())
     1019        return false;
     1020    if (element->hovered() != state.element()->hovered())
     1021        return false;
     1022    if (element->active() != state.element()->active())
     1023        return false;
     1024    if (element->focused() != state.element()->focused())
     1025        return false;
     1026    if (element->shadowPseudoId() != state.element()->shadowPseudoId())
    9901027        return false;
    9911028    if (element == element->document()->cssTarget())
     
    9931030    if (!sharingCandidateHasIdenticalStyleAffectingAttributes(element))
    9941031        return false;
    995     if (element->additionalPresentationAttributeStyle() != state.styledElement->additionalPresentationAttributeStyle())
     1032    if (element->additionalPresentationAttributeStyle() != state.styledElement()->additionalPresentationAttributeStyle())
    9961033        return false;
    9971034
     
    10091046    bool isControl = element->isFormControlElement();
    10101047
    1011     if (isControl != state.element->isFormControlElement())
     1048    if (isControl != state.element()->isFormControlElement())
    10121049        return false;
    10131050
     
    10331070        return false;
    10341071
    1035     if (element->isLink() && state.elementLinkState != style->insideLink())
     1072    if (element->isLink() && state.elementLinkState() != style->insideLink())
    10361073        return false;
    10371074
    10381075#if ENABLE(VIDEO_TRACK)
    10391076    // Deny sharing styles between WebVTT and non-WebVTT nodes.
    1040     if (element->isWebVTTElement() != state.element->isWebVTTElement())
    1041         return false;
    1042 
    1043     if (element->isWebVTTElement() && state.element->isWebVTTElement() && toWebVTTElement(element)->isPastNode() != toWebVTTElement(state.element)->isPastNode())
     1077    if (element->isWebVTTElement() != state.element()->isWebVTTElement())
     1078        return false;
     1079
     1080    if (element->isWebVTTElement() && state.element()->isWebVTTElement() && toWebVTTElement(element)->isPastNode() != toWebVTTElement(state.element())->isPastNode())
    10441081        return false;
    10451082#endif
    10461083
    10471084#if ENABLE(FULLSCREEN_API)
    1048     if (element == element->document()->webkitCurrentFullScreenElement() || state.element == state.element->document()->webkitCurrentFullScreenElement())
     1085    if (element == element->document()->webkitCurrentFullScreenElement() || state.element() == state.document()->webkitCurrentFullScreenElement())
    10491086        return false;
    10501087#endif
     
    10681105{
    10691106    State& state = m_state;
    1070     if (!state.styledElement || !state.parentStyle)
     1107    if (!state.styledElement() || !state.parentStyle())
    10711108        return 0;
    10721109
    10731110    // If the element has inline style it is probably unique.
    1074     if (state.styledElement->inlineStyle())
     1111    if (state.styledElement()->inlineStyle())
    10751112        return 0;
    10761113#if ENABLE(SVG)
    1077     if (state.styledElement->isSVGElement() && static_cast<SVGElement*>(state.styledElement)->animatedSMILStyleProperties())
     1114    if (state.styledElement()->isSVGElement() && static_cast<SVGElement*>(state.styledElement())->animatedSMILStyleProperties())
    10781115        return 0;
    10791116#endif
    10801117    // Ids stop style sharing if they show up in the stylesheets.
    1081     if (state.styledElement->hasID() && m_ruleSets.features().idsInRules.contains(state.styledElement->idForStyleResolution().impl()))
     1118    if (state.styledElement()->hasID() && m_ruleSets.features().idsInRules.contains(state.styledElement()->idForStyleResolution().impl()))
    10821119        return 0;
    1083     if (parentElementPreventsSharing(state.element->parentElement()))
     1120    if (parentElementPreventsSharing(state.element()->parentElement()))
    10841121        return 0;
    1085     if (state.styledElement->hasScopedHTMLStyleChild())
     1122    if (state.styledElement()->hasScopedHTMLStyleChild())
    10861123        return 0;
    1087     if (state.element == state.element->document()->cssTarget())
     1124    if (state.element() == state.document()->cssTarget())
    10881125        return 0;
    1089     if (elementHasDirectionAuto(state.element))
     1126    if (elementHasDirectionAuto(state.element()))
    10901127        return 0;
    10911128
    10921129    // Cache whether state.element is affected by any known class selectors.
    10931130    // FIXME: This shouldn't be a member variable. The style sharing code could be factored out of StyleResolver.
    1094     state.elementAffectedByClassRules = state.element && state.element->hasClass() && classNamesAffectedByRules(state.element->classNames());
     1131    state.setElementAffectedByClassRules(state.element() && state.element()->hasClass() && classNamesAffectedByRules(state.element()->classNames()));
    10951132
    10961133    // Check previous siblings and their cousins.
     
    10981135    unsigned visitedNodeCount = 0;
    10991136    StyledElement* shareElement = 0;
    1100     Node* cousinList = state.styledElement->previousSibling();
     1137    Node* cousinList = state.styledElement()->previousSibling();
    11011138    while (cousinList) {
    11021139        shareElement = findSiblingForStyleSharing(cousinList, count);
     
    11201157        return 0;
    11211158    // Tracking child index requires unique style for each node. This may get set by the sibling rule match above.
    1122     if (parentElementPreventsSharing(state.element->parentElement()))
     1159    if (parentElementPreventsSharing(state.element()->parentElement()))
    11231160        return 0;
    11241161    return shareElement->renderStyle();
     
    13421379    State& state = m_state;
    13431380    initElement(element);
    1344     initForStyleResolve(element, defaultParent);
    1345     state.regionForStyling = regionForStyling;
    1346     if (sharingBehavior == AllowStyleSharing && !state.distributedToInsertionPoint) {
     1381    state.initForStyleResolve(document(), element, defaultParent, NOPSEUDO, regionForStyling);
     1382    if (sharingBehavior == AllowStyleSharing && !state.distributedToInsertionPoint()) {
    13471383        RenderStyle* sharedStyle = locateSharedStyle();
    13481384        if (sharedStyle)
     
    13521388    RefPtr<RenderStyle> cloneForParent;
    13531389
    1354     if (state.parentStyle) {
    1355         state.style = RenderStyle::create();
    1356         state.style->inheritFrom(state.parentStyle, isAtShadowBoundary(element) ? RenderStyle::AtShadowBoundary : RenderStyle::NotAtShadowBoundary);
     1390    if (state.parentStyle()) {
     1391        state.setStyle(RenderStyle::create());
     1392        state.style()->inheritFrom(state.parentStyle(), isAtShadowBoundary(element) ? RenderStyle::AtShadowBoundary : RenderStyle::NotAtShadowBoundary);
    13571393    } else {
    1358         state.style = defaultStyleForElement();
    1359         cloneForParent = RenderStyle::clone(state.style.get());
    1360         state.parentStyle = cloneForParent.get();
     1394        state.setStyle(defaultStyleForElement());
     1395        cloneForParent = RenderStyle::clone(state.style());
     1396        state.setParentStyle(cloneForParent.get());
    13611397    }
    13621398    // contenteditable attribute (implemented by -webkit-user-modify) should
    13631399    // be propagated from shadow host to distributed node.
    1364     if (state.distributedToInsertionPoint) {
     1400    if (state.distributedToInsertionPoint()) {
    13651401        if (Element* parent = element->parentElement()) {
    13661402            if (RenderStyle* styleOfShadowHost = parent->renderStyle())
    1367                 state.style->setUserModify(styleOfShadowHost->userModify());
     1403                state.style()->setUserModify(styleOfShadowHost->userModify());
    13681404        }
    13691405    }
    13701406
    13711407    if (element->isLink()) {
    1372         state.style->setIsLink(true);
    1373         EInsideLink linkState = state.elementLinkState;
     1408        state.style()->setIsLink(true);
     1409        EInsideLink linkState = state.elementLinkState();
    13741410        if (linkState != NotInsideLink) {
    13751411            bool forceVisited = InspectorInstrumentation::forcePseudoState(element, CSSSelector::PseudoVisited);
     
    13771413                linkState = InsideVisitedLink;
    13781414        }
    1379         state.style->setInsideLink(linkState);
     1415        state.style()->setInsideLink(linkState);
    13801416    }
    13811417
     
    13941430
    13951431    // Clean up our style object's display and text decorations (among other fixups).
    1396     adjustRenderStyle(state.style.get(), state.parentStyle, element);
    1397 
    1398     initElement(0); // Clear out for the next resolve.
    1399 
    1400     if (cloneForParent)
    1401         state.parentStyle = 0;
     1432    adjustRenderStyle(state.style(), state.parentStyle(), element);
     1433
     1434    state.clear(); // Clear out for the next resolve.
    14021435
    14031436    document()->didAccessStyleResolver();
    14041437
    14051438    // Now return the style.
    1406     return state.style.release();
     1439    return state.takeStyle();
    14071440}
    14081441
     
    14131446        addMatchedProperties(result, keyframe->properties());
    14141447
    1415     ASSERT(!m_state.style);
     1448    ASSERT(!m_state.style());
    14161449
    14171450    State& state = m_state;
    14181451
    14191452    // Create the style
    1420     state.style = RenderStyle::clone(elementStyle);
    1421 
    1422     state.lineHeightValue = 0;
     1453    state.setStyle(RenderStyle::clone(elementStyle));
     1454    state.setLineHeightValue(0);
    14231455
    14241456    // We don't need to bother with !important. Since there is only ever one
     
    14321464
    14331465    // Line-height is set when we are sure we decided on the font-size
    1434     if (state.lineHeightValue)
    1435         applyProperty(CSSPropertyLineHeight, state.lineHeightValue);
     1466    if (state.lineHeightValue())
     1467        applyProperty(CSSPropertyLineHeight, state.lineHeightValue());
    14361468
    14371469    // Now do rest of the properties.
     
    14601492    document()->didAccessStyleResolver();
    14611493
    1462     return state.style.release();
     1494    return state.takeStyle();
    14631495}
    14641496
     
    14841516        // Apply the declaration to the style. This is a simplified version of the logic in styleForElement
    14851517        initElement(e);
    1486         initForStyleResolve(e);
     1518        m_state.initForStyleResolve(document(), e);
    14871519
    14881520        const StyleKeyframe* keyframe = keyframes[i].get();
     
    15281560PassRefPtr<RenderStyle> StyleResolver::pseudoStyleForElement(PseudoId pseudo, Element* e, RenderStyle* parentStyle)
    15291561{
    1530     ASSERT(m_state.parentStyle);
     1562    ASSERT(parentStyle);
    15311563    if (!e)
    15321564        return 0;
     
    15361568    initElement(e);
    15371569
    1538     initForStyleResolve(e, parentStyle, pseudo);
    1539     state.style = RenderStyle::create();
    1540     state.style->inheritFrom(m_state.parentStyle);
     1570    state.initForStyleResolve(document(), e, parentStyle, pseudo);
     1571    state.setStyle(RenderStyle::create());
     1572    state.style()->inheritFrom(m_state.parentStyle());
    15411573
    15421574    // Since we don't use pseudo-elements in any of our quirk/print user agent rules, don't waste time walking
     
    15551587        return 0;
    15561588
    1557     state.style->setStyleType(pseudo);
     1589    state.style()->setStyleType(pseudo);
    15581590
    15591591    applyMatchedProperties(matchResult, e);
    15601592
    15611593    // Clean up our style object's display and text decorations (among other fixups).
    1562     adjustRenderStyle(state.style.get(), m_state.parentStyle, 0);
     1594    adjustRenderStyle(state.style(), m_state.parentStyle(), 0);
    15631595
    15641596    // Start loading resources referenced by this style.
     
    15681600
    15691601    // Now return the style.
    1570     return state.style.release();
     1602    return state.takeStyle();
    15711603}
    15721604
    15731605PassRefPtr<RenderStyle> StyleResolver::styleForPage(int pageIndex)
    15741606{
    1575     initForStyleResolve(document()->documentElement()); // m_rootElementStyle will be set to the document style.
    1576 
    1577     m_state.style = RenderStyle::create();
    1578     m_state.style->inheritFrom(m_state.rootElementStyle);
     1607    m_state.initForStyleResolve(document(), document()->documentElement()); // m_rootElementStyle will be set to the document style.
     1608
     1609    m_state.setStyle(RenderStyle::create());
     1610    m_state.style()->inheritFrom(m_state.rootElementStyle());
    15791611
    15801612    const bool isLeft = isLeftPage(pageIndex);
     
    15871619    // Only consider the global author RuleSet for @page rules, as per the HTML5 spec.
    15881620    matchPageRules(result, m_ruleSets.authorStyle(), isLeft, isFirst, page);
    1589     m_state.lineHeightValue = 0;
     1621    m_state.setLineHeightValue(0);
    15901622    bool inheritedOnly = false;
    15911623#if ENABLE(CSS_VARIABLES)
     
    15981630
    15991631    // Line-height is set when we are sure we decided on the font-size.
    1600     if (m_state.lineHeightValue)
    1601         applyProperty(CSSPropertyLineHeight, m_state.lineHeightValue);
     1632    if (m_state.lineHeightValue())
     1633        applyProperty(CSSPropertyLineHeight, m_state.lineHeightValue());
    16021634
    16031635    applyMatchedProperties<LowPriorityProperties>(result, false, 0, result.matchedProperties.size() - 1, inheritedOnly);
     
    16091641
    16101642    // Now return the style.
    1611     return m_state.style.release();
     1643    return m_state.takeStyle();
    16121644}
    16131645
    16141646PassRefPtr<RenderStyle> StyleResolver::defaultStyleForElement()
    16151647{
    1616     m_state.style = RenderStyle::create();
     1648    m_state.setStyle(RenderStyle::create());
    16171649    // Make sure our fonts are initialized if we don't inherit them from our parent style.
    16181650    if (Settings* settings = documentSettings()) {
    16191651        initializeFontStyle(settings);
    1620         m_state.style->font().update(fontSelector());
     1652        m_state.style()->font().update(fontSelector());
    16211653    } else
    1622         m_state.style->font().update(0);
    1623 
    1624     return m_state.style.release();
     1654        m_state.style()->font().update(0);
     1655
     1656    return m_state.takeStyle();
    16251657}
    16261658
     
    19101942    // Let the theme also have a crack at adjusting the style.
    19111943    if (style->hasAppearance())
    1912         RenderTheme::defaultTheme()->adjustStyle(this, style, e, m_state.hasUAAppearance, m_state.borderData, m_state.backgroundData, m_state.backgroundColor);
     1944        RenderTheme::defaultTheme()->adjustStyle(this, style, e, m_state.hasUAAppearance(), m_state.borderData(), m_state.backgroundData(), m_state.backgroundColor());
    19131945
    19141946    // If we have first-letter pseudo style, do not share this style.
     
    19932025void StyleResolver::updateFont()
    19942026{
    1995     if (!m_state.fontDirty)
     2027    if (!m_state.fontDirty())
    19962028        return;
    19972029
    19982030    checkForTextSizeAdjust();
    1999     RenderStyle* style = m_state.style.get();
    2000     checkForGenericFamilyChange(style, m_state.parentStyle);
    2001     checkForZoomChange(style, m_state.parentStyle);
     2031    RenderStyle* style = m_state.style();
     2032    checkForGenericFamilyChange(style, m_state.parentStyle());
     2033    checkForZoomChange(style, m_state.parentStyle());
    20022034    checkForOrientationChange(style);
    2003     m_state.style->font().update(m_fontSelector);
    2004     m_state.fontDirty = false;
    2005 }
    2006 
    2007 void StyleResolver::cacheBorderAndBackground()
    2008 {
    2009     m_state.hasUAAppearance = m_state.style->hasAppearance();
    2010     if (m_state.hasUAAppearance) {
    2011         m_state.borderData = m_state.style->border();
    2012         m_state.backgroundData = *m_state.style->backgroundLayers();
    2013         m_state.backgroundColor = m_state.style->backgroundColor();
    2014     }
     2035    style->font().update(m_fontSelector);
     2036    m_state.setFontDirty(false);
    20152037}
    20162038
     
    20252047        return 0;
    20262048
    2027     m_state.mode = SelectorChecker::CollectingRules;
     2049    m_state.setMode(SelectorChecker::CollectingRules);
    20282050
    20292051    initElement(e);
    2030     initForStyleResolve(e, 0, pseudoId);
     2052    m_state.initForStyleResolve(document(), e, 0, pseudoId);
    20312053
    20322054    MatchResult dummy;
     
    20412063
    20422064    if (m_matchAuthorAndUserStyles && (rulesToInclude & AuthorCSSRules)) {
    2043         m_state.sameOriginOnly = !(rulesToInclude & CrossOriginCSSRules);
     2065        m_state.setSameOriginOnly(!(rulesToInclude & CrossOriginCSSRules));
    20442066
    20452067        // Check the rules in author sheets.
    20462068        matchAuthorRules(dummy, rulesToInclude & EmptyCSSRules);
    20472069
    2048         m_state.sameOriginOnly = false;
    2049     }
    2050 
    2051     m_state.mode = SelectorChecker::ResolvingStyle;
    2052 
    2053     return m_state.ruleList.release();
    2054 }
    2055 
    2056 inline bool StyleResolver::ruleMatches(const RuleData& ruleData, const ContainerNode* scope)
     2070        m_state.setSameOriginOnly(false);
     2071    }
     2072
     2073    m_state.setMode(SelectorChecker::ResolvingStyle);
     2074
     2075    return m_state.takeRuleList();
     2076}
     2077
     2078inline bool StyleResolver::ruleMatches(const RuleData& ruleData, const ContainerNode* scope, PseudoId& dynamicPseudo)
    20572079{
    20582080    State& state = m_state;
    2059     state.dynamicPseudo = NOPSEUDO;
    20602081
    20612082    if (ruleData.hasFastCheckableSelector()) {
    20622083        // We know this selector does not include any pseudo elements.
    2063         if (state.pseudoStyle != NOPSEUDO)
     2084        if (state.pseudoStyle() != NOPSEUDO)
    20642085            return false;
    20652086        // We know a sufficiently simple single part selector matches simply because we found it from the rule hash.
    20662087        // This is limited to HTML only so we don't need to check the namespace.
    2067         if (ruleData.hasRightmostSelectorMatchingHTMLBasedOnRuleHash() && state.element->isHTMLElement()) {
     2088        if (ruleData.hasRightmostSelectorMatchingHTMLBasedOnRuleHash() && state.element()->isHTMLElement()) {
    20682089            if (!ruleData.hasMultipartSelector())
    20692090                return true;
    20702091        }
    2071         if (ruleData.selector()->m_match == CSSSelector::Tag && !SelectorChecker::tagMatches(state.element, ruleData.selector()->tagQName()))
     2092        if (ruleData.selector()->m_match == CSSSelector::Tag && !SelectorChecker::tagMatches(state.element(), ruleData.selector()->tagQName()))
    20722093            return false;
    2073         if (!SelectorChecker::fastCheckRightmostAttributeSelector(state.element, ruleData.selector()))
     2094        if (!SelectorChecker::fastCheckRightmostAttributeSelector(state.element(), ruleData.selector()))
    20742095            return false;
    20752096
    2076         return SelectorChecker::fastCheck(ruleData.selector(), state.element);
     2097        return SelectorChecker::fastCheck(ruleData.selector(), state.element());
    20772098    }
    20782099
    20792100    // Slow path.
    2080     SelectorChecker selectorChecker(document(), state.mode);
    2081     SelectorChecker::SelectorCheckingContext context(ruleData.selector(), state.element, SelectorChecker::VisitedMatchEnabled);
    2082     context.elementStyle = state.style.get();
     2101    SelectorChecker selectorChecker(document(), state.mode());
     2102    SelectorChecker::SelectorCheckingContext context(ruleData.selector(), state.element(), SelectorChecker::VisitedMatchEnabled);
     2103    context.elementStyle = state.style();
    20832104    context.scope = scope;
    2084     context.pseudoStyle = state.pseudoStyle;
    2085     SelectorChecker::Match match = selectorChecker.match(context, state.dynamicPseudo, DOMSiblingTraversalStrategy());
     2105    context.pseudoStyle = state.pseudoStyle();
     2106    SelectorChecker::Match match = selectorChecker.match(context, dynamicPseudo, DOMSiblingTraversalStrategy());
    20862107    if (match != SelectorChecker::SelectorMatches)
    20872108        return false;
    2088     if (state.pseudoStyle != NOPSEUDO && state.pseudoStyle != state.dynamicPseudo)
     2109    if (state.pseudoStyle() != NOPSEUDO && state.pseudoStyle() != dynamicPseudo)
    20892110        return false;
    20902111    return true;
     
    20962117        return false;
    20972118
    2098     m_state.pseudoStyle = NOPSEUDO;
    2099 
    2100     SelectorChecker selectorChecker(document(), SelectorChecker::ResolvingStyle);
     2119    SelectorChecker selectorChecker(document(), m_state.mode());
    21012120    for (const CSSSelector* s = regionSelector; s; s = CSSSelectorList::next(s))
    21022121        if (selectorChecker.matches(s, regionElement))
     
    21222141void StyleResolver::applyProperties(const StylePropertySet* properties, StyleRule* rule, bool isImportant, bool inheritedOnly, PropertyWhitelistType propertyWhitelistType)
    21232142{
    2124     ASSERT((propertyWhitelistType != PropertyWhitelistRegion) || m_state.regionForStyling);
     2143    ASSERT((propertyWhitelistType != PropertyWhitelistRegion) || m_state.regionForStyling());
    21252144    InspectorInstrumentationCookie cookie = InspectorInstrumentation::willProcessRule(document(), rule, this);
    21262145
     
    21662185            // we apply line-height later
    21672186            else if (property == CSSPropertyLineHeight)
    2168                 m_state.lineHeightValue = current.value();
     2187                m_state.setLineHeightValue(current.value());
    21692188            break;
    21702189        case LowPriorityProperties:
     
    21832202
    21842203    State& state = m_state;
    2185     if (state.style->insideLink() != NotInsideLink) {
     2204    if (state.style()->insideLink() != NotInsideLink) {
    21862205        for (int i = startIndex; i <= endIndex; ++i) {
    21872206            const MatchedProperties& matchedProperties = matchResult.matchedProperties[i];
    21882207            unsigned linkMatchType = matchedProperties.linkMatchType;
    21892208            // FIXME: It would be nicer to pass these as arguments but that requires changes in many places.
    2190             state.applyPropertyToRegularStyle = linkMatchType & SelectorChecker::MatchLink;
    2191             state.applyPropertyToVisitedLinkStyle = linkMatchType & SelectorChecker::MatchVisited;
     2209            state.setApplyPropertyToRegularStyle(linkMatchType & SelectorChecker::MatchLink);
     2210            state.setApplyPropertyToVisitedLinkStyle(linkMatchType & SelectorChecker::MatchVisited);
    21922211
    21932212            applyProperties<pass>(matchedProperties.properties.get(), matchResult.matchedRules[i], isImportant, inheritedOnly, static_cast<PropertyWhitelistType>(matchedProperties.whitelistType));
    21942213        }
    2195         state.applyPropertyToRegularStyle = true;
    2196         state.applyPropertyToVisitedLinkStyle = false;
     2214        state.setApplyPropertyToRegularStyle(true);
     2215        state.setApplyPropertyToVisitedLinkStyle(false);
    21972216        return;
    21982217    }
     
    23102329        // style declarations. We then only need to apply the inherited properties, if any, as their values can depend on the
    23112330        // element context. This is fast and saves memory by reusing the style data structures.
    2312         state.style->copyNonInheritedFrom(cacheItem->renderStyle.get());
    2313         if (state.parentStyle->inheritedDataShared(cacheItem->parentRenderStyle.get()) && !isAtShadowBoundary(element)) {
    2314             EInsideLink linkStatus = state.style->insideLink();
     2331        state.style()->copyNonInheritedFrom(cacheItem->renderStyle.get());
     2332        if (state.parentStyle()->inheritedDataShared(cacheItem->parentRenderStyle.get()) && !isAtShadowBoundary(element)) {
     2333            EInsideLink linkStatus = state.style()->insideLink();
    23152334            // If the cache item parent style has identical inherited properties to the current parent style then the
    23162335            // resulting style will be identical too. We copy the inherited properties over from the cache and are done.
    2317             state.style->inheritFrom(cacheItem->renderStyle.get());
     2336            state.style()->inheritFrom(cacheItem->renderStyle.get());
    23182337
    23192338            // Unfortunately the link status is treated like an inherited property. We need to explicitly restore it.
    2320             state.style->setInsideLink(linkStatus);
     2339            state.style()->setInsideLink(linkStatus);
    23212340            return;
    23222341        }
     
    23362355    // The order is (1) high-priority not important, (2) high-priority important, (3) normal not important
    23372356    // and (4) normal important.
    2338     state.lineHeightValue = 0;
     2357    state.setLineHeightValue(0);
    23392358    applyMatchedProperties<HighPriorityProperties>(matchResult, false, 0, matchResult.matchedProperties.size() - 1, applyInheritedOnly);
    23402359    applyMatchedProperties<HighPriorityProperties>(matchResult, true, matchResult.ranges.firstAuthorRule, matchResult.ranges.lastAuthorRule, applyInheritedOnly);
     
    23422361    applyMatchedProperties<HighPriorityProperties>(matchResult, true, matchResult.ranges.firstUARule, matchResult.ranges.lastUARule, applyInheritedOnly);
    23432362
    2344     if (cacheItem && cacheItem->renderStyle->effectiveZoom() != state.style->effectiveZoom()) {
    2345         state.fontDirty = true;
     2363    if (cacheItem && cacheItem->renderStyle->effectiveZoom() != state.style()->effectiveZoom()) {
     2364        state.setFontDirty(true);
    23462365        applyInheritedOnly = false;
    23472366    }
     
    23512370
    23522371    // Line-height is set when we are sure we decided on the font-size.
    2353     if (state.lineHeightValue)
    2354         applyProperty(CSSPropertyLineHeight, state.lineHeightValue);
     2372    if (state.lineHeightValue())
     2373        applyProperty(CSSPropertyLineHeight, state.lineHeightValue());
    23552374
    23562375    // Many properties depend on the font. If it changes we just apply all properties.
    2357     if (cacheItem && cacheItem->renderStyle->fontDescription() != state.style->fontDescription())
     2376    if (cacheItem && cacheItem->renderStyle->fontDescription() != state.style()->fontDescription())
    23582377        applyInheritedOnly = false;
    23592378
     
    23622381   
    23632382    // Cache our border and background so that we can examine them later.
    2364     cacheBorderAndBackground();
     2383    state.cacheBorderAndBackground();
    23652384   
    23662385    // Now do the author and user normal priority properties and all the !important properties.
     
    23732392    loadPendingResources();
    23742393   
    2375     ASSERT(!state.fontDirty);
     2394    ASSERT(!state.fontDirty());
    23762395   
    23772396    if (cacheItem || !cacheHash)
    23782397        return;
    2379     if (!isCacheableInMatchedPropertiesCache(state.element, state.style.get(), state.parentStyle))
    2380         return;
    2381     addToMatchedPropertiesCache(state.style.get(), state.parentStyle, cacheHash, matchResult);
     2398    if (!isCacheableInMatchedPropertiesCache(state.element(), state.style(), state.parentStyle()))
     2399        return;
     2400    addToMatchedPropertiesCache(state.style(), state.parentStyle(), cacheHash, matchResult);
    23822401}
    23832402
     
    24442463{
    24452464    bool isFirstPageLeft = false;
    2446     if (!m_state.rootElementStyle->isLeftToRightDirection())
     2465    if (!m_state.rootElementStyle()->isLeftToRightDirection())
    24472466        isFirstPageLeft = true;
    24482467
     
    24652484{
    24662485    initElement(0);
    2467     initForStyleResolve(0, style);
    2468     m_state.style = style;
     2486    m_state.initForStyleResolve(document(), 0, style);
     2487    m_state.setStyle(style);
    24692488    applyPropertyToCurrentStyle(id, value);
    24702489}
     
    25782597bool StyleResolver::useSVGZoomRules()
    25792598{
    2580     return m_state.element && m_state.element->isSVGElement();
     2599    return m_state.element() && m_state.element()->isSVGElement();
    25812600}
    25822601
     
    25932612    }
    25942613
    2595     workingLength = primitiveValue->convertToLength<FixedIntegerConversion | PercentConversion | ViewportPercentageConversion | AutoConversion>(state.style.get(), state.rootElementStyle, state.style->effectiveZoom());
     2614    workingLength = primitiveValue->convertToLength<FixedIntegerConversion | PercentConversion | ViewportPercentageConversion | AutoConversion>(state.style(), state.rootElementStyle(), state.style()->effectiveZoom());
    25962615    if (workingLength.isUndefined())
    25972616        return false;
     
    26992718void StyleResolver::resolveVariables(CSSPropertyID id, CSSValue* value, Vector<std::pair<CSSPropertyID, String> >& knownExpressions)
    27002719{
    2701     std::pair<CSSPropertyID, String> expression(id, value->serializeResolvingVariables(*m_state.style->variables()));
     2720    std::pair<CSSPropertyID, String> expression(id, value->serializeResolvingVariables(*m_state.style()->variables()));
    27022721
    27032722    if (knownExpressions.contains(expression))
     
    27322751
    27332752    State& state = m_state;
    2734     bool isInherit = state.parentNode && value->isInheritedValue();
    2735     bool isInitial = value->isInitialValue() || (!state.parentNode && value->isInheritedValue());
     2753    bool isInherit = state.parentNode() && value->isInheritedValue();
     2754    bool isInitial = value->isInitialValue() || (!state.parentNode() && value->isInheritedValue());
    27362755
    27372756    ASSERT(!isInherit || !isInitial); // isInherit -> !isInitial && isInitial -> !isInherit
    2738     ASSERT(!isInherit || (state.parentNode && state.parentStyle)); // isInherit -> (state.parentNode && state.parentStyle)
    2739 
    2740     if (!state.applyPropertyToRegularStyle && (!state.applyPropertyToVisitedLinkStyle || !isValidVisitedLinkProperty(id))) {
     2757    ASSERT(!isInherit || (state.parentNode() && state.parentStyle())); // isInherit -> (state.parentNode() && state.parentStyle())
     2758
     2759    if (!state.applyPropertyToRegularStyle() && (!state.applyPropertyToVisitedLinkStyle() || !isValidVisitedLinkProperty(id))) {
    27412760        // Limit the properties that can be applied to only the ones honored by :visited.
    27422761        return;
    27432762    }
    27442763
    2745     if (isInherit && !state.parentStyle->hasExplicitlyInheritedProperties() && !CSSProperty::isInheritedProperty(id))
    2746         state.parentStyle->setHasExplicitlyInheritedProperties();
     2764    if (isInherit && !state.parentStyle()->hasExplicitlyInheritedProperties() && !CSSProperty::isInheritedProperty(id))
     2765        state.parentStyle()->setHasExplicitlyInheritedProperties();
    27472766
    27482767#if ENABLE(CSS_VARIABLES)
     
    27522771        ASSERT(!variable->name().isEmpty());
    27532772        ASSERT(!variable->value().isEmpty());
    2754         state.style->setVariable(variable->name(), variable->value());
     2773        state.style()->setVariable(variable->name(), variable->value());
    27552774        return;
    27562775    }
     
    27712790    CSSPrimitiveValue* primitiveValue = value->isPrimitiveValue() ? static_cast<CSSPrimitiveValue*>(value) : 0;
    27722791
    2773     float zoomFactor = state.style->effectiveZoom();
     2792    float zoomFactor = state.style()->effectiveZoom();
    27742793
    27752794    // What follows is a list that maps the CSS properties into their corresponding front-end
     
    27852804
    27862805            if (isInitial) {
    2787                 state.style->clearContent();
     2806                state.style()->clearContent();
    27882807                return;
    27892808            }
     
    27972816                if (item->isImageGeneratorValue()) {
    27982817                    if (item->isGradientValue())
    2799                         state.style->setContent(StyleGeneratedImage::create(static_cast<CSSGradientValue*>(item)->gradientWithStylesResolved(this).get()), didSet);
     2818                        state.style()->setContent(StyleGeneratedImage::create(static_cast<CSSGradientValue*>(item)->gradientWithStylesResolved(this).get()), didSet);
    28002819                    else
    2801                         state.style->setContent(StyleGeneratedImage::create(static_cast<CSSImageGeneratorValue*>(item)), didSet);
     2820                        state.style()->setContent(StyleGeneratedImage::create(static_cast<CSSImageGeneratorValue*>(item)), didSet);
    28022821                    didSet = true;
    28032822#if ENABLE(CSS_IMAGE_SET)
    28042823                } else if (item->isImageSetValue()) {
    2805                     state.style->setContent(setOrPendingFromValue(CSSPropertyContent, static_cast<CSSImageSetValue*>(item)), didSet);
     2824                    state.style()->setContent(setOrPendingFromValue(CSSPropertyContent, static_cast<CSSImageSetValue*>(item)), didSet);
    28062825                    didSet = true;
    28072826#endif
     
    28092828
    28102829                if (item->isImageValue()) {
    2811                     state.style->setContent(cachedOrPendingFromValue(CSSPropertyContent, static_cast<CSSImageValue*>(item)), didSet);
     2830                    state.style()->setContent(cachedOrPendingFromValue(CSSPropertyContent, static_cast<CSSImageValue*>(item)), didSet);
    28122831                    didSet = true;
    28132832                    continue;
     
    28202839
    28212840                if (contentValue->isString()) {
    2822                     state.style->setContent(contentValue->getStringValue().impl(), didSet);
     2841                    state.style()->setContent(contentValue->getStringValue().impl(), didSet);
    28232842                    didSet = true;
    28242843                } else if (contentValue->isAttr()) {
    28252844                    // FIXME: Can a namespace be specified for an attr(foo)?
    2826                     if (state.style->styleType() == NOPSEUDO)
    2827                         state.style->setUnique();
     2845                    if (state.style()->styleType() == NOPSEUDO)
     2846                        state.style()->setUnique();
    28282847                    else
    2829                         state.parentStyle->setUnique();
     2848                        state.parentStyle()->setUnique();
    28302849                    QualifiedName attr(nullAtom, contentValue->getStringValue().impl(), nullAtom);
    2831                     const AtomicString& value = state.element->getAttribute(attr);
    2832                     state.style->setContent(value.isNull() ? emptyAtom : value.impl(), didSet);
     2850                    const AtomicString& value = state.element()->getAttribute(attr);
     2851                    state.style()->setContent(value.isNull() ? emptyAtom : value.impl(), didSet);
    28332852                    didSet = true;
    28342853                    // register the fact that the attribute value affects the style
     
    28412860                        listStyleType = static_cast<EListStyleType>(listStyleIdent - CSSValueDisc);
    28422861                    OwnPtr<CounterContent> counter = adoptPtr(new CounterContent(counterValue->identifier(), listStyleType, counterValue->separator()));
    2843                     state.style->setContent(counter.release(), didSet);
     2862                    state.style()->setContent(counter.release(), didSet);
    28442863                    didSet = true;
    28452864                } else {
    28462865                    switch (contentValue->getIdent()) {
    28472866                    case CSSValueOpenQuote:
    2848                         state.style->setContent(OPEN_QUOTE, didSet);
     2867                        state.style()->setContent(OPEN_QUOTE, didSet);
    28492868                        didSet = true;
    28502869                        break;
    28512870                    case CSSValueCloseQuote:
    2852                         state.style->setContent(CLOSE_QUOTE, didSet);
     2871                        state.style()->setContent(CLOSE_QUOTE, didSet);
    28532872                        didSet = true;
    28542873                        break;
    28552874                    case CSSValueNoOpenQuote:
    2856                         state.style->setContent(NO_OPEN_QUOTE, didSet);
     2875                        state.style()->setContent(NO_OPEN_QUOTE, didSet);
    28572876                        didSet = true;
    28582877                        break;
    28592878                    case CSSValueNoCloseQuote:
    2860                         state.style->setContent(NO_CLOSE_QUOTE, didSet);
     2879                        state.style()->setContent(NO_CLOSE_QUOTE, didSet);
    28612880                        didSet = true;
    28622881                        break;
     
    28682887            }
    28692888            if (!didSet)
    2870                 state.style->clearContent();
     2889                state.style()->clearContent();
    28712890            return;
    28722891        }
    28732892    case CSSPropertyQuotes:
    28742893        if (isInherit) {
    2875             state.style->setQuotes(state.parentStyle->quotes());
     2894            state.style()->setQuotes(state.parentStyle()->quotes());
    28762895            return;
    28772896        }
    28782897        if (isInitial) {
    2879             state.style->setQuotes(0);
     2898            state.style()->setQuotes(0);
    28802899            return;
    28812900        }
     
    28952914                quotes->addPair(std::make_pair(startQuote, endQuote));
    28962915            }
    2897             state.style->setQuotes(quotes);
     2916            state.style()->setQuotes(quotes);
    28982917            return;
    28992918        }
    29002919        if (primitiveValue) {
    29012920            if (primitiveValue->getIdent() == CSSValueNone)
    2902                 state.style->setQuotes(QuotesData::create());
     2921                state.style()->setQuotes(QuotesData::create());
    29032922        }
    29042923        return;
     
    29062925        // list of strings and ids
    29072926        if (isInherit) {
    2908             FontDescription parentFontDescription = state.parentStyle->fontDescription();
    2909             FontDescription fontDescription = state.style->fontDescription();
     2927            FontDescription parentFontDescription = state.parentStyle()->fontDescription();
     2928            FontDescription fontDescription = state.style()->fontDescription();
    29102929            fontDescription.setGenericFamily(parentFontDescription.genericFamily());
    29112930            fontDescription.setFamily(parentFontDescription.firstFamily());
     
    29172936        if (isInitial) {
    29182937            FontDescription initialDesc = FontDescription();
    2919             FontDescription fontDescription = state.style->fontDescription();
     2938            FontDescription fontDescription = state.style()->fontDescription();
    29202939            // We need to adjust the size to account for the generic family change from monospace
    29212940            // to non-monospace.
     
    29312950        if (!value->isValueList())
    29322951            return;
    2933         FontDescription fontDescription = state.style->fontDescription();
     2952        FontDescription fontDescription = state.style()->fontDescription();
    29342953        FontFamily& firstFamily = fontDescription.firstFamily();
    29352954        FontFamily* currFamily = 0;
     
    30093028    case CSSPropertyBackground:
    30103029        if (isInitial) {
    3011             state.style->clearBackgroundLayers();
    3012             state.style->setBackgroundColor(Color());
     3030            state.style()->clearBackgroundLayers();
     3031            state.style()->setBackgroundColor(Color());
    30133032        } else if (isInherit) {
    3014             state.style->inheritBackgroundLayers(*state.parentStyle->backgroundLayers());
    3015             state.style->setBackgroundColor(state.parentStyle->backgroundColor());
     3033            state.style()->inheritBackgroundLayers(*state.parentStyle()->backgroundLayers());
     3034            state.style()->setBackgroundColor(state.parentStyle()->backgroundColor());
    30163035        }
    30173036        return;
    30183037    case CSSPropertyWebkitMask:
    30193038        if (isInitial)
    3020             state.style->clearMaskLayers();
     3039            state.style()->clearMaskLayers();
    30213040        else if (isInherit)
    3022             state.style->inheritMaskLayers(*state.parentStyle->maskLayers());
     3041            state.style()->inheritMaskLayers(*state.parentStyle()->maskLayers());
    30233042        return;
    30243043    case CSSPropertyFont:
    30253044        if (isInherit) {
    3026             FontDescription fontDescription = state.parentStyle->fontDescription();
    3027             state.style->setLineHeight(state.parentStyle->specifiedLineHeight());
    3028             state.lineHeightValue = 0;
     3045            FontDescription fontDescription = state.parentStyle()->fontDescription();
     3046            state.style()->setLineHeight(state.parentStyle()->specifiedLineHeight());
     3047            state.setLineHeightValue(0);
    30293048            setFontDescription(fontDescription);
    30303049        } else if (isInitial) {
     
    30353054            initializeFontStyle(settings);
    30363055        } else if (primitiveValue) {
    3037             state.style->setLineHeight(RenderStyle::initialLineHeight());
    3038             state.lineHeightValue = 0;
     3056            state.style()->setLineHeight(RenderStyle::initialLineHeight());
     3057            state.setLineHeightValue(0);
    30393058
    30403059            FontDescription fontDescription;
     
    30523071
    30533072                // Handle the zoom factor.
    3054                 fontDescription.setComputedSize(getComputedSizeFromSpecifiedSize(document(), state.style.get(), fontDescription.isAbsoluteSize(), fontDescription.specifiedSize(), useSVGZoomRules()));
     3073                fontDescription.setComputedSize(getComputedSizeFromSpecifiedSize(document(), state.style(), fontDescription.isAbsoluteSize(), fontDescription.specifiedSize(), useSVGZoomRules()));
    30553074                setFontDescription(fontDescription);
    30563075            }
     
    30703089            applyProperty(CSSPropertyFontSize, font->size.get());
    30713090
    3072             state.lineHeightValue = font->lineHeight.get();
     3091            state.setLineHeightValue(font->lineHeight.get());
    30733092
    30743093            applyProperty(CSSPropertyFontFamily, font->family.get());
     
    30823101        if (isInherit) {
    30833102            if (id == CSSPropertyTextShadow)
    3084                 return state.style->setTextShadow(state.parentStyle->textShadow() ? adoptPtr(new ShadowData(*state.parentStyle->textShadow())) : nullptr);
    3085             return state.style->setBoxShadow(state.parentStyle->boxShadow() ? adoptPtr(new ShadowData(*state.parentStyle->boxShadow())) : nullptr);
     3103                return state.style()->setTextShadow(state.parentStyle()->textShadow() ? adoptPtr(new ShadowData(*state.parentStyle()->textShadow())) : nullptr);
     3104            return state.style()->setBoxShadow(state.parentStyle()->boxShadow() ? adoptPtr(new ShadowData(*state.parentStyle()->boxShadow())) : nullptr);
    30863105        }
    30873106        if (isInitial || primitiveValue) // initial | none
    3088             return id == CSSPropertyTextShadow ? state.style->setTextShadow(nullptr) : state.style->setBoxShadow(nullptr);
     3107            return id == CSSPropertyTextShadow ? state.style()->setTextShadow(nullptr) : state.style()->setBoxShadow(nullptr);
    30893108
    30903109        if (!value->isValueList())
     
    30963115                continue;
    30973116            ShadowValue* item = static_cast<ShadowValue*>(currValue);
    3098             int x = item->x->computeLength<int>(state.style.get(), state.rootElementStyle, zoomFactor);
    3099             int y = item->y->computeLength<int>(state.style.get(), state.rootElementStyle, zoomFactor);
    3100             int blur = item->blur ? item->blur->computeLength<int>(state.style.get(), state.rootElementStyle, zoomFactor) : 0;
    3101             int spread = item->spread ? item->spread->computeLength<int>(state.style.get(), state.rootElementStyle, zoomFactor) : 0;
     3117            int x = item->x->computeLength<int>(state.style(), state.rootElementStyle(), zoomFactor);
     3118            int y = item->y->computeLength<int>(state.style(), state.rootElementStyle(), zoomFactor);
     3119            int blur = item->blur ? item->blur->computeLength<int>(state.style(), state.rootElementStyle(), zoomFactor) : 0;
     3120            int spread = item->spread ? item->spread->computeLength<int>(state.style(), state.rootElementStyle(), zoomFactor) : 0;
    31023121            ShadowStyle shadowStyle = item->style && item->style->getIdent() == CSSValueInset ? Inset : Normal;
    31033122            Color color;
    31043123            if (item->color)
    31053124                color = colorFromPrimitiveValue(item->color.get());
    3106             else if (state.style)
    3107                 color = state.style->color();
     3125            else if (state.style())
     3126                color = state.style()->color();
    31083127
    31093128            OwnPtr<ShadowData> shadowData = adoptPtr(new ShadowData(IntPoint(x, y), blur, spread, shadowStyle, id == CSSPropertyWebkitBoxShadow, color.isValid() ? color : Color::transparent));
    31103129            if (id == CSSPropertyTextShadow)
    3111                 state.style->setTextShadow(shadowData.release(), i.index()); // add to the list if this is not the first entry
     3130                state.style()->setTextShadow(shadowData.release(), i.index()); // add to the list if this is not the first entry
    31123131            else
    3113                 state.style->setBoxShadow(shadowData.release(), i.index()); // add to the list if this is not the first entry
     3132                state.style()->setBoxShadow(shadowData.release(), i.index()); // add to the list if this is not the first entry
    31143133        }
    31153134        return;
     
    31183137        HANDLE_INHERIT_AND_INITIAL(boxReflect, BoxReflect)
    31193138        if (primitiveValue) {
    3120             state.style->setBoxReflect(RenderStyle::initialBoxReflect());
     3139            state.style()->setBoxReflect(RenderStyle::initialBoxReflect());
    31213140            return;
    31223141        }
     
    31293148        reflection->setDirection(*reflectValue->direction());
    31303149        if (reflectValue->offset())
    3131             reflection->setOffset(reflectValue->offset()->convertToLength<FixedIntegerConversion | PercentConversion | CalculatedConversion>(state.style.get(), state.rootElementStyle, zoomFactor));
     3150            reflection->setOffset(reflectValue->offset()->convertToLength<FixedIntegerConversion | PercentConversion | CalculatedConversion>(state.style(), state.rootElementStyle(), zoomFactor));
    31323151        NinePieceImage mask;
    31333152        mask.setMaskDefaults();
     
    31353154        reflection->setMask(mask);
    31363155
    3137         state.style->setBoxReflect(reflection.release());
     3156        state.style()->setBoxReflect(reflection.release());
    31383157        return;
    31393158    }
     
    31443163    case CSSPropertyWebkitColumnRule:
    31453164        if (isInherit) {
    3146             state.style->setColumnRuleColor(state.parentStyle->columnRuleColor().isValid() ? state.parentStyle->columnRuleColor() : state.parentStyle->color());
    3147             state.style->setColumnRuleStyle(state.parentStyle->columnRuleStyle());
    3148             state.style->setColumnRuleWidth(state.parentStyle->columnRuleWidth());
     3165            state.style()->setColumnRuleColor(state.parentStyle()->columnRuleColor().isValid() ? state.parentStyle()->columnRuleColor() : state.parentStyle()->color());
     3166            state.style()->setColumnRuleStyle(state.parentStyle()->columnRuleStyle());
     3167            state.style()->setColumnRuleWidth(state.parentStyle()->columnRuleWidth());
    31493168        } else if (isInitial)
    3150             state.style->resetColumnRule();
     3169            state.style()->resetColumnRule();
    31513170        return;
    31523171    case CSSPropertyWebkitMarquee:
    31533172        if (!isInherit)
    31543173            return;
    3155         state.style->setMarqueeDirection(state.parentStyle->marqueeDirection());
    3156         state.style->setMarqueeIncrement(state.parentStyle->marqueeIncrement());
    3157         state.style->setMarqueeSpeed(state.parentStyle->marqueeSpeed());
    3158         state.style->setMarqueeLoopCount(state.parentStyle->marqueeLoopCount());
    3159         state.style->setMarqueeBehavior(state.parentStyle->marqueeBehavior());
     3174        state.style()->setMarqueeDirection(state.parentStyle()->marqueeDirection());
     3175        state.style()->setMarqueeIncrement(state.parentStyle()->marqueeIncrement());
     3176        state.style()->setMarqueeSpeed(state.parentStyle()->marqueeSpeed());
     3177        state.style()->setMarqueeLoopCount(state.parentStyle()->marqueeLoopCount());
     3178        state.style()->setMarqueeBehavior(state.parentStyle()->marqueeBehavior());
    31603179        return;
    31613180    case CSSPropertyWebkitMarqueeRepetition: {
     
    31643183            return;
    31653184        if (primitiveValue->getIdent() == CSSValueInfinite)
    3166             state.style->setMarqueeLoopCount(-1); // -1 means repeat forever.
     3185            state.style()->setMarqueeLoopCount(-1); // -1 means repeat forever.
    31673186        else if (primitiveValue->isNumber())
    3168             state.style->setMarqueeLoopCount(primitiveValue->getIntValue());
     3187            state.style()->setMarqueeLoopCount(primitiveValue->getIntValue());
    31693188        return;
    31703189    }
     
    31763195            switch (ident) {
    31773196            case CSSValueSlow:
    3178                 state.style->setMarqueeSpeed(500); // 500 msec.
     3197                state.style()->setMarqueeSpeed(500); // 500 msec.
    31793198                break;
    31803199            case CSSValueNormal:
    3181                 state.style->setMarqueeSpeed(85); // 85msec. The WinIE default.
     3200                state.style()->setMarqueeSpeed(85); // 85msec. The WinIE default.
    31823201                break;
    31833202            case CSSValueFast:
    3184                 state.style->setMarqueeSpeed(10); // 10msec. Super fast.
     3203                state.style()->setMarqueeSpeed(10); // 10msec. Super fast.
    31853204                break;
    31863205            }
    31873206        } else if (primitiveValue->isTime())
    3188             state.style->setMarqueeSpeed(primitiveValue->computeTime<int, CSSPrimitiveValue::Milliseconds>());
     3207            state.style()->setMarqueeSpeed(primitiveValue->computeTime<int, CSSPrimitiveValue::Milliseconds>());
    31893208        else if (primitiveValue->isNumber()) // For scrollamount support.
    3190             state.style->setMarqueeSpeed(primitiveValue->getIntValue());
     3209            state.style()->setMarqueeSpeed(primitiveValue->getIntValue());
    31913210        return;
    31923211    }
     
    31983217            switch (primitiveValue->getIdent()) {
    31993218            case CSSValueSmall:
    3200                 state.style->setMarqueeIncrement(Length(1, Fixed)); // 1px.
     3219                state.style()->setMarqueeIncrement(Length(1, Fixed)); // 1px.
    32013220                break;
    32023221            case CSSValueNormal:
    3203                 state.style->setMarqueeIncrement(Length(6, Fixed)); // 6px. The WinIE default.
     3222                state.style()->setMarqueeIncrement(Length(6, Fixed)); // 6px. The WinIE default.
    32043223                break;
    32053224            case CSSValueLarge:
    3206                 state.style->setMarqueeIncrement(Length(36, Fixed)); // 36px.
     3225                state.style()->setMarqueeIncrement(Length(36, Fixed)); // 36px.
    32073226                break;
    32083227            }
    32093228        } else {
    3210             Length marqueeLength = convertToIntLength(primitiveValue, state.style.get(), state.rootElementStyle);
     3229            Length marqueeLength = convertToIntLength(primitiveValue, state.style(), state.rootElementStyle());
    32113230            if (!marqueeLength.isUndefined())
    3212                 state.style->setMarqueeIncrement(marqueeLength);
     3231                state.style()->setMarqueeIncrement(marqueeLength);
    32133232        }
    32143233        return;
     
    32193238            return;
    32203239        if (primitiveValue->getIdent() == CSSValueAuto)
    3221             state.style->setLocale(nullAtom);
     3240            state.style()->setLocale(nullAtom);
    32223241        else
    3223             state.style->setLocale(primitiveValue->getStringValue());
    3224         FontDescription fontDescription = state.style->fontDescription();
    3225         fontDescription.setScript(localeToScriptCodeForFontSelection(state.style->locale()));
     3242            state.style()->setLocale(primitiveValue->getStringValue());
     3243        FontDescription fontDescription = state.style()->fontDescription();
     3244        fontDescription.setScript(localeToScriptCodeForFontSelection(state.style()->locale()));
    32263245        setFontDescription(fontDescription);
    32273246        return;
     
    32423261
    32433262        if (primitiveValue->getIdent() == CSSValueNone) {
    3244             state.style->setDashboardRegions(RenderStyle::noneDashboardRegions());
     3263            state.style()->setDashboardRegions(RenderStyle::noneDashboardRegions());
    32453264            return;
    32463265        }
     
    32523271        DashboardRegion* first = region;
    32533272        while (region) {
    3254             Length top = convertToIntLength(region->top(), state.style.get(), state.rootElementStyle);
    3255             Length right = convertToIntLength(region->right(), state.style.get(), state.rootElementStyle);
    3256             Length bottom = convertToIntLength(region->bottom(), state.style.get(), state.rootElementStyle);
    3257             Length left = convertToIntLength(region->left(), state.style.get(), state.rootElementStyle);
     3273            Length top = convertToIntLength(region->top(), state.style(), state.rootElementStyle());
     3274            Length right = convertToIntLength(region->right(), state.style(), state.rootElementStyle());
     3275            Length bottom = convertToIntLength(region->bottom(), state.style(), state.rootElementStyle());
     3276            Length left = convertToIntLength(region->left(), state.style(), state.rootElementStyle());
    32583277
    32593278            if (top.isUndefined())
     
    32673286
    32683287            if (region->m_isCircle)
    3269                 state.style->setDashboardRegion(StyleDashboardRegion::Circle, region->m_label, top, right, bottom, left, region == first ? false : true);
     3288                state.style()->setDashboardRegion(StyleDashboardRegion::Circle, region->m_label, top, right, bottom, left, region == first ? false : true);
    32703289            else if (region->m_isRectangle)
    3271                 state.style->setDashboardRegion(StyleDashboardRegion::Rectangle, region->m_label, top, right, bottom, left, region == first ? false : true);
     3290                state.style()->setDashboardRegion(StyleDashboardRegion::Rectangle, region->m_label, top, right, bottom, left, region == first ? false : true);
    32723291            region = region->m_next.get();
    32733292        }
    32743293
    3275         state.element->document()->setHasAnnotatedRegions(true);
     3294        state.document()->setHasAnnotatedRegions(true);
    32763295
    32773296        return;
     
    32823301        if (!primitiveValue || !primitiveValue->getIdent())
    32833302            return;
    3284         state.style->setDraggableRegionMode(primitiveValue->getIdent() == CSSValueDrag ? DraggableRegionDrag : DraggableRegionNoDrag);
    3285         state.element->document()->setHasAnnotatedRegions(true);
     3303        state.style()->setDraggableRegionMode(primitiveValue->getIdent() == CSSValueDrag ? DraggableRegionDrag : DraggableRegionNoDrag);
     3304        state.document()->setHasAnnotatedRegions(true);
    32863305        return;
    32873306    }
     
    32993318            else if (primitiveValue->getIdent() == CSSValueThick)
    33003319                result *= 5;
    3301             width = CSSPrimitiveValue::create(result, CSSPrimitiveValue::CSS_EMS)->computeLength<float>(state.style.get(), state.rootElementStyle, zoomFactor);
     3320            width = CSSPrimitiveValue::create(result, CSSPrimitiveValue::CSS_EMS)->computeLength<float>(state.style(), state.rootElementStyle(), zoomFactor);
    33023321            break;
    33033322        }
    33043323        default:
    3305             width = primitiveValue->computeLength<float>(state.style.get(), state.rootElementStyle, zoomFactor);
     3324            width = primitiveValue->computeLength<float>(state.style(), state.rootElementStyle(), zoomFactor);
    33063325            break;
    33073326        }
    3308         state.style->setTextStrokeWidth(width);
     3327        state.style()->setTextStrokeWidth(width);
    33093328        return;
    33103329    }
     
    33123331        HANDLE_INHERIT_AND_INITIAL(transform, Transform);
    33133332        TransformOperations operations;
    3314         createTransformOperations(value, state.style.get(), state.rootElementStyle, operations);
    3315         state.style->setTransform(operations);
     3333        createTransformOperations(value, state.style(), state.rootElementStyle(), operations);
     3334        state.style()->setTransform(operations);
    33163335        return;
    33173336    }
     
    33233342
    33243343        if (primitiveValue->getIdent() == CSSValueNone) {
    3325             state.style->setPerspective(0);
     3344            state.style()->setPerspective(0);
    33263345            return;
    33273346        }
     
    33293348        float perspectiveValue;
    33303349        if (primitiveValue->isLength())
    3331             perspectiveValue = primitiveValue->computeLength<float>(state.style.get(), state.rootElementStyle, zoomFactor);
     3350            perspectiveValue = primitiveValue->computeLength<float>(state.style(), state.rootElementStyle(), zoomFactor);
    33323351        else if (primitiveValue->isNumber()) {
    33333352            // For backward compatibility, treat valueless numbers as px.
    3334             perspectiveValue = CSSPrimitiveValue::create(primitiveValue->getDoubleValue(), CSSPrimitiveValue::CSS_PX)->computeLength<float>(state.style.get(), state.rootElementStyle, zoomFactor);
     3353            perspectiveValue = CSSPrimitiveValue::create(primitiveValue->getDoubleValue(), CSSPrimitiveValue::CSS_PX)->computeLength<float>(state.style(), state.rootElementStyle(), zoomFactor);
    33353354        } else
    33363355            return;
    33373356
    33383357        if (perspectiveValue >= 0.0f)
    3339             state.style->setPerspective(perspectiveValue);
     3358            state.style()->setPerspective(perspectiveValue);
    33403359        return;
    33413360    }
    33423361    case CSSPropertyWebkitAnimation:
    33433362        if (isInitial)
    3344             state.style->clearAnimations();
     3363            state.style()->clearAnimations();
    33453364        else if (isInherit)
    3346             state.style->inheritAnimations(state.parentStyle->animations());
     3365            state.style()->inheritAnimations(state.parentStyle()->animations());
    33473366        return;
    33483367    case CSSPropertyWebkitTransition:
    33493368        if (isInitial)
    3350             state.style->clearTransitions();
     3369            state.style()->clearTransitions();
    33513370        else if (isInherit)
    3352             state.style->inheritTransitions(state.parentStyle->transitions());
     3371            state.style()->inheritTransitions(state.parentStyle()->transitions());
    33533372        return;
    33543373#if ENABLE(TOUCH_EVENTS)
     
    33593378
    33603379        Color col = colorFromPrimitiveValue(primitiveValue);
    3361         state.style->setTapHighlightColor(col);
     3380        state.style()->setTapHighlightColor(col);
    33623381        return;
    33633382    }
     
    33683387        if (!primitiveValue)
    33693388            break;
    3370         state.style->setUseTouchOverflowScrolling(primitiveValue->getIdent() == CSSValueTouch);
     3389        state.style()->setUseTouchOverflowScrolling(primitiveValue->getIdent() == CSSValueTouch);
    33713390        return;
    33723391    }
     
    34113430    case CSSPropertyWebkitMaxLogicalHeight:
    34123431    {
    3413         CSSPropertyID newId = CSSProperty::resolveDirectionAwareProperty(id, state.style->direction(), state.style->writingMode());
     3432        CSSPropertyID newId = CSSProperty::resolveDirectionAwareProperty(id, state.style()->direction(), state.style()->writingMode());
    34143433        ASSERT(newId != id);
    34153434        return applyProperty(newId, value);
     
    34463465
    34473466        // FIXME: It is not ok to modify document state while applying style.
    3448         if (state.element && state.element == state.element->document()->documentElement())
    3449             state.element->document()->setWritingModeSetOnDocumentElement(true);
     3467        if (state.element() && state.element() == state.document()->documentElement())
     3468            state.document()->setWritingModeSetOnDocumentElement(true);
    34503469        return;
    34513470    }
     
    34633482        HANDLE_INHERIT_AND_INITIAL(lineBoxContain, LineBoxContain)
    34643483        if (primitiveValue && primitiveValue->getIdent() == CSSValueNone) {
    3465             state.style->setLineBoxContain(LineBoxContainNone);
     3484            state.style()->setLineBoxContain(LineBoxContainNone);
    34663485            return;
    34673486        }
     
    34713490
    34723491        CSSLineBoxContainValue* lineBoxContainValue = static_cast<CSSLineBoxContainValue*>(value);
    3473         state.style->setLineBoxContain(lineBoxContainValue->value());
     3492        state.style()->setLineBoxContain(lineBoxContainValue->value());
    34743493        return;
    34753494    }
     
    34783497    case CSSPropertyWebkitFontFeatureSettings: {
    34793498        if (primitiveValue && primitiveValue->getIdent() == CSSValueNormal) {
    3480             setFontDescription(state.style->fontDescription().makeNormalFeatureSettings());
     3499            setFontDescription(state.style()->fontDescription().makeNormalFeatureSettings());
    34813500            return;
    34823501        }
     
    34853504            return;
    34863505
    3487         FontDescription fontDescription = state.style->fontDescription();
     3506        FontDescription fontDescription = state.style()->fontDescription();
    34883507        CSSValueList* list = static_cast<CSSValueList*>(value);
    34893508        RefPtr<FontFeatureSettings> settings = FontFeatureSettings::create();
     
    35053524        HANDLE_INHERIT_AND_INITIAL(filter, Filter);
    35063525        FilterOperations operations;
    3507         if (createFilterOperations(value, state.style.get(), state.rootElementStyle, operations))
    3508             state.style->setFilter(operations);
     3526        if (createFilterOperations(value, state.style(), state.rootElementStyle(), operations))
     3527            state.style()->setFilter(operations);
    35093528        return;
    35103529    }
     
    35143533        if (!createGridTrackList(value, trackSizes, state))
    35153534            return;
    3516         state.style->setGridColumns(trackSizes);
     3535        state.style()->setGridColumns(trackSizes);
    35173536        return;
    35183537    }
     
    35213540        if (!createGridTrackList(value, trackSizes, state))
    35223541            return;
    3523         state.style->setGridRows(trackSizes);
     3542        state.style()->setGridRows(trackSizes);
    35243543        return;
    35253544    }
     
    35293548        if (!createGridPosition(value, column))
    35303549            return;
    3531         state.style->setGridItemColumn(column);
     3550        state.style()->setGridItemColumn(column);
    35323551        return;
    35333552    }
     
    35363555        if (!createGridPosition(value, row))
    35373556            return;
    3538         state.style->setGridItemRow(row);
     3557        state.style()->setGridItemRow(row);
    35393558        return;
    35403559    }
     
    38583877    RefPtr<StyleImage> image = value->cachedOrPendingImage();
    38593878    if (image && image->isPendingImage())
    3860         m_state.pendingImageProperties.set(property, value);
     3879        m_state.pendingImageProperties().set(property, value);
    38613880    return image.release();
    38623881}
     
    38653884{
    38663885    if (value->isPending()) {
    3867         m_state.pendingImageProperties.set(property, value);
     3886        m_state.pendingImageProperties().set(property, value);
    38683887        return StylePendingImage::create(value);
    38693888    }
     
    38763895    RefPtr<StyleImage> image = value->cachedOrPendingImageSet(document());
    38773896    if (image && image->isPendingImage())
    3878         m_state.pendingImageProperties.set(property, value);
     3897        m_state.pendingImageProperties().set(property, value);
    38793898    return image.release();
    38803899}
     
    38853904    RefPtr<StyleImage> image = value->cachedOrPendingImage(document());
    38863905    if (image && image->isPendingImage())
    3887         m_state.pendingImageProperties.set(property, value);
     3906        m_state.pendingImageProperties().set(property, value);
    38883907    return image.release();
    38893908}
     
    38913910void StyleResolver::checkForTextSizeAdjust()
    38923911{
    3893     RenderStyle* style = m_state.style.get();
     3912    RenderStyle* style = m_state.style();
    38943913
    38953914    if (style->textSizeAdjust())
     
    39633982    fontDescription.setKeywordSize(CSSValueMedium - CSSValueXxSmall + 1);
    39643983    setFontSize(fontDescription, fontSizeForKeyword(document(), CSSValueMedium, false));
    3965     m_state.style->setLineHeight(RenderStyle::initialLineHeight());
    3966     m_state.lineHeightValue = 0;
     3984    m_state.style()->setLineHeight(RenderStyle::initialLineHeight());
     3985    m_state.setLineHeightValue(0);
    39673986    setFontDescription(fontDescription);
    39683987}
     
    39713990{
    39723991    fontDescription.setSpecifiedSize(size);
    3973     fontDescription.setComputedSize(getComputedSizeFromSpecifiedSize(document(), m_state.style.get(), fontDescription.isAbsoluteSize(), size, useSVGZoomRules()));
     3992    fontDescription.setComputedSize(getComputedSizeFromSpecifiedSize(document(), m_state.style(), fontDescription.isAbsoluteSize(), size, useSVGZoomRules()));
    39743993}
    39753994
     
    41804199        return Color();
    41814200    case CSSValueWebkitText:
    4182         return state.element->document()->textColor();
     4201        return state.document()->textColor();
    41834202    case CSSValueWebkitLink:
    4184         return (state.element->isLink() && forVisitedLink) ? state.element->document()->visitedLinkColor() : state.element->document()->linkColor();
     4203        return (state.element()->isLink() && forVisitedLink) ? state.document()->visitedLinkColor() : state.document()->linkColor();
    41854204    case CSSValueWebkitActivelink:
    4186         return state.element->document()->activeLinkColor();
     4205        return state.document()->activeLinkColor();
    41874206    case CSSValueWebkitFocusRingColor:
    41884207        return RenderTheme::focusRingColor();
    41894208    case CSSValueCurrentcolor:
    4190         return state.style->color();
     4209        return state.style()->color();
    41914210    default:
    41924211        return colorForCSSValue(ident);
     
    45234542{
    45244543    State& state = m_state;
    4525     if (!state.style->hasFilter() || state.pendingSVGDocuments.isEmpty())
    4526         return;
    4527 
    4528     CachedResourceLoader* cachedResourceLoader = state.element->document()->cachedResourceLoader();
    4529     Vector<RefPtr<FilterOperation> >& filterOperations = state.style->mutableFilter().operations();
     4544    if (!state.style()->hasFilter() || state.pendingSVGDocuments().isEmpty())
     4545        return;
     4546
     4547    CachedResourceLoader* cachedResourceLoader = state.document()->cachedResourceLoader();
     4548    Vector<RefPtr<FilterOperation> >& filterOperations = state.style()->mutableFilter().operations();
    45304549    for (unsigned i = 0; i < filterOperations.size(); ++i) {
    45314550        RefPtr<FilterOperation> filterOperation = filterOperations.at(i);
     
    45334552            ReferenceFilterOperation* referenceFilter = static_cast<ReferenceFilterOperation*>(filterOperation.get());
    45344553
    4535             WebKitCSSSVGDocumentValue* value = state.pendingSVGDocuments.get(referenceFilter).get();
     4554            WebKitCSSSVGDocumentValue* value = state.pendingSVGDocuments().get(referenceFilter).get();
    45364555            if (!value)
    45374556                continue;
     
    45444563        }
    45454564    }
    4546     state.pendingSVGDocuments.clear();
     4565    state.pendingSVGDocuments().clear();
    45474566}
    45484567#endif
     
    45604579    StyleShader* shader = value->cachedOrPendingShader();
    45614580    if (shader && shader->isPendingShader())
    4562         m_state.hasPendingShaders = true;
     4581        m_state.setHasPendingShaders(true);
    45634582    return shader;
    45644583}
     
    45664585void StyleResolver::loadPendingShaders()
    45674586{
    4568     if (!m_state.style->hasFilter() || !m_state.hasPendingShaders)
    4569         return;
    4570 
    4571     CachedResourceLoader* cachedResourceLoader = m_state.element->document()->cachedResourceLoader();
    4572 
    4573     Vector<RefPtr<FilterOperation> >& filterOperations = m_state.style->mutableFilter().operations();
     4587    if (!m_state.style()->hasFilter() || !m_state.hasPendingShaders())
     4588        return;
     4589
     4590    CachedResourceLoader* cachedResourceLoader = m_state.document()->cachedResourceLoader();
     4591
     4592    Vector<RefPtr<FilterOperation> >& filterOperations = m_state.style()->mutableFilter().operations();
    45744593    for (unsigned i = 0; i < filterOperations.size(); ++i) {
    45754594        RefPtr<FilterOperation> filterOperation = filterOperations.at(i);
     
    45884607        }
    45894608    }
    4590     m_state.hasPendingShaders = false;
     4609    m_state.setHasPendingShaders(false);
    45914610}
    45924611
     
    46304649    RefPtr<CustomFilterTransformParameter> transformParameter = CustomFilterTransformParameter::create(name);
    46314650    TransformOperations operations;
    4632     createTransformOperations(values, m_state.style.get(), m_state.rootElementStyle, operations);
     4651    createTransformOperations(values, m_state.style(), m_state.rootElementStyle(), operations);
    46334652    transformParameter->setOperations(operations);
    46344653    return transformParameter.release();
     
    48804899
    48814900            WebKitCSSSVGDocumentValue* svgDocumentValue = static_cast<WebKitCSSSVGDocumentValue*>(argument);
    4882             KURL url = m_state.element->document()->completeURL(svgDocumentValue->url());
     4901            KURL url = m_state.document()->completeURL(svgDocumentValue->url());
    48834902
    48844903            RefPtr<ReferenceFilterOperation> operation = ReferenceFilterOperation::create(svgDocumentValue->url(), url.fragmentIdentifier(), operationType);
    4885             if (SVGURIReference::isExternalURIReference(svgDocumentValue->url(), m_state.element->document())) {
     4904            if (SVGURIReference::isExternalURIReference(svgDocumentValue->url(), m_state.document())) {
    48864905                if (!svgDocumentValue->loadRequested())
    4887                     m_state.pendingSVGDocuments.set(operation.get(), svgDocumentValue);
     4906                    m_state.pendingSVGDocuments().set(operation.get(), svgDocumentValue);
    48884907                else if (svgDocumentValue->cachedSVGDocument())
    48894908                    operation->setCachedSVGDocumentReference(adoptPtr(new CachedSVGDocumentReference(svgDocumentValue->cachedSVGDocument())));
     
    49895008PassRefPtr<StyleImage> StyleResolver::loadPendingImage(StylePendingImage* pendingImage)
    49905009{
    4991     CachedResourceLoader* cachedResourceLoader = m_state.element->document()->cachedResourceLoader();
     5010    CachedResourceLoader* cachedResourceLoader = m_state.document()->cachedResourceLoader();
    49925011
    49935012    if (pendingImage->cssImageValue()) {
     
    50195038void StyleResolver::loadPendingImages()
    50205039{
    5021     if (m_state.pendingImageProperties.isEmpty())
    5022         return;
    5023 
    5024     PendingImagePropertyMap::const_iterator::Keys end = m_state.pendingImageProperties.end().keys();
    5025     for (PendingImagePropertyMap::const_iterator::Keys it = m_state.pendingImageProperties.begin().keys(); it != end; ++it) {
     5040    if (m_state.pendingImageProperties().isEmpty())
     5041        return;
     5042
     5043    PendingImagePropertyMap::const_iterator::Keys end = m_state.pendingImageProperties().end().keys();
     5044    for (PendingImagePropertyMap::const_iterator::Keys it = m_state.pendingImageProperties().begin().keys(); it != end; ++it) {
    50265045        CSSPropertyID currentProperty = *it;
    50275046
    50285047        switch (currentProperty) {
    50295048        case CSSPropertyBackgroundImage: {
    5030             for (FillLayer* backgroundLayer = m_state.style->accessBackgroundLayers(); backgroundLayer; backgroundLayer = backgroundLayer->next()) {
     5049            for (FillLayer* backgroundLayer = m_state.style()->accessBackgroundLayers(); backgroundLayer; backgroundLayer = backgroundLayer->next()) {
    50315050                if (backgroundLayer->image() && backgroundLayer->image()->isPendingImage())
    50325051                    backgroundLayer->setImage(loadPendingImage(static_cast<StylePendingImage*>(backgroundLayer->image())));
     
    50355054        }
    50365055        case CSSPropertyContent: {
    5037             for (ContentData* contentData = const_cast<ContentData*>(m_state.style->contentData()); contentData; contentData = contentData->next()) {
     5056            for (ContentData* contentData = const_cast<ContentData*>(m_state.style()->contentData()); contentData; contentData = contentData->next()) {
    50385057                if (contentData->isImage()) {
    50395058                    StyleImage* image = static_cast<ImageContentData*>(contentData)->image();
     
    50485067        }
    50495068        case CSSPropertyCursor: {
    5050             if (CursorList* cursorList = m_state.style->cursors()) {
     5069            if (CursorList* cursorList = m_state.style()->cursors()) {
    50515070                for (size_t i = 0; i < cursorList->size(); ++i) {
    50525071                    CursorData& currentCursor = cursorList->at(i);
     
    50605079        }
    50615080        case CSSPropertyListStyleImage: {
    5062             if (m_state.style->listStyleImage() && m_state.style->listStyleImage()->isPendingImage())
    5063                 m_state.style->setListStyleImage(loadPendingImage(static_cast<StylePendingImage*>(m_state.style->listStyleImage())));
     5081            if (m_state.style()->listStyleImage() && m_state.style()->listStyleImage()->isPendingImage())
     5082                m_state.style()->setListStyleImage(loadPendingImage(static_cast<StylePendingImage*>(m_state.style()->listStyleImage())));
    50645083            break;
    50655084        }
    50665085        case CSSPropertyBorderImageSource: {
    5067             if (m_state.style->borderImageSource() && m_state.style->borderImageSource()->isPendingImage())
    5068                 m_state.style->setBorderImageSource(loadPendingImage(static_cast<StylePendingImage*>(m_state.style->borderImageSource())));
     5086            if (m_state.style()->borderImageSource() && m_state.style()->borderImageSource()->isPendingImage())
     5087                m_state.style()->setBorderImageSource(loadPendingImage(static_cast<StylePendingImage*>(m_state.style()->borderImageSource())));
    50695088            break;
    50705089        }
    50715090        case CSSPropertyWebkitBoxReflect: {
    5072             if (StyleReflection* reflection = m_state.style->boxReflect()) {
     5091            if (StyleReflection* reflection = m_state.style()->boxReflect()) {
    50735092                const NinePieceImage& maskImage = reflection->mask();
    50745093                if (maskImage.image() && maskImage.image()->isPendingImage()) {
     
    50805099        }
    50815100        case CSSPropertyWebkitMaskBoxImageSource: {
    5082             if (m_state.style->maskBoxImageSource() && m_state.style->maskBoxImageSource()->isPendingImage())
    5083                 m_state.style->setMaskBoxImageSource(loadPendingImage(static_cast<StylePendingImage*>(m_state.style->maskBoxImageSource())));
     5101            if (m_state.style()->maskBoxImageSource() && m_state.style()->maskBoxImageSource()->isPendingImage())
     5102                m_state.style()->setMaskBoxImageSource(loadPendingImage(static_cast<StylePendingImage*>(m_state.style()->maskBoxImageSource())));
    50845103            break;
    50855104        }
    50865105        case CSSPropertyWebkitMaskImage: {
    5087             for (FillLayer* maskLayer = m_state.style->accessMaskLayers(); maskLayer; maskLayer = maskLayer->next()) {
     5106            for (FillLayer* maskLayer = m_state.style()->accessMaskLayers(); maskLayer; maskLayer = maskLayer->next()) {
    50885107                if (maskLayer->image() && maskLayer->image()->isPendingImage())
    50895108                    maskLayer->setImage(loadPendingImage(static_cast<StylePendingImage*>(maskLayer->image())));
     
    50965115    }
    50975116
    5098     m_state.pendingImageProperties.clear();
     5117    m_state.pendingImageProperties().clear();
    50995118}
    51005119
  • trunk/Source/WebCore/css/StyleResolver.h

    r142591 r142757  
    166166    static PassRefPtr<RenderStyle> styleForDocument(Document*, CSSFontSelector* = 0);
    167167
    168     RenderStyle* style() const { return m_state.style.get(); }
    169     RenderStyle* parentStyle() const { return m_state.parentStyle; }
    170     RenderStyle* rootElementStyle() const { return m_state.rootElementStyle; }
    171     Element* element() const { return m_state.element; }
    172     Document* document() const { return m_document; }
     168    RenderStyle* style() const { return m_state.style(); }
     169    RenderStyle* parentStyle() const { return m_state.parentStyle(); }
     170    RenderStyle* rootElementStyle() const { return m_state.rootElementStyle(); }
     171    Element* element() { return m_state.element(); }
     172    Document* document() { return m_document; }
    173173    StyleScopeResolver* scopeResolver() const { return m_scopeResolver.get(); }
    174     const FontDescription& fontDescription() { return style()->fontDescription(); }
    175     const FontDescription& parentFontDescription() { return parentStyle()->fontDescription(); }
    176     void setFontDescription(const FontDescription& fontDescription) { m_state.fontDirty |= style()->setFontDescription(fontDescription); }
    177     void setZoom(float f) { m_state.fontDirty |= style()->setZoom(f); }
    178     void setEffectiveZoom(float f) { m_state.fontDirty |= style()->setEffectiveZoom(f); }
    179     void setTextSizeAdjust(bool b) { m_state.fontDirty |= style()->setTextSizeAdjust(b); }
    180     void setWritingMode(WritingMode writingMode) { m_state.fontDirty |= style()->setWritingMode(writingMode); }
    181     void setTextOrientation(TextOrientation textOrientation) { m_state.fontDirty |= style()->setTextOrientation(textOrientation); }
    182     bool hasParentNode() const { return m_state.parentNode; }
     174    bool hasParentNode() const { return m_state.parentNode(); }
    183175
    184176    // FIXME: It could be better to call m_ruleSets.appendAuthorStyleSheets() directly after we factor StyleRsolver further.
     
    208200
    209201private:
    210     void initForStyleResolve(Element*, RenderStyle* parentStyle = 0, PseudoId = NOPSEUDO);
    211202    void initElement(Element*);
    212203    RenderStyle* locateSharedStyle();
     
    315306    void adjustRenderStyle(RenderStyle* styleToAdjust, RenderStyle* parentStyle, Element*);
    316307
    317     void addMatchedRule(const RuleData* rule) { m_state.matchedRules.append(rule); }
    318 
    319308    struct RuleRange {
    320309        RuleRange(int& firstRuleIndex, int& lastRuleIndex): firstRuleIndex(firstRuleIndex), lastRuleIndex(lastRuleIndex) { }
     
    388377    void sortAndTransferMatchedRules(MatchResult&);
    389378
    390     bool ruleMatches(const RuleData&, const ContainerNode* scope);
     379    bool ruleMatches(const RuleData&, const ContainerNode* scope, PseudoId&);
    391380    bool checkRegionSelector(const CSSSelector* regionSelector, Element* regionElement);
    392381    void applyMatchedProperties(const MatchResult&, const Element*);
     
    433422    public:
    434423        State()
    435         : element(0)
    436         , styledElement(0)
    437         , parentNode(0)
    438         , parentStyle(0)
    439         , rootElementStyle(0)
    440         , regionForStyling(0)
    441         , sameOriginOnly(false)
    442         , pseudoStyle(NOPSEUDO)
    443         , elementLinkState(NotInsideLink)
    444         , distributedToInsertionPoint(false)
    445         , elementAffectedByClassRules(false)
    446         , mode(SelectorChecker::ResolvingStyle)
    447         , applyPropertyToRegularStyle(true)
    448         , applyPropertyToVisitedLinkStyle(false)
     424        : m_element(0)
     425        , m_styledElement(0)
     426        , m_parentNode(0)
     427        , m_parentStyle(0)
     428        , m_rootElementStyle(0)
     429        , m_regionForStyling(0)
     430        , m_sameOriginOnly(false)
     431        , m_pseudoStyle(NOPSEUDO)
     432        , m_elementLinkState(NotInsideLink)
     433        , m_distributedToInsertionPoint(false)
     434        , m_elementAffectedByClassRules(false)
     435        , m_mode(SelectorChecker::ResolvingStyle)
     436        , m_applyPropertyToRegularStyle(true)
     437        , m_applyPropertyToVisitedLinkStyle(false)
    449438#if ENABLE(CSS_SHADERS)
    450         , hasPendingShaders(false)
    451 #endif
    452         , lineHeightValue(0)
    453         , fontDirty(false)
    454         , hasUAAppearance(false)
    455         , backgroundData(BackgroundFillLayer) { }
     439        , m_hasPendingShaders(false)
     440#endif
     441        , m_lineHeightValue(0)
     442        , m_fontDirty(false)
     443        , m_hasUAAppearance(false)
     444        , m_backgroundData(BackgroundFillLayer) { }
     445
     446    public:
     447        void initElement(Element*);
     448        void initForStyleResolve(Document*, Element*, RenderStyle* parentStyle = 0, PseudoId = NOPSEUDO, RenderRegion* regionForStyling = 0);
     449        void clear();
     450
     451        Document* document() const { return m_element->document(); }
     452        Element* element() const { return m_element; }
     453        StyledElement* styledElement() const { return m_styledElement; }
     454        void setStyle(PassRefPtr<RenderStyle> style) { m_style = style; }
     455        RenderStyle* style() const { return m_style.get(); }
     456        PassRefPtr<RenderStyle> takeStyle() { return m_style.release(); }
     457
     458        StaticCSSRuleList* ensureRuleList();
     459        PassRefPtr<CSSRuleList> takeRuleList() { return m_ruleList.release(); }
     460
     461        const ContainerNode* parentNode() const { return m_parentNode; }
     462        void setParentStyle(RenderStyle* parentStyle) { m_parentStyle = parentStyle; }
     463        RenderStyle* parentStyle() const { return m_parentStyle; }
     464        RenderStyle* rootElementStyle() const { return m_rootElementStyle; }
     465
     466        const RenderRegion* regionForStyling() const { return m_regionForStyling; }
     467        void setSameOriginOnly(bool isSameOriginOnly) { m_sameOriginOnly = isSameOriginOnly; }
     468        bool isSameOriginOnly() const { return m_sameOriginOnly; }
     469        PseudoId pseudoStyle() const { return m_pseudoStyle; }
     470        EInsideLink elementLinkState() const { return m_elementLinkState; }
     471        bool distributedToInsertionPoint() const { return m_distributedToInsertionPoint; }
     472        void setElementAffectedByClassRules(bool isAffected) { m_elementAffectedByClassRules = isAffected; }
     473        bool elementAffectedByClassRules() const { return m_elementAffectedByClassRules; }
     474        void setMode(SelectorChecker::Mode mode) { m_mode = mode; }
     475        SelectorChecker::Mode mode() const { return m_mode; }
    456476       
    457 public:
     477        void setApplyPropertyToRegularStyle(bool isApply) { m_applyPropertyToRegularStyle = isApply; }
     478        void setApplyPropertyToVisitedLinkStyle(bool isApply) { m_applyPropertyToVisitedLinkStyle = isApply; }
     479        bool applyPropertyToRegularStyle() const { return m_applyPropertyToRegularStyle; }
     480        bool applyPropertyToVisitedLinkStyle() const { return m_applyPropertyToVisitedLinkStyle; }
     481        PendingImagePropertyMap& pendingImageProperties() { return m_pendingImageProperties; }
     482#if ENABLE(CSS_FILTERS) && ENABLE(SVG)
     483        PendingSVGDocumentMap& pendingSVGDocuments() { return m_pendingSVGDocuments; }
     484#endif
     485#if ENABLE(CSS_SHADERS)
     486        void setHasPendingShaders(bool hasPendingShaders) { m_hasPendingShaders = hasPendingShaders; }
     487        bool hasPendingShaders() const { return m_hasPendingShaders; }
     488#endif
     489
     490        void setLineHeightValue(CSSValue* value) { m_lineHeightValue = value; }
     491        CSSValue* lineHeightValue() { return m_lineHeightValue; }
     492        void setFontDirty(bool isDirty) { m_fontDirty = isDirty; }
     493        bool fontDirty() const { return m_fontDirty; }
     494
     495        void cacheBorderAndBackground();
     496        bool hasUAAppearance() const { return m_hasUAAppearance; }
     497        BorderData borderData() const { return m_borderData; }
     498        FillLayer backgroundData() const { return m_backgroundData; }
     499        Color backgroundColor() const { return m_backgroundColor; }
     500
     501        const FontDescription& fontDescription() { return m_style->fontDescription(); }
     502        const FontDescription& parentFontDescription() { return m_parentStyle->fontDescription(); }
     503        void setFontDescription(const FontDescription& fontDescription) { m_fontDirty |= m_style->setFontDescription(fontDescription); }
     504        void setZoom(float f) { m_fontDirty |= m_style->setZoom(f); }
     505        void setEffectiveZoom(float f) { m_fontDirty |= m_style->setEffectiveZoom(f); }
     506        void setTextSizeAdjust(bool b) { m_fontDirty |= m_style->setTextSizeAdjust(b); }
     507        void setWritingMode(WritingMode writingMode) { m_fontDirty |= m_style->setWritingMode(writingMode); }
     508        void setTextOrientation(TextOrientation textOrientation) { m_fontDirty |= m_style->setTextOrientation(textOrientation); }
     509
     510        Vector<const RuleData*, 32>& matchedRules() { return m_matchedRules; }
     511        void addMatchedRule(const RuleData* rule) { m_matchedRules.append(rule); }
     512       
     513    private:
    458514        // FIXME(bug 108563): to make it easier to review, these member
    459515        // variables are public. However we should add methods to access
    460516        // these variables.
    461         Element* element;
    462         RefPtr<RenderStyle> style;
    463         StyledElement* styledElement;
    464         ContainerNode* parentNode;
    465         RenderStyle* parentStyle;
    466         RenderStyle* rootElementStyle;
     517        Element* m_element;
     518        RefPtr<RenderStyle> m_style;
     519        StyledElement* m_styledElement;
     520        ContainerNode* m_parentNode;
     521        RenderStyle* m_parentStyle;
     522        RenderStyle* m_rootElementStyle;
    467523       
    468         RenderRegion* regionForStyling;
    469         bool sameOriginOnly;
    470         PseudoId pseudoStyle;
    471 
    472         EInsideLink elementLinkState;
    473 
    474         bool distributedToInsertionPoint;
    475 
    476         bool elementAffectedByClassRules;
    477 
    478         PseudoId dynamicPseudo;
    479 
    480         SelectorChecker::Mode mode;
     524        RenderRegion* m_regionForStyling;
     525        bool m_sameOriginOnly;
     526        PseudoId m_pseudoStyle;
     527
     528        EInsideLink m_elementLinkState;
     529
     530        bool m_distributedToInsertionPoint;
     531
     532        bool m_elementAffectedByClassRules;
     533
     534        SelectorChecker::Mode m_mode;
    481535
    482536        // A buffer used to hold the set of matched rules for an element,
    483537        // and a temporary buffer used for merge sorting.
    484         Vector<const RuleData*, 32> matchedRules;
    485         RefPtr<StaticCSSRuleList> ruleList;
    486 
    487         bool applyPropertyToRegularStyle;
    488         bool applyPropertyToVisitedLinkStyle;
    489 
    490         PendingImagePropertyMap pendingImageProperties;
     538        Vector<const RuleData*, 32> m_matchedRules;
     539        RefPtr<StaticCSSRuleList> m_ruleList;
     540
     541        bool m_applyPropertyToRegularStyle;
     542        bool m_applyPropertyToVisitedLinkStyle;
     543
     544        PendingImagePropertyMap m_pendingImageProperties;
    491545#if ENABLE(CSS_SHADERS)
    492         bool hasPendingShaders;
     546        bool m_hasPendingShaders;
    493547#endif
    494548#if ENABLE(CSS_FILTERS) && ENABLE(SVG)
    495         PendingSVGDocumentMap pendingSVGDocuments;
    496 #endif
    497         CSSValue* lineHeightValue;
    498         bool fontDirty;
    499 
    500         bool hasUAAppearance;
    501         BorderData borderData;
    502         FillLayer backgroundData;
    503         Color backgroundColor;
     549        PendingSVGDocumentMap m_pendingSVGDocuments;
     550#endif
     551        CSSValue* m_lineHeightValue;
     552        bool m_fontDirty;
     553
     554        bool m_hasUAAppearance;
     555        BorderData m_borderData;
     556        FillLayer m_backgroundData;
     557        Color m_backgroundColor;
    504558    };
    505559
     
    514568    PassRefPtr<StyleImage> cursorOrPendingFromValue(CSSPropertyID, CSSCursorImageValue*);
    515569
    516     bool applyPropertyToRegularStyle() const { return m_state.applyPropertyToRegularStyle; }
    517     bool applyPropertyToVisitedLinkStyle() const { return m_state.applyPropertyToVisitedLinkStyle; }
     570    bool applyPropertyToRegularStyle() const { return m_state.applyPropertyToRegularStyle(); }
     571    bool applyPropertyToVisitedLinkStyle() const { return m_state.applyPropertyToVisitedLinkStyle(); }
    518572
    519573    static Length convertToIntLength(CSSPrimitiveValue*, RenderStyle*, RenderStyle* rootStyle, double multiplier = 1);
     
    522576    CSSToStyleMap* styleMap() { return &m_styleMap; }
    523577    InspectorCSSOMWrappers& inspectorCSSOMWrappers() { return m_inspectorCSSOMWrappers; }
    524 
     578    const FontDescription& fontDescription() { return m_state.fontDescription(); }
     579    const FontDescription& parentFontDescription() { return m_state.parentFontDescription(); }
     580    void setFontDescription(const FontDescription& fontDescription) { m_state.setFontDescription(fontDescription); }
     581    void setZoom(float f) { m_state.setZoom(f); }
     582    void setEffectiveZoom(float f) { m_state.setEffectiveZoom(f); }
     583    void setTextSizeAdjust(bool b) { m_state.setTextSizeAdjust(b); }
     584    void setWritingMode(WritingMode writingMode) { m_state.setWritingMode(writingMode); }
     585    void setTextOrientation(TextOrientation textOrientation) { m_state.setTextOrientation(textOrientation); }
     586   
    525587    void reportMemoryUsage(MemoryObjectInfo*) const;
    526588   
Note: See TracChangeset for help on using the changeset viewer.