Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(580)

Unified Diff: Source/core/css/resolver/StyleResolver.cpp

Issue 751593002: Removed add/removeScopedStyleResolver from StyleEngine (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 6 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Source/core/animation/css/CSSAnimations.cpp ('k') | Source/core/dom/ProcessingInstruction.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/css/resolver/StyleResolver.cpp
diff --git a/Source/core/css/resolver/StyleResolver.cpp b/Source/core/css/resolver/StyleResolver.cpp
index cd4f778df1e55209db6b091cf0ee98cfd6374952..130ed33e1e1f89a06306d842c0c95a1377c0c212 100644
--- a/Source/core/css/resolver/StyleResolver.cpp
+++ b/Source/core/css/resolver/StyleResolver.cpp
@@ -181,10 +181,7 @@ void StyleResolver::appendCSSStyleSheet(CSSStyleSheet& cssSheet)
if (!treeScope)
return;
- ScopedStyleResolver& resolver = treeScope->ensureScopedStyleResolver();
- document().styleEngine()->addScopedStyleResolver(&resolver);
- unsigned index = resolver.appendCSSStyleSheet(&cssSheet);
-
+ unsigned index = treeScope->ensureScopedStyleResolver().appendCSSStyleSheet(&cssSheet);
addRulesFromSheet(cssSheet, treeScope, index);
}
@@ -239,10 +236,9 @@ void StyleResolver::resetRuleFeatures()
void StyleResolver::processScopedRules(const RuleSet& authorRules, CSSStyleSheet* parentStyleSheet, unsigned parentIndex, ContainerNode& scope)
{
const WillBeHeapVector<RawPtrWillBeMember<StyleRuleKeyframes> > keyframesRules = authorRules.keyframesRules();
- ScopedStyleResolver* resolver = &scope.treeScope().ensureScopedStyleResolver();
- document().styleEngine()->addScopedStyleResolver(resolver);
+ ScopedStyleResolver& resolver = scope.treeScope().ensureScopedStyleResolver();
for (unsigned i = 0; i < keyframesRules.size(); ++i)
- resolver->addKeyframeStyle(keyframesRules[i]);
+ resolver.addKeyframeStyle(keyframesRules[i]);
m_treeBoundaryCrossingRules.addTreeBoundaryCrossingRules(authorRules, parentStyleSheet, parentIndex, scope);
@@ -263,14 +259,12 @@ void StyleResolver::resetAuthorStyle(TreeScope& treeScope)
return;
m_treeBoundaryCrossingRules.reset(&treeScope.rootNode());
-
resolver->resetAuthorStyle();
resetRuleFeatures();
if (treeScope.rootNode().isDocumentNode())
return;
// resolver is going to be freed below.
- document().styleEngine()->removeScopedStyleResolver(resolver);
treeScope.clearScopedStyleResolver();
}
@@ -401,8 +395,13 @@ void StyleResolver::matchAuthorRules(Element* element, ElementRuleCollector& col
collector.clearMatchedRules();
collector.matchedResult().ranges.lastAuthorRule = collector.matchedResult().matchedProperties.size() - 1;
- if (document().styleEngine()->hasOnlyScopedResolverForDocument()) {
- document().scopedStyleResolver()->collectMatchingAuthorRules(collector, includeEmptyRules, ignoreCascadeScope);
+ if (document().styleEngine()->onlyDocumentHasStyles()) {
+ ScopedStyleResolver* resolver = document().scopedStyleResolver();
+ if (!resolver)
+ return;
+ // If we have no resolver for a document, the document has no styles.
+ // We don't need to see any rules (including treeboundary crossing ones).
+ resolver->collectMatchingAuthorRules(collector, includeEmptyRules, ignoreCascadeScope);
m_treeBoundaryCrossingRules.collectTreeBoundaryCrossingRules(element, collector, includeEmptyRules);
collector.sortAndTransferMatchedRules();
return;
@@ -418,15 +417,14 @@ void StyleResolver::matchAuthorRules(Element* element, ElementRuleCollector& col
return;
}
- if (resolvers.isEmpty())
- return;
-
- CascadeScope cascadeScope = 0;
- CascadeOrder cascadeOrder = resolvers.size();
- for (unsigned i = 0; i < resolvers.size(); ++i, --cascadeOrder) {
- ScopedStyleResolver* resolver = resolvers.at(i);
- // FIXME: Need to clarify how to treat style scoped.
- resolver->collectMatchingAuthorRules(collector, includeEmptyRules, cascadeScope++, resolver->treeScope() == element->treeScope() && resolver->treeScope().rootNode().isShadowRoot() ? 0 : cascadeOrder);
+ if (!resolvers.isEmpty()) {
+ CascadeScope cascadeScope = 0;
+ CascadeOrder cascadeOrder = resolvers.size();
+ for (unsigned i = 0; i < resolvers.size(); ++i, --cascadeOrder) {
+ ScopedStyleResolver* resolver = resolvers.at(i);
+ // FIXME: Need to clarify how to treat style scoped.
+ resolver->collectMatchingAuthorRules(collector, includeEmptyRules, cascadeScope++, resolver->treeScope() == element->treeScope() && resolver->treeScope().rootNode().isShadowRoot() ? 0 : cascadeOrder);
+ }
}
m_treeBoundaryCrossingRules.collectTreeBoundaryCrossingRules(element, collector, includeEmptyRules);
« no previous file with comments | « Source/core/animation/css/CSSAnimations.cpp ('k') | Source/core/dom/ProcessingInstruction.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698