LibWeb: Scroll into viewport from a task in set_focused_element()
This is a hack needed to preserve current behaviour after making set viewport_rect() being not async in upcoming changes. For example both handle_mousedown and handle_mouseup should use the same viewport scroll offset even though handle_mousedown runs focusing steps that might cause scrolling to focused element: - handle_mousedown({ 0, 0 }) - run_focusing_steps() - set_focused_element() - scroll_into_viewport() changes viewport scroll offset - handle_mouseup({ 0, 0 })
This commit is contained in:
parent
8e062a52a3
commit
50920b0595
Notes:
sideshowbarker
2024-07-17 01:27:18 +09:00
Author: https://github.com/kalenikaliaksandr Commit: https://github.com/LadybirdBrowser/ladybird/commit/50920b0595 Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/21
1 changed files with 6 additions and 4 deletions
|
@ -1906,10 +1906,12 @@ void Document::set_focused_element(Element* element)
|
|||
|
||||
// Scroll the viewport if necessary to make the newly focused element visible.
|
||||
if (m_focused_element) {
|
||||
ScrollIntoViewOptions scroll_options;
|
||||
scroll_options.block = Bindings::ScrollLogicalPosition::Nearest;
|
||||
scroll_options.inline_ = Bindings::ScrollLogicalPosition::Nearest;
|
||||
(void)m_focused_element->scroll_into_view(scroll_options);
|
||||
m_focused_element->queue_an_element_task(HTML::Task::Source::UserInteraction, [&]() {
|
||||
ScrollIntoViewOptions scroll_options;
|
||||
scroll_options.block = Bindings::ScrollLogicalPosition::Nearest;
|
||||
scroll_options.inline_ = Bindings::ScrollLogicalPosition::Nearest;
|
||||
(void)m_focused_element->scroll_into_view(scroll_options);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue