Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(109)

Unified Diff: third_party/WebKit/Source/bindings/core/v8/Iterable.h

Issue 1409433003: CSS Font Loading: make FontFaceSet Setlike (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: oilpan type fix Created 5 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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()

Powered by Google App Engine
This is Rietveld 408576698