summaryrefslogtreecommitdiff
path: root/Userland/Libraries/LibWeb/DOM
diff options
context:
space:
mode:
authorsin-ack <sin-ack@users.noreply.github.com>2022-03-14 23:05:55 +0000
committerAndreas Kling <kling@serenityos.org>2022-03-16 00:38:31 +0100
commit29583104d220e4ea2d626781ef5c525fdf11974e (patch)
tree6a7e94958f4c298147168457b62616a0a21e4d9e /Userland/Libraries/LibWeb/DOM
parent06ccc451577cc3f55bd10ce4c88f9fdf471e5129 (diff)
downloadserenity-29583104d220e4ea2d626781ef5c525fdf11974e.zip
LibWeb: Refactor all LabelableNode subclasses + input event handling :^)
This commit is messy due to the Paintable and Layout classes being tangled together. The RadioButton, CheckBox and ButtonBox classes are now subclasses of FormAssociatedLabelableNode. This subclass separates these layout nodes from LabelableNode, which is also the superclass of non-form associated labelable nodes (Progress). ButtonPaintable, CheckBoxPaintable and RadioButtonPaintable no longer call events on DOM nodes directly from their mouse event handlers; instead, all the functionality is now directly in EventHandler, which dispatches the related events. handle_mousedown and related methods return a bool indicating whether the event handling should proceed. Paintable classes can now return an alternative DOM::Node which should be the target of the mouse event. Labels use this to indicate that the labeled control should be the target of the mouse events. HTMLInputElement put its activation behavior on run_activation_behavior, which wasn't actually called anywhere and had to be manually called by other places. We now use activation_behavior which is used by EventDispatcher. This commit also brings HTMLInputElement closer to spec by removing the did_foo functions that did ad-hoc event dispatching and unifies the behavior under run_input_activation_behavior.
Diffstat (limited to 'Userland/Libraries/LibWeb/DOM')
-rw-r--r--Userland/Libraries/LibWeb/DOM/EventDispatcher.cpp1
-rw-r--r--Userland/Libraries/LibWeb/DOM/EventTarget.h4
2 files changed, 2 insertions, 3 deletions
diff --git a/Userland/Libraries/LibWeb/DOM/EventDispatcher.cpp b/Userland/Libraries/LibWeb/DOM/EventDispatcher.cpp
index 208920cdee..9584813bed 100644
--- a/Userland/Libraries/LibWeb/DOM/EventDispatcher.cpp
+++ b/Userland/Libraries/LibWeb/DOM/EventDispatcher.cpp
@@ -328,6 +328,7 @@ bool EventDispatcher::dispatch(NonnullRefPtr<EventTarget> target, NonnullRefPtr<
if (!event->cancelled()) {
// NOTE: Since activation_target is set, it will have activation behavior.
activation_target->activation_behavior(event);
+ activation_target->legacy_cancelled_activation_behavior_was_not_called();
} else {
activation_target->legacy_cancelled_activation_behavior();
}
diff --git a/Userland/Libraries/LibWeb/DOM/EventTarget.h b/Userland/Libraries/LibWeb/DOM/EventTarget.h
index 8d5fb9b47c..75586c3d36 100644
--- a/Userland/Libraries/LibWeb/DOM/EventTarget.h
+++ b/Userland/Libraries/LibWeb/DOM/EventTarget.h
@@ -55,13 +55,11 @@ public:
// NOTE: These only exist for checkbox and radio input elements.
virtual void legacy_pre_activation_behavior() { }
virtual void legacy_cancelled_activation_behavior() { }
+ virtual void legacy_cancelled_activation_behavior_was_not_called() { }
Bindings::CallbackType* event_handler_attribute(FlyString const& name);
void set_event_handler_attribute(FlyString const& name, Optional<Bindings::CallbackType>);
- // https://dom.spec.whatwg.org/#eventtarget-activation-behavior
- virtual void run_activation_behavior() { }
-
protected:
EventTarget();