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

Unified Diff: third_party/WebKit/Source/core/dom/custom/CustomElementReactionQueue.cpp

Issue 2021763002: Add a queue for custom element reactions. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 7 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: third_party/WebKit/Source/core/dom/custom/CustomElementReactionQueue.cpp
diff --git a/third_party/WebKit/Source/core/dom/custom/CustomElementReactionQueue.cpp b/third_party/WebKit/Source/core/dom/custom/CustomElementReactionQueue.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..5b3406cddea0354df87ce6befc58c3e5196a91e8
--- /dev/null
+++ b/third_party/WebKit/Source/core/dom/custom/CustomElementReactionQueue.cpp
@@ -0,0 +1,47 @@
+// Copyright 2016 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 "core/dom/custom/CustomElementReactionQueue.h"
+
+#include "core/dom/custom/CustomElementReaction.h"
+
+namespace blink {
+
+CustomElementReactionQueue::CustomElementReactionQueue()
yosin_UTC9 2016/06/01 02:14:01 Better to use |m_index = 0u| in class declaration
+ : m_index(0u)
+{
+}
+
+CustomElementReactionQueue::~CustomElementReactionQueue()
yosin_UTC9 2016/06/01 02:14:01 nit: = default
+{
+}
+
+DEFINE_TRACE(CustomElementReactionQueue)
+{
+ visitor->trace(m_reactions);
+}
+
+void CustomElementReactionQueue::add(CustomElementReaction* reaction)
+{
+ m_reactions.append(reaction);
+}
+
+// There is one queue per element, so this could be invoked
+// recursively.
+void CustomElementReactionQueue::invokeReactions(Element* element)
+{
+ while (m_index < m_reactions.size()) {
+ CustomElementReaction* reaction = m_reactions[m_index];
+ m_reactions[m_index++] = nullptr;
+ reaction->invoke(element);
+ }
+ // Unlike V0CustomElementsCallbackQueue, reactions are always
+ // inserted by steps which bump the global element queue. This
+ // means we do not need queue "owner" guards.
+ // https://html.spec.whatwg.org/multipage/scripting.html#custom-element-reactions
+ m_index = 0;
+ m_reactions.resize(0);
+}
+
+} // namespace blink

Powered by Google App Engine
This is Rietveld 408576698