mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-06-05 01:42:54 +00:00
LibWeb: Move the navigable's cursor position to be owned by the document
Navigables are re-used for navigations within the same tab. Its current ownership of the cursor position is a bit ad-hoc, so nothing in the spec indicates when to reset the cursor, nor do we manually do so. So when a cursor update happens on one page, that cursor is retained on the next page. Instead, let's have the document own the cursor. Each navigation results in a new document, thus we don't need to worry about resetting cursors. This also makes many of the callsites feel nicer. We were previously often going from the node, to the document, to the navigable, to the cursor. This patch removes the navigable hop.
This commit is contained in:
parent
f8d83b2922
commit
faebbbc281
Notes:
github-actions[bot]
2024-08-02 16:41:32 +00:00
Author: https://github.com/trflynn89
Commit: faebbbc281
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/932
Reviewed-by: https://github.com/AtkinsSJ
Reviewed-by: https://github.com/awesomekling
Reviewed-by: https://github.com/shannonbooth
15 changed files with 155 additions and 159 deletions
|
@ -407,7 +407,7 @@ WebIDL::ExceptionOr<void> HTMLInputElement::run_input_activation_behavior(DOM::E
|
|||
return {};
|
||||
}
|
||||
|
||||
void HTMLInputElement::did_edit_text_node(Badge<Navigable>)
|
||||
void HTMLInputElement::did_edit_text_node(Badge<DOM::Document>)
|
||||
{
|
||||
// An input element's dirty value flag must be set to true whenever the user interacts with the control in a way that changes the value.
|
||||
m_value = value_sanitization_algorithm(m_text_node->data());
|
||||
|
@ -555,8 +555,7 @@ WebIDL::ExceptionOr<void> HTMLInputElement::set_value(String const& value)
|
|||
m_text_node->set_data(m_value);
|
||||
update_placeholder_visibility();
|
||||
|
||||
if (auto navigable = document().navigable())
|
||||
navigable->set_cursor_position(DOM::Position::create(realm, *m_text_node, m_text_node->data().bytes().size()));
|
||||
document().set_cursor_position(DOM::Position::create(realm, *m_text_node, m_text_node->data().bytes().size()));
|
||||
}
|
||||
|
||||
update_shadow_tree();
|
||||
|
@ -1137,11 +1136,8 @@ void HTMLInputElement::did_receive_focus()
|
|||
if (!m_text_node)
|
||||
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));
|
||||
|
||||
document().set_cursor_position(DOM::Position::create(realm(), *m_text_node, 0));
|
||||
}
|
||||
|
||||
void HTMLInputElement::did_lose_focus()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue