OLD | NEW |
(Empty) | |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "config.h" |
| 6 #include "core/dom/NodeList.h" |
| 7 |
| 8 namespace blink { |
| 9 |
| 10 namespace { |
| 11 |
| 12 class NodeListIterationSource final : public ValueIterable<Node*>::IterationSour
ce { |
| 13 public: |
| 14 explicit NodeListIterationSource(NodeList* nodeList) |
| 15 : m_nodeList(nodeList) |
| 16 { |
| 17 } |
| 18 |
| 19 bool next(ScriptState* scriptState, Node*& value, ExceptionState& exceptionS
tate) override |
| 20 { |
| 21 if (m_index >= m_nodeList->length()) { |
| 22 value = nullptr; |
| 23 return false; |
| 24 } |
| 25 value = m_nodeList->item(m_index); |
| 26 return true; |
| 27 } |
| 28 |
| 29 DEFINE_INLINE_VIRTUAL_TRACE() |
| 30 { |
| 31 visitor->trace(m_nodeList); |
| 32 ValueIterable<Node*>::IterationSource::trace(visitor); |
| 33 } |
| 34 |
| 35 private: |
| 36 const RefPtrWillBeMember<NodeList> m_nodeList; |
| 37 }; |
| 38 |
| 39 } // namespace |
| 40 |
| 41 ValueIterable<Node*>::IterationSource* NodeList::startIteration(ScriptState*, Ex
ceptionState&) |
| 42 { |
| 43 return new NodeListIterationSource(this); |
| 44 } |
| 45 |
| 46 } // namespace blink |
OLD | NEW |