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