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

Unified Diff: Source/core/css/resolver/StyleResolverParentScope.h

Issue 216283003: Use the StyleResolverParentScope for ShadowRoot (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: 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 | « no previous file | Source/core/dom/shadow/ShadowRoot.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/css/resolver/StyleResolverParentScope.h
diff --git a/Source/core/css/resolver/StyleResolverParentScope.h b/Source/core/css/resolver/StyleResolverParentScope.h
index 58624fa2b83269747e2cdc72de92f9a1b22832ed..8972b42088bfcce55f34b329c772e4037348155a 100644
--- a/Source/core/css/resolver/StyleResolverParentScope.h
+++ b/Source/core/css/resolver/StyleResolverParentScope.h
@@ -7,13 +7,14 @@
#include "core/css/resolver/StyleResolver.h"
#include "core/dom/Element.h"
+#include "core/dom/shadow/ShadowRoot.h"
namespace WebCore {
// Maintains the parent element stack (and bloom filter) inside recalcStyle.
class StyleResolverParentScope FINAL {
public:
- explicit StyleResolverParentScope(Element& parent);
+ explicit StyleResolverParentScope(Node& parent);
~StyleResolverParentScope();
static void ensureParentStackIsPushed();
@@ -21,27 +22,34 @@ public:
private:
void pushParentIfNeeded();
- Element& m_parent;
+ Node& m_parent;
bool m_pushed;
StyleResolverParentScope* m_previous;
+ StyleResolver& m_resolver;
static StyleResolverParentScope* s_currentScope;
};
-inline StyleResolverParentScope::StyleResolverParentScope(Element& parent)
+inline StyleResolverParentScope::StyleResolverParentScope(Node& parent)
: m_parent(parent)
, m_pushed(false)
, m_previous(s_currentScope)
+ , m_resolver(*m_parent.document().styleResolver())
{
ASSERT(m_parent.document().inStyleRecalc());
+ ASSERT(parent.isElementNode() || parent.isShadowRoot());
s_currentScope = this;
}
inline StyleResolverParentScope::~StyleResolverParentScope()
{
- if (m_pushed)
- m_parent.document().styleResolver()->popParentElement(m_parent);
s_currentScope = m_previous;
+ if (!m_pushed)
+ return;
+ if (m_parent.isElementNode())
+ m_resolver.popParentElement(toElement(m_parent));
+ else
+ m_resolver.popParentShadowRoot(toShadowRoot(m_parent));
}
inline void StyleResolverParentScope::ensureParentStackIsPushed()
@@ -56,7 +64,10 @@ inline void StyleResolverParentScope::pushParentIfNeeded()
return;
if (m_previous)
m_previous->pushParentIfNeeded();
- m_parent.document().styleResolver()->pushParentElement(m_parent);
+ if (m_parent.isElementNode())
+ m_resolver.pushParentElement(toElement(m_parent));
+ else
+ m_resolver.pushParentShadowRoot(toShadowRoot(m_parent));
m_pushed = true;
}
« no previous file with comments | « no previous file | Source/core/dom/shadow/ShadowRoot.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698