diff options
Diffstat (limited to 'Userland/Libraries/LibWeb/Layout')
-rw-r--r-- | Userland/Libraries/LibWeb/Layout/ImageBox.cpp | 15 | ||||
-rw-r--r-- | Userland/Libraries/LibWeb/Layout/ImageProvider.h | 6 |
2 files changed, 9 insertions, 12 deletions
diff --git a/Userland/Libraries/LibWeb/Layout/ImageBox.cpp b/Userland/Libraries/LibWeb/Layout/ImageBox.cpp index 22770d00e6..5aa621f70b 100644 --- a/Userland/Libraries/LibWeb/Layout/ImageBox.cpp +++ b/Userland/Libraries/LibWeb/Layout/ImageBox.cpp @@ -23,18 +23,9 @@ ImageBox::~ImageBox() = default; void ImageBox::prepare_for_replaced_layout() { - auto bitmap = m_image_provider.current_image_bitmap(); - - if (!bitmap) { - set_intrinsic_width(0); - set_intrinsic_height(0); - } else { - auto width = bitmap->width(); - auto height = bitmap->height(); - set_intrinsic_width(width); - set_intrinsic_height(height); - set_intrinsic_aspect_ratio(static_cast<float>(width) / static_cast<float>(height)); - } + set_intrinsic_width(m_image_provider.intrinsic_width()); + set_intrinsic_height(m_image_provider.intrinsic_height()); + set_intrinsic_aspect_ratio(m_image_provider.intrinsic_aspect_ratio()); if (renders_as_alt_text()) { auto& image_element = verify_cast<HTML::HTMLImageElement>(dom_node()); diff --git a/Userland/Libraries/LibWeb/Layout/ImageProvider.h b/Userland/Libraries/LibWeb/Layout/ImageProvider.h index 39537295c2..1a45c3de8b 100644 --- a/Userland/Libraries/LibWeb/Layout/ImageProvider.h +++ b/Userland/Libraries/LibWeb/Layout/ImageProvider.h @@ -6,12 +6,18 @@ #pragma once +#include <LibWeb/PixelUnits.h> + namespace Web::Layout { class ImageProvider { public: virtual ~ImageProvider() { } + virtual Optional<CSSPixels> intrinsic_width() const = 0; + virtual Optional<CSSPixels> intrinsic_height() const = 0; + virtual Optional<float> intrinsic_aspect_ratio() const = 0; + virtual RefPtr<Gfx::Bitmap const> current_image_bitmap() const = 0; virtual void set_visible_in_viewport(bool) = 0; }; |