From add3a095d8ef6682e7ccfca1dc4508d7db26d664 Mon Sep 17 00:00:00 2001 From: InvalidUsernameException Date: Fri, 18 Jul 2025 20:36:09 +0200 Subject: [PATCH] LibWeb/CSS: Rename background-repeat related symbols to align with spec These will be used for the mask-repeat property as well in an upcoming commit, hence the more generic names. Also, this more closely matches the names used in the spec. --- Libraries/LibWeb/CMakeLists.txt | 2 +- Libraries/LibWeb/CSS/CSSStyleValue.cpp | 8 +- Libraries/LibWeb/CSS/CSSStyleValue.h | 12 +- Libraries/LibWeb/CSS/ComputedValues.h | 4 +- Libraries/LibWeb/CSS/Enums.json | 2 +- Libraries/LibWeb/CSS/Parser/Parser.h | 2 +- .../LibWeb/CSS/Parser/PropertyParsing.cpp | 131 +++++++++--------- Libraries/LibWeb/CSS/Parser/ValueParsing.cpp | 2 +- Libraries/LibWeb/CSS/Properties.json | 2 +- .../StyleValues/BackgroundRepeatStyleValue.h | 42 ------ ...yleValue.cpp => RepeatStyleStyleValue.cpp} | 14 +- .../CSS/StyleValues/RepeatStyleStyleValue.h | 42 ++++++ Libraries/LibWeb/Forward.h | 2 +- Libraries/LibWeb/Layout/Node.cpp | 8 +- .../LibWeb/Painting/BackgroundPainting.cpp | 22 +-- .../LibWeb/Painting/BackgroundPainting.h | 4 +- .../Libraries/LibWeb/CSS/StyleValues/BUILD.gn | 2 +- 17 files changed, 151 insertions(+), 150 deletions(-) delete mode 100644 Libraries/LibWeb/CSS/StyleValues/BackgroundRepeatStyleValue.h rename Libraries/LibWeb/CSS/StyleValues/{BackgroundRepeatStyleValue.cpp => RepeatStyleStyleValue.cpp} (59%) create mode 100644 Libraries/LibWeb/CSS/StyleValues/RepeatStyleStyleValue.h diff --git a/Libraries/LibWeb/CMakeLists.txt b/Libraries/LibWeb/CMakeLists.txt index 4f2a13c23ed..8c94976c276 100644 --- a/Libraries/LibWeb/CMakeLists.txt +++ b/Libraries/LibWeb/CMakeLists.txt @@ -182,7 +182,6 @@ set(SOURCES CSS/StyleValues/AnchorStyleValue.cpp CSS/StyleValues/AnchorSizeStyleValue.cpp CSS/StyleValues/AngleStyleValue.cpp - CSS/StyleValues/BackgroundRepeatStyleValue.cpp CSS/StyleValues/BackgroundSizeStyleValue.cpp CSS/StyleValues/BasicShapeStyleValue.cpp CSS/StyleValues/BorderImageSliceStyleValue.cpp @@ -224,6 +223,7 @@ set(SOURCES CSS/StyleValues/PositionStyleValue.cpp CSS/StyleValues/RadialGradientStyleValue.cpp CSS/StyleValues/RectStyleValue.cpp + CSS/StyleValues/RepeatStyleStyleValue.cpp CSS/StyleValues/ScrollbarColorStyleValue.cpp CSS/StyleValues/ShadowStyleValue.cpp CSS/StyleValues/ShorthandStyleValue.cpp diff --git a/Libraries/LibWeb/CSS/CSSStyleValue.cpp b/Libraries/LibWeb/CSS/CSSStyleValue.cpp index 907e7275976..d1d4f862b90 100644 --- a/Libraries/LibWeb/CSS/CSSStyleValue.cpp +++ b/Libraries/LibWeb/CSS/CSSStyleValue.cpp @@ -16,7 +16,6 @@ #include #include #include -#include #include #include #include @@ -58,6 +57,7 @@ #include #include #include +#include #include #include #include @@ -128,10 +128,10 @@ AngleStyleValue const& CSSStyleValue::as_angle() const return static_cast(*this); } -BackgroundRepeatStyleValue const& CSSStyleValue::as_background_repeat() const +RepeatStyleStyleValue const& CSSStyleValue::as_repeat_style() const { - VERIFY(is_background_repeat()); - return static_cast(*this); + VERIFY(is_repeat_style()); + return static_cast(*this); } BackgroundSizeStyleValue const& CSSStyleValue::as_background_size() const diff --git a/Libraries/LibWeb/CSS/CSSStyleValue.h b/Libraries/LibWeb/CSS/CSSStyleValue.h index 675a650df23..c4b4270a7fe 100644 --- a/Libraries/LibWeb/CSS/CSSStyleValue.h +++ b/Libraries/LibWeb/CSS/CSSStyleValue.h @@ -102,10 +102,9 @@ public: Anchor, AnchorSize, Angle, - BackgroundRepeat, BackgroundSize, - BorderImageSlice, BasicShape, + BorderImageSlice, BorderRadius, Calculated, Color, @@ -144,6 +143,7 @@ public: RadialGradient, Ratio, Rect, + RepeatStyle, Resolution, ScrollbarColor, ScrollbarGutter, @@ -180,10 +180,6 @@ public: AngleStyleValue const& as_angle() const; AngleStyleValue& as_angle() { return const_cast(const_cast(*this).as_angle()); } - bool is_background_repeat() const { return type() == Type::BackgroundRepeat; } - BackgroundRepeatStyleValue const& as_background_repeat() const; - BackgroundRepeatStyleValue& as_background_repeat() { return const_cast(const_cast(*this).as_background_repeat()); } - bool is_background_size() const { return type() == Type::BackgroundSize; } BackgroundSizeStyleValue const& as_background_size() const; BackgroundSizeStyleValue& as_background_size() { return const_cast(const_cast(*this).as_background_size()); } @@ -349,6 +345,10 @@ public: RectStyleValue const& as_rect() const; RectStyleValue& as_rect() { return const_cast(const_cast(*this).as_rect()); } + bool is_repeat_style() const { return type() == Type::RepeatStyle; } + RepeatStyleStyleValue const& as_repeat_style() const; + RepeatStyleStyleValue& as_repeat_style() { return const_cast(const_cast(*this).as_repeat_style()); } + bool is_resolution() const { return type() == Type::Resolution; } ResolutionStyleValue const& as_resolution() const; ResolutionStyleValue& as_resolution() { return const_cast(const_cast(*this).as_resolution()); } diff --git a/Libraries/LibWeb/CSS/ComputedValues.h b/Libraries/LibWeb/CSS/ComputedValues.h index 087e6a59ca6..aa8c04a2a48 100644 --- a/Libraries/LibWeb/CSS/ComputedValues.h +++ b/Libraries/LibWeb/CSS/ComputedValues.h @@ -314,8 +314,8 @@ struct BackgroundLayerData { CSS::BackgroundSize size_type { CSS::BackgroundSize::LengthPercentage }; CSS::LengthPercentage size_x { CSS::Length::make_auto() }; CSS::LengthPercentage size_y { CSS::Length::make_auto() }; - CSS::Repeat repeat_x { CSS::Repeat::Repeat }; - CSS::Repeat repeat_y { CSS::Repeat::Repeat }; + CSS::Repetition repeat_x { CSS::Repetition::Repeat }; + CSS::Repetition repeat_y { CSS::Repetition::Repeat }; CSS::MixBlendMode blend_mode { CSS::MixBlendMode::Normal }; }; diff --git a/Libraries/LibWeb/CSS/Enums.json b/Libraries/LibWeb/CSS/Enums.json index caa19939a24..12980d5ccbd 100644 --- a/Libraries/LibWeb/CSS/Enums.json +++ b/Libraries/LibWeb/CSS/Enums.json @@ -597,7 +597,7 @@ "strict-origin-when-cross-origin", "unsafe-url" ], - "repeat": [ + "repetition": [ "no-repeat", "repeat", "round", diff --git a/Libraries/LibWeb/CSS/Parser/Parser.h b/Libraries/LibWeb/CSS/Parser/Parser.h index 5b631bfb364..afa51453cd9 100644 --- a/Libraries/LibWeb/CSS/Parser/Parser.h +++ b/Libraries/LibWeb/CSS/Parser/Parser.h @@ -421,7 +421,6 @@ private: RefPtr parse_aspect_ratio_value(TokenStream&); RefPtr parse_background_value(TokenStream&); RefPtr parse_single_background_position_x_or_y_value(TokenStream&, PropertyID); - RefPtr parse_single_background_repeat_value(TokenStream&); RefPtr parse_single_background_size_value(TokenStream&); RefPtr parse_border_value(PropertyID, TokenStream&); RefPtr parse_border_image_value(TokenStream&); @@ -458,6 +457,7 @@ private: RefPtr parse_place_items_value(TokenStream&); RefPtr parse_place_self_value(TokenStream&); RefPtr parse_quotes_value(TokenStream&); + RefPtr parse_single_repeat_style_value(PropertyID, TokenStream&); RefPtr parse_scrollbar_color_value(TokenStream&); RefPtr parse_scrollbar_gutter_value(TokenStream&); enum class AllowInsetKeyword { diff --git a/Libraries/LibWeb/CSS/Parser/PropertyParsing.cpp b/Libraries/LibWeb/CSS/Parser/PropertyParsing.cpp index ce25ea811d5..a4d5b634653 100644 --- a/Libraries/LibWeb/CSS/Parser/PropertyParsing.cpp +++ b/Libraries/LibWeb/CSS/Parser/PropertyParsing.cpp @@ -20,7 +20,6 @@ #include #include #include -#include #include #include #include @@ -50,6 +49,7 @@ #include #include #include +#include #include #include #include @@ -476,7 +476,7 @@ Parser::ParseErrorOr> Parser::parse_css_value return parsed_value.release_nonnull(); return ParseError::SyntaxError; case PropertyID::BackgroundRepeat: - if (auto parsed_value = parse_comma_separated_value_list(tokens, [this](auto& tokens) { return parse_single_background_repeat_value(tokens); })) + if (auto parsed_value = parse_comma_separated_value_list(tokens, [this, property_id](auto& tokens) { return parse_single_repeat_style_value(property_id, tokens); })) return parsed_value.release_nonnull(); return ParseError::SyntaxError; case PropertyID::BackgroundSize: @@ -1252,9 +1252,10 @@ RefPtr Parser::parse_background_value(TokenStreamstyle_value; - remove_property(remaining_layer_properties, value_and_property->property); + auto property = value_and_property->property; + remove_property(remaining_layer_properties, property); - switch (value_and_property->property) { + switch (property) { case PropertyID::BackgroundAttachment: VERIFY(!background_attachment); background_attachment = value.release_nonnull(); @@ -1306,7 +1307,7 @@ RefPtr Parser::parse_background_value(TokenStream Parser::parse_single_background_position_x_or_y_valu return EdgeStyleValue::create(relative_edge, {}); } -RefPtr Parser::parse_single_background_repeat_value(TokenStream& tokens) -{ - auto transaction = tokens.begin_transaction(); - - auto is_directional_repeat = [](CSSStyleValue const& value) -> bool { - auto keyword = value.to_keyword(); - return keyword == Keyword::RepeatX || keyword == Keyword::RepeatY; - }; - - auto as_repeat = [](Keyword keyword) -> Optional { - switch (keyword) { - case Keyword::NoRepeat: - return Repeat::NoRepeat; - case Keyword::Repeat: - return Repeat::Repeat; - case Keyword::Round: - return Repeat::Round; - case Keyword::Space: - return Repeat::Space; - default: - return {}; - } - }; - - auto maybe_x_value = parse_css_value_for_property(PropertyID::BackgroundRepeat, tokens); - if (!maybe_x_value) - return nullptr; - auto x_value = maybe_x_value.release_nonnull(); - - if (is_directional_repeat(*x_value)) { - auto keyword = x_value->to_keyword(); - transaction.commit(); - return BackgroundRepeatStyleValue::create( - keyword == Keyword::RepeatX ? Repeat::Repeat : Repeat::NoRepeat, - keyword == Keyword::RepeatX ? Repeat::NoRepeat : Repeat::Repeat); - } - - auto x_repeat = as_repeat(x_value->to_keyword()); - if (!x_repeat.has_value()) - return nullptr; - - // See if we have a second value for Y - auto maybe_y_value = parse_css_value_for_property(PropertyID::BackgroundRepeat, tokens); - if (!maybe_y_value) { - // We don't have a second value, so use x for both - transaction.commit(); - return BackgroundRepeatStyleValue::create(x_repeat.value(), x_repeat.value()); - } - auto y_value = maybe_y_value.release_nonnull(); - if (is_directional_repeat(*y_value)) - return nullptr; - - auto y_repeat = as_repeat(y_value->to_keyword()); - if (!y_repeat.has_value()) - return nullptr; - - transaction.commit(); - return BackgroundRepeatStyleValue::create(x_repeat.value(), y_repeat.value()); -} - RefPtr Parser::parse_single_background_size_value(TokenStream& tokens) { auto transaction = tokens.begin_transaction(); @@ -3764,6 +3705,66 @@ RefPtr Parser::parse_quotes_value(TokenStream Parser::parse_single_repeat_style_value(PropertyID property, TokenStream& tokens) +{ + auto transaction = tokens.begin_transaction(); + + auto is_directional_repeat = [](CSSStyleValue const& value) -> bool { + auto keyword = value.to_keyword(); + return keyword == Keyword::RepeatX || keyword == Keyword::RepeatY; + }; + + auto as_repeat = [](Keyword keyword) -> Optional { + switch (keyword) { + case Keyword::NoRepeat: + return Repetition::NoRepeat; + case Keyword::Repeat: + return Repetition::Repeat; + case Keyword::Round: + return Repetition::Round; + case Keyword::Space: + return Repetition::Space; + default: + return {}; + } + }; + + auto maybe_x_value = parse_css_value_for_property(property, tokens); + if (!maybe_x_value) + return nullptr; + auto x_value = maybe_x_value.release_nonnull(); + + if (is_directional_repeat(*x_value)) { + auto keyword = x_value->to_keyword(); + transaction.commit(); + return RepeatStyleStyleValue::create( + keyword == Keyword::RepeatX ? Repetition::Repeat : Repetition::NoRepeat, + keyword == Keyword::RepeatX ? Repetition::NoRepeat : Repetition::Repeat); + } + + auto x_repeat = as_repeat(x_value->to_keyword()); + if (!x_repeat.has_value()) + return nullptr; + + // See if we have a second value for Y + auto maybe_y_value = parse_css_value_for_property(property, tokens); + if (!maybe_y_value) { + // We don't have a second value, so use x for both + transaction.commit(); + return RepeatStyleStyleValue::create(x_repeat.value(), x_repeat.value()); + } + auto y_value = maybe_y_value.release_nonnull(); + if (is_directional_repeat(*y_value)) + return nullptr; + + auto y_repeat = as_repeat(y_value->to_keyword()); + if (!y_repeat.has_value()) + return nullptr; + + transaction.commit(); + return RepeatStyleStyleValue::create(x_repeat.value(), y_repeat.value()); +} + RefPtr Parser::parse_text_decoration_value(TokenStream& tokens) { RefPtr decoration_line; diff --git a/Libraries/LibWeb/CSS/Parser/ValueParsing.cpp b/Libraries/LibWeb/CSS/Parser/ValueParsing.cpp index 068552f9572..0acb5c586e1 100644 --- a/Libraries/LibWeb/CSS/Parser/ValueParsing.cpp +++ b/Libraries/LibWeb/CSS/Parser/ValueParsing.cpp @@ -25,7 +25,6 @@ #include #include #include -#include #include #include #include @@ -61,6 +60,7 @@ #include #include #include +#include #include #include #include diff --git a/Libraries/LibWeb/CSS/Properties.json b/Libraries/LibWeb/CSS/Properties.json index 30a4290f896..a8128308056 100644 --- a/Libraries/LibWeb/CSS/Properties.json +++ b/Libraries/LibWeb/CSS/Properties.json @@ -459,7 +459,7 @@ "initial": "repeat", "max-values": 2, "valid-types": [ - "repeat" + "repetition" ], "valid-identifiers": [ "repeat-x", diff --git a/Libraries/LibWeb/CSS/StyleValues/BackgroundRepeatStyleValue.h b/Libraries/LibWeb/CSS/StyleValues/BackgroundRepeatStyleValue.h deleted file mode 100644 index 4686d862682..00000000000 --- a/Libraries/LibWeb/CSS/StyleValues/BackgroundRepeatStyleValue.h +++ /dev/null @@ -1,42 +0,0 @@ -/* - * 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 BackgroundRepeatStyleValue final : public StyleValueWithDefaultOperators { -public: - static ValueComparingNonnullRefPtr create(Repeat repeat_x, Repeat repeat_y) - { - return adopt_ref(*new (nothrow) BackgroundRepeatStyleValue(repeat_x, repeat_y)); - } - virtual ~BackgroundRepeatStyleValue() override; - - Repeat repeat_x() const { return m_properties.repeat_x; } - Repeat repeat_y() const { return m_properties.repeat_y; } - - virtual String to_string(SerializationMode) const override; - - bool properties_equal(BackgroundRepeatStyleValue const& other) const { return m_properties == other.m_properties; } - -private: - BackgroundRepeatStyleValue(Repeat repeat_x, Repeat repeat_y); - - struct Properties { - Repeat repeat_x; - Repeat repeat_y; - bool operator==(Properties const&) const = default; - } m_properties; -}; - -} diff --git a/Libraries/LibWeb/CSS/StyleValues/BackgroundRepeatStyleValue.cpp b/Libraries/LibWeb/CSS/StyleValues/RepeatStyleStyleValue.cpp similarity index 59% rename from Libraries/LibWeb/CSS/StyleValues/BackgroundRepeatStyleValue.cpp rename to Libraries/LibWeb/CSS/StyleValues/RepeatStyleStyleValue.cpp index 6bdfbe680c0..8996749502b 100644 --- a/Libraries/LibWeb/CSS/StyleValues/BackgroundRepeatStyleValue.cpp +++ b/Libraries/LibWeb/CSS/StyleValues/RepeatStyleStyleValue.cpp @@ -7,27 +7,27 @@ * SPDX-License-Identifier: BSD-2-Clause */ -#include "BackgroundRepeatStyleValue.h" +#include "RepeatStyleStyleValue.h" #include namespace Web::CSS { -BackgroundRepeatStyleValue::BackgroundRepeatStyleValue(Repeat repeat_x, Repeat repeat_y) - : StyleValueWithDefaultOperators(Type::BackgroundRepeat) +RepeatStyleStyleValue::RepeatStyleStyleValue(Repetition repeat_x, Repetition repeat_y) + : StyleValueWithDefaultOperators(Type::RepeatStyle) , m_properties { .repeat_x = repeat_x, .repeat_y = repeat_y } { } -BackgroundRepeatStyleValue::~BackgroundRepeatStyleValue() = default; +RepeatStyleStyleValue::~RepeatStyleStyleValue() = default; -String BackgroundRepeatStyleValue::to_string(SerializationMode) const +String RepeatStyleStyleValue::to_string(SerializationMode) const { if (m_properties.repeat_x == m_properties.repeat_y) return MUST(String::from_utf8(CSS::to_string(m_properties.repeat_x))); - if (m_properties.repeat_x == Repeat::Repeat && m_properties.repeat_y == Repeat::NoRepeat) + if (m_properties.repeat_x == Repetition::Repeat && m_properties.repeat_y == Repetition::NoRepeat) return "repeat-x"_string; - if (m_properties.repeat_x == Repeat::NoRepeat && m_properties.repeat_y == Repeat::Repeat) + if (m_properties.repeat_x == Repetition::NoRepeat && m_properties.repeat_y == Repetition::Repeat) return "repeat-y"_string; return MUST(String::formatted("{} {}", CSS::to_string(m_properties.repeat_x), CSS::to_string(m_properties.repeat_y))); diff --git a/Libraries/LibWeb/CSS/StyleValues/RepeatStyleStyleValue.h b/Libraries/LibWeb/CSS/StyleValues/RepeatStyleStyleValue.h new file mode 100644 index 00000000000..ccb2ff1789c --- /dev/null +++ b/Libraries/LibWeb/CSS/StyleValues/RepeatStyleStyleValue.h @@ -0,0 +1,42 @@ +/* + * 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 RepeatStyleStyleValue final : public StyleValueWithDefaultOperators { +public: + static ValueComparingNonnullRefPtr create(Repetition repeat_x, Repetition repeat_y) + { + return adopt_ref(*new (nothrow) RepeatStyleStyleValue(repeat_x, repeat_y)); + } + virtual ~RepeatStyleStyleValue() override; + + Repetition repeat_x() const { return m_properties.repeat_x; } + Repetition repeat_y() const { return m_properties.repeat_y; } + + virtual String to_string(SerializationMode) const override; + + bool properties_equal(RepeatStyleStyleValue const& other) const { return m_properties == other.m_properties; } + +private: + RepeatStyleStyleValue(Repetition repeat_x, Repetition repeat_y); + + struct Properties { + Repetition repeat_x; + Repetition repeat_y; + bool operator==(Properties const&) const = default; + } m_properties; +}; + +} diff --git a/Libraries/LibWeb/Forward.h b/Libraries/LibWeb/Forward.h index 2646bc39467..b3c585d3489 100644 --- a/Libraries/LibWeb/Forward.h +++ b/Libraries/LibWeb/Forward.h @@ -198,7 +198,6 @@ class Angle; class AngleOrCalculated; class AnglePercentage; class AngleStyleValue; -class BackgroundRepeatStyleValue; class BackgroundSizeStyleValue; class BasicShapeStyleValue; class BorderImageSliceStyleValue; @@ -307,6 +306,7 @@ class RadialGradientStyleValue; class Ratio; class RatioStyleValue; class RectStyleValue; +class RepeatStyleStyleValue; class Resolution; class ResolutionOrCalculated; class ResolutionStyleValue; diff --git a/Libraries/LibWeb/Layout/Node.cpp b/Libraries/LibWeb/Layout/Node.cpp index bdad234fa70..cf87f4dec0c 100644 --- a/Libraries/LibWeb/Layout/Node.cpp +++ b/Libraries/LibWeb/Layout/Node.cpp @@ -9,7 +9,6 @@ #include #include #include -#include #include #include #include @@ -18,6 +17,7 @@ #include #include #include +#include #include #include #include @@ -510,9 +510,9 @@ void NodeWithStyle::apply_style(CSS::ComputedProperties const& computed_style) } } - if (auto repeat_value = value_for_layer(repeats, layer_index); repeat_value && repeat_value->is_background_repeat()) { - layer.repeat_x = repeat_value->as_background_repeat().repeat_x(); - layer.repeat_y = repeat_value->as_background_repeat().repeat_y(); + if (auto repeat_value = value_for_layer(repeats, layer_index); repeat_value && repeat_value->is_repeat_style()) { + layer.repeat_x = repeat_value->as_repeat_style().repeat_x(); + layer.repeat_y = repeat_value->as_repeat_style().repeat_y(); } layer.blend_mode = CSS::keyword_to_mix_blend_mode(value_for_layer(background_blend_modes, layer_index)->to_keyword()).value_or(CSS::MixBlendMode::Normal); diff --git a/Libraries/LibWeb/Painting/BackgroundPainting.cpp b/Libraries/LibWeb/Painting/BackgroundPainting.cpp index d0766b7e367..f7a42387e36 100644 --- a/Libraries/LibWeb/Painting/BackgroundPainting.cpp +++ b/Libraries/LibWeb/Painting/BackgroundPainting.cpp @@ -204,11 +204,11 @@ void paint_background(DisplayListRecordingContext& context, PaintableBox const& CSSPixels y_step = 0; switch (layer.repeat_x) { - case CSS::Repeat::Round: + case CSS::Repetition::Round: x_step = image_rect.width(); repeat_x = true; break; - case CSS::Repeat::Space: { + case CSS::Repetition::Space: { int whole_images = (background_positioning_area.width() / image_rect.width()).to_int(); if (whole_images <= 1) { x_step = image_rect.width(); @@ -221,11 +221,11 @@ void paint_background(DisplayListRecordingContext& context, PaintableBox const& } break; } - case CSS::Repeat::Repeat: + case CSS::Repetition::Repeat: x_step = image_rect.width(); repeat_x = true; break; - case CSS::Repeat::NoRepeat: + case CSS::Repetition::NoRepeat: repeat_x = false; break; } @@ -236,11 +236,11 @@ void paint_background(DisplayListRecordingContext& context, PaintableBox const& } switch (layer.repeat_y) { - case CSS::Repeat::Round: + case CSS::Repetition::Round: y_step = image_rect.height(); repeat_y = true; break; - case CSS::Repeat::Space: { + case CSS::Repetition::Space: { int whole_images = (background_positioning_area.height() / image_rect.height()).to_int(); if (whole_images <= 1) { y_step = image_rect.height(); @@ -253,11 +253,11 @@ void paint_background(DisplayListRecordingContext& context, PaintableBox const& } break; } - case CSS::Repeat::Repeat: + case CSS::Repetition::Repeat: y_step = image_rect.height(); repeat_y = true; break; - case CSS::Repeat::NoRepeat: + case CSS::Repetition::NoRepeat: repeat_y = false; break; } @@ -417,15 +417,15 @@ ResolvedBackground resolve_background_layers(Vector co // If background-repeat is round for one (or both) dimensions, there is a second step. // The UA must scale the image in that dimension (or both dimensions) so that it fits a // whole number of times in the background positioning area. - if (layer.repeat_x == CSS::Repeat::Round || layer.repeat_y == CSS::Repeat::Round) { + if (layer.repeat_x == CSS::Repetition::Round || layer.repeat_y == CSS::Repetition::Round) { // If X ≠ 0 is the width of the image after step one and W is the width of the // background positioning area, then the rounded width X' = W / round(W / X) // where round() is a function that returns the nearest natural number // (integer greater than zero). - if (layer.repeat_x == CSS::Repeat::Round) { + if (layer.repeat_x == CSS::Repetition::Round) { image_rect.set_width(background_positioning_area.width() / round(background_positioning_area.width() / image_rect.width())); } - if (layer.repeat_y == CSS::Repeat::Round) { + if (layer.repeat_y == CSS::Repetition::Round) { image_rect.set_height(background_positioning_area.height() / round(background_positioning_area.height() / image_rect.height())); } diff --git a/Libraries/LibWeb/Painting/BackgroundPainting.h b/Libraries/LibWeb/Painting/BackgroundPainting.h index aaba876eb85..7928cccf19c 100644 --- a/Libraries/LibWeb/Painting/BackgroundPainting.h +++ b/Libraries/LibWeb/Painting/BackgroundPainting.h @@ -21,8 +21,8 @@ struct ResolvedBackgroundLayerData { CSSPixels offset_y; CSSPixelRect background_positioning_area; CSSPixelRect image_rect; - CSS::Repeat repeat_x; - CSS::Repeat repeat_y; + CSS::Repetition repeat_x; + CSS::Repetition repeat_y; CSS::MixBlendMode blend_mode; }; 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 f445d0d69a3..d2182cd5c1d 100644 --- a/Meta/gn/secondary/Userland/Libraries/LibWeb/CSS/StyleValues/BUILD.gn +++ b/Meta/gn/secondary/Userland/Libraries/LibWeb/CSS/StyleValues/BUILD.gn @@ -3,7 +3,6 @@ source_set("StyleValues") { deps = [ "//Userland/Libraries/LibWeb:all_generated" ] sources = [ "AngleStyleValue.cpp", - "BackgroundRepeatStyleValue.cpp", "BackgroundSizeStyleValue.cpp", "BasicShapeStyleValue.cpp", "BorderRadiusStyleValue.cpp", @@ -39,6 +38,7 @@ source_set("StyleValues") { "PositionStyleValue.cpp", "RadialGradientStyleValue.cpp", "RectStyleValue.cpp", + "RepeatStyleStyleValue.cpp", "ShadowStyleValue.cpp", "ShorthandStyleValue.cpp", "StyleValueList.cpp",