From 434bac3c67195587f97308b34a91987d0b2b3bd6 Mon Sep 17 00:00:00 2001 From: Sam Atkins Date: Tue, 4 Jul 2023 16:08:19 +0100 Subject: [PATCH] LibWeb: Return true for `is_operator_node()` for math-function nodes --- .../CSS/StyleValues/CalculatedStyleValue.h | 35 +++++++++++++++++-- 1 file changed, 33 insertions(+), 2 deletions(-) diff --git a/Userland/Libraries/LibWeb/CSS/StyleValues/CalculatedStyleValue.h b/Userland/Libraries/LibWeb/CSS/StyleValues/CalculatedStyleValue.h index 3694ba1444a..a47be2e1dc5 100644 --- a/Userland/Libraries/LibWeb/CSS/StyleValues/CalculatedStyleValue.h +++ b/Userland/Libraries/LibWeb/CSS/StyleValues/CalculatedStyleValue.h @@ -193,12 +193,43 @@ public: Type type() const { return m_type; } + // https://www.w3.org/TR/css-values-4/#calculation-tree-operator-nodes bool is_operator_node() const { - // FIXME: Check for operator node types once they exist - return is_calc_operator_node(); + return is_calc_operator_node() || is_math_function_node(); } + bool is_math_function_node() const + { + switch (m_type) { + case Type::Min: + case Type::Max: + case Type::Clamp: + case Type::Abs: + case Type::Sign: + case Type::Sin: + case Type::Cos: + case Type::Tan: + case Type::Asin: + case Type::Acos: + case Type::Atan: + case Type::Atan2: + case Type::Pow: + case Type::Sqrt: + case Type::Hypot: + case Type::Log: + case Type::Exp: + case Type::Round: + case Type::Mod: + case Type::Rem: + return true; + + default: + return false; + } + } + + // https://www.w3.org/TR/css-values-4/#calculation-tree-calc-operator-nodes bool is_calc_operator_node() const { return first_is_one_of(m_type, Type::Sum, Type::Product, Type::Negate, Type::Invert);