Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(239)

Side by Side Diff: Source/core/dom/custom/CustomElementMicrotaskQueue.cpp

Issue 238923009: HTML Imports: No more BlockingDocumentCreation. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Rebased to ToT. Created 6 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 17 matching lines...) Expand all
28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 */ 29 */
30 30
31 #include "config.h" 31 #include "config.h"
32 #include "core/dom/custom/CustomElementMicrotaskQueue.h" 32 #include "core/dom/custom/CustomElementMicrotaskQueue.h"
33 33
34 #include "core/dom/custom/CustomElementCallbackDispatcher.h" 34 #include "core/dom/custom/CustomElementCallbackDispatcher.h"
35 35
36 namespace WebCore { 36 namespace WebCore {
37 37
38 class MicrotaskQueueInvocationScope {
39 public:
40 #if defined(NDEBUG)
41 explicit MicrotaskQueueInvocationScope(CustomElementMicrotaskQueue*) { }
42 #else
43 explicit MicrotaskQueueInvocationScope(CustomElementMicrotaskQueue* queue)
44 : m_parent(s_top)
45 , m_queue(queue)
46 {
47 s_top = this;
48 ASSERT(m_queue->isEmpty() || !hasReenter());
49 }
50
51 ~MicrotaskQueueInvocationScope()
52 {
53 s_top = m_parent;
54 }
55
56 private:
57 bool hasReenter() const
58 {
59 for (MicrotaskQueueInvocationScope* scope = this->m_parent; scope; scope = scope->m_parent) {
60 if (scope->m_queue == m_queue)
61 return true;
62 }
63
64 return false;
65 }
66
67 MicrotaskQueueInvocationScope* m_parent;
68 CustomElementMicrotaskQueue* m_queue;
69
70 static MicrotaskQueueInvocationScope* s_top;
71 #endif
72 };
73
74 #if !defined(NDEBUG)
75 MicrotaskQueueInvocationScope* MicrotaskQueueInvocationScope::s_top = 0;
76 #endif
77
38 void CustomElementMicrotaskQueue::enqueue(PassOwnPtr<CustomElementMicrotaskStep> step) 78 void CustomElementMicrotaskQueue::enqueue(PassOwnPtr<CustomElementMicrotaskStep> step)
39 { 79 {
40 m_queue.append(step); 80 m_queue.append(step);
41 } 81 }
42 82
43 CustomElementMicrotaskStep::Result CustomElementMicrotaskQueue::dispatch() 83 CustomElementMicrotaskStep::Result CustomElementMicrotaskQueue::dispatch()
44 { 84 {
85 MicrotaskQueueInvocationScope scope(this);
45 Result result = Result(0); 86 Result result = Result(0);
46 87
47 unsigned i; 88 unsigned i;
48 for (i = 0; i < m_queue.size(); ++i) { 89 for (i = 0; i < m_queue.size(); ++i) {
49 result = Result(result | m_queue[i]->process()); 90 result = Result(result | m_queue[i]->process());
50 91
51 if (result & CustomElementMicrotaskStep::ShouldStop) 92 if (result & CustomElementMicrotaskStep::ShouldStop)
52 break; 93 break;
53 } 94 }
54 95
55 bool wasStopped = i < m_queue.size(); 96 bool wasStopped = i < m_queue.size();
56 if (wasStopped) 97 if (wasStopped)
57 m_queue.remove(0, i); 98 m_queue.remove(0, i);
58 else 99 else
59 m_queue.resize(0); 100 m_queue.resize(0);
60 101
61 return result; 102 return result;
62 } 103 }
63 104
64 } // namespace WebCore 105 } // namespace WebCore
OLDNEW
« no previous file with comments | « Source/core/dom/custom/CustomElementMicrotaskQueue.h ('k') | Source/core/dom/custom/CustomElementScheduler.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698