From c5d91dce8b1837d54dbf8554b234134e2815b1ac Mon Sep 17 00:00:00 2001 From: Aliaksandr Kalenik Date: Tue, 19 Dec 2023 15:52:56 +0100 Subject: [PATCH] LibWeb: Scroll to the "start" in Document::scroll_to_fragment() Implements spec comment. --- .../Text/expected/scroll-to-fragment.txt | 1 + .../LibWeb/Text/input/scroll-to-fragment.html | 35 +++++++++++++++++++ Userland/Libraries/LibWeb/DOM/Document.cpp | 6 ++-- 3 files changed, 40 insertions(+), 2 deletions(-) create mode 100644 Tests/LibWeb/Text/expected/scroll-to-fragment.txt create mode 100644 Tests/LibWeb/Text/input/scroll-to-fragment.html diff --git a/Tests/LibWeb/Text/expected/scroll-to-fragment.txt b/Tests/LibWeb/Text/expected/scroll-to-fragment.txt new file mode 100644 index 0000000000..0b88047ce4 --- /dev/null +++ b/Tests/LibWeb/Text/expected/scroll-to-fragment.txt @@ -0,0 +1 @@ +Take test The page has been scrolled to y: 562.59375 \ No newline at end of file diff --git a/Tests/LibWeb/Text/input/scroll-to-fragment.html b/Tests/LibWeb/Text/input/scroll-to-fragment.html new file mode 100644 index 0000000000..24d0430609 --- /dev/null +++ b/Tests/LibWeb/Text/input/scroll-to-fragment.html @@ -0,0 +1,35 @@ + + +Take test +
+
+ + diff --git a/Userland/Libraries/LibWeb/DOM/Document.cpp b/Userland/Libraries/LibWeb/DOM/Document.cpp index efbee2cc28..f4a32f772c 100644 --- a/Userland/Libraries/LibWeb/DOM/Document.cpp +++ b/Userland/Libraries/LibWeb/DOM/Document.cpp @@ -1842,8 +1842,10 @@ void Document::scroll_to_the_fragment() // FIXME: 5. Run the ancestor hidden-until-found revealing algorithm on target. // 6. Scroll target into view, with behavior set to "auto", block set to "start", and inline set to "nearest". [CSSOMVIEW] - // FIXME: Do this properly! - (void)target->scroll_into_view(); + ScrollIntoViewOptions scroll_options; + scroll_options.block = Bindings::ScrollLogicalPosition::Start; + scroll_options.inline_ = Bindings::ScrollLogicalPosition::Nearest; + (void)target->scroll_into_view(scroll_options); // 7. Run the focusing steps for target, with the Document's viewport as the fallback target. // FIXME: Pass the Document's viewport somehow.