From d39788556ac6425defc0ee21e9a6c8e116a9dc46 Mon Sep 17 00:00:00 2001 From: Sam Atkins Date: Fri, 24 Mar 2023 14:57:27 +0000 Subject: [PATCH] LibWeb: Split GridTrackSizeStyleValue out of StyleValue.{h,cpp} --- Userland/Libraries/LibWeb/CMakeLists.txt | 1 + .../Libraries/LibWeb/CSS/Parser/Parser.cpp | 1 + .../CSS/ResolvedCSSStyleDeclaration.cpp | 1 + .../Libraries/LibWeb/CSS/StyleProperties.cpp | 1 + Userland/Libraries/LibWeb/CSS/StyleValue.cpp | 16 +------- Userland/Libraries/LibWeb/CSS/StyleValue.h | 23 ----------- .../StyleValues/GridTrackSizeStyleValue.cpp | 29 ++++++++++++++ .../CSS/StyleValues/GridTrackSizeStyleValue.h | 40 +++++++++++++++++++ 8 files changed, 74 insertions(+), 38 deletions(-) create mode 100644 Userland/Libraries/LibWeb/CSS/StyleValues/GridTrackSizeStyleValue.cpp create mode 100644 Userland/Libraries/LibWeb/CSS/StyleValues/GridTrackSizeStyleValue.h diff --git a/Userland/Libraries/LibWeb/CMakeLists.txt b/Userland/Libraries/LibWeb/CMakeLists.txt index 052810c13be..89155969c9f 100644 --- a/Userland/Libraries/LibWeb/CMakeLists.txt +++ b/Userland/Libraries/LibWeb/CMakeLists.txt @@ -81,6 +81,7 @@ set(SOURCES CSS/StyleValues/GridTemplateAreaStyleValue.cpp CSS/StyleValues/GridTrackPlacementStyleValue.cpp CSS/StyleValues/GridTrackPlacementShorthandStyleValue.cpp + CSS/StyleValues/GridTrackSizeStyleValue.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 48217dc9f5b..377015361e9 100644 --- a/Userland/Libraries/LibWeb/CSS/Parser/Parser.cpp +++ b/Userland/Libraries/LibWeb/CSS/Parser/Parser.cpp @@ -47,6 +47,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 b59d14898c1..e296a226507 100644 --- a/Userland/Libraries/LibWeb/CSS/ResolvedCSSStyleDeclaration.cpp +++ b/Userland/Libraries/LibWeb/CSS/ResolvedCSSStyleDeclaration.cpp @@ -21,6 +21,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 19190b23d24..2dccffa27ec 100644 --- a/Userland/Libraries/LibWeb/CSS/StyleProperties.cpp +++ b/Userland/Libraries/LibWeb/CSS/StyleProperties.cpp @@ -13,6 +13,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 638332b3283..8d94eec8785 100644 --- a/Userland/Libraries/LibWeb/CSS/StyleValue.cpp +++ b/Userland/Libraries/LibWeb/CSS/StyleValue.cpp @@ -29,6 +29,7 @@ #include #include #include +#include #include #include #include @@ -1031,11 +1032,6 @@ CalculatedStyleValue::CalculationResult CalculatedStyleValue::CalcNumberSumPartW return value->resolve(layout_node, percentage_basis); } -ErrorOr GridTrackSizeStyleValue::to_string() const -{ - return m_grid_track_size_list.to_string(); -} - ErrorOr IdentifierStyleValue::to_string() const { return String::from_utf8(CSS::string_from_value_id(m_id)); @@ -1921,16 +1917,6 @@ ErrorOr StyleValueList::to_string() const } -ValueComparingNonnullRefPtr GridTrackSizeStyleValue::create(CSS::GridTrackSizeList grid_track_size_list) -{ - return adopt_ref(*new GridTrackSizeStyleValue(grid_track_size_list)); -} - -ValueComparingNonnullRefPtr GridTrackSizeStyleValue::make_auto() -{ - return adopt_ref(*new GridTrackSizeStyleValue(CSS::GridTrackSizeList())); -} - ValueComparingNonnullRefPtr RectStyleValue::create(EdgeRect rect) { return adopt_ref(*new RectStyleValue(rect)); diff --git a/Userland/Libraries/LibWeb/CSS/StyleValue.h b/Userland/Libraries/LibWeb/CSS/StyleValue.h index ee972535acd..b58f74259d1 100644 --- a/Userland/Libraries/LibWeb/CSS/StyleValue.h +++ b/Userland/Libraries/LibWeb/CSS/StyleValue.h @@ -661,29 +661,6 @@ private: NonnullOwnPtr m_expression; }; -class GridTrackSizeStyleValue final : public StyleValueWithDefaultOperators { -public: - static ValueComparingNonnullRefPtr create(CSS::GridTrackSizeList grid_track_size_list); - virtual ~GridTrackSizeStyleValue() override = default; - - static ValueComparingNonnullRefPtr make_auto(); - - CSS::GridTrackSizeList grid_track_size_list() const { return m_grid_track_size_list; } - - virtual ErrorOr to_string() const override; - - bool properties_equal(GridTrackSizeStyleValue const& other) const { return m_grid_track_size_list == other.m_grid_track_size_list; } - -private: - explicit GridTrackSizeStyleValue(CSS::GridTrackSizeList grid_track_size_list) - : StyleValueWithDefaultOperators(Type::GridTrackSizeList) - , m_grid_track_size_list(grid_track_size_list) - { - } - - CSS::GridTrackSizeList m_grid_track_size_list; -}; - class IdentifierStyleValue final : public StyleValueWithDefaultOperators { public: static ValueComparingNonnullRefPtr create(CSS::ValueID id) diff --git a/Userland/Libraries/LibWeb/CSS/StyleValues/GridTrackSizeStyleValue.cpp b/Userland/Libraries/LibWeb/CSS/StyleValues/GridTrackSizeStyleValue.cpp new file mode 100644 index 00000000000..53eec27e0b4 --- /dev/null +++ b/Userland/Libraries/LibWeb/CSS/StyleValues/GridTrackSizeStyleValue.cpp @@ -0,0 +1,29 @@ +/* + * 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 "GridTrackSizeStyleValue.h" + +namespace Web::CSS { + +ErrorOr GridTrackSizeStyleValue::to_string() const +{ + return m_grid_track_size_list.to_string(); +} + +ValueComparingNonnullRefPtr GridTrackSizeStyleValue::create(CSS::GridTrackSizeList grid_track_size_list) +{ + return adopt_ref(*new GridTrackSizeStyleValue(grid_track_size_list)); +} + +ValueComparingNonnullRefPtr GridTrackSizeStyleValue::make_auto() +{ + return adopt_ref(*new GridTrackSizeStyleValue(CSS::GridTrackSizeList())); +} + +} diff --git a/Userland/Libraries/LibWeb/CSS/StyleValues/GridTrackSizeStyleValue.h b/Userland/Libraries/LibWeb/CSS/StyleValues/GridTrackSizeStyleValue.h new file mode 100644 index 00000000000..f73a818878d --- /dev/null +++ b/Userland/Libraries/LibWeb/CSS/StyleValues/GridTrackSizeStyleValue.h @@ -0,0 +1,40 @@ +/* + * 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 +#include + +namespace Web::CSS { + +class GridTrackSizeStyleValue final : public StyleValueWithDefaultOperators { +public: + static ValueComparingNonnullRefPtr create(CSS::GridTrackSizeList grid_track_size_list); + virtual ~GridTrackSizeStyleValue() override = default; + + static ValueComparingNonnullRefPtr make_auto(); + + CSS::GridTrackSizeList grid_track_size_list() const { return m_grid_track_size_list; } + + virtual ErrorOr to_string() const override; + + bool properties_equal(GridTrackSizeStyleValue const& other) const { return m_grid_track_size_list == other.m_grid_track_size_list; } + +private: + explicit GridTrackSizeStyleValue(CSS::GridTrackSizeList grid_track_size_list) + : StyleValueWithDefaultOperators(Type::GridTrackSizeList) + , m_grid_track_size_list(grid_track_size_list) + { + } + + CSS::GridTrackSizeList m_grid_track_size_list; +}; + +}