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

Unified Diff: Source/bindings/core/v8/V8ErrorHandler.cpp

Issue 1061503005: bindings: Use Maybe version of Call() (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 5 years, 8 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
« no previous file with comments | « Source/bindings/core/v8/V8AbstractEventListener.h ('k') | Source/bindings/core/v8/V8EventListener.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/bindings/core/v8/V8ErrorHandler.cpp
diff --git a/Source/bindings/core/v8/V8ErrorHandler.cpp b/Source/bindings/core/v8/V8ErrorHandler.cpp
index a1239c174752f8a8ba484563a0310db1e7fcd324..e7d9830db24620536f8f1b4dabe23bf43642c359 100644
--- a/Source/bindings/core/v8/V8ErrorHandler.cpp
+++ b/Source/bindings/core/v8/V8ErrorHandler.cpp
@@ -57,26 +57,32 @@ v8::Local<v8::Value> V8ErrorHandler::callListenerFunction(ScriptState* scriptSta
return v8::Null(isolate());
v8::Local<v8::Object> listener = getListenerObject(scriptState->executionContext());
- v8::Local<v8::Value> returnValue;
- if (!listener.IsEmpty() && listener->IsFunction()) {
- v8::Local<v8::Function> callFunction = v8::Local<v8::Function>::Cast(listener);
- v8::Local<v8::Object> thisValue = scriptState->context()->Global();
+ if (listener.IsEmpty() || !listener->IsFunction())
+ return v8::Null(isolate());
- v8::Local<v8::Object> eventObject;
- if (!jsEvent->ToObject(scriptState->context()).ToLocal(&eventObject))
- return v8::Null(isolate());
- v8::Local<v8::Value> error = V8HiddenValue::getHiddenValue(isolate(), eventObject, V8HiddenValue::error(isolate()));
- if (error.IsEmpty())
- error = v8::Null(isolate());
+ v8::Local<v8::Function> callFunction = v8::Local<v8::Function>::Cast(listener);
+ v8::Local<v8::Object> thisValue = scriptState->context()->Global();
+
+ v8::Local<v8::Object> eventObject;
+ if (!jsEvent->ToObject(scriptState->context()).ToLocal(&eventObject))
+ return v8::Null(isolate());
+ v8::Local<v8::Value> error = V8HiddenValue::getHiddenValue(isolate(), eventObject, V8HiddenValue::error(isolate()));
+ if (error.IsEmpty())
+ error = v8::Null(isolate());
- v8::Local<v8::Value> parameters[5] = { v8String(isolate(), errorEvent->message()), v8String(isolate(), errorEvent->filename()), v8::Integer::New(isolate(), errorEvent->lineno()), v8::Integer::New(isolate(), errorEvent->colno()), error };
- v8::TryCatch tryCatch;
- tryCatch.SetVerbose(true);
- if (scriptState->executionContext()->isWorkerGlobalScope())
- returnValue = V8ScriptRunner::callFunction(callFunction, scriptState->executionContext(), thisValue, WTF_ARRAY_LENGTH(parameters), parameters, isolate());
- else
- returnValue = ScriptController::callFunction(scriptState->executionContext(), callFunction, thisValue, WTF_ARRAY_LENGTH(parameters), parameters, isolate());
+ v8::Local<v8::Value> parameters[5] = { v8String(isolate(), errorEvent->message()), v8String(isolate(), errorEvent->filename()), v8::Integer::New(isolate(), errorEvent->lineno()), v8::Integer::New(isolate(), errorEvent->colno()), error };
+ v8::TryCatch tryCatch;
+ tryCatch.SetVerbose(true);
+ v8::MaybeLocal<v8::Value> result;
+ if (scriptState->executionContext()->isWorkerGlobalScope()) {
+ result = V8ScriptRunner::callFunction(callFunction, scriptState->executionContext(), thisValue, WTF_ARRAY_LENGTH(parameters), parameters, isolate());
+ } else {
+ result = ScriptController::callFunction(scriptState->executionContext(), callFunction, thisValue, WTF_ARRAY_LENGTH(parameters), parameters, isolate());
}
+ v8::Local<v8::Value> returnValue;
+ if (!result.ToLocal(&returnValue))
+ return v8::Null(isolate());
+
return returnValue;
}
« no previous file with comments | « Source/bindings/core/v8/V8AbstractEventListener.h ('k') | Source/bindings/core/v8/V8EventListener.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698