mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-06-16 15:21:56 +00:00
LibWeb: Invalidate input element style on focus change
The style of input and textarea elements is now invalidated when focus is changed to a new element. This ensures any `:focus` selectors are applied correctly.
This commit is contained in:
parent
9448c957c1
commit
572324d47b
Notes:
sideshowbarker
2024-07-17 01:53:23 +09:00
Author: https://github.com/tcl3
Commit: 572324d47b
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/499
Issue: https://github.com/LadybirdBrowser/ladybird/issues/471
2 changed files with 16 additions and 6 deletions
|
@ -1098,16 +1098,21 @@ void HTMLInputElement::update_slider_thumb_element()
|
||||||
|
|
||||||
void HTMLInputElement::did_receive_focus()
|
void HTMLInputElement::did_receive_focus()
|
||||||
{
|
{
|
||||||
auto navigable = document().navigable();
|
|
||||||
if (!navigable)
|
|
||||||
return;
|
|
||||||
if (!m_text_node)
|
if (!m_text_node)
|
||||||
return;
|
return;
|
||||||
|
m_text_node->invalidate_style();
|
||||||
|
auto navigable = document().navigable();
|
||||||
|
if (!navigable) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
navigable->set_cursor_position(DOM::Position::create(realm(), *m_text_node, 0));
|
navigable->set_cursor_position(DOM::Position::create(realm(), *m_text_node, 0));
|
||||||
}
|
}
|
||||||
|
|
||||||
void HTMLInputElement::did_lose_focus()
|
void HTMLInputElement::did_lose_focus()
|
||||||
{
|
{
|
||||||
|
if (m_text_node)
|
||||||
|
m_text_node->invalidate_style();
|
||||||
|
|
||||||
commit_pending_changes();
|
commit_pending_changes();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -67,16 +67,21 @@ void HTMLTextAreaElement::visit_edges(Cell::Visitor& visitor)
|
||||||
|
|
||||||
void HTMLTextAreaElement::did_receive_focus()
|
void HTMLTextAreaElement::did_receive_focus()
|
||||||
{
|
{
|
||||||
auto navigable = document().navigable();
|
|
||||||
if (!navigable)
|
|
||||||
return;
|
|
||||||
if (!m_text_node)
|
if (!m_text_node)
|
||||||
return;
|
return;
|
||||||
|
m_text_node->invalidate_style();
|
||||||
|
auto navigable = document().navigable();
|
||||||
|
if (!navigable) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
navigable->set_cursor_position(DOM::Position::create(realm(), *m_text_node, 0));
|
navigable->set_cursor_position(DOM::Position::create(realm(), *m_text_node, 0));
|
||||||
}
|
}
|
||||||
|
|
||||||
void HTMLTextAreaElement::did_lose_focus()
|
void HTMLTextAreaElement::did_lose_focus()
|
||||||
{
|
{
|
||||||
|
if (m_text_node)
|
||||||
|
m_text_node->invalidate_style();
|
||||||
|
|
||||||
// The change event fires when the value is committed, if that makes sense for the control,
|
// The change event fires when the value is committed, if that makes sense for the control,
|
||||||
// or else when the control loses focus
|
// or else when the control loses focus
|
||||||
queue_an_element_task(HTML::Task::Source::UserInteraction, [this] {
|
queue_an_element_task(HTML::Task::Source::UserInteraction, [this] {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue