summaryrefslogtreecommitdiff
path: root/Userland/Libraries/LibWeb/DOM/EventTarget.h
AgeCommit message (Collapse)Author
2021-04-10LibWeb: Support nullable EventListener parameters in WrapperGeneratorLinus Groh
The internal C++ function will now receive a RefPtr<EventListener> for 'EventListener?' and a NonnullRefPtr<EventListener> for 'EventListener'. Examples of this are addEventListener() and removeEventListener(), which both have nullable callback parameters.
2021-02-03LibWeb: Basic implementation of global event handlers :^)Andreas Kling
Document and HTMLElement now inherit from HTML::GlobalEventHandlers which allows them to support "onfoo" event handler attributes. These are assignable both via IDL attributes and content attributes. Event listeners constructed this way get a special "attribute" flag on them so we know which one to replace if you reassign them. This also allows them to coexist with EventTarget.addEventListener(). This is all a bit sloppy, but it works decently for a first cut. The Window object should also inherit GlobalEventHandlers, but since we don't generate it from IDL, I haven't taken that step here. Also this would be a lot nicer if we supported IDL mixins.
2021-01-18LibWeb: Make the Window object "inherit" from EventTarget :^)Andreas Kling
Since Web::Bindings::WindowObject inherits from JS::GlobalObject, it cannot also inherit from Web::Bindings::EventTargetWrapper. However, that's not actually necessary. Instead, we simply set the Window object's prototype to the EventTargetPrototype, and add a little extra branch in the impl_from() function that turns the JS "this" value into a DOM::EventTarget*. With this, you can now call window.addEventListener()! Very cool :^) Fixes #4758.
2021-01-12Libraries: Move to Userland/Libraries/Andreas Kling