diff --git a/Tests/LibWeb/Text/expected/scroll-into-view-center.txt b/Tests/LibWeb/Text/expected/scroll-into-view-center.txt new file mode 100644 index 0000000000..fbdc2759f0 --- /dev/null +++ b/Tests/LibWeb/Text/expected/scroll-into-view-center.txt @@ -0,0 +1 @@ + The page has been scrolled to y: 800 diff --git a/Tests/LibWeb/Text/input/scroll-into-view-center.html b/Tests/LibWeb/Text/input/scroll-into-view-center.html new file mode 100644 index 0000000000..08accabdda --- /dev/null +++ b/Tests/LibWeb/Text/input/scroll-into-view-center.html @@ -0,0 +1,29 @@ + + +
+
+
+ diff --git a/Userland/Libraries/LibWeb/DOM/Element.cpp b/Userland/Libraries/LibWeb/DOM/Element.cpp index 6af6fd6417..438f159aab 100644 --- a/Userland/Libraries/LibWeb/DOM/Element.cpp +++ b/Userland/Libraries/LibWeb/DOM/Element.cpp @@ -1672,7 +1672,7 @@ static ErrorOr scroll_an_element_into_view(DOM::Element& target, Bindings: } // 3. Otherwise, if block is "center", then align the center of target bounding border box with the center of scrolling box in scrolling box’s block flow direction. else if (block == Bindings::ScrollLogicalPosition::Center) { - TODO(); + y = element_edge_a + (element_height / 2) - (scrolling_box_height / 2); } // 4. Otherwise, block is "nearest": else {