Chromium Code Reviews| 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..9bcdadcb45e93a3ac6429e82bcc32f8cbed57324 |
| --- /dev/null |
| +++ b/third_party/WebKit/Source/core/dom/NodeList.cpp |
| @@ -0,0 +1,46 @@ |
| +// 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) |
|
esprehn
2015/10/03 05:07:45
reference
caitp (gmail)
2015/10/03 15:46:45
Done.
|
| + : m_nodeList(nodeList) |
| + { |
| + } |
| + |
| + bool next(ScriptState* scriptState, Node*& value, ExceptionState& exceptionState) override |
| + { |
| + if (m_index >= m_nodeList->length()) { |
|
esprehn
2015/10/03 05:07:45
accessing length causes us to cache the entire con
|
| + value = nullptr; |
| + return false; |
| + } |
| + value = m_nodeList->item(m_index); |
|
esprehn
2015/10/03 05:07:45
accessing out of bounds always returns a nullptr,
caitp (gmail)
2015/10/03 15:46:45
Done.
There's a presubmit rule preventing compari
|
| + return true; |
| + } |
| + |
| + 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); |
|
esprehn
2015/10/03 05:07:45
*this
|
| +} |
| + |
| +} // namespace blink |