mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 07:38:10 +00:00
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.
This commit is contained in:
parent
06ccc45157
commit
29583104d2
26 changed files with 409 additions and 466 deletions
|
@ -67,14 +67,7 @@ public:
|
|||
Programmatic,
|
||||
User,
|
||||
};
|
||||
enum class ShouldRunActivationBehavior {
|
||||
No,
|
||||
Yes,
|
||||
};
|
||||
void set_checked(bool, ChangeSource = ChangeSource::Programmatic, ShouldRunActivationBehavior = ShouldRunActivationBehavior::Yes);
|
||||
|
||||
void did_click_button(Badge<Painting::ButtonPaintable>);
|
||||
void did_click_checkbox(Badge<Painting::CheckBoxPaintable>);
|
||||
void set_checked(bool, ChangeSource = ChangeSource::Programmatic);
|
||||
|
||||
void did_edit_text_node(Badge<BrowsingContext>);
|
||||
|
||||
|
@ -105,10 +98,13 @@ public:
|
|||
private:
|
||||
// ^DOM::EventTarget
|
||||
virtual void did_receive_focus() override;
|
||||
virtual void run_activation_behavior() override;
|
||||
virtual void legacy_pre_activation_behavior() override;
|
||||
virtual void legacy_cancelled_activation_behavior() override;
|
||||
virtual void legacy_cancelled_activation_behavior_was_not_called() override;
|
||||
|
||||
void create_shadow_tree_if_needed();
|
||||
void run_input_activation_behavior();
|
||||
void set_checked_within_group();
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/input.html#value-sanitization-algorithm
|
||||
String value_sanitization_algorithm(String) const;
|
||||
|
@ -118,6 +114,10 @@ private:
|
|||
|
||||
// https://html.spec.whatwg.org/multipage/input.html#concept-input-checked-dirty-flag
|
||||
bool m_dirty_checkedness { false };
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/input.html#the-input-element:legacy-pre-activation-behavior
|
||||
bool m_before_legacy_pre_activation_behavior_checked { false };
|
||||
RefPtr<HTMLInputElement> m_legacy_pre_activation_behavior_checked_element_in_group;
|
||||
};
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue