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

Unified Diff: third_party/WebKit/Source/core/dom/NodeList.cpp

Issue 1367523002: [dom] support iterable<> NodeList (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Actual on the left, expected on the right Created 5 years, 2 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
« no previous file with comments | « third_party/WebKit/Source/core/dom/NodeList.h ('k') | third_party/WebKit/Source/core/dom/NodeList.idl » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/core/dom/NodeList.cpp
diff --git a/third_party/WebKit/Source/core/dom/NodeList.cpp b/third_party/WebKit/Source/core/dom/NodeList.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..10d3f197fd3e3dbe9e4ebf88d7ed4fe431b0b721
--- /dev/null
+++ b/third_party/WebKit/Source/core/dom/NodeList.cpp
@@ -0,0 +1,42 @@
+// Copyright 2015 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/NodeList.h"
+
+namespace blink {
+
+namespace {
+
+ class NodeListIterationSource final : public ValueIterable<Node*>::IterationSource {
+ public:
+ explicit NodeListIterationSource(NodeList& nodeList)
+ : m_nodeList(nodeList)
+ {
+ }
+
+ bool next(ScriptState* scriptState, Node*& value, ExceptionState& exceptionState) override
+ {
+ value = m_nodeList->item(m_index);
+ return !!value;
+ }
+
+ DEFINE_INLINE_VIRTUAL_TRACE()
+ {
+ visitor->trace(m_nodeList);
+ ValueIterable<Node*>::IterationSource::trace(visitor);
+ }
+
+ private:
+ const RefPtrWillBeMember<NodeList> m_nodeList;
+ };
+
+} // namespace
+
+ValueIterable<Node*>::IterationSource* NodeList::startIteration(ScriptState*, ExceptionState&)
+{
+ return new NodeListIterationSource(*this);
+}
+
+} // namespace blink
« no previous file with comments | « third_party/WebKit/Source/core/dom/NodeList.h ('k') | third_party/WebKit/Source/core/dom/NodeList.idl » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698