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

Side by Side Diff: third_party/WebKit/Source/core/dom/custom/CustomElementReactionStack.cpp

Issue 2456773002: Clear the custom element's reaction queue if upgrade fails. (Closed)
Patch Set: Created 4 years, 1 month 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
OLDNEW
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 #include "core/dom/custom/CustomElementReactionStack.h" 5 #include "core/dom/custom/CustomElementReactionStack.h"
6 6
7 #include "bindings/core/v8/Microtask.h" 7 #include "bindings/core/v8/Microtask.h"
8 #include "core/dom/Element.h" 8 #include "core/dom/Element.h"
9 #include "core/dom/custom/CEReactionsScope.h" 9 #include "core/dom/custom/CEReactionsScope.h"
10 #include "core/dom/custom/CustomElementReactionQueue.h" 10 #include "core/dom/custom/CustomElementReactionQueue.h"
11 #include "core/frame/FrameHost.h" 11 #include "core/frame/FrameHost.h"
12 12
13 namespace blink { 13 namespace blink {
14 14
15 namespace { 15 namespace {
16 16
17 CustomElementReactionStack& customElementReactionStack() { 17 Persistent<CustomElementReactionStack>& customElementReactionStack() {
18 DEFINE_STATIC_LOCAL(CustomElementReactionStack, customElementReactionStack, 18 DEFINE_STATIC_LOCAL(Persistent<CustomElementReactionStack>,
19 customElementReactionStack,
19 (new CustomElementReactionStack)); 20 (new CustomElementReactionStack));
20 return customElementReactionStack; 21 return customElementReactionStack;
21 } 22 }
22 23
23 } // namespace 24 } // namespace
24 25
25 // TODO(dominicc): Consider using linked heap structures, avoiding 26 // TODO(dominicc): Consider using linked heap structures, avoiding
26 // finalizers, to make short-lived entries fast. 27 // finalizers, to make short-lived entries fast.
27 28
28 CustomElementReactionStack::CustomElementReactionStack() {} 29 CustomElementReactionStack::CustomElementReactionStack() {}
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
89 // If the processing the backup element queue is not set: 90 // If the processing the backup element queue is not set:
90 if (!m_backupQueue || m_backupQueue->isEmpty()) { 91 if (!m_backupQueue || m_backupQueue->isEmpty()) {
91 Microtask::enqueueMicrotask( 92 Microtask::enqueueMicrotask(
92 WTF::bind(&CustomElementReactionStack::invokeBackupQueue, 93 WTF::bind(&CustomElementReactionStack::invokeBackupQueue,
93 Persistent<CustomElementReactionStack>(this))); 94 Persistent<CustomElementReactionStack>(this)));
94 } 95 }
95 96
96 enqueue(m_backupQueue, element, reaction); 97 enqueue(m_backupQueue, element, reaction);
97 } 98 }
98 99
100 void CustomElementReactionStack::clearQueue(Element* element) {
101 if (CustomElementReactionQueue* reactions = m_map.get(element))
102 reactions->clear();
103 }
104
99 void CustomElementReactionStack::invokeBackupQueue() { 105 void CustomElementReactionStack::invokeBackupQueue() {
100 DCHECK(isMainThread()); 106 DCHECK(isMainThread());
101 invokeReactions(*m_backupQueue); 107 invokeReactions(*m_backupQueue);
102 m_backupQueue->clear(); 108 m_backupQueue->clear();
103 } 109 }
104 110
105 CustomElementReactionStack& CustomElementReactionStack::current() { 111 CustomElementReactionStack& CustomElementReactionStack::current() {
106 return customElementReactionStack(); 112 return *customElementReactionStack();
113 }
114
115 CustomElementReactionStack*
116 CustomElementReactionStackTestSupport::setCurrentForTest(
117 CustomElementReactionStack* newStack) {
118 Persistent<CustomElementReactionStack>& stack = customElementReactionStack();
119 CustomElementReactionStack* oldStack = stack.get();
120 stack = newStack;
121 return oldStack;
107 } 122 }
108 123
109 } // namespace blink 124 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698