diff options
author | Andreas Kling <kling@serenityos.org> | 2020-06-23 18:02:08 +0200 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2020-06-23 18:02:08 +0200 |
commit | 78f10942ba08b4400619337292d7bb8a4997b217 (patch) | |
tree | 25f952035f3893abcad51169f7e210373662e825 | |
parent | 0166a1fa7467ec9737ca52c35a5e977303757d6d (diff) | |
download | serenity-78f10942ba08b4400619337292d7bb8a4997b217.zip |
LibWeb: Update PageView content size on page relayout
If the layout changes and the page becomes taller or shorter for some
reason, we need to update the PageView's scrollable content size.
-rw-r--r-- | Libraries/LibWeb/DOM/Document.cpp | 2 | ||||
-rw-r--r-- | Libraries/LibWeb/Page.h | 1 | ||||
-rw-r--r-- | Libraries/LibWeb/PageView.cpp | 5 | ||||
-rw-r--r-- | Libraries/LibWeb/PageView.h | 1 |
4 files changed, 9 insertions, 0 deletions
diff --git a/Libraries/LibWeb/DOM/Document.cpp b/Libraries/LibWeb/DOM/Document.cpp index 9bd60d24d3..0d62288c76 100644 --- a/Libraries/LibWeb/DOM/Document.cpp +++ b/Libraries/LibWeb/DOM/Document.cpp @@ -245,6 +245,8 @@ void Document::layout() } m_layout_root->layout(); m_layout_root->set_needs_display(); + + frame()->page().client().page_did_layout(); } void Document::update_style() diff --git a/Libraries/LibWeb/Page.h b/Libraries/LibWeb/Page.h index 32a2e57d7c..5d2967abf7 100644 --- a/Libraries/LibWeb/Page.h +++ b/Libraries/LibWeb/Page.h @@ -84,6 +84,7 @@ public: virtual void page_did_request_scroll_to_anchor([[maybe_unused]] const String& fragment) { } virtual void page_did_invalidate(const Gfx::IntRect&) { } virtual void page_did_change_favicon(const Gfx::Bitmap&) { } + virtual void page_did_layout() { } }; } diff --git a/Libraries/LibWeb/PageView.cpp b/Libraries/LibWeb/PageView.cpp index 24c8d9a658..4230183ad1 100644 --- a/Libraries/LibWeb/PageView.cpp +++ b/Libraries/LibWeb/PageView.cpp @@ -66,6 +66,11 @@ PageView::~PageView() { } +void PageView::page_did_layout() +{ + set_content_size(layout_root()->size().to_int_size()); +} + void PageView::page_did_change_title(const String& title) { if (on_title_change) diff --git a/Libraries/LibWeb/PageView.h b/Libraries/LibWeb/PageView.h index f57f5f0f8a..8dec382d94 100644 --- a/Libraries/LibWeb/PageView.h +++ b/Libraries/LibWeb/PageView.h @@ -108,6 +108,7 @@ private: virtual void page_did_request_scroll_to_anchor(const String& fragment) override; virtual void page_did_invalidate(const Gfx::IntRect&) override; virtual void page_did_change_favicon(const Gfx::Bitmap&) override; + virtual void page_did_layout() override; void layout_and_sync_size(); |