diff options
author | Timothy Flynn <trflynn89@pm.me> | 2023-01-10 12:52:01 -0500 |
---|---|---|
committer | Linus Groh <mail@linusgroh.de> | 2023-01-10 17:55:23 +0000 |
commit | 491edaffc708d5174a0126244d3cd99fc05290e3 (patch) | |
tree | 3dacd18db1c9e2e444f98863a5145c53d2cd3d1c /Meta | |
parent | 4d335f3819e72a4e9d42172e2b586b3f5995d190 (diff) | |
download | serenity-491edaffc708d5174a0126244d3cd99fc05290e3.zip |
LibWeb: Ensure legacy constructors are defined on the global object
This regressed in 6e93d89ee3108873a30bd0178b0f84fff3db3315.
Diffstat (limited to 'Meta')
-rw-r--r-- | Meta/Lagom/Tools/CodeGenerators/LibWeb/GenerateWindowOrWorkerInterfaces.cpp | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/Meta/Lagom/Tools/CodeGenerators/LibWeb/GenerateWindowOrWorkerInterfaces.cpp b/Meta/Lagom/Tools/CodeGenerators/LibWeb/GenerateWindowOrWorkerInterfaces.cpp index 0204e2612b..ca95a9dbc9 100644 --- a/Meta/Lagom/Tools/CodeGenerators/LibWeb/GenerateWindowOrWorkerInterfaces.cpp +++ b/Meta/Lagom/Tools/CodeGenerators/LibWeb/GenerateWindowOrWorkerInterfaces.cpp @@ -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"~~~( |