diff options
author | Andreas Kling <kling@serenityos.org> | 2020-06-25 15:31:56 +0200 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2020-06-25 15:53:23 +0200 |
commit | f650f18bd208dfcd55b836c44eec4bdf1ffc8fba (patch) | |
tree | 93644e2982134b356958e7f71f1a57020526d382 | |
parent | bab0143bb27f8dfcdde25863276518d3b94d4f6f (diff) | |
download | serenity-f650f18bd208dfcd55b836c44eec4bdf1ffc8fba.zip |
LibWeb: Make scroll-to-anchor zone in on the element's padding box
That seems to be what other engines do. This is a bit hackish but we'll
soon have to redo scroll-to-anchor anyway for the multi-process model.
-rw-r--r-- | Libraries/LibWeb/PageView.cpp | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/Libraries/LibWeb/PageView.cpp b/Libraries/LibWeb/PageView.cpp index 4230183ad1..95cafa09bf 100644 --- a/Libraries/LibWeb/PageView.cpp +++ b/Libraries/LibWeb/PageView.cpp @@ -331,6 +331,11 @@ void PageView::scroll_to_anchor(const StringView& name) } auto& layout_node = *element->layout_node(); Gfx::FloatRect float_rect { layout_node.box_type_agnostic_position(), { (float)visible_content_rect().width(), (float)visible_content_rect().height() } }; + if (is<LayoutBox>(layout_node)) { + auto& layout_box = to<LayoutBox>(layout_node); + auto padding_box = layout_box.box_model().padding_box(layout_box); + float_rect.move_by(-padding_box.left, -padding_box.top); + } scroll_into_view(enclosing_int_rect(float_rect), true, true); window()->set_override_cursor(GUI::StandardCursor::None); } |