From 88aa3566066bfd24156b45707ce42dd767fcc98b Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Thu, 3 Mar 2022 13:24:03 +0100 Subject: [PATCH] LibWeb: Update element style when focus state changes To ensure that :focus rules get included (or excluded), we have to update style whenever focus moves. --- Userland/Libraries/LibWeb/DOM/Document.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/Userland/Libraries/LibWeb/DOM/Document.cpp b/Userland/Libraries/LibWeb/DOM/Document.cpp index f929326525d606..41f79e2673812c 100644 --- a/Userland/Libraries/LibWeb/DOM/Document.cpp +++ b/Userland/Libraries/LibWeb/DOM/Document.cpp @@ -1081,13 +1081,17 @@ void Document::set_focused_element(Element* element) if (m_focused_element == element) return; - if (m_focused_element) + if (m_focused_element) { m_focused_element->did_lose_focus(); + m_focused_element->set_needs_style_update(true); + } m_focused_element = element; - if (m_focused_element) + if (m_focused_element) { m_focused_element->did_receive_focus(); + m_focused_element->set_needs_style_update(true); + } if (m_layout_root) m_layout_root->set_needs_display();