WebKit Bugzilla
New
Browse
Search+
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
[patch]
WIP
bug-96421-20130130174147.patch (text/plain), 136.57 KB, created by
Takashi Sakamoto
on 2013-01-30 00:45:02 PST
(
hide
)
Description:
WIP
Filename:
MIME Type:
Creator:
Takashi Sakamoto
Created:
2013-01-30 00:45:02 PST
Size:
136.57 KB
patch
obsolete
>Subversion Revision: 141191 >diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog >index 89b8b01f3e9670515ab25754648ff96392a31e8d..cccdd05a13663acf51cf6b8ceb1e9ae9594860e3 100644 >--- a/Source/WebCore/ChangeLog >+++ b/Source/WebCore/ChangeLog >@@ -1,3 +1,98 @@ >+2013-01-30 Takashi Sakamoto <tasak@google.com> >+ >+ Split per-resolve logic out from StyleResolver. >+ https://bugs.webkit.org/show_bug.cgi?id=96421 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ Implemented class 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. >+ > 2013-01-29 Tim Horton <timothy_horton@apple.com> > > Don't updateTileCoverageMap() from setScrollingModeIndication if we don't need to. >diff --git a/Source/WebCore/css/SVGCSSStyleSelector.cpp b/Source/WebCore/css/SVGCSSStyleSelector.cpp >index 6145bb1f1625b8fe4d167607bbba8bfd9a1b0119..89c82a91a761f8d543555eedd1379dd27089c34b 100644 >--- a/Source/WebCore/css/SVGCSSStyleSelector.cpp >+++ b/Source/WebCore/css/SVGCSSStyleSelector.cpp >@@ -49,7 +49,7 @@ > #define HANDLE_INHERIT(prop, Prop) \ > if (isInherit) \ > { \ >- svgstyle->set##Prop(m_parentStyle->svgStyle()->prop()); \ >+ svgstyle->set##Prop(state.m_parentStyle->svgStyle()->prop()); \ > return; \ > } > >@@ -109,10 +109,11 @@ void StyleResolver::applySVGProperty(CSSPropertyID id, CSSValue* value) > if (value->isPrimitiveValue()) > primitiveValue = static_cast<CSSPrimitiveValue*>(value); > >- SVGRenderStyle* svgstyle = m_style->accessSVGStyle(); >+ const State& state = m_state; >+ SVGRenderStyle* svgstyle = state.m_style->accessSVGStyle(); > >- bool isInherit = m_parentNode && value->isInheritedValue(); >- bool isInitial = value->isInitialValue() || (!m_parentNode && value->isInheritedValue()); >+ bool isInherit = state.m_parentNode && value->isInheritedValue(); >+ bool isInitial = value->isInitialValue() || (!state.m_parentNode && value->isInheritedValue()); > > // What follows is a list that maps the CSS properties into their > // corresponding front-end RenderStyle values. Shorthands(e.g. border, >@@ -229,7 +230,7 @@ void StyleResolver::applySVGProperty(CSSPropertyID id, CSSValue* value) > case CSSPropertyFill: > { > if (isInherit) { >- const SVGRenderStyle* svgParentStyle = m_parentStyle->svgStyle(); >+ const SVGRenderStyle* svgParentStyle = state.m_parentStyle->svgStyle(); > svgstyle->setFillPaint(svgParentStyle->fillPaintType(), svgParentStyle->fillPaintColor(), svgParentStyle->fillPaintUri(), applyPropertyToRegularStyle(), applyPropertyToVisitedLinkStyle()); > return; > } >@@ -239,14 +240,14 @@ void StyleResolver::applySVGProperty(CSSPropertyID id, CSSValue* value) > } > if (value->isSVGPaint()) { > SVGPaint* svgPaint = static_cast<SVGPaint*>(value); >- svgstyle->setFillPaint(svgPaint->paintType(), colorFromSVGColorCSSValue(svgPaint, m_style->color()), svgPaint->uri(), applyPropertyToRegularStyle(), applyPropertyToVisitedLinkStyle()); >+ svgstyle->setFillPaint(svgPaint->paintType(), colorFromSVGColorCSSValue(svgPaint, state.m_style->color()), svgPaint->uri(), applyPropertyToRegularStyle(), applyPropertyToVisitedLinkStyle()); > } > break; > } > case CSSPropertyStroke: > { > if (isInherit) { >- const SVGRenderStyle* svgParentStyle = m_parentStyle->svgStyle(); >+ const SVGRenderStyle* svgParentStyle = state.m_parentStyle->svgStyle(); > svgstyle->setStrokePaint(svgParentStyle->strokePaintType(), svgParentStyle->strokePaintColor(), svgParentStyle->strokePaintUri(), applyPropertyToRegularStyle(), applyPropertyToVisitedLinkStyle()); > return; > } >@@ -256,7 +257,7 @@ void StyleResolver::applySVGProperty(CSSPropertyID id, CSSValue* value) > } > if (value->isSVGPaint()) { > SVGPaint* svgPaint = static_cast<SVGPaint*>(value); >- svgstyle->setStrokePaint(svgPaint->paintType(), colorFromSVGColorCSSValue(svgPaint, m_style->color()), svgPaint->uri(), applyPropertyToRegularStyle(), applyPropertyToVisitedLinkStyle()); >+ svgstyle->setStrokePaint(svgPaint->paintType(), colorFromSVGColorCSSValue(svgPaint, state.m_style->color()), svgPaint->uri(), applyPropertyToRegularStyle(), applyPropertyToVisitedLinkStyle()); > } > break; > } >@@ -363,7 +364,7 @@ void StyleResolver::applySVGProperty(CSSPropertyID id, CSSValue* value) > if (type == CSSPrimitiveValue::CSS_URI) > s = primitiveValue->getStringValue(); > >- svgstyle->setMarkerStartResource(SVGURIReference::fragmentIdentifierFromIRIString(s, m_element->document())); >+ svgstyle->setMarkerStartResource(SVGURIReference::fragmentIdentifierFromIRIString(s, state.m_element->document())); > break; > } > case CSSPropertyMarkerMid: >@@ -377,7 +378,7 @@ void StyleResolver::applySVGProperty(CSSPropertyID id, CSSValue* value) > if (type == CSSPrimitiveValue::CSS_URI) > s = primitiveValue->getStringValue(); > >- svgstyle->setMarkerMidResource(SVGURIReference::fragmentIdentifierFromIRIString(s, m_element->document())); >+ svgstyle->setMarkerMidResource(SVGURIReference::fragmentIdentifierFromIRIString(s, state.m_element->document())); > break; > } > case CSSPropertyMarkerEnd: >@@ -391,7 +392,7 @@ void StyleResolver::applySVGProperty(CSSPropertyID id, CSSValue* value) > if (type == CSSPrimitiveValue::CSS_URI) > s = primitiveValue->getStringValue(); > >- svgstyle->setMarkerEndResource(SVGURIReference::fragmentIdentifierFromIRIString(s, m_element->document())); >+ svgstyle->setMarkerEndResource(SVGURIReference::fragmentIdentifierFromIRIString(s, state.m_element->document())); > break; > } > case CSSPropertyStrokeLinecap: >@@ -428,7 +429,7 @@ void StyleResolver::applySVGProperty(CSSPropertyID id, CSSValue* value) > if (type == CSSPrimitiveValue::CSS_URI) > s = primitiveValue->getStringValue(); > >- svgstyle->setFilterResource(SVGURIReference::fragmentIdentifierFromIRIString(s, m_element->document())); >+ svgstyle->setFilterResource(SVGURIReference::fragmentIdentifierFromIRIString(s, state.m_element->document())); > break; > } > case CSSPropertyMask: >@@ -442,7 +443,7 @@ void StyleResolver::applySVGProperty(CSSPropertyID id, CSSValue* value) > if (type == CSSPrimitiveValue::CSS_URI) > s = primitiveValue->getStringValue(); > >- svgstyle->setMaskerResource(SVGURIReference::fragmentIdentifierFromIRIString(s, m_element->document())); >+ svgstyle->setMaskerResource(SVGURIReference::fragmentIdentifierFromIRIString(s, state.m_element->document())); > break; > } > case CSSPropertyClipPath: >@@ -456,7 +457,7 @@ void StyleResolver::applySVGProperty(CSSPropertyID id, CSSValue* value) > if (type == CSSPrimitiveValue::CSS_URI) > s = primitiveValue->getStringValue(); > >- svgstyle->setClipperResource(SVGURIReference::fragmentIdentifierFromIRIString(s, m_element->document())); >+ svgstyle->setClipperResource(SVGURIReference::fragmentIdentifierFromIRIString(s, state.m_element->document())); > break; > } > case CSSPropertyTextAnchor: >@@ -477,14 +478,14 @@ void StyleResolver::applySVGProperty(CSSPropertyID id, CSSValue* value) > { > HANDLE_INHERIT_AND_INITIAL(stopColor, StopColor); > if (value->isSVGColor()) >- svgstyle->setStopColor(colorFromSVGColorCSSValue(static_cast<SVGColor*>(value), m_style->color())); >+ svgstyle->setStopColor(colorFromSVGColorCSSValue(static_cast<SVGColor*>(value), state.m_style->color())); > break; > } > case CSSPropertyLightingColor: > { > HANDLE_INHERIT_AND_INITIAL(lightingColor, LightingColor); > if (value->isSVGColor()) >- svgstyle->setLightingColor(colorFromSVGColorCSSValue(static_cast<SVGColor*>(value), m_style->color())); >+ svgstyle->setLightingColor(colorFromSVGColorCSSValue(static_cast<SVGColor*>(value), state.m_style->color())); > break; > } > case CSSPropertyFloodOpacity: >@@ -509,7 +510,7 @@ void StyleResolver::applySVGProperty(CSSPropertyID id, CSSValue* value) > { > HANDLE_INHERIT_AND_INITIAL(floodColor, FloodColor); > if (value->isSVGColor()) >- svgstyle->setFloodColor(colorFromSVGColorCSSValue(static_cast<SVGColor*>(value), m_style->color())); >+ svgstyle->setFloodColor(colorFromSVGColorCSSValue(static_cast<SVGColor*>(value), state.m_style->color())); > break; > } > case CSSPropertyGlyphOrientationHorizontal: >@@ -549,7 +550,7 @@ void StyleResolver::applySVGProperty(CSSPropertyID id, CSSValue* value) > break; > case CSSPropertyWebkitSvgShadow: { > if (isInherit) >- return svgstyle->setShadow(adoptPtr(m_parentStyle->svgStyle()->shadow() ? new ShadowData(*m_parentStyle->svgStyle()->shadow()) : 0)); >+ return svgstyle->setShadow(adoptPtr(state.m_parentStyle->svgStyle()->shadow() ? new ShadowData(*state.m_parentStyle->svgStyle()->shadow()) : 0)); > if (isInitial || primitiveValue) // initial | none > return svgstyle->setShadow(nullptr); > >@@ -564,9 +565,9 @@ void StyleResolver::applySVGProperty(CSSPropertyID id, CSSValue* value) > if (!firstValue->isShadowValue()) > return; > ShadowValue* item = static_cast<ShadowValue*>(firstValue); >- IntPoint location(item->x->computeLength<int>(style(), m_rootElementStyle), >- item->y->computeLength<int>(style(), m_rootElementStyle)); >- int blur = item->blur ? item->blur->computeLength<int>(style(), m_rootElementStyle) : 0; >+ IntPoint location(item->x->computeLength<int>(state.m_style.get(), state.m_rootElementStyle), >+ item->y->computeLength<int>(state.m_style.get(), state.m_rootElementStyle)); >+ int blur = item->blur ? item->blur->computeLength<int>(state.m_style.get(), state.m_rootElementStyle) : 0; > Color color; > if (item->color) > color = colorFromPrimitiveValue(item->color.get()); >diff --git a/Source/WebCore/css/StyleResolver.cpp b/Source/WebCore/css/StyleResolver.cpp >index 956b984b72a541965a5e39b779f485ff7436024b..aa9a84c71fe5f62c7777dd44b3b147b207351708 100644 >--- a/Source/WebCore/css/StyleResolver.cpp >+++ b/Source/WebCore/css/StyleResolver.cpp >@@ -44,7 +44,6 @@ > #include "CSSPrimitiveValueMappings.h" > #include "CSSPropertyNames.h" > #include "CSSReflectValue.h" >-#include "CSSRuleList.h" > #include "CSSSelector.h" > #include "CSSSelectorList.h" > #include "CSSStyleRule.h" >@@ -200,14 +199,14 @@ using namespace HTMLNames; > > #define HANDLE_INHERIT(prop, Prop) \ > if (isInherit) { \ >- m_style->set##Prop(m_parentStyle->prop()); \ >+ m_state.m_style->set##Prop(m_state.m_parentStyle->prop()); \ > return; \ > } > > #define HANDLE_INHERIT_AND_INITIAL(prop, Prop) \ > HANDLE_INHERIT(prop, Prop) \ > if (isInitial) { \ >- m_style->set##Prop(RenderStyle::initial##Prop()); \ >+ m_state.m_style->set##Prop(RenderStyle::initial##Prop()); \ > return; \ > } > >@@ -269,34 +268,16 @@ static StylePropertySet* rightToLeftDeclaration() > > > StyleResolver::StyleResolver(Document* document, bool matchAuthorAndUserStyles) >- : m_hasUAAppearance(false) >- , m_backgroundData(BackgroundFillLayer) >- , m_matchedPropertiesCacheAdditionsSinceLastSweep(0) >+ : m_matchedPropertiesCacheAdditionsSinceLastSweep(0) > , m_matchedPropertiesCacheSweepTimer(this, &StyleResolver::sweepMatchedPropertiesCache) > , m_document(document) > , m_selectorChecker(document) >- , m_parentStyle(0) >- , m_rootElementStyle(0) >- , m_element(0) >- , m_styledElement(0) >- , m_regionForStyling(0) >- , m_elementLinkState(NotInsideLink) >- , m_parentNode(0) >- , m_lineHeightValue(0) >- , m_fontDirty(false) > , m_matchAuthorAndUserStyles(matchAuthorAndUserStyles) >- , m_sameOriginOnly(false) >- , m_distributedToInsertionPoint(false) > , m_fontSelector(CSSFontSelector::create(document)) > #if ENABLE(CSS_DEVICE_ADAPTATION) > , m_viewportStyleResolver(ViewportStyleResolver::create(document)) > #endif >- , m_applyPropertyToRegularStyle(true) >- , m_applyPropertyToVisitedLinkStyle(false) > , m_styleBuilder(StyleBuilder::sharedStyleBuilder()) >-#if ENABLE(CSS_SHADERS) >- , m_hasPendingShaders(false) >-#endif > , m_styleMap(this) > { > Element* root = document->documentElement(); >@@ -660,23 +641,26 @@ bool MatchingUARulesScope::m_matchingUARules = false; > void StyleResolver::collectMatchingRules(const MatchRequest& matchRequest, RuleRange& ruleRange) > { > ASSERT(matchRequest.ruleSet); >- ASSERT(m_element); >+ ASSERT(m_state.m_element); > >- const AtomicString& pseudoId = m_element->shadowPseudoId(); >+ State& state = m_state; >+ Element* element = state.m_element; >+ StyledElement* styledElement = state.m_styledElement; >+ const AtomicString& pseudoId = element->shadowPseudoId(); > if (!pseudoId.isEmpty()) { >- ASSERT(m_styledElement); >+ ASSERT(styledElement); > collectMatchingRulesForList(matchRequest.ruleSet->shadowPseudoElementRules(pseudoId.impl()), matchRequest, ruleRange); > } > > #if ENABLE(VIDEO_TRACK) >- if (m_element->isWebVTTElement() && toWebVTTElement(m_element)->webVTTNodeType()) >+ if (element->isWebVTTElement() && toWebVTTElement(element)->webVTTNodeType()) > collectMatchingRulesForList(matchRequest.ruleSet->cuePseudoRules(), matchRequest, ruleRange); > #endif > // Check whether other types of rules are applicable in the current tree scope. Criteria for this: > // a) it's a UA rule > // b) the tree scope allows author rules > // c) the rules comes from a scoped style sheet within the same tree scope >- TreeScope* treeScope = m_element->treeScope(); >+ TreeScope* treeScope = element->treeScope(); > if (!MatchingUARulesScope::isMatchingUARules() > && !treeScope->applyAuthorStyles() > && (!matchRequest.scope || matchRequest.scope->treeScope() != treeScope)) >@@ -684,30 +668,30 @@ void StyleResolver::collectMatchingRules(const MatchRequest& matchRequest, RuleR > > // We need to collect the rules for id, class, tag, and everything else into a buffer and > // then sort the buffer. >- if (m_element->hasID()) >- collectMatchingRulesForList(matchRequest.ruleSet->idRules(m_element->idForStyleResolution().impl()), matchRequest, ruleRange); >- if (m_styledElement && m_styledElement->hasClass()) { >- for (size_t i = 0; i < m_styledElement->classNames().size(); ++i) >- collectMatchingRulesForList(matchRequest.ruleSet->classRules(m_styledElement->classNames()[i].impl()), matchRequest, ruleRange); >+ if (element->hasID()) >+ collectMatchingRulesForList(matchRequest.ruleSet->idRules(element->idForStyleResolution().impl()), matchRequest, ruleRange); >+ if (styledElement && styledElement->hasClass()) { >+ for (size_t i = 0; i < styledElement->classNames().size(); ++i) >+ collectMatchingRulesForList(matchRequest.ruleSet->classRules(styledElement->classNames()[i].impl()), matchRequest, ruleRange); > } > >- if (m_element->isLink()) >+ if (element->isLink()) > collectMatchingRulesForList(matchRequest.ruleSet->linkPseudoClassRules(), matchRequest, ruleRange); >- if (m_selectorChecker.matchesFocusPseudoClass(m_element)) >+ if (m_selectorChecker.matchesFocusPseudoClass(element)) > collectMatchingRulesForList(matchRequest.ruleSet->focusPseudoClassRules(), matchRequest, ruleRange); >- collectMatchingRulesForList(matchRequest.ruleSet->tagRules(m_element->localName().impl()), matchRequest, ruleRange); >+ collectMatchingRulesForList(matchRequest.ruleSet->tagRules(element->localName().impl()), matchRequest, ruleRange); > collectMatchingRulesForList(matchRequest.ruleSet->universalRules(), matchRequest, ruleRange); > } > > void StyleResolver::collectMatchingRulesForRegion(const MatchRequest& matchRequest, RuleRange& ruleRange) > { >- if (!m_regionForStyling) >+ if (!m_state.m_regionForStyling) > return; > > unsigned size = matchRequest.ruleSet->m_regionSelectorsAndRuleSets.size(); > for (unsigned i = 0; i < size; ++i) { > const CSSSelector* regionSelector = matchRequest.ruleSet->m_regionSelectorsAndRuleSets.at(i).selector; >- if (checkRegionSelector(regionSelector, static_cast<Element*>(m_regionForStyling->node()))) { >+ if (checkRegionSelector(regionSelector, static_cast<Element*>(m_state.m_regionForStyling->node()))) { > RuleSet* regionRules = matchRequest.ruleSet->m_regionSelectorsAndRuleSets.at(i).ruleSet.get(); > ASSERT(regionRules); > collectMatchingRules(MatchRequest(regionRules, matchRequest.includeEmptyRules, matchRequest.scope), ruleRange); >@@ -717,24 +701,25 @@ void StyleResolver::collectMatchingRulesForRegion(const MatchRequest& matchReque > > void StyleResolver::sortAndTransferMatchedRules(MatchResult& result) > { >- if (m_matchedRules.isEmpty()) >+ State& state = m_state; >+ if (state.m_matchedRules.isEmpty()) > return; > > sortMatchedRules(); > > if (m_selectorChecker.mode() == SelectorChecker::CollectingRules) { >- if (!m_ruleList) >- m_ruleList = StaticCSSRuleList::create(); >- for (unsigned i = 0; i < m_matchedRules.size(); ++i) >- m_ruleList->rules().append(m_matchedRules[i]->rule()->createCSSOMWrapper()); >+ if (!state.m_ruleList) >+ state.m_ruleList = StaticCSSRuleList::create(); >+ for (unsigned i = 0; i < state.m_matchedRules.size(); ++i) >+ state.m_ruleList->rules().append(state.m_matchedRules[i]->rule()->createCSSOMWrapper()); > return; > } > > // Now transfer the set of matched rules over to our list of declarations. >- for (unsigned i = 0; i < m_matchedRules.size(); i++) { >- if (m_style && m_matchedRules[i]->containsUncommonAttributeSelector()) >- m_style->setUnique(); >- addMatchedProperties(result, m_matchedRules[i]->rule()->properties(), m_matchedRules[i]->rule(), m_matchedRules[i]->linkMatchType(), m_matchedRules[i]->propertyWhitelistType()); >+ for (unsigned i = 0; i < state.m_matchedRules.size(); i++) { >+ if (state.m_style && state.m_matchedRules[i]->containsUncommonAttributeSelector()) >+ state.m_style->setUnique(); >+ addMatchedProperties(result, state.m_matchedRules[i]->rule()->properties(), state.m_matchedRules[i]->rule(), state.m_matchedRules[i]->linkMatchType(), state.m_matchedRules[i]->propertyWhitelistType()); > } > } > >@@ -745,12 +730,12 @@ void StyleResolver::matchScopedAuthorRules(MatchResult& result, bool includeEmpt > return; > > // Match scoped author rules by traversing the scoped element stack (rebuild it if it got inconsistent). >- if (m_scopeResolver->hasScopedStyles() && m_scopeResolver->ensureStackConsistency(m_element)) { >- bool applyAuthorStyles = m_element->treeScope()->applyAuthorStyles(); >+ if (m_scopeResolver->hasScopedStyles() && m_scopeResolver->ensureStackConsistency(m_state.m_element)) { >+ bool applyAuthorStyles = m_state.m_element->treeScope()->applyAuthorStyles(); > bool documentScope = true; > unsigned scopeSize = m_scopeResolver->stackSize(); > for (unsigned i = 0; i < scopeSize; ++i) { >- m_matchedRules.clear(); >+ m_state.m_matchedRules.clear(); > result.ranges.lastAuthorRule = result.matchedProperties.size() - 1; > > const StyleScopeResolver::StackFrame& frame = m_scopeResolver->stackFrameAt(i); >@@ -781,7 +766,7 @@ void StyleResolver::matchScopedAuthorRules(MatchResult& result, bool includeEmpt > inline bool StyleResolver::styleSharingCandidateMatchesHostRules() > { > #if ENABLE(SHADOW_DOM) >- return m_scopeResolver && m_scopeResolver->styleSharingCandidateMatchesHostRules(m_element); >+ return m_scopeResolver && m_scopeResolver->styleSharingCandidateMatchesHostRules(m_state.m_element); > #else > return false; > #endif >@@ -792,17 +777,17 @@ void StyleResolver::matchHostRules(MatchResult& result, bool includeEmptyRules) > #if ENABLE(SHADOW_DOM) > ASSERT(m_scopeResolver); > >- m_matchedRules.clear(); >+ m_state.m_matchedRules.clear(); > result.ranges.lastAuthorRule = result.matchedProperties.size() - 1; > > Vector<RuleSet*> matchedRules; >- m_scopeResolver->matchHostRules(m_element, matchedRules); >+ m_scopeResolver->matchHostRules(m_state.m_element, matchedRules); > if (matchedRules.isEmpty()) > return; > > for (unsigned i = matchedRules.size(); i > 0; --i) { > RuleRange ruleRange = result.ranges.authorRuleRange(); >- collectMatchingRules(MatchRequest(matchedRules.at(i-1), includeEmptyRules, m_element), ruleRange); >+ collectMatchingRules(MatchRequest(matchedRules.at(i-1), includeEmptyRules, m_state.m_element), ruleRange); > } > sortAndTransferMatchedRules(result); > #else >@@ -813,10 +798,10 @@ void StyleResolver::matchHostRules(MatchResult& result, bool includeEmptyRules) > > void StyleResolver::matchAuthorRules(MatchResult& result, bool includeEmptyRules) > { >- m_matchedRules.clear(); >+ m_state.m_matchedRules.clear(); > result.ranges.lastAuthorRule = result.matchedProperties.size() - 1; > >- if (!m_element) >+ if (!m_state.m_element) > return; > > // Match global author rules. >@@ -834,7 +819,7 @@ void StyleResolver::matchUserRules(MatchResult& result, bool includeEmptyRules) > if (!m_userStyle) > return; > >- m_matchedRules.clear(); >+ m_state.m_matchedRules.clear(); > > result.ranges.lastUserRule = result.matchedProperties.size() - 1; > MatchRequest matchRequest(m_userStyle.get(), includeEmptyRules); >@@ -847,7 +832,7 @@ void StyleResolver::matchUserRules(MatchResult& result, bool includeEmptyRules) > > void StyleResolver::matchUARules(MatchResult& result, RuleSet* rules) > { >- m_matchedRules.clear(); >+ m_state.m_matchedRules.clear(); > > result.ranges.lastUARule = result.matchedProperties.size() - 1; > RuleRange ruleRange = result.ranges.UARuleRange(); >@@ -861,9 +846,10 @@ void StyleResolver::collectMatchingRulesForList(const Vector<RuleData>* rules, c > if (!rules) > return; > >+ State& state = m_state; > // In some cases we may end up looking up style for random elements in the middle of a recursive tree resolve. > // Ancestor identifier filter won't be up-to-date in that case and we can't use the fast path. >- bool canUseFastReject = m_selectorFilter.parentStackIsConsistent(m_parentNode); >+ bool canUseFastReject = m_selectorFilter.parentStackIsConsistent(state.m_parentNode); > > unsigned size = rules->size(); > for (unsigned i = 0; i < size; ++i) { >@@ -881,19 +867,19 @@ void StyleResolver::collectMatchingRulesForList(const Vector<RuleData>* rules, c > continue; > } > // FIXME: Exposing the non-standard getMatchedCSSRules API to web is the only reason this is needed. >- if (m_sameOriginOnly && !ruleData.hasDocumentSecurityOrigin()) { >+ if (state.m_sameOriginOnly && !ruleData.hasDocumentSecurityOrigin()) { > InspectorInstrumentation::didMatchRule(cookie, false); > continue; > } > // If we're matching normal rules, set a pseudo bit if > // we really just matched a pseudo-element. >- if (m_dynamicPseudo != NOPSEUDO && m_pseudoStyle == NOPSEUDO) { >+ if (state.m_dynamicPseudo != NOPSEUDO && state.m_pseudoStyle == NOPSEUDO) { > if (m_selectorChecker.mode() == SelectorChecker::CollectingRules) { > InspectorInstrumentation::didMatchRule(cookie, false); > continue; > } >- if (m_dynamicPseudo < FIRST_INTERNAL_PSEUDOID) >- m_style->setHasPseudoStyle(m_dynamicPseudo); >+ if (state.m_dynamicPseudo < FIRST_INTERNAL_PSEUDOID) >+ state.m_style->setHasPseudoStyle(state.m_dynamicPseudo); > } else { > // Update our first/last rule indices in the matched rules array. > ++ruleRange.lastRuleIndex; >@@ -919,7 +905,7 @@ static inline bool compareRules(const RuleData* r1, const RuleData* r2) > > void StyleResolver::sortMatchedRules() > { >- std::sort(m_matchedRules.begin(), m_matchedRules.end(), compareRules); >+ std::sort(m_state.m_matchedRules.begin(), m_state.m_matchedRules.end(), compareRules); > } > > void StyleResolver::matchAllRules(MatchResult& result, bool includeSMILProperties) >@@ -929,19 +915,19 @@ void StyleResolver::matchAllRules(MatchResult& result, bool includeSMILPropertie > // Now we check user sheet rules. > if (m_matchAuthorAndUserStyles) > matchUserRules(result, false); >- >+ > // Now check author rules, beginning first with presentational attributes mapped from HTML. >- if (m_styledElement) { >- addElementStyleProperties(result, m_styledElement->presentationAttributeStyle()); >+ if (m_state.m_styledElement) { >+ addElementStyleProperties(result, m_state.m_styledElement->presentationAttributeStyle()); > > // Now we check additional mapped declarations. > // Tables and table cells share an additional mapped rule that must be applied > // after all attributes, since their mapped style depends on the values of multiple attributes. >- addElementStyleProperties(result, m_styledElement->additionalPresentationAttributeStyle()); >+ addElementStyleProperties(result, m_state.m_styledElement->additionalPresentationAttributeStyle()); > >- if (m_styledElement->isHTMLElement()) { >+ if (m_state.m_styledElement->isHTMLElement()) { > bool isAuto; >- TextDirection textDirection = toHTMLElement(m_styledElement)->directionalityIfhasDirAutoAttribute(isAuto); >+ TextDirection textDirection = toHTMLElement(m_state.m_styledElement)->directionalityIfhasDirAutoAttribute(isAuto); > if (isAuto) > addMatchedProperties(result, textDirection == LTR ? leftToRightDeclaration() : rightToLeftDeclaration()); > } >@@ -952,18 +938,18 @@ void StyleResolver::matchAllRules(MatchResult& result, bool includeSMILPropertie > matchAuthorRules(result, false); > > // Now check our inline style attribute. >- if (m_matchAuthorAndUserStyles && m_styledElement && m_styledElement->inlineStyle()) { >+ if (m_matchAuthorAndUserStyles && m_state.m_styledElement && m_state.m_styledElement->inlineStyle()) { > // Inline style is immutable as long as there is no CSSOM wrapper. > // FIXME: Media control shadow trees seem to have problems with caching. >- bool isInlineStyleCacheable = !m_styledElement->inlineStyle()->isMutable() && !m_styledElement->isInShadowTree(); >+ bool isInlineStyleCacheable = !m_state.m_styledElement->inlineStyle()->isMutable() && !m_state.m_styledElement->isInShadowTree(); > // FIXME: Constify. >- addElementStyleProperties(result, m_styledElement->inlineStyle(), isInlineStyleCacheable); >+ addElementStyleProperties(result, m_state.m_styledElement->inlineStyle(), isInlineStyleCacheable); > } > > #if ENABLE(SVG) > // Now check SMIL animation override style. >- if (includeSMILProperties && m_matchAuthorAndUserStyles && m_styledElement && m_styledElement->isSVGElement()) >- addElementStyleProperties(result, static_cast<SVGElement*>(m_styledElement)->animatedSMILStyleProperties(), false /* isCacheable */); >+ if (includeSMILProperties && m_matchAuthorAndUserStyles && m_state.m_styledElement && m_state.m_styledElement->isSVGElement()) >+ addElementStyleProperties(result, static_cast<SVGElement*>(m_state.m_styledElement)->animatedSMILStyleProperties(), false /* isCacheable */); > #else > UNUSED_PARAM(includeSMILProperties); > #endif >@@ -980,10 +966,10 @@ bool StyleResolver::classNamesAffectedByRules(const SpaceSplitString& classNames > > inline void StyleResolver::initElement(Element* e) > { >- if (m_element != e) { >- m_element = e; >- m_styledElement = m_element && m_element->isStyledElement() ? static_cast<StyledElement*>(m_element) : 0; >- m_elementLinkState = document()->visitedLinkState()->determineLinkState(m_element); >+ if (m_state.m_element != e) { >+ m_state.m_element = e; >+ m_state.m_styledElement = m_state.m_element && m_state.m_element->isStyledElement() ? static_cast<StyledElement*>(m_state.m_element) : 0; >+ m_state.m_elementLinkState = document()->visitedLinkState()->determineLinkState(e); > if (e && e == e->document()->documentElement()) { > e->document()->setDirectionSetOnDocumentElement(false); > e->document()->setWritingModeSetOnDocumentElement(false); >@@ -993,32 +979,33 @@ inline void StyleResolver::initElement(Element* e) > > inline void StyleResolver::initForStyleResolve(Element* e, RenderStyle* parentStyle, PseudoId pseudoID) > { >- m_pseudoStyle = pseudoID; >+ State& state = m_state; >+ state.m_pseudoStyle = pseudoID; > > if (e) { > NodeRenderingContext context(e); >- m_parentNode = context.parentNodeForRenderingAndStyle(); >- m_parentStyle = context.resetStyleInheritance() ? 0 : >+ state.m_parentNode = context.parentNodeForRenderingAndStyle(); >+ state.m_parentStyle = context.resetStyleInheritance() ? 0 : > parentStyle ? parentStyle : >- m_parentNode ? m_parentNode->renderStyle() : 0; >- m_distributedToInsertionPoint = context.insertionPoint(); >+ state.m_parentNode ? state.m_parentNode->renderStyle() : 0; >+ state.m_distributedToInsertionPoint = context.insertionPoint(); > } else { >- m_parentNode = 0; >- m_parentStyle = parentStyle; >- m_distributedToInsertionPoint = false; >+ state.m_parentNode = 0; >+ state.m_parentStyle = parentStyle; >+ state.m_distributedToInsertionPoint = false; > } > > Node* docElement = e ? e->document()->documentElement() : 0; > RenderStyle* docStyle = document()->renderStyle(); >- m_rootElementStyle = docElement && e != docElement ? docElement->renderStyle() : docStyle; >+ state.m_rootElementStyle = docElement && e != docElement ? docElement->renderStyle() : docStyle; > >- m_style = 0; >+ state.m_style = 0; > >- m_pendingImageProperties.clear(); >+ state.m_pendingImageProperties.clear(); > >- m_ruleList = 0; >+ state.m_ruleList = 0; > >- m_fontDirty = false; >+ state.m_fontDirty = false; > } > > static const unsigned cStyleSearchThreshold = 10; >@@ -1081,23 +1068,24 @@ bool StyleResolver::styleSharingCandidateMatchesRuleSet(RuleSet* ruleSet) > { > if (!ruleSet) > return false; >- m_matchedRules.clear(); >+ m_state.m_matchedRules.clear(); > > m_selectorChecker.setMode(SelectorChecker::SharingRules); > int firstRuleIndex = -1, lastRuleIndex = -1; > RuleRange ruleRange(firstRuleIndex, lastRuleIndex); > collectMatchingRules(MatchRequest(ruleSet), ruleRange); > m_selectorChecker.setMode(SelectorChecker::ResolvingStyle); >- if (m_matchedRules.isEmpty()) >+ if (m_state.m_matchedRules.isEmpty()) > return false; >- m_matchedRules.clear(); >+ m_state.m_matchedRules.clear(); > return true; > } > > bool StyleResolver::canShareStyleWithControl(StyledElement* element) const > { >+ const State& state = m_state; > HTMLInputElement* thisInputElement = element->toInputElement(); >- HTMLInputElement* otherInputElement = m_element->toInputElement(); >+ HTMLInputElement* otherInputElement = state.m_element->toInputElement(); > > if (!thisInputElement || !otherInputElement) > return false; >@@ -1118,25 +1106,25 @@ bool StyleResolver::canShareStyleWithControl(StyledElement* element) const > if (thisInputElement->isRequired() != otherInputElement->isRequired()) > return false; > >- if (element->isEnabledFormControl() != m_element->isEnabledFormControl()) >+ if (element->isEnabledFormControl() != state.m_element->isEnabledFormControl()) > return false; > >- if (element->isDefaultButtonForForm() != m_element->isDefaultButtonForForm()) >+ if (element->isDefaultButtonForForm() != state.m_element->isDefaultButtonForForm()) > return false; > >- if (m_element->document()->containsValidityStyleRules()) { >+ if (state.m_element->document()->containsValidityStyleRules()) { > bool willValidate = element->willValidate(); > >- if (willValidate != m_element->willValidate()) >+ if (willValidate != state.m_element->willValidate()) > return false; > >- if (willValidate && (element->isValidFormControlElement() != m_element->isValidFormControlElement())) >+ if (willValidate && (element->isValidFormControlElement() != state.m_element->isValidFormControlElement())) > return false; > >- if (element->isInRange() != m_element->isInRange()) >+ if (element->isInRange() != state.m_element->isInRange()) > return false; > >- if (element->isOutOfRange() != m_element->isOutOfRange()) >+ if (element->isOutOfRange() != state.m_element->isOutOfRange()) > return false; > } > >@@ -1151,25 +1139,26 @@ static inline bool elementHasDirectionAuto(Element* element) > > bool StyleResolver::sharingCandidateHasIdenticalStyleAffectingAttributes(StyledElement* sharingCandidate) const > { >- if (m_element->attributeData() == sharingCandidate->attributeData()) >+ const State& state = m_state; >+ if (state.m_element->attributeData() == sharingCandidate->attributeData()) > return true; >- if (m_element->fastGetAttribute(XMLNames::langAttr) != sharingCandidate->fastGetAttribute(XMLNames::langAttr)) >+ if (state.m_element->fastGetAttribute(XMLNames::langAttr) != sharingCandidate->fastGetAttribute(XMLNames::langAttr)) > return false; >- if (m_element->fastGetAttribute(langAttr) != sharingCandidate->fastGetAttribute(langAttr)) >+ if (state.m_element->fastGetAttribute(langAttr) != sharingCandidate->fastGetAttribute(langAttr)) > return false; > >- if (!m_elementAffectedByClassRules) { >+ if (!state.m_elementAffectedByClassRules) { > if (sharingCandidate->hasClass() && classNamesAffectedByRules(sharingCandidate->classNames())) > return false; > } else if (sharingCandidate->hasClass()) { > #if ENABLE(SVG) > // SVG elements require a (slow!) getAttribute comparision because "class" is an animatable attribute for SVG. >- if (m_element->isSVGElement()) { >- if (m_element->getAttribute(classAttr) != sharingCandidate->getAttribute(classAttr)) >+ if (state.m_element->isSVGElement()) { >+ if (state.m_element->getAttribute(classAttr) != sharingCandidate->getAttribute(classAttr)) > return false; > } else { > #endif >- if (m_element->classNames() != sharingCandidate->classNames()) >+ if (state.m_element->classNames() != sharingCandidate->classNames()) > return false; > #if ENABLE(SVG) > } >@@ -1177,12 +1166,12 @@ bool StyleResolver::sharingCandidateHasIdenticalStyleAffectingAttributes(StyledE > } else > return false; > >- if (m_styledElement->presentationAttributeStyle() != sharingCandidate->presentationAttributeStyle()) >+ if (state.m_styledElement->presentationAttributeStyle() != sharingCandidate->presentationAttributeStyle()) > return false; > > #if ENABLE(PROGRESS_ELEMENT) >- if (m_element->hasTagName(progressTag)) { >- if (static_cast<HTMLProgressElement*>(m_element)->isDeterminate() != static_cast<HTMLProgressElement*>(sharingCandidate)->isDeterminate()) >+ if (state.m_element->hasTagName(progressTag)) { >+ if (static_cast<HTMLProgressElement*>(state.m_element)->isDeterminate() != static_cast<HTMLProgressElement*>(sharingCandidate)->isDeterminate()) > return false; > } > #endif >@@ -1193,12 +1182,13 @@ bool StyleResolver::sharingCandidateHasIdenticalStyleAffectingAttributes(StyledE > bool StyleResolver::canShareStyleWithElement(StyledElement* element) const > { > RenderStyle* style = element->renderStyle(); >+ const State& state = m_state; > > if (!style) > return false; > if (style->unique()) > return false; >- if (element->tagQName() != m_element->tagQName()) >+ if (element->tagQName() != state.m_element->tagQName()) > return false; > if (element->inlineStyle()) > return false; >@@ -1208,21 +1198,21 @@ bool StyleResolver::canShareStyleWithElement(StyledElement* element) const > if (element->isSVGElement() && static_cast<SVGElement*>(element)->animatedSMILStyleProperties()) > return false; > #endif >- if (element->isLink() != m_element->isLink()) >+ if (element->isLink() != state.m_element->isLink()) > return false; >- if (element->hovered() != m_element->hovered()) >+ if (element->hovered() != state.m_element->hovered()) > return false; >- if (element->active() != m_element->active()) >+ if (element->active() != state.m_element->active()) > return false; >- if (element->focused() != m_element->focused()) >+ if (element->focused() != state.m_element->focused()) > return false; >- if (element->shadowPseudoId() != m_element->shadowPseudoId()) >+ if (element->shadowPseudoId() != state.m_element->shadowPseudoId()) > return false; > if (element == element->document()->cssTarget()) > return false; > if (!sharingCandidateHasIdenticalStyleAffectingAttributes(element)) > return false; >- if (element->additionalPresentationAttributeStyle() != m_styledElement->additionalPresentationAttributeStyle()) >+ if (element->additionalPresentationAttributeStyle() != state.m_styledElement->additionalPresentationAttributeStyle()) > return false; > > if (element->hasID() && m_features.idsInRules.contains(element->idForStyleResolution().impl())) >@@ -1238,7 +1228,7 @@ bool StyleResolver::canShareStyleWithElement(StyledElement* element) const > > bool isControl = element->isFormControlElement(); > >- if (isControl != m_element->isFormControlElement()) >+ if (isControl != state.m_element->isFormControlElement()) > return false; > > if (isControl && !canShareStyleWithControl(element)) >@@ -1262,20 +1252,20 @@ bool StyleResolver::canShareStyleWithElement(StyledElement* element) const > if (elementHasDirectionAuto(element)) > return false; > >- if (element->isLink() && m_elementLinkState != style->insideLink()) >+ if (element->isLink() && state.m_elementLinkState != style->insideLink()) > return false; > > #if ENABLE(VIDEO_TRACK) > // Deny sharing styles between WebVTT and non-WebVTT nodes. >- if (element->isWebVTTElement() != m_element->isWebVTTElement()) >+ if (element->isWebVTTElement() != state.m_element->isWebVTTElement()) > return false; > >- if (element->isWebVTTElement() && m_element->isWebVTTElement() && toWebVTTElement(element)->webVTTNodeType() != toWebVTTElement(m_element)->webVTTNodeType()) >+ if (element->isWebVTTElement() && state.m_element->isWebVTTElement() && toWebVTTElement(element)->webVTTNodeType() != toWebVTTElement(state.m_element)->webVTTNodeType()) > return false; > #endif > > #if ENABLE(FULLSCREEN_API) >- if (element == element->document()->webkitCurrentFullScreenElement() || m_element == m_element->document()->webkitCurrentFullScreenElement()) >+ if (element == element->document()->webkitCurrentFullScreenElement() || state.m_element == state.m_element->document()->webkitCurrentFullScreenElement()) > return false; > #endif > return true; >@@ -1296,36 +1286,38 @@ inline StyledElement* StyleResolver::findSiblingForStyleSharing(Node* node, unsi > > RenderStyle* StyleResolver::locateSharedStyle() > { >- if (!m_styledElement || !m_parentStyle) >+ State& state = m_state; >+ if (!state.m_styledElement || !state.m_parentStyle) > return 0; >+ > // If the element has inline style it is probably unique. >- if (m_styledElement->inlineStyle()) >+ if (state.m_styledElement->inlineStyle()) > return 0; > #if ENABLE(SVG) >- if (m_styledElement->isSVGElement() && static_cast<SVGElement*>(m_styledElement)->animatedSMILStyleProperties()) >+ if (state.m_styledElement->isSVGElement() && static_cast<SVGElement*>(state.m_styledElement)->animatedSMILStyleProperties()) > return 0; > #endif > // Ids stop style sharing if they show up in the stylesheets. >- if (m_styledElement->hasID() && m_features.idsInRules.contains(m_styledElement->idForStyleResolution().impl())) >+ if (state.m_styledElement->hasID() && m_features.idsInRules.contains(state.m_styledElement->idForStyleResolution().impl())) > return 0; >- if (parentElementPreventsSharing(m_element->parentElement())) >+ if (parentElementPreventsSharing(state.m_element->parentElement())) > return 0; >- if (m_styledElement->hasScopedHTMLStyleChild()) >+ if (state.m_styledElement->hasScopedHTMLStyleChild()) > return 0; >- if (m_element == m_element->document()->cssTarget()) >+ if (state.m_element == state.m_element->document()->cssTarget()) > return 0; >- if (elementHasDirectionAuto(m_element)) >+ if (elementHasDirectionAuto(state.m_element)) > return 0; > > // Cache whether m_element is affected by any known class selectors. > // FIXME: This shouldn't be a member variable. The style sharing code could be factored out of StyleResolver. >- m_elementAffectedByClassRules = m_element && m_element->hasClass() && classNamesAffectedByRules(m_element->classNames()); >+ state.m_elementAffectedByClassRules = state.m_element && state.m_element->hasClass() && classNamesAffectedByRules(state.m_element->classNames()); > > // Check previous siblings and their cousins. > unsigned count = 0; > unsigned visitedNodeCount = 0; > StyledElement* shareElement = 0; >- Node* cousinList = m_styledElement->previousSibling(); >+ Node* cousinList = state.m_styledElement->previousSibling(); > while (cousinList) { > shareElement = findSiblingForStyleSharing(cousinList, count); > if (shareElement) >@@ -1347,7 +1339,7 @@ RenderStyle* StyleResolver::locateSharedStyle() > if (styleSharingCandidateMatchesHostRules()) > return 0; > // Tracking child index requires unique style for each node. This may get set by the sibling rule match above. >- if (parentElementPreventsSharing(m_element->parentElement())) >+ if (parentElementPreventsSharing(state.m_element->parentElement())) > return 0; > return shareElement->renderStyle(); > } >@@ -1567,10 +1559,11 @@ PassRefPtr<RenderStyle> StyleResolver::styleForElement(Element* element, RenderS > return s_styleNotYetAvailable; > } > >+ State& state = m_state; > initElement(element); > initForStyleResolve(element, defaultParent); >- m_regionForStyling = regionForStyling; >- if (sharingBehavior == AllowStyleSharing && !m_distributedToInsertionPoint) { >+ state.m_regionForStyling = regionForStyling; >+ if (sharingBehavior == AllowStyleSharing && !state.m_distributedToInsertionPoint) { > RenderStyle* sharedStyle = locateSharedStyle(); > if (sharedStyle) > return sharedStyle; >@@ -1578,33 +1571,32 @@ PassRefPtr<RenderStyle> StyleResolver::styleForElement(Element* element, RenderS > > RefPtr<RenderStyle> cloneForParent; > >- if (m_parentStyle) { >- m_style = RenderStyle::create(); >- m_style->inheritFrom(m_parentStyle, isAtShadowBoundary(element) ? RenderStyle::AtShadowBoundary : RenderStyle::NotAtShadowBoundary); >+ if (state.m_parentStyle) { >+ state.m_style = RenderStyle::create(); >+ state.m_style->inheritFrom(state.m_parentStyle, isAtShadowBoundary(element) ? RenderStyle::AtShadowBoundary : RenderStyle::NotAtShadowBoundary); > } else { >- m_style = defaultStyleForElement(); >- cloneForParent = RenderStyle::clone(style()); >- m_parentStyle = cloneForParent.get(); >+ state.m_style = defaultStyleForElement(); >+ cloneForParent = RenderStyle::clone(state.m_style.get()); >+ state.m_parentStyle = cloneForParent.get(); > } > // contenteditable attribute (implemented by -webkit-user-modify) should > // be propagated from shadow host to distributed node. >- if (m_distributedToInsertionPoint) { >+ if (state.m_distributedToInsertionPoint) { > if (Element* parent = element->parentElement()) { > if (RenderStyle* styleOfShadowHost = parent->renderStyle()) >- m_style->setUserModify(styleOfShadowHost->userModify()); >+ state.m_style->setUserModify(styleOfShadowHost->userModify()); > } > } > > if (element->isLink()) { >- m_style->setIsLink(true); >- EInsideLink linkState = m_elementLinkState; >- if (m_elementLinkState != NotInsideLink) { >+ state.m_style->setIsLink(true); >+ EInsideLink linkState = state.m_elementLinkState; >+ if (linkState != NotInsideLink) { > bool forceVisited = InspectorInstrumentation::forcePseudoState(element, CSSSelector::PseudoVisited); > if (forceVisited) > linkState = InsideVisitedLink; > } >- >- m_style->setInsideLink(linkState); >+ state.m_style->setInsideLink(linkState); > } > > ensureDefaultStyleSheetsForElement(element); >@@ -1618,17 +1610,17 @@ PassRefPtr<RenderStyle> StyleResolver::styleForElement(Element* element, RenderS > applyMatchedProperties(matchResult, element); > > // Clean up our style object's display and text decorations (among other fixups). >- adjustRenderStyle(style(), m_parentStyle, element); >+ adjustRenderStyle(state.m_style.get(), state.m_parentStyle, element); > > initElement(0); // Clear out for the next resolve. > > if (cloneForParent) >- m_parentStyle = 0; >+ state.m_parentStyle = 0; > > document()->didAccessStyleResolver(); > > // Now return the style. >- return m_style.release(); >+ return state.m_style.release(); > } > > PassRefPtr<RenderStyle> StyleResolver::styleForKeyframe(const RenderStyle* elementStyle, const StyleKeyframe* keyframe, KeyframeValue& keyframeValue) >@@ -1637,12 +1629,14 @@ PassRefPtr<RenderStyle> StyleResolver::styleForKeyframe(const RenderStyle* eleme > if (keyframe->properties()) > addMatchedProperties(result, keyframe->properties()); > >- ASSERT(!m_style); >+ ASSERT(!m_state.m_style); >+ >+ State& state = m_state; > > // Create the style >- m_style = RenderStyle::clone(elementStyle); >+ state.m_style = RenderStyle::clone(elementStyle); > >- m_lineHeightValue = 0; >+ state.m_lineHeightValue = 0; > > // We don't need to bother with !important. Since there is only ever one > // decl, there's nothing to override. So just add the first properties. >@@ -1654,8 +1648,8 @@ PassRefPtr<RenderStyle> StyleResolver::styleForKeyframe(const RenderStyle* eleme > updateFont(); > > // Line-height is set when we are sure we decided on the font-size >- if (m_lineHeightValue) >- applyProperty(CSSPropertyLineHeight, m_lineHeightValue); >+ if (state.m_lineHeightValue) >+ applyProperty(CSSPropertyLineHeight, state.m_lineHeightValue); > > // Now do rest of the properties. > if (keyframe->properties()) >@@ -1682,7 +1676,7 @@ PassRefPtr<RenderStyle> StyleResolver::styleForKeyframe(const RenderStyle* eleme > > document()->didAccessStyleResolver(); > >- return m_style.release(); >+ return state.m_style.release(); > } > > void StyleResolver::keyframeStylesForAnimation(Element* e, const RenderStyle* elementStyle, KeyframeList& list) >@@ -1750,15 +1744,17 @@ void StyleResolver::keyframeStylesForAnimation(Element* e, const RenderStyle* el > > PassRefPtr<RenderStyle> StyleResolver::pseudoStyleForElement(PseudoId pseudo, Element* e, RenderStyle* parentStyle) > { >- ASSERT(m_parentStyle); >+ ASSERT(m_state.m_parentStyle); > if (!e) > return 0; > >+ State& state = m_state; >+ > initElement(e); > > initForStyleResolve(e, parentStyle, pseudo); >- m_style = RenderStyle::create(); >- m_style->inheritFrom(m_parentStyle); >+ state.m_style = RenderStyle::create(); >+ state.m_style->inheritFrom(m_state.m_parentStyle); > > // Since we don't use pseudo-elements in any of our quirk/print user agent rules, don't waste time walking > // those rules. >@@ -1775,12 +1771,12 @@ PassRefPtr<RenderStyle> StyleResolver::pseudoStyleForElement(PseudoId pseudo, El > if (matchResult.matchedProperties.isEmpty()) > return 0; > >- m_style->setStyleType(pseudo); >+ state.m_style->setStyleType(pseudo); > > applyMatchedProperties(matchResult, e); > > // Clean up our style object's display and text decorations (among other fixups). >- adjustRenderStyle(style(), parentStyle, 0); >+ adjustRenderStyle(state.m_style.get(), m_state.m_parentStyle, 0); > > // Start loading resources referenced by this style. > loadPendingResources(); >@@ -1788,15 +1784,15 @@ PassRefPtr<RenderStyle> StyleResolver::pseudoStyleForElement(PseudoId pseudo, El > document()->didAccessStyleResolver(); > > // Now return the style. >- return m_style.release(); >+ return state.m_style.release(); > } > > PassRefPtr<RenderStyle> StyleResolver::styleForPage(int pageIndex) > { > initForStyleResolve(document()->documentElement()); // m_rootElementStyle will be set to the document style. > >- m_style = RenderStyle::create(); >- m_style->inheritFrom(m_rootElementStyle); >+ m_state.m_style = RenderStyle::create(); >+ m_state.m_style->inheritFrom(m_state.m_rootElementStyle); > > const bool isLeft = isLeftPage(pageIndex); > const bool isFirst = isFirstPage(pageIndex); >@@ -1807,7 +1803,7 @@ PassRefPtr<RenderStyle> StyleResolver::styleForPage(int pageIndex) > matchPageRules(result, m_userStyle.get(), isLeft, isFirst, page); > // Only consider the global author RuleSet for @page rules, as per the HTML5 spec. > matchPageRules(result, m_authorStyle.get(), isLeft, isFirst, page); >- m_lineHeightValue = 0; >+ m_state.m_lineHeightValue = 0; > bool inheritedOnly = false; > #if ENABLE(CSS_VARIABLES) > applyMatchedProperties<VariableDefinitions>(result, false, 0, result.matchedProperties.size() - 1, inheritedOnly); >@@ -1818,8 +1814,8 @@ PassRefPtr<RenderStyle> StyleResolver::styleForPage(int pageIndex) > updateFont(); > > // Line-height is set when we are sure we decided on the font-size. >- if (m_lineHeightValue) >- applyProperty(CSSPropertyLineHeight, m_lineHeightValue); >+ if (m_state.m_lineHeightValue) >+ applyProperty(CSSPropertyLineHeight, m_state.m_lineHeightValue); > > applyMatchedProperties<LowPriorityProperties>(result, false, 0, result.matchedProperties.size() - 1, inheritedOnly); > >@@ -1829,20 +1825,20 @@ PassRefPtr<RenderStyle> StyleResolver::styleForPage(int pageIndex) > document()->didAccessStyleResolver(); > > // Now return the style. >- return m_style.release(); >+ return m_state.m_style.release(); > } > > PassRefPtr<RenderStyle> StyleResolver::defaultStyleForElement() > { >- m_style = RenderStyle::create(); >+ m_state.m_style = RenderStyle::create(); > // Make sure our fonts are initialized if we don't inherit them from our parent style. > if (Settings* settings = documentSettings()) { > initializeFontStyle(settings); >- m_style->font().update(fontSelector()); >+ m_state.m_style->font().update(fontSelector()); > } else >- m_style->font().update(0); >+ m_state.m_style->font().update(0); > >- return m_style.release(); >+ return m_state.m_style.release(); > } > > PassRefPtr<RenderStyle> StyleResolver::styleForText(Text* textNode) >@@ -2130,7 +2126,7 @@ void StyleResolver::adjustRenderStyle(RenderStyle* style, RenderStyle* parentSty > > // Let the theme also have a crack at adjusting the style. > if (style->hasAppearance()) >- RenderTheme::defaultTheme()->adjustStyle(this, style, e, m_hasUAAppearance, m_borderData, m_backgroundData, m_backgroundColor); >+ RenderTheme::defaultTheme()->adjustStyle(this, style, e, m_state.m_hasUAAppearance, m_state.m_borderData, m_state.m_backgroundData, m_state.m_backgroundColor); > > // If we have first-letter pseudo style, do not share this style. > if (style->hasPseudoStyle(FIRST_LETTER)) >@@ -2213,24 +2209,25 @@ static void checkForOrientationChange(RenderStyle* style) > > void StyleResolver::updateFont() > { >- if (!m_fontDirty) >+ if (!m_state.m_fontDirty) > return; > > checkForTextSizeAdjust(); >- checkForGenericFamilyChange(style(), m_parentStyle); >- checkForZoomChange(style(), m_parentStyle); >- checkForOrientationChange(style()); >- m_style->font().update(m_fontSelector); >- m_fontDirty = false; >+ RenderStyle* style = m_state.m_style.get(); >+ checkForGenericFamilyChange(style, m_state.m_parentStyle); >+ checkForZoomChange(style, m_state.m_parentStyle); >+ checkForOrientationChange(style); >+ m_state.m_style->font().update(m_fontSelector); >+ m_state.m_fontDirty = false; > } > > void StyleResolver::cacheBorderAndBackground() > { >- m_hasUAAppearance = m_style->hasAppearance(); >- if (m_hasUAAppearance) { >- m_borderData = m_style->border(); >- m_backgroundData = *m_style->backgroundLayers(); >- m_backgroundColor = m_style->backgroundColor(); >+ m_state.m_hasUAAppearance = m_state.m_style->hasAppearance(); >+ if (m_state.m_hasUAAppearance) { >+ m_state.m_borderData = m_state.m_style->border(); >+ m_state.m_backgroundData = *m_state.m_style->backgroundLayers(); >+ m_state.m_backgroundColor = m_state.m_style->backgroundColor(); > } > } > >@@ -2260,49 +2257,51 @@ PassRefPtr<CSSRuleList> StyleResolver::pseudoStyleRulesForElement(Element* e, Ps > } > > if (m_matchAuthorAndUserStyles && (rulesToInclude & AuthorCSSRules)) { >- m_sameOriginOnly = !(rulesToInclude & CrossOriginCSSRules); >+ m_state.m_sameOriginOnly = !(rulesToInclude & CrossOriginCSSRules); > > // Check the rules in author sheets. > matchAuthorRules(dummy, rulesToInclude & EmptyCSSRules); > >- m_sameOriginOnly = false; >+ m_state.m_sameOriginOnly = false; > } > > m_selectorChecker.setMode(SelectorChecker::ResolvingStyle); > >- return m_ruleList.release(); >+ return m_state.m_ruleList.release(); > } > > inline bool StyleResolver::ruleMatches(const RuleData& ruleData, const ContainerNode* scope) > { >- m_dynamicPseudo = NOPSEUDO; >+ State& state = m_state; >+ state.m_dynamicPseudo = NOPSEUDO; > > if (ruleData.hasFastCheckableSelector()) { > // We know this selector does not include any pseudo elements. >- if (m_pseudoStyle != NOPSEUDO) >+ if (state.m_pseudoStyle != NOPSEUDO) > return false; > // We know a sufficiently simple single part selector matches simply because we found it from the rule hash. > // This is limited to HTML only so we don't need to check the namespace. >- if (ruleData.hasRightmostSelectorMatchingHTMLBasedOnRuleHash() && m_element->isHTMLElement()) { >+ if (ruleData.hasRightmostSelectorMatchingHTMLBasedOnRuleHash() && state.m_element->isHTMLElement()) { > if (!ruleData.hasMultipartSelector()) > return true; > } >- if (ruleData.selector()->m_match == CSSSelector::Tag && !SelectorChecker::tagMatches(m_element, ruleData.selector()->tagQName())) >+ if (ruleData.selector()->m_match == CSSSelector::Tag && !SelectorChecker::tagMatches(state.m_element, ruleData.selector()->tagQName())) > return false; >- if (!SelectorChecker::fastCheckRightmostAttributeSelector(m_element, ruleData.selector())) >+ if (!SelectorChecker::fastCheckRightmostAttributeSelector(state.m_element, ruleData.selector())) > return false; >- return m_selectorChecker.fastCheck(ruleData.selector(), m_element); >+ >+ return m_selectorChecker.fastCheck(ruleData.selector(), state.m_element); > } > > // Slow path. >- SelectorChecker::SelectorCheckingContext context(ruleData.selector(), m_element, SelectorChecker::VisitedMatchEnabled); >- context.elementStyle = style(); >+ SelectorChecker::SelectorCheckingContext context(ruleData.selector(), state.m_element, SelectorChecker::VisitedMatchEnabled); >+ context.elementStyle = state.m_style.get(); > context.scope = scope; >- context.pseudoStyle = m_pseudoStyle; >- SelectorChecker::Match match = m_selectorChecker.match(context, m_dynamicPseudo, DOMSiblingTraversalStrategy()); >+ context.pseudoStyle = state.m_pseudoStyle; >+ SelectorChecker::Match match = m_selectorChecker.match(context, state.m_dynamicPseudo, DOMSiblingTraversalStrategy()); > if (match != SelectorChecker::SelectorMatches) > return false; >- if (m_pseudoStyle != NOPSEUDO && m_pseudoStyle != m_dynamicPseudo) >+ if (state.m_pseudoStyle != NOPSEUDO && state.m_pseudoStyle != state.m_dynamicPseudo) > return false; > return true; > } >@@ -2312,7 +2311,7 @@ bool StyleResolver::checkRegionSelector(const CSSSelector* regionSelector, Eleme > if (!regionSelector || !regionElement) > return false; > >- m_pseudoStyle = NOPSEUDO; >+ m_state.m_pseudoStyle = NOPSEUDO; > > for (const CSSSelector* s = regionSelector; s; s = CSSSelectorList::next(s)) > if (m_selectorChecker.matches(s, regionElement)) >@@ -2337,7 +2336,7 @@ Length StyleResolver::convertToFloatLength(CSSPrimitiveValue* primitiveValue, Re > template <StyleResolver::StyleApplicationPass pass> > void StyleResolver::applyProperties(const StylePropertySet* properties, StyleRule* rule, bool isImportant, bool inheritedOnly, PropertyWhitelistType propertyWhitelistType) > { >- ASSERT((propertyWhitelistType != PropertyWhitelistRegion) || m_regionForStyling); >+ ASSERT((propertyWhitelistType != PropertyWhitelistRegion) || m_state.m_regionForStyling); > InspectorInstrumentationCookie cookie = InspectorInstrumentation::willProcessRule(document(), rule, this); > > unsigned propertyCount = properties->propertyCount(); >@@ -2381,7 +2380,7 @@ void StyleResolver::applyProperties(const StylePropertySet* properties, StyleRul > applyProperty(current.id(), current.value()); > // we apply line-height later > else if (property == CSSPropertyLineHeight) >- m_lineHeightValue = current.value(); >+ m_state.m_lineHeightValue = current.value(); > break; > case LowPriorityProperties: > if (property > CSSPropertyLineHeight) >@@ -2397,18 +2396,19 @@ void StyleResolver::applyMatchedProperties(const MatchResult& matchResult, bool > if (startIndex == -1) > return; > >- if (m_style->insideLink() != NotInsideLink) { >+ State& state = m_state; >+ if (state.m_style->insideLink() != NotInsideLink) { > for (int i = startIndex; i <= endIndex; ++i) { > const MatchedProperties& matchedProperties = matchResult.matchedProperties[i]; > unsigned linkMatchType = matchedProperties.linkMatchType; > // FIXME: It would be nicer to pass these as arguments but that requires changes in many places. >- m_applyPropertyToRegularStyle = linkMatchType & SelectorChecker::MatchLink; >- m_applyPropertyToVisitedLinkStyle = linkMatchType & SelectorChecker::MatchVisited; >+ state.m_applyPropertyToRegularStyle = linkMatchType & SelectorChecker::MatchLink; >+ state.m_applyPropertyToVisitedLinkStyle = linkMatchType & SelectorChecker::MatchVisited; > > applyProperties<pass>(matchedProperties.properties.get(), matchResult.matchedRules[i], isImportant, inheritedOnly, static_cast<PropertyWhitelistType>(matchedProperties.whitelistType)); > } >- m_applyPropertyToRegularStyle = true; >- m_applyPropertyToVisitedLinkStyle = false; >+ state.m_applyPropertyToRegularStyle = true; >+ state.m_applyPropertyToVisitedLinkStyle = false; > return; > } > for (int i = startIndex; i <= endIndex; ++i) { >@@ -2515,6 +2515,7 @@ static bool isCacheableInMatchedPropertiesCache(const Element* element, const Re > void StyleResolver::applyMatchedProperties(const MatchResult& matchResult, const Element* element) > { > ASSERT(element); >+ State& state = m_state; > unsigned cacheHash = matchResult.isCacheable ? computeMatchedPropertiesHash(matchResult.matchedProperties.data(), matchResult.matchedProperties.size()) : 0; > bool applyInheritedOnly = false; > const MatchedPropertiesCacheItem* cacheItem = 0; >@@ -2522,15 +2523,15 @@ void StyleResolver::applyMatchedProperties(const MatchResult& matchResult, const > // We can build up the style by copying non-inherited properties from an earlier style object built using the same exact > // style declarations. We then only need to apply the inherited properties, if any, as their values can depend on the > // element context. This is fast and saves memory by reusing the style data structures. >- m_style->copyNonInheritedFrom(cacheItem->renderStyle.get()); >- if (m_parentStyle->inheritedDataShared(cacheItem->parentRenderStyle.get()) && !isAtShadowBoundary(element)) { >- EInsideLink linkStatus = m_style->insideLink(); >+ state.m_style->copyNonInheritedFrom(cacheItem->renderStyle.get()); >+ if (state.m_parentStyle->inheritedDataShared(cacheItem->parentRenderStyle.get()) && !isAtShadowBoundary(element)) { >+ EInsideLink linkStatus = state.m_style->insideLink(); > // If the cache item parent style has identical inherited properties to the current parent style then the > // resulting style will be identical too. We copy the inherited properties over from the cache and are done. >- m_style->inheritFrom(cacheItem->renderStyle.get()); >+ state.m_style->inheritFrom(cacheItem->renderStyle.get()); > > // Unfortunately the link status is treated like an inherited property. We need to explicitly restore it. >- m_style->setInsideLink(linkStatus); >+ state.m_style->setInsideLink(linkStatus); > return; > } > applyInheritedOnly = true; >@@ -2548,14 +2549,14 @@ void StyleResolver::applyMatchedProperties(const MatchResult& matchResult, const > // high-priority properties first, i.e., those properties that other properties depend on. > // The order is (1) high-priority not important, (2) high-priority important, (3) normal not important > // and (4) normal important. >- m_lineHeightValue = 0; >+ state.m_lineHeightValue = 0; > applyMatchedProperties<HighPriorityProperties>(matchResult, false, 0, matchResult.matchedProperties.size() - 1, applyInheritedOnly); > applyMatchedProperties<HighPriorityProperties>(matchResult, true, matchResult.ranges.firstAuthorRule, matchResult.ranges.lastAuthorRule, applyInheritedOnly); > applyMatchedProperties<HighPriorityProperties>(matchResult, true, matchResult.ranges.firstUserRule, matchResult.ranges.lastUserRule, applyInheritedOnly); > applyMatchedProperties<HighPriorityProperties>(matchResult, true, matchResult.ranges.firstUARule, matchResult.ranges.lastUARule, applyInheritedOnly); > >- if (cacheItem && cacheItem->renderStyle->effectiveZoom() != m_style->effectiveZoom()) { >- m_fontDirty = true; >+ if (cacheItem && cacheItem->renderStyle->effectiveZoom() != state.m_style->effectiveZoom()) { >+ state.m_fontDirty = true; > applyInheritedOnly = false; > } > >@@ -2563,11 +2564,11 @@ void StyleResolver::applyMatchedProperties(const MatchResult& matchResult, const > updateFont(); > > // Line-height is set when we are sure we decided on the font-size. >- if (m_lineHeightValue) >- applyProperty(CSSPropertyLineHeight, m_lineHeightValue); >+ if (state.m_lineHeightValue) >+ applyProperty(CSSPropertyLineHeight, state.m_lineHeightValue); > > // Many properties depend on the font. If it changes we just apply all properties. >- if (cacheItem && cacheItem->renderStyle->fontDescription() != m_style->fontDescription()) >+ if (cacheItem && cacheItem->renderStyle->fontDescription() != state.m_style->fontDescription()) > applyInheritedOnly = false; > > // Now do the normal priority UA properties. >@@ -2585,13 +2586,13 @@ void StyleResolver::applyMatchedProperties(const MatchResult& matchResult, const > // Start loading resources referenced by this style. > loadPendingResources(); > >- ASSERT(!m_fontDirty); >+ ASSERT(!state.m_fontDirty); > > if (cacheItem || !cacheHash) > return; >- if (!isCacheableInMatchedPropertiesCache(m_element, m_style.get(), m_parentStyle)) >+ if (!isCacheableInMatchedPropertiesCache(state.m_element, state.m_style.get(), state.m_parentStyle)) > return; >- addToMatchedPropertiesCache(m_style.get(), m_parentStyle, cacheHash, matchResult); >+ addToMatchedPropertiesCache(state.m_style.get(), state.m_parentStyle, cacheHash, matchResult); > } > > static inline bool comparePageRules(const StyleRulePage* r1, const StyleRulePage* r2) >@@ -2656,7 +2657,7 @@ void StyleResolver::matchPageRulesForList(Vector<StyleRulePage*>& matchedRules, > bool StyleResolver::isLeftPage(int pageIndex) const > { > bool isFirstPageLeft = false; >- if (!m_rootElementStyle->isLeftToRightDirection()) >+ if (!m_state.m_rootElementStyle->isLeftToRightDirection()) > isFirstPageLeft = true; > > return (pageIndex + (isFirstPageLeft ? 1 : 0)) % 2; >@@ -2756,7 +2757,7 @@ void StyleResolver::applyPropertyToStyle(CSSPropertyID id, CSSValue* value, Rend > { > initElement(0); > initForStyleResolve(0, style); >- m_style = style; >+ m_state.m_style = style; > applyPropertyToCurrentStyle(id, value); > } > >@@ -2868,10 +2869,10 @@ inline bool StyleResolver::isValidCueStyleProperty(CSSPropertyID id) > // properties that are NOT allowed to scale within a zoomed SVG document (letter/word-spacing/font-size). > bool StyleResolver::useSVGZoomRules() > { >- return m_element && m_element->isSVGElement(); >+ return m_state.m_element && m_state.m_element->isSVGElement(); > } > >-static bool createGridTrackBreadth(CSSPrimitiveValue* primitiveValue, StyleResolver* selector, Length& workingLength) >+static bool createGridTrackBreadth(CSSPrimitiveValue* primitiveValue, const StyleResolver::State& state, Length& workingLength) > { > if (primitiveValue->getIdent() == CSSValueWebkitMinContent) { > workingLength = Length(MinContent); >@@ -2883,7 +2884,7 @@ static bool createGridTrackBreadth(CSSPrimitiveValue* primitiveValue, StyleResol > return true; > } > >- workingLength = primitiveValue->convertToLength<FixedIntegerConversion | PercentConversion | ViewportPercentageConversion | AutoConversion>(selector->style(), selector->rootElementStyle(), selector->style()->effectiveZoom()); >+ workingLength = primitiveValue->convertToLength<FixedIntegerConversion | PercentConversion | ViewportPercentageConversion | AutoConversion>(state.m_style.get(), state.m_rootElementStyle, state.m_style->effectiveZoom()); > if (workingLength.isUndefined()) > return false; > >@@ -2893,12 +2894,12 @@ static bool createGridTrackBreadth(CSSPrimitiveValue* primitiveValue, StyleResol > return true; > } > >-static bool createGridTrackMinMax(CSSPrimitiveValue* primitiveValue, StyleResolver* selector, GridTrackSize& trackSize) >+static bool createGridTrackMinMax(CSSPrimitiveValue* primitiveValue, const StyleResolver::State& state, GridTrackSize& trackSize) > { > Pair* minMaxTrackBreadth = primitiveValue->getPairValue(); > if (!minMaxTrackBreadth) { > Length workingLength; >- if (!createGridTrackBreadth(primitiveValue, selector, workingLength)) >+ if (!createGridTrackBreadth(primitiveValue, state, workingLength)) > return false; > > trackSize.setLength(workingLength); >@@ -2907,14 +2908,14 @@ static bool createGridTrackMinMax(CSSPrimitiveValue* primitiveValue, StyleResolv > > Length minTrackBreadth; > Length maxTrackBreadth; >- if (!createGridTrackBreadth(minMaxTrackBreadth->first(), selector, minTrackBreadth) || !createGridTrackBreadth(minMaxTrackBreadth->second(), selector, maxTrackBreadth)) >+ if (!createGridTrackBreadth(minMaxTrackBreadth->first(), state, minTrackBreadth) || !createGridTrackBreadth(minMaxTrackBreadth->second(), state, maxTrackBreadth)) > return false; > > trackSize.setMinMax(minTrackBreadth, maxTrackBreadth); > return true; > } > >-static bool createGridTrackGroup(CSSValue* value, StyleResolver* selector, Vector<GridTrackSize>& trackSizes) >+static bool createGridTrackGroup(CSSValue* value, const StyleResolver::State& state, Vector<GridTrackSize>& trackSizes) > { > if (!value->isValueList()) > return false; >@@ -2925,7 +2926,7 @@ static bool createGridTrackGroup(CSSValue* value, StyleResolver* selector, Vecto > return false; > > GridTrackSize trackSize; >- if (!createGridTrackMinMax(static_cast<CSSPrimitiveValue*>(currValue), selector, trackSize)) >+ if (!createGridTrackMinMax(static_cast<CSSPrimitiveValue*>(currValue), state, trackSize)) > return false; > > trackSizes.append(trackSize); >@@ -2933,7 +2934,7 @@ static bool createGridTrackGroup(CSSValue* value, StyleResolver* selector, Vecto > return true; > } > >-static bool createGridTrackList(CSSValue* value, Vector<GridTrackSize>& trackSizes, StyleResolver* selector) >+static bool createGridTrackList(CSSValue* value, Vector<GridTrackSize>& trackSizes, const StyleResolver::State& state) > { > // Handle 'none'. > if (value->isPrimitiveValue()) { >@@ -2941,7 +2942,7 @@ static bool createGridTrackList(CSSValue* value, Vector<GridTrackSize>& trackSiz > return primitiveValue->getIdent() == CSSValueNone; > } > >- return createGridTrackGroup(value, selector, trackSizes); >+ return createGridTrackGroup(value, state, trackSizes); > } > > >@@ -2989,7 +2990,7 @@ static bool hasVariableReference(CSSValue* value) > > void StyleResolver::resolveVariables(CSSPropertyID id, CSSValue* value, Vector<std::pair<CSSPropertyID, String> >& knownExpressions) > { >- std::pair<CSSPropertyID, String> expression(id, value->serializeResolvingVariables(*style()->variables())); >+ std::pair<CSSPropertyID, String> expression(id, value->serializeResolvingVariables(*m_state.m_style->variables())); > > if (knownExpressions.contains(expression)) > return; // cycle detected. >@@ -3021,19 +3022,20 @@ void StyleResolver::applyProperty(CSSPropertyID id, CSSValue* value) > } > #endif > >- bool isInherit = m_parentNode && value->isInheritedValue(); >- bool isInitial = value->isInitialValue() || (!m_parentNode && value->isInheritedValue()); >+ State& state = m_state; >+ bool isInherit = state.m_parentNode && value->isInheritedValue(); >+ bool isInitial = value->isInitialValue() || (!state.m_parentNode && value->isInheritedValue()); > > ASSERT(!isInherit || !isInitial); // isInherit -> !isInitial && isInitial -> !isInherit >- ASSERT(!isInherit || (m_parentNode && m_parentStyle)); // isInherit -> (m_parentNode && m_parentStyle) >+ ASSERT(!isInherit || (state.m_parentNode && state.m_parentStyle)); // isInherit -> (state.m_parentNode && state.m_parentStyle) > >- if (!applyPropertyToRegularStyle() && (!applyPropertyToVisitedLinkStyle() || !isValidVisitedLinkProperty(id))) { >+ if (!state.m_applyPropertyToRegularStyle && (!state.m_applyPropertyToVisitedLinkStyle || !isValidVisitedLinkProperty(id))) { > // Limit the properties that can be applied to only the ones honored by :visited. > return; > } > >- if (isInherit && !m_parentStyle->hasExplicitlyInheritedProperties() && !CSSProperty::isInheritedProperty(id)) >- m_parentStyle->setHasExplicitlyInheritedProperties(); >+ if (isInherit && !state.m_parentStyle->hasExplicitlyInheritedProperties() && !CSSProperty::isInheritedProperty(id)) >+ state.m_parentStyle->setHasExplicitlyInheritedProperties(); > > #if ENABLE(CSS_VARIABLES) > if (id == CSSPropertyVariable) { >@@ -3041,7 +3043,7 @@ void StyleResolver::applyProperty(CSSPropertyID id, CSSValue* value) > CSSVariableValue* variable = static_cast<CSSVariableValue*>(value); > ASSERT(!variable->name().isEmpty()); > ASSERT(!variable->value().isEmpty()); >- m_style->setVariable(variable->name(), variable->value()); >+ state.m_style->setVariable(variable->name(), variable->value()); > return; > } > #endif >@@ -3060,7 +3062,7 @@ void StyleResolver::applyProperty(CSSPropertyID id, CSSValue* value) > > CSSPrimitiveValue* primitiveValue = value->isPrimitiveValue() ? static_cast<CSSPrimitiveValue*>(value) : 0; > >- float zoomFactor = m_style->effectiveZoom(); >+ float zoomFactor = state.m_style->effectiveZoom(); > > // What follows is a list that maps the CSS properties into their corresponding front-end > // RenderStyle values. Shorthands (e.g. border, background) occur in this list as well and >@@ -3074,7 +3076,7 @@ void StyleResolver::applyProperty(CSSPropertyID id, CSSValue* value) > // note is a reminder that eventually "inherit" needs to be supported. > > if (isInitial) { >- m_style->clearContent(); >+ state.m_style->clearContent(); > return; > } > >@@ -3086,19 +3088,19 @@ void StyleResolver::applyProperty(CSSPropertyID id, CSSValue* value) > CSSValue* item = i.value(); > if (item->isImageGeneratorValue()) { > if (item->isGradientValue()) >- m_style->setContent(StyleGeneratedImage::create(static_cast<CSSGradientValue*>(item)->gradientWithStylesResolved(this).get()), didSet); >+ state.m_style->setContent(StyleGeneratedImage::create(static_cast<CSSGradientValue*>(item)->gradientWithStylesResolved(this).get()), didSet); > else >- m_style->setContent(StyleGeneratedImage::create(static_cast<CSSImageGeneratorValue*>(item)), didSet); >+ state.m_style->setContent(StyleGeneratedImage::create(static_cast<CSSImageGeneratorValue*>(item)), didSet); > didSet = true; > #if ENABLE(CSS_IMAGE_SET) > } else if (item->isImageSetValue()) { >- m_style->setContent(setOrPendingFromValue(CSSPropertyContent, static_cast<CSSImageSetValue*>(item)), didSet); >+ state.m_style->setContent(setOrPendingFromValue(CSSPropertyContent, static_cast<CSSImageSetValue*>(item)), didSet); > didSet = true; > #endif > } > > if (item->isImageValue()) { >- m_style->setContent(cachedOrPendingFromValue(CSSPropertyContent, static_cast<CSSImageValue*>(item)), didSet); >+ state.m_style->setContent(cachedOrPendingFromValue(CSSPropertyContent, static_cast<CSSImageValue*>(item)), didSet); > didSet = true; > continue; > } >@@ -3109,17 +3111,17 @@ void StyleResolver::applyProperty(CSSPropertyID id, CSSValue* value) > CSSPrimitiveValue* contentValue = static_cast<CSSPrimitiveValue*>(item); > > if (contentValue->isString()) { >- m_style->setContent(contentValue->getStringValue().impl(), didSet); >+ state.m_style->setContent(contentValue->getStringValue().impl(), didSet); > didSet = true; > } else if (contentValue->isAttr()) { > // FIXME: Can a namespace be specified for an attr(foo)? >- if (m_style->styleType() == NOPSEUDO) >- m_style->setUnique(); >+ if (state.m_style->styleType() == NOPSEUDO) >+ state.m_style->setUnique(); > else >- m_parentStyle->setUnique(); >+ state.m_parentStyle->setUnique(); > QualifiedName attr(nullAtom, contentValue->getStringValue().impl(), nullAtom); >- const AtomicString& value = m_element->getAttribute(attr); >- m_style->setContent(value.isNull() ? emptyAtom : value.impl(), didSet); >+ const AtomicString& value = state.m_element->getAttribute(attr); >+ state.m_style->setContent(value.isNull() ? emptyAtom : value.impl(), didSet); > didSet = true; > // register the fact that the attribute value affects the style > m_features.attrsInRules.add(attr.localName().impl()); >@@ -3130,24 +3132,24 @@ void StyleResolver::applyProperty(CSSPropertyID id, CSSValue* value) > if (listStyleIdent != CSSValueNone) > listStyleType = static_cast<EListStyleType>(listStyleIdent - CSSValueDisc); > OwnPtr<CounterContent> counter = adoptPtr(new CounterContent(counterValue->identifier(), listStyleType, counterValue->separator())); >- m_style->setContent(counter.release(), didSet); >+ state.m_style->setContent(counter.release(), didSet); > didSet = true; > } else { > switch (contentValue->getIdent()) { > case CSSValueOpenQuote: >- m_style->setContent(OPEN_QUOTE, didSet); >+ state.m_style->setContent(OPEN_QUOTE, didSet); > didSet = true; > break; > case CSSValueCloseQuote: >- m_style->setContent(CLOSE_QUOTE, didSet); >+ state.m_style->setContent(CLOSE_QUOTE, didSet); > didSet = true; > break; > case CSSValueNoOpenQuote: >- m_style->setContent(NO_OPEN_QUOTE, didSet); >+ state.m_style->setContent(NO_OPEN_QUOTE, didSet); > didSet = true; > break; > case CSSValueNoCloseQuote: >- m_style->setContent(NO_CLOSE_QUOTE, didSet); >+ state.m_style->setContent(NO_CLOSE_QUOTE, didSet); > didSet = true; > break; > default: >@@ -3157,16 +3159,16 @@ void StyleResolver::applyProperty(CSSPropertyID id, CSSValue* value) > } > } > if (!didSet) >- m_style->clearContent(); >+ state.m_style->clearContent(); > return; > } > case CSSPropertyQuotes: > if (isInherit) { >- m_style->setQuotes(m_parentStyle->quotes()); >+ state.m_style->setQuotes(state.m_parentStyle->quotes()); > return; > } > if (isInitial) { >- m_style->setQuotes(0); >+ state.m_style->setQuotes(0); > return; > } > if (value->isValueList()) { >@@ -3184,19 +3186,19 @@ void StyleResolver::applyProperty(CSSPropertyID id, CSSValue* value) > String endQuote = static_cast<CSSPrimitiveValue*>(second)->getStringValue(); > quotes->addPair(std::make_pair(startQuote, endQuote)); > } >- m_style->setQuotes(quotes); >+ state.m_style->setQuotes(quotes); > return; > } > if (primitiveValue) { > if (primitiveValue->getIdent() == CSSValueNone) >- m_style->setQuotes(QuotesData::create()); >+ state.m_style->setQuotes(QuotesData::create()); > } > return; > case CSSPropertyFontFamily: { > // list of strings and ids > if (isInherit) { >- FontDescription parentFontDescription = m_parentStyle->fontDescription(); >- FontDescription fontDescription = m_style->fontDescription(); >+ FontDescription parentFontDescription = state.m_parentStyle->fontDescription(); >+ FontDescription fontDescription = state.m_style->fontDescription(); > fontDescription.setGenericFamily(parentFontDescription.genericFamily()); > fontDescription.setFamily(parentFontDescription.firstFamily()); > fontDescription.setIsSpecifiedFont(parentFontDescription.isSpecifiedFont()); >@@ -3206,7 +3208,7 @@ void StyleResolver::applyProperty(CSSPropertyID id, CSSValue* value) > > if (isInitial) { > FontDescription initialDesc = FontDescription(); >- FontDescription fontDescription = m_style->fontDescription(); >+ FontDescription fontDescription = state.m_style->fontDescription(); > // We need to adjust the size to account for the generic family change from monospace > // to non-monospace. > if (fontDescription.keywordSize() && fontDescription.useFixedDefaultSize()) >@@ -3220,7 +3222,7 @@ void StyleResolver::applyProperty(CSSPropertyID id, CSSValue* value) > > if (!value->isValueList()) > return; >- FontDescription fontDescription = m_style->fontDescription(); >+ FontDescription fontDescription = state.m_style->fontDescription(); > FontFamily& firstFamily = fontDescription.firstFamily(); > FontFamily* currFamily = 0; > >@@ -3298,24 +3300,24 @@ void StyleResolver::applyProperty(CSSPropertyID id, CSSValue* value) > // shorthand properties > case CSSPropertyBackground: > if (isInitial) { >- m_style->clearBackgroundLayers(); >- m_style->setBackgroundColor(Color()); >+ state.m_style->clearBackgroundLayers(); >+ state.m_style->setBackgroundColor(Color()); > } else if (isInherit) { >- m_style->inheritBackgroundLayers(*m_parentStyle->backgroundLayers()); >- m_style->setBackgroundColor(m_parentStyle->backgroundColor()); >+ state.m_style->inheritBackgroundLayers(*state.m_parentStyle->backgroundLayers()); >+ state.m_style->setBackgroundColor(state.m_parentStyle->backgroundColor()); > } > return; > case CSSPropertyWebkitMask: > if (isInitial) >- m_style->clearMaskLayers(); >+ state.m_style->clearMaskLayers(); > else if (isInherit) >- m_style->inheritMaskLayers(*m_parentStyle->maskLayers()); >+ state.m_style->inheritMaskLayers(*state.m_parentStyle->maskLayers()); > return; > case CSSPropertyFont: > if (isInherit) { >- FontDescription fontDescription = m_parentStyle->fontDescription(); >- m_style->setLineHeight(m_parentStyle->specifiedLineHeight()); >- m_lineHeightValue = 0; >+ FontDescription fontDescription = state.m_parentStyle->fontDescription(); >+ state.m_style->setLineHeight(state.m_parentStyle->specifiedLineHeight()); >+ state.m_lineHeightValue = 0; > setFontDescription(fontDescription); > } else if (isInitial) { > Settings* settings = documentSettings(); >@@ -3324,8 +3326,8 @@ void StyleResolver::applyProperty(CSSPropertyID id, CSSValue* value) > return; > initializeFontStyle(settings); > } else if (primitiveValue) { >- m_style->setLineHeight(RenderStyle::initialLineHeight()); >- m_lineHeightValue = 0; >+ state.m_style->setLineHeight(RenderStyle::initialLineHeight()); >+ state.m_lineHeightValue = 0; > > FontDescription fontDescription; > RenderTheme::defaultTheme()->systemFont(primitiveValue->getIdent(), fontDescription); >@@ -3341,7 +3343,7 @@ void StyleResolver::applyProperty(CSSPropertyID id, CSSValue* value) > fontDescription.setUsePrinterFont(document()->printing() || !settings->screenFontSubstitutionEnabled()); > > // Handle the zoom factor. >- fontDescription.setComputedSize(getComputedSizeFromSpecifiedSize(document(), m_style.get(), fontDescription.isAbsoluteSize(), fontDescription.specifiedSize(), useSVGZoomRules())); >+ fontDescription.setComputedSize(getComputedSizeFromSpecifiedSize(document(), state.m_style.get(), fontDescription.isAbsoluteSize(), fontDescription.specifiedSize(), useSVGZoomRules())); > setFontDescription(fontDescription); > } > } else if (value->isFontValue()) { >@@ -3359,7 +3361,7 @@ void StyleResolver::applyProperty(CSSPropertyID id, CSSValue* value) > updateFont(); > applyProperty(CSSPropertyFontSize, font->size.get()); > >- m_lineHeightValue = font->lineHeight.get(); >+ state.m_lineHeightValue = font->lineHeight.get(); > > applyProperty(CSSPropertyFontFamily, font->family.get()); > } >@@ -3371,11 +3373,11 @@ void StyleResolver::applyProperty(CSSPropertyID id, CSSValue* value) > case CSSPropertyWebkitBoxShadow: { > if (isInherit) { > if (id == CSSPropertyTextShadow) >- return m_style->setTextShadow(m_parentStyle->textShadow() ? adoptPtr(new ShadowData(*m_parentStyle->textShadow())) : nullptr); >- return m_style->setBoxShadow(m_parentStyle->boxShadow() ? adoptPtr(new ShadowData(*m_parentStyle->boxShadow())) : nullptr); >+ return state.m_style->setTextShadow(state.m_parentStyle->textShadow() ? adoptPtr(new ShadowData(*state.m_parentStyle->textShadow())) : nullptr); >+ return state.m_style->setBoxShadow(state.m_parentStyle->boxShadow() ? adoptPtr(new ShadowData(*state.m_parentStyle->boxShadow())) : nullptr); > } > if (isInitial || primitiveValue) // initial | none >- return id == CSSPropertyTextShadow ? m_style->setTextShadow(nullptr) : m_style->setBoxShadow(nullptr); >+ return id == CSSPropertyTextShadow ? state.m_style->setTextShadow(nullptr) : state.m_style->setBoxShadow(nullptr); > > if (!value->isValueList()) > return; >@@ -3385,29 +3387,29 @@ void StyleResolver::applyProperty(CSSPropertyID id, CSSValue* value) > if (!currValue->isShadowValue()) > continue; > ShadowValue* item = static_cast<ShadowValue*>(currValue); >- int x = item->x->computeLength<int>(style(), m_rootElementStyle, zoomFactor); >- int y = item->y->computeLength<int>(style(), m_rootElementStyle, zoomFactor); >- int blur = item->blur ? item->blur->computeLength<int>(style(), m_rootElementStyle, zoomFactor) : 0; >- int spread = item->spread ? item->spread->computeLength<int>(style(), m_rootElementStyle, zoomFactor) : 0; >+ int x = item->x->computeLength<int>(state.m_style.get(), state.m_rootElementStyle, zoomFactor); >+ int y = item->y->computeLength<int>(state.m_style.get(), state.m_rootElementStyle, zoomFactor); >+ int blur = item->blur ? item->blur->computeLength<int>(state.m_style.get(), state.m_rootElementStyle, zoomFactor) : 0; >+ int spread = item->spread ? item->spread->computeLength<int>(state.m_style.get(), state.m_rootElementStyle, zoomFactor) : 0; > ShadowStyle shadowStyle = item->style && item->style->getIdent() == CSSValueInset ? Inset : Normal; > Color color; > if (item->color) > color = colorFromPrimitiveValue(item->color.get()); >- else if (m_style) >- color = m_style->color(); >+ else if (state.m_style) >+ color = state.m_style->color(); > > OwnPtr<ShadowData> shadowData = adoptPtr(new ShadowData(IntPoint(x, y), blur, spread, shadowStyle, id == CSSPropertyWebkitBoxShadow, color.isValid() ? color : Color::transparent)); > if (id == CSSPropertyTextShadow) >- m_style->setTextShadow(shadowData.release(), i.index()); // add to the list if this is not the first entry >+ state.m_style->setTextShadow(shadowData.release(), i.index()); // add to the list if this is not the first entry > else >- m_style->setBoxShadow(shadowData.release(), i.index()); // add to the list if this is not the first entry >+ state.m_style->setBoxShadow(shadowData.release(), i.index()); // add to the list if this is not the first entry > } > return; > } > case CSSPropertyWebkitBoxReflect: { > HANDLE_INHERIT_AND_INITIAL(boxReflect, BoxReflect) > if (primitiveValue) { >- m_style->setBoxReflect(RenderStyle::initialBoxReflect()); >+ state.m_style->setBoxReflect(RenderStyle::initialBoxReflect()); > return; > } > >@@ -3418,13 +3420,13 @@ void StyleResolver::applyProperty(CSSPropertyID id, CSSValue* value) > RefPtr<StyleReflection> reflection = StyleReflection::create(); > reflection->setDirection(*reflectValue->direction()); > if (reflectValue->offset()) >- reflection->setOffset(reflectValue->offset()->convertToLength<FixedIntegerConversion | PercentConversion | CalculatedConversion>(style(), m_rootElementStyle, zoomFactor)); >+ reflection->setOffset(reflectValue->offset()->convertToLength<FixedIntegerConversion | PercentConversion | CalculatedConversion>(state.m_style.get(), state.m_rootElementStyle, zoomFactor)); > NinePieceImage mask; > mask.setMaskDefaults(); > m_styleMap.mapNinePieceImage(id, reflectValue->mask(), mask); > reflection->setMask(mask); > >- m_style->setBoxReflect(reflection.release()); >+ state.m_style->setBoxReflect(reflection.release()); > return; > } > case CSSPropertySrc: // Only used in @font-face rules. >@@ -3433,29 +3435,29 @@ void StyleResolver::applyProperty(CSSPropertyID id, CSSValue* value) > return; > case CSSPropertyWebkitColumnRule: > if (isInherit) { >- m_style->setColumnRuleColor(m_parentStyle->columnRuleColor().isValid() ? m_parentStyle->columnRuleColor() : m_parentStyle->color()); >- m_style->setColumnRuleStyle(m_parentStyle->columnRuleStyle()); >- m_style->setColumnRuleWidth(m_parentStyle->columnRuleWidth()); >+ state.m_style->setColumnRuleColor(state.m_parentStyle->columnRuleColor().isValid() ? state.m_parentStyle->columnRuleColor() : state.m_parentStyle->color()); >+ state.m_style->setColumnRuleStyle(state.m_parentStyle->columnRuleStyle()); >+ state.m_style->setColumnRuleWidth(state.m_parentStyle->columnRuleWidth()); > } else if (isInitial) >- m_style->resetColumnRule(); >+ state.m_style->resetColumnRule(); > return; > case CSSPropertyWebkitMarquee: > if (!isInherit) > return; >- m_style->setMarqueeDirection(m_parentStyle->marqueeDirection()); >- m_style->setMarqueeIncrement(m_parentStyle->marqueeIncrement()); >- m_style->setMarqueeSpeed(m_parentStyle->marqueeSpeed()); >- m_style->setMarqueeLoopCount(m_parentStyle->marqueeLoopCount()); >- m_style->setMarqueeBehavior(m_parentStyle->marqueeBehavior()); >+ state.m_style->setMarqueeDirection(state.m_parentStyle->marqueeDirection()); >+ state.m_style->setMarqueeIncrement(state.m_parentStyle->marqueeIncrement()); >+ state.m_style->setMarqueeSpeed(state.m_parentStyle->marqueeSpeed()); >+ state.m_style->setMarqueeLoopCount(state.m_parentStyle->marqueeLoopCount()); >+ state.m_style->setMarqueeBehavior(state.m_parentStyle->marqueeBehavior()); > return; > case CSSPropertyWebkitMarqueeRepetition: { > HANDLE_INHERIT_AND_INITIAL(marqueeLoopCount, MarqueeLoopCount) > if (!primitiveValue) > return; > if (primitiveValue->getIdent() == CSSValueInfinite) >- m_style->setMarqueeLoopCount(-1); // -1 means repeat forever. >+ state.m_style->setMarqueeLoopCount(-1); // -1 means repeat forever. > else if (primitiveValue->isNumber()) >- m_style->setMarqueeLoopCount(primitiveValue->getIntValue()); >+ state.m_style->setMarqueeLoopCount(primitiveValue->getIntValue()); > return; > } > case CSSPropertyWebkitMarqueeSpeed: { >@@ -3465,19 +3467,19 @@ void StyleResolver::applyProperty(CSSPropertyID id, CSSValue* value) > if (int ident = primitiveValue->getIdent()) { > switch (ident) { > case CSSValueSlow: >- m_style->setMarqueeSpeed(500); // 500 msec. >+ state.m_style->setMarqueeSpeed(500); // 500 msec. > break; > case CSSValueNormal: >- m_style->setMarqueeSpeed(85); // 85msec. The WinIE default. >+ state.m_style->setMarqueeSpeed(85); // 85msec. The WinIE default. > break; > case CSSValueFast: >- m_style->setMarqueeSpeed(10); // 10msec. Super fast. >+ state.m_style->setMarqueeSpeed(10); // 10msec. Super fast. > break; > } > } else if (primitiveValue->isTime()) >- m_style->setMarqueeSpeed(primitiveValue->computeTime<int, CSSPrimitiveValue::Milliseconds>()); >+ state.m_style->setMarqueeSpeed(primitiveValue->computeTime<int, CSSPrimitiveValue::Milliseconds>()); > else if (primitiveValue->isNumber()) // For scrollamount support. >- m_style->setMarqueeSpeed(primitiveValue->getIntValue()); >+ state.m_style->setMarqueeSpeed(primitiveValue->getIntValue()); > return; > } > case CSSPropertyWebkitMarqueeIncrement: { >@@ -3487,19 +3489,19 @@ void StyleResolver::applyProperty(CSSPropertyID id, CSSValue* value) > if (primitiveValue->getIdent()) { > switch (primitiveValue->getIdent()) { > case CSSValueSmall: >- m_style->setMarqueeIncrement(Length(1, Fixed)); // 1px. >+ state.m_style->setMarqueeIncrement(Length(1, Fixed)); // 1px. > break; > case CSSValueNormal: >- m_style->setMarqueeIncrement(Length(6, Fixed)); // 6px. The WinIE default. >+ state.m_style->setMarqueeIncrement(Length(6, Fixed)); // 6px. The WinIE default. > break; > case CSSValueLarge: >- m_style->setMarqueeIncrement(Length(36, Fixed)); // 36px. >+ state.m_style->setMarqueeIncrement(Length(36, Fixed)); // 36px. > break; > } > } else { >- Length marqueeLength = convertToIntLength(primitiveValue, style(), m_rootElementStyle); >+ Length marqueeLength = convertToIntLength(primitiveValue, state.m_style.get(), state.m_rootElementStyle); > if (!marqueeLength.isUndefined()) >- m_style->setMarqueeIncrement(marqueeLength); >+ state.m_style->setMarqueeIncrement(marqueeLength); > } > return; > } >@@ -3508,11 +3510,11 @@ void StyleResolver::applyProperty(CSSPropertyID id, CSSValue* value) > if (!primitiveValue) > return; > if (primitiveValue->getIdent() == CSSValueAuto) >- m_style->setLocale(nullAtom); >+ state.m_style->setLocale(nullAtom); > else >- m_style->setLocale(primitiveValue->getStringValue()); >- FontDescription fontDescription = m_style->fontDescription(); >- fontDescription.setScript(localeToScriptCodeForFontSelection(m_style->locale())); >+ state.m_style->setLocale(primitiveValue->getStringValue()); >+ FontDescription fontDescription = state.m_style->fontDescription(); >+ fontDescription.setScript(localeToScriptCodeForFontSelection(state.m_style->locale())); > setFontDescription(fontDescription); > return; > } >@@ -3531,7 +3533,7 @@ void StyleResolver::applyProperty(CSSPropertyID id, CSSValue* value) > return; > > if (primitiveValue->getIdent() == CSSValueNone) { >- m_style->setDashboardRegions(RenderStyle::noneDashboardRegions()); >+ state.m_style->setDashboardRegions(RenderStyle::noneDashboardRegions()); > return; > } > >@@ -3541,10 +3543,10 @@ void StyleResolver::applyProperty(CSSPropertyID id, CSSValue* value) > > DashboardRegion* first = region; > while (region) { >- Length top = convertToIntLength(region->top(), style(), m_rootElementStyle); >- Length right = convertToIntLength(region->right(), style(), m_rootElementStyle); >- Length bottom = convertToIntLength(region->bottom(), style(), m_rootElementStyle); >- Length left = convertToIntLength(region->left(), style(), m_rootElementStyle); >+ Length top = convertToIntLength(region->top(), state.m_style, state.m_rootElementStyle); >+ Length right = convertToIntLength(region->right(), state.m_style, state.m_rootElementStyle); >+ Length bottom = convertToIntLength(region->bottom(), state.m_style, state.m_rootElementStyle); >+ Length left = convertToIntLength(region->left(), state.m_style, state.m_rootElementStyle); > > if (top.isUndefined()) > top = Length(); >@@ -3556,13 +3558,13 @@ void StyleResolver::applyProperty(CSSPropertyID id, CSSValue* value) > left = Length(); > > if (region->m_isCircle) >- m_style->setDashboardRegion(StyleDashboardRegion::Circle, region->m_label, top, right, bottom, left, region == first ? false : true); >+ state.m_style->setDashboardRegion(StyleDashboardRegion::Circle, region->m_label, top, right, bottom, left, region == first ? false : true); > else if (region->m_isRectangle) >- m_style->setDashboardRegion(StyleDashboardRegion::Rectangle, region->m_label, top, right, bottom, left, region == first ? false : true); >+ state.m_style->setDashboardRegion(StyleDashboardRegion::Rectangle, region->m_label, top, right, bottom, left, region == first ? false : true); > region = region->m_next.get(); > } > >- m_element->document()->setHasAnnotatedRegions(true); >+ state.m_element->document()->setHasAnnotatedRegions(true); > > return; > } >@@ -3571,8 +3573,8 @@ void StyleResolver::applyProperty(CSSPropertyID id, CSSValue* value) > case CSSPropertyWebkitAppRegion: { > if (!primitiveValue || !primitiveValue->getIdent()) > return; >- m_style->setDraggableRegionMode(primitiveValue->getIdent() == CSSValueDrag ? DraggableRegionDrag : DraggableRegionNoDrag); >- m_element->document()->setHasAnnotatedRegions(true); >+ state.m_style->setDraggableRegionMode(primitiveValue->getIdent() == CSSValueDrag ? DraggableRegionDrag : DraggableRegionNoDrag); >+ state.m_element->document()->setHasAnnotatedRegions(true); > return; > } > #endif >@@ -3588,21 +3590,21 @@ void StyleResolver::applyProperty(CSSPropertyID id, CSSValue* value) > result *= 3; > else if (primitiveValue->getIdent() == CSSValueThick) > result *= 5; >- width = CSSPrimitiveValue::create(result, CSSPrimitiveValue::CSS_EMS)->computeLength<float>(style(), m_rootElementStyle, zoomFactor); >+ width = CSSPrimitiveValue::create(result, CSSPrimitiveValue::CSS_EMS)->computeLength<float>(state.m_style.get(), state.m_rootElementStyle, zoomFactor); > break; > } > default: >- width = primitiveValue->computeLength<float>(style(), m_rootElementStyle, zoomFactor); >+ width = primitiveValue->computeLength<float>(state.m_style.get(), state.m_rootElementStyle, zoomFactor); > break; > } >- m_style->setTextStrokeWidth(width); >+ state.m_style->setTextStrokeWidth(width); > return; > } > case CSSPropertyWebkitTransform: { > HANDLE_INHERIT_AND_INITIAL(transform, Transform); > TransformOperations operations; >- createTransformOperations(value, style(), m_rootElementStyle, operations); >- m_style->setTransform(operations); >+ createTransformOperations(value, state.m_style.get(), state.m_rootElementStyle, operations); >+ state.m_style->setTransform(operations); > return; > } > case CSSPropertyWebkitPerspective: { >@@ -3612,34 +3614,34 @@ void StyleResolver::applyProperty(CSSPropertyID id, CSSValue* value) > return; > > if (primitiveValue->getIdent() == CSSValueNone) { >- m_style->setPerspective(0); >+ state.m_style->setPerspective(0); > return; > } > > float perspectiveValue; > if (primitiveValue->isLength()) >- perspectiveValue = primitiveValue->computeLength<float>(style(), m_rootElementStyle, zoomFactor); >+ perspectiveValue = primitiveValue->computeLength<float>(state.m_style.get(), state.m_rootElementStyle, zoomFactor); > else if (primitiveValue->isNumber()) { > // For backward compatibility, treat valueless numbers as px. >- perspectiveValue = CSSPrimitiveValue::create(primitiveValue->getDoubleValue(), CSSPrimitiveValue::CSS_PX)->computeLength<float>(style(), m_rootElementStyle, zoomFactor); >+ perspectiveValue = CSSPrimitiveValue::create(primitiveValue->getDoubleValue(), CSSPrimitiveValue::CSS_PX)->computeLength<float>(state.m_style.get(), state.m_rootElementStyle, zoomFactor); > } else > return; > > if (perspectiveValue >= 0.0f) >- m_style->setPerspective(perspectiveValue); >+ state.m_style->setPerspective(perspectiveValue); > return; > } > case CSSPropertyWebkitAnimation: > if (isInitial) >- m_style->clearAnimations(); >+ state.m_style->clearAnimations(); > else if (isInherit) >- m_style->inheritAnimations(m_parentStyle->animations()); >+ state.m_style->inheritAnimations(state.m_parentStyle->animations()); > return; > case CSSPropertyWebkitTransition: > if (isInitial) >- m_style->clearTransitions(); >+ state.m_style->clearTransitions(); > else if (isInherit) >- m_style->inheritTransitions(m_parentStyle->transitions()); >+ state.m_style->inheritTransitions(state.m_parentStyle->transitions()); > return; > #if ENABLE(TOUCH_EVENTS) > case CSSPropertyWebkitTapHighlightColor: { >@@ -3648,7 +3650,7 @@ void StyleResolver::applyProperty(CSSPropertyID id, CSSValue* value) > break; > > Color col = colorFromPrimitiveValue(primitiveValue); >- m_style->setTapHighlightColor(col); >+ state.m_style->setTapHighlightColor(col); > return; > } > #endif >@@ -3657,7 +3659,7 @@ void StyleResolver::applyProperty(CSSPropertyID id, CSSValue* value) > HANDLE_INHERIT_AND_INITIAL(useTouchOverflowScrolling, UseTouchOverflowScrolling); > if (!primitiveValue) > break; >- m_style->setUseTouchOverflowScrolling(primitiveValue->getIdent() == CSSValueTouch); >+ state.m_style->setUseTouchOverflowScrolling(primitiveValue->getIdent() == CSSValueTouch); > return; > } > #endif >@@ -3700,7 +3702,7 @@ void StyleResolver::applyProperty(CSSPropertyID id, CSSValue* value) > case CSSPropertyWebkitMaxLogicalWidth: > case CSSPropertyWebkitMaxLogicalHeight: > { >- CSSPropertyID newId = CSSProperty::resolveDirectionAwareProperty(id, m_style->direction(), m_style->writingMode()); >+ CSSPropertyID newId = CSSProperty::resolveDirectionAwareProperty(id, state.m_style->direction(), state.m_style->writingMode()); > ASSERT(newId != id); > return applyProperty(newId, value); > } >@@ -3735,9 +3737,8 @@ void StyleResolver::applyProperty(CSSPropertyID id, CSSValue* value) > setWritingMode(*primitiveValue); > > // FIXME: It is not ok to modify document state while applying style. >- if (m_element && m_element == m_element->document()->documentElement()) >- m_element->document()->setWritingModeSetOnDocumentElement(true); >- >+ if (state.m_element && state.m_element == state.m_element->document()->documentElement()) >+ state.m_element->document()->setWritingModeSetOnDocumentElement(true); > return; > } > >@@ -3753,7 +3754,7 @@ void StyleResolver::applyProperty(CSSPropertyID id, CSSValue* value) > case CSSPropertyWebkitLineBoxContain: { > HANDLE_INHERIT_AND_INITIAL(lineBoxContain, LineBoxContain) > if (primitiveValue && primitiveValue->getIdent() == CSSValueNone) { >- m_style->setLineBoxContain(LineBoxContainNone); >+ state.m_style->setLineBoxContain(LineBoxContainNone); > return; > } > >@@ -3761,21 +3762,21 @@ void StyleResolver::applyProperty(CSSPropertyID id, CSSValue* value) > return; > > CSSLineBoxContainValue* lineBoxContainValue = static_cast<CSSLineBoxContainValue*>(value); >- m_style->setLineBoxContain(lineBoxContainValue->value()); >+ state.m_style->setLineBoxContain(lineBoxContainValue->value()); > return; > } > > // CSS Fonts Module Level 3 > case CSSPropertyWebkitFontFeatureSettings: { > if (primitiveValue && primitiveValue->getIdent() == CSSValueNormal) { >- setFontDescription(m_style->fontDescription().makeNormalFeatureSettings()); >+ setFontDescription(state.m_style->fontDescription().makeNormalFeatureSettings()); > return; > } > > if (!value->isValueList()) > return; > >- FontDescription fontDescription = m_style->fontDescription(); >+ FontDescription fontDescription = state.m_style->fontDescription(); > CSSValueList* list = static_cast<CSSValueList*>(value); > RefPtr<FontFeatureSettings> settings = FontFeatureSettings::create(); > int len = list->length(); >@@ -3795,23 +3796,23 @@ void StyleResolver::applyProperty(CSSPropertyID id, CSSValue* value) > case CSSPropertyWebkitFilter: { > HANDLE_INHERIT_AND_INITIAL(filter, Filter); > FilterOperations operations; >- if (createFilterOperations(value, style(), m_rootElementStyle, operations)) >- m_style->setFilter(operations); >+ if (createFilterOperations(value, state.m_style.get(), state.m_rootElementStyle, operations)) >+ state.m_style->setFilter(operations); > return; > } > #endif > case CSSPropertyWebkitGridColumns: { > Vector<GridTrackSize> trackSizes; >- if (!createGridTrackList(value, trackSizes, this)) >+ if (!createGridTrackList(value, trackSizes, state)) > return; >- m_style->setGridColumns(trackSizes); >+ state.m_style->setGridColumns(trackSizes); > return; > } > case CSSPropertyWebkitGridRows: { > Vector<GridTrackSize> trackSizes; >- if (!createGridTrackList(value, trackSizes, this)) >+ if (!createGridTrackList(value, trackSizes, state)) > return; >- m_style->setGridRows(trackSizes); >+ state.m_style->setGridRows(trackSizes); > return; > } > >@@ -3819,14 +3820,14 @@ void StyleResolver::applyProperty(CSSPropertyID id, CSSValue* value) > GridPosition column; > if (!createGridPosition(value, column)) > return; >- m_style->setGridItemColumn(column); >+ state.m_style->setGridItemColumn(column); > return; > } > case CSSPropertyWebkitGridRow: { > GridPosition row; > if (!createGridPosition(value, row)) > return; >- m_style->setGridItemRow(row); >+ state.m_style->setGridItemRow(row); > return; > } > // These properties are implemented in the StyleBuilder lookup table. >@@ -4148,14 +4149,14 @@ PassRefPtr<StyleImage> StyleResolver::cachedOrPendingFromValue(CSSPropertyID pro > { > RefPtr<StyleImage> image = value->cachedOrPendingImage(); > if (image && image->isPendingImage()) >- m_pendingImageProperties.set(property, value); >+ m_state.m_pendingImageProperties.set(property, value); > return image.release(); > } > > PassRefPtr<StyleImage> StyleResolver::generatedOrPendingFromValue(CSSPropertyID property, CSSImageGeneratorValue* value) > { > if (value->isPending()) { >- m_pendingImageProperties.set(property, value); >+ m_state.m_pendingImageProperties.set(property, value); > return StylePendingImage::create(value); > } > return StyleGeneratedImage::create(value); >@@ -4166,7 +4167,7 @@ PassRefPtr<StyleImage> StyleResolver::setOrPendingFromValue(CSSPropertyID proper > { > RefPtr<StyleImage> image = value->cachedOrPendingImageSet(document()); > if (image && image->isPendingImage()) >- m_pendingImageProperties.set(property, value); >+ m_state.m_pendingImageProperties.set(property, value); > return image.release(); > } > #endif >@@ -4175,18 +4176,20 @@ PassRefPtr<StyleImage> StyleResolver::cursorOrPendingFromValue(CSSPropertyID pro > { > RefPtr<StyleImage> image = value->cachedOrPendingImage(document()); > if (image && image->isPendingImage()) >- m_pendingImageProperties.set(property, value); >+ m_state.m_pendingImageProperties.set(property, value); > return image.release(); > } > > void StyleResolver::checkForTextSizeAdjust() > { >- if (m_style->textSizeAdjust()) >+ RenderStyle* style = m_state.m_style.get(); >+ >+ if (style->textSizeAdjust()) > return; > >- FontDescription newFontDescription(m_style->fontDescription()); >+ FontDescription newFontDescription(style->fontDescription()); > newFontDescription.setComputedSize(newFontDescription.specifiedSize()); >- m_style->setFontDescription(newFontDescription); >+ style->setFontDescription(newFontDescription); > } > > void StyleResolver::checkForZoomChange(RenderStyle* style, RenderStyle* parentStyle) >@@ -4251,15 +4254,15 @@ void StyleResolver::initializeFontStyle(Settings* settings) > } > fontDescription.setKeywordSize(CSSValueMedium - CSSValueXxSmall + 1); > setFontSize(fontDescription, fontSizeForKeyword(document(), CSSValueMedium, false)); >- m_style->setLineHeight(RenderStyle::initialLineHeight()); >- m_lineHeightValue = 0; >+ m_state.m_style->setLineHeight(RenderStyle::initialLineHeight()); >+ m_state.m_lineHeightValue = 0; > setFontDescription(fontDescription); > } > > void StyleResolver::setFontSize(FontDescription& fontDescription, float size) > { > fontDescription.setSpecifiedSize(size); >- fontDescription.setComputedSize(getComputedSizeFromSpecifiedSize(document(), m_style.get(), fontDescription.isAbsoluteSize(), size, useSVGZoomRules())); >+ fontDescription.setComputedSize(getComputedSizeFromSpecifiedSize(document(), m_state.m_style.get(), fontDescription.isAbsoluteSize(), size, useSVGZoomRules())); > } > > float StyleResolver::getComputedSizeFromSpecifiedSize(Document* document, RenderStyle* style, bool isAbsoluteSize, float specifiedSize, bool useSVGZoomRules) >@@ -4462,20 +4465,21 @@ Color StyleResolver::colorFromPrimitiveValue(CSSPrimitiveValue* value, bool forV > if (value->isRGBColor()) > return Color(value->getRGBA32Value()); > >+ const State& state = m_state; > int ident = value->getIdent(); > switch (ident) { > case 0: > return Color(); > case CSSValueWebkitText: >- return m_element->document()->textColor(); >+ return state.m_element->document()->textColor(); > case CSSValueWebkitLink: >- return (m_element->isLink() && forVisitedLink) ? m_element->document()->visitedLinkColor() : m_element->document()->linkColor(); >+ return (state.m_element->isLink() && forVisitedLink) ? state.m_element->document()->visitedLinkColor() : state.m_element->document()->linkColor(); > case CSSValueWebkitActivelink: >- return m_element->document()->activeLinkColor(); >+ return state.m_element->document()->activeLinkColor(); > case CSSValueWebkitFocusRingColor: > return RenderTheme::focusRingColor(); > case CSSValueCurrentcolor: >- return m_style->color(); >+ return state.m_style->color(); > default: > return colorForCSSValue(ident); > } >@@ -4809,17 +4813,18 @@ static FilterOperation::OperationType filterOperationForType(WebKitCSSFilterValu > #if ENABLE(CSS_FILTERS) && ENABLE(SVG) > void StyleResolver::loadPendingSVGDocuments() > { >- if (!m_style->hasFilter() || m_pendingSVGDocuments.isEmpty()) >+ State& state = m_state; >+ if (!state.m_style->hasFilter() || state.m_pendingSVGDocuments.isEmpty()) > return; > >- CachedResourceLoader* cachedResourceLoader = m_element->document()->cachedResourceLoader(); >- Vector<RefPtr<FilterOperation> >& filterOperations = m_style->mutableFilter().operations(); >+ CachedResourceLoader* cachedResourceLoader = state.m_element->document()->cachedResourceLoader(); >+ Vector<RefPtr<FilterOperation> >& filterOperations = state.m_style->mutableFilter().operations(); > for (unsigned i = 0; i < filterOperations.size(); ++i) { > RefPtr<FilterOperation> filterOperation = filterOperations.at(i); > if (filterOperation->getOperationType() == FilterOperation::REFERENCE) { > ReferenceFilterOperation* referenceFilter = static_cast<ReferenceFilterOperation*>(filterOperation.get()); > >- WebKitCSSSVGDocumentValue* value = m_pendingSVGDocuments.get(referenceFilter).get(); >+ WebKitCSSSVGDocumentValue* value = state.m_pendingSVGDocuments.get(referenceFilter).get(); > if (!value) > continue; > CachedSVGDocument* cachedDocument = value->load(cachedResourceLoader); >@@ -4830,7 +4835,7 @@ void StyleResolver::loadPendingSVGDocuments() > referenceFilter->setCachedSVGDocumentReference(adoptPtr(new CachedSVGDocumentReference(cachedDocument))); > } > } >- m_pendingSVGDocuments.clear(); >+ state.m_pendingSVGDocuments.clear(); > } > #endif > >@@ -4846,18 +4851,18 @@ StyleShader* StyleResolver::cachedOrPendingStyleShaderFromValue(WebKitCSSShaderV > { > StyleShader* shader = value->cachedOrPendingShader(); > if (shader && shader->isPendingShader()) >- m_hasPendingShaders = true; >+ m_state.m_hasPendingShaders = true; > return shader; > } > > void StyleResolver::loadPendingShaders() > { >- if (!m_style->hasFilter() || !m_hasPendingShaders) >+ if (!m_state.m_style->hasFilter() || !m_state.m_hasPendingShaders) > return; > >- CachedResourceLoader* cachedResourceLoader = m_element->document()->cachedResourceLoader(); >+ CachedResourceLoader* cachedResourceLoader = m_state.m_element->document()->cachedResourceLoader(); > >- Vector<RefPtr<FilterOperation> >& filterOperations = m_style->mutableFilter().operations(); >+ Vector<RefPtr<FilterOperation> >& filterOperations = m_state.m_style->mutableFilter().operations(); > for (unsigned i = 0; i < filterOperations.size(); ++i) { > RefPtr<FilterOperation> filterOperation = filterOperations.at(i); > if (filterOperation->getOperationType() == FilterOperation::CUSTOM) { >@@ -4874,7 +4879,7 @@ void StyleResolver::loadPendingShaders() > } > } > } >- m_hasPendingShaders = false; >+ m_state.m_hasPendingShaders = false; > } > > static bool sortParametersByNameComparator(const RefPtr<CustomFilterParameter>& a, const RefPtr<CustomFilterParameter>& b) >@@ -4916,7 +4921,7 @@ PassRefPtr<CustomFilterParameter> StyleResolver::parseCustomFilterTransformParam > { > RefPtr<CustomFilterTransformParameter> transformParameter = CustomFilterTransformParameter::create(name); > TransformOperations operations; >- createTransformOperations(values, style(), m_rootElementStyle, operations); >+ createTransformOperations(values, m_state.m_style.get(), m_state.m_rootElementStyle, operations); > transformParameter->setOperations(operations); > return transformParameter.release(); > } >@@ -5153,12 +5158,12 @@ bool StyleResolver::createFilterOperations(CSSValue* inValue, RenderStyle* style > continue; > > WebKitCSSSVGDocumentValue* svgDocumentValue = static_cast<WebKitCSSSVGDocumentValue*>(argument); >- KURL url = m_element->document()->completeURL(svgDocumentValue->url()); >+ KURL url = m_state.m_element->document()->completeURL(svgDocumentValue->url()); > > RefPtr<ReferenceFilterOperation> operation = ReferenceFilterOperation::create(svgDocumentValue->url(), url.fragmentIdentifier(), operationType); >- if (SVGURIReference::isExternalURIReference(svgDocumentValue->url(), m_element->document())) { >+ if (SVGURIReference::isExternalURIReference(svgDocumentValue->url(), m_state.m_element->document())) { > if (!svgDocumentValue->loadRequested()) >- m_pendingSVGDocuments.set(operation.get(), svgDocumentValue); >+ m_state.m_pendingSVGDocuments.set(operation.get(), svgDocumentValue); > else if (svgDocumentValue->cachedSVGDocument()) > operation->setCachedSVGDocumentReference(adoptPtr(new CachedSVGDocumentReference(svgDocumentValue->cachedSVGDocument()))); > } >@@ -5262,7 +5267,7 @@ bool StyleResolver::createFilterOperations(CSSValue* inValue, RenderStyle* style > > PassRefPtr<StyleImage> StyleResolver::loadPendingImage(StylePendingImage* pendingImage) > { >- CachedResourceLoader* cachedResourceLoader = m_element->document()->cachedResourceLoader(); >+ CachedResourceLoader* cachedResourceLoader = m_state.m_element->document()->cachedResourceLoader(); > > if (pendingImage->cssImageValue()) { > CSSImageValue* imageValue = pendingImage->cssImageValue(); >@@ -5292,23 +5297,23 @@ PassRefPtr<StyleImage> StyleResolver::loadPendingImage(StylePendingImage* pendin > > void StyleResolver::loadPendingImages() > { >- if (m_pendingImageProperties.isEmpty()) >+ if (m_state.m_pendingImageProperties.isEmpty()) > return; > >- PendingImagePropertyMap::const_iterator::Keys end = m_pendingImageProperties.end().keys(); >- for (PendingImagePropertyMap::const_iterator::Keys it = m_pendingImageProperties.begin().keys(); it != end; ++it) { >+ PendingImagePropertyMap::const_iterator::Keys end = m_state.m_pendingImageProperties.end().keys(); >+ for (PendingImagePropertyMap::const_iterator::Keys it = m_state.m_pendingImageProperties.begin().keys(); it != end; ++it) { > CSSPropertyID currentProperty = *it; > > switch (currentProperty) { > case CSSPropertyBackgroundImage: { >- for (FillLayer* backgroundLayer = m_style->accessBackgroundLayers(); backgroundLayer; backgroundLayer = backgroundLayer->next()) { >+ for (FillLayer* backgroundLayer = m_state.m_style->accessBackgroundLayers(); backgroundLayer; backgroundLayer = backgroundLayer->next()) { > if (backgroundLayer->image() && backgroundLayer->image()->isPendingImage()) > backgroundLayer->setImage(loadPendingImage(static_cast<StylePendingImage*>(backgroundLayer->image()))); > } > break; > } > case CSSPropertyContent: { >- for (ContentData* contentData = const_cast<ContentData*>(m_style->contentData()); contentData; contentData = contentData->next()) { >+ for (ContentData* contentData = const_cast<ContentData*>(m_state.m_style->contentData()); contentData; contentData = contentData->next()) { > if (contentData->isImage()) { > StyleImage* image = static_cast<ImageContentData*>(contentData)->image(); > if (image->isPendingImage()) { >@@ -5321,7 +5326,7 @@ void StyleResolver::loadPendingImages() > break; > } > case CSSPropertyCursor: { >- if (CursorList* cursorList = m_style->cursors()) { >+ if (CursorList* cursorList = m_state.m_style->cursors()) { > for (size_t i = 0; i < cursorList->size(); ++i) { > CursorData& currentCursor = cursorList->at(i); > if (StyleImage* image = currentCursor.image()) { >@@ -5333,17 +5338,17 @@ void StyleResolver::loadPendingImages() > break; > } > case CSSPropertyListStyleImage: { >- if (m_style->listStyleImage() && m_style->listStyleImage()->isPendingImage()) >- m_style->setListStyleImage(loadPendingImage(static_cast<StylePendingImage*>(m_style->listStyleImage()))); >+ if (m_state.m_style->listStyleImage() && m_state.m_style->listStyleImage()->isPendingImage()) >+ m_state.m_style->setListStyleImage(loadPendingImage(static_cast<StylePendingImage*>(m_state.m_style->listStyleImage()))); > break; > } > case CSSPropertyBorderImageSource: { >- if (m_style->borderImageSource() && m_style->borderImageSource()->isPendingImage()) >- m_style->setBorderImageSource(loadPendingImage(static_cast<StylePendingImage*>(m_style->borderImageSource()))); >+ if (m_state.m_style->borderImageSource() && m_state.m_style->borderImageSource()->isPendingImage()) >+ m_state.m_style->setBorderImageSource(loadPendingImage(static_cast<StylePendingImage*>(m_state.m_style->borderImageSource()))); > break; > } > case CSSPropertyWebkitBoxReflect: { >- if (StyleReflection* reflection = m_style->boxReflect()) { >+ if (StyleReflection* reflection = m_state.m_style->boxReflect()) { > const NinePieceImage& maskImage = reflection->mask(); > if (maskImage.image() && maskImage.image()->isPendingImage()) { > RefPtr<StyleImage> loadedImage = loadPendingImage(static_cast<StylePendingImage*>(maskImage.image())); >@@ -5353,12 +5358,12 @@ void StyleResolver::loadPendingImages() > break; > } > case CSSPropertyWebkitMaskBoxImageSource: { >- if (m_style->maskBoxImageSource() && m_style->maskBoxImageSource()->isPendingImage()) >- m_style->setMaskBoxImageSource(loadPendingImage(static_cast<StylePendingImage*>(m_style->maskBoxImageSource()))); >+ if (m_state.m_style->maskBoxImageSource() && m_state.m_style->maskBoxImageSource()->isPendingImage()) >+ m_state.m_style->setMaskBoxImageSource(loadPendingImage(static_cast<StylePendingImage*>(m_state.m_style->maskBoxImageSource()))); > break; > } > case CSSPropertyWebkitMaskImage: { >- for (FillLayer* maskLayer = m_style->accessMaskLayers(); maskLayer; maskLayer = maskLayer->next()) { >+ for (FillLayer* maskLayer = m_state.m_style->accessMaskLayers(); maskLayer; maskLayer = maskLayer->next()) { > if (maskLayer->image() && maskLayer->image()->isPendingImage()) > maskLayer->setImage(loadPendingImage(static_cast<StylePendingImage*>(maskLayer->image()))); > } >@@ -5369,7 +5374,7 @@ void StyleResolver::loadPendingImages() > } > } > >- m_pendingImageProperties.clear(); >+ m_state.m_pendingImageProperties.clear(); > } > > void StyleResolver::loadPendingResources() >@@ -5432,7 +5437,6 @@ void MediaQueryResult::reportMemoryUsage(MemoryObjectInfo* memoryObjectInfo) con > void StyleResolver::reportMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const > { > MemoryClassInfo info(memoryObjectInfo, this, WebCoreMemoryTypes::CSS); >- info.addMember(m_style); > info.addMember(m_authorStyle); > info.addMember(m_userStyle); > info.addMember(m_features); >@@ -5441,33 +5445,20 @@ void StyleResolver::reportMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const > info.addMember(m_keyframesRuleMap); > info.addMember(m_matchedPropertiesCache); > info.addMember(m_matchedPropertiesCacheSweepTimer); >- info.addMember(m_matchedRules); > >- info.addMember(m_ruleList); >- info.addMember(m_pendingImageProperties); > info.addMember(m_medium); > info.addMember(m_rootDefaultStyle); > info.addMember(m_document); > >- // FIXME: pointer to RenderStyle could point to an already deleted object. >- info.ignoreMember(m_parentStyle); >- info.ignoreMember(m_rootElementStyle); >- >- info.addMember(m_element); >- info.addMember(m_styledElement); >- info.addMember(m_regionForStyling); >- info.addMember(m_parentNode); >- info.addMember(m_lineHeightValue); > info.addMember(m_fontSelector); > info.addMember(m_viewportDependentMediaQueryResults); > info.ignoreMember(m_styleBuilder); > info.addMember(m_styleRuleToCSSOMWrapperMap); > info.addMember(m_styleSheetCSSOMWrapperSet); >-#if ENABLE(CSS_FILTERS) && ENABLE(SVG) >- info.addMember(m_pendingSVGDocuments); >-#endif > info.addMember(m_scopeResolver); > >+ info.addMember(m_state); >+ > // FIXME: move this to a place where it would be called only once? > info.addMember(defaultStyle); > info.addMember(defaultQuirksStyle); >diff --git a/Source/WebCore/css/StyleResolver.h b/Source/WebCore/css/StyleResolver.h >index 33366c767911e73019f9494bceb4dc8b0c874758..776bdd3ae78a41be9ba44c4f64867694dbadf80e 100644 >--- a/Source/WebCore/css/StyleResolver.h >+++ b/Source/WebCore/css/StyleResolver.h >@@ -23,6 +23,7 @@ > #define StyleResolver_h > > #include "CSSRule.h" >+#include "CSSRuleList.h" > #include "CSSToStyleMap.h" > #include "CSSValueList.h" > #include "LinkHash.h" >@@ -36,6 +37,9 @@ > #include "StyleInheritedData.h" > #include "StyleScopeResolver.h" > #include "ViewportStyleResolver.h" >+#if ENABLE(CSS_FILTERS) && ENABLE(SVG) >+#include "WebKitCSSSVGDocumentValue.h" >+#endif > #include <wtf/HashMap.h> > #include <wtf/HashSet.h> > #include <wtf/RefPtr.h> >@@ -161,20 +165,20 @@ public: > > static PassRefPtr<RenderStyle> styleForDocument(Document*, CSSFontSelector* = 0); > >- RenderStyle* style() const { return m_style.get(); } >- RenderStyle* parentStyle() const { return m_parentStyle; } >- RenderStyle* rootElementStyle() const { return m_rootElementStyle; } >- Element* element() const { return m_element; } >+ RenderStyle* style() const { return m_state.m_style.get(); } >+ RenderStyle* parentStyle() const { return m_state.m_parentStyle; } >+ RenderStyle* rootElementStyle() const { return m_state.m_rootElementStyle; } >+ Element* element() const { return m_state.m_element; } > Document* document() const { return m_document; } > const FontDescription& fontDescription() { return style()->fontDescription(); } > const FontDescription& parentFontDescription() { return parentStyle()->fontDescription(); } >- void setFontDescription(const FontDescription& fontDescription) { m_fontDirty |= style()->setFontDescription(fontDescription); } >- void setZoom(float f) { m_fontDirty |= style()->setZoom(f); } >- void setEffectiveZoom(float f) { m_fontDirty |= style()->setEffectiveZoom(f); } >- void setTextSizeAdjust(bool b) { m_fontDirty |= style()->setTextSizeAdjust(b); } >- void setWritingMode(WritingMode writingMode) { m_fontDirty |= style()->setWritingMode(writingMode); } >- void setTextOrientation(TextOrientation textOrientation) { m_fontDirty |= style()->setTextOrientation(textOrientation); } >- bool hasParentNode() const { return m_parentNode; } >+ void setFontDescription(const FontDescription& fontDescription) { m_state.m_fontDirty |= style()->setFontDescription(fontDescription); } >+ void setZoom(float f) { m_state.m_fontDirty |= style()->setZoom(f); } >+ void setEffectiveZoom(float f) { m_state.m_fontDirty |= style()->setEffectiveZoom(f); } >+ void setTextSizeAdjust(bool b) { m_state.m_fontDirty |= style()->setTextSizeAdjust(b); } >+ void setWritingMode(WritingMode writingMode) { m_state.m_fontDirty |= style()->setWritingMode(writingMode); } >+ void setTextOrientation(TextOrientation textOrientation) { m_state.m_fontDirty |= style()->setTextOrientation(textOrientation); } >+ bool hasParentNode() const { return m_state.m_parentNode; } > > void resetAuthorStyle(); > void appendAuthorStyleSheets(unsigned firstNew, const Vector<RefPtr<CSSStyleSheet> >&); >@@ -308,7 +312,7 @@ private: > > void adjustRenderStyle(RenderStyle* styleToAdjust, RenderStyle* parentStyle, Element*); > >- void addMatchedRule(const RuleData* rule) { m_matchedRules.append(rule); } >+ void addMatchedRule(const RuleData* rule) { m_state.m_matchedRules.append(rule); } > > struct RuleRange { > RuleRange(int& firstRuleIndex, int& lastRuleIndex): firstRuleIndex(firstRuleIndex), lastRuleIndex(lastRuleIndex) { } >@@ -418,15 +422,86 @@ private: > OwnPtr<RuleSet> m_siblingRuleSet; > OwnPtr<RuleSet> m_uncommonAttributeRuleSet; > >- bool m_hasUAAppearance; >- BorderData m_borderData; >- FillLayer m_backgroundData; >- Color m_backgroundColor; >- > typedef HashMap<AtomicStringImpl*, RefPtr<StyleRuleKeyframes> > KeyframesRuleMap; > KeyframesRuleMap m_keyframesRuleMap; > > public: >+ typedef HashMap<CSSPropertyID, RefPtr<CSSValue> > PendingImagePropertyMap; >+#if ENABLE(CSS_FILTERS) && ENABLE(SVG) >+ typedef HashMap<FilterOperation*, RefPtr<WebKitCSSSVGDocumentValue> > PendingSVGDocumentMap; >+#endif >+ >+ class State { >+ WTF_MAKE_NONCOPYABLE(State); >+ public: >+ State() >+ : m_element(0) >+ , m_styledElement(0) >+ , m_parentNode(0) >+ , m_parentStyle(0) >+ , m_rootElementStyle(0) >+ , m_regionForStyling(0) >+ , m_sameOriginOnly(false) >+ , m_pseudoStyle(NOPSEUDO) >+ , m_elementLinkState(NotInsideLink) >+ , m_distributedToInsertionPoint(false) >+ , m_elementAffectedByClassRules(false) >+ , m_applyPropertyToRegularStyle(true) >+ , m_applyPropertyToVisitedLinkStyle(false) >+#if ENABLE(CSS_SHADERS) >+ , m_hasPendingShaders(false) >+#endif >+ , m_lineHeightValue(0) >+ , m_fontDirty(false) >+ , m_hasUAAppearance(false) >+ , m_backgroundData(BackgroundFillLayer) { } >+ >+public: >+ // FIXME: to make it easier to review, these member variables are >+ // public. However we should add methods to access these variables. >+ Element* m_element; >+ RefPtr<RenderStyle> m_style; >+ StyledElement* m_styledElement; >+ ContainerNode* m_parentNode; >+ RenderStyle* m_parentStyle; >+ RenderStyle* m_rootElementStyle; >+ >+ RenderRegion* m_regionForStyling; >+ bool m_sameOriginOnly; >+ PseudoId m_pseudoStyle; >+ >+ EInsideLink m_elementLinkState; >+ >+ bool m_distributedToInsertionPoint; >+ >+ bool m_elementAffectedByClassRules; >+ >+ PseudoId m_dynamicPseudo; >+ >+ // A buffer used to hold the set of matched rules for an element, >+ // and a temporary buffer used for merge sorting. >+ Vector<const RuleData*, 32> m_matchedRules; >+ RefPtr<StaticCSSRuleList> m_ruleList; >+ >+ bool m_applyPropertyToRegularStyle; >+ bool m_applyPropertyToVisitedLinkStyle; >+ >+ PendingImagePropertyMap m_pendingImageProperties; >+#if ENABLE(CSS_SHADERS) >+ bool m_hasPendingShaders; >+#endif >+#if ENABLE(CSS_FILTERS) && ENABLE(SVG) >+ PendingSVGDocumentMap m_pendingSVGDocuments; >+#endif >+ CSSValue* m_lineHeightValue; >+ bool m_fontDirty; >+ >+ bool m_hasUAAppearance; >+ BorderData m_borderData; >+ FillLayer m_backgroundData; >+ Color m_backgroundColor; >+ }; >+ > static RenderStyle* styleNotYetAvailable() { return s_styleNotYetAvailable; } > > PassRefPtr<StyleImage> styleImage(CSSPropertyID, CSSValue*); >@@ -437,8 +512,8 @@ public: > #endif > PassRefPtr<StyleImage> cursorOrPendingFromValue(CSSPropertyID, CSSCursorImageValue*); > >- bool applyPropertyToRegularStyle() const { return m_applyPropertyToRegularStyle; } >- bool applyPropertyToVisitedLinkStyle() const { return m_applyPropertyToVisitedLinkStyle; } >+ bool applyPropertyToRegularStyle() const { return m_state.m_applyPropertyToRegularStyle; } >+ bool applyPropertyToVisitedLinkStyle() const { return m_state.m_applyPropertyToVisitedLinkStyle; } > > static Length convertToIntLength(CSSPrimitiveValue*, RenderStyle*, RenderStyle* rootStyle, double multiplier = 1); > static Length convertToFloatLength(CSSPrimitiveValue*, RenderStyle*, RenderStyle* rootStyle, double multiplier = 1); >@@ -491,39 +566,18 @@ private: > > Timer<StyleResolver> m_matchedPropertiesCacheSweepTimer; > >- // A buffer used to hold the set of matched rules for an element, and a temporary buffer used for >- // merge sorting. >- Vector<const RuleData*, 32> m_matchedRules; >- >- RefPtr<StaticCSSRuleList> m_ruleList; >- >- typedef HashMap<CSSPropertyID, RefPtr<CSSValue> > PendingImagePropertyMap; >- PendingImagePropertyMap m_pendingImageProperties; >- > OwnPtr<MediaQueryEvaluator> m_medium; > RefPtr<RenderStyle> m_rootDefaultStyle; > >- PseudoId m_dynamicPseudo; >- PseudoId m_pseudoStyle; >- > Document* m_document; >+ // FIXME: Make SelectorChecker an on-stack object and >+ // move selectorChecker.mode() to State. >+ // selectorChecker.stringParsing() can be replaced with >+ // !document.inQuirksMode(). > SelectorChecker m_selectorChecker; > SelectorFilter m_selectorFilter; > >- RefPtr<RenderStyle> m_style; >- RenderStyle* m_parentStyle; >- RenderStyle* m_rootElementStyle; >- Element* m_element; >- StyledElement* m_styledElement; >- RenderRegion* m_regionForStyling; >- EInsideLink m_elementLinkState; >- bool m_elementAffectedByClassRules; >- ContainerNode* m_parentNode; >- CSSValue* m_lineHeightValue; >- bool m_fontDirty; > bool m_matchAuthorAndUserStyles; >- bool m_sameOriginOnly; >- bool m_distributedToInsertionPoint; > > RefPtr<CSSFontSelector> m_fontSelector; > Vector<OwnPtr<MediaQueryResult> > m_viewportDependentMediaQueryResults; >@@ -532,24 +586,16 @@ private: > RefPtr<ViewportStyleResolver> m_viewportStyleResolver; > #endif > >- bool m_applyPropertyToRegularStyle; >- bool m_applyPropertyToVisitedLinkStyle; > const StyleBuilder& m_styleBuilder; > > HashMap<StyleRule*, RefPtr<CSSStyleRule> > m_styleRuleToCSSOMWrapperMap; > HashSet<RefPtr<CSSStyleSheet> > m_styleSheetCSSOMWrapperSet; > >-#if ENABLE(CSS_SHADERS) >- bool m_hasPendingShaders; >-#endif >- >-#if ENABLE(CSS_FILTERS) && ENABLE(SVG) >- HashMap<FilterOperation*, RefPtr<WebKitCSSSVGDocumentValue> > m_pendingSVGDocuments; >-#endif >- > OwnPtr<StyleScopeResolver> m_scopeResolver; > CSSToStyleMap m_styleMap; > >+ State m_state; >+ > friend class StyleBuilder; > friend bool operator==(const MatchedProperties&, const MatchedProperties&); > friend bool operator!=(const MatchedProperties&, const MatchedProperties&);
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Formatted Diff
|
Diff
Attachments on
bug 96421
:
163428
|
184683
|
184684
|
184695
|
184702
|
184714
|
184927
|
185211
|
185416
|
185427
|
185696
|
185930
|
185933
|
186284
|
186303