LibWeb: Remove index based frame getters for ImageStyleValue

`ImageStyleValueResource::frame` was unused and `ImageStyleValue::frame`
was only ever used to get the current frame so it can just be inlined.
This commit is contained in:
Callum Law 2026-06-17 23:49:11 +12:00 committed by Alexander Kalenik
parent 3852b3f5a8
commit 27381e9b00
2 changed files with 6 additions and 25 deletions

View file

@ -74,13 +74,6 @@ GC::Ptr<HTML::DecodedImageData> ImageStyleValueResource::decoded_image_data() co
return m_resource_request->image_data();
}
Optional<Gfx::DecodedImageFrame> ImageStyleValueResource::frame(size_t frame_index, Gfx::IntSize size) const
{
if (auto image_data = this->decoded_image_data())
return image_data->frame(frame_index, size);
return {};
}
bool ImageStyleValueResource::has_active_animation_timer() const
{
return m_timer && m_timer->is_active();
@ -270,7 +263,10 @@ void ImageStyleValue::paint(DisplayListRecordingContext& context, DOM::Document
Optional<Gfx::DecodedImageFrame> ImageStyleValue::current_frame(DOM::Document const& document, DevicePixelRect const& dest_rect) const
{
return frame(document, current_frame_index(document), dest_rect.size().to_type<int>());
if (auto image_data = this->image_data(document))
return image_data->frame(current_frame_index(document), dest_rect.size().to_type<int>());
return {};
}
size_t ImageStyleValue::current_frame_index(DOM::Document const& document) const
@ -301,7 +297,7 @@ GC::Ptr<HTML::DecodedImageData> ImageStyleValue::image_data(DOM::Document const&
Optional<Gfx::Color> ImageStyleValue::color_if_single_pixel_bitmap(DOM::Document const& document) const
{
if (auto decoded_frame = frame(document, current_frame_index(document)); decoded_frame.has_value()) {
if (auto decoded_frame = current_frame(document); decoded_frame.has_value()) {
auto const& bitmap = decoded_frame->bitmap();
if (bitmap.width() == 1 && bitmap.height() == 1)
return bitmap.get_pixel(0, 0);
@ -449,19 +445,6 @@ Optional<::URL::URL> ImageStyleValue::resolved_url(DOM::Document const& document
});
}
Optional<Gfx::DecodedImageFrame> ImageStyleValue::frame(DOM::Document const& document, size_t frame_index, Gfx::IntSize size) const
{
auto resolved_url = this->resolved_url(document);
if (resolved_url.has_value()) {
if (auto const* resource = document.css_image_resource(*resolved_url))
return resource->frame(frame_index, size);
}
if (auto image_data = this->image_data(document))
return image_data->frame(frame_index, size);
return {};
}
ImageStyleValue::Client::Client(DOM::Document& document, ImageStyleValue const& image_style_value)
: m_image_style_value(image_style_value)
, m_document(document)

View file

@ -37,7 +37,6 @@ public:
bool can_be_removed() const { return m_image_style_values.is_empty(); }
[[nodiscard]] virtual GC::Ptr<HTML::DecodedImageData> decoded_image_data() const override;
[[nodiscard]] Optional<Gfx::DecodedImageFrame> frame(size_t frame_index, Gfx::IntSize = {}) const;
[[nodiscard]] size_t current_frame_index() const { return m_current_frame_index; }
[[nodiscard]] bool has_active_animation_timer() const;
@ -106,7 +105,7 @@ public:
void paint(DisplayListRecordingContext& context, DOM::Document const&, DevicePixelRect const& dest_rect, CSS::ImageRendering image_rendering) const override;
virtual Optional<Gfx::Color> color_if_single_pixel_bitmap(DOM::Document const&) const override;
Optional<Gfx::DecodedImageFrame> current_frame(DOM::Document const&, DevicePixelRect const& dest_rect) const;
Optional<Gfx::DecodedImageFrame> current_frame(DOM::Document const&, DevicePixelRect const& dest_rect = {}) const;
size_t current_frame_index(DOM::Document const&) const;
GC::Ptr<HTML::DecodedImageData> image_data(DOM::Document const&) const;
@ -128,7 +127,6 @@ private:
virtual void set_style_sheet(GC::Ptr<CSSStyleSheet>) override;
virtual ValueComparingNonnullRefPtr<StyleValue const> absolutized(ComputationContext const&) const override;
Optional<Gfx::DecodedImageFrame> frame(DOM::Document const&, size_t frame_index, Gfx::IntSize = {}) const;
URL m_url;
Optional<::URL::URL> m_style_resource_base_url;