| Index: third_party/WebKit/Source/bindings/templates/callback_function.cpp.tmpl
|
| diff --git a/third_party/WebKit/Source/bindings/templates/callback_function.cpp.tmpl b/third_party/WebKit/Source/bindings/templates/callback_function.cpp.tmpl
|
| index def34ae745b35433cc3fa9788fe06de4c50002a2..50e3b25f6728ce7f06c67f4a1120ba8640239e42 100644
|
| --- a/third_party/WebKit/Source/bindings/templates/callback_function.cpp.tmpl
|
| +++ b/third_party/WebKit/Source/bindings/templates/callback_function.cpp.tmpl
|
| @@ -12,7 +12,7 @@
|
| namespace blink {
|
|
|
| // static
|
| -{{cpp_class}}* {{cpp_class}}::create(ScriptState* scriptState, v8::Local<v8::Value> callback){
|
| +{{cpp_class}}* {{cpp_class}}::create(ScriptState* scriptState, v8::Local<v8::Value> callback) {
|
| if (isUndefinedOrNull(callback))
|
| return nullptr;
|
| return new {{cpp_class}}(scriptState, v8::Local<v8::Function>::Cast(callback));
|
| @@ -24,13 +24,14 @@ namespace blink {
|
| DCHECK(!m_callback.isEmpty());
|
| }
|
|
|
| -DEFINE_TRACE({{cpp_class}}) {}
|
| -
|
| DEFINE_TRACE_WRAPPERS({{cpp_class}}) {
|
| visitor->traceWrappers(m_callback.cast<v8::Value>());
|
| }
|
|
|
| bool {{cpp_class}}::call({{argument_declarations | join(', ')}}) {
|
| + if (m_callback.isEmpty())
|
| + return false;
|
| +
|
| if (!m_scriptState->contextIsValid())
|
| return false;
|
|
|
| @@ -39,39 +40,44 @@ bool {{cpp_class}}::call({{argument_declarations | join(', ')}}) {
|
| if (context->isContextSuspended() || context->isContextDestroyed())
|
| return false;
|
|
|
| - if (m_callback.isEmpty())
|
| - return false;
|
| -
|
| // TODO(bashi): Make sure that using DummyExceptionStateForTesting is OK.
|
| // crbug.com/653769
|
| DummyExceptionStateForTesting exceptionState;
|
| ScriptState::Scope scope(m_scriptState.get());
|
| + v8::Isolate* isolate = m_scriptState->isolate();
|
| +
|
| + v8::Local<v8::Value> thisValue = ToV8(
|
| + scriptWrappable,
|
| + m_scriptState->context()->Global(),
|
| + isolate);
|
|
|
| {% for argument in arguments %}
|
| v8::Local<v8::Value> {{argument.argument_name}} = {{argument.cpp_value_to_v8_value}};
|
| {% endfor %}
|
| -
|
| - v8::Local<v8::Value> thisValue = ToV8(scriptWrappable, m_scriptState->context()->Global(), m_scriptState->isolate());
|
| -
|
| {% if arguments %}
|
| v8::Local<v8::Value> argv[] = { {{arguments | join(', ', 'argument_name')}} };
|
| {% else %}
|
| {# Empty array initializers are illegal, and don\'t compile in MSVC. #}
|
| v8::Local<v8::Value> *argv = nullptr;
|
| {% endif %}
|
| -
|
| - v8::Local<v8::Value> v8ReturnValue;
|
| - v8::TryCatch exceptionCatcher(m_scriptState->isolate());
|
| + v8::TryCatch exceptionCatcher(isolate);
|
| exceptionCatcher.SetVerbose(true);
|
|
|
| - if (V8ScriptRunner::callFunction(m_callback.newLocal(m_scriptState->isolate()), m_scriptState->getExecutionContext(), thisValue, {{arguments | length}}, argv, m_scriptState->isolate()).ToLocal(&v8ReturnValue)) {
|
| - {% if return_value %}
|
| - {{v8_value_to_local_cpp_value(return_value) | indent(8)}}
|
| - returnValue = cppValue;
|
| - {% endif %}
|
| - return true;
|
| + v8::Local<v8::Value> v8ReturnValue;
|
| + if (!V8ScriptRunner::callFunction(m_callback.newLocal(isolate),
|
| + context,
|
| + thisValue,
|
| + {{arguments | length}},
|
| + argv,
|
| + isolate).ToLocal(&v8ReturnValue)) {
|
| + return false;
|
| }
|
| - return false;
|
| +
|
| + {% if return_value %}
|
| + {{v8_value_to_local_cpp_value(return_value) | indent(2)}}
|
| + returnValue = cppValue;
|
| + {% endif %}
|
| + return true;
|
| }
|
|
|
| {{cpp_class}}* NativeValueTraits<{{cpp_class}}>::nativeValue(v8::Isolate* isolate, v8::Local<v8::Value> value, ExceptionState& exceptionState) {
|
|
|