Changeset 141742 in webkit


Ignore:
Timestamp:
Feb 3, 2013 11:02:55 PM (11 years ago)
Author:
tasak@google.com
Message:

Split per-resolve logic out from StyleResolver.
https://bugs.webkit.org/show_bug.cgi?id=96421

Reviewed by Eric Seidel.

Implemented class StyleResolver::State and added m_state to
StyleResolver. All member variables used for per-resolve logic are
moved into the state class.

No new tests, because just refactoring.

  • css/SVGCSSStyleSelector.cpp:

(WebCore::StyleResolver::applySVGProperty):

  • css/StyleResolver.cpp:

(WebCore):
(WebCore::StyleResolver::StyleResolver):
(WebCore::StyleResolver::collectMatchingRules):
(WebCore::StyleResolver::collectMatchingRulesForRegion):
(WebCore::StyleResolver::sortAndTransferMatchedRules):
(WebCore::StyleResolver::matchScopedAuthorRules):
(WebCore::StyleResolver::styleSharingCandidateMatchesHostRules):
(WebCore::StyleResolver::matchHostRules):
(WebCore::StyleResolver::matchAuthorRules):
(WebCore::StyleResolver::matchUserRules):
(WebCore::StyleResolver::matchUARules):
(WebCore::StyleResolver::collectMatchingRulesForList):
(WebCore::StyleResolver::sortMatchedRules):
(WebCore::StyleResolver::matchAllRules):
(WebCore::StyleResolver::initElement):
(WebCore::StyleResolver::initForStyleResolve):
(WebCore::StyleResolver::styleSharingCandidateMatchesRuleSet):
(WebCore::StyleResolver::canShareStyleWithControl):
(WebCore::StyleResolver::sharingCandidateHasIdenticalStyleAffectingAttributes):
(WebCore::StyleResolver::canShareStyleWithElement):
(WebCore::StyleResolver::locateSharedStyle):
(WebCore::StyleResolver::styleForElement):
(WebCore::StyleResolver::styleForKeyframe):
(WebCore::StyleResolver::pseudoStyleForElement):
(WebCore::StyleResolver::styleForPage):
(WebCore::StyleResolver::defaultStyleForElement):
(WebCore::StyleResolver::adjustRenderStyle):
(WebCore::StyleResolver::updateFont):
(WebCore::StyleResolver::cacheBorderAndBackground):
(WebCore::StyleResolver::pseudoStyleRulesForElement):
(WebCore::StyleResolver::ruleMatches):
(WebCore::StyleResolver::checkRegionSelector):
(WebCore::StyleResolver::applyProperties):
(WebCore::StyleResolver::applyMatchedProperties):
(WebCore::StyleResolver::isLeftPage):
(WebCore::StyleResolver::applyPropertyToStyle):
(WebCore::StyleResolver::useSVGZoomRules):
(WebCore::createGridTrackBreadth):
(WebCore::createGridTrackMinMax):
(WebCore::createGridTrackGroup):
(WebCore::createGridTrackList):
(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):
(WebCore::StyleResolver::reportMemoryUsage):

  • css/StyleResolver.h:

(WebCore::StyleResolver::style):
(WebCore::StyleResolver::parentStyle):
(WebCore::StyleResolver::rootElementStyle):
(WebCore::StyleResolver::element):
(WebCore::StyleResolver::setFontDescription):
(WebCore::StyleResolver::setZoom):
(WebCore::StyleResolver::setEffectiveZoom):
(WebCore::StyleResolver::setTextSizeAdjust):
(WebCore::StyleResolver::setWritingMode):
(WebCore::StyleResolver::setTextOrientation):
(WebCore::StyleResolver::hasParentNode):
(WebCore::StyleResolver::addMatchedRule):
(StyleResolver):
(State):
(WebCore::StyleResolver::State::State):
(WebCore::StyleResolver::applyPropertyToRegularStyle):
(WebCore::StyleResolver::applyPropertyToVisitedLinkStyle):
Added "m_state." to access member variables used for per-resolve logic.

Location:
trunk/Source/WebCore
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r141741 r141742  
     12013-02-03  Takashi Sakamoto  <tasak@google.com>
     2
     3        Split per-resolve logic out from StyleResolver.
     4        https://bugs.webkit.org/show_bug.cgi?id=96421
     5
     6        Reviewed by Eric Seidel.
     7
     8        Implemented class StyleResolver::State and added m_state to
     9        StyleResolver. All member variables used for per-resolve logic are
     10        moved into the state class.
     11
     12        No new tests, because just refactoring.
     13
     14        * css/SVGCSSStyleSelector.cpp:
     15        (WebCore::StyleResolver::applySVGProperty):
     16        * css/StyleResolver.cpp:
     17        (WebCore):
     18        (WebCore::StyleResolver::StyleResolver):
     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::initElement):
     32        (WebCore::StyleResolver::initForStyleResolve):
     33        (WebCore::StyleResolver::styleSharingCandidateMatchesRuleSet):
     34        (WebCore::StyleResolver::canShareStyleWithControl):
     35        (WebCore::StyleResolver::sharingCandidateHasIdenticalStyleAffectingAttributes):
     36        (WebCore::StyleResolver::canShareStyleWithElement):
     37        (WebCore::StyleResolver::locateSharedStyle):
     38        (WebCore::StyleResolver::styleForElement):
     39        (WebCore::StyleResolver::styleForKeyframe):
     40        (WebCore::StyleResolver::pseudoStyleForElement):
     41        (WebCore::StyleResolver::styleForPage):
     42        (WebCore::StyleResolver::defaultStyleForElement):
     43        (WebCore::StyleResolver::adjustRenderStyle):
     44        (WebCore::StyleResolver::updateFont):
     45        (WebCore::StyleResolver::cacheBorderAndBackground):
     46        (WebCore::StyleResolver::pseudoStyleRulesForElement):
     47        (WebCore::StyleResolver::ruleMatches):
     48        (WebCore::StyleResolver::checkRegionSelector):
     49        (WebCore::StyleResolver::applyProperties):
     50        (WebCore::StyleResolver::applyMatchedProperties):
     51        (WebCore::StyleResolver::isLeftPage):
     52        (WebCore::StyleResolver::applyPropertyToStyle):
     53        (WebCore::StyleResolver::useSVGZoomRules):
     54        (WebCore::createGridTrackBreadth):
     55        (WebCore::createGridTrackMinMax):
     56        (WebCore::createGridTrackGroup):
     57        (WebCore::createGridTrackList):
     58        (WebCore::StyleResolver::resolveVariables):
     59        (WebCore::StyleResolver::applyProperty):
     60        (WebCore::StyleResolver::cachedOrPendingFromValue):
     61        (WebCore::StyleResolver::generatedOrPendingFromValue):
     62        (WebCore::StyleResolver::setOrPendingFromValue):
     63        (WebCore::StyleResolver::cursorOrPendingFromValue):
     64        (WebCore::StyleResolver::checkForTextSizeAdjust):
     65        (WebCore::StyleResolver::initializeFontStyle):
     66        (WebCore::StyleResolver::setFontSize):
     67        (WebCore::StyleResolver::colorFromPrimitiveValue):
     68        (WebCore::StyleResolver::loadPendingSVGDocuments):
     69        (WebCore::StyleResolver::cachedOrPendingStyleShaderFromValue):
     70        (WebCore::StyleResolver::loadPendingShaders):
     71        (WebCore::StyleResolver::parseCustomFilterTransformParameter):
     72        (WebCore::StyleResolver::createFilterOperations):
     73        (WebCore::StyleResolver::loadPendingImage):
     74        (WebCore::StyleResolver::loadPendingImages):
     75        (WebCore::StyleResolver::reportMemoryUsage):
     76        * css/StyleResolver.h:
     77        (WebCore::StyleResolver::style):
     78        (WebCore::StyleResolver::parentStyle):
     79        (WebCore::StyleResolver::rootElementStyle):
     80        (WebCore::StyleResolver::element):
     81        (WebCore::StyleResolver::setFontDescription):
     82        (WebCore::StyleResolver::setZoom):
     83        (WebCore::StyleResolver::setEffectiveZoom):
     84        (WebCore::StyleResolver::setTextSizeAdjust):
     85        (WebCore::StyleResolver::setWritingMode):
     86        (WebCore::StyleResolver::setTextOrientation):
     87        (WebCore::StyleResolver::hasParentNode):
     88        (WebCore::StyleResolver::addMatchedRule):
     89        (StyleResolver):
     90        (State):
     91        (WebCore::StyleResolver::State::State):
     92        (WebCore::StyleResolver::applyPropertyToRegularStyle):
     93        (WebCore::StyleResolver::applyPropertyToVisitedLinkStyle):
     94        Added "m_state." to access member variables used for per-resolve logic.
     95
    1962013-02-03  Kent Tamura  <tkent@chromium.org>
    297
  • trunk/Source/WebCore/css/SVGCSSStyleSelector.cpp

    r133420 r141742  
    5050if (isInherit) \
    5151{ \
    52     svgstyle->set##Prop(m_parentStyle->svgStyle()->prop()); \
     52    svgstyle->set##Prop(state.parentStyle->svgStyle()->prop()); \
    5353    return; \
    5454}
     
    110110        primitiveValue = static_cast<CSSPrimitiveValue*>(value);
    111111
    112     SVGRenderStyle* svgstyle = m_style->accessSVGStyle();
    113 
    114     bool isInherit = m_parentNode && value->isInheritedValue();
    115     bool isInitial = value->isInitialValue() || (!m_parentNode && value->isInheritedValue());
     112    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());
    116117
    117118    // What follows is a list that maps the CSS properties into their
     
    230231        {
    231232            if (isInherit) {
    232                 const SVGRenderStyle* svgParentStyle = m_parentStyle->svgStyle();
     233                const SVGRenderStyle* svgParentStyle = state.parentStyle->svgStyle();
    233234                svgstyle->setFillPaint(svgParentStyle->fillPaintType(), svgParentStyle->fillPaintColor(), svgParentStyle->fillPaintUri(), applyPropertyToRegularStyle(), applyPropertyToVisitedLinkStyle());
    234235                return;
     
    240241            if (value->isSVGPaint()) {
    241242                SVGPaint* svgPaint = static_cast<SVGPaint*>(value);
    242                 svgstyle->setFillPaint(svgPaint->paintType(), colorFromSVGColorCSSValue(svgPaint, m_style->color()), svgPaint->uri(), applyPropertyToRegularStyle(), applyPropertyToVisitedLinkStyle());
     243                svgstyle->setFillPaint(svgPaint->paintType(), colorFromSVGColorCSSValue(svgPaint, state.style->color()), svgPaint->uri(), applyPropertyToRegularStyle(), applyPropertyToVisitedLinkStyle());
    243244            }
    244245            break;
     
    247248        {
    248249            if (isInherit) {
    249                 const SVGRenderStyle* svgParentStyle = m_parentStyle->svgStyle();
     250                const SVGRenderStyle* svgParentStyle = state.parentStyle->svgStyle();
    250251                svgstyle->setStrokePaint(svgParentStyle->strokePaintType(), svgParentStyle->strokePaintColor(), svgParentStyle->strokePaintUri(), applyPropertyToRegularStyle(), applyPropertyToVisitedLinkStyle());
    251252                return;
     
    257258            if (value->isSVGPaint()) {
    258259                SVGPaint* svgPaint = static_cast<SVGPaint*>(value);
    259                 svgstyle->setStrokePaint(svgPaint->paintType(), colorFromSVGColorCSSValue(svgPaint, m_style->color()), svgPaint->uri(), applyPropertyToRegularStyle(), applyPropertyToVisitedLinkStyle());
     260                svgstyle->setStrokePaint(svgPaint->paintType(), colorFromSVGColorCSSValue(svgPaint, state.style->color()), svgPaint->uri(), applyPropertyToRegularStyle(), applyPropertyToVisitedLinkStyle());
    260261            }
    261262            break;
     
    364365                s = primitiveValue->getStringValue();
    365366
    366             svgstyle->setMarkerStartResource(SVGURIReference::fragmentIdentifierFromIRIString(s, m_element->document()));
     367            svgstyle->setMarkerStartResource(SVGURIReference::fragmentIdentifierFromIRIString(s, state.element->document()));
    367368            break;
    368369        }
     
    378379                s = primitiveValue->getStringValue();
    379380
    380             svgstyle->setMarkerMidResource(SVGURIReference::fragmentIdentifierFromIRIString(s, m_element->document()));
     381            svgstyle->setMarkerMidResource(SVGURIReference::fragmentIdentifierFromIRIString(s, state.element->document()));
    381382            break;
    382383        }
     
    392393                s = primitiveValue->getStringValue();
    393394
    394             svgstyle->setMarkerEndResource(SVGURIReference::fragmentIdentifierFromIRIString(s, m_element->document()));
     395            svgstyle->setMarkerEndResource(SVGURIReference::fragmentIdentifierFromIRIString(s, state.element->document()));
    395396            break;
    396397        }
     
    429430                s = primitiveValue->getStringValue();
    430431
    431             svgstyle->setFilterResource(SVGURIReference::fragmentIdentifierFromIRIString(s, m_element->document()));
     432            svgstyle->setFilterResource(SVGURIReference::fragmentIdentifierFromIRIString(s, state.element->document()));
    432433            break;
    433434        }
     
    443444                s = primitiveValue->getStringValue();
    444445
    445             svgstyle->setMaskerResource(SVGURIReference::fragmentIdentifierFromIRIString(s, m_element->document()));
     446            svgstyle->setMaskerResource(SVGURIReference::fragmentIdentifierFromIRIString(s, state.element->document()));
    446447            break;
    447448        }
     
    457458                s = primitiveValue->getStringValue();
    458459
    459             svgstyle->setClipperResource(SVGURIReference::fragmentIdentifierFromIRIString(s, m_element->document()));
     460            svgstyle->setClipperResource(SVGURIReference::fragmentIdentifierFromIRIString(s, state.element->document()));
    460461            break;
    461462        }
     
    478479            HANDLE_INHERIT_AND_INITIAL(stopColor, StopColor);
    479480            if (value->isSVGColor())
    480                 svgstyle->setStopColor(colorFromSVGColorCSSValue(static_cast<SVGColor*>(value), m_style->color()));
     481                svgstyle->setStopColor(colorFromSVGColorCSSValue(static_cast<SVGColor*>(value), state.style->color()));
    481482            break;
    482483        }
     
    485486            HANDLE_INHERIT_AND_INITIAL(lightingColor, LightingColor);
    486487            if (value->isSVGColor())
    487                 svgstyle->setLightingColor(colorFromSVGColorCSSValue(static_cast<SVGColor*>(value), m_style->color()));
     488                svgstyle->setLightingColor(colorFromSVGColorCSSValue(static_cast<SVGColor*>(value), state.style->color()));
    488489            break;
    489490        }
     
    510511            HANDLE_INHERIT_AND_INITIAL(floodColor, FloodColor);
    511512            if (value->isSVGColor())
    512                 svgstyle->setFloodColor(colorFromSVGColorCSSValue(static_cast<SVGColor*>(value), m_style->color()));
     513                svgstyle->setFloodColor(colorFromSVGColorCSSValue(static_cast<SVGColor*>(value), state.style->color()));
    513514            break;
    514515        }
     
    550551        case CSSPropertyWebkitSvgShadow: {
    551552            if (isInherit)
    552                 return svgstyle->setShadow(adoptPtr(m_parentStyle->svgStyle()->shadow() ? new ShadowData(*m_parentStyle->svgStyle()->shadow()) : 0));
     553                return svgstyle->setShadow(adoptPtr(state.parentStyle->svgStyle()->shadow() ? new ShadowData(*state.parentStyle->svgStyle()->shadow()) : 0));
    553554            if (isInitial || primitiveValue) // initial | none
    554555                return svgstyle->setShadow(nullptr);
     
    565566                return;
    566567            ShadowValue* item = static_cast<ShadowValue*>(firstValue);
    567             IntPoint location(item->x->computeLength<int>(style(), m_rootElementStyle),
    568                               item->y->computeLength<int>(style(), m_rootElementStyle));
    569             int blur = item->blur ? item->blur->computeLength<int>(style(), m_rootElementStyle) : 0;
     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;
    570571            Color color;
    571572            if (item->color)
  • trunk/Source/WebCore/css/StyleResolver.cpp

    r141733 r141742  
    4646#include "CSSPropertyNames.h"
    4747#include "CSSReflectValue.h"
    48 #include "CSSRuleList.h"
    4948#include "CSSSelector.h"
    5049#include "CSSSelectorList.h"
     
    200199#define HANDLE_INHERIT(prop, Prop) \
    201200if (isInherit) { \
    202     m_style->set##Prop(m_parentStyle->prop()); \
     201    m_state.style->set##Prop(m_state.parentStyle->prop()); \
    203202    return; \
    204203}
     
    207206HANDLE_INHERIT(prop, Prop) \
    208207if (isInitial) { \
    209     m_style->set##Prop(RenderStyle::initial##Prop()); \
     208    m_state.style->set##Prop(RenderStyle::initial##Prop()); \
    210209    return; \
    211210}
     
    231230
    232231StyleResolver::StyleResolver(Document* document, bool matchAuthorAndUserStyles)
    233     : m_hasUAAppearance(false)
    234     , m_backgroundData(BackgroundFillLayer)
    235     , m_matchedPropertiesCacheAdditionsSinceLastSweep(0)
     232    : m_matchedPropertiesCacheAdditionsSinceLastSweep(0)
    236233    , m_matchedPropertiesCacheSweepTimer(this, &StyleResolver::sweepMatchedPropertiesCache)
    237234    , m_document(document)
    238235    , m_selectorChecker(document)
    239     , m_parentStyle(0)
    240     , m_rootElementStyle(0)
    241     , m_element(0)
    242     , m_styledElement(0)
    243     , m_regionForStyling(0)
    244     , m_elementLinkState(NotInsideLink)
    245     , m_parentNode(0)
    246     , m_lineHeightValue(0)
    247     , m_fontDirty(false)
    248236    , m_matchAuthorAndUserStyles(matchAuthorAndUserStyles)
    249     , m_sameOriginOnly(false)
    250     , m_distributedToInsertionPoint(false)
    251237    , m_fontSelector(CSSFontSelector::create(document))
    252238#if ENABLE(CSS_DEVICE_ADAPTATION)
    253239    , m_viewportStyleResolver(ViewportStyleResolver::create(document))
    254240#endif
    255     , m_applyPropertyToRegularStyle(true)
    256     , m_applyPropertyToVisitedLinkStyle(false)
    257241    , m_styleBuilder(StyleBuilder::sharedStyleBuilder())
    258 #if ENABLE(CSS_SHADERS)
    259     , m_hasPendingShaders(false)
    260 #endif
    261242    , m_styleMap(this)
    262243{
     
    499480{
    500481    ASSERT(matchRequest.ruleSet);
    501     ASSERT(m_element);
    502 
    503     const AtomicString& pseudoId = m_element->shadowPseudoId();
     482    ASSERT(m_state.element);
     483
     484    State& state = m_state;
     485    Element* element = state.element;
     486    StyledElement* styledElement = state.styledElement;
     487    const AtomicString& pseudoId = element->shadowPseudoId();
    504488    if (!pseudoId.isEmpty()) {
    505         ASSERT(m_styledElement);
     489        ASSERT(styledElement);
    506490        collectMatchingRulesForList(matchRequest.ruleSet->shadowPseudoElementRules(pseudoId.impl()), matchRequest, ruleRange);
    507491    }
    508492
    509493#if ENABLE(VIDEO_TRACK)
    510     if (m_element->isWebVTTElement())
     494    if (element->isWebVTTElement())
    511495        collectMatchingRulesForList(matchRequest.ruleSet->cuePseudoRules(), matchRequest, ruleRange);
    512496#endif
     
    515499    // b) the tree scope allows author rules
    516500    // c) the rules comes from a scoped style sheet within the same tree scope
    517     TreeScope* treeScope = m_element->treeScope();
     501    TreeScope* treeScope = element->treeScope();
    518502    if (!MatchingUARulesScope::isMatchingUARules()
    519503        && !treeScope->applyAuthorStyles()
     
    523507    // We need to collect the rules for id, class, tag, and everything else into a buffer and
    524508    // then sort the buffer.
    525     if (m_element->hasID())
    526         collectMatchingRulesForList(matchRequest.ruleSet->idRules(m_element->idForStyleResolution().impl()), matchRequest, ruleRange);
    527     if (m_styledElement && m_styledElement->hasClass()) {
    528         for (size_t i = 0; i < m_styledElement->classNames().size(); ++i)
    529             collectMatchingRulesForList(matchRequest.ruleSet->classRules(m_styledElement->classNames()[i].impl()), matchRequest, ruleRange);
    530     }
    531 
    532     if (m_element->isLink())
     509    if (element->hasID())
     510        collectMatchingRulesForList(matchRequest.ruleSet->idRules(element->idForStyleResolution().impl()), matchRequest, ruleRange);
     511    if (styledElement && styledElement->hasClass()) {
     512        for (size_t i = 0; i < styledElement->classNames().size(); ++i)
     513            collectMatchingRulesForList(matchRequest.ruleSet->classRules(styledElement->classNames()[i].impl()), matchRequest, ruleRange);
     514    }
     515
     516    if (element->isLink())
    533517        collectMatchingRulesForList(matchRequest.ruleSet->linkPseudoClassRules(), matchRequest, ruleRange);
    534     if (m_selectorChecker.matchesFocusPseudoClass(m_element))
     518    if (m_selectorChecker.matchesFocusPseudoClass(element))
    535519        collectMatchingRulesForList(matchRequest.ruleSet->focusPseudoClassRules(), matchRequest, ruleRange);
    536     collectMatchingRulesForList(matchRequest.ruleSet->tagRules(m_element->localName().impl()), matchRequest, ruleRange);
     520    collectMatchingRulesForList(matchRequest.ruleSet->tagRules(element->localName().impl()), matchRequest, ruleRange);
    537521    collectMatchingRulesForList(matchRequest.ruleSet->universalRules(), matchRequest, ruleRange);
    538522}
     
    540524void StyleResolver::collectMatchingRulesForRegion(const MatchRequest& matchRequest, RuleRange& ruleRange)
    541525{
    542     if (!m_regionForStyling)
     526    if (!m_state.regionForStyling)
    543527        return;
    544528
     
    546530    for (unsigned i = 0; i < size; ++i) {
    547531        const CSSSelector* regionSelector = matchRequest.ruleSet->m_regionSelectorsAndRuleSets.at(i).selector;
    548         if (checkRegionSelector(regionSelector, static_cast<Element*>(m_regionForStyling->node()))) {
     532        if (checkRegionSelector(regionSelector, static_cast<Element*>(m_state.regionForStyling->node()))) {
    549533            RuleSet* regionRules = matchRequest.ruleSet->m_regionSelectorsAndRuleSets.at(i).ruleSet.get();
    550534            ASSERT(regionRules);
     
    556540void StyleResolver::sortAndTransferMatchedRules(MatchResult& result)
    557541{
    558     if (m_matchedRules.isEmpty())
     542    State& state = m_state;
     543    if (state.matchedRules.isEmpty())
    559544        return;
    560545
     
    562547
    563548    if (m_selectorChecker.mode() == SelectorChecker::CollectingRules) {
    564         if (!m_ruleList)
    565             m_ruleList = StaticCSSRuleList::create();
    566         for (unsigned i = 0; i < m_matchedRules.size(); ++i)
    567             m_ruleList->rules().append(m_matchedRules[i]->rule()->createCSSOMWrapper());
     549        if (!state.ruleList)
     550            state.ruleList = StaticCSSRuleList::create();
     551        for (unsigned i = 0; i < state.matchedRules.size(); ++i)
     552            state.ruleList->rules().append(state.matchedRules[i]->rule()->createCSSOMWrapper());
    568553        return;
    569554    }
    570555
    571556    // Now transfer the set of matched rules over to our list of declarations.
    572     for (unsigned i = 0; i < m_matchedRules.size(); i++) {
    573         if (m_style && m_matchedRules[i]->containsUncommonAttributeSelector())
    574             m_style->setUnique();
    575         addMatchedProperties(result, m_matchedRules[i]->rule()->properties(), m_matchedRules[i]->rule(), m_matchedRules[i]->linkMatchType(), m_matchedRules[i]->propertyWhitelistType());
     557    for (unsigned i = 0; i < state.matchedRules.size(); i++) {
     558        if (state.style && state.matchedRules[i]->containsUncommonAttributeSelector())
     559            state.style->setUnique();
     560        addMatchedProperties(result, state.matchedRules[i]->rule()->properties(), state.matchedRules[i]->rule(), state.matchedRules[i]->linkMatchType(), state.matchedRules[i]->propertyWhitelistType());
    576561    }
    577562}
     
    584569
    585570    // Match scoped author rules by traversing the scoped element stack (rebuild it if it got inconsistent).
    586     if (m_scopeResolver->hasScopedStyles() && m_scopeResolver->ensureStackConsistency(m_element)) {
    587         bool applyAuthorStyles = m_element->treeScope()->applyAuthorStyles();
     571    if (m_scopeResolver->hasScopedStyles() && m_scopeResolver->ensureStackConsistency(m_state.element)) {
     572        bool applyAuthorStyles = m_state.element->treeScope()->applyAuthorStyles();
    588573        bool documentScope = true;
    589574        unsigned scopeSize = m_scopeResolver->stackSize();
    590575        for (unsigned i = 0; i < scopeSize; ++i) {
    591             m_matchedRules.clear();
     576            m_state.matchedRules.clear();
    592577            result.ranges.lastAuthorRule = result.matchedProperties.size() - 1;
    593578
     
    620605{
    621606#if ENABLE(SHADOW_DOM)
    622     return m_scopeResolver && m_scopeResolver->styleSharingCandidateMatchesHostRules(m_element);
     607    return m_scopeResolver && m_scopeResolver->styleSharingCandidateMatchesHostRules(m_state.element);
    623608#else
    624609    return false;
     
    631616    ASSERT(m_scopeResolver);
    632617
    633     m_matchedRules.clear();
     618    m_state.matchedRules.clear();
    634619    result.ranges.lastAuthorRule = result.matchedProperties.size() - 1;
    635620
    636621    Vector<RuleSet*> matchedRules;
    637     m_scopeResolver->matchHostRules(m_element, matchedRules);
     622    m_scopeResolver->matchHostRules(m_state.element, matchedRules);
    638623    if (matchedRules.isEmpty())
    639624        return;
     
    641626    for (unsigned i = matchedRules.size(); i > 0; --i) {
    642627        RuleRange ruleRange = result.ranges.authorRuleRange();
    643         collectMatchingRules(MatchRequest(matchedRules.at(i-1), includeEmptyRules, m_element), ruleRange);
     628        collectMatchingRules(MatchRequest(matchedRules.at(i-1), includeEmptyRules, m_state.element), ruleRange);
    644629    }
    645630    sortAndTransferMatchedRules(result);
     
    652637void StyleResolver::matchAuthorRules(MatchResult& result, bool includeEmptyRules)
    653638{
    654     m_matchedRules.clear();
     639    m_state.matchedRules.clear();
    655640    result.ranges.lastAuthorRule = result.matchedProperties.size() - 1;
    656641
    657     if (!m_element)
     642    if (!m_state.element)
    658643        return;
    659644
     
    673658        return;
    674659   
    675     m_matchedRules.clear();
     660    m_state.matchedRules.clear();
    676661
    677662    result.ranges.lastUserRule = result.matchedProperties.size() - 1;
     
    686671void StyleResolver::matchUARules(MatchResult& result, RuleSet* rules)
    687672{
    688     m_matchedRules.clear();
     673    m_state.matchedRules.clear();
    689674   
    690675    result.ranges.lastUARule = result.matchedProperties.size() - 1;
     
    700685        return;
    701686
     687    State& state = m_state;
    702688    // In some cases we may end up looking up style for random elements in the middle of a recursive tree resolve.
    703689    // Ancestor identifier filter won't be up-to-date in that case and we can't use the fast path.
    704     bool canUseFastReject = m_selectorFilter.parentStackIsConsistent(m_parentNode);
     690    bool canUseFastReject = m_selectorFilter.parentStackIsConsistent(state.parentNode);
    705691
    706692    unsigned size = rules->size();
     
    720706            }
    721707            // FIXME: Exposing the non-standard getMatchedCSSRules API to web is the only reason this is needed.
    722             if (m_sameOriginOnly && !ruleData.hasDocumentSecurityOrigin()) {
     708            if (state.sameOriginOnly && !ruleData.hasDocumentSecurityOrigin()) {
    723709                InspectorInstrumentation::didMatchRule(cookie, false);
    724710                continue;
     
    726712            // If we're matching normal rules, set a pseudo bit if
    727713            // we really just matched a pseudo-element.
    728             if (m_dynamicPseudo != NOPSEUDO && m_pseudoStyle == NOPSEUDO) {
     714            if (state.dynamicPseudo != NOPSEUDO && state.pseudoStyle == NOPSEUDO) {
    729715                if (m_selectorChecker.mode() == SelectorChecker::CollectingRules) {
    730716                    InspectorInstrumentation::didMatchRule(cookie, false);
    731717                    continue;
    732718                }
    733                 if (m_dynamicPseudo < FIRST_INTERNAL_PSEUDOID)
    734                     m_style->setHasPseudoStyle(m_dynamicPseudo);
     719                if (state.dynamicPseudo < FIRST_INTERNAL_PSEUDOID)
     720                    state.style->setHasPseudoStyle(state.dynamicPseudo);
    735721            } else {
    736722                // Update our first/last rule indices in the matched rules array.
     
    758744void StyleResolver::sortMatchedRules()
    759745{
    760     std::sort(m_matchedRules.begin(), m_matchedRules.end(), compareRules);
     746    std::sort(m_state.matchedRules.begin(), m_state.matchedRules.end(), compareRules);
    761747}
    762748
     
    768754    if (m_matchAuthorAndUserStyles)
    769755        matchUserRules(result, false);
    770        
     756
    771757    // Now check author rules, beginning first with presentational attributes mapped from HTML.
    772     if (m_styledElement) {
    773         addElementStyleProperties(result, m_styledElement->presentationAttributeStyle());
     758    if (m_state.styledElement) {
     759        addElementStyleProperties(result, m_state.styledElement->presentationAttributeStyle());
    774760
    775761        // Now we check additional mapped declarations.
    776762        // Tables and table cells share an additional mapped rule that must be applied
    777763        // after all attributes, since their mapped style depends on the values of multiple attributes.
    778         addElementStyleProperties(result, m_styledElement->additionalPresentationAttributeStyle());
    779 
    780         if (m_styledElement->isHTMLElement()) {
     764        addElementStyleProperties(result, m_state.styledElement->additionalPresentationAttributeStyle());
     765
     766        if (m_state.styledElement->isHTMLElement()) {
    781767            bool isAuto;
    782             TextDirection textDirection = toHTMLElement(m_styledElement)->directionalityIfhasDirAutoAttribute(isAuto);
     768            TextDirection textDirection = toHTMLElement(m_state.styledElement)->directionalityIfhasDirAutoAttribute(isAuto);
    783769            if (isAuto)
    784770                addMatchedProperties(result, textDirection == LTR ? leftToRightDeclaration() : rightToLeftDeclaration());
     
    791777
    792778    // Now check our inline style attribute.
    793     if (m_matchAuthorAndUserStyles && m_styledElement && m_styledElement->inlineStyle()) {
     779    if (m_matchAuthorAndUserStyles && m_state.styledElement && m_state.styledElement->inlineStyle()) {
    794780        // Inline style is immutable as long as there is no CSSOM wrapper.
    795781        // FIXME: Media control shadow trees seem to have problems with caching.
    796         bool isInlineStyleCacheable = !m_styledElement->inlineStyle()->isMutable() && !m_styledElement->isInShadowTree();
     782        bool isInlineStyleCacheable = !m_state.styledElement->inlineStyle()->isMutable() && !m_state.styledElement->isInShadowTree();
    797783        // FIXME: Constify.
    798         addElementStyleProperties(result, m_styledElement->inlineStyle(), isInlineStyleCacheable);
     784        addElementStyleProperties(result, m_state.styledElement->inlineStyle(), isInlineStyleCacheable);
    799785    }
    800786
    801787#if ENABLE(SVG)
    802788    // Now check SMIL animation override style.
    803     if (includeSMILProperties && m_matchAuthorAndUserStyles && m_styledElement && m_styledElement->isSVGElement())
    804         addElementStyleProperties(result, static_cast<SVGElement*>(m_styledElement)->animatedSMILStyleProperties(), false /* isCacheable */);
     789    if (includeSMILProperties && m_matchAuthorAndUserStyles && m_state.styledElement && m_state.styledElement->isSVGElement())
     790        addElementStyleProperties(result, static_cast<SVGElement*>(m_state.styledElement)->animatedSMILStyleProperties(), false /* isCacheable */);
    805791#else
    806792    UNUSED_PARAM(includeSMILProperties);
     
    819805inline void StyleResolver::initElement(Element* e)
    820806{
    821     if (m_element != e) {
    822         m_element = e;
    823         m_styledElement = m_element && m_element->isStyledElement() ? static_cast<StyledElement*>(m_element) : 0;
    824         m_elementLinkState = document()->visitedLinkState()->determineLinkState(m_element);
     807    if (m_state.element != e) {
     808        m_state.element = e;
     809        m_state.styledElement = m_state.element && m_state.element->isStyledElement() ? static_cast<StyledElement*>(m_state.element) : 0;
     810        m_state.elementLinkState = document()->visitedLinkState()->determineLinkState(e);
    825811        if (e && e == e->document()->documentElement()) {
    826812            e->document()->setDirectionSetOnDocumentElement(false);
     
    832818inline void StyleResolver::initForStyleResolve(Element* e, RenderStyle* parentStyle, PseudoId pseudoID)
    833819{
    834     m_pseudoStyle = pseudoID;
     820    State& state = m_state;
     821    state.pseudoStyle = pseudoID;
    835822
    836823    if (e) {
    837824        NodeRenderingContext context(e);
    838         m_parentNode = context.parentNodeForRenderingAndStyle();
    839         m_parentStyle = context.resetStyleInheritance() ? 0 :
     825        state.parentNode = context.parentNodeForRenderingAndStyle();
     826        state.parentStyle = context.resetStyleInheritance() ? 0 :
    840827            parentStyle ? parentStyle :
    841             m_parentNode ? m_parentNode->renderStyle() : 0;
    842         m_distributedToInsertionPoint = context.insertionPoint();
     828            state.parentNode ? state.parentNode->renderStyle() : 0;
     829        state.distributedToInsertionPoint = context.insertionPoint();
    843830    } else {
    844         m_parentNode = 0;
    845         m_parentStyle = parentStyle;
    846         m_distributedToInsertionPoint = false;
     831        state.parentNode = 0;
     832        state.parentStyle = parentStyle;
     833        state.distributedToInsertionPoint = false;
    847834    }
    848835
    849836    Node* docElement = e ? e->document()->documentElement() : 0;
    850837    RenderStyle* docStyle = document()->renderStyle();
    851     m_rootElementStyle = docElement && e != docElement ? docElement->renderStyle() : docStyle;
    852 
    853     m_style = 0;
    854 
    855     m_pendingImageProperties.clear();
    856 
    857     m_ruleList = 0;
    858 
    859     m_fontDirty = false;
     838    state.rootElementStyle = docElement && e != docElement ? docElement->renderStyle() : docStyle;
     839
     840    state.style = 0;
     841
     842    state.pendingImageProperties.clear();
     843
     844    state.ruleList = 0;
     845
     846    state.fontDirty = false;
    860847}
    861848
     
    920907    if (!ruleSet)
    921908        return false;
    922     m_matchedRules.clear();
     909    m_state.matchedRules.clear();
    923910
    924911    m_selectorChecker.setMode(SelectorChecker::SharingRules);
     
    927914    collectMatchingRules(MatchRequest(ruleSet), ruleRange);
    928915    m_selectorChecker.setMode(SelectorChecker::ResolvingStyle);
    929     if (m_matchedRules.isEmpty())
    930         return false;
    931     m_matchedRules.clear();
     916    if (m_state.matchedRules.isEmpty())
     917        return false;
     918    m_state.matchedRules.clear();
    932919    return true;
    933920}
     
    935922bool StyleResolver::canShareStyleWithControl(StyledElement* element) const
    936923{
     924    const State& state = m_state;
    937925    HTMLInputElement* thisInputElement = element->toInputElement();
    938     HTMLInputElement* otherInputElement = m_element->toInputElement();
     926    HTMLInputElement* otherInputElement = state.element->toInputElement();
    939927
    940928    if (!thisInputElement || !otherInputElement)
     
    957945        return false;
    958946
    959     if (element->isEnabledFormControl() != m_element->isEnabledFormControl())
    960         return false;
    961 
    962     if (element->isDefaultButtonForForm() != m_element->isDefaultButtonForForm())
    963         return false;
    964 
    965     if (m_element->document()->containsValidityStyleRules()) {
     947    if (element->isEnabledFormControl() != state.element->isEnabledFormControl())
     948        return false;
     949
     950    if (element->isDefaultButtonForForm() != state.element->isDefaultButtonForForm())
     951        return false;
     952
     953    if (state.element->document()->containsValidityStyleRules()) {
    966954        bool willValidate = element->willValidate();
    967955
    968         if (willValidate != m_element->willValidate())
     956        if (willValidate != state.element->willValidate())
    969957            return false;
    970958
    971         if (willValidate && (element->isValidFormControlElement() != m_element->isValidFormControlElement()))
     959        if (willValidate && (element->isValidFormControlElement() != state.element->isValidFormControlElement()))
    972960            return false;
    973961
    974         if (element->isInRange() != m_element->isInRange())
     962        if (element->isInRange() != state.element->isInRange())
    975963            return false;
    976964
    977         if (element->isOutOfRange() != m_element->isOutOfRange())
     965        if (element->isOutOfRange() != state.element->isOutOfRange())
    978966            return false;
    979967    }
     
    990978bool StyleResolver::sharingCandidateHasIdenticalStyleAffectingAttributes(StyledElement* sharingCandidate) const
    991979{
    992     if (m_element->attributeData() == sharingCandidate->attributeData())
     980    const State& state = m_state;
     981    if (state.element->attributeData() == sharingCandidate->attributeData())
    993982        return true;
    994     if (m_element->fastGetAttribute(XMLNames::langAttr) != sharingCandidate->fastGetAttribute(XMLNames::langAttr))
    995         return false;
    996     if (m_element->fastGetAttribute(langAttr) != sharingCandidate->fastGetAttribute(langAttr))
    997         return false;
    998 
    999     if (!m_elementAffectedByClassRules) {
     983    if (state.element->fastGetAttribute(XMLNames::langAttr) != sharingCandidate->fastGetAttribute(XMLNames::langAttr))
     984        return false;
     985    if (state.element->fastGetAttribute(langAttr) != sharingCandidate->fastGetAttribute(langAttr))
     986        return false;
     987
     988    if (!state.elementAffectedByClassRules) {
    1000989        if (sharingCandidate->hasClass() && classNamesAffectedByRules(sharingCandidate->classNames()))
    1001990            return false;
     
    1003992#if ENABLE(SVG)
    1004993        // SVG elements require a (slow!) getAttribute comparision because "class" is an animatable attribute for SVG.
    1005         if (m_element->isSVGElement()) {
    1006             if (m_element->getAttribute(classAttr) != sharingCandidate->getAttribute(classAttr))
     994        if (state.element->isSVGElement()) {
     995            if (state.element->getAttribute(classAttr) != sharingCandidate->getAttribute(classAttr))
    1007996                return false;
    1008997        } else {
    1009998#endif
    1010             if (m_element->classNames() != sharingCandidate->classNames())
     999            if (state.element->classNames() != sharingCandidate->classNames())
    10111000                return false;
    10121001#if ENABLE(SVG)
     
    10161005        return false;
    10171006
    1018     if (m_styledElement->presentationAttributeStyle() != sharingCandidate->presentationAttributeStyle())
     1007    if (state.styledElement->presentationAttributeStyle() != sharingCandidate->presentationAttributeStyle())
    10191008        return false;
    10201009
    10211010#if ENABLE(PROGRESS_ELEMENT)
    1022     if (m_element->hasTagName(progressTag)) {
    1023         if (static_cast<HTMLProgressElement*>(m_element)->isDeterminate() != static_cast<HTMLProgressElement*>(sharingCandidate)->isDeterminate())
     1011    if (state.element->hasTagName(progressTag)) {
     1012        if (static_cast<HTMLProgressElement*>(state.element)->isDeterminate() != static_cast<HTMLProgressElement*>(sharingCandidate)->isDeterminate())
    10241013            return false;
    10251014    }
     
    10321021{
    10331022    RenderStyle* style = element->renderStyle();
     1023    const State& state = m_state;
    10341024
    10351025    if (!style)
     
    10371027    if (style->unique())
    10381028        return false;
    1039     if (element->tagQName() != m_element->tagQName())
     1029    if (element->tagQName() != state.element->tagQName())
    10401030        return false;
    10411031    if (element->inlineStyle())
     
    10471037        return false;
    10481038#endif
    1049     if (element->isLink() != m_element->isLink())
    1050         return false;
    1051     if (element->hovered() != m_element->hovered())
    1052         return false;
    1053     if (element->active() != m_element->active())
    1054         return false;
    1055     if (element->focused() != m_element->focused())
    1056         return false;
    1057     if (element->shadowPseudoId() != m_element->shadowPseudoId())
     1039    if (element->isLink() != state.element->isLink())
     1040        return false;
     1041    if (element->hovered() != state.element->hovered())
     1042        return false;
     1043    if (element->active() != state.element->active())
     1044        return false;
     1045    if (element->focused() != state.element->focused())
     1046        return false;
     1047    if (element->shadowPseudoId() != state.element->shadowPseudoId())
    10581048        return false;
    10591049    if (element == element->document()->cssTarget())
     
    10611051    if (!sharingCandidateHasIdenticalStyleAffectingAttributes(element))
    10621052        return false;
    1063     if (element->additionalPresentationAttributeStyle() != m_styledElement->additionalPresentationAttributeStyle())
     1053    if (element->additionalPresentationAttributeStyle() != state.styledElement->additionalPresentationAttributeStyle())
    10641054        return false;
    10651055
     
    10771067    bool isControl = element->isFormControlElement();
    10781068
    1079     if (isControl != m_element->isFormControlElement())
     1069    if (isControl != state.element->isFormControlElement())
    10801070        return false;
    10811071
     
    11011091        return false;
    11021092
    1103     if (element->isLink() && m_elementLinkState != style->insideLink())
     1093    if (element->isLink() && state.elementLinkState != style->insideLink())
    11041094        return false;
    11051095
    11061096#if ENABLE(VIDEO_TRACK)
    11071097    // Deny sharing styles between WebVTT and non-WebVTT nodes.
    1108     if (element->isWebVTTElement() != m_element->isWebVTTElement())
    1109         return false;
    1110 
    1111     if (element->isWebVTTElement() && m_element->isWebVTTElement() && toWebVTTElement(element)->isPastNode() != toWebVTTElement(m_element)->isPastNode())
     1098    if (element->isWebVTTElement() != state.element->isWebVTTElement())
     1099        return false;
     1100
     1101    if (element->isWebVTTElement() && state.element->isWebVTTElement() && toWebVTTElement(element)->isPastNode() != toWebVTTElement(state.element)->isPastNode())
    11121102        return false;
    11131103#endif
    11141104
    11151105#if ENABLE(FULLSCREEN_API)
    1116     if (element == element->document()->webkitCurrentFullScreenElement() || m_element == m_element->document()->webkitCurrentFullScreenElement())
     1106    if (element == element->document()->webkitCurrentFullScreenElement() || state.element == state.element->document()->webkitCurrentFullScreenElement())
    11171107        return false;
    11181108#endif
     
    11351125RenderStyle* StyleResolver::locateSharedStyle()
    11361126{
    1137     if (!m_styledElement || !m_parentStyle)
     1127    State& state = m_state;
     1128    if (!state.styledElement || !state.parentStyle)
    11381129        return 0;
     1130
    11391131    // If the element has inline style it is probably unique.
    1140     if (m_styledElement->inlineStyle())
     1132    if (state.styledElement->inlineStyle())
    11411133        return 0;
    11421134#if ENABLE(SVG)
    1143     if (m_styledElement->isSVGElement() && static_cast<SVGElement*>(m_styledElement)->animatedSMILStyleProperties())
     1135    if (state.styledElement->isSVGElement() && static_cast<SVGElement*>(state.styledElement)->animatedSMILStyleProperties())
    11441136        return 0;
    11451137#endif
    11461138    // Ids stop style sharing if they show up in the stylesheets.
    1147     if (m_styledElement->hasID() && m_features.idsInRules.contains(m_styledElement->idForStyleResolution().impl()))
     1139    if (state.styledElement->hasID() && m_features.idsInRules.contains(state.styledElement->idForStyleResolution().impl()))
    11481140        return 0;
    1149     if (parentElementPreventsSharing(m_element->parentElement()))
     1141    if (parentElementPreventsSharing(state.element->parentElement()))
    11501142        return 0;
    1151     if (m_styledElement->hasScopedHTMLStyleChild())
     1143    if (state.styledElement->hasScopedHTMLStyleChild())
    11521144        return 0;
    1153     if (m_element == m_element->document()->cssTarget())
     1145    if (state.element == state.element->document()->cssTarget())
    11541146        return 0;
    1155     if (elementHasDirectionAuto(m_element))
     1147    if (elementHasDirectionAuto(state.element))
    11561148        return 0;
    11571149
    1158     // Cache whether m_element is affected by any known class selectors.
     1150    // Cache whether state.element is affected by any known class selectors.
    11591151    // FIXME: This shouldn't be a member variable. The style sharing code could be factored out of StyleResolver.
    1160     m_elementAffectedByClassRules = m_element && m_element->hasClass() && classNamesAffectedByRules(m_element->classNames());
     1152    state.elementAffectedByClassRules = state.element && state.element->hasClass() && classNamesAffectedByRules(state.element->classNames());
    11611153
    11621154    // Check previous siblings and their cousins.
     
    11641156    unsigned visitedNodeCount = 0;
    11651157    StyledElement* shareElement = 0;
    1166     Node* cousinList = m_styledElement->previousSibling();
     1158    Node* cousinList = state.styledElement->previousSibling();
    11671159    while (cousinList) {
    11681160        shareElement = findSiblingForStyleSharing(cousinList, count);
     
    11861178        return 0;
    11871179    // Tracking child index requires unique style for each node. This may get set by the sibling rule match above.
    1188     if (parentElementPreventsSharing(m_element->parentElement()))
     1180    if (parentElementPreventsSharing(state.element->parentElement()))
    11891181        return 0;
    11901182    return shareElement->renderStyle();
     
    14061398    }
    14071399
     1400    State& state = m_state;
    14081401    initElement(element);
    14091402    initForStyleResolve(element, defaultParent);
    1410     m_regionForStyling = regionForStyling;
    1411     if (sharingBehavior == AllowStyleSharing && !m_distributedToInsertionPoint) {
     1403    state.regionForStyling = regionForStyling;
     1404    if (sharingBehavior == AllowStyleSharing && !state.distributedToInsertionPoint) {
    14121405        RenderStyle* sharedStyle = locateSharedStyle();
    14131406        if (sharedStyle)
     
    14171410    RefPtr<RenderStyle> cloneForParent;
    14181411
    1419     if (m_parentStyle) {
    1420         m_style = RenderStyle::create();
    1421         m_style->inheritFrom(m_parentStyle, isAtShadowBoundary(element) ? RenderStyle::AtShadowBoundary : RenderStyle::NotAtShadowBoundary);
     1412    if (state.parentStyle) {
     1413        state.style = RenderStyle::create();
     1414        state.style->inheritFrom(state.parentStyle, isAtShadowBoundary(element) ? RenderStyle::AtShadowBoundary : RenderStyle::NotAtShadowBoundary);
    14221415    } else {
    1423         m_style = defaultStyleForElement();
    1424         cloneForParent = RenderStyle::clone(style());
    1425         m_parentStyle = cloneForParent.get();
     1416        state.style = defaultStyleForElement();
     1417        cloneForParent = RenderStyle::clone(state.style.get());
     1418        state.parentStyle = cloneForParent.get();
    14261419    }
    14271420    // contenteditable attribute (implemented by -webkit-user-modify) should
    14281421    // be propagated from shadow host to distributed node.
    1429     if (m_distributedToInsertionPoint) {
     1422    if (state.distributedToInsertionPoint) {
    14301423        if (Element* parent = element->parentElement()) {
    14311424            if (RenderStyle* styleOfShadowHost = parent->renderStyle())
    1432                 m_style->setUserModify(styleOfShadowHost->userModify());
     1425                state.style->setUserModify(styleOfShadowHost->userModify());
    14331426        }
    14341427    }
    14351428
    14361429    if (element->isLink()) {
    1437         m_style->setIsLink(true);
    1438         EInsideLink linkState = m_elementLinkState;
    1439         if (m_elementLinkState != NotInsideLink) {
     1430        state.style->setIsLink(true);
     1431        EInsideLink linkState = state.elementLinkState;
     1432        if (linkState != NotInsideLink) {
    14401433            bool forceVisited = InspectorInstrumentation::forcePseudoState(element, CSSSelector::PseudoVisited);
    14411434            if (forceVisited)
    14421435                linkState = InsideVisitedLink;
    14431436        }
    1444 
    1445         m_style->setInsideLink(linkState);
     1437        state.style->setInsideLink(linkState);
    14461438    }
    14471439
     
    14571449
    14581450    // Clean up our style object's display and text decorations (among other fixups).
    1459     adjustRenderStyle(style(), m_parentStyle, element);
     1451    adjustRenderStyle(state.style.get(), state.parentStyle, element);
    14601452
    14611453    initElement(0); // Clear out for the next resolve.
    14621454
    14631455    if (cloneForParent)
    1464         m_parentStyle = 0;
     1456        state.parentStyle = 0;
    14651457
    14661458    document()->didAccessStyleResolver();
    14671459
    14681460    // Now return the style.
    1469     return m_style.release();
     1461    return state.style.release();
    14701462}
    14711463
     
    14761468        addMatchedProperties(result, keyframe->properties());
    14771469
    1478     ASSERT(!m_style);
     1470    ASSERT(!m_state.style);
     1471
     1472    State& state = m_state;
    14791473
    14801474    // Create the style
    1481     m_style = RenderStyle::clone(elementStyle);
    1482 
    1483     m_lineHeightValue = 0;
     1475    state.style = RenderStyle::clone(elementStyle);
     1476
     1477    state.lineHeightValue = 0;
    14841478
    14851479    // We don't need to bother with !important. Since there is only ever one
     
    14931487
    14941488    // Line-height is set when we are sure we decided on the font-size
    1495     if (m_lineHeightValue)
    1496         applyProperty(CSSPropertyLineHeight, m_lineHeightValue);
     1489    if (state.lineHeightValue)
     1490        applyProperty(CSSPropertyLineHeight, state.lineHeightValue);
    14971491
    14981492    // Now do rest of the properties.
     
    15211515    document()->didAccessStyleResolver();
    15221516
    1523     return m_style.release();
     1517    return state.style.release();
    15241518}
    15251519
     
    15891583PassRefPtr<RenderStyle> StyleResolver::pseudoStyleForElement(PseudoId pseudo, Element* e, RenderStyle* parentStyle)
    15901584{
    1591     ASSERT(m_parentStyle);
     1585    ASSERT(m_state.parentStyle);
    15921586    if (!e)
    15931587        return 0;
    15941588
     1589    State& state = m_state;
     1590
    15951591    initElement(e);
    15961592
    15971593    initForStyleResolve(e, parentStyle, pseudo);
    1598     m_style = RenderStyle::create();
    1599     m_style->inheritFrom(m_parentStyle);
     1594    state.style = RenderStyle::create();
     1595    state.style->inheritFrom(m_state.parentStyle);
    16001596
    16011597    // Since we don't use pseudo-elements in any of our quirk/print user agent rules, don't waste time walking
     
    16141610        return 0;
    16151611
    1616     m_style->setStyleType(pseudo);
     1612    state.style->setStyleType(pseudo);
    16171613
    16181614    applyMatchedProperties(matchResult, e);
    16191615
    16201616    // Clean up our style object's display and text decorations (among other fixups).
    1621     adjustRenderStyle(style(), parentStyle, 0);
     1617    adjustRenderStyle(state.style.get(), m_state.parentStyle, 0);
    16221618
    16231619    // Start loading resources referenced by this style.
     
    16271623
    16281624    // Now return the style.
    1629     return m_style.release();
     1625    return state.style.release();
    16301626}
    16311627
     
    16341630    initForStyleResolve(document()->documentElement()); // m_rootElementStyle will be set to the document style.
    16351631
    1636     m_style = RenderStyle::create();
    1637     m_style->inheritFrom(m_rootElementStyle);
     1632    m_state.style = RenderStyle::create();
     1633    m_state.style->inheritFrom(m_state.rootElementStyle);
    16381634
    16391635    const bool isLeft = isLeftPage(pageIndex);
     
    16461642    // Only consider the global author RuleSet for @page rules, as per the HTML5 spec.
    16471643    matchPageRules(result, m_authorStyle.get(), isLeft, isFirst, page);
    1648     m_lineHeightValue = 0;
     1644    m_state.lineHeightValue = 0;
    16491645    bool inheritedOnly = false;
    16501646#if ENABLE(CSS_VARIABLES)
     
    16571653
    16581654    // Line-height is set when we are sure we decided on the font-size.
    1659     if (m_lineHeightValue)
    1660         applyProperty(CSSPropertyLineHeight, m_lineHeightValue);
     1655    if (m_state.lineHeightValue)
     1656        applyProperty(CSSPropertyLineHeight, m_state.lineHeightValue);
    16611657
    16621658    applyMatchedProperties<LowPriorityProperties>(result, false, 0, result.matchedProperties.size() - 1, inheritedOnly);
     
    16681664
    16691665    // Now return the style.
    1670     return m_style.release();
     1666    return m_state.style.release();
    16711667}
    16721668
    16731669PassRefPtr<RenderStyle> StyleResolver::defaultStyleForElement()
    16741670{
    1675     m_style = RenderStyle::create();
     1671    m_state.style = RenderStyle::create();
    16761672    // Make sure our fonts are initialized if we don't inherit them from our parent style.
    16771673    if (Settings* settings = documentSettings()) {
    16781674        initializeFontStyle(settings);
    1679         m_style->font().update(fontSelector());
     1675        m_state.style->font().update(fontSelector());
    16801676    } else
    1681         m_style->font().update(0);
    1682 
    1683     return m_style.release();
     1677        m_state.style->font().update(0);
     1678
     1679    return m_state.style.release();
    16841680}
    16851681
     
    19691965    // Let the theme also have a crack at adjusting the style.
    19701966    if (style->hasAppearance())
    1971         RenderTheme::defaultTheme()->adjustStyle(this, style, e, m_hasUAAppearance, m_borderData, m_backgroundData, m_backgroundColor);
     1967        RenderTheme::defaultTheme()->adjustStyle(this, style, e, m_state.hasUAAppearance, m_state.borderData, m_state.backgroundData, m_state.backgroundColor);
    19721968
    19731969    // If we have first-letter pseudo style, do not share this style.
     
    20522048void StyleResolver::updateFont()
    20532049{
    2054     if (!m_fontDirty)
     2050    if (!m_state.fontDirty)
    20552051        return;
    20562052
    20572053    checkForTextSizeAdjust();
    2058     checkForGenericFamilyChange(style(), m_parentStyle);
    2059     checkForZoomChange(style(), m_parentStyle);
    2060     checkForOrientationChange(style());
    2061     m_style->font().update(m_fontSelector);
    2062     m_fontDirty = false;
     2054    RenderStyle* style = m_state.style.get();
     2055    checkForGenericFamilyChange(style, m_state.parentStyle);
     2056    checkForZoomChange(style, m_state.parentStyle);
     2057    checkForOrientationChange(style);
     2058    m_state.style->font().update(m_fontSelector);
     2059    m_state.fontDirty = false;
    20632060}
    20642061
    20652062void StyleResolver::cacheBorderAndBackground()
    20662063{
    2067     m_hasUAAppearance = m_style->hasAppearance();
    2068     if (m_hasUAAppearance) {
    2069         m_borderData = m_style->border();
    2070         m_backgroundData = *m_style->backgroundLayers();
    2071         m_backgroundColor = m_style->backgroundColor();
     2064    m_state.hasUAAppearance = m_state.style->hasAppearance();
     2065    if (m_state.hasUAAppearance) {
     2066        m_state.borderData = m_state.style->border();
     2067        m_state.backgroundData = *m_state.style->backgroundLayers();
     2068        m_state.backgroundColor = m_state.style->backgroundColor();
    20722069    }
    20732070}
     
    20992096
    21002097    if (m_matchAuthorAndUserStyles && (rulesToInclude & AuthorCSSRules)) {
    2101         m_sameOriginOnly = !(rulesToInclude & CrossOriginCSSRules);
     2098        m_state.sameOriginOnly = !(rulesToInclude & CrossOriginCSSRules);
    21022099
    21032100        // Check the rules in author sheets.
    21042101        matchAuthorRules(dummy, rulesToInclude & EmptyCSSRules);
    21052102
    2106         m_sameOriginOnly = false;
     2103        m_state.sameOriginOnly = false;
    21072104    }
    21082105
    21092106    m_selectorChecker.setMode(SelectorChecker::ResolvingStyle);
    21102107
    2111     return m_ruleList.release();
     2108    return m_state.ruleList.release();
    21122109}
    21132110
    21142111inline bool StyleResolver::ruleMatches(const RuleData& ruleData, const ContainerNode* scope)
    21152112{
    2116     m_dynamicPseudo = NOPSEUDO;
     2113    State& state = m_state;
     2114    state.dynamicPseudo = NOPSEUDO;
    21172115
    21182116    if (ruleData.hasFastCheckableSelector()) {
    21192117        // We know this selector does not include any pseudo elements.
    2120         if (m_pseudoStyle != NOPSEUDO)
     2118        if (state.pseudoStyle != NOPSEUDO)
    21212119            return false;
    21222120        // We know a sufficiently simple single part selector matches simply because we found it from the rule hash.
    21232121        // This is limited to HTML only so we don't need to check the namespace.
    2124         if (ruleData.hasRightmostSelectorMatchingHTMLBasedOnRuleHash() && m_element->isHTMLElement()) {
     2122        if (ruleData.hasRightmostSelectorMatchingHTMLBasedOnRuleHash() && state.element->isHTMLElement()) {
    21252123            if (!ruleData.hasMultipartSelector())
    21262124                return true;
    21272125        }
    2128         if (ruleData.selector()->m_match == CSSSelector::Tag && !SelectorChecker::tagMatches(m_element, ruleData.selector()->tagQName()))
     2126        if (ruleData.selector()->m_match == CSSSelector::Tag && !SelectorChecker::tagMatches(state.element, ruleData.selector()->tagQName()))
    21292127            return false;
    2130         if (!SelectorChecker::fastCheckRightmostAttributeSelector(m_element, ruleData.selector()))
     2128        if (!SelectorChecker::fastCheckRightmostAttributeSelector(state.element, ruleData.selector()))
    21312129            return false;
    2132         return m_selectorChecker.fastCheck(ruleData.selector(), m_element);
     2130
     2131        return m_selectorChecker.fastCheck(ruleData.selector(), state.element);
    21332132    }
    21342133
    21352134    // Slow path.
    2136     SelectorChecker::SelectorCheckingContext context(ruleData.selector(), m_element, SelectorChecker::VisitedMatchEnabled);
    2137     context.elementStyle = style();
     2135    SelectorChecker::SelectorCheckingContext context(ruleData.selector(), state.element, SelectorChecker::VisitedMatchEnabled);
     2136    context.elementStyle = state.style.get();
    21382137    context.scope = scope;
    2139     context.pseudoStyle = m_pseudoStyle;
    2140     SelectorChecker::Match match = m_selectorChecker.match(context, m_dynamicPseudo, DOMSiblingTraversalStrategy());
     2138    context.pseudoStyle = state.pseudoStyle;
     2139    SelectorChecker::Match match = m_selectorChecker.match(context, state.dynamicPseudo, DOMSiblingTraversalStrategy());
    21412140    if (match != SelectorChecker::SelectorMatches)
    21422141        return false;
    2143     if (m_pseudoStyle != NOPSEUDO && m_pseudoStyle != m_dynamicPseudo)
     2142    if (state.pseudoStyle != NOPSEUDO && state.pseudoStyle != state.dynamicPseudo)
    21442143        return false;
    21452144    return true;
     
    21512150        return false;
    21522151
    2153     m_pseudoStyle = NOPSEUDO;
     2152    m_state.pseudoStyle = NOPSEUDO;
    21542153
    21552154    for (const CSSSelector* s = regionSelector; s; s = CSSSelectorList::next(s))
     
    21762175void StyleResolver::applyProperties(const StylePropertySet* properties, StyleRule* rule, bool isImportant, bool inheritedOnly, PropertyWhitelistType propertyWhitelistType)
    21772176{
    2178     ASSERT((propertyWhitelistType != PropertyWhitelistRegion) || m_regionForStyling);
     2177    ASSERT((propertyWhitelistType != PropertyWhitelistRegion) || m_state.regionForStyling);
    21792178    InspectorInstrumentationCookie cookie = InspectorInstrumentation::willProcessRule(document(), rule, this);
    21802179
     
    22202219            // we apply line-height later
    22212220            else if (property == CSSPropertyLineHeight)
    2222                 m_lineHeightValue = current.value();
     2221                m_state.lineHeightValue = current.value();
    22232222            break;
    22242223        case LowPriorityProperties:
     
    22362235        return;
    22372236
    2238     if (m_style->insideLink() != NotInsideLink) {
     2237    State& state = m_state;
     2238    if (state.style->insideLink() != NotInsideLink) {
    22392239        for (int i = startIndex; i <= endIndex; ++i) {
    22402240            const MatchedProperties& matchedProperties = matchResult.matchedProperties[i];
    22412241            unsigned linkMatchType = matchedProperties.linkMatchType;
    22422242            // FIXME: It would be nicer to pass these as arguments but that requires changes in many places.
    2243             m_applyPropertyToRegularStyle = linkMatchType & SelectorChecker::MatchLink;
    2244             m_applyPropertyToVisitedLinkStyle = linkMatchType & SelectorChecker::MatchVisited;
     2243            state.applyPropertyToRegularStyle = linkMatchType & SelectorChecker::MatchLink;
     2244            state.applyPropertyToVisitedLinkStyle = linkMatchType & SelectorChecker::MatchVisited;
    22452245
    22462246            applyProperties<pass>(matchedProperties.properties.get(), matchResult.matchedRules[i], isImportant, inheritedOnly, static_cast<PropertyWhitelistType>(matchedProperties.whitelistType));
    22472247        }
    2248         m_applyPropertyToRegularStyle = true;
    2249         m_applyPropertyToVisitedLinkStyle = false;
     2248        state.applyPropertyToRegularStyle = true;
     2249        state.applyPropertyToVisitedLinkStyle = false;
    22502250        return;
    22512251    }
     
    23552355{
    23562356    ASSERT(element);
     2357    State& state = m_state;
    23572358    unsigned cacheHash = matchResult.isCacheable ? computeMatchedPropertiesHash(matchResult.matchedProperties.data(), matchResult.matchedProperties.size()) : 0;
    23582359    bool applyInheritedOnly = false;
     
    23622363        // style declarations. We then only need to apply the inherited properties, if any, as their values can depend on the
    23632364        // element context. This is fast and saves memory by reusing the style data structures.
    2364         m_style->copyNonInheritedFrom(cacheItem->renderStyle.get());
    2365         if (m_parentStyle->inheritedDataShared(cacheItem->parentRenderStyle.get()) && !isAtShadowBoundary(element)) {
    2366             EInsideLink linkStatus = m_style->insideLink();
     2365        state.style->copyNonInheritedFrom(cacheItem->renderStyle.get());
     2366        if (state.parentStyle->inheritedDataShared(cacheItem->parentRenderStyle.get()) && !isAtShadowBoundary(element)) {
     2367            EInsideLink linkStatus = state.style->insideLink();
    23672368            // If the cache item parent style has identical inherited properties to the current parent style then the
    23682369            // resulting style will be identical too. We copy the inherited properties over from the cache and are done.
    2369             m_style->inheritFrom(cacheItem->renderStyle.get());
     2370            state.style->inheritFrom(cacheItem->renderStyle.get());
    23702371
    23712372            // Unfortunately the link status is treated like an inherited property. We need to explicitly restore it.
    2372             m_style->setInsideLink(linkStatus);
     2373            state.style->setInsideLink(linkStatus);
    23732374            return;
    23742375        }
     
    23882389    // The order is (1) high-priority not important, (2) high-priority important, (3) normal not important
    23892390    // and (4) normal important.
    2390     m_lineHeightValue = 0;
     2391    state.lineHeightValue = 0;
    23912392    applyMatchedProperties<HighPriorityProperties>(matchResult, false, 0, matchResult.matchedProperties.size() - 1, applyInheritedOnly);
    23922393    applyMatchedProperties<HighPriorityProperties>(matchResult, true, matchResult.ranges.firstAuthorRule, matchResult.ranges.lastAuthorRule, applyInheritedOnly);
     
    23942395    applyMatchedProperties<HighPriorityProperties>(matchResult, true, matchResult.ranges.firstUARule, matchResult.ranges.lastUARule, applyInheritedOnly);
    23952396
    2396     if (cacheItem && cacheItem->renderStyle->effectiveZoom() != m_style->effectiveZoom()) {
    2397         m_fontDirty = true;
     2397    if (cacheItem && cacheItem->renderStyle->effectiveZoom() != state.style->effectiveZoom()) {
     2398        state.fontDirty = true;
    23982399        applyInheritedOnly = false;
    23992400    }
     
    24032404
    24042405    // Line-height is set when we are sure we decided on the font-size.
    2405     if (m_lineHeightValue)
    2406         applyProperty(CSSPropertyLineHeight, m_lineHeightValue);
     2406    if (state.lineHeightValue)
     2407        applyProperty(CSSPropertyLineHeight, state.lineHeightValue);
    24072408
    24082409    // Many properties depend on the font. If it changes we just apply all properties.
    2409     if (cacheItem && cacheItem->renderStyle->fontDescription() != m_style->fontDescription())
     2410    if (cacheItem && cacheItem->renderStyle->fontDescription() != state.style->fontDescription())
    24102411        applyInheritedOnly = false;
    24112412
     
    24252426    loadPendingResources();
    24262427   
    2427     ASSERT(!m_fontDirty);
     2428    ASSERT(!state.fontDirty);
    24282429   
    24292430    if (cacheItem || !cacheHash)
    24302431        return;
    2431     if (!isCacheableInMatchedPropertiesCache(m_element, m_style.get(), m_parentStyle))
    2432         return;
    2433     addToMatchedPropertiesCache(m_style.get(), m_parentStyle, cacheHash, matchResult);
     2432    if (!isCacheableInMatchedPropertiesCache(state.element, state.style.get(), state.parentStyle))
     2433        return;
     2434    addToMatchedPropertiesCache(state.style.get(), state.parentStyle, cacheHash, matchResult);
    24342435}
    24352436
     
    24962497{
    24972498    bool isFirstPageLeft = false;
    2498     if (!m_rootElementStyle->isLeftToRightDirection())
     2499    if (!m_state.rootElementStyle->isLeftToRightDirection())
    24992500        isFirstPageLeft = true;
    25002501
     
    26092610    initElement(0);
    26102611    initForStyleResolve(0, style);
    2611     m_style = style;
     2612    m_state.style = style;
    26122613    applyPropertyToCurrentStyle(id, value);
    26132614}
     
    27212722bool StyleResolver::useSVGZoomRules()
    27222723{
    2723     return m_element && m_element->isSVGElement();
    2724 }
    2725 
    2726 static bool createGridTrackBreadth(CSSPrimitiveValue* primitiveValue, StyleResolver* selector, Length& workingLength)
     2724    return m_state.element && m_state.element->isSVGElement();
     2725}
     2726
     2727static bool createGridTrackBreadth(CSSPrimitiveValue* primitiveValue, const StyleResolver::State& state, Length& workingLength)
    27272728{
    27282729    if (primitiveValue->getIdent() == CSSValueWebkitMinContent) {
     
    27362737    }
    27372738
    2738     workingLength = primitiveValue->convertToLength<FixedIntegerConversion | PercentConversion | ViewportPercentageConversion | AutoConversion>(selector->style(), selector->rootElementStyle(), selector->style()->effectiveZoom());
     2739    workingLength = primitiveValue->convertToLength<FixedIntegerConversion | PercentConversion | ViewportPercentageConversion | AutoConversion>(state.style.get(), state.rootElementStyle, state.style->effectiveZoom());
    27392740    if (workingLength.isUndefined())
    27402741        return false;
     
    27462747}
    27472748
    2748 static bool createGridTrackMinMax(CSSPrimitiveValue* primitiveValue, StyleResolver* selector, GridTrackSize& trackSize)
     2749static bool createGridTrackMinMax(CSSPrimitiveValue* primitiveValue, const StyleResolver::State& state, GridTrackSize& trackSize)
    27492750{
    27502751    Pair* minMaxTrackBreadth = primitiveValue->getPairValue();
    27512752    if (!minMaxTrackBreadth) {
    27522753        Length workingLength;
    2753         if (!createGridTrackBreadth(primitiveValue, selector, workingLength))
     2754        if (!createGridTrackBreadth(primitiveValue, state, workingLength))
    27542755            return false;
    27552756
     
    27602761    Length minTrackBreadth;
    27612762    Length maxTrackBreadth;
    2762     if (!createGridTrackBreadth(minMaxTrackBreadth->first(), selector, minTrackBreadth) || !createGridTrackBreadth(minMaxTrackBreadth->second(), selector, maxTrackBreadth))
     2763    if (!createGridTrackBreadth(minMaxTrackBreadth->first(), state, minTrackBreadth) || !createGridTrackBreadth(minMaxTrackBreadth->second(), state, maxTrackBreadth))
    27632764        return false;
    27642765
     
    27672768}
    27682769
    2769 static bool createGridTrackGroup(CSSValue* value, StyleResolver* selector, Vector<GridTrackSize>& trackSizes)
     2770static bool createGridTrackGroup(CSSValue* value, const StyleResolver::State& state, Vector<GridTrackSize>& trackSizes)
    27702771{
    27712772    if (!value->isValueList())
     
    27782779
    27792780        GridTrackSize trackSize;
    2780         if (!createGridTrackMinMax(static_cast<CSSPrimitiveValue*>(currValue), selector, trackSize))
     2781        if (!createGridTrackMinMax(static_cast<CSSPrimitiveValue*>(currValue), state, trackSize))
    27812782            return false;
    27822783
     
    27862787}
    27872788
    2788 static bool createGridTrackList(CSSValue* value, Vector<GridTrackSize>& trackSizes, StyleResolver* selector)
     2789static bool createGridTrackList(CSSValue* value, Vector<GridTrackSize>& trackSizes, const StyleResolver::State& state)
    27892790{
    27902791    // Handle 'none'.
     
    27942795    }
    27952796
    2796     return createGridTrackGroup(value, selector, trackSizes);
     2797    return createGridTrackGroup(value, state, trackSizes);
    27972798}
    27982799
     
    28422843void StyleResolver::resolveVariables(CSSPropertyID id, CSSValue* value, Vector<std::pair<CSSPropertyID, String> >& knownExpressions)
    28432844{
    2844     std::pair<CSSPropertyID, String> expression(id, value->serializeResolvingVariables(*style()->variables()));
     2845    std::pair<CSSPropertyID, String> expression(id, value->serializeResolvingVariables(*m_state.style->variables()));
    28452846
    28462847    if (knownExpressions.contains(expression))
     
    28742875#endif
    28752876
    2876     bool isInherit = m_parentNode && value->isInheritedValue();
    2877     bool isInitial = value->isInitialValue() || (!m_parentNode && value->isInheritedValue());
     2877    State& state = m_state;
     2878    bool isInherit = state.parentNode && value->isInheritedValue();
     2879    bool isInitial = value->isInitialValue() || (!state.parentNode && value->isInheritedValue());
    28782880
    28792881    ASSERT(!isInherit || !isInitial); // isInherit -> !isInitial && isInitial -> !isInherit
    2880     ASSERT(!isInherit || (m_parentNode && m_parentStyle)); // isInherit -> (m_parentNode && m_parentStyle)
    2881 
    2882     if (!applyPropertyToRegularStyle() && (!applyPropertyToVisitedLinkStyle() || !isValidVisitedLinkProperty(id))) {
     2882    ASSERT(!isInherit || (state.parentNode && state.parentStyle)); // isInherit -> (state.parentNode && state.parentStyle)
     2883
     2884    if (!state.applyPropertyToRegularStyle && (!state.applyPropertyToVisitedLinkStyle || !isValidVisitedLinkProperty(id))) {
    28832885        // Limit the properties that can be applied to only the ones honored by :visited.
    28842886        return;
    28852887    }
    28862888
    2887     if (isInherit && !m_parentStyle->hasExplicitlyInheritedProperties() && !CSSProperty::isInheritedProperty(id))
    2888         m_parentStyle->setHasExplicitlyInheritedProperties();
     2889    if (isInherit && !state.parentStyle->hasExplicitlyInheritedProperties() && !CSSProperty::isInheritedProperty(id))
     2890        state.parentStyle->setHasExplicitlyInheritedProperties();
    28892891
    28902892#if ENABLE(CSS_VARIABLES)
     
    28942896        ASSERT(!variable->name().isEmpty());
    28952897        ASSERT(!variable->value().isEmpty());
    2896         m_style->setVariable(variable->name(), variable->value());
     2898        state.style->setVariable(variable->name(), variable->value());
    28972899        return;
    28982900    }
     
    29132915    CSSPrimitiveValue* primitiveValue = value->isPrimitiveValue() ? static_cast<CSSPrimitiveValue*>(value) : 0;
    29142916
    2915     float zoomFactor = m_style->effectiveZoom();
     2917    float zoomFactor = state.style->effectiveZoom();
    29162918
    29172919    // What follows is a list that maps the CSS properties into their corresponding front-end
     
    29272929
    29282930            if (isInitial) {
    2929                 m_style->clearContent();
     2931                state.style->clearContent();
    29302932                return;
    29312933            }
     
    29392941                if (item->isImageGeneratorValue()) {
    29402942                    if (item->isGradientValue())
    2941                         m_style->setContent(StyleGeneratedImage::create(static_cast<CSSGradientValue*>(item)->gradientWithStylesResolved(this).get()), didSet);
     2943                        state.style->setContent(StyleGeneratedImage::create(static_cast<CSSGradientValue*>(item)->gradientWithStylesResolved(this).get()), didSet);
    29422944                    else
    2943                         m_style->setContent(StyleGeneratedImage::create(static_cast<CSSImageGeneratorValue*>(item)), didSet);
     2945                        state.style->setContent(StyleGeneratedImage::create(static_cast<CSSImageGeneratorValue*>(item)), didSet);
    29442946                    didSet = true;
    29452947#if ENABLE(CSS_IMAGE_SET)
    29462948                } else if (item->isImageSetValue()) {
    2947                     m_style->setContent(setOrPendingFromValue(CSSPropertyContent, static_cast<CSSImageSetValue*>(item)), didSet);
     2949                    state.style->setContent(setOrPendingFromValue(CSSPropertyContent, static_cast<CSSImageSetValue*>(item)), didSet);
    29482950                    didSet = true;
    29492951#endif
     
    29512953
    29522954                if (item->isImageValue()) {
    2953                     m_style->setContent(cachedOrPendingFromValue(CSSPropertyContent, static_cast<CSSImageValue*>(item)), didSet);
     2955                    state.style->setContent(cachedOrPendingFromValue(CSSPropertyContent, static_cast<CSSImageValue*>(item)), didSet);
    29542956                    didSet = true;
    29552957                    continue;
     
    29622964
    29632965                if (contentValue->isString()) {
    2964                     m_style->setContent(contentValue->getStringValue().impl(), didSet);
     2966                    state.style->setContent(contentValue->getStringValue().impl(), didSet);
    29652967                    didSet = true;
    29662968                } else if (contentValue->isAttr()) {
    29672969                    // FIXME: Can a namespace be specified for an attr(foo)?
    2968                     if (m_style->styleType() == NOPSEUDO)
    2969                         m_style->setUnique();
     2970                    if (state.style->styleType() == NOPSEUDO)
     2971                        state.style->setUnique();
    29702972                    else
    2971                         m_parentStyle->setUnique();
     2973                        state.parentStyle->setUnique();
    29722974                    QualifiedName attr(nullAtom, contentValue->getStringValue().impl(), nullAtom);
    2973                     const AtomicString& value = m_element->getAttribute(attr);
    2974                     m_style->setContent(value.isNull() ? emptyAtom : value.impl(), didSet);
     2975                    const AtomicString& value = state.element->getAttribute(attr);
     2976                    state.style->setContent(value.isNull() ? emptyAtom : value.impl(), didSet);
    29752977                    didSet = true;
    29762978                    // register the fact that the attribute value affects the style
     
    29832985                        listStyleType = static_cast<EListStyleType>(listStyleIdent - CSSValueDisc);
    29842986                    OwnPtr<CounterContent> counter = adoptPtr(new CounterContent(counterValue->identifier(), listStyleType, counterValue->separator()));
    2985                     m_style->setContent(counter.release(), didSet);
     2987                    state.style->setContent(counter.release(), didSet);
    29862988                    didSet = true;
    29872989                } else {
    29882990                    switch (contentValue->getIdent()) {
    29892991                    case CSSValueOpenQuote:
    2990                         m_style->setContent(OPEN_QUOTE, didSet);
     2992                        state.style->setContent(OPEN_QUOTE, didSet);
    29912993                        didSet = true;
    29922994                        break;
    29932995                    case CSSValueCloseQuote:
    2994                         m_style->setContent(CLOSE_QUOTE, didSet);
     2996                        state.style->setContent(CLOSE_QUOTE, didSet);
    29952997                        didSet = true;
    29962998                        break;
    29972999                    case CSSValueNoOpenQuote:
    2998                         m_style->setContent(NO_OPEN_QUOTE, didSet);
     3000                        state.style->setContent(NO_OPEN_QUOTE, didSet);
    29993001                        didSet = true;
    30003002                        break;
    30013003                    case CSSValueNoCloseQuote:
    3002                         m_style->setContent(NO_CLOSE_QUOTE, didSet);
     3004                        state.style->setContent(NO_CLOSE_QUOTE, didSet);
    30033005                        didSet = true;
    30043006                        break;
     
    30103012            }
    30113013            if (!didSet)
    3012                 m_style->clearContent();
     3014                state.style->clearContent();
    30133015            return;
    30143016        }
    30153017    case CSSPropertyQuotes:
    30163018        if (isInherit) {
    3017             m_style->setQuotes(m_parentStyle->quotes());
     3019            state.style->setQuotes(state.parentStyle->quotes());
    30183020            return;
    30193021        }
    30203022        if (isInitial) {
    3021             m_style->setQuotes(0);
     3023            state.style->setQuotes(0);
    30223024            return;
    30233025        }
     
    30373039                quotes->addPair(std::make_pair(startQuote, endQuote));
    30383040            }
    3039             m_style->setQuotes(quotes);
     3041            state.style->setQuotes(quotes);
    30403042            return;
    30413043        }
    30423044        if (primitiveValue) {
    30433045            if (primitiveValue->getIdent() == CSSValueNone)
    3044                 m_style->setQuotes(QuotesData::create());
     3046                state.style->setQuotes(QuotesData::create());
    30453047        }
    30463048        return;
     
    30483050        // list of strings and ids
    30493051        if (isInherit) {
    3050             FontDescription parentFontDescription = m_parentStyle->fontDescription();
    3051             FontDescription fontDescription = m_style->fontDescription();
     3052            FontDescription parentFontDescription = state.parentStyle->fontDescription();
     3053            FontDescription fontDescription = state.style->fontDescription();
    30523054            fontDescription.setGenericFamily(parentFontDescription.genericFamily());
    30533055            fontDescription.setFamily(parentFontDescription.firstFamily());
     
    30593061        if (isInitial) {
    30603062            FontDescription initialDesc = FontDescription();
    3061             FontDescription fontDescription = m_style->fontDescription();
     3063            FontDescription fontDescription = state.style->fontDescription();
    30623064            // We need to adjust the size to account for the generic family change from monospace
    30633065            // to non-monospace.
     
    30733075        if (!value->isValueList())
    30743076            return;
    3075         FontDescription fontDescription = m_style->fontDescription();
     3077        FontDescription fontDescription = state.style->fontDescription();
    30763078        FontFamily& firstFamily = fontDescription.firstFamily();
    30773079        FontFamily* currFamily = 0;
     
    31513153    case CSSPropertyBackground:
    31523154        if (isInitial) {
    3153             m_style->clearBackgroundLayers();
    3154             m_style->setBackgroundColor(Color());
     3155            state.style->clearBackgroundLayers();
     3156            state.style->setBackgroundColor(Color());
    31553157        } else if (isInherit) {
    3156             m_style->inheritBackgroundLayers(*m_parentStyle->backgroundLayers());
    3157             m_style->setBackgroundColor(m_parentStyle->backgroundColor());
     3158            state.style->inheritBackgroundLayers(*state.parentStyle->backgroundLayers());
     3159            state.style->setBackgroundColor(state.parentStyle->backgroundColor());
    31583160        }
    31593161        return;
    31603162    case CSSPropertyWebkitMask:
    31613163        if (isInitial)
    3162             m_style->clearMaskLayers();
     3164            state.style->clearMaskLayers();
    31633165        else if (isInherit)
    3164             m_style->inheritMaskLayers(*m_parentStyle->maskLayers());
     3166            state.style->inheritMaskLayers(*state.parentStyle->maskLayers());
    31653167        return;
    31663168    case CSSPropertyFont:
    31673169        if (isInherit) {
    3168             FontDescription fontDescription = m_parentStyle->fontDescription();
    3169             m_style->setLineHeight(m_parentStyle->specifiedLineHeight());
    3170             m_lineHeightValue = 0;
     3170            FontDescription fontDescription = state.parentStyle->fontDescription();
     3171            state.style->setLineHeight(state.parentStyle->specifiedLineHeight());
     3172            state.lineHeightValue = 0;
    31713173            setFontDescription(fontDescription);
    31723174        } else if (isInitial) {
     
    31773179            initializeFontStyle(settings);
    31783180        } else if (primitiveValue) {
    3179             m_style->setLineHeight(RenderStyle::initialLineHeight());
    3180             m_lineHeightValue = 0;
     3181            state.style->setLineHeight(RenderStyle::initialLineHeight());
     3182            state.lineHeightValue = 0;
    31813183
    31823184            FontDescription fontDescription;
     
    31943196
    31953197                // Handle the zoom factor.
    3196                 fontDescription.setComputedSize(getComputedSizeFromSpecifiedSize(document(), m_style.get(), fontDescription.isAbsoluteSize(), fontDescription.specifiedSize(), useSVGZoomRules()));
     3198                fontDescription.setComputedSize(getComputedSizeFromSpecifiedSize(document(), state.style.get(), fontDescription.isAbsoluteSize(), fontDescription.specifiedSize(), useSVGZoomRules()));
    31973199                setFontDescription(fontDescription);
    31983200            }
     
    32123214            applyProperty(CSSPropertyFontSize, font->size.get());
    32133215
    3214             m_lineHeightValue = font->lineHeight.get();
     3216            state.lineHeightValue = font->lineHeight.get();
    32153217
    32163218            applyProperty(CSSPropertyFontFamily, font->family.get());
     
    32243226        if (isInherit) {
    32253227            if (id == CSSPropertyTextShadow)
    3226                 return m_style->setTextShadow(m_parentStyle->textShadow() ? adoptPtr(new ShadowData(*m_parentStyle->textShadow())) : nullptr);
    3227             return m_style->setBoxShadow(m_parentStyle->boxShadow() ? adoptPtr(new ShadowData(*m_parentStyle->boxShadow())) : nullptr);
     3228                return state.style->setTextShadow(state.parentStyle->textShadow() ? adoptPtr(new ShadowData(*state.parentStyle->textShadow())) : nullptr);
     3229            return state.style->setBoxShadow(state.parentStyle->boxShadow() ? adoptPtr(new ShadowData(*state.parentStyle->boxShadow())) : nullptr);
    32283230        }
    32293231        if (isInitial || primitiveValue) // initial | none
    3230             return id == CSSPropertyTextShadow ? m_style->setTextShadow(nullptr) : m_style->setBoxShadow(nullptr);
     3232            return id == CSSPropertyTextShadow ? state.style->setTextShadow(nullptr) : state.style->setBoxShadow(nullptr);
    32313233
    32323234        if (!value->isValueList())
     
    32383240                continue;
    32393241            ShadowValue* item = static_cast<ShadowValue*>(currValue);
    3240             int x = item->x->computeLength<int>(style(), m_rootElementStyle, zoomFactor);
    3241             int y = item->y->computeLength<int>(style(), m_rootElementStyle, zoomFactor);
    3242             int blur = item->blur ? item->blur->computeLength<int>(style(), m_rootElementStyle, zoomFactor) : 0;
    3243             int spread = item->spread ? item->spread->computeLength<int>(style(), m_rootElementStyle, zoomFactor) : 0;
     3242            int x = item->x->computeLength<int>(state.style.get(), state.rootElementStyle, zoomFactor);
     3243            int y = item->y->computeLength<int>(state.style.get(), state.rootElementStyle, zoomFactor);
     3244            int blur = item->blur ? item->blur->computeLength<int>(state.style.get(), state.rootElementStyle, zoomFactor) : 0;
     3245            int spread = item->spread ? item->spread->computeLength<int>(state.style.get(), state.rootElementStyle, zoomFactor) : 0;
    32443246            ShadowStyle shadowStyle = item->style && item->style->getIdent() == CSSValueInset ? Inset : Normal;
    32453247            Color color;
    32463248            if (item->color)
    32473249                color = colorFromPrimitiveValue(item->color.get());
    3248             else if (m_style)
    3249                 color = m_style->color();
     3250            else if (state.style)
     3251                color = state.style->color();
    32503252
    32513253            OwnPtr<ShadowData> shadowData = adoptPtr(new ShadowData(IntPoint(x, y), blur, spread, shadowStyle, id == CSSPropertyWebkitBoxShadow, color.isValid() ? color : Color::transparent));
    32523254            if (id == CSSPropertyTextShadow)
    3253                 m_style->setTextShadow(shadowData.release(), i.index()); // add to the list if this is not the first entry
     3255                state.style->setTextShadow(shadowData.release(), i.index()); // add to the list if this is not the first entry
    32543256            else
    3255                 m_style->setBoxShadow(shadowData.release(), i.index()); // add to the list if this is not the first entry
     3257                state.style->setBoxShadow(shadowData.release(), i.index()); // add to the list if this is not the first entry
    32563258        }
    32573259        return;
     
    32603262        HANDLE_INHERIT_AND_INITIAL(boxReflect, BoxReflect)
    32613263        if (primitiveValue) {
    3262             m_style->setBoxReflect(RenderStyle::initialBoxReflect());
     3264            state.style->setBoxReflect(RenderStyle::initialBoxReflect());
    32633265            return;
    32643266        }
     
    32713273        reflection->setDirection(*reflectValue->direction());
    32723274        if (reflectValue->offset())
    3273             reflection->setOffset(reflectValue->offset()->convertToLength<FixedIntegerConversion | PercentConversion | CalculatedConversion>(style(), m_rootElementStyle, zoomFactor));
     3275            reflection->setOffset(reflectValue->offset()->convertToLength<FixedIntegerConversion | PercentConversion | CalculatedConversion>(state.style.get(), state.rootElementStyle, zoomFactor));
    32743276        NinePieceImage mask;
    32753277        mask.setMaskDefaults();
     
    32773279        reflection->setMask(mask);
    32783280
    3279         m_style->setBoxReflect(reflection.release());
     3281        state.style->setBoxReflect(reflection.release());
    32803282        return;
    32813283    }
     
    32863288    case CSSPropertyWebkitColumnRule:
    32873289        if (isInherit) {
    3288             m_style->setColumnRuleColor(m_parentStyle->columnRuleColor().isValid() ? m_parentStyle->columnRuleColor() : m_parentStyle->color());
    3289             m_style->setColumnRuleStyle(m_parentStyle->columnRuleStyle());
    3290             m_style->setColumnRuleWidth(m_parentStyle->columnRuleWidth());
     3290            state.style->setColumnRuleColor(state.parentStyle->columnRuleColor().isValid() ? state.parentStyle->columnRuleColor() : state.parentStyle->color());
     3291            state.style->setColumnRuleStyle(state.parentStyle->columnRuleStyle());
     3292            state.style->setColumnRuleWidth(state.parentStyle->columnRuleWidth());
    32913293        } else if (isInitial)
    3292             m_style->resetColumnRule();
     3294            state.style->resetColumnRule();
    32933295        return;
    32943296    case CSSPropertyWebkitMarquee:
    32953297        if (!isInherit)
    32963298            return;
    3297         m_style->setMarqueeDirection(m_parentStyle->marqueeDirection());
    3298         m_style->setMarqueeIncrement(m_parentStyle->marqueeIncrement());
    3299         m_style->setMarqueeSpeed(m_parentStyle->marqueeSpeed());
    3300         m_style->setMarqueeLoopCount(m_parentStyle->marqueeLoopCount());
    3301         m_style->setMarqueeBehavior(m_parentStyle->marqueeBehavior());
     3299        state.style->setMarqueeDirection(state.parentStyle->marqueeDirection());
     3300        state.style->setMarqueeIncrement(state.parentStyle->marqueeIncrement());
     3301        state.style->setMarqueeSpeed(state.parentStyle->marqueeSpeed());
     3302        state.style->setMarqueeLoopCount(state.parentStyle->marqueeLoopCount());
     3303        state.style->setMarqueeBehavior(state.parentStyle->marqueeBehavior());
    33023304        return;
    33033305    case CSSPropertyWebkitMarqueeRepetition: {
     
    33063308            return;
    33073309        if (primitiveValue->getIdent() == CSSValueInfinite)
    3308             m_style->setMarqueeLoopCount(-1); // -1 means repeat forever.
     3310            state.style->setMarqueeLoopCount(-1); // -1 means repeat forever.
    33093311        else if (primitiveValue->isNumber())
    3310             m_style->setMarqueeLoopCount(primitiveValue->getIntValue());
     3312            state.style->setMarqueeLoopCount(primitiveValue->getIntValue());
    33113313        return;
    33123314    }
     
    33183320            switch (ident) {
    33193321            case CSSValueSlow:
    3320                 m_style->setMarqueeSpeed(500); // 500 msec.
     3322                state.style->setMarqueeSpeed(500); // 500 msec.
    33213323                break;
    33223324            case CSSValueNormal:
    3323                 m_style->setMarqueeSpeed(85); // 85msec. The WinIE default.
     3325                state.style->setMarqueeSpeed(85); // 85msec. The WinIE default.
    33243326                break;
    33253327            case CSSValueFast:
    3326                 m_style->setMarqueeSpeed(10); // 10msec. Super fast.
     3328                state.style->setMarqueeSpeed(10); // 10msec. Super fast.
    33273329                break;
    33283330            }
    33293331        } else if (primitiveValue->isTime())
    3330             m_style->setMarqueeSpeed(primitiveValue->computeTime<int, CSSPrimitiveValue::Milliseconds>());
     3332            state.style->setMarqueeSpeed(primitiveValue->computeTime<int, CSSPrimitiveValue::Milliseconds>());
    33313333        else if (primitiveValue->isNumber()) // For scrollamount support.
    3332             m_style->setMarqueeSpeed(primitiveValue->getIntValue());
     3334            state.style->setMarqueeSpeed(primitiveValue->getIntValue());
    33333335        return;
    33343336    }
     
    33403342            switch (primitiveValue->getIdent()) {
    33413343            case CSSValueSmall:
    3342                 m_style->setMarqueeIncrement(Length(1, Fixed)); // 1px.
     3344                state.style->setMarqueeIncrement(Length(1, Fixed)); // 1px.
    33433345                break;
    33443346            case CSSValueNormal:
    3345                 m_style->setMarqueeIncrement(Length(6, Fixed)); // 6px. The WinIE default.
     3347                state.style->setMarqueeIncrement(Length(6, Fixed)); // 6px. The WinIE default.
    33463348                break;
    33473349            case CSSValueLarge:
    3348                 m_style->setMarqueeIncrement(Length(36, Fixed)); // 36px.
     3350                state.style->setMarqueeIncrement(Length(36, Fixed)); // 36px.
    33493351                break;
    33503352            }
    33513353        } else {
    3352             Length marqueeLength = convertToIntLength(primitiveValue, style(), m_rootElementStyle);
     3354            Length marqueeLength = convertToIntLength(primitiveValue, state.style.get(), state.rootElementStyle);
    33533355            if (!marqueeLength.isUndefined())
    3354                 m_style->setMarqueeIncrement(marqueeLength);
     3356                state.style->setMarqueeIncrement(marqueeLength);
    33553357        }
    33563358        return;
     
    33613363            return;
    33623364        if (primitiveValue->getIdent() == CSSValueAuto)
    3363             m_style->setLocale(nullAtom);
     3365            state.style->setLocale(nullAtom);
    33643366        else
    3365             m_style->setLocale(primitiveValue->getStringValue());
    3366         FontDescription fontDescription = m_style->fontDescription();
    3367         fontDescription.setScript(localeToScriptCodeForFontSelection(m_style->locale()));
     3367            state.style->setLocale(primitiveValue->getStringValue());
     3368        FontDescription fontDescription = state.style->fontDescription();
     3369        fontDescription.setScript(localeToScriptCodeForFontSelection(state.style->locale()));
    33683370        setFontDescription(fontDescription);
    33693371        return;
     
    33843386
    33853387        if (primitiveValue->getIdent() == CSSValueNone) {
    3386             m_style->setDashboardRegions(RenderStyle::noneDashboardRegions());
     3388            state.style->setDashboardRegions(RenderStyle::noneDashboardRegions());
    33873389            return;
    33883390        }
     
    33943396        DashboardRegion* first = region;
    33953397        while (region) {
    3396             Length top = convertToIntLength(region->top(), style(), m_rootElementStyle);
    3397             Length right = convertToIntLength(region->right(), style(), m_rootElementStyle);
    3398             Length bottom = convertToIntLength(region->bottom(), style(), m_rootElementStyle);
    3399             Length left = convertToIntLength(region->left(), style(), m_rootElementStyle);
     3398            Length top = convertToIntLength(region->top(), state.style.get(), state.rootElementStyle);
     3399            Length right = convertToIntLength(region->right(), state.style.get(), state.rootElementStyle);
     3400            Length bottom = convertToIntLength(region->bottom(), state.style.get(), state.rootElementStyle);
     3401            Length left = convertToIntLength(region->left(), state.style.get(), state.rootElementStyle);
    34003402
    34013403            if (top.isUndefined())
     
    34093411
    34103412            if (region->m_isCircle)
    3411                 m_style->setDashboardRegion(StyleDashboardRegion::Circle, region->m_label, top, right, bottom, left, region == first ? false : true);
     3413                state.style->setDashboardRegion(StyleDashboardRegion::Circle, region->m_label, top, right, bottom, left, region == first ? false : true);
    34123414            else if (region->m_isRectangle)
    3413                 m_style->setDashboardRegion(StyleDashboardRegion::Rectangle, region->m_label, top, right, bottom, left, region == first ? false : true);
     3415                state.style->setDashboardRegion(StyleDashboardRegion::Rectangle, region->m_label, top, right, bottom, left, region == first ? false : true);
    34143416            region = region->m_next.get();
    34153417        }
    34163418
    3417         m_element->document()->setHasAnnotatedRegions(true);
     3419        state.element->document()->setHasAnnotatedRegions(true);
    34183420
    34193421        return;
     
    34243426        if (!primitiveValue || !primitiveValue->getIdent())
    34253427            return;
    3426         m_style->setDraggableRegionMode(primitiveValue->getIdent() == CSSValueDrag ? DraggableRegionDrag : DraggableRegionNoDrag);
    3427         m_element->document()->setHasAnnotatedRegions(true);
     3428        state.style->setDraggableRegionMode(primitiveValue->getIdent() == CSSValueDrag ? DraggableRegionDrag : DraggableRegionNoDrag);
     3429        state.element->document()->setHasAnnotatedRegions(true);
    34283430        return;
    34293431    }
     
    34413443            else if (primitiveValue->getIdent() == CSSValueThick)
    34423444                result *= 5;
    3443             width = CSSPrimitiveValue::create(result, CSSPrimitiveValue::CSS_EMS)->computeLength<float>(style(), m_rootElementStyle, zoomFactor);
     3445            width = CSSPrimitiveValue::create(result, CSSPrimitiveValue::CSS_EMS)->computeLength<float>(state.style.get(), state.rootElementStyle, zoomFactor);
    34443446            break;
    34453447        }
    34463448        default:
    3447             width = primitiveValue->computeLength<float>(style(), m_rootElementStyle, zoomFactor);
     3449            width = primitiveValue->computeLength<float>(state.style.get(), state.rootElementStyle, zoomFactor);
    34483450            break;
    34493451        }
    3450         m_style->setTextStrokeWidth(width);
     3452        state.style->setTextStrokeWidth(width);
    34513453        return;
    34523454    }
     
    34543456        HANDLE_INHERIT_AND_INITIAL(transform, Transform);
    34553457        TransformOperations operations;
    3456         createTransformOperations(value, style(), m_rootElementStyle, operations);
    3457         m_style->setTransform(operations);
     3458        createTransformOperations(value, state.style.get(), state.rootElementStyle, operations);
     3459        state.style->setTransform(operations);
    34583460        return;
    34593461    }
     
    34653467
    34663468        if (primitiveValue->getIdent() == CSSValueNone) {
    3467             m_style->setPerspective(0);
     3469            state.style->setPerspective(0);
    34683470            return;
    34693471        }
     
    34713473        float perspectiveValue;
    34723474        if (primitiveValue->isLength())
    3473             perspectiveValue = primitiveValue->computeLength<float>(style(), m_rootElementStyle, zoomFactor);
     3475            perspectiveValue = primitiveValue->computeLength<float>(state.style.get(), state.rootElementStyle, zoomFactor);
    34743476        else if (primitiveValue->isNumber()) {
    34753477            // For backward compatibility, treat valueless numbers as px.
    3476             perspectiveValue = CSSPrimitiveValue::create(primitiveValue->getDoubleValue(), CSSPrimitiveValue::CSS_PX)->computeLength<float>(style(), m_rootElementStyle, zoomFactor);
     3478            perspectiveValue = CSSPrimitiveValue::create(primitiveValue->getDoubleValue(), CSSPrimitiveValue::CSS_PX)->computeLength<float>(state.style.get(), state.rootElementStyle, zoomFactor);
    34773479        } else
    34783480            return;
    34793481
    34803482        if (perspectiveValue >= 0.0f)
    3481             m_style->setPerspective(perspectiveValue);
     3483            state.style->setPerspective(perspectiveValue);
    34823484        return;
    34833485    }
    34843486    case CSSPropertyWebkitAnimation:
    34853487        if (isInitial)
    3486             m_style->clearAnimations();
     3488            state.style->clearAnimations();
    34873489        else if (isInherit)
    3488             m_style->inheritAnimations(m_parentStyle->animations());
     3490            state.style->inheritAnimations(state.parentStyle->animations());
    34893491        return;
    34903492    case CSSPropertyWebkitTransition:
    34913493        if (isInitial)
    3492             m_style->clearTransitions();
     3494            state.style->clearTransitions();
    34933495        else if (isInherit)
    3494             m_style->inheritTransitions(m_parentStyle->transitions());
     3496            state.style->inheritTransitions(state.parentStyle->transitions());
    34953497        return;
    34963498#if ENABLE(TOUCH_EVENTS)
     
    35013503
    35023504        Color col = colorFromPrimitiveValue(primitiveValue);
    3503         m_style->setTapHighlightColor(col);
     3505        state.style->setTapHighlightColor(col);
    35043506        return;
    35053507    }
     
    35103512        if (!primitiveValue)
    35113513            break;
    3512         m_style->setUseTouchOverflowScrolling(primitiveValue->getIdent() == CSSValueTouch);
     3514        state.style->setUseTouchOverflowScrolling(primitiveValue->getIdent() == CSSValueTouch);
    35133515        return;
    35143516    }
     
    35533555    case CSSPropertyWebkitMaxLogicalHeight:
    35543556    {
    3555         CSSPropertyID newId = CSSProperty::resolveDirectionAwareProperty(id, m_style->direction(), m_style->writingMode());
     3557        CSSPropertyID newId = CSSProperty::resolveDirectionAwareProperty(id, state.style->direction(), state.style->writingMode());
    35563558        ASSERT(newId != id);
    35573559        return applyProperty(newId, value);
     
    35883590
    35893591        // FIXME: It is not ok to modify document state while applying style.
    3590         if (m_element && m_element == m_element->document()->documentElement())
    3591             m_element->document()->setWritingModeSetOnDocumentElement(true);
    3592 
     3592        if (state.element && state.element == state.element->document()->documentElement())
     3593            state.element->document()->setWritingModeSetOnDocumentElement(true);
    35933594        return;
    35943595    }
     
    36063607        HANDLE_INHERIT_AND_INITIAL(lineBoxContain, LineBoxContain)
    36073608        if (primitiveValue && primitiveValue->getIdent() == CSSValueNone) {
    3608             m_style->setLineBoxContain(LineBoxContainNone);
     3609            state.style->setLineBoxContain(LineBoxContainNone);
    36093610            return;
    36103611        }
     
    36143615
    36153616        CSSLineBoxContainValue* lineBoxContainValue = static_cast<CSSLineBoxContainValue*>(value);
    3616         m_style->setLineBoxContain(lineBoxContainValue->value());
     3617        state.style->setLineBoxContain(lineBoxContainValue->value());
    36173618        return;
    36183619    }
     
    36213622    case CSSPropertyWebkitFontFeatureSettings: {
    36223623        if (primitiveValue && primitiveValue->getIdent() == CSSValueNormal) {
    3623             setFontDescription(m_style->fontDescription().makeNormalFeatureSettings());
     3624            setFontDescription(state.style->fontDescription().makeNormalFeatureSettings());
    36243625            return;
    36253626        }
     
    36283629            return;
    36293630
    3630         FontDescription fontDescription = m_style->fontDescription();
     3631        FontDescription fontDescription = state.style->fontDescription();
    36313632        CSSValueList* list = static_cast<CSSValueList*>(value);
    36323633        RefPtr<FontFeatureSettings> settings = FontFeatureSettings::create();
     
    36483649        HANDLE_INHERIT_AND_INITIAL(filter, Filter);
    36493650        FilterOperations operations;
    3650         if (createFilterOperations(value, style(), m_rootElementStyle, operations))
    3651             m_style->setFilter(operations);
     3651        if (createFilterOperations(value, state.style.get(), state.rootElementStyle, operations))
     3652            state.style->setFilter(operations);
    36523653        return;
    36533654    }
     
    36553656    case CSSPropertyWebkitGridColumns: {
    36563657        Vector<GridTrackSize> trackSizes;
    3657         if (!createGridTrackList(value, trackSizes, this))
     3658        if (!createGridTrackList(value, trackSizes, state))
    36583659            return;
    3659         m_style->setGridColumns(trackSizes);
     3660        state.style->setGridColumns(trackSizes);
    36603661        return;
    36613662    }
    36623663    case CSSPropertyWebkitGridRows: {
    36633664        Vector<GridTrackSize> trackSizes;
    3664         if (!createGridTrackList(value, trackSizes, this))
     3665        if (!createGridTrackList(value, trackSizes, state))
    36653666            return;
    3666         m_style->setGridRows(trackSizes);
     3667        state.style->setGridRows(trackSizes);
    36673668        return;
    36683669    }
     
    36723673        if (!createGridPosition(value, column))
    36733674            return;
    3674         m_style->setGridItemColumn(column);
     3675        state.style->setGridItemColumn(column);
    36753676        return;
    36763677    }
     
    36793680        if (!createGridPosition(value, row))
    36803681            return;
    3681         m_style->setGridItemRow(row);
     3682        state.style->setGridItemRow(row);
    36823683        return;
    36833684    }
     
    40014002    RefPtr<StyleImage> image = value->cachedOrPendingImage();
    40024003    if (image && image->isPendingImage())
    4003         m_pendingImageProperties.set(property, value);
     4004        m_state.pendingImageProperties.set(property, value);
    40044005    return image.release();
    40054006}
     
    40084009{
    40094010    if (value->isPending()) {
    4010         m_pendingImageProperties.set(property, value);
     4011        m_state.pendingImageProperties.set(property, value);
    40114012        return StylePendingImage::create(value);
    40124013    }
     
    40194020    RefPtr<StyleImage> image = value->cachedOrPendingImageSet(document());
    40204021    if (image && image->isPendingImage())
    4021         m_pendingImageProperties.set(property, value);
     4022        m_state.pendingImageProperties.set(property, value);
    40224023    return image.release();
    40234024}
     
    40284029    RefPtr<StyleImage> image = value->cachedOrPendingImage(document());
    40294030    if (image && image->isPendingImage())
    4030         m_pendingImageProperties.set(property, value);
     4031        m_state.pendingImageProperties.set(property, value);
    40314032    return image.release();
    40324033}
     
    40344035void StyleResolver::checkForTextSizeAdjust()
    40354036{
    4036     if (m_style->textSizeAdjust())
    4037         return;
    4038 
    4039     FontDescription newFontDescription(m_style->fontDescription());
     4037    RenderStyle* style = m_state.style.get();
     4038
     4039    if (style->textSizeAdjust())
     4040        return;
     4041
     4042    FontDescription newFontDescription(style->fontDescription());
    40404043    newFontDescription.setComputedSize(newFontDescription.specifiedSize());
    4041     m_style->setFontDescription(newFontDescription);
     4044    style->setFontDescription(newFontDescription);
    40424045}
    40434046
     
    41044107    fontDescription.setKeywordSize(CSSValueMedium - CSSValueXxSmall + 1);
    41054108    setFontSize(fontDescription, fontSizeForKeyword(document(), CSSValueMedium, false));
    4106     m_style->setLineHeight(RenderStyle::initialLineHeight());
    4107     m_lineHeightValue = 0;
     4109    m_state.style->setLineHeight(RenderStyle::initialLineHeight());
     4110    m_state.lineHeightValue = 0;
    41084111    setFontDescription(fontDescription);
    41094112}
     
    41124115{
    41134116    fontDescription.setSpecifiedSize(size);
    4114     fontDescription.setComputedSize(getComputedSizeFromSpecifiedSize(document(), m_style.get(), fontDescription.isAbsoluteSize(), size, useSVGZoomRules()));
     4117    fontDescription.setComputedSize(getComputedSizeFromSpecifiedSize(document(), m_state.style.get(), fontDescription.isAbsoluteSize(), size, useSVGZoomRules()));
    41154118}
    41164119
     
    43154318        return Color(value->getRGBA32Value());
    43164319
     4320    const State& state = m_state;
    43174321    int ident = value->getIdent();
    43184322    switch (ident) {
     
    43204324        return Color();
    43214325    case CSSValueWebkitText:
    4322         return m_element->document()->textColor();
     4326        return state.element->document()->textColor();
    43234327    case CSSValueWebkitLink:
    4324         return (m_element->isLink() && forVisitedLink) ? m_element->document()->visitedLinkColor() : m_element->document()->linkColor();
     4328        return (state.element->isLink() && forVisitedLink) ? state.element->document()->visitedLinkColor() : state.element->document()->linkColor();
    43254329    case CSSValueWebkitActivelink:
    4326         return m_element->document()->activeLinkColor();
     4330        return state.element->document()->activeLinkColor();
    43274331    case CSSValueWebkitFocusRingColor:
    43284332        return RenderTheme::focusRingColor();
    43294333    case CSSValueCurrentcolor:
    4330         return m_style->color();
     4334        return state.style->color();
    43314335    default:
    43324336        return colorForCSSValue(ident);
     
    46624666void StyleResolver::loadPendingSVGDocuments()
    46634667{
    4664     if (!m_style->hasFilter() || m_pendingSVGDocuments.isEmpty())
    4665         return;
    4666 
    4667     CachedResourceLoader* cachedResourceLoader = m_element->document()->cachedResourceLoader();
    4668     Vector<RefPtr<FilterOperation> >& filterOperations = m_style->mutableFilter().operations();
     4668    State& state = m_state;
     4669    if (!state.style->hasFilter() || state.pendingSVGDocuments.isEmpty())
     4670        return;
     4671
     4672    CachedResourceLoader* cachedResourceLoader = state.element->document()->cachedResourceLoader();
     4673    Vector<RefPtr<FilterOperation> >& filterOperations = state.style->mutableFilter().operations();
    46694674    for (unsigned i = 0; i < filterOperations.size(); ++i) {
    46704675        RefPtr<FilterOperation> filterOperation = filterOperations.at(i);
     
    46724677            ReferenceFilterOperation* referenceFilter = static_cast<ReferenceFilterOperation*>(filterOperation.get());
    46734678
    4674             WebKitCSSSVGDocumentValue* value = m_pendingSVGDocuments.get(referenceFilter).get();
     4679            WebKitCSSSVGDocumentValue* value = state.pendingSVGDocuments.get(referenceFilter).get();
    46754680            if (!value)
    46764681                continue;
     
    46834688        }
    46844689    }
    4685     m_pendingSVGDocuments.clear();
     4690    state.pendingSVGDocuments.clear();
    46864691}
    46874692#endif
     
    46994704    StyleShader* shader = value->cachedOrPendingShader();
    47004705    if (shader && shader->isPendingShader())
    4701         m_hasPendingShaders = true;
     4706        m_state.hasPendingShaders = true;
    47024707    return shader;
    47034708}
     
    47054710void StyleResolver::loadPendingShaders()
    47064711{
    4707     if (!m_style->hasFilter() || !m_hasPendingShaders)
    4708         return;
    4709 
    4710     CachedResourceLoader* cachedResourceLoader = m_element->document()->cachedResourceLoader();
    4711 
    4712     Vector<RefPtr<FilterOperation> >& filterOperations = m_style->mutableFilter().operations();
     4712    if (!m_state.style->hasFilter() || !m_state.hasPendingShaders)
     4713        return;
     4714
     4715    CachedResourceLoader* cachedResourceLoader = m_state.element->document()->cachedResourceLoader();
     4716
     4717    Vector<RefPtr<FilterOperation> >& filterOperations = m_state.style->mutableFilter().operations();
    47134718    for (unsigned i = 0; i < filterOperations.size(); ++i) {
    47144719        RefPtr<FilterOperation> filterOperation = filterOperations.at(i);
     
    47274732        }
    47284733    }
    4729     m_hasPendingShaders = false;
     4734    m_state.hasPendingShaders = false;
    47304735}
    47314736
     
    47694774    RefPtr<CustomFilterTransformParameter> transformParameter = CustomFilterTransformParameter::create(name);
    47704775    TransformOperations operations;
    4771     createTransformOperations(values, style(), m_rootElementStyle, operations);
     4776    createTransformOperations(values, m_state.style.get(), m_state.rootElementStyle, operations);
    47724777    transformParameter->setOperations(operations);
    47734778    return transformParameter.release();
     
    50195024
    50205025            WebKitCSSSVGDocumentValue* svgDocumentValue = static_cast<WebKitCSSSVGDocumentValue*>(argument);
    5021             KURL url = m_element->document()->completeURL(svgDocumentValue->url());
     5026            KURL url = m_state.element->document()->completeURL(svgDocumentValue->url());
    50225027
    50235028            RefPtr<ReferenceFilterOperation> operation = ReferenceFilterOperation::create(svgDocumentValue->url(), url.fragmentIdentifier(), operationType);
    5024             if (SVGURIReference::isExternalURIReference(svgDocumentValue->url(), m_element->document())) {
     5029            if (SVGURIReference::isExternalURIReference(svgDocumentValue->url(), m_state.element->document())) {
    50255030                if (!svgDocumentValue->loadRequested())
    5026                     m_pendingSVGDocuments.set(operation.get(), svgDocumentValue);
     5031                    m_state.pendingSVGDocuments.set(operation.get(), svgDocumentValue);
    50275032                else if (svgDocumentValue->cachedSVGDocument())
    50285033                    operation->setCachedSVGDocumentReference(adoptPtr(new CachedSVGDocumentReference(svgDocumentValue->cachedSVGDocument())));
     
    51285133PassRefPtr<StyleImage> StyleResolver::loadPendingImage(StylePendingImage* pendingImage)
    51295134{
    5130     CachedResourceLoader* cachedResourceLoader = m_element->document()->cachedResourceLoader();
     5135    CachedResourceLoader* cachedResourceLoader = m_state.element->document()->cachedResourceLoader();
    51315136
    51325137    if (pendingImage->cssImageValue()) {
     
    51585163void StyleResolver::loadPendingImages()
    51595164{
    5160     if (m_pendingImageProperties.isEmpty())
    5161         return;
    5162 
    5163     PendingImagePropertyMap::const_iterator::Keys end = m_pendingImageProperties.end().keys();
    5164     for (PendingImagePropertyMap::const_iterator::Keys it = m_pendingImageProperties.begin().keys(); it != end; ++it) {
     5165    if (m_state.pendingImageProperties.isEmpty())
     5166        return;
     5167
     5168    PendingImagePropertyMap::const_iterator::Keys end = m_state.pendingImageProperties.end().keys();
     5169    for (PendingImagePropertyMap::const_iterator::Keys it = m_state.pendingImageProperties.begin().keys(); it != end; ++it) {
    51655170        CSSPropertyID currentProperty = *it;
    51665171
    51675172        switch (currentProperty) {
    51685173        case CSSPropertyBackgroundImage: {
    5169             for (FillLayer* backgroundLayer = m_style->accessBackgroundLayers(); backgroundLayer; backgroundLayer = backgroundLayer->next()) {
     5174            for (FillLayer* backgroundLayer = m_state.style->accessBackgroundLayers(); backgroundLayer; backgroundLayer = backgroundLayer->next()) {
    51705175                if (backgroundLayer->image() && backgroundLayer->image()->isPendingImage())
    51715176                    backgroundLayer->setImage(loadPendingImage(static_cast<StylePendingImage*>(backgroundLayer->image())));
     
    51745179        }
    51755180        case CSSPropertyContent: {
    5176             for (ContentData* contentData = const_cast<ContentData*>(m_style->contentData()); contentData; contentData = contentData->next()) {
     5181            for (ContentData* contentData = const_cast<ContentData*>(m_state.style->contentData()); contentData; contentData = contentData->next()) {
    51775182                if (contentData->isImage()) {
    51785183                    StyleImage* image = static_cast<ImageContentData*>(contentData)->image();
     
    51875192        }
    51885193        case CSSPropertyCursor: {
    5189             if (CursorList* cursorList = m_style->cursors()) {
     5194            if (CursorList* cursorList = m_state.style->cursors()) {
    51905195                for (size_t i = 0; i < cursorList->size(); ++i) {
    51915196                    CursorData& currentCursor = cursorList->at(i);
     
    51995204        }
    52005205        case CSSPropertyListStyleImage: {
    5201             if (m_style->listStyleImage() && m_style->listStyleImage()->isPendingImage())
    5202                 m_style->setListStyleImage(loadPendingImage(static_cast<StylePendingImage*>(m_style->listStyleImage())));
     5206            if (m_state.style->listStyleImage() && m_state.style->listStyleImage()->isPendingImage())
     5207                m_state.style->setListStyleImage(loadPendingImage(static_cast<StylePendingImage*>(m_state.style->listStyleImage())));
    52035208            break;
    52045209        }
    52055210        case CSSPropertyBorderImageSource: {
    5206             if (m_style->borderImageSource() && m_style->borderImageSource()->isPendingImage())
    5207                 m_style->setBorderImageSource(loadPendingImage(static_cast<StylePendingImage*>(m_style->borderImageSource())));
     5211            if (m_state.style->borderImageSource() && m_state.style->borderImageSource()->isPendingImage())
     5212                m_state.style->setBorderImageSource(loadPendingImage(static_cast<StylePendingImage*>(m_state.style->borderImageSource())));
    52085213            break;
    52095214        }
    52105215        case CSSPropertyWebkitBoxReflect: {
    5211             if (StyleReflection* reflection = m_style->boxReflect()) {
     5216            if (StyleReflection* reflection = m_state.style->boxReflect()) {
    52125217                const NinePieceImage& maskImage = reflection->mask();
    52135218                if (maskImage.image() && maskImage.image()->isPendingImage()) {
     
    52195224        }
    52205225        case CSSPropertyWebkitMaskBoxImageSource: {
    5221             if (m_style->maskBoxImageSource() && m_style->maskBoxImageSource()->isPendingImage())
    5222                 m_style->setMaskBoxImageSource(loadPendingImage(static_cast<StylePendingImage*>(m_style->maskBoxImageSource())));
     5226            if (m_state.style->maskBoxImageSource() && m_state.style->maskBoxImageSource()->isPendingImage())
     5227                m_state.style->setMaskBoxImageSource(loadPendingImage(static_cast<StylePendingImage*>(m_state.style->maskBoxImageSource())));
    52235228            break;
    52245229        }
    52255230        case CSSPropertyWebkitMaskImage: {
    5226             for (FillLayer* maskLayer = m_style->accessMaskLayers(); maskLayer; maskLayer = maskLayer->next()) {
     5231            for (FillLayer* maskLayer = m_state.style->accessMaskLayers(); maskLayer; maskLayer = maskLayer->next()) {
    52275232                if (maskLayer->image() && maskLayer->image()->isPendingImage())
    52285233                    maskLayer->setImage(loadPendingImage(static_cast<StylePendingImage*>(maskLayer->image())));
     
    52355240    }
    52365241
    5237     m_pendingImageProperties.clear();
     5242    m_state.pendingImageProperties.clear();
    52385243}
    52395244
     
    52985303{
    52995304    MemoryClassInfo info(memoryObjectInfo, this, WebCoreMemoryTypes::CSS);
    5300     info.addMember(m_style, "style");
    53015305    info.addMember(m_authorStyle, "authorStyle");
    53025306    info.addMember(m_userStyle, "userStyle");
     
    53075311    info.addMember(m_matchedPropertiesCache, "matchedPropertiesCache");
    53085312    info.addMember(m_matchedPropertiesCacheSweepTimer, "matchedPropertiesCacheSweepTimer");
    5309     info.addMember(m_matchedRules, "matchedRules");
    5310 
    5311     info.addMember(m_ruleList, "ruleList");
    5312     info.addMember(m_pendingImageProperties, "pendingImageProperties");
     5313
    53135314    info.addMember(m_medium, "medium");
    53145315    info.addMember(m_rootDefaultStyle, "rootDefaultStyle");
    53155316    info.addMember(m_document, "document");
    53165317
    5317     // FIXME: pointer to RenderStyle could point to an already deleted object.
    5318     info.ignoreMember(m_parentStyle);
    5319     info.ignoreMember(m_rootElementStyle);
    5320 
    5321     info.addMember(m_element, "element");
    5322     info.addMember(m_styledElement, "styledElement");
    5323     info.addMember(m_regionForStyling, "regionForStyling");
    5324     info.addMember(m_parentNode, "parentNode");
    5325     info.addMember(m_lineHeightValue, "lineHeightValue");
    53265318    info.addMember(m_fontSelector, "fontSelector");
    53275319    info.addMember(m_viewportDependentMediaQueryResults, "viewportDependentMediaQueryResults");
    53285320    info.ignoreMember(m_styleBuilder);
    53295321    info.addMember(m_inspectorCSSOMWrappers);
    5330 #if ENABLE(CSS_FILTERS) && ENABLE(SVG)
    5331     info.addMember(m_pendingSVGDocuments, "pendingSVGDocuments");
    5332 #endif
    53335322    info.addMember(m_scopeResolver, "scopeResolver");
     5323
     5324    info.addMember(m_state, "state");
    53345325
    53355326    // FIXME: move this to a place where it would be called only once?
  • trunk/Source/WebCore/css/StyleResolver.h

    r141480 r141742  
    2424
    2525#include "CSSRule.h"
     26#include "CSSRuleList.h"
    2627#include "CSSToStyleMap.h"
    2728#include "CSSValueList.h"
     
    3738#include "StyleScopeResolver.h"
    3839#include "ViewportStyleResolver.h"
     40#if ENABLE(CSS_FILTERS) && ENABLE(SVG)
     41#include "WebKitCSSSVGDocumentValue.h"
     42#endif
    3943#include <wtf/HashMap.h>
    4044#include <wtf/HashSet.h>
     
    183187    static PassRefPtr<RenderStyle> styleForDocument(Document*, CSSFontSelector* = 0);
    184188
    185     RenderStyle* style() const { return m_style.get(); }
    186     RenderStyle* parentStyle() const { return m_parentStyle; }
    187     RenderStyle* rootElementStyle() const { return m_rootElementStyle; }
    188     Element* element() const { return m_element; }
     189    RenderStyle* style() const { return m_state.style.get(); }
     190    RenderStyle* parentStyle() const { return m_state.parentStyle; }
     191    RenderStyle* rootElementStyle() const { return m_state.rootElementStyle; }
     192    Element* element() const { return m_state.element; }
    189193    Document* document() const { return m_document; }
    190194    const FontDescription& fontDescription() { return style()->fontDescription(); }
    191195    const FontDescription& parentFontDescription() { return parentStyle()->fontDescription(); }
    192     void setFontDescription(const FontDescription& fontDescription) { m_fontDirty |= style()->setFontDescription(fontDescription); }
    193     void setZoom(float f) { m_fontDirty |= style()->setZoom(f); }
    194     void setEffectiveZoom(float f) { m_fontDirty |= style()->setEffectiveZoom(f); }
    195     void setTextSizeAdjust(bool b) { m_fontDirty |= style()->setTextSizeAdjust(b); }
    196     void setWritingMode(WritingMode writingMode) { m_fontDirty |= style()->setWritingMode(writingMode); }
    197     void setTextOrientation(TextOrientation textOrientation) { m_fontDirty |= style()->setTextOrientation(textOrientation); }
    198     bool hasParentNode() const { return m_parentNode; }
     196    void setFontDescription(const FontDescription& fontDescription) { m_state.fontDirty |= style()->setFontDescription(fontDescription); }
     197    void setZoom(float f) { m_state.fontDirty |= style()->setZoom(f); }
     198    void setEffectiveZoom(float f) { m_state.fontDirty |= style()->setEffectiveZoom(f); }
     199    void setTextSizeAdjust(bool b) { m_state.fontDirty |= style()->setTextSizeAdjust(b); }
     200    void setWritingMode(WritingMode writingMode) { m_state.fontDirty |= style()->setWritingMode(writingMode); }
     201    void setTextOrientation(TextOrientation textOrientation) { m_state.fontDirty |= style()->setTextOrientation(textOrientation); }
     202    bool hasParentNode() const { return m_state.parentNode; }
    199203
    200204    void resetAuthorStyle();
     
    328332    void adjustRenderStyle(RenderStyle* styleToAdjust, RenderStyle* parentStyle, Element*);
    329333
    330     void addMatchedRule(const RuleData* rule) { m_matchedRules.append(rule); }
     334    void addMatchedRule(const RuleData* rule) { m_state.matchedRules.append(rule); }
    331335
    332336    struct RuleRange {
     
    438442    OwnPtr<RuleSet> m_uncommonAttributeRuleSet;
    439443
    440     bool m_hasUAAppearance;
    441     BorderData m_borderData;
    442     FillLayer m_backgroundData;
    443     Color m_backgroundColor;
    444 
    445444    typedef HashMap<AtomicStringImpl*, RefPtr<StyleRuleKeyframes> > KeyframesRuleMap;
    446445    KeyframesRuleMap m_keyframesRuleMap;
    447446
    448447public:
     448    typedef HashMap<CSSPropertyID, RefPtr<CSSValue> > PendingImagePropertyMap;
     449#if ENABLE(CSS_FILTERS) && ENABLE(SVG)
     450    typedef HashMap<FilterOperation*, RefPtr<WebKitCSSSVGDocumentValue> > PendingSVGDocumentMap;
     451#endif
     452
     453    class State {
     454        WTF_MAKE_NONCOPYABLE(State);
     455    public:
     456        State()
     457        : element(0)
     458        , styledElement(0)
     459        , parentNode(0)
     460        , parentStyle(0)
     461        , rootElementStyle(0)
     462        , regionForStyling(0)
     463        , sameOriginOnly(false)
     464        , pseudoStyle(NOPSEUDO)
     465        , elementLinkState(NotInsideLink)
     466        , distributedToInsertionPoint(false)
     467        , elementAffectedByClassRules(false)
     468        , applyPropertyToRegularStyle(true)
     469        , applyPropertyToVisitedLinkStyle(false)
     470#if ENABLE(CSS_SHADERS)
     471        , hasPendingShaders(false)
     472#endif
     473        , lineHeightValue(0)
     474        , fontDirty(false)
     475        , hasUAAppearance(false)
     476        , backgroundData(BackgroundFillLayer) { }
     477       
     478public:
     479        // FIXME(bug 108563): to make it easier to review, these member
     480        // variables are public. However we should add methods to access
     481        // these variables.
     482        Element* element;
     483        RefPtr<RenderStyle> style;
     484        StyledElement* styledElement;
     485        ContainerNode* parentNode;
     486        RenderStyle* parentStyle;
     487        RenderStyle* rootElementStyle;
     488       
     489        RenderRegion* regionForStyling;
     490        bool sameOriginOnly;
     491        PseudoId pseudoStyle;
     492
     493        EInsideLink elementLinkState;
     494
     495        bool distributedToInsertionPoint;
     496
     497        bool elementAffectedByClassRules;
     498
     499        PseudoId dynamicPseudo;
     500
     501        // A buffer used to hold the set of matched rules for an element,
     502        // and a temporary buffer used for merge sorting.
     503        Vector<const RuleData*, 32> matchedRules;
     504        RefPtr<StaticCSSRuleList> ruleList;
     505
     506        bool applyPropertyToRegularStyle;
     507        bool applyPropertyToVisitedLinkStyle;
     508
     509        PendingImagePropertyMap pendingImageProperties;
     510#if ENABLE(CSS_SHADERS)
     511        bool hasPendingShaders;
     512#endif
     513#if ENABLE(CSS_FILTERS) && ENABLE(SVG)
     514        PendingSVGDocumentMap pendingSVGDocuments;
     515#endif
     516        CSSValue* lineHeightValue;
     517        bool fontDirty;
     518
     519        bool hasUAAppearance;
     520        BorderData borderData;
     521        FillLayer backgroundData;
     522        Color backgroundColor;
     523    };
     524
    449525    static RenderStyle* styleNotYetAvailable() { return s_styleNotYetAvailable; }
    450526
     
    457533    PassRefPtr<StyleImage> cursorOrPendingFromValue(CSSPropertyID, CSSCursorImageValue*);
    458534
    459     bool applyPropertyToRegularStyle() const { return m_applyPropertyToRegularStyle; }
    460     bool applyPropertyToVisitedLinkStyle() const { return m_applyPropertyToVisitedLinkStyle; }
     535    bool applyPropertyToRegularStyle() const { return m_state.applyPropertyToRegularStyle; }
     536    bool applyPropertyToVisitedLinkStyle() const { return m_state.applyPropertyToVisitedLinkStyle; }
    461537
    462538    static Length convertToIntLength(CSSPrimitiveValue*, RenderStyle*, RenderStyle* rootStyle, double multiplier = 1);
     
    512588    Timer<StyleResolver> m_matchedPropertiesCacheSweepTimer;
    513589
    514     // A buffer used to hold the set of matched rules for an element, and a temporary buffer used for
    515     // merge sorting.
    516     Vector<const RuleData*, 32> m_matchedRules;
    517 
    518     RefPtr<StaticCSSRuleList> m_ruleList;
    519 
    520     typedef HashMap<CSSPropertyID, RefPtr<CSSValue> > PendingImagePropertyMap;
    521     PendingImagePropertyMap m_pendingImageProperties;
    522 
    523590    OwnPtr<MediaQueryEvaluator> m_medium;
    524591    RefPtr<RenderStyle> m_rootDefaultStyle;
    525592
    526     PseudoId m_dynamicPseudo;
    527     PseudoId m_pseudoStyle;
    528 
    529593    Document* m_document;
     594    // FIXME: Make SelectorChecker an on-stack object and
     595    // move selectorChecker.mode() to State.
     596    // selectorChecker.stringParsing() can be replaced with
     597    // !document.inQuirksMode().
    530598    SelectorChecker m_selectorChecker;
    531599    SelectorFilter m_selectorFilter;
    532600
    533     RefPtr<RenderStyle> m_style;
    534     RenderStyle* m_parentStyle;
    535     RenderStyle* m_rootElementStyle;
    536     Element* m_element;
    537     StyledElement* m_styledElement;
    538     RenderRegion* m_regionForStyling;
    539     EInsideLink m_elementLinkState;
    540     bool m_elementAffectedByClassRules;
    541     ContainerNode* m_parentNode;
    542     CSSValue* m_lineHeightValue;
    543     bool m_fontDirty;
    544601    bool m_matchAuthorAndUserStyles;
    545     bool m_sameOriginOnly;
    546     bool m_distributedToInsertionPoint;
    547602
    548603    RefPtr<CSSFontSelector> m_fontSelector;
     
    553608#endif
    554609
    555     bool m_applyPropertyToRegularStyle;
    556     bool m_applyPropertyToVisitedLinkStyle;
    557610    const StyleBuilder& m_styleBuilder;
    558 
    559 #if ENABLE(CSS_SHADERS)
    560     bool m_hasPendingShaders;
    561 #endif
    562 
    563 #if ENABLE(CSS_FILTERS) && ENABLE(SVG)
    564     HashMap<FilterOperation*, RefPtr<WebKitCSSSVGDocumentValue> > m_pendingSVGDocuments;
    565 #endif
    566611
    567612    OwnPtr<StyleScopeResolver> m_scopeResolver;
    568613    CSSToStyleMap m_styleMap;
    569614    InspectorCSSOMWrappers m_inspectorCSSOMWrappers;
     615
     616    State m_state;
    570617
    571618    friend class StyleBuilder;
Note: See TracChangeset for help on using the changeset viewer.