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 #include "core/dom/custom/CustomElementReactionQueue.h" | 5 #include "core/dom/custom/CustomElementReactionQueue.h" |
6 | 6 |
| 7 #include "core/dom/Element.h" |
7 #include "core/dom/custom/CustomElementReaction.h" | 8 #include "core/dom/custom/CustomElementReaction.h" |
| 9 #include "platform/tracing/TraceEvent.h" |
8 | 10 |
9 namespace blink { | 11 namespace blink { |
10 | 12 |
11 CustomElementReactionQueue::CustomElementReactionQueue() : m_index(0u) {} | 13 CustomElementReactionQueue::CustomElementReactionQueue() : m_index(0u) {} |
12 | 14 |
13 CustomElementReactionQueue::~CustomElementReactionQueue() {} | 15 CustomElementReactionQueue::~CustomElementReactionQueue() {} |
14 | 16 |
15 DEFINE_TRACE(CustomElementReactionQueue) { | 17 DEFINE_TRACE(CustomElementReactionQueue) { |
16 visitor->trace(m_reactions); | 18 visitor->trace(m_reactions); |
17 } | 19 } |
18 | 20 |
19 void CustomElementReactionQueue::add(CustomElementReaction* reaction) { | 21 void CustomElementReactionQueue::add(CustomElementReaction* reaction) { |
20 m_reactions.append(reaction); | 22 m_reactions.append(reaction); |
21 } | 23 } |
22 | 24 |
23 // There is one queue per element, so this could be invoked | 25 // There is one queue per element, so this could be invoked |
24 // recursively. | 26 // recursively. |
25 void CustomElementReactionQueue::invokeReactions(Element* element) { | 27 void CustomElementReactionQueue::invokeReactions(Element* element) { |
| 28 TRACE_EVENT1("blink", "CustomElementReactionQueue::invokeReactions", "name", |
| 29 element->localName().utf8()); |
26 while (m_index < m_reactions.size()) { | 30 while (m_index < m_reactions.size()) { |
27 CustomElementReaction* reaction = m_reactions[m_index]; | 31 CustomElementReaction* reaction = m_reactions[m_index]; |
28 m_reactions[m_index++] = nullptr; | 32 m_reactions[m_index++] = nullptr; |
29 reaction->invoke(element); | 33 reaction->invoke(element); |
30 } | 34 } |
31 // Unlike V0CustomElementsCallbackQueue, reactions are always | 35 // Unlike V0CustomElementsCallbackQueue, reactions are always |
32 // inserted by steps which bump the global element queue. This | 36 // inserted by steps which bump the global element queue. This |
33 // means we do not need queue "owner" guards. | 37 // means we do not need queue "owner" guards. |
34 // https://html.spec.whatwg.org/multipage/scripting.html#custom-element-reacti
ons | 38 // https://html.spec.whatwg.org/multipage/scripting.html#custom-element-reacti
ons |
35 clear(); | 39 clear(); |
36 } | 40 } |
37 | 41 |
38 void CustomElementReactionQueue::clear() { | 42 void CustomElementReactionQueue::clear() { |
39 m_index = 0; | 43 m_index = 0; |
40 m_reactions.resize(0); | 44 m_reactions.resize(0); |
41 } | 45 } |
42 | 46 |
43 } // namespace blink | 47 } // namespace blink |
OLD | NEW |