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

Unified Diff: Source/core/dom/custom/CustomElementMicrotaskDispatcher.cpp

Issue 144023016: Separate Custom Element resolution and upgrade/createdCallback. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 11 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 side-by-side diff with in-line comments
Download patch
Index: Source/core/dom/custom/CustomElementMicrotaskDispatcher.cpp
diff --git a/Source/core/dom/custom/CustomElementMicrotaskDispatcher.cpp b/Source/core/dom/custom/CustomElementMicrotaskDispatcher.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..493881e6ab4e4821986461a63f921dc695685cfc
--- /dev/null
+++ b/Source/core/dom/custom/CustomElementMicrotaskDispatcher.cpp
@@ -0,0 +1,57 @@
+// Copyright 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "config.h"
+#include "core/dom/custom/CustomElementMicrotaskDispatcher.h"
+
+#include "core/dom/custom/CustomElementCallbackDispatcher.h"
+#include "core/dom/custom/CustomElementCallbackQueue.h"
+#include "core/dom/custom/CustomElementMicrotaskImportStep.h"
+#include "core/html/HTMLImport.h"
+
+namespace WebCore {
+
+static const CustomElementCallbackQueue::ElementQueueId kMicrotaskQueueId = 0;
+
+void CustomElementMicrotaskDispatcher::enqueue(HTMLImport* import, PassOwnPtr<CustomElementMicrotaskStep> step)
+{
+ ASSERT(m_phase == Quiescent || m_phase == DispatchingCallbacks);
+ if (import && import->customElementMicrotaskStep())
+ import->customElementMicrotaskStep()->enqueue(step);
+ else
+ m_resolutionAndImports.enqueue(step);
+}
+
+void CustomElementMicrotaskDispatcher::enqueue(CustomElementCallbackQueue* queue)
+{
+ ASSERT(m_phase == Quiescent || m_phase == Resolving);
+ queue->setOwner(kMicrotaskQueueId);
+ m_elements.append(queue);
+}
+
+bool CustomElementMicrotaskDispatcher::dispatch()
+{
+ ASSERT(m_phase == Quiescent);
+
+ bool didWork = false;
+
+ m_phase = Resolving;
+ m_resolutionAndImports.dispatch();
+
+ m_phase = DispatchingCallbacks;
+ for (Vector<CustomElementCallbackQueue*>::iterator it = m_elements.begin();it != m_elements.end(); ++it) {
+ // Created callback may enqueue an attached callback.
+ CustomElementCallbackDispatcher::CallbackDeliveryScope scope;
+ (*it)->processInElementQueue(kMicrotaskQueueId);
+
+ didWork = true;
+ }
+
+ m_elements.clear();
+ m_phase = Quiescent;
+
+ return didWork;
+}
+
+} // namespace WebCore
« no previous file with comments | « Source/core/dom/custom/CustomElementMicrotaskDispatcher.h ('k') | Source/core/dom/custom/CustomElementMicrotaskElementStep.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698