mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-04-21 20:15:17 +00:00
LibWeb: Add [CustomVisit] IDL interface extended attribute
This custom attribute will be used for objects that hold onto arbitrary JS::Value's. This is needed as JS::Handle can only be constructed for objects that implement JS::Cell, which JS::Value doesn't. This works by overriding the `visit_edges` function in the wrapper. This overridden function calls the base `visit_edges` and then forwards it to the underlying implementation. This will be used for CustomEvent, which must hold onto an arbitrary JS::Value for it's entire lifespan.
This commit is contained in:
parent
8da21583db
commit
d30ec4d790
Notes:
sideshowbarker
2024-07-18 03:24:07 +09:00
Author: https://github.com/Lubrsi Commit: https://github.com/SerenityOS/serenity/commit/d30ec4d7900 Pull-request: https://github.com/SerenityOS/serenity/pull/10229
1 changed files with 16 additions and 0 deletions
|
@ -1164,6 +1164,12 @@ public:
|
|||
)~~~");
|
||||
}
|
||||
|
||||
if (interface.extended_attributes.contains("CustomVisit")) {
|
||||
generator.append(R"~~~(
|
||||
virtual void visit_edges(JS::Cell::Visitor&) override;
|
||||
)~~~");
|
||||
}
|
||||
|
||||
if (interface.is_legacy_platform_object()) {
|
||||
generator.append(R"~~~(
|
||||
virtual Optional<JS::PropertyDescriptor> internal_get_own_property(JS::PropertyName const&) const override;
|
||||
|
@ -1326,6 +1332,16 @@ void @wrapper_class@::initialize(JS::GlobalObject& global_object)
|
|||
)~~~");
|
||||
}
|
||||
|
||||
if (interface.extended_attributes.contains("CustomVisit")) {
|
||||
generator.append(R"~~~(
|
||||
void @wrapper_class@::visit_edges(JS::Cell::Visitor& visitor)
|
||||
{
|
||||
@wrapper_base_class@::visit_edges(visitor);
|
||||
impl().visit_edges(visitor);
|
||||
}
|
||||
)~~~");
|
||||
}
|
||||
|
||||
if (interface.is_legacy_platform_object()) {
|
||||
auto scoped_generator = generator.fork();
|
||||
scoped_generator.set("class_name", interface.wrapper_class);
|
||||
|
|
Loading…
Add table
Reference in a new issue