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

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

Issue 23567016: Have ScopedStyleResolver deal with ContainerNode references, not pointers (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 7 years, 3 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/Element.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 54dd5636646847aae469d2e2eafc45bae6d99dbe..7a9505417256eadeb614542a78019577a7b3f7ae 100644
--- a/Source/core/css/resolver/StyleResolver.cpp
+++ b/Source/core/css/resolver/StyleResolver.cpp
@@ -184,7 +184,7 @@ void StyleResolver::finishAppendAuthorStyleSheets()
void StyleResolver::resetAuthorStyle(const ContainerNode* scopingNode)
{
- ScopedStyleResolver* resolver = scopingNode ? m_styleTree.scopedStyleResolverFor(scopingNode) : m_styleTree.scopedStyleResolverForDocument();
+ ScopedStyleResolver* resolver = scopingNode ? m_styleTree.scopedStyleResolverFor(*scopingNode) : m_styleTree.scopedStyleResolverForDocument();
if (!resolver)
return;
@@ -210,7 +210,8 @@ void StyleResolver::resetAtHostRules(const ContainerNode* scopingNode)
const ShadowRoot* shadowRoot = toShadowRoot(scopingNode);
const ContainerNode* shadowHost = shadowRoot->shadowHost();
- ScopedStyleResolver* resolver = m_styleTree.scopedStyleResolverFor(shadowHost);
+ ASSERT(shadowHost);
+ ScopedStyleResolver* resolver = m_styleTree.scopedStyleResolverFor(*shadowHost);
if (!resolver)
return;
@@ -244,6 +245,7 @@ void StyleResolver::collectFeatures()
void StyleResolver::pushParentElement(Element* parent)
{
+ ASSERT(parent);
const ContainerNode* parentsParent = parent->parentOrShadowHostElement();
// We are not always invoked consistently. For example, script execution can cause us to enter
@@ -256,28 +258,29 @@ void StyleResolver::pushParentElement(Element* parent)
m_selectorFilter.pushParent(parent);
// Note: We mustn't skip ShadowRoot nodes for the scope stack.
- m_styleTree.pushStyleCache(parent, parent->parentOrShadowHostNode());
+ m_styleTree.pushStyleCache(*parent, parent->parentOrShadowHostNode());
}
void StyleResolver::popParentElement(Element* parent)
{
+ ASSERT(parent);
// Note that we may get invoked for some random elements in some wacky cases during style resolve.
// Pause maintaining the stack in this case.
if (m_selectorFilter.parentStackIsConsistent(parent))
m_selectorFilter.popParent();
- m_styleTree.popStyleCache(parent);
+ m_styleTree.popStyleCache(*parent);
}
-void StyleResolver::pushParentShadowRoot(const ShadowRoot* shadowRoot)
+void StyleResolver::pushParentShadowRoot(const ShadowRoot& shadowRoot)
{
- ASSERT(shadowRoot->host());
- m_styleTree.pushStyleCache(shadowRoot, shadowRoot->host());
+ ASSERT(shadowRoot.host());
+ m_styleTree.pushStyleCache(shadowRoot, shadowRoot.host());
}
-void StyleResolver::popParentShadowRoot(const ShadowRoot* shadowRoot)
+void StyleResolver::popParentShadowRoot(const ShadowRoot& shadowRoot)
{
- ASSERT(shadowRoot->host());
+ ASSERT(shadowRoot.host());
m_styleTree.popStyleCache(shadowRoot);
}
@@ -316,7 +319,7 @@ inline void StyleResolver::matchShadowDistributedRules(ElementRuleCollector& col
void StyleResolver::matchHostRules(Element* element, ScopedStyleResolver* resolver, ElementRuleCollector& collector, bool includeEmptyRules)
{
- if (element != resolver->scopingNode())
+ if (element != &resolver->scopingNode())
return;
resolver->matchHostRules(collector, includeEmptyRules);
}
@@ -379,7 +382,7 @@ void StyleResolver::matchScopedAuthorRules(Element* element, ElementRuleCollecto
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, applyAuthorStyles, cascadeScope++, resolver->treeScope() == element->treeScope() && resolver->scopingNode()->isShadowRoot() ? 0 : cascadeOrder);
+ resolver->collectMatchingAuthorRules(collector, includeEmptyRules, applyAuthorStyles, cascadeScope++, resolver->treeScope() == element->treeScope() && resolver->scopingNode().isShadowRoot() ? 0 : cascadeOrder);
}
collector.sortAndTransferMatchedRules();
« no previous file with comments | « Source/core/css/resolver/StyleResolver.h ('k') | Source/core/dom/Element.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698