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

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

Issue 844963002: Refactor StyleResolver::matchAuthorRules. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@style-scoped-20150109
Patch Set: Rebased Created 5 years, 11 months 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/css/resolver/StyleResolver.h ('k') | Source/core/dom/StyleEngine.h » ('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 6600d1a17906d718c148f5e5ffad61cd46cc0def..1050228dee1659bd0fd76ba0c1d70ea1fffa3cd8 100644
--- a/Source/core/css/resolver/StyleResolver.cpp
+++ b/Source/core/css/resolver/StyleResolver.cpp
@@ -414,40 +414,24 @@ static inline ScopedStyleResolver* scopedResolverFor(const Element* element)
return treeScope->scopedStyleResolver();
}
-void StyleResolver::matchAuthorRulesForShadowHost(Element* element, ElementRuleCollector& collector, bool includeEmptyRules, WillBeHeapVector<RawPtrWillBeMember<ScopedStyleResolver>, 8>& resolversInShadowTree)
-{
- CascadeOrder cascadeOrder = 0;
- for (int j = resolversInShadowTree.size() - 1; j >= 0; --j)
- resolversInShadowTree.at(j)->collectMatchingShadowHostRules(collector, includeEmptyRules, cascadeOrder++);
-
- if (ScopedStyleResolver* resolver = scopedResolverFor(element))
- resolver->collectMatchingAuthorRules(collector, includeEmptyRules, cascadeOrder);
-}
-
void StyleResolver::matchAuthorRules(Element* element, ElementRuleCollector& collector, bool includeEmptyRules)
{
collector.clearMatchedRules();
collector.matchedResult().ranges.lastAuthorRule = collector.matchedResult().matchedProperties.size() - 1;
- if (document().styleEngine()->onlyDocumentHasStyles()) {
- ScopedStyleResolver* resolver = document().scopedStyleResolver();
- // 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).
- if (!resolver)
- return;
- resolver->collectMatchingAuthorRules(collector, includeEmptyRules);
- m_treeBoundaryCrossingRules.collectTreeBoundaryCrossingRules(element, collector, includeEmptyRules);
- collector.sortAndTransferMatchedRules();
- return;
- }
-
+ CascadeOrder cascadeOrder = 0;
WillBeHeapVector<RawPtrWillBeMember<ScopedStyleResolver>, 8> resolversInShadowTree;
collectScopedResolversForHostedShadowTrees(element, resolversInShadowTree);
- if (!resolversInShadowTree.isEmpty())
- matchAuthorRulesForShadowHost(element, collector, includeEmptyRules, resolversInShadowTree);
- else if (ScopedStyleResolver* resolver = scopedResolverFor(element))
- resolver->collectMatchingAuthorRules(collector, includeEmptyRules, resolver->treeScope().rootNode().isShadowRoot() ? 0 : 1);
+ // Apply :host and :host-context rules from inner scopes.
+ for (int j = resolversInShadowTree.size() - 1; j >= 0; --j)
+ resolversInShadowTree.at(j)->collectMatchingShadowHostRules(collector, includeEmptyRules, ++cascadeOrder);
+
+ // Apply normal rules from element scope.
+ if (ScopedStyleResolver* resolver = scopedResolverFor(element))
+ resolver->collectMatchingAuthorRules(collector, includeEmptyRules, ++cascadeOrder);
+
+ // Apply /deep/ and ::shadow rules from outer scopes, and ::content from inner.
m_treeBoundaryCrossingRules.collectTreeBoundaryCrossingRules(element, collector, includeEmptyRules);
collector.sortAndTransferMatchedRules();
}
« no previous file with comments | « Source/core/css/resolver/StyleResolver.h ('k') | Source/core/dom/StyleEngine.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698