LibWeb: Add stroke-linecap attribute and plumb it to SVGGraphicsElement

SVGGraphicsElement then goes ahead and does nothing with it for now.
This commit is contained in:
Nico Weber 2024-10-10 10:15:49 -04:00 committed by Tim Ledbetter
commit cc0cfd044b
Notes: github-actions[bot] 2024-10-10 23:28:42 +00:00
11 changed files with 41 additions and 1 deletions

View file

@ -144,6 +144,7 @@ public:
static float fill_opacity() { return 1.0f; }
static CSS::FillRule fill_rule() { return CSS::FillRule::Nonzero; }
static CSS::ClipRule clip_rule() { return CSS::ClipRule::Nonzero; }
static CSS::StrokeLinecap stroke_linecap() { return CSS::StrokeLinecap::Butt; }
static float stroke_opacity() { return 1.0f; }
static float stop_opacity() { return 1.0f; }
static CSS::TextAnchor text_anchor() { return CSS::TextAnchor::Start; }
@ -464,6 +465,7 @@ public:
CSS::FillRule fill_rule() const { return m_inherited.fill_rule; }
Optional<SVGPaint> const& stroke() const { return m_inherited.stroke; }
float fill_opacity() const { return m_inherited.fill_opacity; }
CSS::StrokeLinecap stroke_linecap() const { return m_inherited.stroke_linecap; }
float stroke_opacity() const { return m_inherited.stroke_opacity; }
LengthPercentage const& stroke_width() const { return m_inherited.stroke_width; }
Color stop_color() const { return m_noninherited.stop_color; }
@ -555,6 +557,7 @@ protected:
CSS::FillRule fill_rule { InitialValues::fill_rule() };
Optional<SVGPaint> stroke;
float fill_opacity { InitialValues::fill_opacity() };
CSS::StrokeLinecap stroke_linecap { InitialValues::stroke_linecap() };
float stroke_opacity { InitialValues::stroke_opacity() };
LengthPercentage stroke_width { Length::make_px(1) };
CSS::TextAnchor text_anchor { InitialValues::text_anchor() };
@ -791,6 +794,7 @@ public:
void set_stroke(SVGPaint value) { m_inherited.stroke = value; }
void set_fill_rule(CSS::FillRule value) { m_inherited.fill_rule = value; }
void set_fill_opacity(float value) { m_inherited.fill_opacity = value; }
void set_stroke_linecap(CSS::StrokeLinecap value) { m_inherited.stroke_linecap = value; }
void set_stroke_opacity(float value) { m_inherited.stroke_opacity = value; }
void set_stroke_width(LengthPercentage value) { m_inherited.stroke_width = value; }
void set_stop_color(Color value) { m_noninherited.stop_color = value; }

View file

@ -417,6 +417,11 @@
"thin",
"none"
],
"stroke-linecap": [
"butt",
"square",
"round"
],
"text-align": [
"center",
"justify",

View file

@ -90,6 +90,7 @@
"bottom",
"break-word",
"browser",
"butt",
"button",
"buttonborder",
"buttonface",

View file

@ -2418,6 +2418,15 @@
"paint"
]
},
"stroke-linecap": {
"affects-layout": false,
"animation-type": "discrete",
"inherited": true,
"initial": "butt",
"valid-types": [
"stroke-linecap"
]
},
"stroke-opacity": {
"affects-layout": false,
"animation-type": "by-computed-value",

View file

@ -326,6 +326,12 @@ float StyleProperties::fill_opacity() const
return resolve_opacity_value(*value);
}
Optional<CSS::StrokeLinecap> StyleProperties::stroke_linecap() const
{
auto value = property(CSS::PropertyID::StrokeLinecap);
return keyword_to_stroke_linecap(value->to_keyword());
}
float StyleProperties::stroke_opacity() const
{
auto value = property(CSS::PropertyID::StrokeOpacity);

View file

@ -177,6 +177,7 @@ public:
Color stop_color() const;
float stop_opacity() const;
float fill_opacity() const;
Optional<CSS::StrokeLinecap> stroke_linecap() const;
float stroke_opacity() const;
Optional<CSS::FillRule> fill_rule() const;
Optional<CSS::ClipRule> clip_rule() const;