| 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 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 58 | 58 |
| 59 while (true) { | 59 while (true) { |
| 60 KeyType key; | 60 KeyType key; |
| 61 ValueType value; | 61 ValueType value; |
| 62 | 62 |
| 63 if (!source->next(scriptState, key, value, exceptionState)) | 63 if (!source->next(scriptState, key, value, exceptionState)) |
| 64 return; | 64 return; |
| 65 | 65 |
| 66 ASSERT(!exceptionState.hadException()); | 66 ASSERT(!exceptionState.hadException()); |
| 67 | 67 |
| 68 args[0] = toV8(value, creationContext, isolate); | 68 args[0] = ToV8(value, creationContext, isolate); |
| 69 args[1] = toV8(key, creationContext, isolate); | 69 args[1] = ToV8(key, creationContext, isolate); |
| 70 if (args[0].IsEmpty() || args[1].IsEmpty()) { | 70 if (args[0].IsEmpty() || args[1].IsEmpty()) { |
| 71 if (tryCatch.HasCaught()) | 71 if (tryCatch.HasCaught()) |
| 72 exceptionState.rethrowV8Exception(tryCatch.Exception()); | 72 exceptionState.rethrowV8Exception(tryCatch.Exception()); |
| 73 return; | 73 return; |
| 74 } | 74 } |
| 75 | 75 |
| 76 v8::Local<v8::Value> result; | 76 v8::Local<v8::Value> result; |
| 77 if (!V8ScriptRunner::callFunction(v8Callback, | 77 if (!V8ScriptRunner::callFunction(v8Callback, |
| 78 scriptState->getExecutionContext(), | 78 scriptState->getExecutionContext(), |
| 79 v8ThisArg, 3, args, isolate) | 79 v8ThisArg, 3, args, isolate) |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 117 struct EntrySelector { | 117 struct EntrySelector { |
| 118 STATIC_ONLY(EntrySelector); | 118 STATIC_ONLY(EntrySelector); |
| 119 static Vector<ScriptValue, 2> select(ScriptState* scriptState, | 119 static Vector<ScriptValue, 2> select(ScriptState* scriptState, |
| 120 const KeyType& key, | 120 const KeyType& key, |
| 121 const ValueType& value) { | 121 const ValueType& value) { |
| 122 v8::Local<v8::Object> creationContext = scriptState->context()->Global(); | 122 v8::Local<v8::Object> creationContext = scriptState->context()->Global(); |
| 123 v8::Isolate* isolate = scriptState->isolate(); | 123 v8::Isolate* isolate = scriptState->isolate(); |
| 124 | 124 |
| 125 Vector<ScriptValue, 2> entry; | 125 Vector<ScriptValue, 2> entry; |
| 126 entry.push_back( | 126 entry.push_back( |
| 127 ScriptValue(scriptState, toV8(key, creationContext, isolate))); | 127 ScriptValue(scriptState, ToV8(key, creationContext, isolate))); |
| 128 entry.push_back( | 128 entry.push_back( |
| 129 ScriptValue(scriptState, toV8(value, creationContext, isolate))); | 129 ScriptValue(scriptState, ToV8(value, creationContext, isolate))); |
| 130 return entry; | 130 return entry; |
| 131 } | 131 } |
| 132 }; | 132 }; |
| 133 | 133 |
| 134 template <typename Selector> | 134 template <typename Selector> |
| 135 class IterableIterator final : public Iterator { | 135 class IterableIterator final : public Iterator { |
| 136 public: | 136 public: |
| 137 explicit IterableIterator(IterationSource* source) : m_source(source) {} | 137 explicit IterableIterator(IterationSource* source) : m_source(source) {} |
| 138 | 138 |
| 139 ScriptValue next(ScriptState* scriptState, | 139 ScriptValue next(ScriptState* scriptState, |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 209 class PairIterable : public Iterable<KeyType, ValueType> { | 209 class PairIterable : public Iterable<KeyType, ValueType> { |
| 210 public: | 210 public: |
| 211 Iterator* iterator(ScriptState* scriptState, ExceptionState& exceptionState) { | 211 Iterator* iterator(ScriptState* scriptState, ExceptionState& exceptionState) { |
| 212 return this->entriesForBinding(scriptState, exceptionState); | 212 return this->entriesForBinding(scriptState, exceptionState); |
| 213 } | 213 } |
| 214 }; | 214 }; |
| 215 | 215 |
| 216 } // namespace blink | 216 } // namespace blink |
| 217 | 217 |
| 218 #endif // Iterable_h | 218 #endif // Iterable_h |
| OLD | NEW |