diff --git a/Userland/Libraries/LibWeb/DOM/Document.cpp b/Userland/Libraries/LibWeb/DOM/Document.cpp index 5a14f3ca9c6..0c2248afe55 100644 --- a/Userland/Libraries/LibWeb/DOM/Document.cpp +++ b/Userland/Libraries/LibWeb/DOM/Document.cpp @@ -107,6 +107,7 @@ #include #include #include +#include #include #include #include @@ -2154,6 +2155,9 @@ void Document::update_readiness(HTML::DocumentReadyState readiness_value) if (readiness_value == HTML::DocumentReadyState::Complete) { auto navigable = this->navigable(); if (navigable && navigable->is_traversable()) { + if (!is_decoded_svg()) { + HTML::HTMLLinkElement::load_fallback_favicon_if_needed(*this).release_value_but_fixme_should_propagate_errors(); + } HTML::HTMLLinkElement::load_fallback_favicon_if_needed(*this).release_value_but_fixme_should_propagate_errors(); navigable->traversable_navigable()->page().client().page_did_finish_loading(url()); } else { @@ -4803,6 +4807,11 @@ void Document::for_each_shadow_root(Function&& callback) callback(shadow_root); } +bool Document::is_decoded_svg() const +{ + return is(page().client()); +} + // https://drafts.csswg.org/css-position-4/#add-an-element-to-the-top-layer void Document::add_an_element_to_the_top_layer(JS::NonnullGCPtr element) { diff --git a/Userland/Libraries/LibWeb/DOM/Document.h b/Userland/Libraries/LibWeb/DOM/Document.h index 2c1436fdd16..c880b27ee1b 100644 --- a/Userland/Libraries/LibWeb/DOM/Document.h +++ b/Userland/Libraries/LibWeb/DOM/Document.h @@ -634,6 +634,9 @@ public: size_t transition_generation() const { return m_transition_generation; } + // Does document represent an embedded svg img + [[nodiscard]] bool is_decoded_svg() const; + protected: virtual void initialize(JS::Realm&) override; virtual void visit_edges(Cell::Visitor&) override; diff --git a/Userland/Libraries/LibWeb/SVG/SVGDecodedImageData.cpp b/Userland/Libraries/LibWeb/SVG/SVGDecodedImageData.cpp index fcb20439df4..d92ed02f362 100644 --- a/Userland/Libraries/LibWeb/SVG/SVGDecodedImageData.cpp +++ b/Userland/Libraries/LibWeb/SVG/SVGDecodedImageData.cpp @@ -25,39 +25,6 @@ namespace Web::SVG { JS_DEFINE_ALLOCATOR(SVGDecodedImageData); -class SVGDecodedImageData::SVGPageClient final : public PageClient { - JS_CELL(SVGDecodedImageData::SVGPageClient, PageClient); - -public: - static JS::NonnullGCPtr create(JS::VM& vm, Page& page) - { - return vm.heap().allocate_without_realm(page); - } - - virtual ~SVGPageClient() override = default; - - Page& m_host_page; - Page* m_svg_page { nullptr }; - - virtual Page& page() override { return *m_svg_page; } - virtual Page const& page() const override { return *m_svg_page; } - virtual bool is_connection_open() const override { return false; } - virtual Gfx::Palette palette() const override { return m_host_page.client().palette(); } - virtual DevicePixelRect screen_rect() const override { return {}; } - virtual double device_pixels_per_css_pixel() const override { return 1.0; } - virtual CSS::PreferredColorScheme preferred_color_scheme() const override { return m_host_page.client().preferred_color_scheme(); } - virtual void request_file(FileRequest) override { } - virtual void paint(DevicePixelRect const&, Gfx::Bitmap&, Web::PaintOptions = {}) override { } - virtual void schedule_repaint() override { } - virtual bool is_ready_to_paint() const override { return true; } - -private: - explicit SVGPageClient(Page& host_page) - : m_host_page(host_page) - { - } -}; - ErrorOr> SVGDecodedImageData::create(JS::Realm& realm, JS::NonnullGCPtr host_page, URL::URL const& url, ByteBuffer data) { auto page_client = SVGPageClient::create(Bindings::main_thread_vm(), host_page); diff --git a/Userland/Libraries/LibWeb/SVG/SVGDecodedImageData.h b/Userland/Libraries/LibWeb/SVG/SVGDecodedImageData.h index 796ae6d33ff..674cf17ef2c 100644 --- a/Userland/Libraries/LibWeb/SVG/SVGDecodedImageData.h +++ b/Userland/Libraries/LibWeb/SVG/SVGDecodedImageData.h @@ -8,6 +8,7 @@ #include #include +#include namespace Web::SVG { @@ -16,6 +17,7 @@ class SVGDecodedImageData final : public HTML::DecodedImageData { JS_DECLARE_ALLOCATOR(SVGDecodedImageData); public: + class SVGPageClient; static ErrorOr> create(JS::Realm&, JS::NonnullGCPtr, URL::URL const&, ByteBuffer encoded_svg); virtual ~SVGDecodedImageData() override; @@ -36,7 +38,6 @@ public: virtual void visit_edges(Cell::Visitor& visitor) override; private: - class SVGPageClient; SVGDecodedImageData(JS::NonnullGCPtr, JS::NonnullGCPtr, JS::NonnullGCPtr, JS::NonnullGCPtr); RefPtr render(Gfx::IntSize) const; @@ -50,4 +51,37 @@ private: JS::NonnullGCPtr m_root_element; }; +class SVGDecodedImageData::SVGPageClient final : public PageClient { + JS_CELL(SVGDecodedImageData::SVGPageClient, PageClient); + +public: + static JS::NonnullGCPtr create(JS::VM& vm, Page& page) + { + return vm.heap().allocate_without_realm(page); + } + + virtual ~SVGPageClient() override = default; + + Page& m_host_page; + Page* m_svg_page { nullptr }; + + virtual Page& page() override { return *m_svg_page; } + virtual Page const& page() const override { return *m_svg_page; } + virtual bool is_connection_open() const override { return false; } + virtual Gfx::Palette palette() const override { return m_host_page.client().palette(); } + virtual DevicePixelRect screen_rect() const override { return {}; } + virtual double device_pixels_per_css_pixel() const override { return 1.0; } + virtual CSS::PreferredColorScheme preferred_color_scheme() const override { return m_host_page.client().preferred_color_scheme(); } + virtual void request_file(FileRequest) override { } + virtual void paint(DevicePixelRect const&, Gfx::Bitmap&, Web::PaintOptions = {}) override { } + virtual void schedule_repaint() override { } + virtual bool is_ready_to_paint() const override { return true; } + +private: + explicit SVGPageClient(Page& host_page) + : m_host_page(host_page) + { + } +}; + }