mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-22 15:40:19 +00:00
LibWeb: Ensure legacy constructors are defined on the global object
This regressed in 6e93d89ee3
.
This commit is contained in:
parent
4d335f3819
commit
491edaffc7
Notes:
sideshowbarker
2024-07-17 23:07:41 +09:00
Author: https://github.com/trflynn89 Commit: https://github.com/SerenityOS/serenity/commit/491edaffc7 Pull-request: https://github.com/SerenityOS/serenity/pull/16949
1 changed files with 12 additions and 5 deletions
|
@ -306,23 +306,30 @@ void add_@global_object_snake_name@_exposed_interfaces(JS::Object& global)
|
|||
static constexpr u8 attr = JS::Attribute::Writable | JS::Attribute::Configurable;
|
||||
)~~~");
|
||||
|
||||
auto add_interface = [](SourceGenerator& gen, StringView name, StringView prototype_class) {
|
||||
auto add_interface = [](SourceGenerator& gen, StringView name, StringView prototype_class, Optional<LegacyConstructor> const& legacy_constructor) {
|
||||
gen.set("interface_name", name);
|
||||
gen.set("prototype_class", prototype_class);
|
||||
|
||||
gen.append(R"~~~(
|
||||
global.define_intrinsic_accessor("@interface_name@", attr, [](auto& realm) -> JS::Value { return &ensure_web_constructor<@prototype_class@>(realm, "@interface_name@"sv); });)~~~"); };
|
||||
global.define_intrinsic_accessor("@interface_name@", attr, [](auto& realm) -> JS::Value { return &ensure_web_constructor<@prototype_class@>(realm, "@interface_name@"sv); });)~~~");
|
||||
|
||||
if (legacy_constructor.has_value()) {
|
||||
gen.set("legacy_interface_name", legacy_constructor->name);
|
||||
gen.append(R"~~~(
|
||||
global.define_intrinsic_accessor("@legacy_interface_name@", attr, [](auto& realm) -> JS::Value { return &ensure_web_constructor<@prototype_class@>(realm, "@legacy_interface_name@"sv); });)~~~");
|
||||
}
|
||||
};
|
||||
|
||||
for (auto& interface : exposed_interfaces) {
|
||||
auto gen = generator.fork();
|
||||
add_interface(gen, interface.name, interface.prototype_class);
|
||||
add_interface(gen, interface.name, interface.prototype_class, lookup_legacy_constructor(interface));
|
||||
}
|
||||
|
||||
// FIXME: Special case window. We should convert Window and Location to use IDL
|
||||
if (class_name == "Window"sv) {
|
||||
auto gen = generator.fork();
|
||||
add_interface(gen, "Window"sv, "WindowPrototype"sv);
|
||||
add_interface(gen, "Location"sv, "LocationPrototype"sv);
|
||||
add_interface(gen, "Window"sv, "WindowPrototype"sv, {});
|
||||
add_interface(gen, "Location"sv, "LocationPrototype"sv, {});
|
||||
}
|
||||
|
||||
generator.append(R"~~~(
|
||||
|
|
Loading…
Reference in a new issue