mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 02:27:43 +00:00
LibWeb: Support -webkit-linear-gradient()
correctly
The -webkit version of linear-gradient does not include the `to` before a <side or corner>. The angles of the <side or corner> for the webkit version are also opposite that of the standard one. So for the standard: linear-gradient(to left, red, blue) The webkit version is: -webkit-linear-gradient(right, red, blue) Adding the `to` in the -webkit version is invalid, omitting it in the standard one is also invalid.
This commit is contained in:
parent
834d936bbc
commit
ca2e345cdc
3 changed files with 82 additions and 46 deletions
|
@ -933,10 +933,15 @@ class LinearGradientStyleValue final : public StyleValue {
|
|||
public:
|
||||
using GradientDirection = Variant<Angle, SideOrCorner>;
|
||||
|
||||
static NonnullRefPtr<LinearGradientStyleValue> create(GradientDirection direction, Vector<ColorStopListElement> color_stop_list)
|
||||
enum class GradientType {
|
||||
Standard,
|
||||
WebKit
|
||||
};
|
||||
|
||||
static NonnullRefPtr<LinearGradientStyleValue> create(GradientDirection direction, Vector<ColorStopListElement> color_stop_list, GradientType type)
|
||||
{
|
||||
VERIFY(color_stop_list.size() >= 2);
|
||||
return adopt_ref(*new LinearGradientStyleValue(direction, move(color_stop_list)));
|
||||
return adopt_ref(*new LinearGradientStyleValue(direction, move(color_stop_list), type));
|
||||
}
|
||||
|
||||
virtual String to_string() const override;
|
||||
|
@ -951,15 +956,17 @@ public:
|
|||
float angle_degrees(Gfx::FloatRect const& gradient_rect) const;
|
||||
|
||||
private:
|
||||
LinearGradientStyleValue(GradientDirection direction, Vector<ColorStopListElement> color_stop_list)
|
||||
LinearGradientStyleValue(GradientDirection direction, Vector<ColorStopListElement> color_stop_list, GradientType type)
|
||||
: StyleValue(Type::LinearGradient)
|
||||
, m_direction(direction)
|
||||
, m_color_stop_list(move(color_stop_list))
|
||||
, m_gradient_type(type)
|
||||
{
|
||||
}
|
||||
|
||||
GradientDirection m_direction;
|
||||
Vector<ColorStopListElement> m_color_stop_list;
|
||||
GradientType m_gradient_type;
|
||||
};
|
||||
|
||||
class InheritStyleValue final : public StyleValue {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue