mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-09-20 17:58:18 +03:00
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.
This commit is contained in:
parent
bab0143bb2
commit
f650f18bd2
Notes:
sideshowbarker
2024-07-19 05:23:24 +09:00
Author: https://github.com/awesomekling Commit: https://github.com/SerenityOS/serenity/commit/f650f18bd20
@ -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);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user