diff options
author | Andreas Kling <kling@serenityos.org> | 2023-05-09 07:25:20 +0200 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2023-05-09 09:48:49 +0200 |
commit | 6ae208dbf6af4356e1de29023d6feb3e63cf62ca (patch) | |
tree | e9b3899a794894cdc9d936989c332a2768b99e66 /Userland/Libraries/LibWeb/HTML | |
parent | dbe961ca02c6d360058f4e73748b44cfbd419a70 (diff) | |
download | serenity-6ae208dbf6af4356e1de29023d6feb3e63cf62ca.zip |
LibWeb: Broadcast the viewport rect to clients immediately after layout
This lets elements figure out if they're visible within the viewport or
not, so they take appropriate action.
Fixes the issues with animations not starting until the viewport was
resized or scrolled.
Diffstat (limited to 'Userland/Libraries/LibWeb/HTML')
-rw-r--r-- | Userland/Libraries/LibWeb/HTML/BrowsingContext.cpp | 6 | ||||
-rw-r--r-- | Userland/Libraries/LibWeb/HTML/BrowsingContext.h | 2 |
2 files changed, 8 insertions, 0 deletions
diff --git a/Userland/Libraries/LibWeb/HTML/BrowsingContext.cpp b/Userland/Libraries/LibWeb/HTML/BrowsingContext.cpp index 874fce80b6..d0f6122ce2 100644 --- a/Userland/Libraries/LibWeb/HTML/BrowsingContext.cpp +++ b/Userland/Libraries/LibWeb/HTML/BrowsingContext.cpp @@ -539,6 +539,12 @@ void BrowsingContext::set_active_document(JS::NonnullGCPtr<DOM::Document> docume previously_active_document->did_stop_being_active_document_in_browsing_context({}); } +void BrowsingContext::inform_all_viewport_clients_about_the_current_viewport_rect() +{ + for (auto* client : m_viewport_clients) + client->browsing_context_did_set_viewport_rect(viewport_rect()); +} + void BrowsingContext::set_viewport_rect(CSSPixelRect const& rect) { bool did_change = false; diff --git a/Userland/Libraries/LibWeb/HTML/BrowsingContext.h b/Userland/Libraries/LibWeb/HTML/BrowsingContext.h index d043fa6982..162179015d 100644 --- a/Userland/Libraries/LibWeb/HTML/BrowsingContext.h +++ b/Userland/Libraries/LibWeb/HTML/BrowsingContext.h @@ -277,6 +277,8 @@ public: virtual String const& window_handle() const override { return m_window_handle; } virtual void set_window_handle(String handle) override { m_window_handle = move(handle); } + void inform_all_viewport_clients_about_the_current_viewport_rect(); + private: explicit BrowsingContext(Page&, HTML::NavigableContainer*); |