OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2013 Google Inc. All rights reserved. | 2 * Copyright (C) 2013 Google Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
6 * are met: | 6 * are met: |
7 * | 7 * |
8 * 1. Redistributions of source code must retain the above copyright | 8 * 1. Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * 2. Redistributions in binary form must reproduce the above copyright | 10 * 2. Redistributions in binary form must reproduce the above copyright |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
76 #endif | 76 #endif |
77 | 77 |
78 void CustomElementMicrotaskQueue::enqueue(PassOwnPtr<CustomElementMicrotaskStep>
step) | 78 void CustomElementMicrotaskQueue::enqueue(PassOwnPtr<CustomElementMicrotaskStep>
step) |
79 { | 79 { |
80 m_queue.append(step); | 80 m_queue.append(step); |
81 } | 81 } |
82 | 82 |
83 CustomElementMicrotaskStep::Result CustomElementMicrotaskQueue::dispatch() | 83 CustomElementMicrotaskStep::Result CustomElementMicrotaskQueue::dispatch() |
84 { | 84 { |
85 MicrotaskQueueInvocationScope scope(this); | 85 MicrotaskQueueInvocationScope scope(this); |
86 Result result = CustomElementMicrotaskStep::Continue; | 86 Vector<OwnPtr<CustomElementMicrotaskStep> > remaining; |
| 87 Result accumulatedResult = CustomElementMicrotaskStep::ContinueWithRemoving; |
87 | 88 |
88 unsigned i; | 89 unsigned i; |
89 for (i = 0; i < m_queue.size(); ++i) { | 90 for (i = 0; i < m_queue.size(); ++i) { |
90 result = Result(result | m_queue[i]->process()); | 91 Result result = m_queue[i]->process(); |
91 | 92 accumulatedResult = CustomElementMicrotaskStep::Result(result | accumula
tedResult); |
| 93 if (result & CustomElementMicrotaskStep::ShouldRemain) |
| 94 remaining.append(m_queue[i].release()); |
92 if (result & CustomElementMicrotaskStep::ShouldStop) | 95 if (result & CustomElementMicrotaskStep::ShouldStop) |
93 break; | 96 break; |
94 } | 97 } |
95 | 98 |
96 bool wasStopped = i < m_queue.size(); | 99 for (++i; i < m_queue.size(); ++i) |
97 if (wasStopped) | 100 remaining.append(m_queue[i].release()); |
98 m_queue.remove(0, i); | 101 m_queue.swap(remaining); |
99 else | |
100 m_queue.resize(0); | |
101 | 102 |
102 return result; | 103 return accumulatedResult; |
103 } | 104 } |
104 | 105 |
105 #if !defined(NDEBUG) | 106 #if !defined(NDEBUG) |
106 void CustomElementMicrotaskQueue::show(unsigned indent) | 107 void CustomElementMicrotaskQueue::show(unsigned indent) |
107 { | 108 { |
108 for (unsigned q = 0; q < m_queue.size(); ++q) { | 109 for (unsigned q = 0; q < m_queue.size(); ++q) { |
109 if (m_queue[q]) | 110 if (m_queue[q]) |
110 m_queue[q]->show(indent); | 111 m_queue[q]->show(indent); |
111 else | 112 else |
112 fprintf(stderr, "%*s\n", indent, ""); | 113 fprintf(stderr, "%*snull\n", indent, ""); |
113 } | 114 } |
114 } | 115 } |
115 #endif | 116 #endif |
116 | 117 |
117 } // namespace WebCore | 118 } // namespace WebCore |
OLD | NEW |