LibWeb: Rewrite EventTarget to more closely match the spec

This isn't perfect (especially the global object situation in
activate_event_handler), but I believe it's in a much more complete
state now :^)

This fixes the issue of crashing in prepare_for_ordinary_call with the
`i < m_size` crash, as it now uses the IDL callback functions which
requires the Environment Settings Object. The environment settings
object for the callback is fetched at the time the callback is created,
for example, WrapperGenerator gets the incumbent settings object for
the callback at the time of wrapping. This allows us to remove passing
in ScriptExecutionContext into EventTarget's constructor.

With this, we can now drop ScriptExecutionContext.
This commit is contained in:
Luke Wilde 2021-10-14 18:03:08 +01:00 committed by Linus Groh
commit 5aacec65ab
Notes: sideshowbarker 2024-07-17 19:09:19 +09:00
39 changed files with 874 additions and 300 deletions

View file

@ -15,7 +15,7 @@
namespace Web::CSS {
MediaQueryList::MediaQueryList(DOM::Document& document, NonnullRefPtrVector<MediaQuery>&& media)
: DOM::EventTarget(static_cast<Bindings::ScriptExecutionContext&>(document))
: DOM::EventTarget()
, m_document(document)
, m_media(move(media))
{
@ -83,12 +83,12 @@ void MediaQueryList::remove_listener(RefPtr<DOM::EventListener> listener)
remove_event_listener(HTML::EventNames::change, listener);
}
void MediaQueryList::set_onchange(HTML::EventHandler event_handler)
void MediaQueryList::set_onchange(Optional<Bindings::CallbackType> event_handler)
{
set_event_handler_attribute(HTML::EventNames::change, event_handler);
}
HTML::EventHandler MediaQueryList::onchange()
Bindings::CallbackType* MediaQueryList::onchange()
{
return event_handler_attribute(HTML::EventNames::change);
}