From 4005793e79b42e7ff042dd74ebe57aa869c92ec2 Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Wed, 10 May 2023 14:14:04 +0200 Subject: [PATCH] LibWeb: Handle CSS "color: currentcolor" Per CSS-COLOR-4, when `color` is `currentcolor`, it should resolve to the inherited value. --- Userland/Libraries/LibWeb/CSS/StyleComputer.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/Userland/Libraries/LibWeb/CSS/StyleComputer.cpp b/Userland/Libraries/LibWeb/CSS/StyleComputer.cpp index 1bdf909f08..5929b78893 100644 --- a/Userland/Libraries/LibWeb/CSS/StyleComputer.cpp +++ b/Userland/Libraries/LibWeb/CSS/StyleComputer.cpp @@ -1053,6 +1053,14 @@ void StyleComputer::compute_defaulted_values(StyleProperties& style, DOM::Elemen auto property_id = (CSS::PropertyID)i; compute_defaulted_property_value(style, element, property_id, pseudo_element); } + + // https://www.w3.org/TR/css-color-4/#resolving-other-colors + // In the color property, the used value of currentcolor is the inherited value. + auto color = style.property(CSS::PropertyID::Color); + if (color->to_identifier() == CSS::ValueID::Currentcolor) { + color = get_inherit_value(document().realm(), CSS::PropertyID::Color, element, pseudo_element); + style.set_property(CSS::PropertyID::Color, color); + } } Length::FontMetrics StyleComputer::calculate_root_element_font_metrics(StyleProperties const& style) const