mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 20:57:35 +00:00
LibWeb: Split RadialGradientStyleValue out of StyleValue.{h,cpp}
This commit is contained in:
parent
c8ffd82cb7
commit
0f04fa2e6e
7 changed files with 340 additions and 282 deletions
|
@ -668,85 +668,6 @@ enum class GradientRepeating {
|
|||
No
|
||||
};
|
||||
|
||||
class RadialGradientStyleValue final : public AbstractImageStyleValue {
|
||||
public:
|
||||
enum class EndingShape {
|
||||
Circle,
|
||||
Ellipse
|
||||
};
|
||||
|
||||
enum class Extent {
|
||||
ClosestCorner,
|
||||
ClosestSide,
|
||||
FarthestCorner,
|
||||
FarthestSide
|
||||
};
|
||||
|
||||
struct CircleSize {
|
||||
Length radius;
|
||||
bool operator==(CircleSize const&) const = default;
|
||||
};
|
||||
|
||||
struct EllipseSize {
|
||||
LengthPercentage radius_a;
|
||||
LengthPercentage radius_b;
|
||||
bool operator==(EllipseSize const&) const = default;
|
||||
};
|
||||
|
||||
using Size = Variant<Extent, CircleSize, EllipseSize>;
|
||||
|
||||
static ValueComparingNonnullRefPtr<RadialGradientStyleValue> create(EndingShape ending_shape, Size size, PositionValue position, Vector<LinearColorStopListElement> color_stop_list, GradientRepeating repeating)
|
||||
{
|
||||
VERIFY(color_stop_list.size() >= 2);
|
||||
return adopt_ref(*new RadialGradientStyleValue(ending_shape, size, position, move(color_stop_list), repeating));
|
||||
}
|
||||
|
||||
virtual ErrorOr<String> to_string() const override;
|
||||
|
||||
void paint(PaintContext&, DevicePixelRect const& dest_rect, CSS::ImageRendering) const override;
|
||||
|
||||
virtual bool equals(StyleValue const& other) const override;
|
||||
|
||||
Vector<LinearColorStopListElement> const& color_stop_list() const
|
||||
{
|
||||
return m_properties.color_stop_list;
|
||||
}
|
||||
|
||||
bool is_paintable() const override { return true; }
|
||||
|
||||
void resolve_for_size(Layout::Node const&, CSSPixelSize) const override;
|
||||
|
||||
Gfx::FloatSize resolve_size(Layout::Node const&, Gfx::FloatPoint, Gfx::FloatRect const&) const;
|
||||
|
||||
bool is_repeating() const { return m_properties.repeating == GradientRepeating::Yes; }
|
||||
|
||||
virtual ~RadialGradientStyleValue() override = default;
|
||||
|
||||
private:
|
||||
RadialGradientStyleValue(EndingShape ending_shape, Size size, PositionValue position, Vector<LinearColorStopListElement> color_stop_list, GradientRepeating repeating)
|
||||
: AbstractImageStyleValue(Type::RadialGradient)
|
||||
, m_properties { .ending_shape = ending_shape, .size = size, .position = position, .color_stop_list = move(color_stop_list), .repeating = repeating }
|
||||
{
|
||||
}
|
||||
|
||||
struct Properties {
|
||||
EndingShape ending_shape;
|
||||
Size size;
|
||||
PositionValue position;
|
||||
Vector<LinearColorStopListElement> color_stop_list;
|
||||
GradientRepeating repeating;
|
||||
bool operator==(Properties const&) const = default;
|
||||
} m_properties;
|
||||
|
||||
struct ResolvedData {
|
||||
Painting::RadialGradientData data;
|
||||
Gfx::FloatSize gradient_size;
|
||||
Gfx::FloatPoint center;
|
||||
};
|
||||
|
||||
mutable Optional<ResolvedData> m_resolved;
|
||||
};
|
||||
|
||||
class InheritStyleValue final : public StyleValueWithDefaultOperators<InheritStyleValue> {
|
||||
public:
|
||||
static ValueComparingNonnullRefPtr<InheritStyleValue> the()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue