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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef StyleResolverParentScope_h
6 #define StyleResolverParentScope_h
7
8 #include "core/css/resolver/StyleResolver.h"
9 #include "core/dom/Element.h"
10
11 namespace WebCore {
12
13 // Maintains the parent element stack (and bloom filter) inside recalcStyle.
14 class StyleResolverParentScope FINAL {
15 public:
16 explicit StyleResolverParentScope(Element& parent);
17 ~StyleResolverParentScope();
18
19 static void ensureParentStackIsPushed();
20
21 private:
22 void pushParentIfNeeded();
23
24 Element& m_parent;
25 bool m_pushed;
26 StyleResolverParentScope* m_previous;
27
28 static StyleResolverParentScope* s_currentScope;
29 };
30
31 inline StyleResolverParentScope::StyleResolverParentScope(Element& parent)
32 : m_parent(parent)
33 , m_pushed(false)
34 , m_previous(s_currentScope)
35 {
36 ASSERT(m_parent.document().inStyleRecalc());
37 s_currentScope = this;
38 }
39
40 inline StyleResolverParentScope::~StyleResolverParentScope()
41 {
42 if (m_pushed)
43 m_parent.document().styleResolver()->popParentElement(m_parent);
44 s_currentScope = m_previous;
45 }
46
47 inline void StyleResolverParentScope::ensureParentStackIsPushed()
48 {
49 if (s_currentScope)
50 s_currentScope->pushParentIfNeeded();
51 }
52
53 inline void StyleResolverParentScope::pushParentIfNeeded()
54 {
55 if (m_pushed)
56 return;
57 if (m_previous)
58 m_previous->pushParentIfNeeded();
59 m_parent.document().styleResolver()->pushParentElement(m_parent);
60 m_pushed = true;
61 }
62
63 } // namespace WebCore
64
65 #endif // StyleResolverParentScope_h
OLDNEW
« 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