Chromium Code Reviews| 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 = Result(0); | 86 Vector<OwnPtr<CustomElementMicrotaskStep> > remaining; |
|
dominicc (has gone to gerrit)
2014/04/30 23:57:20
I think you should avoid this "remain" thing. It j
| |
| 87 Result accumulatedResult = Result(CustomElementMicrotaskStep::Continue); | |
| 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(); |
| 92 accumulatedResult = Result(result | accumulatedResult); | |
| 91 | 93 |
| 92 if (result & CustomElementMicrotaskStep::ShouldStop) | 94 bool shouldStop = result & CustomElementMicrotaskStep::ShouldStop; |
| 95 bool shouldRemain = result & CustomElementMicrotaskStep::ShouldRemain; | |
| 96 ASSERT(!shouldStop || shouldStop == shouldRemain); | |
| 97 if (shouldRemain) | |
| 98 remaining.append(m_queue[i].release()); | |
| 99 if (shouldStop) | |
| 93 break; | 100 break; |
| 94 } | 101 } |
| 95 | 102 |
| 96 bool wasStopped = i < m_queue.size(); | 103 for (++i; i < m_queue.size(); ++i) |
| 97 if (wasStopped) | 104 remaining.append(m_queue[i].release()); |
| 98 m_queue.remove(0, i); | 105 m_queue.swap(remaining); |
| 99 else | 106 return accumulatedResult; |
| 100 m_queue.resize(0); | |
| 101 | |
| 102 return result; | |
| 103 } | 107 } |
| 104 | 108 |
| 109 #if !defined(NDEBUG) | |
| 110 void CustomElementMicrotaskQueue::show(unsigned indent) | |
| 111 { | |
| 112 for (unsigned i = 0; i < m_queue.size(); ++i) { | |
| 113 if (m_queue[i]) { | |
| 114 m_queue[i]->show(indent); | |
| 115 } else { | |
| 116 for (unsigned j = 0; j < indent; ++j) | |
| 117 fprintf(stderr, " "); | |
| 118 fprintf(stderr, "null\n"); | |
| 119 } | |
| 120 } | |
| 121 } | |
| 122 #endif | |
| 123 | |
| 105 } // namespace WebCore | 124 } // namespace WebCore |
| OLD | NEW |