diff --git a/Userland/Libraries/LibWeb/CMakeLists.txt b/Userland/Libraries/LibWeb/CMakeLists.txt index 8bd8b2bd67..983a307414 100644 --- a/Userland/Libraries/LibWeb/CMakeLists.txt +++ b/Userland/Libraries/LibWeb/CMakeLists.txt @@ -93,6 +93,7 @@ set(SOURCES CSS/StyleValues/PositionStyleValue.cpp CSS/StyleValues/RadialGradientStyleValue.cpp CSS/StyleValues/ShadowStyleValue.cpp + CSS/StyleValues/TextDecorationStyleValue.cpp CSS/Supports.cpp CSS/SyntaxHighlighter/SyntaxHighlighter.cpp CSS/Time.cpp diff --git a/Userland/Libraries/LibWeb/CSS/Parser/Parser.cpp b/Userland/Libraries/LibWeb/CSS/Parser/Parser.cpp index 557dfdf69a..466178e169 100644 --- a/Userland/Libraries/LibWeb/CSS/Parser/Parser.cpp +++ b/Userland/Libraries/LibWeb/CSS/Parser/Parser.cpp @@ -64,6 +64,7 @@ #include #include #include +#include #include #include #include diff --git a/Userland/Libraries/LibWeb/CSS/StyleComputer.cpp b/Userland/Libraries/LibWeb/CSS/StyleComputer.cpp index 906320f753..24afe8e3fa 100644 --- a/Userland/Libraries/LibWeb/CSS/StyleComputer.cpp +++ b/Userland/Libraries/LibWeb/CSS/StyleComputer.cpp @@ -43,6 +43,7 @@ #include #include #include +#include #include #include #include diff --git a/Userland/Libraries/LibWeb/CSS/StyleValue.cpp b/Userland/Libraries/LibWeb/CSS/StyleValue.cpp index 9354b1ba17..82017b1ce4 100644 --- a/Userland/Libraries/LibWeb/CSS/StyleValue.cpp +++ b/Userland/Libraries/LibWeb/CSS/StyleValue.cpp @@ -47,6 +47,7 @@ #include #include #include +#include #include #include #include @@ -1148,11 +1149,6 @@ ErrorOr RectStyleValue::to_string() const return String::formatted("rect({} {} {} {})", m_rect.top_edge, m_rect.right_edge, m_rect.bottom_edge, m_rect.left_edge); } -ErrorOr TextDecorationStyleValue::to_string() const -{ - return String::formatted("{} {} {} {}", TRY(m_properties.line->to_string()), TRY(m_properties.thickness->to_string()), TRY(m_properties.style->to_string()), TRY(m_properties.color->to_string())); -} - ErrorOr TransformationStyleValue::to_string() const { StringBuilder builder; diff --git a/Userland/Libraries/LibWeb/CSS/StyleValue.h b/Userland/Libraries/LibWeb/CSS/StyleValue.h index 11eab4ea40..eab2ce6fe0 100644 --- a/Userland/Libraries/LibWeb/CSS/StyleValue.h +++ b/Userland/Libraries/LibWeb/CSS/StyleValue.h @@ -622,47 +622,6 @@ private: NonnullOwnPtr m_expression; }; -class TextDecorationStyleValue final : public StyleValueWithDefaultOperators { -public: - static ValueComparingNonnullRefPtr create( - ValueComparingNonnullRefPtr line, - ValueComparingNonnullRefPtr thickness, - ValueComparingNonnullRefPtr style, - ValueComparingNonnullRefPtr color) - { - return adopt_ref(*new TextDecorationStyleValue(move(line), move(thickness), move(style), move(color))); - } - virtual ~TextDecorationStyleValue() override = default; - - ValueComparingNonnullRefPtr line() const { return m_properties.line; } - ValueComparingNonnullRefPtr thickness() const { return m_properties.thickness; } - ValueComparingNonnullRefPtr style() const { return m_properties.style; } - ValueComparingNonnullRefPtr color() const { return m_properties.color; } - - virtual ErrorOr to_string() const override; - - bool properties_equal(TextDecorationStyleValue const& other) const { return m_properties == other.m_properties; } - -private: - TextDecorationStyleValue( - ValueComparingNonnullRefPtr line, - ValueComparingNonnullRefPtr thickness, - ValueComparingNonnullRefPtr style, - ValueComparingNonnullRefPtr color) - : StyleValueWithDefaultOperators(Type::TextDecoration) - , m_properties { .line = move(line), .thickness = move(thickness), .style = move(style), .color = move(color) } - { - } - - struct Properties { - ValueComparingNonnullRefPtr line; - ValueComparingNonnullRefPtr thickness; - ValueComparingNonnullRefPtr style; - ValueComparingNonnullRefPtr color; - bool operator==(Properties const&) const = default; - } m_properties; -}; - class TimeStyleValue : public StyleValueWithDefaultOperators { public: static ValueComparingNonnullRefPtr create(Time time) diff --git a/Userland/Libraries/LibWeb/CSS/StyleValues/TextDecorationStyleValue.cpp b/Userland/Libraries/LibWeb/CSS/StyleValues/TextDecorationStyleValue.cpp new file mode 100644 index 0000000000..722ab84629 --- /dev/null +++ b/Userland/Libraries/LibWeb/CSS/StyleValues/TextDecorationStyleValue.cpp @@ -0,0 +1,19 @@ +/* + * Copyright (c) 2018-2020, Andreas Kling + * Copyright (c) 2021, Tobias Christiansen + * Copyright (c) 2021-2023, Sam Atkins + * Copyright (c) 2022-2023, MacDue + * + * SPDX-License-Identifier: BSD-2-Clause + */ + +#include "TextDecorationStyleValue.h" + +namespace Web::CSS { + +ErrorOr TextDecorationStyleValue::to_string() const +{ + return String::formatted("{} {} {} {}", TRY(m_properties.line->to_string()), TRY(m_properties.thickness->to_string()), TRY(m_properties.style->to_string()), TRY(m_properties.color->to_string())); +} + +} diff --git a/Userland/Libraries/LibWeb/CSS/StyleValues/TextDecorationStyleValue.h b/Userland/Libraries/LibWeb/CSS/StyleValues/TextDecorationStyleValue.h new file mode 100644 index 0000000000..b3a6ace4bc --- /dev/null +++ b/Userland/Libraries/LibWeb/CSS/StyleValues/TextDecorationStyleValue.h @@ -0,0 +1,57 @@ +/* + * Copyright (c) 2018-2020, Andreas Kling + * Copyright (c) 2021, Tobias Christiansen + * Copyright (c) 2021-2023, Sam Atkins + * Copyright (c) 2022-2023, MacDue + * + * SPDX-License-Identifier: BSD-2-Clause + */ + +#pragma once + +#include + +namespace Web::CSS { + +class TextDecorationStyleValue final : public StyleValueWithDefaultOperators { +public: + static ValueComparingNonnullRefPtr create( + ValueComparingNonnullRefPtr line, + ValueComparingNonnullRefPtr thickness, + ValueComparingNonnullRefPtr style, + ValueComparingNonnullRefPtr color) + { + return adopt_ref(*new TextDecorationStyleValue(move(line), move(thickness), move(style), move(color))); + } + virtual ~TextDecorationStyleValue() override = default; + + ValueComparingNonnullRefPtr line() const { return m_properties.line; } + ValueComparingNonnullRefPtr thickness() const { return m_properties.thickness; } + ValueComparingNonnullRefPtr style() const { return m_properties.style; } + ValueComparingNonnullRefPtr color() const { return m_properties.color; } + + virtual ErrorOr to_string() const override; + + bool properties_equal(TextDecorationStyleValue const& other) const { return m_properties == other.m_properties; } + +private: + TextDecorationStyleValue( + ValueComparingNonnullRefPtr line, + ValueComparingNonnullRefPtr thickness, + ValueComparingNonnullRefPtr style, + ValueComparingNonnullRefPtr color) + : StyleValueWithDefaultOperators(Type::TextDecoration) + , m_properties { .line = move(line), .thickness = move(thickness), .style = move(style), .color = move(color) } + { + } + + struct Properties { + ValueComparingNonnullRefPtr line; + ValueComparingNonnullRefPtr thickness; + ValueComparingNonnullRefPtr style; + ValueComparingNonnullRefPtr color; + bool operator==(Properties const&) const = default; + } m_properties; +}; + +}