Chromium Code Reviews| 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 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 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 const KeyType& select(ScriptState*, const KeyType& key, const Val ueType& value) | 96 static const KeyType& select(ScriptState*, const KeyType& key, const Val ueType& value) |
| 97 { | 97 { |
| 98 return key; | 98 return key; |
| 99 } | 99 } |
| 100 STATIC_ONLY(KeySelector); | |
|
haraken
2015/08/12 07:56:12
Ditto.
tasak
2015/08/12 09:13:26
Done.
| |
| 100 }; | 101 }; |
| 101 struct ValueSelector { | 102 struct ValueSelector { |
| 102 static const ValueType& select(ScriptState*, const KeyType& key, const V alueType& value) | 103 static const ValueType& select(ScriptState*, const KeyType& key, const V alueType& value) |
| 103 { | 104 { |
| 104 return value; | 105 return value; |
| 105 } | 106 } |
| 107 STATIC_ONLY(ValueSelector); | |
| 106 }; | 108 }; |
| 107 struct EntrySelector { | 109 struct EntrySelector { |
| 108 static Vector<ScriptValue, 2> select(ScriptState* scriptState, const Key Type& key, const ValueType& value) | 110 static Vector<ScriptValue, 2> select(ScriptState* scriptState, const Key Type& key, const ValueType& value) |
| 109 { | 111 { |
| 110 v8::Local<v8::Object> creationContext = scriptState->context()->Glob al(); | 112 v8::Local<v8::Object> creationContext = scriptState->context()->Glob al(); |
| 111 v8::Isolate* isolate = scriptState->isolate(); | 113 v8::Isolate* isolate = scriptState->isolate(); |
| 112 | 114 |
| 113 Vector<ScriptValue, 2> entry; | 115 Vector<ScriptValue, 2> entry; |
| 114 entry.append(ScriptValue(scriptState, toV8(key, creationContext, iso late))); | 116 entry.append(ScriptValue(scriptState, toV8(key, creationContext, iso late))); |
| 115 entry.append(ScriptValue(scriptState, toV8(value, creationContext, i solate))); | 117 entry.append(ScriptValue(scriptState, toV8(value, creationContext, i solate))); |
| 116 return entry; | 118 return entry; |
| 117 } | 119 } |
| 120 STATIC_ONLY(EntrySelector); | |
| 118 }; | 121 }; |
| 119 | 122 |
| 120 template <typename Selector> | 123 template <typename Selector> |
| 121 class IterableIterator final : public Iterator { | 124 class IterableIterator final : public Iterator { |
| 122 public: | 125 public: |
| 123 explicit IterableIterator(IterationSource* source) | 126 explicit IterableIterator(IterationSource* source) |
| 124 : m_source(source) | 127 : m_source(source) |
| 125 { | 128 { |
| 126 } | 129 } |
| 127 | 130 |
| (...skipping 68 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 |