diff options
author | Andreas Kling <kling@serenityos.org> | 2020-07-05 14:50:38 +0200 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2020-07-05 15:57:07 +0200 |
commit | 56d14d57013af3d1f7efbf957b2632b0390d2e0f (patch) | |
tree | 24ac0c98b6dc234c9256a0e62e767f7d7df042a4 /Libraries/LibWeb/PageView.cpp | |
parent | 2b80a45f82fa1203c1c2ab013c154116f6f2b2f6 (diff) | |
download | serenity-56d14d57013af3d1f7efbf957b2632b0390d2e0f.zip |
LibWeb: Move fragment link handling to Frame
Activating a "#foo" fragment link will now be handled internally by
the Frame instead of involving the widget layer.
If the viewport needs to be scrolled as a result, we will simply ask
the PageClient to scroll a new rect into view.
Diffstat (limited to 'Libraries/LibWeb/PageView.cpp')
-rw-r--r-- | Libraries/LibWeb/PageView.cpp | 38 |
1 files changed, 2 insertions, 36 deletions
diff --git a/Libraries/LibWeb/PageView.cpp b/Libraries/LibWeb/PageView.cpp index 4ae7dc2abf..56b7acf430 100644 --- a/Libraries/LibWeb/PageView.cpp +++ b/Libraries/LibWeb/PageView.cpp @@ -239,11 +239,6 @@ void PageView::page_did_unhover_link() { } -void PageView::page_did_request_scroll_to_anchor(const String& fragment) -{ - scroll_to_anchor(fragment); -} - void PageView::page_did_invalidate(const Gfx::IntRect&) { update(); @@ -403,38 +398,9 @@ LayoutDocument* PageView::layout_root() return const_cast<LayoutDocument*>(document()->layout_node()); } -void PageView::scroll_to_anchor(const StringView& name) +void PageView::page_did_request_scroll_into_view(const Gfx::IntRect& rect) { - if (!document()) - return; - - const auto* element = document()->get_element_by_id(name); - if (!element) { - auto candidates = document()->get_elements_by_name(name); - for (auto* candidate : candidates) { - if (is<HTMLAnchorElement>(*candidate)) { - element = to<HTMLAnchorElement>(candidate); - break; - } - } - } - - if (!element) { - dbg() << "PageView::scroll_to_anchor(): Anchor not found: '" << name << "'"; - return; - } - if (!element->layout_node()) { - dbg() << "PageView::scroll_to_anchor(): Anchor found but without layout node: '" << name << "'"; - return; - } - 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); + scroll_into_view(rect, true, true); window()->set_override_cursor(GUI::StandardCursor::None); } |