Commit 91d1eb91 authored by Yuki Shiino's avatar Yuki Shiino Committed by Commit Bot

bind-gen: Implement DOMException's prototype chain

Sets DOMException.prototype.__proto__ to %ErrorPrototype%.

Bug: 839389
Change-Id: Ifba243e49ae7095c73bf094740b3d447f5a53413
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2135668
Commit-Queue: Yuki Shiino <yukishiino@chromium.org>
Reviewed-by: default avatarHitoshi Yoshida <peria@chromium.org>
Cr-Commit-Position: refs/heads/master@{#756619}
parent 98b51f4c
...@@ -2861,12 +2861,50 @@ def bind_installer_local_vars(code_node, cg_context): ...@@ -2861,12 +2861,50 @@ def bind_installer_local_vars(code_node, cg_context):
# parent_interface_template # parent_interface_template
pattern = ( pattern = (
"v8::Local<v8::FunctionTemplate> ${parent_interface_template}{_1};") "v8::Local<v8::FunctionTemplate> ${parent_interface_template}{_1};")
_1 = (" = ${wrapper_type_info}->parent_class->dom_template_function" interface = cg_context.interface
"(${isolate}, ${world})") if not interface:
if not cg_context.class_like.inherited: _1 = ""
elif (interface and "Global" in interface.extended_attributes
and interface.indexed_and_named_properties
and interface.indexed_and_named_properties.has_named_properties):
# https://heycam.github.io/webidl/#named-properties-object
_1 = " = ${npo_interface_template}" # npo = named properties object
elif interface.inherited:
_1 = (" = ${wrapper_type_info}->parent_class->dom_template_function"
"(${isolate}, ${world})")
else:
_1 = "" _1 = ""
local_vars.append(S("parent_interface_template", _format(pattern, _1=_1))) local_vars.append(S("parent_interface_template", _format(pattern, _1=_1)))
# npo_interface_template
# npo = named properties object
text = """\
// Named properties object
v8::Local<v8::FunctionTemplate> ${npo_interface_template} =
v8::FunctionTemplate::New(${isolate});
v8::Local<v8::ObjectTemplate> ${npo_prototype_template} =
${npo_interface_template}->PrototypeTemplate();
${npo_interface_template}->Inherit(
${wrapper_type_info}->parent_class->dom_template_function(
${isolate}, ${world}));
${npo_prototype_template}->SetImmutableProto();
V8DOMConfiguration::SetClassString(
${isolate}, ${npo_prototype_template},
"${interface.identifier}Properties");
// Make the named properties object look like the global object. Note that
// the named properties object is _not_ a prototype object, plus, we'd like
// the named properties object to behave just like the global object (= the
// wrapper object of the global object) from the point of view of named
// properties.
// https://heycam.github.io/webidl/#named-properties-object
${npo_prototype_template}->SetInternalFieldCount(
kV8DefaultWrapperInternalFieldCount);
"""
local_vars.append(S("npo_interface_template", text))
local_vars.append(
S("npo_prototype_template",
"<% npo_interface_template.request_symbol_definition() %>"))
# Arguments have priority over local vars. # Arguments have priority over local vars.
template_vars = code_node.template_vars template_vars = code_node.template_vars
for symbol_node in local_vars: for symbol_node in local_vars:
...@@ -3545,7 +3583,7 @@ def make_install_interface_template( ...@@ -3545,7 +3583,7 @@ def make_install_interface_template(
body.extend([T(set_callback), T(set_length)]) body.extend([T(set_callback), T(set_length)])
else: else:
assert False assert False
body.append(EmptyNode()) body.append(EmptyNode())
if cross_origin_property_install_nodes: if cross_origin_property_install_nodes:
body.extend([ body.extend([
...@@ -3553,9 +3591,35 @@ def make_install_interface_template( ...@@ -3553,9 +3591,35 @@ def make_install_interface_template(
EmptyNode(), EmptyNode(),
]) ])
if cg_context.class_like.identifier == "DOMException":
body.append(
T("""\
// DOMException-specific settings
// https://heycam.github.io/webidl/#es-DOMException-specialness
{
v8::Local<v8::FunctionTemplate> intrinsic_error_prototype_interface_template =
v8::FunctionTemplate::New(${isolate});
intrinsic_error_prototype_interface_template->RemovePrototype();
intrinsic_error_prototype_interface_template->SetIntrinsicDataProperty(
V8AtomicString(${isolate}, "prototype"), v8::kErrorPrototype);
${interface_template}->Inherit(intrinsic_error_prototype_interface_template);
}
"""))
if cg_context.class_like.identifier == "HTMLAllCollection":
body.append(
T("""\
// HTMLAllCollection-specific settings
// https://html.spec.whatwg.org/C/#the-htmlallcollection-interface
${instance_template}->SetCallAsFunctionHandler(
${class_name}::LegacyCallCustom);
${instance_template}->MarkAsUndetectable();
"""))
if cg_context.class_like.identifier == "Location": if cg_context.class_like.identifier == "Location":
body.append( body.append(
T("""\ T("""\
// Location-specific settings
// https://html.spec.whatwg.org/C/#the-location-interface // https://html.spec.whatwg.org/C/#the-location-interface
// To create a Location object, run these steps: // To create a Location object, run these steps:
// step 3. Let valueOf be location's relevant // step 3. Let valueOf be location's relevant
...@@ -3596,17 +3660,6 @@ ${instance_template}->Set( ...@@ -3596,17 +3660,6 @@ ${instance_template}->Set(
EmptyNode(), EmptyNode(),
]) ])
if cg_context.class_like.identifier == "HTMLAllCollection":
body.extend([
T("// HTMLAllCollection"),
T("// https://html.spec.whatwg.org/C/"
"#the-htmlallcollection-interface"),
T("${instance_template}->SetCallAsFunctionHandler"
"(${class_name}::LegacyCallCustom);"),
T("${instance_template}->MarkAsUndetectable();"),
EmptyNode(),
])
func_call_pattern = ("{}(${isolate}, ${world}, ${instance_template}, " func_call_pattern = ("{}(${isolate}, ${world}, ${instance_template}, "
"${prototype_template}, ${interface_template});") "${prototype_template}, ${interface_template});")
if install_unconditional_func_name: if install_unconditional_func_name:
...@@ -3962,7 +4015,12 @@ ${instance_template}->SetHandler( ...@@ -3962,7 +4015,12 @@ ${instance_template}->SetHandler(
map(lambda flag: "int({})".format(flag), flags)))) map(lambda flag: "int({})".format(flag), flags))))
pattern = """\ pattern = """\
// Named properties // Named properties
${instance_template}->SetHandler( % if "Global" in interface.extended_attributes:
${npo_prototype_template}
% else:
${instance_template}
%endif
->SetHandler(
v8::NamedPropertyHandlerConfiguration( v8::NamedPropertyHandlerConfiguration(
{impl_bridge}::NamedPropertyGetterCallback, {impl_bridge}::NamedPropertyGetterCallback,
% if interface.indexed_and_named_properties.named_setter: % if interface.indexed_and_named_properties.named_setter:
......
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