LibWeb: Change where content selection via mouse is allowed

Previously, only DOM nodes with `is_editable()` allowed selection via
the mouse. This had the unwanted consequence, that read-only
input/textarea elements did not allow selection.

Now, `EventHandler::handle_mousedown()` asks the node's non-shadow
parent element over the new virtual method `is_child_node_selectable()`,
if selection of the node is allowed.
This method is overridden for `HTMLButtonElement` and
`HTMLInputElement`, to disallow selection of buttons and placeholders.

Fixes #579
This commit is contained in:
simonkrauter 2024-08-19 17:06:13 -03:00 committed by Sam Atkins
parent a2e4259099
commit 6c9adf3dbc
Notes: github-actions[bot] 2024-08-23 08:31:56 +00:00
5 changed files with 24 additions and 3 deletions

View file

@ -2368,4 +2368,9 @@ HTMLInputElement::ValueAttributeMode HTMLInputElement::value_attribute_mode() co
VERIFY_NOT_REACHED();
}
bool HTMLInputElement::is_child_node_selectable(DOM::Node const& node) const
{
return !is_button() && (!m_placeholder_element || !m_placeholder_element->is_inclusive_ancestor_of(node));
}
}