mirror of
https://github.com/fergalmoran/ladybird.git
synced 2026-03-06 13:35:03 +00:00
LibWeb: Scroll elements into view when they become focused
This makes both user-interactive (tab keys) and programmatic focus changes scroll the viewport if necessary to reveal the newly focused element.
This commit is contained in:
@@ -1427,6 +1427,10 @@ void Document::set_focused_element(Element* element)
|
||||
|
||||
if (m_layout_root)
|
||||
m_layout_root->set_needs_display();
|
||||
|
||||
// Scroll the viewport if necessary to make the newly focused element visible.
|
||||
if (m_focused_element)
|
||||
m_focused_element->scroll_into_view();
|
||||
}
|
||||
|
||||
void Document::set_active_element(Element* element)
|
||||
|
||||
@@ -160,7 +160,7 @@ public:
|
||||
WebIDL::ExceptionOr<void> insert_adjacent_text(String const& where, String const& data);
|
||||
|
||||
// https://w3c.github.io/csswg-drafts/cssom-view-1/#dom-element-scrollintoview
|
||||
void scroll_into_view(Optional<Variant<bool, ScrollIntoViewOptions>>);
|
||||
void scroll_into_view(Optional<Variant<bool, ScrollIntoViewOptions>> = {});
|
||||
|
||||
protected:
|
||||
Element(Document&, DOM::QualifiedName);
|
||||
|
||||
Reference in New Issue
Block a user