mirror of
				https://github.com/RGBCube/serenity
				synced 2025-10-31 15:42:44 +00:00 
			
		
		
		
	LibWeb: Replace OverflowStyleValue with ShorthandStyleValue
This commit is contained in:
		
							parent
							
								
									e905072e47
								
							
						
					
					
						commit
						aea112da71
					
				
					 11 changed files with 9 additions and 81 deletions
				
			
		|  | @ -25,7 +25,6 @@ source_set("StyleValues") { | ||||||
|     "LinearGradientStyleValue.cpp", |     "LinearGradientStyleValue.cpp", | ||||||
|     "MathDepthStyleValue.cpp", |     "MathDepthStyleValue.cpp", | ||||||
|     "NumberStyleValue.cpp", |     "NumberStyleValue.cpp", | ||||||
|     "OverflowStyleValue.cpp", |  | ||||||
|     "PositionStyleValue.cpp", |     "PositionStyleValue.cpp", | ||||||
|     "RadialGradientStyleValue.cpp", |     "RadialGradientStyleValue.cpp", | ||||||
|     "RectStyleValue.cpp", |     "RectStyleValue.cpp", | ||||||
|  |  | ||||||
|  | @ -102,7 +102,6 @@ set(SOURCES | ||||||
|     CSS/StyleValues/LinearGradientStyleValue.cpp |     CSS/StyleValues/LinearGradientStyleValue.cpp | ||||||
|     CSS/StyleValues/MathDepthStyleValue.cpp |     CSS/StyleValues/MathDepthStyleValue.cpp | ||||||
|     CSS/StyleValues/NumberStyleValue.cpp |     CSS/StyleValues/NumberStyleValue.cpp | ||||||
|     CSS/StyleValues/OverflowStyleValue.cpp |  | ||||||
|     CSS/StyleValues/PositionStyleValue.cpp |     CSS/StyleValues/PositionStyleValue.cpp | ||||||
|     CSS/StyleValues/RadialGradientStyleValue.cpp |     CSS/StyleValues/RadialGradientStyleValue.cpp | ||||||
|     CSS/StyleValues/RectStyleValue.cpp |     CSS/StyleValues/RectStyleValue.cpp | ||||||
|  |  | ||||||
|  | @ -58,7 +58,6 @@ | ||||||
| #include <LibWeb/CSS/StyleValues/LengthStyleValue.h> | #include <LibWeb/CSS/StyleValues/LengthStyleValue.h> | ||||||
| #include <LibWeb/CSS/StyleValues/MathDepthStyleValue.h> | #include <LibWeb/CSS/StyleValues/MathDepthStyleValue.h> | ||||||
| #include <LibWeb/CSS/StyleValues/NumberStyleValue.h> | #include <LibWeb/CSS/StyleValues/NumberStyleValue.h> | ||||||
| #include <LibWeb/CSS/StyleValues/OverflowStyleValue.h> |  | ||||||
| #include <LibWeb/CSS/StyleValues/PercentageStyleValue.h> | #include <LibWeb/CSS/StyleValues/PercentageStyleValue.h> | ||||||
| #include <LibWeb/CSS/StyleValues/PositionStyleValue.h> | #include <LibWeb/CSS/StyleValues/PositionStyleValue.h> | ||||||
| #include <LibWeb/CSS/StyleValues/RatioStyleValue.h> | #include <LibWeb/CSS/StyleValues/RatioStyleValue.h> | ||||||
|  | @ -4549,7 +4548,9 @@ RefPtr<StyleValue> Parser::parse_overflow_value(Vector<ComponentValue> const& co | ||||||
|         auto maybe_value = parse_css_value_for_property(PropertyID::Overflow, tokens); |         auto maybe_value = parse_css_value_for_property(PropertyID::Overflow, tokens); | ||||||
|         if (!maybe_value) |         if (!maybe_value) | ||||||
|             return nullptr; |             return nullptr; | ||||||
|         return OverflowStyleValue::create(*maybe_value, *maybe_value); |         return ShorthandStyleValue::create(PropertyID::Overflow, | ||||||
|  |             { PropertyID::OverflowX, PropertyID::OverflowY }, | ||||||
|  |             { *maybe_value, *maybe_value }); | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     if (component_values.size() == 2) { |     if (component_values.size() == 2) { | ||||||
|  | @ -4557,7 +4558,9 @@ RefPtr<StyleValue> Parser::parse_overflow_value(Vector<ComponentValue> const& co | ||||||
|         auto maybe_y_value = parse_css_value_for_property(PropertyID::OverflowY, tokens); |         auto maybe_y_value = parse_css_value_for_property(PropertyID::OverflowY, tokens); | ||||||
|         if (!maybe_x_value || !maybe_y_value) |         if (!maybe_x_value || !maybe_y_value) | ||||||
|             return nullptr; |             return nullptr; | ||||||
|         return OverflowStyleValue::create(maybe_x_value.release_nonnull(), maybe_y_value.release_nonnull()); |         return ShorthandStyleValue::create(PropertyID::Overflow, | ||||||
|  |             { PropertyID::OverflowX, PropertyID::OverflowY }, | ||||||
|  |             { maybe_x_value.release_nonnull(), maybe_y_value.release_nonnull() }); | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     return nullptr; |     return nullptr; | ||||||
|  |  | ||||||
|  | @ -43,7 +43,6 @@ | ||||||
| #include <LibWeb/CSS/StyleValues/LengthStyleValue.h> | #include <LibWeb/CSS/StyleValues/LengthStyleValue.h> | ||||||
| #include <LibWeb/CSS/StyleValues/MathDepthStyleValue.h> | #include <LibWeb/CSS/StyleValues/MathDepthStyleValue.h> | ||||||
| #include <LibWeb/CSS/StyleValues/NumberStyleValue.h> | #include <LibWeb/CSS/StyleValues/NumberStyleValue.h> | ||||||
| #include <LibWeb/CSS/StyleValues/OverflowStyleValue.h> |  | ||||||
| #include <LibWeb/CSS/StyleValues/PercentageStyleValue.h> | #include <LibWeb/CSS/StyleValues/PercentageStyleValue.h> | ||||||
| #include <LibWeb/CSS/StyleValues/PositionStyleValue.h> | #include <LibWeb/CSS/StyleValues/PositionStyleValue.h> | ||||||
| #include <LibWeb/CSS/StyleValues/RectStyleValue.h> | #include <LibWeb/CSS/StyleValues/RectStyleValue.h> | ||||||
|  | @ -468,13 +467,6 @@ static void set_property_expanding_shorthands(StyleProperties& style, CSS::Prope | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     if (property_id == CSS::PropertyID::Overflow) { |     if (property_id == CSS::PropertyID::Overflow) { | ||||||
|         if (value.is_overflow()) { |  | ||||||
|             auto const& overflow = value.as_overflow(); |  | ||||||
|             set_longhand_property(CSS::PropertyID::OverflowX, overflow.overflow_x()); |  | ||||||
|             set_longhand_property(CSS::PropertyID::OverflowY, overflow.overflow_y()); |  | ||||||
|             return; |  | ||||||
|         } |  | ||||||
| 
 |  | ||||||
|         set_longhand_property(CSS::PropertyID::OverflowX, value); |         set_longhand_property(CSS::PropertyID::OverflowX, value); | ||||||
|         set_longhand_property(CSS::PropertyID::OverflowY, value); |         set_longhand_property(CSS::PropertyID::OverflowY, value); | ||||||
|         return; |         return; | ||||||
|  |  | ||||||
|  | @ -38,7 +38,6 @@ | ||||||
| #include <LibWeb/CSS/StyleValues/LinearGradientStyleValue.h> | #include <LibWeb/CSS/StyleValues/LinearGradientStyleValue.h> | ||||||
| #include <LibWeb/CSS/StyleValues/MathDepthStyleValue.h> | #include <LibWeb/CSS/StyleValues/MathDepthStyleValue.h> | ||||||
| #include <LibWeb/CSS/StyleValues/NumberStyleValue.h> | #include <LibWeb/CSS/StyleValues/NumberStyleValue.h> | ||||||
| #include <LibWeb/CSS/StyleValues/OverflowStyleValue.h> |  | ||||||
| #include <LibWeb/CSS/StyleValues/PercentageStyleValue.h> | #include <LibWeb/CSS/StyleValues/PercentageStyleValue.h> | ||||||
| #include <LibWeb/CSS/StyleValues/PositionStyleValue.h> | #include <LibWeb/CSS/StyleValues/PositionStyleValue.h> | ||||||
| #include <LibWeb/CSS/StyleValues/RadialGradientStyleValue.h> | #include <LibWeb/CSS/StyleValues/RadialGradientStyleValue.h> | ||||||
|  |  | ||||||
|  | @ -110,7 +110,6 @@ using StyleValueVector = Vector<ValueComparingNonnullRefPtr<StyleValue const>>; | ||||||
|     __ENUMERATE_STYLE_VALUE_TYPE(LinearGradient, linear_gradient)          \ |     __ENUMERATE_STYLE_VALUE_TYPE(LinearGradient, linear_gradient)          \ | ||||||
|     __ENUMERATE_STYLE_VALUE_TYPE(MathDepth, math_depth)                    \ |     __ENUMERATE_STYLE_VALUE_TYPE(MathDepth, math_depth)                    \ | ||||||
|     __ENUMERATE_STYLE_VALUE_TYPE(Number, number)                           \ |     __ENUMERATE_STYLE_VALUE_TYPE(Number, number)                           \ | ||||||
|     __ENUMERATE_STYLE_VALUE_TYPE(Overflow, overflow)                       \ |  | ||||||
|     __ENUMERATE_STYLE_VALUE_TYPE(Percentage, percentage)                   \ |     __ENUMERATE_STYLE_VALUE_TYPE(Percentage, percentage)                   \ | ||||||
|     __ENUMERATE_STYLE_VALUE_TYPE(Position, position)                       \ |     __ENUMERATE_STYLE_VALUE_TYPE(Position, position)                       \ | ||||||
|     __ENUMERATE_STYLE_VALUE_TYPE(RadialGradient, radial_gradient)          \ |     __ENUMERATE_STYLE_VALUE_TYPE(RadialGradient, radial_gradient)          \ | ||||||
|  |  | ||||||
|  | @ -1,19 +0,0 @@ | ||||||
| /*
 |  | ||||||
|  * Copyright (c) 2018-2020, Andreas Kling <kling@serenityos.org> |  | ||||||
|  * Copyright (c) 2021, Tobias Christiansen <tobyase@serenityos.org> |  | ||||||
|  * Copyright (c) 2021-2023, Sam Atkins <atkinssj@serenityos.org> |  | ||||||
|  * Copyright (c) 2022-2023, MacDue <macdue@dueutil.tech> |  | ||||||
|  * |  | ||||||
|  * SPDX-License-Identifier: BSD-2-Clause |  | ||||||
|  */ |  | ||||||
| 
 |  | ||||||
| #include "OverflowStyleValue.h" |  | ||||||
| 
 |  | ||||||
| namespace Web::CSS { |  | ||||||
| 
 |  | ||||||
| String OverflowStyleValue::to_string() const |  | ||||||
| { |  | ||||||
|     return MUST(String::formatted("{} {}", m_properties.overflow_x->to_string(), m_properties.overflow_y->to_string())); |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| } |  | ||||||
|  | @ -1,45 +0,0 @@ | ||||||
| /*
 |  | ||||||
|  * Copyright (c) 2018-2020, Andreas Kling <kling@serenityos.org> |  | ||||||
|  * Copyright (c) 2021, Tobias Christiansen <tobyase@serenityos.org> |  | ||||||
|  * Copyright (c) 2021-2023, Sam Atkins <atkinssj@serenityos.org> |  | ||||||
|  * Copyright (c) 2022-2023, MacDue <macdue@dueutil.tech> |  | ||||||
|  * |  | ||||||
|  * SPDX-License-Identifier: BSD-2-Clause |  | ||||||
|  */ |  | ||||||
| 
 |  | ||||||
| #pragma once |  | ||||||
| 
 |  | ||||||
| #include <LibWeb/CSS/StyleValue.h> |  | ||||||
| 
 |  | ||||||
| namespace Web::CSS { |  | ||||||
| 
 |  | ||||||
| class OverflowStyleValue final : public StyleValueWithDefaultOperators<OverflowStyleValue> { |  | ||||||
| public: |  | ||||||
|     static ValueComparingNonnullRefPtr<OverflowStyleValue> create(ValueComparingNonnullRefPtr<StyleValue> overflow_x, ValueComparingNonnullRefPtr<StyleValue> overflow_y) |  | ||||||
|     { |  | ||||||
|         return adopt_ref(*new (nothrow) OverflowStyleValue(move(overflow_x), move(overflow_y))); |  | ||||||
|     } |  | ||||||
|     virtual ~OverflowStyleValue() override = default; |  | ||||||
| 
 |  | ||||||
|     ValueComparingNonnullRefPtr<StyleValue> overflow_x() const { return m_properties.overflow_x; } |  | ||||||
|     ValueComparingNonnullRefPtr<StyleValue> overflow_y() const { return m_properties.overflow_y; } |  | ||||||
| 
 |  | ||||||
|     virtual String to_string() const override; |  | ||||||
| 
 |  | ||||||
|     bool properties_equal(OverflowStyleValue const& other) const { return m_properties == other.m_properties; } |  | ||||||
| 
 |  | ||||||
| private: |  | ||||||
|     OverflowStyleValue(ValueComparingNonnullRefPtr<StyleValue> overflow_x, ValueComparingNonnullRefPtr<StyleValue> overflow_y) |  | ||||||
|         : StyleValueWithDefaultOperators(Type::Overflow) |  | ||||||
|         , m_properties { .overflow_x = move(overflow_x), .overflow_y = move(overflow_y) } |  | ||||||
|     { |  | ||||||
|     } |  | ||||||
| 
 |  | ||||||
|     struct Properties { |  | ||||||
|         ValueComparingNonnullRefPtr<StyleValue> overflow_x; |  | ||||||
|         ValueComparingNonnullRefPtr<StyleValue> overflow_y; |  | ||||||
|         bool operator==(Properties const&) const = default; |  | ||||||
|     } m_properties; |  | ||||||
| }; |  | ||||||
| 
 |  | ||||||
| } |  | ||||||
|  | @ -161,6 +161,8 @@ String ShorthandStyleValue::to_string() const | ||||||
|     } |     } | ||||||
|     case PropertyID::ListStyle: |     case PropertyID::ListStyle: | ||||||
|         return MUST(String::formatted("{} {} {}", longhand(PropertyID::ListStylePosition)->to_string(), longhand(PropertyID::ListStyleImage)->to_string(), longhand(PropertyID::ListStyleType)->to_string())); |         return MUST(String::formatted("{} {} {}", longhand(PropertyID::ListStylePosition)->to_string(), longhand(PropertyID::ListStyleImage)->to_string(), longhand(PropertyID::ListStyleType)->to_string())); | ||||||
|  |     case PropertyID::Overflow: | ||||||
|  |         return MUST(String::formatted("{} {}", longhand(PropertyID::OverflowX)->to_string(), longhand(PropertyID::OverflowY)->to_string())); | ||||||
|     case PropertyID::PlaceContent: { |     case PropertyID::PlaceContent: { | ||||||
|         auto align_content = longhand(PropertyID::AlignContent)->to_string(); |         auto align_content = longhand(PropertyID::AlignContent)->to_string(); | ||||||
|         auto justify_content = longhand(PropertyID::JustifyContent)->to_string(); |         auto justify_content = longhand(PropertyID::JustifyContent)->to_string(); | ||||||
|  |  | ||||||
|  | @ -134,7 +134,6 @@ class MediaQueryList; | ||||||
| class MediaQueryListEvent; | class MediaQueryListEvent; | ||||||
| class Number; | class Number; | ||||||
| class NumberStyleValue; | class NumberStyleValue; | ||||||
| class OverflowStyleValue; |  | ||||||
| class Percentage; | class Percentage; | ||||||
| class PercentageOrCalculated; | class PercentageOrCalculated; | ||||||
| class PercentageStyleValue; | class PercentageStyleValue; | ||||||
|  |  | ||||||
|  | @ -8,7 +8,7 @@ | ||||||
| #include <LibWeb/CSS/StyleProperties.h> | #include <LibWeb/CSS/StyleProperties.h> | ||||||
| #include <LibWeb/CSS/StyleValues/DisplayStyleValue.h> | #include <LibWeb/CSS/StyleValues/DisplayStyleValue.h> | ||||||
| #include <LibWeb/CSS/StyleValues/IdentifierStyleValue.h> | #include <LibWeb/CSS/StyleValues/IdentifierStyleValue.h> | ||||||
| #include <LibWeb/CSS/StyleValues/OverflowStyleValue.h> | #include <LibWeb/CSS/StyleValues/ShorthandStyleValue.h> | ||||||
| #include <LibWeb/DOM/ShadowRoot.h> | #include <LibWeb/DOM/ShadowRoot.h> | ||||||
| #include <LibWeb/Layout/Box.h> | #include <LibWeb/Layout/Box.h> | ||||||
| #include <LibWeb/SVG/AttributeNames.h> | #include <LibWeb/SVG/AttributeNames.h> | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Sam Atkins
						Sam Atkins