mirror of
https://github.com/zebrajr/ladybird.git
synced 2025-12-06 00:19:53 +01: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
|
|
@ -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…
Reference in New Issue
Block a user