1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-26 11:27:34 +00:00

LibWeb: Move image resource request out of ImageStyleValue constructor

This always felt awkward to me, and required a few other hacks to make
it work. Now, the request is only started when `load_bitmap()` is
called, which we do inside `NodeWithStyle::apply_style()`.
This commit is contained in:
Sam Atkins 2021-10-22 20:55:27 +01:00 committed by Andreas Kling
parent cf3c125e77
commit 0f393771b7
5 changed files with 17 additions and 9 deletions

View file

@ -891,15 +891,16 @@ class ImageStyleValue final
: public StyleValue
, public ImageResourceClient {
public:
static NonnullRefPtr<ImageStyleValue> create(AK::URL const& url, DOM::Document* document) { return adopt_ref(*new ImageStyleValue(url, document)); }
static NonnullRefPtr<ImageStyleValue> create(AK::URL const& url) { return adopt_ref(*new ImageStyleValue(url)); }
virtual ~ImageStyleValue() override { }
String to_string() const override { return String::formatted("Image({})", m_url.to_string()); }
const Gfx::Bitmap* bitmap() const { return m_bitmap; }
void load_bitmap(DOM::Document& document);
Gfx::Bitmap const* bitmap() const { return m_bitmap; }
private:
ImageStyleValue(AK::URL const&, DOM::Document*);
ImageStyleValue(AK::URL const&);
// ^ResourceClient
virtual void resource_did_load() override;