OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef Iterable_h | 5 #ifndef Iterable_h |
6 #define Iterable_h | 6 #define Iterable_h |
7 | 7 |
8 #include "bindings/core/v8/V8IteratorResultValue.h" | 8 #include "bindings/core/v8/V8IteratorResultValue.h" |
9 #include "bindings/core/v8/V8ScriptRunner.h" | 9 #include "bindings/core/v8/V8ScriptRunner.h" |
10 #include "core/dom/Iterator.h" | 10 #include "core/dom/Iterator.h" |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
75 } | 75 } |
76 | 76 |
77 class IterationSource : public GarbageCollectedFinalized<IterationSource> { | 77 class IterationSource : public GarbageCollectedFinalized<IterationSource> { |
78 public: | 78 public: |
79 virtual ~IterationSource() { } | 79 virtual ~IterationSource() { } |
80 | 80 |
81 // If end of iteration has been reached or an exception thrown: return f
alse. | 81 // If end of iteration has been reached or an exception thrown: return f
alse. |
82 // Otherwise: set |key| and |value| and return true. | 82 // Otherwise: set |key| and |value| and return true. |
83 virtual bool next(ScriptState*, KeyType&, ValueType&, ExceptionState&) =
0; | 83 virtual bool next(ScriptState*, KeyType&, ValueType&, ExceptionState&) =
0; |
84 | 84 |
85 virtual void trace(Visitor*) { } | 85 DEFINE_INLINE_VIRTUAL_TRACE() { } |
86 }; | 86 }; |
87 | 87 |
88 private: | 88 private: |
89 virtual IterationSource* startIteration(ScriptState*, ExceptionState&) = 0; | 89 virtual IterationSource* startIteration(ScriptState*, ExceptionState&) = 0; |
90 | 90 |
91 struct KeySelector { | 91 struct KeySelector { |
92 static const KeyType& select(ScriptState*, const KeyType& key, const Val
ueType& value) | 92 static const KeyType& select(ScriptState*, const KeyType& key, const Val
ueType& value) |
93 { | 93 { |
94 return key; | 94 return key; |
95 } | 95 } |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
130 return v8IteratorResultDone(scriptState); | 130 return v8IteratorResultDone(scriptState); |
131 | 131 |
132 return v8IteratorResult(scriptState, Selector::select(scriptState, k
ey, value)); | 132 return v8IteratorResult(scriptState, Selector::select(scriptState, k
ey, value)); |
133 } | 133 } |
134 | 134 |
135 ScriptValue next(ScriptState* scriptState, ScriptValue, ExceptionState&
exceptionState) override | 135 ScriptValue next(ScriptState* scriptState, ScriptValue, ExceptionState&
exceptionState) override |
136 { | 136 { |
137 return next(scriptState, exceptionState); | 137 return next(scriptState, exceptionState); |
138 } | 138 } |
139 | 139 |
140 void trace(Visitor* visitor) override | 140 DEFINE_INLINE_VIRTUAL_TRACE() |
141 { | 141 { |
142 visitor->trace(m_source); | 142 visitor->trace(m_source); |
143 Iterator::trace(visitor); | 143 Iterator::trace(visitor); |
144 } | 144 } |
145 | 145 |
146 private: | 146 private: |
147 Member<IterationSource> m_source; | 147 Member<IterationSource> m_source; |
148 }; | 148 }; |
149 }; | 149 }; |
150 | 150 |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
192 public: | 192 public: |
193 Iterator* iterator(ScriptState* scriptState, ExceptionState& exceptionState) | 193 Iterator* iterator(ScriptState* scriptState, ExceptionState& exceptionState) |
194 { | 194 { |
195 return this->entriesForBinding(scriptState, exceptionState); | 195 return this->entriesForBinding(scriptState, exceptionState); |
196 } | 196 } |
197 }; | 197 }; |
198 | 198 |
199 } // namespace blink | 199 } // namespace blink |
200 | 200 |
201 #endif // Iterable_h | 201 #endif // Iterable_h |
OLD | NEW |