LibWeb: Support relative lengths in stop-color calcs

This commit is contained in:
Callum Law 2025-07-19 16:00:37 +12:00 committed by Sam Atkins
commit 3b52b1139a
Notes: github-actions[bot] 2025-08-04 10:30:24 +00:00
7 changed files with 32 additions and 25 deletions

View file

@ -1813,24 +1813,6 @@ MaskType ComputedProperties::mask_type() const
return keyword_to_mask_type(value.to_keyword()).release_value();
}
Color ComputedProperties::stop_color() const
{
NonnullRawPtr<CSSStyleValue const> value = property(PropertyID::StopColor);
if (value->is_keyword()) {
// Workaround lack of layout node to resolve current color.
auto const& keyword = value->as_keyword();
if (keyword.keyword() == Keyword::Currentcolor)
value = property(PropertyID::Color);
}
if (value->has_color()) {
// FIXME: This is used by the SVGStopElement, which does not participate in layout, so we can't pass a layout
// node or CalculationResolutionContext. This means we don't support all valid colors (e.g. palette
// colors, calculated values which depend on length resolution, etc)
return value->to_color({}).value_or(Color::Black);
}
return Color::Black;
}
void ComputedProperties::set_math_depth(int math_depth)
{
m_math_depth = math_depth;