diff --git a/Userland/Libraries/LibWeb/HTML/AnimatedBitmapDecodedImageData.cpp b/Userland/Libraries/LibWeb/HTML/AnimatedBitmapDecodedImageData.cpp
index 06805f789c..5b5c24cb5d 100644
--- a/Userland/Libraries/LibWeb/HTML/AnimatedBitmapDecodedImageData.cpp
+++ b/Userland/Libraries/LibWeb/HTML/AnimatedBitmapDecodedImageData.cpp
@@ -23,7 +23,7 @@ AnimatedBitmapDecodedImageData::AnimatedBitmapDecodedImageData(Vector&& f
AnimatedBitmapDecodedImageData::~AnimatedBitmapDecodedImageData() = default;
-RefPtr AnimatedBitmapDecodedImageData::bitmap(size_t frame_index) const
+RefPtr AnimatedBitmapDecodedImageData::bitmap(size_t frame_index, Gfx::IntSize) const
{
if (frame_index >= m_frames.size())
return nullptr;
diff --git a/Userland/Libraries/LibWeb/HTML/AnimatedBitmapDecodedImageData.h b/Userland/Libraries/LibWeb/HTML/AnimatedBitmapDecodedImageData.h
index 0d24dbd36e..9f7ca8fc31 100644
--- a/Userland/Libraries/LibWeb/HTML/AnimatedBitmapDecodedImageData.h
+++ b/Userland/Libraries/LibWeb/HTML/AnimatedBitmapDecodedImageData.h
@@ -20,7 +20,7 @@ public:
static ErrorOr> create(Vector&&, size_t loop_count, bool animated);
virtual ~AnimatedBitmapDecodedImageData() override;
- virtual RefPtr bitmap(size_t frame_index) const override;
+ virtual RefPtr bitmap(size_t frame_index, Gfx::IntSize = {}) const override;
virtual int frame_duration(size_t frame_index) const override;
virtual size_t frame_count() const override { return m_frames.size(); }
diff --git a/Userland/Libraries/LibWeb/HTML/DecodedImageData.h b/Userland/Libraries/LibWeb/HTML/DecodedImageData.h
index 100722767a..f96b60342e 100644
--- a/Userland/Libraries/LibWeb/HTML/DecodedImageData.h
+++ b/Userland/Libraries/LibWeb/HTML/DecodedImageData.h
@@ -7,7 +7,7 @@
#pragma once
#include
-#include
+#include
#include
#include
@@ -18,7 +18,7 @@ class DecodedImageData : public RefCounted {
public:
virtual ~DecodedImageData();
- virtual RefPtr bitmap(size_t frame_index) const = 0;
+ virtual RefPtr bitmap(size_t frame_index, Gfx::IntSize = {}) const = 0;
virtual int frame_duration(size_t frame_index) const = 0;
virtual size_t frame_count() const = 0;
diff --git a/Userland/Libraries/LibWeb/HTML/HTMLImageElement.cpp b/Userland/Libraries/LibWeb/HTML/HTMLImageElement.cpp
index 3abb9a292a..56537cd7ed 100644
--- a/Userland/Libraries/LibWeb/HTML/HTMLImageElement.cpp
+++ b/Userland/Libraries/LibWeb/HTML/HTMLImageElement.cpp
@@ -132,10 +132,10 @@ Optional HTMLImageElement::intrinsic_aspect_ratio() const
return {};
}
-RefPtr HTMLImageElement::current_image_bitmap() const
+RefPtr HTMLImageElement::current_image_bitmap(Gfx::IntSize size) const
{
if (auto data = m_current_request->image_data())
- return data->bitmap(m_current_frame_index);
+ return data->bitmap(m_current_frame_index, size);
return nullptr;
}
diff --git a/Userland/Libraries/LibWeb/HTML/HTMLImageElement.h b/Userland/Libraries/LibWeb/HTML/HTMLImageElement.h
index abb5d1f77b..1086d4c598 100644
--- a/Userland/Libraries/LibWeb/HTML/HTMLImageElement.h
+++ b/Userland/Libraries/LibWeb/HTML/HTMLImageElement.h
@@ -81,7 +81,7 @@ public:
virtual Optional intrinsic_width() const override;
virtual Optional intrinsic_height() const override;
virtual Optional intrinsic_aspect_ratio() const override;
- virtual RefPtr current_image_bitmap() const override;
+ virtual RefPtr current_image_bitmap(Gfx::IntSize = {}) const override;
virtual void set_visible_in_viewport(bool) override;
private:
diff --git a/Userland/Libraries/LibWeb/HTML/HTMLObjectElement.cpp b/Userland/Libraries/LibWeb/HTML/HTMLObjectElement.cpp
index 4c25726b0d..edb4858dd4 100644
--- a/Userland/Libraries/LibWeb/HTML/HTMLObjectElement.cpp
+++ b/Userland/Libraries/LibWeb/HTML/HTMLObjectElement.cpp
@@ -371,7 +371,7 @@ Optional HTMLObjectElement::intrinsic_aspect_ratio() const
return {};
}
-RefPtr HTMLObjectElement::current_image_bitmap() const
+RefPtr HTMLObjectElement::current_image_bitmap(Gfx::IntSize) const
{
if (m_image_loader.has_value())
return m_image_loader->bitmap(m_image_loader->current_frame_index());
diff --git a/Userland/Libraries/LibWeb/HTML/HTMLObjectElement.h b/Userland/Libraries/LibWeb/HTML/HTMLObjectElement.h
index d728f4cc72..15ab8074f1 100644
--- a/Userland/Libraries/LibWeb/HTML/HTMLObjectElement.h
+++ b/Userland/Libraries/LibWeb/HTML/HTMLObjectElement.h
@@ -73,7 +73,7 @@ private:
virtual Optional intrinsic_width() const override;
virtual Optional intrinsic_height() const override;
virtual Optional intrinsic_aspect_ratio() const override;
- virtual RefPtr current_image_bitmap() const override;
+ virtual RefPtr current_image_bitmap(Gfx::IntSize = {}) const override;
virtual void set_visible_in_viewport(bool) override;
Representation m_representation { Representation::Unknown };
diff --git a/Userland/Libraries/LibWeb/Layout/ImageProvider.h b/Userland/Libraries/LibWeb/Layout/ImageProvider.h
index 1a45c3de8b..8d1455d698 100644
--- a/Userland/Libraries/LibWeb/Layout/ImageProvider.h
+++ b/Userland/Libraries/LibWeb/Layout/ImageProvider.h
@@ -6,6 +6,7 @@
#pragma once
+#include
#include
namespace Web::Layout {
@@ -18,7 +19,7 @@ public:
virtual Optional intrinsic_height() const = 0;
virtual Optional intrinsic_aspect_ratio() const = 0;
- virtual RefPtr current_image_bitmap() const = 0;
+ virtual RefPtr current_image_bitmap(Gfx::IntSize) const = 0;
virtual void set_visible_in_viewport(bool) = 0;
};
diff --git a/Userland/Libraries/LibWeb/Painting/ImagePaintable.cpp b/Userland/Libraries/LibWeb/Painting/ImagePaintable.cpp
index 4c8ca279d0..7629c51961 100644
--- a/Userland/Libraries/LibWeb/Painting/ImagePaintable.cpp
+++ b/Userland/Libraries/LibWeb/Painting/ImagePaintable.cpp
@@ -52,6 +52,7 @@ void ImagePaintable::paint(PaintContext& context, PaintPhase phase) const
PaintableBox::paint(context, phase);
if (phase == PaintPhase::Foreground) {
+ auto image_rect = context.rounded_device_rect(absolute_rect());
if (layout_box().renders_as_alt_text()) {
auto& image_element = verify_cast(*dom_node());
auto enclosing_rect = context.enclosing_device_rect(absolute_rect()).to_type();
@@ -61,8 +62,7 @@ void ImagePaintable::paint(PaintContext& context, PaintPhase phase) const
if (alt.is_empty())
alt = image_element.src();
context.painter().draw_text(enclosing_rect, alt, Gfx::TextAlignment::Center, computed_values().color(), Gfx::TextElision::Right);
- } else if (auto bitmap = layout_box().image_provider().current_image_bitmap()) {
- auto image_rect = context.rounded_device_rect(absolute_rect());
+ } else if (auto bitmap = layout_box().image_provider().current_image_bitmap(image_rect.size().to_type())) {
ScopedCornerRadiusClip corner_clip { context, context.painter(), image_rect, normalized_border_radii_data(ShrinkRadiiForBorders::Yes) };
auto scaling_mode = to_gfx_scaling_mode(computed_values().image_rendering(), bitmap->rect(), image_rect.to_type());
context.painter().draw_scaled_bitmap(image_rect.to_type(), *bitmap, bitmap->rect(), 1.f, scaling_mode);
diff --git a/Userland/Libraries/LibWeb/SVG/SVGDecodedImageData.cpp b/Userland/Libraries/LibWeb/SVG/SVGDecodedImageData.cpp
index d6192cb9ef..bda9e99561 100644
--- a/Userland/Libraries/LibWeb/SVG/SVGDecodedImageData.cpp
+++ b/Userland/Libraries/LibWeb/SVG/SVGDecodedImageData.cpp
@@ -20,7 +20,7 @@ SVGDecodedImageData::SVGDecodedImageData()
SVGDecodedImageData::~SVGDecodedImageData() = default;
-RefPtr SVGDecodedImageData::bitmap(size_t) const
+RefPtr SVGDecodedImageData::bitmap(size_t, Gfx::IntSize) const
{
return nullptr;
}
diff --git a/Userland/Libraries/LibWeb/SVG/SVGDecodedImageData.h b/Userland/Libraries/LibWeb/SVG/SVGDecodedImageData.h
index f8a5b05809..1adc482684 100644
--- a/Userland/Libraries/LibWeb/SVG/SVGDecodedImageData.h
+++ b/Userland/Libraries/LibWeb/SVG/SVGDecodedImageData.h
@@ -15,7 +15,7 @@ public:
static ErrorOr> create(ByteBuffer encoded_svg);
virtual ~SVGDecodedImageData() override;
- virtual RefPtr bitmap(size_t frame_index) const override;
+ virtual RefPtr bitmap(size_t frame_index, Gfx::IntSize) const override;
virtual Optional intrinsic_width() const override;
virtual Optional intrinsic_height() const override;