LibWeb: Handle CSS "color: currentcolor"

Per CSS-COLOR-4, when `color` is `currentcolor`, it should resolve to
the inherited value.
This commit is contained in:
Andreas Kling 2023-05-10 14:14:04 +02:00
parent cf4a43e4c0
commit 4005793e79
Notes: sideshowbarker 2024-07-17 02:08:15 +09:00

View file

@ -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