diff --git a/Meta/gn/secondary/Userland/Libraries/LibWeb/CSS/StyleValues/BUILD.gn b/Meta/gn/secondary/Userland/Libraries/LibWeb/CSS/StyleValues/BUILD.gn index d20243213e..90aeac7e6a 100644 --- a/Meta/gn/secondary/Userland/Libraries/LibWeb/CSS/StyleValues/BUILD.gn +++ b/Meta/gn/secondary/Userland/Libraries/LibWeb/CSS/StyleValues/BUILD.gn @@ -28,7 +28,6 @@ source_set("StyleValues") { "NumberStyleValue.cpp", "OverflowStyleValue.cpp", "PlaceItemsStyleValue.cpp", - "PlaceSelfStyleValue.cpp", "PositionStyleValue.cpp", "RadialGradientStyleValue.cpp", "RectStyleValue.cpp", diff --git a/Userland/Libraries/LibWeb/CMakeLists.txt b/Userland/Libraries/LibWeb/CMakeLists.txt index ea0f29ac83..6665700c37 100644 --- a/Userland/Libraries/LibWeb/CMakeLists.txt +++ b/Userland/Libraries/LibWeb/CMakeLists.txt @@ -105,7 +105,6 @@ set(SOURCES CSS/StyleValues/NumberStyleValue.cpp CSS/StyleValues/OverflowStyleValue.cpp CSS/StyleValues/PlaceItemsStyleValue.cpp - CSS/StyleValues/PlaceSelfStyleValue.cpp CSS/StyleValues/PositionStyleValue.cpp CSS/StyleValues/RadialGradientStyleValue.cpp CSS/StyleValues/RectStyleValue.cpp diff --git a/Userland/Libraries/LibWeb/CSS/Parser/Parser.cpp b/Userland/Libraries/LibWeb/CSS/Parser/Parser.cpp index d99d9a3b37..eb8d3eb242 100644 --- a/Userland/Libraries/LibWeb/CSS/Parser/Parser.cpp +++ b/Userland/Libraries/LibWeb/CSS/Parser/Parser.cpp @@ -62,7 +62,6 @@ #include #include #include -#include #include #include #include @@ -4622,13 +4621,17 @@ RefPtr Parser::parse_place_self_value(Vector const& if (component_values.size() == 1) { if (!property_accepts_identifier(PropertyID::JustifySelf, maybe_align_self_value->to_identifier())) return nullptr; - return PlaceSelfStyleValue::create(*maybe_align_self_value, *maybe_align_self_value); + return ShorthandStyleValue::create(PropertyID::PlaceSelf, + { PropertyID::AlignSelf, PropertyID::JustifySelf }, + { *maybe_align_self_value, *maybe_align_self_value }); } auto maybe_justify_self_value = parse_css_value_for_property(PropertyID::JustifySelf, tokens); if (!maybe_justify_self_value) return nullptr; - return PlaceItemsStyleValue::create(*maybe_align_self_value, *maybe_justify_self_value); + return ShorthandStyleValue::create(PropertyID::PlaceSelf, + { PropertyID::AlignSelf, PropertyID::JustifySelf }, + { *maybe_align_self_value, *maybe_justify_self_value }); } RefPtr Parser::parse_quotes_value(Vector const& component_values) diff --git a/Userland/Libraries/LibWeb/CSS/StyleComputer.cpp b/Userland/Libraries/LibWeb/CSS/StyleComputer.cpp index 9877e7052d..4bc17b97ff 100644 --- a/Userland/Libraries/LibWeb/CSS/StyleComputer.cpp +++ b/Userland/Libraries/LibWeb/CSS/StyleComputer.cpp @@ -47,7 +47,6 @@ #include #include #include -#include #include #include #include @@ -513,13 +512,6 @@ static void set_property_expanding_shorthands(StyleProperties& style, CSS::Prope } if (property_id == CSS::PropertyID::PlaceSelf) { - if (value.is_place_self()) { - auto const& place_self = value.as_place_self(); - set_longhand_property(CSS::PropertyID::AlignSelf, place_self.align_self()); - set_longhand_property(CSS::PropertyID::JustifySelf, place_self.justify_self()); - return; - } - set_longhand_property(CSS::PropertyID::AlignSelf, value); set_longhand_property(CSS::PropertyID::JustifySelf, value); return; diff --git a/Userland/Libraries/LibWeb/CSS/StyleValue.cpp b/Userland/Libraries/LibWeb/CSS/StyleValue.cpp index 07a7d84b18..cb3c3f26e5 100644 --- a/Userland/Libraries/LibWeb/CSS/StyleValue.cpp +++ b/Userland/Libraries/LibWeb/CSS/StyleValue.cpp @@ -42,7 +42,6 @@ #include #include #include -#include #include #include #include diff --git a/Userland/Libraries/LibWeb/CSS/StyleValue.h b/Userland/Libraries/LibWeb/CSS/StyleValue.h index eadb6c203e..eec77fa8c9 100644 --- a/Userland/Libraries/LibWeb/CSS/StyleValue.h +++ b/Userland/Libraries/LibWeb/CSS/StyleValue.h @@ -114,7 +114,6 @@ using StyleValueVector = Vector>; __ENUMERATE_STYLE_VALUE_TYPE(Overflow, overflow) \ __ENUMERATE_STYLE_VALUE_TYPE(Percentage, percentage) \ __ENUMERATE_STYLE_VALUE_TYPE(PlaceItems, place_items) \ - __ENUMERATE_STYLE_VALUE_TYPE(PlaceSelf, place_self) \ __ENUMERATE_STYLE_VALUE_TYPE(Position, position) \ __ENUMERATE_STYLE_VALUE_TYPE(RadialGradient, radial_gradient) \ __ENUMERATE_STYLE_VALUE_TYPE(Ratio, ratio) \ diff --git a/Userland/Libraries/LibWeb/CSS/StyleValues/PlaceSelfStyleValue.cpp b/Userland/Libraries/LibWeb/CSS/StyleValues/PlaceSelfStyleValue.cpp deleted file mode 100644 index 0c7d7e7ce8..0000000000 --- a/Userland/Libraries/LibWeb/CSS/StyleValues/PlaceSelfStyleValue.cpp +++ /dev/null @@ -1,20 +0,0 @@ -/* - * Copyright (c) 2023, Aliaksandr Kalenik - * - * SPDX-License-Identifier: BSD-2-Clause - */ - -#include "PlaceSelfStyleValue.h" - -namespace Web::CSS { - -String PlaceSelfStyleValue::to_string() const -{ - auto align_self = m_properties.align_self->to_string(); - auto justify_self = m_properties.justify_self->to_string(); - if (align_self == justify_self) - return MUST(String::formatted("{}", align_self)); - return MUST(String::formatted("{} {}", align_self, justify_self)); -} - -} diff --git a/Userland/Libraries/LibWeb/CSS/StyleValues/PlaceSelfStyleValue.h b/Userland/Libraries/LibWeb/CSS/StyleValues/PlaceSelfStyleValue.h deleted file mode 100644 index 05bb61b066..0000000000 --- a/Userland/Libraries/LibWeb/CSS/StyleValues/PlaceSelfStyleValue.h +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Copyright (c) 2023, Aliaksandr Kalenik - * - * SPDX-License-Identifier: BSD-2-Clause - */ - -#pragma once - -#include - -namespace Web::CSS { - -class PlaceSelfStyleValue final : public StyleValueWithDefaultOperators { -public: - static ValueComparingNonnullRefPtr create(ValueComparingNonnullRefPtr align_self, ValueComparingNonnullRefPtr justify_self) - { - return adopt_ref(*new (nothrow) PlaceSelfStyleValue(move(align_self), move(justify_self))); - } - virtual ~PlaceSelfStyleValue() override = default; - - ValueComparingNonnullRefPtr align_self() const { return m_properties.align_self; } - ValueComparingNonnullRefPtr justify_self() const { return m_properties.justify_self; } - - virtual String to_string() const override; - - bool properties_equal(PlaceSelfStyleValue const& other) const { return m_properties == other.m_properties; } - -private: - PlaceSelfStyleValue(ValueComparingNonnullRefPtr align_self, ValueComparingNonnullRefPtr justify_self) - : StyleValueWithDefaultOperators(Type::PlaceSelf) - , m_properties { .align_self = move(align_self), .justify_self = move(justify_self) } - { - } - - struct Properties { - ValueComparingNonnullRefPtr align_self; - ValueComparingNonnullRefPtr justify_self; - bool operator==(Properties const&) const = default; - } m_properties; -}; - -} diff --git a/Userland/Libraries/LibWeb/CSS/StyleValues/ShorthandStyleValue.cpp b/Userland/Libraries/LibWeb/CSS/StyleValues/ShorthandStyleValue.cpp index b7db280718..ad509bf350 100644 --- a/Userland/Libraries/LibWeb/CSS/StyleValues/ShorthandStyleValue.cpp +++ b/Userland/Libraries/LibWeb/CSS/StyleValues/ShorthandStyleValue.cpp @@ -154,6 +154,13 @@ String ShorthandStyleValue::to_string() const return align_content; return MUST(String::formatted("{} {}", align_content, justify_content)); } + case PropertyID::PlaceSelf: { + auto align_self = longhand(PropertyID::AlignSelf)->to_string(); + auto justify_self = longhand(PropertyID::JustifySelf)->to_string(); + if (align_self == justify_self) + return align_self; + return MUST(String::formatted("{} {}", align_self, justify_self)); + } default: StringBuilder builder; auto first = true; diff --git a/Userland/Libraries/LibWeb/Forward.h b/Userland/Libraries/LibWeb/Forward.h index 1e1296d227..e28347e110 100644 --- a/Userland/Libraries/LibWeb/Forward.h +++ b/Userland/Libraries/LibWeb/Forward.h @@ -140,7 +140,6 @@ class Percentage; class PercentageOrCalculated; class PercentageStyleValue; class PlaceItemsStyleValue; -class PlaceSelfStyleValue; class PositionStyleValue; class PropertyOwningCSSStyleDeclaration; class RadialGradientStyleValue;