Index: Source/core/css/resolver/StyleResolver.cpp |
diff --git a/Source/core/css/resolver/StyleResolver.cpp b/Source/core/css/resolver/StyleResolver.cpp |
index 28550e67db9a5df2dac7e6b32080e76d7740b332..e34c6a0c7b521208b2f6718a1bb996166becd4c8 100644 |
--- a/Source/core/css/resolver/StyleResolver.cpp |
+++ b/Source/core/css/resolver/StyleResolver.cpp |
@@ -374,61 +374,30 @@ StyleResolver::~StyleResolver() |
{ |
} |
-void StyleResolver::matchAuthorRulesForShadowHost(Element* element, ElementRuleCollector& collector, bool includeEmptyRules, WillBeHeapVector<RawPtrWillBeMember<ScopedStyleResolver>, 8>& resolvers, WillBeHeapVector<RawPtrWillBeMember<ScopedStyleResolver>, 8>& resolversInShadowTree) |
-{ |
- collector.clearMatchedRules(); |
- collector.matchedResult().ranges.lastAuthorRule = collector.matchedResult().matchedProperties.size() - 1; |
- |
- CascadeScope cascadeScope = 0; |
- CascadeOrder cascadeOrder = 0; |
- |
- for (int j = resolversInShadowTree.size() - 1; j >= 0; --j) |
- resolversInShadowTree.at(j)->collectMatchingAuthorRules(collector, includeEmptyRules, cascadeScope, cascadeOrder++); |
- |
- if (resolvers.isEmpty() || resolvers.first()->treeScope() != element->treeScope()) |
- ++cascadeScope; |
- cascadeOrder += resolvers.size(); |
- for (unsigned i = 0; i < resolvers.size(); ++i) |
- resolvers.at(i)->collectMatchingAuthorRules(collector, includeEmptyRules, cascadeScope++, --cascadeOrder); |
- |
- m_treeBoundaryCrossingRules.collectTreeBoundaryCrossingRules(element, collector, includeEmptyRules); |
- collector.sortAndTransferMatchedRules(); |
-} |
- |
void StyleResolver::matchAuthorRules(Element* element, ElementRuleCollector& collector, bool includeEmptyRules) |
{ |
collector.clearMatchedRules(); |
collector.matchedResult().ranges.lastAuthorRule = collector.matchedResult().matchedProperties.size() - 1; |
- if (document().styleEngine()->hasOnlyScopedResolverForDocument()) { |
- document().scopedStyleResolver()->collectMatchingAuthorRules(collector, includeEmptyRules, ignoreCascadeScope); |
- m_treeBoundaryCrossingRules.collectTreeBoundaryCrossingRules(element, collector, includeEmptyRules); |
- collector.sortAndTransferMatchedRules(); |
- return; |
- } |
+ CascadeOrder cascadeOrder = 0; |
- WillBeHeapVector<RawPtrWillBeMember<ScopedStyleResolver>, 8> resolvers; |
- resolveScopedStyles(element, resolvers); |
+ // FIXME: We should track host rules separately right now the SelectorChecker |
+ // is doing lots of checking to compensate for entering with rules that |
+ // shouldn't match in the :host/:host-context step below. |
+ // Match :host and :host-context rules. |
WillBeHeapVector<RawPtrWillBeMember<ScopedStyleResolver>, 8> resolversInShadowTree; |
collectScopedResolversForHostedShadowTrees(element, resolversInShadowTree); |
- if (!resolversInShadowTree.isEmpty()) { |
- matchAuthorRulesForShadowHost(element, collector, includeEmptyRules, resolvers, resolversInShadowTree); |
- return; |
- } |
- |
- if (resolvers.isEmpty()) |
- return; |
+ for (int j = resolversInShadowTree.size() - 1; j >= 0; --j) |
+ resolversInShadowTree[j]->collectMatchingAuthorRules(collector, includeEmptyRules, ignoreCascadeScope, ++cascadeOrder); |
- 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); |
- } |
+ // Match rules in your own scope (ShadowRoot or Document). |
+ if (ScopedStyleResolver* resolver = element->treeScope().scopedStyleResolver()) |
+ resolver->collectMatchingAuthorRules(collector, includeEmptyRules, ignoreCascadeScope, ++cascadeOrder); |
+ // Match /deep/, ::shadow and ::content rules. |
m_treeBoundaryCrossingRules.collectTreeBoundaryCrossingRules(element, collector, includeEmptyRules); |
+ |
collector.sortAndTransferMatchedRules(); |
} |
@@ -999,21 +968,6 @@ bool StyleResolver::applyAnimatedProperties(StyleResolverState& state, const Ele |
return true; |
} |
-static inline ScopedStyleResolver* scopedResolverFor(const Element* element) |
-{ |
- for (TreeScope* treeScope = &element->treeScope(); treeScope; treeScope = treeScope->parentTreeScope()) { |
- if (ScopedStyleResolver* scopedStyleResolver = treeScope->scopedStyleResolver()) |
- return scopedStyleResolver; |
- } |
- return 0; |
-} |
- |
-void StyleResolver::resolveScopedStyles(const Element* element, WillBeHeapVector<RawPtrWillBeMember<ScopedStyleResolver>, 8>& resolvers) |
-{ |
- for (ScopedStyleResolver* scopedResolver = scopedResolverFor(element); scopedResolver; scopedResolver = scopedResolver->parent()) |
- resolvers.append(scopedResolver); |
-} |
- |
void StyleResolver::collectScopedResolversForHostedShadowTrees(const Element* element, WillBeHeapVector<RawPtrWillBeMember<ScopedStyleResolver>, 8>& resolvers) |
{ |
ElementShadow* shadow = element->shadow(); |
@@ -1031,16 +985,10 @@ void StyleResolver::collectScopedResolversForHostedShadowTrees(const Element* el |
void StyleResolver::styleTreeResolveScopedKeyframesRules(const Element* element, WillBeHeapVector<RawPtrWillBeMember<ScopedStyleResolver>, 8>& resolvers) |
{ |
- TreeScope& treeScope = element->treeScope(); |
- |
- // Add resolvers for shadow roots hosted by the given element. |
collectScopedResolversForHostedShadowTrees(element, resolvers); |
- // Add resolvers while walking up DOM tree from the given element. |
- for (ScopedStyleResolver* scopedResolver = scopedResolverFor(element); scopedResolver; scopedResolver = scopedResolver->parent()) { |
- if (scopedResolver->treeScope() == treeScope) |
- resolvers.append(scopedResolver); |
- } |
+ if (ScopedStyleResolver* scopedResolver = element->treeScope().scopedStyleResolver()) |
+ resolvers.append(scopedResolver); |
} |
template <StyleResolver::StyleApplicationPass pass> |