|
@@ -58,6 +58,31 @@ enum class FlexBasis {
|
|
Auto,
|
|
Auto,
|
|
};
|
|
};
|
|
|
|
|
|
|
|
+enum class SideOrCorner {
|
|
|
|
+ Top,
|
|
|
|
+ Bottom,
|
|
|
|
+ Left,
|
|
|
|
+ Right,
|
|
|
|
+ TopLeft,
|
|
|
|
+ TopRight,
|
|
|
|
+ BottomLeft,
|
|
|
|
+ BottomRight
|
|
|
|
+};
|
|
|
|
+
|
|
|
|
+struct GradientColorStop {
|
|
|
|
+ Color color;
|
|
|
|
+ Optional<LengthPercentage> length;
|
|
|
|
+};
|
|
|
|
+
|
|
|
|
+struct GradientColorHint {
|
|
|
|
+ LengthPercentage value;
|
|
|
|
+};
|
|
|
|
+
|
|
|
|
+struct ColorStopListElement {
|
|
|
|
+ Optional<GradientColorHint> transition_hint;
|
|
|
|
+ GradientColorStop color_stop;
|
|
|
|
+};
|
|
|
|
+
|
|
// FIXME: Find a better place for this helper.
|
|
// FIXME: Find a better place for this helper.
|
|
inline Gfx::Painter::ScalingMode to_gfx_scaling_mode(CSS::ImageRendering css_value)
|
|
inline Gfx::Painter::ScalingMode to_gfx_scaling_mode(CSS::ImageRendering css_value)
|
|
{
|
|
{
|
|
@@ -99,6 +124,7 @@ public:
|
|
Initial,
|
|
Initial,
|
|
Invalid,
|
|
Invalid,
|
|
Length,
|
|
Length,
|
|
|
|
+ LinearGradient,
|
|
ListStyle,
|
|
ListStyle,
|
|
Numeric,
|
|
Numeric,
|
|
Overflow,
|
|
Overflow,
|
|
@@ -112,7 +138,7 @@ public:
|
|
Transformation,
|
|
Transformation,
|
|
Unresolved,
|
|
Unresolved,
|
|
Unset,
|
|
Unset,
|
|
- ValueList,
|
|
|
|
|
|
+ ValueList
|
|
};
|
|
};
|
|
|
|
|
|
Type type() const { return m_type; }
|
|
Type type() const { return m_type; }
|
|
@@ -136,6 +162,7 @@ public:
|
|
bool is_inherit() const { return type() == Type::Inherit; }
|
|
bool is_inherit() const { return type() == Type::Inherit; }
|
|
bool is_initial() const { return type() == Type::Initial; }
|
|
bool is_initial() const { return type() == Type::Initial; }
|
|
bool is_length() const { return type() == Type::Length; }
|
|
bool is_length() const { return type() == Type::Length; }
|
|
|
|
+ bool is_linear_gradient() const { return type() == Type::LinearGradient; }
|
|
bool is_list_style() const { return type() == Type::ListStyle; }
|
|
bool is_list_style() const { return type() == Type::ListStyle; }
|
|
bool is_numeric() const { return type() == Type::Numeric; }
|
|
bool is_numeric() const { return type() == Type::Numeric; }
|
|
bool is_overflow() const { return type() == Type::Overflow; }
|
|
bool is_overflow() const { return type() == Type::Overflow; }
|
|
@@ -172,6 +199,7 @@ public:
|
|
InheritStyleValue const& as_inherit() const;
|
|
InheritStyleValue const& as_inherit() const;
|
|
InitialStyleValue const& as_initial() const;
|
|
InitialStyleValue const& as_initial() const;
|
|
LengthStyleValue const& as_length() const;
|
|
LengthStyleValue const& as_length() const;
|
|
|
|
+ LinearGradientStyleValue const& as_linear_gradient() const;
|
|
ListStyleStyleValue const& as_list_style() const;
|
|
ListStyleStyleValue const& as_list_style() const;
|
|
NumericStyleValue const& as_numeric() const;
|
|
NumericStyleValue const& as_numeric() const;
|
|
OverflowStyleValue const& as_overflow() const;
|
|
OverflowStyleValue const& as_overflow() const;
|
|
@@ -206,6 +234,7 @@ public:
|
|
InheritStyleValue& as_inherit() { return const_cast<InheritStyleValue&>(const_cast<StyleValue const&>(*this).as_inherit()); }
|
|
InheritStyleValue& as_inherit() { return const_cast<InheritStyleValue&>(const_cast<StyleValue const&>(*this).as_inherit()); }
|
|
InitialStyleValue& as_initial() { return const_cast<InitialStyleValue&>(const_cast<StyleValue const&>(*this).as_initial()); }
|
|
InitialStyleValue& as_initial() { return const_cast<InitialStyleValue&>(const_cast<StyleValue const&>(*this).as_initial()); }
|
|
LengthStyleValue& as_length() { return const_cast<LengthStyleValue&>(const_cast<StyleValue const&>(*this).as_length()); }
|
|
LengthStyleValue& as_length() { return const_cast<LengthStyleValue&>(const_cast<StyleValue const&>(*this).as_length()); }
|
|
|
|
+ LinearGradientStyleValue& as_linear_gradient() { return const_cast<LinearGradientStyleValue&>(const_cast<StyleValue const&>(*this).as_linear_gradient()); }
|
|
ListStyleStyleValue& as_list_style() { return const_cast<ListStyleStyleValue&>(const_cast<StyleValue const&>(*this).as_list_style()); }
|
|
ListStyleStyleValue& as_list_style() { return const_cast<ListStyleStyleValue&>(const_cast<StyleValue const&>(*this).as_list_style()); }
|
|
NumericStyleValue& as_numeric() { return const_cast<NumericStyleValue&>(const_cast<StyleValue const&>(*this).as_numeric()); }
|
|
NumericStyleValue& as_numeric() { return const_cast<NumericStyleValue&>(const_cast<StyleValue const&>(*this).as_numeric()); }
|
|
OverflowStyleValue& as_overflow() { return const_cast<OverflowStyleValue&>(const_cast<StyleValue const&>(*this).as_overflow()); }
|
|
OverflowStyleValue& as_overflow() { return const_cast<OverflowStyleValue&>(const_cast<StyleValue const&>(*this).as_overflow()); }
|
|
@@ -887,6 +916,39 @@ private:
|
|
RefPtr<Gfx::Bitmap> m_bitmap;
|
|
RefPtr<Gfx::Bitmap> m_bitmap;
|
|
};
|
|
};
|
|
|
|
|
|
|
|
+class LinearGradientStyleValue final : public StyleValue {
|
|
|
|
+public:
|
|
|
|
+ using GradientDirection = Variant<Angle, SideOrCorner>;
|
|
|
|
+
|
|
|
|
+ static NonnullRefPtr<LinearGradientStyleValue> create(GradientDirection direction, Vector<ColorStopListElement> color_stop_list)
|
|
|
|
+ {
|
|
|
|
+ VERIFY(color_stop_list.size() >= 2);
|
|
|
|
+ return adopt_ref(*new LinearGradientStyleValue(direction, move(color_stop_list)));
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ virtual String to_string() const override;
|
|
|
|
+ virtual ~LinearGradientStyleValue() override = default;
|
|
|
|
+ virtual bool equals(StyleValue const& other) const override;
|
|
|
|
+
|
|
|
|
+ Vector<ColorStopListElement> const& color_stop_list() const
|
|
|
|
+ {
|
|
|
|
+ return m_color_stop_list;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ float angle(Gfx::FloatRect const& background_box) const;
|
|
|
|
+
|
|
|
|
+private:
|
|
|
|
+ LinearGradientStyleValue(GradientDirection direction, Vector<ColorStopListElement> color_stop_list)
|
|
|
|
+ : StyleValue(Type::LinearGradient)
|
|
|
|
+ , m_direction(direction)
|
|
|
|
+ , m_color_stop_list(move(color_stop_list))
|
|
|
|
+ {
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ GradientDirection m_direction;
|
|
|
|
+ Vector<ColorStopListElement> m_color_stop_list;
|
|
|
|
+};
|
|
|
|
+
|
|
class InheritStyleValue final : public StyleValue {
|
|
class InheritStyleValue final : public StyleValue {
|
|
public:
|
|
public:
|
|
static NonnullRefPtr<InheritStyleValue> the()
|
|
static NonnullRefPtr<InheritStyleValue> the()
|