| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef SelectorFilterParentScope_h | 5 #ifndef SelectorFilterParentScope_h |
| 6 #define SelectorFilterParentScope_h | 6 #define SelectorFilterParentScope_h |
| 7 | 7 |
| 8 #include "core/css/SelectorFilter.h" | 8 #include "core/css/SelectorFilter.h" |
| 9 #include "core/css/resolver/StyleResolver.h" | 9 #include "core/css/resolver/StyleResolver.h" |
| 10 #include "core/dom/Document.h" | 10 #include "core/dom/Document.h" |
| (...skipping 20 matching lines...) Expand all Loading... |
| 31 Member<StyleResolver> m_resolver; | 31 Member<StyleResolver> m_resolver; |
| 32 | 32 |
| 33 static SelectorFilterParentScope* s_currentScope; | 33 static SelectorFilterParentScope* s_currentScope; |
| 34 }; | 34 }; |
| 35 | 35 |
| 36 inline SelectorFilterParentScope::SelectorFilterParentScope(Element& parent) | 36 inline SelectorFilterParentScope::SelectorFilterParentScope(Element& parent) |
| 37 : m_parent(parent), | 37 : m_parent(parent), |
| 38 m_pushed(false), | 38 m_pushed(false), |
| 39 m_previous(s_currentScope), | 39 m_previous(s_currentScope), |
| 40 m_resolver(parent.document().styleResolver()) { | 40 m_resolver(parent.document().styleResolver()) { |
| 41 ASSERT(parent.document().inStyleRecalc()); | 41 DCHECK(parent.document().inStyleRecalc()); |
| 42 s_currentScope = this; | 42 s_currentScope = this; |
| 43 } | 43 } |
| 44 | 44 |
| 45 inline SelectorFilterParentScope::~SelectorFilterParentScope() { | 45 inline SelectorFilterParentScope::~SelectorFilterParentScope() { |
| 46 s_currentScope = m_previous; | 46 s_currentScope = m_previous; |
| 47 if (!m_pushed) | 47 if (!m_pushed) |
| 48 return; | 48 return; |
| 49 m_resolver->selectorFilter().popParent(*m_parent); | 49 m_resolver->selectorFilter().popParent(*m_parent); |
| 50 } | 50 } |
| 51 | 51 |
| 52 inline void SelectorFilterParentScope::ensureParentStackIsPushed() { | 52 inline void SelectorFilterParentScope::ensureParentStackIsPushed() { |
| 53 if (s_currentScope) | 53 if (s_currentScope) |
| 54 s_currentScope->pushParentIfNeeded(); | 54 s_currentScope->pushParentIfNeeded(); |
| 55 } | 55 } |
| 56 | 56 |
| 57 inline void SelectorFilterParentScope::pushParentIfNeeded() { | 57 inline void SelectorFilterParentScope::pushParentIfNeeded() { |
| 58 if (m_pushed) | 58 if (m_pushed) |
| 59 return; | 59 return; |
| 60 if (m_previous) | 60 if (m_previous) |
| 61 m_previous->pushParentIfNeeded(); | 61 m_previous->pushParentIfNeeded(); |
| 62 m_resolver->selectorFilter().pushParent(*m_parent); | 62 m_resolver->selectorFilter().pushParent(*m_parent); |
| 63 m_pushed = true; | 63 m_pushed = true; |
| 64 } | 64 } |
| 65 | 65 |
| 66 } // namespace blink | 66 } // namespace blink |
| 67 | 67 |
| 68 #endif // SelectorFilterParentScope_h | 68 #endif // SelectorFilterParentScope_h |
| OLD | NEW |