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

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

Issue 102273004: Defer pushing the parent stack in recalcStyle until StyleResolver::styleForElement() (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Rebase 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.cpp ('k') | Source/core/css/resolver/StyleResolverParentScope.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
new file mode 100644
index 0000000000000000000000000000000000000000..58624fa2b83269747e2cdc72de92f9a1b22832ed
--- /dev/null
+++ b/Source/core/css/resolver/StyleResolverParentScope.h
@@ -0,0 +1,65 @@
+// Copyright 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef StyleResolverParentScope_h
+#define StyleResolverParentScope_h
+
+#include "core/css/resolver/StyleResolver.h"
+#include "core/dom/Element.h"
+
+namespace WebCore {
+
+// Maintains the parent element stack (and bloom filter) inside recalcStyle.
+class StyleResolverParentScope FINAL {
+public:
+ explicit StyleResolverParentScope(Element& parent);
+ ~StyleResolverParentScope();
+
+ static void ensureParentStackIsPushed();
+
+private:
+ void pushParentIfNeeded();
+
+ Element& m_parent;
+ bool m_pushed;
+ StyleResolverParentScope* m_previous;
+
+ static StyleResolverParentScope* s_currentScope;
+};
+
+inline StyleResolverParentScope::StyleResolverParentScope(Element& parent)
+ : m_parent(parent)
+ , m_pushed(false)
+ , m_previous(s_currentScope)
+{
+ ASSERT(m_parent.document().inStyleRecalc());
+ s_currentScope = this;
+}
+
+inline StyleResolverParentScope::~StyleResolverParentScope()
+{
+ if (m_pushed)
+ m_parent.document().styleResolver()->popParentElement(m_parent);
+ s_currentScope = m_previous;
+}
+
+inline void StyleResolverParentScope::ensureParentStackIsPushed()
+{
+ if (s_currentScope)
+ s_currentScope->pushParentIfNeeded();
+}
+
+inline void StyleResolverParentScope::pushParentIfNeeded()
+{
+ if (m_pushed)
+ return;
+ if (m_previous)
+ m_previous->pushParentIfNeeded();
+ m_parent.document().styleResolver()->pushParentElement(m_parent);
+ m_pushed = true;
+}
+
+} // namespace WebCore
+
+#endif // StyleResolverParentScope_h
« no previous file with comments | « Source/core/css/resolver/StyleResolver.cpp ('k') | Source/core/css/resolver/StyleResolverParentScope.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698