Chromium Code Reviews| 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) | |
|
esprehn
2015/10/03 05:07:45
reference
caitp (gmail)
2015/10/03 15:46:45
Done.
| |
| 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()) { | |
|
esprehn
2015/10/03 05:07:45
accessing length causes us to cache the entire con
| |
| 22 value = nullptr; | |
| 23 return false; | |
| 24 } | |
| 25 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
| |
| 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); | |
|
esprehn
2015/10/03 05:07:45
*this
| |
| 44 } | |
| 45 | |
| 46 } // namespace blink | |
| OLD | NEW |