From 0f7156ed81ca08222347e8e320135dd85e118ab9 Mon Sep 17 00:00:00 2001 From: Karol Kosek Date: Sun, 6 Mar 2022 02:09:00 +0100 Subject: [PATCH] LibWeb: Parse CSS `text-decoration-thickness` property --- Userland/Libraries/LibWeb/CSS/Parser/Parser.cpp | 14 +++++++++++--- Userland/Libraries/LibWeb/CSS/StyleComputer.cpp | 2 ++ Userland/Libraries/LibWeb/CSS/StyleValue.cpp | 2 +- Userland/Libraries/LibWeb/CSS/StyleValue.h | 7 ++++++- 4 files changed, 20 insertions(+), 5 deletions(-) diff --git a/Userland/Libraries/LibWeb/CSS/Parser/Parser.cpp b/Userland/Libraries/LibWeb/CSS/Parser/Parser.cpp index c1530bc627..ae582466ec 100644 --- a/Userland/Libraries/LibWeb/CSS/Parser/Parser.cpp +++ b/Userland/Libraries/LibWeb/CSS/Parser/Parser.cpp @@ -3733,13 +3733,13 @@ RefPtr Parser::parse_overflow_value(Vector RefPtr Parser::parse_text_decoration_value(Vector const& component_values) { - if (component_values.size() > 3) + if (component_values.size() > 4) return nullptr; RefPtr decoration_line; + RefPtr decoration_thickness; RefPtr decoration_style; RefPtr decoration_color; - // FIXME: Implement 'text-decoration-thickness' parameter. https://www.w3.org/TR/css-text-decor-4/#text-decoration-width-property for (auto& part : component_values) { auto value = parse_css_value(part); @@ -3758,6 +3758,12 @@ RefPtr Parser::parse_text_decoration_value(Vector Parser::parse_text_decoration_value(Vector parse_transform_function_name(StringView name) diff --git a/Userland/Libraries/LibWeb/CSS/StyleComputer.cpp b/Userland/Libraries/LibWeb/CSS/StyleComputer.cpp index ccaa8dc947..d1152f31e1 100644 --- a/Userland/Libraries/LibWeb/CSS/StyleComputer.cpp +++ b/Userland/Libraries/LibWeb/CSS/StyleComputer.cpp @@ -180,12 +180,14 @@ static void set_property_expanding_shorthands(StyleProperties& style, CSS::Prope if (value.is_text_decoration()) { auto const& text_decoration = value.as_text_decoration(); style.set_property(CSS::PropertyID::TextDecorationLine, text_decoration.line()); + style.set_property(CSS::PropertyID::TextDecorationThickness, text_decoration.thickness()); style.set_property(CSS::PropertyID::TextDecorationStyle, text_decoration.style()); style.set_property(CSS::PropertyID::TextDecorationColor, text_decoration.color()); return; } style.set_property(CSS::PropertyID::TextDecorationLine, value); + style.set_property(CSS::PropertyID::TextDecorationThickness, value); style.set_property(CSS::PropertyID::TextDecorationStyle, value); style.set_property(CSS::PropertyID::TextDecorationColor, value); return; diff --git a/Userland/Libraries/LibWeb/CSS/StyleValue.cpp b/Userland/Libraries/LibWeb/CSS/StyleValue.cpp index 4b6e9ccda1..12e87244a4 100644 --- a/Userland/Libraries/LibWeb/CSS/StyleValue.cpp +++ b/Userland/Libraries/LibWeb/CSS/StyleValue.cpp @@ -1319,7 +1319,7 @@ String PositionStyleValue::to_string() const String TextDecorationStyleValue::to_string() const { - return String::formatted("{} {} {}", m_line->to_string(), m_style->to_string(), m_color->to_string()); + return String::formatted("{} {} {} {}", m_line->to_string(), m_thickness->to_string(), m_style->to_string(), m_color->to_string()); } String TransformationStyleValue::to_string() const diff --git a/Userland/Libraries/LibWeb/CSS/StyleValue.h b/Userland/Libraries/LibWeb/CSS/StyleValue.h index 8991aeb53f..e94aa54160 100644 --- a/Userland/Libraries/LibWeb/CSS/StyleValue.h +++ b/Userland/Libraries/LibWeb/CSS/StyleValue.h @@ -1451,14 +1451,16 @@ class TextDecorationStyleValue final : public StyleValue { public: static NonnullRefPtr create( NonnullRefPtr line, + NonnullRefPtr thickness, NonnullRefPtr style, NonnullRefPtr color) { - return adopt_ref(*new TextDecorationStyleValue(line, style, color)); + return adopt_ref(*new TextDecorationStyleValue(line, thickness, style, color)); } virtual ~TextDecorationStyleValue() override { } NonnullRefPtr line() const { return m_line; } + NonnullRefPtr thickness() const { return m_thickness; } NonnullRefPtr style() const { return m_style; } NonnullRefPtr color() const { return m_color; } @@ -1467,16 +1469,19 @@ public: private: TextDecorationStyleValue( NonnullRefPtr line, + NonnullRefPtr thickness, NonnullRefPtr style, NonnullRefPtr color) : StyleValue(Type::TextDecoration) , m_line(line) + , m_thickness(thickness) , m_style(style) , m_color(color) { } NonnullRefPtr m_line; + NonnullRefPtr m_thickness; NonnullRefPtr m_style; NonnullRefPtr m_color; };