1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 10:37:45 +00:00

LibWeb: Add BoxShadowStyleType as a CSS StyleType

This new StyleType stores values related to box-shadows, since they
consist of multiple parts that isn't just a shorthand for other
properties.
This commit is contained in:
Tobias Christiansen 2021-07-23 21:17:09 +02:00 committed by Andreas Kling
parent 2002b7e2e3
commit 2fdae3b0ca

View file

@ -228,6 +228,7 @@ public:
Numeric,
ValueList,
Calculated,
BoxShadow,
};
Type type() const { return m_type; }
@ -251,6 +252,7 @@ public:
{
return is_inherit() || is_initial() || is_custom_property();
}
bool is_box_shadow() const { return type() == Type::BoxShadow; }
bool is_calculated() const
{
@ -342,6 +344,38 @@ private:
String m_string;
};
class BoxShadowStyleValue : public StyleValue {
public:
static NonnullRefPtr<BoxShadowStyleValue> create(Length const& offset_x, Length const& offset_y, Length const& blur_radius, Color const& color)
{
return adopt_ref(*new BoxShadowStyleValue(offset_x, offset_y, blur_radius, color));
}
virtual ~BoxShadowStyleValue() override { }
Length const& offset_x() const { return m_offset_x; }
Length const& offset_y() const { return m_offset_y; }
Length const& blur_radius() const { return m_blur_radius; }
Color const& color() const { return m_color; }
String to_string() const override { return String::formatted("BoxShadow offset_x: {}, offset_y: {}, blur_radius: {}, color: {}",
m_offset_x.to_string(), m_offset_y.to_string(), m_blur_radius.to_string(), m_color.to_string()); }
private:
explicit BoxShadowStyleValue(Length const& offset_x, Length const& offset_y, Length const& blur_radius, Color const& color)
: StyleValue(Type::BoxShadow)
, m_offset_x(offset_x)
, m_offset_y(offset_y)
, m_blur_radius(blur_radius)
, m_color(color)
{
}
Length m_offset_x;
Length m_offset_y;
Length m_blur_radius;
Color m_color;
};
class LengthStyleValue : public StyleValue {
public:
static NonnullRefPtr<LengthStyleValue> create(const Length& length)