| 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/ExceptionState.h" | 8 #include "bindings/core/v8/ExceptionState.h" |
| 9 #include "bindings/core/v8/V8IteratorResultValue.h" | 9 #include "bindings/core/v8/V8IteratorResultValue.h" |
| 10 #include "bindings/core/v8/V8ScriptRunner.h" | 10 #include "bindings/core/v8/V8ScriptRunner.h" |
| (...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 168 visitor->Trace(source_); | 168 visitor->Trace(source_); |
| 169 Iterator::Trace(visitor); | 169 Iterator::Trace(visitor); |
| 170 } | 170 } |
| 171 | 171 |
| 172 private: | 172 private: |
| 173 Member<IterationSource> source_; | 173 Member<IterationSource> source_; |
| 174 }; | 174 }; |
| 175 }; | 175 }; |
| 176 | 176 |
| 177 // Utiltity mixin base-class for classes implementing IDL interfaces with | 177 // Utiltity mixin base-class for classes implementing IDL interfaces with |
| 178 // "iterable<T1, T2>". | 178 // "iterable<T1, T2>" or "maplike<T1, T2>". |
| 179 template <typename KeyType, typename ValueType> | 179 template <typename KeyType, typename ValueType> |
| 180 class PairIterable : public Iterable<KeyType, ValueType> { | 180 class PairIterable : public Iterable<KeyType, ValueType> { |
| 181 public: | 181 public: |
| 182 Iterator* GetIterator(ScriptState* script_state, | 182 Iterator* GetIterator(ScriptState* script_state, |
| 183 ExceptionState& exception_state) { | 183 ExceptionState& exception_state) { |
| 184 return this->entriesForBinding(script_state, exception_state); | 184 return this->entriesForBinding(script_state, exception_state); |
| 185 } | 185 } |
| 186 }; | 186 }; |
| 187 | 187 |
| 188 // Utiltity mixin base-class for classes implementing IDL interfaces with |
| 189 // "setlike<V>" (not "iterable<V>"). |
| 190 // IDL interfaces with "iterable<V>" (value iterators) inherit @@iterator, |
| 191 // values(), entries(), keys() and forEach() from the %ArrayPrototype% |
| 192 // intrinsic object automatically. |
| 193 template <typename ValueType> |
| 194 class SetlikeIterable : public Iterable<ValueType, ValueType> { |
| 195 public: |
| 196 Iterator* GetIterator(ScriptState* script_state, |
| 197 ExceptionState& exception_state) { |
| 198 return this->valuesForBinding(script_state, exception_state); |
| 199 } |
| 200 }; |
| 201 |
| 188 } // namespace blink | 202 } // namespace blink |
| 189 | 203 |
| 190 #endif // Iterable_h | 204 #endif // Iterable_h |
| OLD | NEW |