mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-25 09:00:22 +00:00
LibWeb: Don't load fallback icon for SVG documents
Skip loading a fallback favicon if Document represents a decoded SVG. Issue: #23405
This commit is contained in:
parent
44d3fd0546
commit
bdb8af94ee
Notes:
sideshowbarker
2024-07-17 20:19:08 +09:00
Author: https://github.com/mobounya Commit: https://github.com/SerenityOS/serenity/commit/bdb8af94ee Pull-request: https://github.com/SerenityOS/serenity/pull/23406 Reviewed-by: https://github.com/ADKaster Reviewed-by: https://github.com/awesomekling Reviewed-by: https://github.com/kalenikaliaksandr Reviewed-by: https://github.com/trflynn89
4 changed files with 47 additions and 34 deletions
|
@ -107,6 +107,7 @@
|
|||
#include <LibWeb/PermissionsPolicy/AutoplayAllowlist.h>
|
||||
#include <LibWeb/ResizeObserver/ResizeObserver.h>
|
||||
#include <LibWeb/ResizeObserver/ResizeObserverEntry.h>
|
||||
#include <LibWeb/SVG/SVGDecodedImageData.h>
|
||||
#include <LibWeb/SVG/SVGElement.h>
|
||||
#include <LibWeb/SVG/SVGTitleElement.h>
|
||||
#include <LibWeb/SVG/TagNames.h>
|
||||
|
@ -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<void(DOM::ShadowRoot&)>&& callback)
|
|||
callback(shadow_root);
|
||||
}
|
||||
|
||||
bool Document::is_decoded_svg() const
|
||||
{
|
||||
return is<Web::SVG::SVGDecodedImageData::SVGPageClient>(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> element)
|
||||
{
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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<SVGPageClient> create(JS::VM& vm, Page& page)
|
||||
{
|
||||
return vm.heap().allocate_without_realm<SVGPageClient>(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<JS::NonnullGCPtr<SVGDecodedImageData>> SVGDecodedImageData::create(JS::Realm& realm, JS::NonnullGCPtr<Page> host_page, URL::URL const& url, ByteBuffer data)
|
||||
{
|
||||
auto page_client = SVGPageClient::create(Bindings::main_thread_vm(), host_page);
|
||||
|
|
|
@ -8,6 +8,7 @@
|
|||
|
||||
#include <LibWeb/DOM/Document.h>
|
||||
#include <LibWeb/HTML/DecodedImageData.h>
|
||||
#include <WebContent/PageClient.h>
|
||||
|
||||
namespace Web::SVG {
|
||||
|
||||
|
@ -16,6 +17,7 @@ class SVGDecodedImageData final : public HTML::DecodedImageData {
|
|||
JS_DECLARE_ALLOCATOR(SVGDecodedImageData);
|
||||
|
||||
public:
|
||||
class SVGPageClient;
|
||||
static ErrorOr<JS::NonnullGCPtr<SVGDecodedImageData>> create(JS::Realm&, JS::NonnullGCPtr<Page>, 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<Page>, JS::NonnullGCPtr<SVGPageClient>, JS::NonnullGCPtr<DOM::Document>, JS::NonnullGCPtr<SVG::SVGSVGElement>);
|
||||
|
||||
RefPtr<Gfx::Bitmap> render(Gfx::IntSize) const;
|
||||
|
@ -50,4 +51,37 @@ private:
|
|||
JS::NonnullGCPtr<SVG::SVGSVGElement> m_root_element;
|
||||
};
|
||||
|
||||
class SVGDecodedImageData::SVGPageClient final : public PageClient {
|
||||
JS_CELL(SVGDecodedImageData::SVGPageClient, PageClient);
|
||||
|
||||
public:
|
||||
static JS::NonnullGCPtr<SVGPageClient> create(JS::VM& vm, Page& page)
|
||||
{
|
||||
return vm.heap().allocate_without_realm<SVGPageClient>(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)
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue