From 4a14c4dae86d110aa1b6c999c92474a644a35f6f Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Sat, 12 Mar 2022 17:00:29 +0100 Subject: [PATCH] LibWeb: Support the CSS 'unset' value This works as 'inherit' for inherited properties and 'initial' for everything else. --- Userland/Libraries/LibWeb/CSS/StyleComputer.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/Userland/Libraries/LibWeb/CSS/StyleComputer.cpp b/Userland/Libraries/LibWeb/CSS/StyleComputer.cpp index ccd1da4889..5760a49f50 100644 --- a/Userland/Libraries/LibWeb/CSS/StyleComputer.cpp +++ b/Userland/Libraries/LibWeb/CSS/StyleComputer.cpp @@ -684,6 +684,18 @@ void StyleComputer::compute_defaulted_property_value(StyleProperties& style, DOM value_slot = get_inherit_value(property_id, element, pseudo_element); return; } + + // https://www.w3.org/TR/css-cascade-4/#inherit-initial + // If the cascaded value of a property is the unset keyword, + if (value_slot->is_unset()) { + if (is_inherited_property(property_id)) { + // then if it is an inherited property, this is treated as inherit, + value_slot = get_inherit_value(property_id, element, pseudo_element); + } else { + // and if it is not, this is treated as initial. + value_slot = property_initial_value(property_id); + } + } } // https://www.w3.org/TR/css-cascade/#defaulting