mirror of
https://github.com/LadybirdBrowser/ladybird
synced 2026-04-27 02:05:07 +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 ✅
@@ -1472,10 +1472,10 @@ void HTMLInputElement::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();
|
||||
|
||||
if (has_selectable_text()) {
|
||||
if (document().last_focus_trigger() == FocusTrigger::Key)
|
||||
@@ -1487,12 +1487,11 @@ void HTMLInputElement::did_receive_focus()
|
||||
|
||||
void HTMLInputElement::did_lose_focus()
|
||||
{
|
||||
if (m_text_node) {
|
||||
m_text_node->invalidate_style(DOM::StyleInvalidationReason::DidLoseFocus);
|
||||
}
|
||||
if (m_text_node)
|
||||
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();
|
||||
|
||||
commit_pending_changes();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user