diff --git a/Userland/Libraries/LibWeb/CMakeLists.txt b/Userland/Libraries/LibWeb/CMakeLists.txt index cf95c24267..f18e44d03f 100644 --- a/Userland/Libraries/LibWeb/CMakeLists.txt +++ b/Userland/Libraries/LibWeb/CMakeLists.txt @@ -92,6 +92,7 @@ set(SOURCES CSS/StyleValues/OverflowStyleValue.cpp CSS/StyleValues/PositionStyleValue.cpp CSS/StyleValues/RadialGradientStyleValue.cpp + CSS/StyleValues/RectStyleValue.cpp CSS/StyleValues/ShadowStyleValue.cpp CSS/StyleValues/TextDecorationStyleValue.cpp CSS/StyleValues/TransformationStyleValue.cpp diff --git a/Userland/Libraries/LibWeb/CSS/Parser/Parser.cpp b/Userland/Libraries/LibWeb/CSS/Parser/Parser.cpp index def048cbbb..a25f381029 100644 --- a/Userland/Libraries/LibWeb/CSS/Parser/Parser.cpp +++ b/Userland/Libraries/LibWeb/CSS/Parser/Parser.cpp @@ -61,6 +61,7 @@ #include #include #include +#include #include #include #include diff --git a/Userland/Libraries/LibWeb/CSS/ResolvedCSSStyleDeclaration.cpp b/Userland/Libraries/LibWeb/CSS/ResolvedCSSStyleDeclaration.cpp index d58cd832ce..e55e139ae8 100644 --- a/Userland/Libraries/LibWeb/CSS/ResolvedCSSStyleDeclaration.cpp +++ b/Userland/Libraries/LibWeb/CSS/ResolvedCSSStyleDeclaration.cpp @@ -28,6 +28,7 @@ #include #include #include +#include #include #include #include diff --git a/Userland/Libraries/LibWeb/CSS/StyleProperties.cpp b/Userland/Libraries/LibWeb/CSS/StyleProperties.cpp index 6cece5f3f6..33b16a9b3e 100644 --- a/Userland/Libraries/LibWeb/CSS/StyleProperties.cpp +++ b/Userland/Libraries/LibWeb/CSS/StyleProperties.cpp @@ -15,6 +15,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 2ae512e95a..eeda36a8bf 100644 --- a/Userland/Libraries/LibWeb/CSS/StyleValue.cpp +++ b/Userland/Libraries/LibWeb/CSS/StyleValue.cpp @@ -44,6 +44,7 @@ #include #include #include +#include #include #include #include @@ -1148,11 +1149,6 @@ ErrorOr PositionValue::serialize(StringBuilder& builder) const return {}; } -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); -} - bool StyleValueList::Properties::operator==(Properties const& other) const { return separator == other.separator && values.span() == other.values.span(); @@ -1181,12 +1177,6 @@ ErrorOr StyleValueList::to_string() const return builder.to_string(); } - -ValueComparingNonnullRefPtr RectStyleValue::create(EdgeRect rect) -{ - return adopt_ref(*new RectStyleValue(rect)); -} - Optional absolutized_length(CSS::Length const& length, CSSPixelRect const& viewport_rect, Gfx::FontPixelMetrics const& font_metrics, CSSPixels font_size, CSSPixels root_font_size, CSSPixels line_height, CSSPixels root_line_height) { if (length.is_px()) diff --git a/Userland/Libraries/LibWeb/CSS/StyleValue.h b/Userland/Libraries/LibWeb/CSS/StyleValue.h index 080920fc89..41f181a56d 100644 --- a/Userland/Libraries/LibWeb/CSS/StyleValue.h +++ b/Userland/Libraries/LibWeb/CSS/StyleValue.h @@ -657,28 +657,6 @@ private: } m_properties; }; -class RectStyleValue : public StyleValueWithDefaultOperators { -public: - static ValueComparingNonnullRefPtr create(EdgeRect rect); - virtual ~RectStyleValue() override = default; - - EdgeRect rect() const { return m_rect; } - virtual ErrorOr to_string() const override; - virtual bool has_rect() const override { return true; } - virtual EdgeRect to_rect() const override { return m_rect; } - - bool properties_equal(RectStyleValue const& other) const { return m_rect == other.m_rect; } - -private: - explicit RectStyleValue(EdgeRect rect) - : StyleValueWithDefaultOperators(Type::Rect) - , m_rect(rect) - { - } - - EdgeRect m_rect; -}; - } template<> diff --git a/Userland/Libraries/LibWeb/CSS/StyleValues/RectStyleValue.cpp b/Userland/Libraries/LibWeb/CSS/StyleValues/RectStyleValue.cpp new file mode 100644 index 0000000000..3282f056ab --- /dev/null +++ b/Userland/Libraries/LibWeb/CSS/StyleValues/RectStyleValue.cpp @@ -0,0 +1,24 @@ +/* + * 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 "RectStyleValue.h" + +namespace Web::CSS { + +ValueComparingNonnullRefPtr RectStyleValue::create(EdgeRect rect) +{ + return adopt_ref(*new RectStyleValue(rect)); +} + +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); +} + +} diff --git a/Userland/Libraries/LibWeb/CSS/StyleValues/RectStyleValue.h b/Userland/Libraries/LibWeb/CSS/StyleValues/RectStyleValue.h new file mode 100644 index 0000000000..cd1b9cf07c --- /dev/null +++ b/Userland/Libraries/LibWeb/CSS/StyleValues/RectStyleValue.h @@ -0,0 +1,38 @@ +/* + * 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 RectStyleValue : public StyleValueWithDefaultOperators { +public: + static ValueComparingNonnullRefPtr create(EdgeRect rect); + virtual ~RectStyleValue() override = default; + + EdgeRect rect() const { return m_rect; } + virtual ErrorOr to_string() const override; + virtual bool has_rect() const override { return true; } + virtual EdgeRect to_rect() const override { return m_rect; } + + bool properties_equal(RectStyleValue const& other) const { return m_rect == other.m_rect; } + +private: + explicit RectStyleValue(EdgeRect rect) + : StyleValueWithDefaultOperators(Type::Rect) + , m_rect(rect) + { + } + + EdgeRect m_rect; +}; + +}