| 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 1fd35321f4c756844000000ebf80853098d30859..e73d99f406765bd1276a38300513dca04d3c30d9 100644
|
| --- a/third_party/WebKit/Source/bindings/templates/callback_function.cpp.tmpl
|
| +++ b/third_party/WebKit/Source/bindings/templates/callback_function.cpp.tmpl
|
| @@ -13,67 +13,61 @@ namespace blink {
|
|
|
| {{cpp_class}}::{{cpp_class}}(ScriptState* scriptState, v8::Local<v8::Function> callback)
|
| : m_scriptState(scriptState),
|
| - m_callback(scriptState->isolate(), callback)
|
| -{
|
| - DCHECK(!m_callback.isEmpty());
|
| - m_callback.setPhantom();
|
| + m_callback(scriptState->isolate(), callback) {
|
| + DCHECK(!m_callback.isEmpty());
|
| + m_callback.setPhantom();
|
| }
|
|
|
| -DEFINE_TRACE({{cpp_class}})
|
| -{
|
| -}
|
| +DEFINE_TRACE({{cpp_class}}) {}
|
|
|
| -DEFINE_TRACE_WRAPPERS({{cpp_class}})
|
| -{
|
| - visitor->traceWrappers(&m_callback.cast<v8::Object>());
|
| +DEFINE_TRACE_WRAPPERS({{cpp_class}}) {
|
| + visitor->traceWrappers(&m_callback.cast<v8::Object>());
|
| }
|
|
|
| -bool {{cpp_class}}::call({{argument_declarations | join(', ')}})
|
| -{
|
| - if (!m_scriptState->contextIsValid())
|
| - return false;
|
| +bool {{cpp_class}}::call({{argument_declarations | join(', ')}}) {
|
| + if (!m_scriptState->contextIsValid())
|
| + return false;
|
| +
|
| + ExecutionContext* context = m_scriptState->getExecutionContext();
|
| + DCHECK(context);
|
| + if (context->activeDOMObjectsAreSuspended() || context->activeDOMObjectsAreStopped())
|
| + return false;
|
| +
|
| + if (m_callback.isEmpty())
|
| + return false;
|
|
|
| - ExecutionContext* context = m_scriptState->getExecutionContext();
|
| - DCHECK(context);
|
| - if (context->activeDOMObjectsAreSuspended() || context->activeDOMObjectsAreStopped())
|
| - return false;
|
| + // TODO(bashi): Make sure that using TrackExceptionState is OK.
|
| + // crbug.com/653769
|
| + TrackExceptionState exceptionState;
|
| + ScriptState::Scope scope(m_scriptState.get());
|
|
|
| - if (m_callback.isEmpty())
|
| - return false;
|
| + {% for argument in arguments %}
|
| + v8::Local<v8::Value> {{argument.argument_name}} = {{argument.cpp_value_to_v8_value}};
|
| + {% endfor %}
|
|
|
| - // TODO(bashi): Make sure that using TrackExceptionState is OK.
|
| - // crbug.com/653769
|
| - TrackExceptionState exceptionState;
|
| - ScriptState::Scope scope(m_scriptState.get());
|
| + v8::Local<v8::Value> thisValue = toV8(scriptWrappable, m_scriptState->context()->Global(), m_scriptState->isolate());
|
|
|
| - {% for argument in arguments %}
|
| - v8::Local<v8::Value> {{argument.argument_name}} = {{argument.cpp_value_to_v8_value}};
|
| - {% endfor %}
|
| + {% 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> thisValue = toV8(scriptWrappable, m_scriptState->context()->Global(), m_scriptState->isolate());
|
| + v8::Local<v8::Value> v8ReturnValue;
|
| + v8::TryCatch exceptionCatcher(m_scriptState->isolate());
|
| + exceptionCatcher.SetVerbose(true);
|
|
|
| - {% 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;
|
| + 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 %}
|
| -
|
| - v8::Local<v8::Value> v8ReturnValue;
|
| - v8::TryCatch exceptionCatcher(m_scriptState->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;
|
| - }
|
| - return false;
|
| + return true;
|
| + }
|
| + return false;
|
| }
|
|
|
| -} // namespace blink
|
| +} // namespace blink
|
|
|
| {% endfilter %}{# format_blink_cpp_source_code #}
|
|
|