Index: Source/core/html/HTMLCollection.cpp |
diff --git a/Source/core/html/HTMLCollection.cpp b/Source/core/html/HTMLCollection.cpp |
index e2b14857228b5d7d87725109a4810d8a238860a9..d79ba45b571fe0edea4dc97d0e5266e86c72dc07 100644 |
--- a/Source/core/html/HTMLCollection.cpp |
+++ b/Source/core/html/HTMLCollection.cpp |
@@ -40,6 +40,42 @@ |
namespace blink { |
+namespace { |
+ |
+class HTMLCollectionIterationSource final : public ValueIterable<Element*>::IterationSource { |
+public: |
+ explicit HTMLCollectionIterationSource(HTMLCollection* collection) |
+ : m_collection(collection) |
+ { |
+ } |
+ |
+ bool next(ScriptState* scriptState, Element*& value, ExceptionState& exceptionState) override |
+ { |
+ if (m_index >= m_collection->length()) { |
+ value = nullptr; |
+ return false; |
+ } |
+ value = m_collection->item(m_index); |
+ return true; |
+ } |
+ |
+ DEFINE_INLINE_VIRTUAL_TRACE() |
+ { |
+ visitor->trace(m_collection); |
+ ValueIterable<Element*>::IterationSource::trace(visitor); |
+ } |
+ |
+private: |
+ const RefPtrWillBeMember<HTMLCollection> m_collection; |
+}; |
+ |
+} // namespace |
+ |
+ValueIterable<Element*>::IterationSource* HTMLCollection::startIteration(ScriptState*, ExceptionState&) |
+{ |
+ return new HTMLCollectionIterationSource(this); |
+} |
+ |
using namespace HTMLNames; |
static bool shouldTypeOnlyIncludeDirectChildren(CollectionType type) |