LibWeb: Move event handling & cursor from BrowsingContext to Navigable

This was a long standing FIXME since the introduction of navigables.
This commit is contained in:
Andreas Kling 2024-04-26 16:59:04 +02:00
parent 9cd4a65071
commit 0ebfc0a4c4
Notes: sideshowbarker 2024-07-17 01:46:43 +09:00
26 changed files with 364 additions and 360 deletions

View file

@ -66,12 +66,12 @@ void HTMLTextAreaElement::visit_edges(Cell::Visitor& visitor)
void HTMLTextAreaElement::did_receive_focus()
{
auto* browsing_context = document().browsing_context();
if (!browsing_context)
auto navigable = document().navigable();
if (!navigable)
return;
if (!m_text_node)
return;
browsing_context->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()
@ -158,8 +158,8 @@ void HTMLTextAreaElement::set_value(String const& value)
m_text_node->set_data(m_raw_value);
update_placeholder_visibility();
if (auto* browsing_context = document().browsing_context())
browsing_context->set_cursor_position(DOM::Position::create(realm, *m_text_node, m_text_node->data().bytes().size()));
if (auto navigable = document().navigable())
navigable->set_cursor_position(DOM::Position::create(realm, *m_text_node, m_text_node->data().bytes().size()));
}
}
}
@ -215,8 +215,8 @@ WebIDL::UnsignedLong HTMLTextAreaElement::selection_start() const
// 2. If there is no selection, return the code unit offset within the relevant value to the character that
// immediately follows the text entry cursor.
if (auto const* browsing_context = document().browsing_context()) {
if (auto cursor = browsing_context->cursor_position())
if (auto navigable = document().navigable()) {
if (auto cursor = navigable->cursor_position())
return cursor->offset();
}
@ -244,8 +244,8 @@ WebIDL::UnsignedLong HTMLTextAreaElement::selection_end() const
// 2. If there is no selection, return the code unit offset within the relevant value to the character that
// immediately follows the text entry cursor.
if (auto const* browsing_context = document().browsing_context()) {
if (auto cursor = browsing_context->cursor_position())
if (auto navigable = document().navigable()) {
if (auto cursor = navigable->cursor_position())
return cursor->offset();
}
@ -430,7 +430,7 @@ void HTMLTextAreaElement::form_associated_element_attribute_changed(FlyString co
}
}
void HTMLTextAreaElement::did_edit_text_node(Badge<Web::HTML::BrowsingContext>)
void HTMLTextAreaElement::did_edit_text_node(Badge<Navigable>)
{
VERIFY(m_text_node);
set_raw_value(m_text_node->data());