mirror of
https://github.com/RGBCube/serenity
synced 2025-05-21 10:45:07 +00:00
LibWeb: Initialize IDL-generated prototypes' prototype directly
Instead of setting it to the default object prototype and then immediately setting it again via internal_set_prototype_of, we can just set it directly in the parent constructor call.
This commit is contained in:
parent
a7ce118249
commit
a4bc3fa255
1 changed files with 8 additions and 9 deletions
|
@ -2819,28 +2819,27 @@ using namespace Web::URL;
|
||||||
|
|
||||||
namespace Web::Bindings {
|
namespace Web::Bindings {
|
||||||
|
|
||||||
@prototype_class@::@prototype_class@(JS::GlobalObject& global_object)
|
@prototype_class@::@prototype_class@([[maybe_unused]] JS::GlobalObject& global_object))~~~");
|
||||||
: Object(*global_object.object_prototype())
|
|
||||||
{
|
|
||||||
)~~~");
|
|
||||||
|
|
||||||
if (interface.name == "DOMException") {
|
if (interface.name == "DOMException") {
|
||||||
// https://heycam.github.io/webidl/#es-DOMException-specialness
|
// https://heycam.github.io/webidl/#es-DOMException-specialness
|
||||||
// Object.getPrototypeOf(DOMException.prototype) === Error.prototype
|
// Object.getPrototypeOf(DOMException.prototype) === Error.prototype
|
||||||
generator.append(R"~~~(
|
generator.append(R"~~~(
|
||||||
auto success = internal_set_prototype_of(global_object.error_prototype()).release_value();
|
: Object(*global_object.error_prototype())
|
||||||
VERIFY(success);
|
|
||||||
)~~~");
|
)~~~");
|
||||||
} else if (!interface.parent_name.is_empty()) {
|
} else if (!interface.parent_name.is_empty()) {
|
||||||
generator.append(R"~~~(
|
generator.append(R"~~~(
|
||||||
auto success = internal_set_prototype_of(&static_cast<WindowObject&>(global_object).ensure_web_prototype<@prototype_base_class@>("@parent_name@")).release_value();
|
: Object(static_cast<WindowObject&>(global_object).ensure_web_prototype<@prototype_base_class@>("@parent_name@"))
|
||||||
VERIFY(success);
|
)~~~");
|
||||||
|
} else {
|
||||||
|
generator.append(R"~~~(
|
||||||
|
: Object(*global_object.object_prototype())
|
||||||
)~~~");
|
)~~~");
|
||||||
}
|
}
|
||||||
|
|
||||||
// FIXME: Currently almost everything gets default_attributes but it should be configurable per attribute.
|
// FIXME: Currently almost everything gets default_attributes but it should be configurable per attribute.
|
||||||
// See the spec links for details
|
// See the spec links for details
|
||||||
generator.append(R"~~~(
|
generator.append(R"~~~(
|
||||||
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@prototype_class@::~@prototype_class@()
|
@prototype_class@::~@prototype_class@()
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue