LibWeb: Don't dispatch click events to disabled FormAssociatedElements

Disabled FormAssociatedElements also no longer receive focus when
clicked.
This commit is contained in:
Tim Ledbetter 2024-07-12 11:06:08 +01:00 committed by Andreas Kling
commit e18501f67f
Notes: sideshowbarker 2024-07-17 05:03:11 +09:00
4 changed files with 25 additions and 10 deletions

View file

@ -47,6 +47,13 @@ static JS::GCPtr<DOM::Node> dom_node_for_event_dispatch(Painting::Paintable& pai
static bool parent_element_for_event_dispatch(Painting::Paintable& paintable, JS::GCPtr<DOM::Node>& node, Layout::Node*& layout_node)
{
auto* current_ancestor_node = node.ptr();
do {
if (is<HTML::FormAssociatedElement>(current_ancestor_node) && !dynamic_cast<HTML::FormAssociatedElement*>(current_ancestor_node)->enabled()) {
return false;
}
} while ((current_ancestor_node = current_ancestor_node->parent()));
layout_node = &paintable.layout_node();
while (layout_node && node && !node->is_element() && layout_node->parent()) {
layout_node = layout_node->parent();