From 29583104d220e4ea2d626781ef5c525fdf11974e Mon Sep 17 00:00:00 2001 From: sin-ack Date: Mon, 14 Mar 2022 23:05:55 +0000 Subject: 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. --- Userland/Libraries/LibWeb/Layout/ButtonBox.h | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) (limited to 'Userland/Libraries/LibWeb/Layout/ButtonBox.h') diff --git a/Userland/Libraries/LibWeb/Layout/ButtonBox.h b/Userland/Libraries/LibWeb/Layout/ButtonBox.h index 1c0b11283e..d80278e202 100644 --- a/Userland/Libraries/LibWeb/Layout/ButtonBox.h +++ b/Userland/Libraries/LibWeb/Layout/ButtonBox.h @@ -7,20 +7,17 @@ #pragma once #include -#include +#include namespace Web::Layout { -class ButtonBox : public LabelableNode { +class ButtonBox : public FormAssociatedLabelableNode { public: ButtonBox(DOM::Document&, HTML::HTMLInputElement&, NonnullRefPtr); virtual ~ButtonBox() override; virtual void prepare_for_replaced_layout() override; - const HTML::HTMLInputElement& dom_node() const { return static_cast(LabelableNode::dom_node()); } - HTML::HTMLInputElement& dom_node() { return static_cast(LabelableNode::dom_node()); } - private: virtual RefPtr create_paintable() const override; }; -- cgit v1.2.3