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/CustomElementReactionStack.h" | 5 #include "core/dom/custom/CustomElementReactionStack.h" |
6 | 6 |
7 #include "core/dom/Element.h" | 7 #include "core/dom/Element.h" |
8 #include "core/dom/custom/CustomElementReactionQueue.h" | 8 #include "core/dom/custom/CustomElementReactionQueue.h" |
9 | 9 |
10 namespace blink { | 10 namespace blink { |
(...skipping 12 matching lines...) Expand all Loading... |
23 } | 23 } |
24 | 24 |
25 void CustomElementReactionStack::push() | 25 void CustomElementReactionStack::push() |
26 { | 26 { |
27 m_stack.append(nullptr); | 27 m_stack.append(nullptr); |
28 } | 28 } |
29 | 29 |
30 void CustomElementReactionStack::popInvokingReactions() | 30 void CustomElementReactionStack::popInvokingReactions() |
31 { | 31 { |
32 ElementQueue* queue = m_stack.last(); | 32 ElementQueue* queue = m_stack.last(); |
33 m_stack.removeLast(); | 33 if (!queue) { |
34 if (!queue) | 34 m_stack.removeLast(); |
35 return; | 35 return; |
36 for (auto& element : *queue) { | 36 } |
| 37 |
| 38 for (size_t i = 0; i < queue->size(); ++i) { |
| 39 Element* element = (*queue)[i]; |
37 if (CustomElementReactionQueue* reactions = m_map.get(element)) { | 40 if (CustomElementReactionQueue* reactions = m_map.get(element)) { |
38 reactions->invokeReactions(element); | 41 reactions->invokeReactions(element); |
39 CHECK(reactions->isEmpty()); | 42 CHECK(reactions->isEmpty()); |
40 m_map.remove(element); | 43 m_map.remove(element); |
41 } | 44 } |
42 } | 45 } |
| 46 |
| 47 m_stack.removeLast(); |
43 } | 48 } |
44 | 49 |
45 void CustomElementReactionStack::enqueue( | 50 void CustomElementReactionStack::enqueue( |
46 Element* element, | 51 Element* element, |
47 CustomElementReaction* reaction) | 52 CustomElementReaction* reaction) |
48 { | 53 { |
49 ElementQueue* queue = m_stack.last(); | 54 ElementQueue* queue = m_stack.last(); |
50 if (!queue) | 55 if (!queue) |
51 m_stack.last() = queue = new ElementQueue(); | 56 m_stack.last() = queue = new ElementQueue(); |
52 queue->append(element); | 57 queue->append(element); |
53 | 58 |
54 CustomElementReactionQueue* reactions = m_map.get(element); | 59 CustomElementReactionQueue* reactions = m_map.get(element); |
55 if (!reactions) { | 60 if (!reactions) { |
56 reactions = new CustomElementReactionQueue(); | 61 reactions = new CustomElementReactionQueue(); |
57 m_map.add(element, reactions); | 62 m_map.add(element, reactions); |
58 } | 63 } |
59 | 64 |
60 reactions->add(reaction); | 65 reactions->add(reaction); |
61 } | 66 } |
62 | 67 |
63 } // namespace blink | 68 } // namespace blink |
OLD | NEW |