Commit 5cb122f3 authored by Yuki Shiino's avatar Yuki Shiino Committed by Commit Bot

bind-gen: Workaround misuse of [HTMLConstructor] in the new bindings gentor

The current IDL definitions misuse [HTMLConstructor].  Workarounds
it in the new Web IDL database.

Bug: 839389, 1068098
Change-Id: I00905dafeb25392b7d2a910b78e26dfd89316ac9
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2136979
Commit-Queue: Yuki Shiino <yukishiino@chromium.org>
Reviewed-by: default avatarHitoshi Yoshida <peria@chromium.org>
Cr-Commit-Position: refs/heads/master@{#756596}
parent 186f9ae1
......@@ -1688,6 +1688,10 @@ def make_constructor_function_def(cg_context, function_name):
"HTMLElementType::{});",
name_style.constant(cg_context.class_like.identifier))
body.append(T(text))
body.accumulate(
CodeGenAccumulator.require_include_headers([
"third_party/blink/renderer/bindings/core/v8/v8_html_constructor.h",
]))
else:
body.append(
T("v8::Local<v8::Object> v8_wrapper = "
......
......@@ -11,6 +11,7 @@ from blinkbuild.name_style_converter import NameStyleConverter
from .callback_function import CallbackFunction
from .callback_interface import CallbackInterface
from .composition_parts import Identifier
from .constructor import Constructor
from .constructor import ConstructorGroup
from .database import Database
from .database import DatabaseBody
......@@ -101,6 +102,10 @@ class IdlCompiler(object):
# Process inheritances.
self._process_interface_inheritances()
# Temporary mitigation of misuse of [HTMLConstructor]
# This should be removed once the IDL definitions get fixed.
self._supplement_missing_html_constructor_operation()
self._copy_named_constructor_extattrs()
# Make groups of overloaded functions including inherited ones.
......@@ -408,6 +413,35 @@ class IdlCompiler(object):
if is_own_member(operation)
])
def _supplement_missing_html_constructor_operation(self):
# Temporary mitigation of misuse of [HTMLConstructor]
# https://html.spec.whatwg.org/C/#htmlconstructor
# [HTMLConstructor] must be applied to only the single constructor
# operation, but it's now applied to interfaces without a constructor
# operation declaration.
old_irs = self._ir_map.irs_of_kind(IRMap.IR.Kind.INTERFACE)
self._ir_map.move_to_new_phase()
for old_ir in old_irs:
new_ir = self._maybe_make_copy(old_ir)
self._ir_map.add(new_ir)
if not (not new_ir.constructors
and "HTMLConstructor" in new_ir.extended_attributes):
continue
html_constructor = Constructor.IR(
identifier=None,
arguments=[],
return_type=self._idl_type_factory.reference_type(
new_ir.identifier),
extended_attributes=ExtendedAttributesMutable(
[ExtendedAttribute(key="HTMLConstructor")]),
component=new_ir.components[0],
debug_info=new_ir.debug_info)
new_ir.constructors.append(html_constructor)
def _copy_named_constructor_extattrs(self):
old_irs = self._ir_map.irs_of_kind(IRMap.IR.Kind.INTERFACE)
......
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