| Index: Source/bindings/templates/methods.cpp
|
| diff --git a/Source/bindings/templates/methods.cpp b/Source/bindings/templates/methods.cpp
|
| index 95ab1b1a27ee7e229e6b58dbe1bd64f7545a2bd4..171fbbe2b4785a775a217111fe6cb66e66fb552f 100644
|
| --- a/Source/bindings/templates/methods.cpp
|
| +++ b/Source/bindings/templates/methods.cpp
|
| @@ -24,7 +24,7 @@ static void {{method.name}}{{method.overload_index}}Method{{world_suffix}}(const
|
| {% if interface_name == 'EventTarget' %}
|
| if (DOMWindow* window = impl->toDOMWindow()) {
|
| if (!BindingSecurity::shouldAllowAccessToFrame(info.GetIsolate(), window->frame(), exceptionState)) {
|
| - exceptionState.throwIfNeeded();
|
| + {{throw_from_exception_state(method)}};
|
| return;
|
| }
|
| if (!window->document())
|
| @@ -32,14 +32,14 @@ static void {{method.name}}{{method.overload_index}}Method{{world_suffix}}(const
|
| }
|
| {% elif method.is_check_security_for_frame %}
|
| if (!BindingSecurity::shouldAllowAccessToFrame(info.GetIsolate(), impl->frame(), exceptionState)) {
|
| - exceptionState.throwIfNeeded();
|
| + {{throw_from_exception_state(method)}};
|
| return;
|
| }
|
| {% endif %}
|
| {% if method.is_check_security_for_node %}
|
| if (!BindingSecurity::shouldAllowAccessToNode(info.GetIsolate(), impl->{{method.name}}(exceptionState), exceptionState)) {
|
| v8SetReturnValueNull(info);
|
| - exceptionState.throwIfNeeded();
|
| + {{throw_from_exception_state(method)}};
|
| return;
|
| }
|
| {% endif %}
|
| @@ -134,15 +134,21 @@ OwnPtr<{{argument.idl_type}}> {{argument.name}} = {% if argument.is_nullable %}i
|
| {% elif argument.is_clamp %}{# argument.is_callback_interface #}
|
| {# NaN is treated as 0: http://www.w3.org/TR/WebIDL/#es-type-mapping #}
|
| {{argument.cpp_type}} {{argument.name}} = 0;
|
| +{% if method.idl_type == 'Promise' %}
|
| +TONATIVE_VOID_ASYNC(double, {{argument.name}}NativeValue, info[{{argument.index}}]->NumberValue(), info);
|
| +{% else %}
|
| TONATIVE_VOID(double, {{argument.name}}NativeValue, info[{{argument.index}}]->NumberValue());
|
| +{% endif %}
|
| if (!std::isnan({{argument.name}}NativeValue))
|
| {# IDL type is used for clamping, for the right bounds, since different
|
| IDL integer types have same internal C++ type (int or unsigned) #}
|
| {{argument.name}} = clampTo<{{argument.idl_type}}>({{argument.name}}NativeValue);
|
| {% elif argument.idl_type == 'SerializedScriptValue' %}
|
| {{argument.cpp_type}} {{argument.name}} = SerializedScriptValue::create(info[{{argument.index}}], 0, 0, exceptionState, info.GetIsolate());
|
| -if (exceptionState.throwIfNeeded())
|
| +if (exceptionState.hadException()) {
|
| + {{throw_from_exception_state(method)}};
|
| return;
|
| +}
|
| {% elif argument.is_variadic_wrapper_type %}
|
| {{argument.vector_type}}<{{argument.cpp_type}} > {{argument.name}};
|
| for (int i = {{argument.index}}; i < info.Length(); ++i) {
|
| @@ -153,9 +159,13 @@ for (int i = {{argument.index}}; i < info.Length(); ++i) {
|
| }
|
| {{argument.name}}.append(V8{{argument.idl_type}}::toNative(v8::Handle<v8::Object>::Cast(info[i])));
|
| }
|
| +{% else %}{# argument.is_nullable #}
|
| +{% if method.idl_type == 'Promise' %}
|
| +{{argument.v8_value_to_local_cpp_value_async}};
|
| {% else %}
|
| {{argument.v8_value_to_local_cpp_value}};
|
| {% endif %}
|
| +{% endif %}{# argument.is_nullable #}
|
| {% if argument.enum_validation_expression %}
|
| {# Methods throw on invalid enum values: http://www.w3.org/TR/WebIDL/#idl-enums #}
|
| String string = {{argument.name}};
|
| @@ -208,8 +218,10 @@ RefPtr<ScriptArguments> scriptArguments(createScriptArguments(info, {{method.num
|
| {% endif %}
|
| {# Post-call #}
|
| {% if method.is_raises_exception %}
|
| -if (exceptionState.throwIfNeeded())
|
| +if (exceptionState.hadException()) {
|
| + {{throw_from_exception_state(method)}};
|
| return;
|
| +}
|
| {% endif %}
|
| {# Set return value #}
|
| {% if method.is_constructor %}
|
| @@ -245,17 +257,44 @@ v8SetReturnValueNull(info);
|
| {% macro throw_type_error(method, error_message) %}
|
| {% if method.has_exception_state %}
|
| exceptionState.throwTypeError({{error_message}});
|
| -exceptionState.throwIfNeeded();
|
| +{{throw_from_exception_state(method)}};
|
| {%- elif method.is_constructor %}
|
| +{% if method.idl_type == 'Promise' %}
|
| +v8SetReturnValue(info, ScriptPromise::rejectWithTypeError(ExceptionMessages::failedToConstruct("{{interface_name}}", {{error_message}}), info.GetIsolate()).v8Value());
|
| +{%- else %}
|
| throwTypeError(ExceptionMessages::failedToConstruct("{{interface_name}}", {{error_message}}), info.GetIsolate());
|
| +{%- endif %}
|
| +{%- else %}{# method.has_exception_state #}
|
| +{% if method.idl_type == 'Promise' %}
|
| +v8SetReturnValue(info, ScriptPromise::rejectWithTypeError(ExceptionMessages::failedToExecute("{{method.name}}", "{{interface_name}}", {{error_message}}), info.GetIsolate()).v8Value());
|
| {%- else %}
|
| throwTypeError(ExceptionMessages::failedToExecute("{{method.name}}", "{{interface_name}}", {{error_message}}), info.GetIsolate());
|
| {%- endif %}
|
| +{%- endif %}{# method.has_exception_state #}
|
| +{% endmacro %}
|
| +
|
| +
|
| +{######################################}
|
| +{% macro throw_from_exception_state(method) %}
|
| +{% if method.idl_type == 'Promise' %}
|
| +v8SetReturnValue(info, exceptionState.reject().v8Value())
|
| +{%- else %}
|
| +exceptionState.throwIfNeeded()
|
| +{%- endif %}
|
| {% endmacro %}
|
|
|
|
|
| {######################################}
|
| {% macro throw_arity_type_error(method, number_of_required_arguments) %}
|
| +{% if method.idl_type == 'Promise' %}
|
| +{% if method.has_exception_state %}
|
| +v8SetReturnValue(info, ScriptPromise::rejectWithArityTypeError(exceptionState, {{number_of_required_arguments}}, info.Length()).v8Value())
|
| +{%- elif method.is_constructor %}
|
| +v8SetReturnValue(info, ScriptPromise::rejectWithArityTypeErrorForConstructor("{{interface_name}}", {{number_of_required_arguments}}, info.Length(), info.GetIsolate().v8Value())
|
| +{%- else %}
|
| +v8SetReturnValue(info, ScriptPromise::rejectWithArityTypeErrorForMethod("{{method.name}}", "{{interface_name}}", {{number_of_required_arguments}}, info.Length(), info.GetIsolate()).v8Value())
|
| +{%- endif %}
|
| +{%- else %}{# methods.idl_type == 'Promise' #}
|
| {% if method.has_exception_state %}
|
| throwArityTypeError(exceptionState, {{number_of_required_arguments}}, info.Length())
|
| {%- elif method.is_constructor %}
|
| @@ -263,6 +302,7 @@ throwArityTypeErrorForConstructor("{{interface_name}}", {{number_of_required_arg
|
| {%- else %}
|
| throwArityTypeErrorForMethod("{{method.name}}", "{{interface_name}}", {{number_of_required_arguments}}, info.Length(), info.GetIsolate())
|
| {%- endif %}
|
| +{%- endif %}{# methods.idl_type == 'Promise' #}
|
| {% endmacro %}
|
|
|
|
|
|
|