diff --git a/Userland/Libraries/LibWeb/CMakeLists.txt b/Userland/Libraries/LibWeb/CMakeLists.txt index 059fa78171..1e0b26d62a 100644 --- a/Userland/Libraries/LibWeb/CMakeLists.txt +++ b/Userland/Libraries/LibWeb/CMakeLists.txt @@ -89,6 +89,7 @@ set(SOURCES CSS/StyleValues/LinearGradientStyleValue.cpp CSS/StyleValues/ListStyleStyleValue.cpp CSS/StyleValues/NumericStyleValue.cpp + CSS/StyleValues/OverflowStyleValue.cpp CSS/StyleValues/RadialGradientStyleValue.cpp CSS/Supports.cpp CSS/SyntaxHighlighter/SyntaxHighlighter.cpp diff --git a/Userland/Libraries/LibWeb/CSS/Parser/Parser.cpp b/Userland/Libraries/LibWeb/CSS/Parser/Parser.cpp index 928cb1015f..6f5e1e7fff 100644 --- a/Userland/Libraries/LibWeb/CSS/Parser/Parser.cpp +++ b/Userland/Libraries/LibWeb/CSS/Parser/Parser.cpp @@ -57,6 +57,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 3f8c4852c3..358c09231c 100644 --- a/Userland/Libraries/LibWeb/CSS/StyleComputer.cpp +++ b/Userland/Libraries/LibWeb/CSS/StyleComputer.cpp @@ -41,6 +41,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 265277e3ad..f8eeda34f6 100644 --- a/Userland/Libraries/LibWeb/CSS/StyleValue.cpp +++ b/Userland/Libraries/LibWeb/CSS/StyleValue.cpp @@ -40,6 +40,7 @@ #include #include #include +#include #include #include #include @@ -1137,11 +1138,6 @@ ErrorOr PositionValue::serialize(StringBuilder& builder) const return {}; } -ErrorOr OverflowStyleValue::to_string() const -{ - return String::formatted("{} {}", TRY(m_properties.overflow_x->to_string()), TRY(m_properties.overflow_y->to_string())); -} - ErrorOr PercentageStyleValue::to_string() const { return m_percentage.to_string(); diff --git a/Userland/Libraries/LibWeb/CSS/StyleValue.h b/Userland/Libraries/LibWeb/CSS/StyleValue.h index fca52733ec..e0af8d8356 100644 --- a/Userland/Libraries/LibWeb/CSS/StyleValue.h +++ b/Userland/Libraries/LibWeb/CSS/StyleValue.h @@ -627,35 +627,6 @@ private: NonnullOwnPtr m_expression; }; -class OverflowStyleValue final : public StyleValueWithDefaultOperators { -public: - static ValueComparingNonnullRefPtr create(ValueComparingNonnullRefPtr overflow_x, ValueComparingNonnullRefPtr overflow_y) - { - return adopt_ref(*new OverflowStyleValue(move(overflow_x), move(overflow_y))); - } - virtual ~OverflowStyleValue() override = default; - - ValueComparingNonnullRefPtr overflow_x() const { return m_properties.overflow_x; } - ValueComparingNonnullRefPtr overflow_y() const { return m_properties.overflow_y; } - - virtual ErrorOr to_string() const override; - - bool properties_equal(OverflowStyleValue const& other) const { return m_properties == other.m_properties; } - -private: - OverflowStyleValue(ValueComparingNonnullRefPtr overflow_x, ValueComparingNonnullRefPtr overflow_y) - : StyleValueWithDefaultOperators(Type::Overflow) - , m_properties { .overflow_x = move(overflow_x), .overflow_y = move(overflow_y) } - { - } - - struct Properties { - ValueComparingNonnullRefPtr overflow_x; - ValueComparingNonnullRefPtr overflow_y; - bool operator==(Properties const&) const = default; - } m_properties; -}; - class PercentageStyleValue final : public StyleValueWithDefaultOperators { public: static ValueComparingNonnullRefPtr create(Percentage percentage) diff --git a/Userland/Libraries/LibWeb/CSS/StyleValues/OverflowStyleValue.cpp b/Userland/Libraries/LibWeb/CSS/StyleValues/OverflowStyleValue.cpp new file mode 100644 index 0000000000..433b1c1545 --- /dev/null +++ b/Userland/Libraries/LibWeb/CSS/StyleValues/OverflowStyleValue.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 "OverflowStyleValue.h" + +namespace Web::CSS { + +ErrorOr OverflowStyleValue::to_string() const +{ + return String::formatted("{} {}", TRY(m_properties.overflow_x->to_string()), TRY(m_properties.overflow_y->to_string())); +} + +} diff --git a/Userland/Libraries/LibWeb/CSS/StyleValues/OverflowStyleValue.h b/Userland/Libraries/LibWeb/CSS/StyleValues/OverflowStyleValue.h new file mode 100644 index 0000000000..d7f2540eaa --- /dev/null +++ b/Userland/Libraries/LibWeb/CSS/StyleValues/OverflowStyleValue.h @@ -0,0 +1,45 @@ +/* + * 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 OverflowStyleValue final : public StyleValueWithDefaultOperators { +public: + static ValueComparingNonnullRefPtr create(ValueComparingNonnullRefPtr overflow_x, ValueComparingNonnullRefPtr overflow_y) + { + return adopt_ref(*new OverflowStyleValue(move(overflow_x), move(overflow_y))); + } + virtual ~OverflowStyleValue() override = default; + + ValueComparingNonnullRefPtr overflow_x() const { return m_properties.overflow_x; } + ValueComparingNonnullRefPtr overflow_y() const { return m_properties.overflow_y; } + + virtual ErrorOr to_string() const override; + + bool properties_equal(OverflowStyleValue const& other) const { return m_properties == other.m_properties; } + +private: + OverflowStyleValue(ValueComparingNonnullRefPtr overflow_x, ValueComparingNonnullRefPtr overflow_y) + : StyleValueWithDefaultOperators(Type::Overflow) + , m_properties { .overflow_x = move(overflow_x), .overflow_y = move(overflow_y) } + { + } + + struct Properties { + ValueComparingNonnullRefPtr overflow_x; + ValueComparingNonnullRefPtr overflow_y; + bool operator==(Properties const&) const = default; + } m_properties; +}; + +}