Commit 6a742460 authored by Yuki Shiino's avatar Yuki Shiino Committed by Commit Bot

bind-gen: Fix argument index and add missing IDL definitions

Fixes the argument index (was +1'ed) and adds
OnErrorEventHandler and OnBeforeUnloadEventHandler.

Bug: 839389
Change-Id: Id56dad2e5ff6e048d39f10018f49e10784199f8d
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2147489Reviewed-by: default avatarHitoshi Yoshida <peria@chromium.org>
Commit-Queue: Yuki Shiino <yukishiino@chromium.org>
Cr-Commit-Position: refs/heads/master@{#759302}
parent f24fa5ac
...@@ -211,11 +211,11 @@ def bind_blink_api_arguments(code_node, cg_context): ...@@ -211,11 +211,11 @@ def bind_blink_api_arguments(code_node, cg_context):
cg_context.attribute.idl_type)) cg_context.attribute.idl_type))
return return
for index, argument in enumerate(cg_context.function_like.arguments, 1): for index, argument in enumerate(cg_context.function_like.arguments):
name = name_style.arg_f("arg{}_{}", index, argument.identifier) name = name_style.arg_f("arg{}_{}", index + 1, argument.identifier)
if argument.is_variadic: if argument.is_variadic:
code_node.register_code_symbol( code_node.register_code_symbol(
make_v8_to_blink_value_variadic(name, "${info}", index - 1, make_v8_to_blink_value_variadic(name, "${info}", index,
argument.idl_type)) argument.idl_type))
else: else:
v8_value = "${{info}}[{}]".format(argument.index) v8_value = "${{info}}[{}]".format(argument.index)
...@@ -732,6 +732,9 @@ def make_check_argument_length(cg_context): ...@@ -732,6 +732,9 @@ def make_check_argument_length(cg_context):
elif cg_context.function_like: elif cg_context.function_like:
num_of_required_args = ( num_of_required_args = (
cg_context.function_like.num_of_required_arguments) cg_context.function_like.num_of_required_arguments)
elif isinstance(cg_context.property_, web_idl.OverloadGroup):
num_of_required_args = (
cg_context.property_.min_num_of_required_arguments)
else: else:
assert False assert False
...@@ -1142,6 +1145,7 @@ def make_overload_dispatcher(cg_context): ...@@ -1142,6 +1145,7 @@ def make_overload_dispatcher(cg_context):
return SequenceNode([ return SequenceNode([
branches, branches,
EmptyNode(), EmptyNode(),
make_check_argument_length(cg_context),
T("${exception_state}.ThrowTypeError" T("${exception_state}.ThrowTypeError"
"(\"Overload resolution failed.\");\n" "(\"Overload resolution failed.\");\n"
"return;"), "return;"),
...@@ -1241,8 +1245,11 @@ auto&& v8_private_cached_attribute = ...@@ -1241,8 +1245,11 @@ auto&& v8_private_cached_attribute =
V8PrivateProperty::GetSymbol(${isolate}, kPrivatePropertyCachedAttribute); V8PrivateProperty::GetSymbol(${isolate}, kPrivatePropertyCachedAttribute);
if (!${blink_receiver}->""" + pred + """()) { if (!${blink_receiver}->""" + pred + """()) {
v8::Local<v8::Value> v8_value; v8::Local<v8::Value> v8_value;
if (v8_private_cached_attribute.GetOrUndefined(${v8_receiver}) if (!v8_private_cached_attribute.GetOrUndefined(${v8_receiver})
.ToLocal(&v8_value) && !v8_value->IsUndefined()) { .ToLocal(&v8_value)) {
return;
}
if (!v8_value->IsUndefined()) {
bindings::V8SetReturnValue(${info}, v8_value); bindings::V8SetReturnValue(${info}, v8_value);
return; return;
} }
...@@ -1256,8 +1263,11 @@ auto&& v8_private_save_same_object = ...@@ -1256,8 +1263,11 @@ auto&& v8_private_save_same_object =
V8PrivateProperty::GetSymbol(${isolate}, kPrivatePropertySaveSameObject); V8PrivateProperty::GetSymbol(${isolate}, kPrivatePropertySaveSameObject);
{ {
v8::Local<v8::Value> v8_value; v8::Local<v8::Value> v8_value;
if (v8_private_save_same_object.GetOrUndefined(${v8_receiver}) if (!v8_private_save_same_object.GetOrUndefined(${v8_receiver})
.ToLocal(&v8_value) && !v8_value->IsUndefined()) { .ToLocal(&v8_value)) {
return;
}
if (!v8_value->IsUndefined()) {
bindings::V8SetReturnValue(${info}, v8_value); bindings::V8SetReturnValue(${info}, v8_value);
return; return;
} }
...@@ -5784,6 +5794,11 @@ def _collect_include_headers(interface): ...@@ -5784,6 +5794,11 @@ def _collect_include_headers(interface):
type_def_obj = idl_type.type_definition_object type_def_obj = idl_type.type_definition_object
if type_def_obj is not None: if type_def_obj is not None:
if (type_def_obj.identifier in (
"OnErrorEventHandlerNonNull",
"OnBeforeUnloadEventHandlerNonNull")):
raise StopIteration(idl_type.syntactic_form)
headers.add(PathManager(type_def_obj).api_path(ext="h")) headers.add(PathManager(type_def_obj).api_path(ext="h"))
if isinstance(type_def_obj, web_idl.Interface): if isinstance(type_def_obj, web_idl.Interface):
headers.add(PathManager(type_def_obj).blink_path(ext="h")) headers.add(PathManager(type_def_obj).blink_path(ext="h"))
......
...@@ -10,6 +10,16 @@ ...@@ -10,6 +10,16 @@
typedef EventHandlerNonNull? EventHandler; typedef EventHandlerNonNull? EventHandler;
// https://html.spec.whatwg.org/C/#onerroreventhandler
[TreatNonObjectAsNull]
callback OnErrorEventHandlerNonNull = any ((Event or DOMString) event, optional DOMString source, optional unsigned long lineno, optional unsigned long colno, optional any error);
typedef OnErrorEventHandlerNonNull? OnErrorEventHandler;
// https://html.spec.whatwg.org/C/#onbeforeunloadeventhandler
[TreatNonObjectAsNull]
callback OnBeforeUnloadEventHandlerNonNull = DOMString? (Event event);
typedef OnBeforeUnloadEventHandlerNonNull? OnBeforeUnloadEventHandler;
typedef DOMMatrix DOMMatrixConstructor; typedef DOMMatrix DOMMatrixConstructor;
typedef MediaStream MediaStreamConstructor; typedef MediaStream MediaStreamConstructor;
typedef MutationObserver MutationObserverConstructor; typedef MutationObserver MutationObserverConstructor;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment