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