| Index: third_party/WebKit/Source/bindings/core/v8/Iterable.h
|
| diff --git a/third_party/WebKit/Source/bindings/core/v8/Iterable.h b/third_party/WebKit/Source/bindings/core/v8/Iterable.h
|
| index e91c67b5c875dd335a6aefdc872111defc0e64e9..4365f0a0893861d94963d0a415664258774f7124 100644
|
| --- a/third_party/WebKit/Source/bindings/core/v8/Iterable.h
|
| +++ b/third_party/WebKit/Source/bindings/core/v8/Iterable.h
|
| @@ -20,7 +20,7 @@ public:
|
| IterationSource* source = this->startIteration(scriptState, exceptionState);
|
| if (!source)
|
| return nullptr;
|
| - return new IterableIterator<KeySelector>(source);
|
| + return createKeyIterator(source);
|
| }
|
|
|
| Iterator* valuesForBinding(ScriptState* scriptState, ExceptionState& exceptionState)
|
| @@ -28,7 +28,7 @@ public:
|
| IterationSource* source = this->startIteration(scriptState, exceptionState);
|
| if (!source)
|
| return nullptr;
|
| - return new IterableIterator<ValueSelector>(source);
|
| + return createValueIterator(source);
|
| }
|
|
|
| Iterator* entriesForBinding(ScriptState* scriptState, ExceptionState& exceptionState)
|
| @@ -36,7 +36,7 @@ public:
|
| IterationSource* source = this->startIteration(scriptState, exceptionState);
|
| if (!source)
|
| return nullptr;
|
| - return new IterableIterator<EntrySelector>(source);
|
| + return createEntryIterator(source);
|
| }
|
|
|
| void forEachForBinding(ScriptState* scriptState, const ScriptValue& thisValue, const ScriptValue& callback, const ScriptValue& thisArg, ExceptionState& exceptionState)
|
| @@ -89,8 +89,10 @@ public:
|
| DEFINE_INLINE_VIRTUAL_TRACE() { }
|
| };
|
|
|
| -private:
|
| - virtual IterationSource* startIteration(ScriptState*, ExceptionState&) = 0;
|
| +protected:
|
| + virtual Iterator* createKeyIterator(IterationSource* source) { return new IterableIterator<KeySelector>(source); }
|
| + virtual Iterator* createValueIterator(IterationSource* source) { return new IterableIterator<ValueSelector>(source); }
|
| + virtual Iterator* createEntryIterator(IterationSource* source) { return new IterableIterator<MapEntrySelector>(source); }
|
|
|
| struct KeySelector {
|
| STATIC_ONLY(KeySelector);
|
| @@ -106,8 +108,21 @@ private:
|
| return value;
|
| }
|
| };
|
| - struct EntrySelector {
|
| - STATIC_ONLY(EntrySelector);
|
| + struct SetEntrySelector {
|
| + STATIC_ONLY(SetEntrySelector);
|
| + static Vector<ScriptValue, 2> select(ScriptState* scriptState, const KeyType& key, const ValueType& value)
|
| + {
|
| + v8::Local<v8::Object> creationContext = scriptState->context()->Global();
|
| + v8::Isolate* isolate = scriptState->isolate();
|
| +
|
| + Vector<ScriptValue, 2> entry;
|
| + entry.append(ScriptValue(scriptState, toV8(value, creationContext, isolate)));
|
| + entry.append(ScriptValue(scriptState, toV8(value, creationContext, isolate)));
|
| + return entry;
|
| + }
|
| + };
|
| + struct MapEntrySelector {
|
| + STATIC_ONLY(MapEntrySelector);
|
| static Vector<ScriptValue, 2> select(ScriptState* scriptState, const KeyType& key, const ValueType& value)
|
| {
|
| v8::Local<v8::Object> creationContext = scriptState->context()->Global();
|
| @@ -153,6 +168,9 @@ private:
|
| private:
|
| Member<IterationSource> m_source;
|
| };
|
| +
|
| +private:
|
| + virtual IterationSource* startIteration(ScriptState*, ExceptionState&) = 0;
|
| };
|
|
|
| // Utiltity mixin base-class for classes implementing IDL interfaces with "iterable<T>".
|
| @@ -164,6 +182,9 @@ public:
|
| return this->valuesForBinding(scriptState, exceptionState);
|
| }
|
|
|
| + Iterator* createKeyIterator(typename Iterable<unsigned, ValueType>::IterationSource* source) override { return this->createValueIterator(source); }
|
| + Iterator* createEntryIterator(typename Iterable<unsigned, ValueType>::IterationSource* source) override { return new typename Iterable<unsigned, ValueType>::template IterableIterator<typename Iterable<unsigned, ValueType>::SetEntrySelector>(source); }
|
| +
|
| class IterationSource : public Iterable<unsigned, ValueType>::IterationSource {
|
| public:
|
| IterationSource()
|
|
|