OLD | NEW |
(Empty) | |
| 1 // Copyright 2016 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 CEReactionsScope_h |
| 6 #define CEReactionsScope_h |
| 7 |
| 8 #include "core/CoreExport.h" |
| 9 #include "platform/heap/Handle.h" |
| 10 #include "wtf/Allocator.h" |
| 11 #include "wtf/StdLibExtras.h" |
| 12 |
| 13 namespace blink { |
| 14 |
| 15 class CustomElementReaction; |
| 16 class Element; |
| 17 class FrameHost; |
| 18 |
| 19 // https://html.spec.whatwg.org/multipage/scripting.html#cereactions |
| 20 class CORE_EXPORT CEReactionsScope final { |
| 21 STACK_ALLOCATED(); |
| 22 DISALLOW_COPY_AND_ASSIGN(CEReactionsScope); |
| 23 public: |
| 24 static CEReactionsScope* current() |
| 25 { |
| 26 return topOfStack(); |
| 27 } |
| 28 |
| 29 CEReactionsScope() |
| 30 : m_prev(topOfStack()) |
| 31 { |
| 32 topOfStack() = this; |
| 33 } |
| 34 |
| 35 ~CEReactionsScope() |
| 36 { |
| 37 CEReactionsScope** top = &topOfStack(); |
| 38 *top = (*top)->m_prev; |
| 39 if (m_frameHost.get()) |
| 40 invokeReactions(); |
| 41 } |
| 42 |
| 43 void enqueue(Element*, CustomElementReaction*); |
| 44 |
| 45 private: |
| 46 static CEReactionsScope*& topOfStack() |
| 47 { |
| 48 static CEReactionsScope* top = nullptr; |
| 49 return top; |
| 50 } |
| 51 |
| 52 void invokeReactions(); |
| 53 |
| 54 CEReactionsScope* m_prev; |
| 55 Member<FrameHost> m_frameHost; |
| 56 }; |
| 57 |
| 58 } // namespace blink |
| 59 |
| 60 #endif // CEReactionsScope_h |
OLD | NEW |