mirror of
https://github.com/LadybirdBrowser/ladybird
synced 2026-04-28 02:27:19 +02:00
LibWeb: Invalidate paint cache for input/textarea on focus change
The invalidate_style() calls on text nodes in did_receive_focus() and did_lose_focus() were no-ops since Node::invalidate_style() returns early for character data nodes. Replace them with set_needs_repaint() which properly invalidates the containing PaintableWithLines' paint cache, ensuring selection highlights are cleared and the caret is repainted when switching focus between text controls. Fixes #8363
This commit is contained in:
committed by
Tim Ledbetter
parent
76c65eca57
commit
2e42421553
Notes:
github-actions[bot]
2026-03-11 16:45:30 +00:00
Author: https://github.com/gmta Commit: https://github.com/LadybirdBrowser/ladybird/commit/2e42421553f Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/8366 Reviewed-by: https://github.com/kalenikaliaksandr ✅ Reviewed-by: https://github.com/tcl3 ✅
@@ -72,10 +72,10 @@ void HTMLTextAreaElement::did_receive_focus()
|
||||
{
|
||||
if (!m_text_node)
|
||||
return;
|
||||
m_text_node->invalidate_style(DOM::StyleInvalidationReason::DidReceiveFocus);
|
||||
m_text_node->set_needs_repaint();
|
||||
|
||||
if (m_placeholder_text_node)
|
||||
m_placeholder_text_node->invalidate_style(DOM::StyleInvalidationReason::DidReceiveFocus);
|
||||
m_placeholder_text_node->set_needs_repaint();
|
||||
|
||||
document().get_selection()->remove_all_ranges();
|
||||
}
|
||||
@@ -83,10 +83,10 @@ void HTMLTextAreaElement::did_receive_focus()
|
||||
void HTMLTextAreaElement::did_lose_focus()
|
||||
{
|
||||
if (m_text_node)
|
||||
m_text_node->invalidate_style(DOM::StyleInvalidationReason::DidLoseFocus);
|
||||
m_text_node->set_needs_repaint();
|
||||
|
||||
if (m_placeholder_text_node)
|
||||
m_placeholder_text_node->invalidate_style(DOM::StyleInvalidationReason::DidLoseFocus);
|
||||
m_placeholder_text_node->set_needs_repaint();
|
||||
|
||||
// The change event fires when the value is committed, if that makes sense for the control,
|
||||
// or else when the control loses focus
|
||||
|
||||
Reference in New Issue
Block a user