LibWeb/SVG: Add FEFloodElement

This commit is contained in:
Lucien Fiorini 2025-07-06 21:48:55 +02:00 committed by Sam Atkins
commit d3684a36b0
Notes: github-actions[bot] 2025-07-09 17:08:44 +00:00
22 changed files with 189 additions and 18 deletions

View file

@ -443,6 +443,22 @@ ClipRule ComputedProperties::clip_rule() const
return keyword_to_fill_rule(value.to_keyword()).release_value();
}
Color ComputedProperties::flood_color(Layout::NodeWithStyle const& node) const
{
auto const& value = property(PropertyID::FloodColor);
if (value.has_color()) {
return value.to_color(node, { .length_resolution_context = Length::ResolutionContext::for_layout_node(node) });
}
return InitialValues::flood_color();
}
float ComputedProperties::flood_opacity() const
{
auto const& value = property(PropertyID::FloodOpacity);
return resolve_opacity_value(value);
}
FlexDirection ComputedProperties::flex_direction() const
{
auto const& value = property(PropertyID::FlexDirection);

View file

@ -194,6 +194,8 @@ public:
float stroke_opacity() const;
FillRule fill_rule() const;
ClipRule clip_rule() const;
Color flood_color(Layout::NodeWithStyle const&) const;
float flood_opacity() const;
Gfx::FontCascadeList const& computed_font_list() const
{

View file

@ -152,6 +152,8 @@ 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 Color flood_color() { return Color::Black; }
static float flood_opacity() { return 1.0f; }
static CSS::LengthPercentage stroke_dashoffset() { return CSS::Length::make_px(0); }
static CSS::StrokeLinecap stroke_linecap() { return CSS::StrokeLinecap::Butt; }
static CSS::StrokeLinejoin stroke_linejoin() { return CSS::StrokeLinejoin::Miter; }
@ -554,6 +556,8 @@ public:
CSS::MaskType mask_type() const { return m_noninherited.mask_type; }
Optional<ClipPathReference> const& clip_path() const { return m_noninherited.clip_path; }
CSS::ClipRule clip_rule() const { return m_inherited.clip_rule; }
Color flood_color() const { return m_noninherited.flood_color; }
float flood_opacity() const { return m_noninherited.flood_opacity; }
LengthPercentage const& cx() const { return m_noninherited.cx; }
LengthPercentage const& cy() const { return m_noninherited.cy; }
@ -796,6 +800,9 @@ protected:
Vector<CounterData, 0> counter_increment;
Vector<CounterData, 0> counter_reset;
Vector<CounterData, 0> counter_set;
Color flood_color { InitialValues::flood_color() };
float flood_opacity { InitialValues::flood_opacity() };
} m_noninherited;
};
@ -982,6 +989,8 @@ public:
void set_mask_image(CSS::AbstractImageStyleValue const& value) { m_noninherited.mask_image = value; }
void set_clip_path(ClipPathReference value) { m_noninherited.clip_path = move(value); }
void set_clip_rule(CSS::ClipRule value) { m_inherited.clip_rule = value; }
void set_flood_color(Color value) { m_noninherited.flood_color = value; }
void set_flood_opacity(float value) { m_noninherited.flood_opacity = value; }
void set_cx(LengthPercentage cx) { m_noninherited.cx = move(cx); }
void set_cy(LengthPercentage cy) { m_noninherited.cy = move(cy); }

View file

@ -1537,6 +1537,24 @@
"float"
]
},
"flood-color": {
"affects-layout": false,
"animation-type": "by-computed-value",
"inherited": false,
"initial": "black",
"valid-types": [
"color"
]
},
"flood-opacity": {
"affects-layout": false,
"animation-type": "by-computed-value",
"inherited": false,
"initial": "1",
"valid-types": [
"number [0,1]"
]
},
"font": {
"inherited": true,
"initial": "normal medium serif",