diff options
-rw-r--r-- | Userland/Libraries/LibWeb/Page/Frame.cpp | 22 | ||||
-rw-r--r-- | Userland/Libraries/LibWeb/Page/Frame.h | 1 | ||||
-rw-r--r-- | Userland/Services/WebContent/PageHost.cpp | 5 |
3 files changed, 24 insertions, 4 deletions
diff --git a/Userland/Libraries/LibWeb/Page/Frame.cpp b/Userland/Libraries/LibWeb/Page/Frame.cpp index 29decc7d08..ac1cbb8c4c 100644 --- a/Userland/Libraries/LibWeb/Page/Frame.cpp +++ b/Userland/Libraries/LibWeb/Page/Frame.cpp @@ -108,6 +108,28 @@ void Frame::set_document(DOM::Document* document) m_page->client().page_did_set_document_in_main_frame(m_document); } +void Frame::set_viewport_rect(const Gfx::IntRect& rect) +{ + bool did_change = false; + + if (m_size != rect.size()) { + m_size = rect.size(); + if (m_document) + m_document->update_layout(); + did_change = true; + } + + if (m_viewport_scroll_offset != rect.location()) { + m_viewport_scroll_offset = rect.location(); + did_change = true; + } + + if (did_change) { + for (auto* client : m_viewport_clients) + client->frame_did_set_viewport_rect(rect); + } +} + void Frame::set_size(const Gfx::IntSize& size) { if (m_size == size) diff --git a/Userland/Libraries/LibWeb/Page/Frame.h b/Userland/Libraries/LibWeb/Page/Frame.h index aad2e566b8..eae2e89692 100644 --- a/Userland/Libraries/LibWeb/Page/Frame.h +++ b/Userland/Libraries/LibWeb/Page/Frame.h @@ -73,6 +73,7 @@ public: void set_viewport_scroll_offset(const Gfx::IntPoint&); Gfx::IntRect viewport_rect() const { return { m_viewport_scroll_offset, m_size }; } + void set_viewport_rect(const Gfx::IntRect&); void did_scroll(Badge<InProcessWebView>); diff --git a/Userland/Services/WebContent/PageHost.cpp b/Userland/Services/WebContent/PageHost.cpp index d37ff61054..929cfac044 100644 --- a/Userland/Services/WebContent/PageHost.cpp +++ b/Userland/Services/WebContent/PageHost.cpp @@ -100,10 +100,7 @@ void PageHost::paint(const Gfx::IntRect& content_rect, Gfx::Bitmap& target) void PageHost::set_viewport_rect(const Gfx::IntRect& rect) { - page().main_frame().set_size(rect.size()); - if (page().main_frame().document()) - page().main_frame().document()->update_layout(); - page().main_frame().set_viewport_scroll_offset(rect.location()); + page().main_frame().set_viewport_rect(rect); } void PageHost::page_did_invalidate(const Gfx::IntRect& content_rect) |