Skip to content

Truly independent web browser

LibWeb: Resolve currentcolor in SVG stop and flood colors

Andreas Klingeb090d530a2b
diff --git a/Libraries/LibWeb/CSS/CSSStyleProperties.cpp b/Libraries/LibWeb/CSS/CSSStyleProperties.cpp
index 232dbf2cdb6..db9739b30cc 100644
--- a/Libraries/LibWeb/CSS/CSSStyleProperties.cpp
+++ b/Libraries/LibWeb/CSS/CSSStyleProperties.cpp
@@ -663,7 +663,7 @@ static void ensure_pseudo_element_style_for_cssom(Layout::BegunRead const& read,
}
static RefPtr<StyleValue const> resolve_color_style_value(StyleValue const&, Color, Optional<ColorResolutionStyle> = {});
-static NonnullRefPtr<StyleValue const> resolve_svg_paint_style_value(StyleValue const&, ColorResolutionStyle);
+static NonnullRefPtr<StyleValue const> resolve_svg_color_style_value(StyleValue const&, ColorResolutionStyle);
static bool is_min_or_max_size_property(PropertyID property_id)
{
@@ -906,8 +906,10 @@ Optional<StyleProperty> CSSStyleProperties::get_direct_property(PropertyNameAndI
case PropertyID::Color:
return resolve_color_style_value(*computed_value, computed_values->color(), ColorResolutionStyle::for_computed_values(*computed_values)).release_nonnull();
case PropertyID::Fill:
+ case PropertyID::FloodColor:
+ case PropertyID::StopColor:
case PropertyID::Stroke:
- return resolve_svg_paint_style_value(*computed_value, ColorResolutionStyle::for_computed_values(*computed_values));
+ return resolve_svg_color_style_value(*computed_value, ColorResolutionStyle::for_computed_values(*computed_values));
case PropertyID::CaretColor:
return resolve_color_style_value(*computed_value, computed_values->caret_color()).release_nonnull();
case PropertyID::BackgroundColor:
@@ -1119,7 +1121,7 @@ static RefPtr<StyleValue const> resolve_color_style_value(StyleValue const& styl
// https://drafts.csswg.org/css-color-4/#resolving-color-values
// The resolved value of a <color> is its used value.
-static NonnullRefPtr<StyleValue const> resolve_svg_paint_style_value(StyleValue const& style_value, ColorResolutionStyle color_resolution_style)
+static NonnullRefPtr<StyleValue const> resolve_svg_color_style_value(StyleValue const& style_value, ColorResolutionStyle color_resolution_style)
{
if (!style_value.depends_on_current_color())
return style_value;
@@ -1128,7 +1130,7 @@ static NonnullRefPtr<StyleValue const> resolve_svg_paint_style_value(StyleValue
auto const& list = style_value.as_value_list();
auto values = list.values();
for (auto& value : values)
- value = resolve_svg_paint_style_value(*value, color_resolution_style);
+ value = resolve_svg_color_style_value(*value, color_resolution_style);
return StyleValueList::create(move(values), list.separator());
}
@@ -1298,8 +1300,10 @@ RefPtr<StyleValue const> CSSStyleProperties::style_value_for_computed_property(L
return resolve_color_style_value(*get_computed_value(property_id), style->color(), ColorResolutionStyle::for_element(*owner_node()));
}
case PropertyID::Fill:
+ case PropertyID::FloodColor:
+ case PropertyID::StopColor:
case PropertyID::Stroke:
- return resolve_svg_paint_style_value(*get_computed_value(property_id), color_resolution_style);
+ return resolve_svg_color_style_value(*get_computed_value(property_id), color_resolution_style);
case PropertyID::ColumnRuleColor:
return resolve_color_style_value(*get_computed_value(property_id), layout_node.column_rule_color(), color_resolution_style);
case PropertyID::OutlineColor:
diff --git a/Tests/LibWeb/Text/expected/svg-reset-color-inheritance.txt b/Tests/LibWeb/Text/expected/svg-reset-color-inheritance.txt
index 7a741cced50..ef5ccebb8a3 100644
--- a/Tests/LibWeb/Text/expected/svg-reset-color-inheritance.txt
+++ b/Tests/LibWeb/Text/expected/svg-reset-color-inheritance.txt
@@ -1,5 +1,5 @@
-initial stop-color: currentcolor
-initial flood-color: currentcolor
+initial stop-color: rgb(0, 0, 255)
+initial flood-color: rgb(0, 0, 255)
block stop-color parent: rgb(255, 0, 0)
block stop-color inherited: rgb(0, 0, 255)
block stop-color parent color changed: rgb(0, 0, 255)
diff --git a/Tests/LibWeb/Text/expected/wpt-import/svg/pservers/scripted/stop-color-inheritance-currentcolor.txt b/Tests/LibWeb/Text/expected/wpt-import/svg/pservers/scripted/stop-color-inheritance-currentcolor.txt
index 7ca21509b7c..7f17f5b2f5b 100644
--- a/Tests/LibWeb/Text/expected/wpt-import/svg/pservers/scripted/stop-color-inheritance-currentcolor.txt
+++ b/Tests/LibWeb/Text/expected/wpt-import/svg/pservers/scripted/stop-color-inheritance-currentcolor.txt
@@ -2,5 +2,5 @@ Harness status: OK
Found 1 tests
-1 Fail
-Fail "currentcolor" is inherited as a keyword
\ No newline at end of file
+1 Pass
+Pass "currentcolor" is inherited as a keyword
\ No newline at end of file