mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-08-17 15:59:43 +00:00
IDLGenerators: Add a callback for when a setlike's set is modified
For simplicity, this requires that the setlike Foo class has a `void on_set_modified_from_js(Badge<Bindings::FooPrototype>)` method. This will be called after the set is modified from a generated `add()`, `delete()`, or `clear()` method.
This commit is contained in:
parent
be21d952b1
commit
bc94431b99
Notes:
github-actions[bot]
2025-07-04 17:12:01 +00:00
Author: https://github.com/AtkinsSJ
Commit: bc94431b99
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/5302
Reviewed-by: https://github.com/tcl3 ✅
2 changed files with 7 additions and 1 deletions
|
@ -45,6 +45,8 @@ public:
|
|||
|
||||
void resolve_ready_promise();
|
||||
|
||||
void on_set_modified_from_js(Badge<Bindings::FontFaceSetPrototype>) { }
|
||||
|
||||
private:
|
||||
FontFaceSet(JS::Realm&, GC::Ref<WebIDL::Promise> ready_promise, GC::Ref<JS::Set> set_entries);
|
||||
|
||||
|
|
|
@ -4639,6 +4639,7 @@ JS_DEFINE_NATIVE_FUNCTION(@class_name@::add)
|
|||
// What? Which interfaces have a number as their set type?
|
||||
|
||||
set->set_add(value_arg);
|
||||
impl->on_set_modified_from_js({});
|
||||
|
||||
return impl;
|
||||
}
|
||||
|
@ -4660,7 +4661,9 @@ JS_DEFINE_NATIVE_FUNCTION(@class_name@::delete_)
|
|||
// FIXME: If value is -0, set value to +0.
|
||||
// What? Which interfaces have a number as their set type?
|
||||
|
||||
return set->set_remove(value_arg);
|
||||
auto result = set->set_remove(value_arg);
|
||||
impl->on_set_modified_from_js({});
|
||||
return result;
|
||||
}
|
||||
)~~~");
|
||||
}
|
||||
|
@ -4675,6 +4678,7 @@ JS_DEFINE_NATIVE_FUNCTION(@class_name@::clear)
|
|||
GC::Ref<JS::Set> set = impl->set_entries();
|
||||
|
||||
set->set_clear();
|
||||
impl->on_set_modified_from_js({});
|
||||
|
||||
return JS::js_undefined();
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue