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

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

Issue 206043009: Setup parent stylesheet for tree boundary crossing rules. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: compiles on oilpan Created 6 years, 9 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') | no next file » | 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 879b2d86b50438fb68c5f4107590aa8640eee24b..9393ed60d2628a997653a2fa432ec8456025d8ca 100644
--- a/Source/core/css/resolver/StyleResolver.cpp
+++ b/Source/core/css/resolver/StyleResolver.cpp
@@ -247,31 +247,21 @@ void StyleResolver::resetRuleFeatures()
m_needCollectFeatures = true;
}
-void StyleResolver::addTreeBoundaryCrossingRules(const WillBeHeapVector<MinimalRuleData>& rules, ContainerNode* scope)
-{
- for (unsigned i = 0; i < rules.size(); ++i) {
- const MinimalRuleData& info = rules[i];
- m_treeBoundaryCrossingRules.addRule(info.m_rule, info.m_selectorIndex, scope, info.m_flags);
- }
-}
-
-void StyleResolver::processScopedRules(const RuleSet& authorRules, const KURL& sheetBaseURL, ContainerNode* scope)
+void StyleResolver::processScopedRules(const RuleSet& authorRules, CSSStyleSheet* parentStyleSheet, ContainerNode& scope)
{
const WillBeHeapVector<RawPtrWillBeMember<StyleRuleKeyframes> > keyframesRules = authorRules.keyframesRules();
for (unsigned i = 0; i < keyframesRules.size(); ++i)
- ensureScopedStyleResolver(scope)->addKeyframeStyle(keyframesRules[i]);
+ ensureScopedStyleResolver(&scope)->addKeyframeStyle(keyframesRules[i]);
- addTreeBoundaryCrossingRules(authorRules.treeBoundaryCrossingRules(), scope);
+ m_treeBoundaryCrossingRules.addTreeBoundaryCrossingRules(authorRules, scope, parentStyleSheet);
// FIXME(BUG 72461): We don't add @font-face rules of scoped style sheets for the moment.
- if (!scope || scope->isDocumentNode()) {
+ if (scope.isDocumentNode()) {
const WillBeHeapVector<RawPtrWillBeMember<StyleRuleFontFace> > fontFaceRules = authorRules.fontFaceRules();
for (unsigned i = 0; i < fontFaceRules.size(); ++i)
addFontFaceRule(&m_document, document().styleEngine()->fontSelector(), fontFaceRules[i]);
if (fontFaceRules.size())
invalidateMatchedPropertiesCache();
- } else {
- addTreeBoundaryCrossingRules(authorRules.shadowDistributedRules(), scope);
}
}
@@ -283,7 +273,7 @@ void StyleResolver::resetAuthorStyle(const ContainerNode* scopingNode)
if (!resolver)
return;
- treeBoundaryCrossingRules().reset(scopingNode);
+ m_treeBoundaryCrossingRules.reset(scopingNode);
resolver->resetAuthorStyle();
resetRuleFeatures();
@@ -400,37 +390,6 @@ StyleResolver::~StyleResolver()
{
}
-inline void StyleResolver::collectTreeBoundaryCrossingRules(Element* element, ElementRuleCollector& collector, bool includeEmptyRules)
-{
- if (m_treeBoundaryCrossingRules.isEmpty())
- return;
-
- // When comparing rules declared in outer treescopes, outer's rules win.
- CascadeOrder outerCascadeOrder = m_treeBoundaryCrossingRules.size() + m_treeBoundaryCrossingRules.size();
- // When comparing rules declared in inner treescopes, inner's rules win.
- CascadeOrder innerCascadeOrder = m_treeBoundaryCrossingRules.size();
-
- for (DocumentOrderedList::iterator it = m_treeBoundaryCrossingRules.begin(); it != m_treeBoundaryCrossingRules.end(); ++it) {
- const ContainerNode* scopingNode = toContainerNode(*it);
- RuleSet* ruleSet = m_treeBoundaryCrossingRules.ruleSetScopedBy(scopingNode);
- unsigned boundaryBehavior = SelectorChecker::ScopeContainsLastMatchedElement;
- bool isInnerTreeScope = element->treeScope().isInclusiveAncestorOf(scopingNode->treeScope());
-
- // If a given scoping node is a shadow root and a given element is in a descendant tree of tree hosted by
- // the scoping node's shadow host, we should use ScopeIsShadowHost.
- if (scopingNode && scopingNode->isShadowRoot()) {
- if (element->isInDescendantTreeOf(toShadowRoot(scopingNode)->host()))
- boundaryBehavior |= SelectorChecker::ScopeIsShadowHost;
- scopingNode = toShadowRoot(scopingNode)->host();
- }
-
- CascadeOrder cascadeOrder = isInnerTreeScope ? innerCascadeOrder : outerCascadeOrder;
- collector.collectMatchingRules(MatchRequest(ruleSet, includeEmptyRules, scopingNode), collector.matchedResult().ranges.authorRuleRange(), static_cast<SelectorChecker::BehaviorAtBoundary>(boundaryBehavior), ignoreCascadeScope, cascadeOrder);
- ++innerCascadeOrder;
- --outerCascadeOrder;
- }
-}
-
static inline bool applyAuthorStylesOf(const Element* element)
{
return element->treeScope().applyAuthorStyles() || (element->shadow() && element->shadow()->applyAuthorStyles());
@@ -454,7 +413,7 @@ void StyleResolver::matchAuthorRulesForShadowHost(Element* element, ElementRuleC
for (unsigned i = 0; i < resolvers.size(); ++i)
resolvers.at(i)->collectMatchingAuthorRules(collector, includeEmptyRules, applyAuthorStyles, cascadeScope++, --cascadeOrder);
- collectTreeBoundaryCrossingRules(element, collector, includeEmptyRules);
+ m_treeBoundaryCrossingRules.collectTreeBoundaryCrossingRules(element, collector, includeEmptyRules);
collector.sortAndTransferMatchedRules();
}
@@ -466,7 +425,7 @@ void StyleResolver::matchAuthorRules(Element* element, ElementRuleCollector& col
bool applyAuthorStyles = applyAuthorStylesOf(element);
if (m_styleTree.hasOnlyScopedResolverForDocument()) {
m_styleTree.scopedStyleResolverForDocument()->collectMatchingAuthorRules(collector, includeEmptyRules, applyAuthorStyles, ignoreCascadeScope);
- collectTreeBoundaryCrossingRules(element, collector, includeEmptyRules);
+ m_treeBoundaryCrossingRules.collectTreeBoundaryCrossingRules(element, collector, includeEmptyRules);
collector.sortAndTransferMatchedRules();
return;
}
@@ -492,7 +451,7 @@ void StyleResolver::matchAuthorRules(Element* element, ElementRuleCollector& col
resolver->collectMatchingAuthorRules(collector, includeEmptyRules, applyAuthorStyles, cascadeScope++, resolver->treeScope() == element->treeScope() && resolver->scopingNode().isShadowRoot() ? 0 : cascadeOrder);
}
- collectTreeBoundaryCrossingRules(element, collector, includeEmptyRules);
+ m_treeBoundaryCrossingRules.collectTreeBoundaryCrossingRules(element, collector, includeEmptyRules);
collector.sortAndTransferMatchedRules();
}
« no previous file with comments | « Source/core/css/resolver/StyleResolver.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698