1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 04:38:11 +00:00

LibWeb: Move viewport subscriptions from BrowsingContext to Document

With this change, elements that want to receive viewport rect updates
will need to register on document instead of the browsing context.

This change solves the problem where a browsing context for a document
is guaranteed to exist only while the document is active so browsing
context might not exit by the time DOM node that want to register is
constructed.

This is a part of preparation work before switching to navigables where
this issue becomes more visible.
This commit is contained in:
Aliaksandr Kalenik 2023-08-23 18:58:42 +02:00 committed by Andreas Kling
parent 48e9097aa4
commit 5ff7448fee
10 changed files with 66 additions and 61 deletions

View file

@ -9,6 +9,7 @@
#include <AK/ByteBuffer.h>
#include <AK/OwnPtr.h>
#include <LibGfx/Forward.h>
#include <LibWeb/DOM/Document.h>
#include <LibWeb/DOM/DocumentLoadEventDelayer.h>
#include <LibWeb/HTML/BrowsingContext.h>
#include <LibWeb/HTML/CORSSettingAttribute.h>
@ -23,7 +24,7 @@ class HTMLImageElement final
: public HTMLElement
, public FormAssociatedElement
, public Layout::ImageProvider
, public BrowsingContext::ViewportClient {
, public DOM::Document::ViewportClient {
WEB_PLATFORM_OBJECT(HTMLImageElement, HTMLElement);
FORM_ASSOCIATED_ELEMENT(HTMLElement, HTMLImageElement)
@ -99,11 +100,13 @@ private:
virtual void initialize(JS::Realm&) override;
virtual void finalize() override;
virtual void adopted_from(DOM::Document&) override;
virtual void apply_presentational_hints(CSS::StyleProperties&) const override;
virtual JS::GCPtr<Layout::Node> create_layout_node(NonnullRefPtr<CSS::StyleProperties>) override;
virtual void browsing_context_did_set_viewport_rect(CSSPixelRect const&) override;
virtual void did_set_viewport_rect(CSSPixelRect const&) override;
void handle_successful_fetch(AK::URL const&, StringView mime_type, ImageRequest&, ByteBuffer, bool maybe_omit_events, AK::URL const& previous_url);
void handle_failed_fetch();