| 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 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 86 // Otherwise: set |key| and |value| and return true. | 86 // Otherwise: set |key| and |value| and return true. |
| 87 virtual bool next(ScriptState*, KeyType&, ValueType&, ExceptionState&) =
0; | 87 virtual bool next(ScriptState*, KeyType&, ValueType&, ExceptionState&) =
0; |
| 88 | 88 |
| 89 DEFINE_INLINE_VIRTUAL_TRACE() { } | 89 DEFINE_INLINE_VIRTUAL_TRACE() { } |
| 90 }; | 90 }; |
| 91 | 91 |
| 92 private: | 92 private: |
| 93 virtual IterationSource* startIteration(ScriptState*, ExceptionState&) = 0; | 93 virtual IterationSource* startIteration(ScriptState*, ExceptionState&) = 0; |
| 94 | 94 |
| 95 struct KeySelector { | 95 struct KeySelector { |
| 96 STATIC_ONLY(KeySelector); |
| 96 static const KeyType& select(ScriptState*, const KeyType& key, const Val
ueType& value) | 97 static const KeyType& select(ScriptState*, const KeyType& key, const Val
ueType& value) |
| 97 { | 98 { |
| 98 return key; | 99 return key; |
| 99 } | 100 } |
| 100 }; | 101 }; |
| 101 struct ValueSelector { | 102 struct ValueSelector { |
| 103 STATIC_ONLY(ValueSelector); |
| 102 static const ValueType& select(ScriptState*, const KeyType& key, const V
alueType& value) | 104 static const ValueType& select(ScriptState*, const KeyType& key, const V
alueType& value) |
| 103 { | 105 { |
| 104 return value; | 106 return value; |
| 105 } | 107 } |
| 106 }; | 108 }; |
| 107 struct EntrySelector { | 109 struct EntrySelector { |
| 110 STATIC_ONLY(EntrySelector); |
| 108 static Vector<ScriptValue, 2> select(ScriptState* scriptState, const Key
Type& key, const ValueType& value) | 111 static Vector<ScriptValue, 2> select(ScriptState* scriptState, const Key
Type& key, const ValueType& value) |
| 109 { | 112 { |
| 110 v8::Local<v8::Object> creationContext = scriptState->context()->Glob
al(); | 113 v8::Local<v8::Object> creationContext = scriptState->context()->Glob
al(); |
| 111 v8::Isolate* isolate = scriptState->isolate(); | 114 v8::Isolate* isolate = scriptState->isolate(); |
| 112 | 115 |
| 113 Vector<ScriptValue, 2> entry; | 116 Vector<ScriptValue, 2> entry; |
| 114 entry.append(ScriptValue(scriptState, toV8(key, creationContext, iso
late))); | 117 entry.append(ScriptValue(scriptState, toV8(key, creationContext, iso
late))); |
| 115 entry.append(ScriptValue(scriptState, toV8(value, creationContext, i
solate))); | 118 entry.append(ScriptValue(scriptState, toV8(value, creationContext, i
solate))); |
| 116 return entry; | 119 return entry; |
| 117 } | 120 } |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 196 public: | 199 public: |
| 197 Iterator* iterator(ScriptState* scriptState, ExceptionState& exceptionState) | 200 Iterator* iterator(ScriptState* scriptState, ExceptionState& exceptionState) |
| 198 { | 201 { |
| 199 return this->entriesForBinding(scriptState, exceptionState); | 202 return this->entriesForBinding(scriptState, exceptionState); |
| 200 } | 203 } |
| 201 }; | 204 }; |
| 202 | 205 |
| 203 } // namespace blink | 206 } // namespace blink |
| 204 | 207 |
| 205 #endif // Iterable_h | 208 #endif // Iterable_h |
| OLD | NEW |