1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 17:47:36 +00:00

LibWeb: Convert AbstractImageStyleValue to new pixel units

This commit is contained in:
Sam Atkins 2022-11-08 16:31:01 +00:00 committed by Linus Groh
parent 02cd853eee
commit 13b1952929
5 changed files with 53 additions and 53 deletions

View file

@ -1,7 +1,7 @@
/*
* Copyright (c) 2018-2020, Andreas Kling <kling@serenityos.org>
* Copyright (c) 2021, Tobias Christiansen <tobyase@serenityos.org>
* Copyright (c) 2021-2022, Sam Atkins <atkinssj@serenityos.org>
* Copyright (c) 2021-2023, Sam Atkins <atkinssj@serenityos.org>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
@ -130,7 +130,7 @@ struct PositionValue {
HorizontalEdge x_relative_to { HorizontalEdge::Left };
VerticalEdge y_relative_to { VerticalEdge::Top };
Gfx::FloatPoint resolved(Layout::Node const&, Gfx::FloatRect const&) const;
CSSPixelPoint resolved(Layout::Node const& node, CSSPixelRect const& rect) const;
void serialize(StringBuilder&) const;
bool operator==(PositionValue const&) const;
};
@ -1153,14 +1153,14 @@ class AbstractImageStyleValue : public StyleValue {
public:
using StyleValue::StyleValue;
virtual Optional<int> natural_width() const { return {}; }
virtual Optional<int> natural_height() const { return {}; }
virtual Optional<CSSPixels> natural_width() const { return {}; }
virtual Optional<CSSPixels> natural_height() const { return {}; }
virtual void load_any_resources(DOM::Document&) {};
virtual void resolve_for_size(Layout::Node const&, Gfx::FloatSize) const {};
virtual void resolve_for_size(Layout::Node const&, CSSPixelSize) const {};
virtual bool is_paintable() const = 0;
virtual void paint(PaintContext& context, Gfx::IntRect const& dest_rect, CSS::ImageRendering image_rendering) const = 0;
virtual void paint(PaintContext& context, DevicePixelRect const& dest_rect, CSS::ImageRendering image_rendering) const = 0;
};
class ImageStyleValue final
@ -1175,11 +1175,11 @@ public:
virtual void load_any_resources(DOM::Document&) override;
Optional<int> natural_width() const override;
Optional<int> natural_height() const override;
Optional<CSSPixels> natural_width() const override;
Optional<CSSPixels> natural_height() const override;
bool is_paintable() const override { return bitmap(0) != nullptr; }
void paint(PaintContext& context, Gfx::IntRect const& dest_rect, CSS::ImageRendering image_rendering) const override;
void paint(PaintContext& context, DevicePixelRect const& dest_rect, CSS::ImageRendering image_rendering) const override;
Function<void()> on_animate;
@ -1240,7 +1240,7 @@ public:
virtual DeprecatedString to_deprecated_string() const override;
void paint(PaintContext&, Gfx::IntRect const& dest_rect, CSS::ImageRendering) const override;
void paint(PaintContext&, DevicePixelRect const& dest_rect, CSS::ImageRendering) const override;
virtual bool equals(StyleValue const& other) const override;
@ -1251,7 +1251,7 @@ public:
bool is_paintable() const override { return true; }
void resolve_for_size(Layout::Node const&, Gfx::FloatSize) const override;
void resolve_for_size(Layout::Node const&, CSSPixelSize) const override;
Gfx::FloatSize resolve_size(Layout::Node const&, Gfx::FloatPoint, Gfx::FloatRect const&) const;
@ -1295,7 +1295,7 @@ public:
virtual DeprecatedString to_deprecated_string() const override;
void paint(PaintContext&, Gfx::IntRect const& dest_rect, CSS::ImageRendering) const override;
void paint(PaintContext&, DevicePixelRect const& dest_rect, CSS::ImageRendering) const override;
virtual bool equals(StyleValue const& other) const override;
@ -1308,11 +1308,11 @@ public:
bool is_paintable() const override { return true; }
void resolve_for_size(Layout::Node const&, Gfx::FloatSize) const override;
void resolve_for_size(Layout::Node const&, CSSPixelSize) const override;
virtual ~ConicGradientStyleValue() override = default;
Gfx::FloatPoint resolve_position(Layout::Node const&, Gfx::FloatRect const&) const;
CSSPixelPoint resolve_position(Layout::Node const&, CSSPixelRect const&) const;
bool is_repeating() const { return m_repeating == GradientRepeating::Yes; }
@ -1334,7 +1334,7 @@ private:
struct ResolvedData {
Painting::ConicGradientData data;
Gfx::FloatPoint position;
CSSPixelPoint position;
};
mutable Optional<ResolvedData> m_resolved;
@ -1366,12 +1366,12 @@ public:
bool is_repeating() const { return m_repeating == GradientRepeating::Yes; }
float angle_degrees(Gfx::FloatSize gradient_size) const;
float angle_degrees(CSSPixelSize gradient_size) const;
void resolve_for_size(Layout::Node const&, Gfx::FloatSize) const override;
void resolve_for_size(Layout::Node const&, CSSPixelSize) const override;
bool is_paintable() const override { return true; }
void paint(PaintContext& context, Gfx::IntRect const& dest_rect, CSS::ImageRendering image_rendering) const override;
void paint(PaintContext& context, DevicePixelRect const& dest_rect, CSS::ImageRendering image_rendering) const override;
private:
LinearGradientStyleValue(GradientDirection direction, Vector<LinearColorStopListElement> color_stop_list, GradientType type, GradientRepeating repeating)
@ -1390,7 +1390,7 @@ private:
struct ResolvedData {
Painting::LinearGradientData data;
Gfx::FloatSize size;
CSSPixelSize size;
};
mutable Optional<ResolvedData> m_resolved;