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

Unified Diff: third_party/WebKit/Source/bindings/core/v8/V8Binding.cpp

Issue 2316263003: Add toImplSequence() (Closed)
Patch Set: comments Created 4 years, 3 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/V8Binding.cpp
diff --git a/third_party/WebKit/Source/bindings/core/v8/V8Binding.cpp b/third_party/WebKit/Source/bindings/core/v8/V8Binding.cpp
index d0bb9de194cf24ec8ad2487adc5c89c2ed997404..64c806effb0e00657aa309f18873126eba93e42f 100644
--- a/third_party/WebKit/Source/bindings/core/v8/V8Binding.cpp
+++ b/third_party/WebKit/Source/bindings/core/v8/V8Binding.cpp
@@ -905,6 +905,28 @@ v8::Local<v8::Function> getBoundFunction(v8::Local<v8::Function> function)
return boundFunction->IsFunction() ? v8::Local<v8::Function>::Cast(boundFunction) : function;
}
+v8::MaybeLocal<v8::Object> getEsIterator(v8::Isolate* isolate, v8::Local<v8::Object> object, ExceptionState& exceptionState)
+{
+ v8::Local<v8::Context> context = isolate->GetCurrentContext();
+ v8::Local<v8::Value> iteratorGetter;
+ if (!object->Get(context, v8::Symbol::GetIterator(isolate)).ToLocal(&iteratorGetter))
+ return v8::MaybeLocal<v8::Object>();
+ if (!iteratorGetter->IsFunction()) {
+ exceptionState.throwTypeError("Iterator getter is not callable.");
+ return v8::MaybeLocal<v8::Object>();
+ }
+
+ v8::Local<v8::Function> getterFunction = iteratorGetter.As<v8::Function>();
+ v8::Local<v8::Value> iterator;
+ if (!V8ScriptRunner::callFunction(getterFunction, toExecutionContext(context), object, 0, nullptr, isolate).ToLocal(&iterator))
+ return v8::MaybeLocal<v8::Object>();
+ if (!iterator->IsObject()) {
+ exceptionState.throwTypeError("Iterator is not an object.");
+ return v8::MaybeLocal<v8::Object>();
+ }
+ return v8::MaybeLocal<v8::Object>(iterator.As<v8::Object>());
+}
+
bool addHiddenValueToArray(v8::Isolate* isolate, v8::Local<v8::Object> object, v8::Local<v8::Value> value, int arrayIndex)
{
ASSERT(!value.IsEmpty());

Powered by Google App Engine
This is Rietveld 408576698