mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-07-29 12:19:54 +00:00
LibWeb: Dispatch "click" event on input control associated with <label>
For example, in the following HTML: ```html <label> <input type="radio" name="fruit" value="apple" id="radio1"> <span class="box"></span> </label> ``` When any descendant of a <label> element is clicked, a "click" event must be dispatched on the <input> element nested within the <label>, in addition to the "click" event dispatched on the clicked descendant. Previously, this behavior was implemented only for text node descendants by "overriding" the mouse event target using `mouse_event_target()` in the TextPaintable. This approach was incorrect because it was limited to text nodes, whereas the behavior should apply to any box. Moreover, the "click" event for the input control must be dispatched *in addition* to the event on the clicked element, rather than redirecting it.
This commit is contained in:
parent
001df24935
commit
c0e90a2a68
Notes:
github-actions[bot]
2024-11-21 15:11:58 +00:00
Author: https://github.com/kalenikaliaksandr
Commit: c0e90a2a68
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/2466
6 changed files with 105 additions and 15 deletions
|
@ -30,13 +30,6 @@ bool TextPaintable::wants_mouse_events() const
|
|||
return layout_node().first_ancestor_of_type<Layout::Label>();
|
||||
}
|
||||
|
||||
DOM::Node* TextPaintable::mouse_event_target() const
|
||||
{
|
||||
if (auto const* label = layout_node().first_ancestor_of_type<Layout::Label>())
|
||||
return label->dom_node().control().ptr();
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
TextPaintable::DispatchEventOfSameName TextPaintable::handle_mousedown(Badge<EventHandler>, CSSPixelPoint position, unsigned button, unsigned)
|
||||
{
|
||||
auto* label = layout_node().first_ancestor_of_type<Layout::Label>();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue