From 3676f5085e3afe545f20fb6c7c0e03f2212091ca Mon Sep 17 00:00:00 2001 From: MacDue Date: Mon, 20 Feb 2023 00:41:51 +0000 Subject: [PATCH] LibWeb: Replace `RefPtr` with `ValueComparingRefPtr` in StyleValue Like the name suggests this pointer type compares its pointees by value rather than just by the pointer. This is needed for the defaulted struct Properties equality operator. This commit also contains a few changes to StyleValue such as replacing the operator==()s with a .equals() again. This is done to avoid the new reversed operator==()s ambiguity in C++20. --- .../Libraries/LibWeb/CSS/Parser/Parser.cpp | 32 +- .../CSS/ResolvedCSSStyleDeclaration.cpp | 14 +- Userland/Libraries/LibWeb/CSS/StyleValue.cpp | 52 +- Userland/Libraries/LibWeb/CSS/StyleValue.h | 542 ++++++++++-------- 4 files changed, 351 insertions(+), 289 deletions(-) diff --git a/Userland/Libraries/LibWeb/CSS/Parser/Parser.cpp b/Userland/Libraries/LibWeb/CSS/Parser/Parser.cpp index 76b4580efc..c2fefa1638 100644 --- a/Userland/Libraries/LibWeb/CSS/Parser/Parser.cpp +++ b/Userland/Libraries/LibWeb/CSS/Parser/Parser.cpp @@ -3997,7 +3997,7 @@ RefPtr Parser::parse_comma_separated_value_list(Vector values; + StyleValueVector values; values.append(first.release_nonnull()); while (tokens.has_next_token()) { @@ -4027,13 +4027,13 @@ RefPtr Parser::parse_simple_comma_separated_value_list(Vector Parser::parse_background_value(Vector const& component_values) { - NonnullRefPtrVector background_images; - NonnullRefPtrVector background_positions; - NonnullRefPtrVector background_sizes; - NonnullRefPtrVector background_repeats; - NonnullRefPtrVector background_attachments; - NonnullRefPtrVector background_clips; - NonnullRefPtrVector background_origins; + StyleValueVector background_images; + StyleValueVector background_positions; + StyleValueVector background_sizes; + StyleValueVector background_repeats; + StyleValueVector background_attachments; + StyleValueVector background_clips; + StyleValueVector background_origins; RefPtr background_color; // Per-layer values @@ -4778,8 +4778,8 @@ RefPtr Parser::parse_content_value(Vector const& com } } - NonnullRefPtrVector content_values; - NonnullRefPtrVector alt_text_values; + StyleValueVector content_values; + StyleValueVector alt_text_values; bool in_alt_text = false; for (auto const& value : component_values) { @@ -5239,7 +5239,7 @@ RefPtr Parser::parse_font_family_value(Vector const& // eg, these are equivalent: // font-family: my cool font\!, serif; // font-family: "my cool font!", serif; - NonnullRefPtrVector font_families; + StyleValueVector font_families; Vector current_name_parts; for (size_t i = start_index; i < component_values.size(); ++i) { auto const& part = component_values[i]; @@ -5642,7 +5642,7 @@ RefPtr Parser::parse_text_decoration_value(Vector co RefPtr Parser::parse_text_decoration_line_value(TokenStream& tokens) { - NonnullRefPtrVector style_values; + StyleValueVector style_values; while (tokens.has_next_token()) { auto const& token = tokens.next_token(); @@ -5681,7 +5681,7 @@ RefPtr Parser::parse_text_decoration_line_value(TokenStream Parser::parse_transform_value(Vector const& component_values) { - NonnullRefPtrVector transformations; + StyleValueVector transformations; auto tokens = TokenStream { component_values }; tokens.skip_whitespace(); @@ -5706,7 +5706,7 @@ RefPtr Parser::parse_transform_value(Vector const& c auto function = maybe_function.release_value(); auto function_metadata = transform_function_metadata(function); - NonnullRefPtrVector values; + StyleValueVector values; auto argument_tokens = TokenStream { part.function().values() }; argument_tokens.skip_whitespace(); size_t argument_index = 0; @@ -5851,7 +5851,7 @@ RefPtr Parser::parse_transform_origin_value(Vector c }; auto make_list = [](NonnullRefPtr const& x_value, NonnullRefPtr const& y_value) -> NonnullRefPtr { - NonnullRefPtrVector values; + StyleValueVector values; values.append(x_value); values.append(y_value); return StyleValueList::create(move(values), StyleValueList::Separator::Space); @@ -6615,7 +6615,7 @@ Parser::ParseErrorOr> Parser::parse_css_value(Property // We have multiple values, so treat them as a StyleValueList. if (property_maximum_value_count(property_id) > 1) { - NonnullRefPtrVector parsed_values; + StyleValueVector parsed_values; for (auto& component_value : component_values) { auto parsed_value = parse_css_value(component_value); if (!parsed_value || !property_accepts_value(property_id, *parsed_value)) diff --git a/Userland/Libraries/LibWeb/CSS/ResolvedCSSStyleDeclaration.cpp b/Userland/Libraries/LibWeb/CSS/ResolvedCSSStyleDeclaration.cpp index f3dcc9ac2d..190916e5db 100644 --- a/Userland/Libraries/LibWeb/CSS/ResolvedCSSStyleDeclaration.cpp +++ b/Userland/Libraries/LibWeb/CSS/ResolvedCSSStyleDeclaration.cpp @@ -54,7 +54,7 @@ static RefPtr style_value_for_display(CSS::Display display) return IdentifierStyleValue::create(CSS::ValueID::None); if (display.is_outside_and_inside()) { - NonnullRefPtrVector values; + StyleValueVector values; switch (display.outside()) { case CSS::Display::Outside::Inline: values.append(IdentifierStyleValue::create(CSS::ValueID::Inline)); @@ -288,7 +288,7 @@ RefPtr ResolvedCSSStyleDeclaration::style_value_for_property(Layout: if (box_shadow_layers.size() == 1) return make_box_shadow_style_value(box_shadow_layers.first()); - NonnullRefPtrVector box_shadow; + StyleValueVector box_shadow; box_shadow.ensure_capacity(box_shadow_layers.size()); for (auto const& layer : box_shadow_layers) box_shadow.append(make_box_shadow_style_value(layer)); @@ -412,7 +412,7 @@ RefPtr ResolvedCSSStyleDeclaration::style_value_for_property(Layout: return IdentifierStyleValue::create(to_value_id(layout_node.computed_values().list_style_type())); case CSS::PropertyID::Margin: { auto margin = layout_node.computed_values().margin(); - auto values = NonnullRefPtrVector {}; + auto values = StyleValueVector {}; values.append(style_value_for_length_percentage(margin.top())); values.append(style_value_for_length_percentage(margin.right())); values.append(style_value_for_length_percentage(margin.bottom())); @@ -445,7 +445,7 @@ RefPtr ResolvedCSSStyleDeclaration::style_value_for_property(Layout: return IdentifierStyleValue::create(to_value_id(layout_node.computed_values().overflow_y())); case CSS::PropertyID::Padding: { auto padding = layout_node.computed_values().padding(); - auto values = NonnullRefPtrVector {}; + auto values = StyleValueVector {}; values.append(style_value_for_length_percentage(padding.top())); values.append(style_value_for_length_percentage(padding.right())); values.append(style_value_for_length_percentage(padding.bottom())); @@ -472,7 +472,7 @@ RefPtr ResolvedCSSStyleDeclaration::style_value_for_property(Layout: auto text_decoration_lines = layout_node.computed_values().text_decoration_line(); if (text_decoration_lines.is_empty()) return IdentifierStyleValue::create(ValueID::None); - NonnullRefPtrVector style_values; + StyleValueVector style_values; for (auto const& line : text_decoration_lines) { style_values.append(IdentifierStyleValue::create(to_value_id(line))); } @@ -505,7 +505,7 @@ RefPtr ResolvedCSSStyleDeclaration::style_value_for_property(Layout: // https://w3c.github.io/csswg-drafts/css-transforms-2/#serialization-of-the-computed-value auto affine_matrix = paintable_box->stacking_context()->affine_transform_matrix(); - NonnullRefPtrVector parameters; + StyleValueVector parameters; parameters.ensure_capacity(6); parameters.append(NumericStyleValue::create_float(affine_matrix.a())); parameters.append(NumericStyleValue::create_float(affine_matrix.b())); @@ -517,7 +517,7 @@ RefPtr ResolvedCSSStyleDeclaration::style_value_for_property(Layout: NonnullRefPtr matrix_function = TransformationStyleValue::create(TransformFunction::Matrix, move(parameters)); // Elsewhere we always store the transform property's value as a StyleValueList of TransformationStyleValues, // so this is just for consistency. - NonnullRefPtrVector matrix_functions; + StyleValueVector matrix_functions; matrix_functions.append(matrix_function); return StyleValueList::create(move(matrix_functions), StyleValueList::Separator::Space); } diff --git a/Userland/Libraries/LibWeb/CSS/StyleValue.cpp b/Userland/Libraries/LibWeb/CSS/StyleValue.cpp index 40a9df8347..6743d32f6c 100644 --- a/Userland/Libraries/LibWeb/CSS/StyleValue.cpp +++ b/Userland/Libraries/LibWeb/CSS/StyleValue.cpp @@ -291,14 +291,14 @@ StyleValueList const& StyleValue::as_value_list() const } BackgroundStyleValue::BackgroundStyleValue( - NonnullRefPtr color, - NonnullRefPtr image, - NonnullRefPtr position, - NonnullRefPtr size, - NonnullRefPtr repeat, - NonnullRefPtr attachment, - NonnullRefPtr origin, - NonnullRefPtr clip) + ValueComparingNonnullRefPtr color, + ValueComparingNonnullRefPtr image, + ValueComparingNonnullRefPtr position, + ValueComparingNonnullRefPtr size, + ValueComparingNonnullRefPtr repeat, + ValueComparingNonnullRefPtr attachment, + ValueComparingNonnullRefPtr origin, + ValueComparingNonnullRefPtr clip) : StyleValueWithDefaultOperators(Type::Background) , m_properties { .color = move(color), @@ -335,7 +335,7 @@ ErrorOr BackgroundStyleValue::to_string() const return String::formatted("{} {} {} {} {} {} {} {}", TRY(m_properties.color->to_string()), TRY(m_properties.image->to_string()), TRY(m_properties.position->to_string()), TRY(m_properties.size->to_string()), TRY(m_properties.repeat->to_string()), TRY(m_properties.attachment->to_string()), TRY(m_properties.origin->to_string()), TRY(m_properties.clip->to_string())); } - auto get_layer_value_string = [](NonnullRefPtr const& style_value, size_t index) { + auto get_layer_value_string = [](ValueComparingNonnullRefPtr const& style_value, size_t index) { if (style_value->is_value_list()) return style_value->as_value_list().value_at(index, true)->to_string(); return style_value->to_string(); @@ -574,7 +574,7 @@ ErrorOr CalculatedStyleValue::to_string() const return String::formatted("calc({})", TRY(m_expression->to_string())); } -bool CalculatedStyleValue::operator==(StyleValue const& other) const +bool CalculatedStyleValue::equals(StyleValue const& other) const { if (type() != other.type()) return false; @@ -1549,7 +1549,7 @@ ErrorOr ImageStyleValue::to_string() const return serialize_a_url(m_url.to_deprecated_string()); } -bool ImageStyleValue::operator==(StyleValue const& other) const +bool ImageStyleValue::equals(StyleValue const& other) const { if (type() != other.type()) return false; @@ -1640,7 +1640,7 @@ ErrorOr LinearGradientStyleValue::to_string() const return builder.to_string(); } -bool LinearGradientStyleValue::operator==(StyleValue const& other_) const +bool LinearGradientStyleValue::equals(StyleValue const& other_) const { if (type() != other_.type()) return false; @@ -1981,7 +1981,7 @@ void RadialGradientStyleValue::resolve_for_size(Layout::Node const& node, CSSPix }; } -bool RadialGradientStyleValue::operator==(StyleValue const& other) const +bool RadialGradientStyleValue::equals(StyleValue const& other) const { if (type() != other.type()) return false; @@ -2033,7 +2033,7 @@ void ConicGradientStyleValue::paint(PaintContext& context, DevicePixelRect const Painting::paint_conic_gradient(context, dest_rect, m_resolved->data, context.rounded_device_point(m_resolved->position)); } -bool ConicGradientStyleValue::operator==(StyleValue const& other) const +bool ConicGradientStyleValue::equals(StyleValue const& other) const { if (type() != other.type()) return false; @@ -2131,7 +2131,7 @@ ErrorOr UnresolvedStyleValue::to_string() const return builder.to_string(); } -bool UnresolvedStyleValue::operator==(StyleValue const& other) const +bool UnresolvedStyleValue::equals(StyleValue const& other) const { if (type() != other.type()) return false; @@ -2161,7 +2161,7 @@ ErrorOr StyleValueList::to_string() const return String::from_deprecated_string(DeprecatedString::join(separator, m_properties.values)); } -NonnullRefPtr ColorStyleValue::create(Color color) +ValueComparingNonnullRefPtr ColorStyleValue::create(Color color) { if (color.value() == 0) { static auto transparent = adopt_ref(*new ColorStyleValue(color)); @@ -2181,32 +2181,32 @@ NonnullRefPtr ColorStyleValue::create(Color color) return adopt_ref(*new ColorStyleValue(color)); } -NonnullRefPtr GridTemplateAreaStyleValue::create(Vector> grid_template_area) +ValueComparingNonnullRefPtr GridTemplateAreaStyleValue::create(Vector> grid_template_area) { return adopt_ref(*new GridTemplateAreaStyleValue(grid_template_area)); } -NonnullRefPtr GridTrackPlacementStyleValue::create(CSS::GridTrackPlacement grid_track_placement) +ValueComparingNonnullRefPtr GridTrackPlacementStyleValue::create(CSS::GridTrackPlacement grid_track_placement) { return adopt_ref(*new GridTrackPlacementStyleValue(grid_track_placement)); } -NonnullRefPtr GridTrackSizeStyleValue::create(CSS::GridTrackSizeList grid_track_size_list) +ValueComparingNonnullRefPtr GridTrackSizeStyleValue::create(CSS::GridTrackSizeList grid_track_size_list) { return adopt_ref(*new GridTrackSizeStyleValue(grid_track_size_list)); } -NonnullRefPtr GridTrackSizeStyleValue::make_auto() +ValueComparingNonnullRefPtr GridTrackSizeStyleValue::make_auto() { return adopt_ref(*new GridTrackSizeStyleValue(CSS::GridTrackSizeList())); } -NonnullRefPtr RectStyleValue::create(EdgeRect rect) +ValueComparingNonnullRefPtr RectStyleValue::create(EdgeRect rect) { return adopt_ref(*new RectStyleValue(rect)); } -NonnullRefPtr LengthStyleValue::create(Length const& length) +ValueComparingNonnullRefPtr LengthStyleValue::create(Length const& length) { if (length.is_auto()) { static auto value = adopt_ref(*new LengthStyleValue(CSS::Length::make_auto())); @@ -2236,19 +2236,19 @@ static Optional absolutized_length(CSS::Length const& length, CSSPi return {}; } -NonnullRefPtr StyleValue::absolutized(CSSPixelRect const&, Gfx::FontPixelMetrics const&, CSSPixels, CSSPixels) const +ValueComparingNonnullRefPtr StyleValue::absolutized(CSSPixelRect const&, Gfx::FontPixelMetrics const&, CSSPixels, CSSPixels) const { return *this; } -NonnullRefPtr LengthStyleValue::absolutized(CSSPixelRect const& viewport_rect, Gfx::FontPixelMetrics const& font_metrics, CSSPixels font_size, CSSPixels root_font_size) const +ValueComparingNonnullRefPtr LengthStyleValue::absolutized(CSSPixelRect const& viewport_rect, Gfx::FontPixelMetrics const& font_metrics, CSSPixels font_size, CSSPixels root_font_size) const { if (auto length = absolutized_length(m_length, viewport_rect, font_metrics, font_size, root_font_size); length.has_value()) return LengthStyleValue::create(length.release_value()); return *this; } -NonnullRefPtr ShadowStyleValue::absolutized(CSSPixelRect const& viewport_rect, Gfx::FontPixelMetrics const& font_metrics, CSSPixels font_size, CSSPixels root_font_size) const +ValueComparingNonnullRefPtr ShadowStyleValue::absolutized(CSSPixelRect const& viewport_rect, Gfx::FontPixelMetrics const& font_metrics, CSSPixels font_size, CSSPixels root_font_size) const { auto absolutized_offset_x = absolutized_length(m_properties.offset_x, viewport_rect, font_metrics, font_size, root_font_size).value_or(m_properties.offset_x); auto absolutized_offset_y = absolutized_length(m_properties.offset_y, viewport_rect, font_metrics, font_size, root_font_size).value_or(m_properties.offset_y); @@ -2257,7 +2257,7 @@ NonnullRefPtr ShadowStyleValue::absolutized(CSSPixelRect const& view return ShadowStyleValue::create(m_properties.color, absolutized_offset_x, absolutized_offset_y, absolutized_blur_radius, absolutized_spread_distance, m_properties.placement); } -NonnullRefPtr BorderRadiusStyleValue::absolutized(CSSPixelRect const& viewport_rect, Gfx::FontPixelMetrics const& font_metrics, CSSPixels font_size, CSSPixels root_font_size) const +ValueComparingNonnullRefPtr BorderRadiusStyleValue::absolutized(CSSPixelRect const& viewport_rect, Gfx::FontPixelMetrics const& font_metrics, CSSPixels font_size, CSSPixels root_font_size) const { if (m_properties.horizontal_radius.is_percentage() && m_properties.vertical_radius.is_percentage()) return *this; diff --git a/Userland/Libraries/LibWeb/CSS/StyleValue.h b/Userland/Libraries/LibWeb/CSS/StyleValue.h index 427bcc998d..4e842922b9 100644 --- a/Userland/Libraries/LibWeb/CSS/StyleValue.h +++ b/Userland/Libraries/LibWeb/CSS/StyleValue.h @@ -9,6 +9,7 @@ #pragma once +#include #include #include #include @@ -214,6 +215,62 @@ inline Gfx::Painter::ScalingMode to_gfx_scaling_mode(CSS::ImageRendering css_val VERIFY_NOT_REACHED(); } +template +struct ValueComparingNonnullRefPtr : public NonnullRefPtr { + using NonnullRefPtr::NonnullRefPtr; + + ValueComparingNonnullRefPtr(NonnullRefPtr const& other) + : NonnullRefPtr(other) + { + } + + ValueComparingNonnullRefPtr(NonnullRefPtr&& other) + : NonnullRefPtr(move(other)) + { + } + + bool operator==(ValueComparingNonnullRefPtr const& other) const + { + return this->ptr() == other.ptr() || this->ptr()->equals(*other); + } + +private: + using NonnullRefPtr::operator==; +}; + +template +struct ValueComparingRefPtr : public RefPtr { + using RefPtr::RefPtr; + + ValueComparingRefPtr(RefPtr const& other) + : RefPtr(other) + { + } + + ValueComparingRefPtr(RefPtr&& other) + : RefPtr(move(other)) + { + } + + template + bool operator==(ValueComparingNonnullRefPtr const& other) const + { + return this->ptr() == other.ptr() || (this->ptr() && this->ptr()->equals(*other)); + } + + bool operator==(ValueComparingRefPtr const& other) const + { + return this->ptr() == other.ptr() || (this->ptr() && other.ptr() && this->ptr()->equals(*other)); + } + +private: + using RefPtr::operator==; +}; + +template +using ValueComparingNonnullRefPtrVector = AK::NonnullPtrVector>; +using StyleValueVector = ValueComparingNonnullRefPtrVector; + class StyleValue : public RefCounted { public: virtual ~StyleValue() = default; @@ -412,7 +469,7 @@ public: virtual bool has_number() const { return false; } virtual bool has_integer() const { return false; } - virtual NonnullRefPtr absolutized(CSSPixelRect const& viewport_rect, Gfx::FontPixelMetrics const& font_metrics, CSSPixels font_size, CSSPixels root_font_size) const; + virtual ValueComparingNonnullRefPtr absolutized(CSSPixelRect const& viewport_rect, Gfx::FontPixelMetrics const& font_metrics, CSSPixels font_size, CSSPixels root_font_size) const; virtual Color to_color(Layout::NodeWithStyle const&) const { return {}; } virtual EdgeRect to_rect() const { VERIFY_NOT_REACHED(); } @@ -422,7 +479,12 @@ public: virtual float to_integer() const { return 0; } virtual ErrorOr to_string() const = 0; - virtual bool operator==(StyleValue const& other) const = 0; + virtual bool equals(StyleValue const& other) const = 0; + + bool operator==(StyleValue const& other) const + { + return this->equals(other); + } protected: explicit StyleValue(Type); @@ -435,18 +497,18 @@ template struct StyleValueWithDefaultOperators : public StyleValue { using StyleValue::StyleValue; - bool operator==(StyleValue const& other) const override + virtual bool equals(StyleValue const& other) const override { if (type() != other.type()) return false; auto const& typed_other = static_cast(other); - return static_cast(*this).equals(typed_other); + return static_cast(*this).properties_equal(typed_other); } }; class AngleStyleValue : public StyleValueWithDefaultOperators { public: - static NonnullRefPtr create(Angle angle) + static ValueComparingNonnullRefPtr create(Angle angle) { return adopt_ref(*new AngleStyleValue(move(angle))); } @@ -456,7 +518,7 @@ public: virtual ErrorOr to_string() const override { return m_angle.to_string(); } - bool equals(AngleStyleValue const& other) const { return m_angle == other.m_angle; } + bool properties_equal(AngleStyleValue const& other) const { return m_angle == other.m_angle; } private: explicit AngleStyleValue(Angle angle) @@ -470,15 +532,15 @@ private: class BackgroundStyleValue final : public StyleValueWithDefaultOperators { public: - static NonnullRefPtr create( - NonnullRefPtr color, - NonnullRefPtr image, - NonnullRefPtr position, - NonnullRefPtr size, - NonnullRefPtr repeat, - NonnullRefPtr attachment, - NonnullRefPtr origin, - NonnullRefPtr clip) + static ValueComparingNonnullRefPtr create( + ValueComparingNonnullRefPtr color, + ValueComparingNonnullRefPtr image, + ValueComparingNonnullRefPtr position, + ValueComparingNonnullRefPtr size, + ValueComparingNonnullRefPtr repeat, + ValueComparingNonnullRefPtr attachment, + ValueComparingNonnullRefPtr origin, + ValueComparingNonnullRefPtr clip) { return adopt_ref(*new BackgroundStyleValue(move(color), move(image), move(position), move(size), move(repeat), move(attachment), move(origin), move(clip))); } @@ -486,39 +548,39 @@ public: size_t layer_count() const { return m_properties.layer_count; } - NonnullRefPtr attachment() const { return m_properties.attachment; } - NonnullRefPtr clip() const { return m_properties.clip; } - NonnullRefPtr color() const { return m_properties.color; } - NonnullRefPtr image() const { return m_properties.image; } - NonnullRefPtr origin() const { return m_properties.origin; } - NonnullRefPtr position() const { return m_properties.position; } - NonnullRefPtr repeat() const { return m_properties.repeat; } - NonnullRefPtr size() const { return m_properties.size; } + ValueComparingNonnullRefPtr attachment() const { return m_properties.attachment; } + ValueComparingNonnullRefPtr clip() const { return m_properties.clip; } + ValueComparingNonnullRefPtr color() const { return m_properties.color; } + ValueComparingNonnullRefPtr image() const { return m_properties.image; } + ValueComparingNonnullRefPtr origin() const { return m_properties.origin; } + ValueComparingNonnullRefPtr position() const { return m_properties.position; } + ValueComparingNonnullRefPtr repeat() const { return m_properties.repeat; } + ValueComparingNonnullRefPtr size() const { return m_properties.size; } virtual ErrorOr to_string() const override; - bool equals(BackgroundStyleValue const& other) const { return m_properties == other.m_properties; } + bool properties_equal(BackgroundStyleValue const& other) const { return m_properties == other.m_properties; } private: BackgroundStyleValue( - NonnullRefPtr color, - NonnullRefPtr image, - NonnullRefPtr position, - NonnullRefPtr size, - NonnullRefPtr repeat, - NonnullRefPtr attachment, - NonnullRefPtr origin, - NonnullRefPtr clip); + ValueComparingNonnullRefPtr color, + ValueComparingNonnullRefPtr image, + ValueComparingNonnullRefPtr position, + ValueComparingNonnullRefPtr size, + ValueComparingNonnullRefPtr repeat, + ValueComparingNonnullRefPtr attachment, + ValueComparingNonnullRefPtr origin, + ValueComparingNonnullRefPtr clip); struct Properties { - NonnullRefPtr color; - NonnullRefPtr image; - NonnullRefPtr position; - NonnullRefPtr size; - NonnullRefPtr repeat; - NonnullRefPtr attachment; - NonnullRefPtr origin; - NonnullRefPtr clip; + ValueComparingNonnullRefPtr color; + ValueComparingNonnullRefPtr image; + ValueComparingNonnullRefPtr position; + ValueComparingNonnullRefPtr size; + ValueComparingNonnullRefPtr repeat; + ValueComparingNonnullRefPtr attachment; + ValueComparingNonnullRefPtr origin; + ValueComparingNonnullRefPtr clip; size_t layer_count; bool operator==(Properties const&) const = default; } m_properties; @@ -526,7 +588,7 @@ private: class BackgroundRepeatStyleValue final : public StyleValueWithDefaultOperators { public: - static NonnullRefPtr create(Repeat repeat_x, Repeat repeat_y) + static ValueComparingNonnullRefPtr create(Repeat repeat_x, Repeat repeat_y) { return adopt_ref(*new BackgroundRepeatStyleValue(repeat_x, repeat_y)); } @@ -537,7 +599,7 @@ public: virtual ErrorOr to_string() const override; - bool equals(BackgroundRepeatStyleValue const& other) const { return m_properties == other.m_properties; } + bool properties_equal(BackgroundRepeatStyleValue const& other) const { return m_properties == other.m_properties; } private: BackgroundRepeatStyleValue(Repeat repeat_x, Repeat repeat_y) @@ -556,7 +618,7 @@ private: // NOTE: This is not used for identifier sizes, like `cover` and `contain`. class BackgroundSizeStyleValue final : public StyleValueWithDefaultOperators { public: - static NonnullRefPtr create(LengthPercentage size_x, LengthPercentage size_y) + static ValueComparingNonnullRefPtr create(LengthPercentage size_x, LengthPercentage size_y) { return adopt_ref(*new BackgroundSizeStyleValue(size_x, size_y)); } @@ -567,7 +629,7 @@ public: virtual ErrorOr to_string() const override; - bool equals(BackgroundSizeStyleValue const& other) const { return m_properties == other.m_properties; } + bool properties_equal(BackgroundSizeStyleValue const& other) const { return m_properties == other.m_properties; } private: BackgroundSizeStyleValue(LengthPercentage size_x, LengthPercentage size_y) @@ -585,44 +647,44 @@ private: class BorderStyleValue final : public StyleValueWithDefaultOperators { public: - static NonnullRefPtr create( - NonnullRefPtr border_width, - NonnullRefPtr border_style, - NonnullRefPtr border_color) + static ValueComparingNonnullRefPtr create( + ValueComparingNonnullRefPtr border_width, + ValueComparingNonnullRefPtr border_style, + ValueComparingNonnullRefPtr border_color) { return adopt_ref(*new BorderStyleValue(move(border_width), move(border_style), move(border_color))); } virtual ~BorderStyleValue() override = default; - NonnullRefPtr border_width() const { return m_properties.border_width; } - NonnullRefPtr border_style() const { return m_properties.border_style; } - NonnullRefPtr border_color() const { return m_properties.border_color; } + ValueComparingNonnullRefPtr border_width() const { return m_properties.border_width; } + ValueComparingNonnullRefPtr border_style() const { return m_properties.border_style; } + ValueComparingNonnullRefPtr border_color() const { return m_properties.border_color; } virtual ErrorOr to_string() const override; - bool equals(BorderStyleValue const& other) const { return m_properties == other.m_properties; } + bool properties_equal(BorderStyleValue const& other) const { return m_properties == other.m_properties; } private: BorderStyleValue( - NonnullRefPtr border_width, - NonnullRefPtr border_style, - NonnullRefPtr border_color) + ValueComparingNonnullRefPtr border_width, + ValueComparingNonnullRefPtr border_style, + ValueComparingNonnullRefPtr border_color) : StyleValueWithDefaultOperators(Type::Border) , m_properties { .border_width = move(border_width), .border_style = move(border_style), .border_color = move(border_color) } { } struct Properties { - NonnullRefPtr border_width; - NonnullRefPtr border_style; - NonnullRefPtr border_color; + ValueComparingNonnullRefPtr border_width; + ValueComparingNonnullRefPtr border_style; + ValueComparingNonnullRefPtr border_color; bool operator==(Properties const&) const = default; } m_properties; }; class BorderRadiusStyleValue final : public StyleValueWithDefaultOperators { public: - static NonnullRefPtr create(LengthPercentage const& horizontal_radius, LengthPercentage const& vertical_radius) + static ValueComparingNonnullRefPtr create(LengthPercentage const& horizontal_radius, LengthPercentage const& vertical_radius) { return adopt_ref(*new BorderRadiusStyleValue(horizontal_radius, vertical_radius)); } @@ -634,7 +696,7 @@ public: virtual ErrorOr to_string() const override; - bool equals(BorderRadiusStyleValue const& other) const { return m_properties == other.m_properties; } + bool properties_equal(BorderRadiusStyleValue const& other) const { return m_properties == other.m_properties; } private: BorderRadiusStyleValue(LengthPercentage const& horizontal_radius, LengthPercentage const& vertical_radius) @@ -643,7 +705,7 @@ private: { } - virtual NonnullRefPtr absolutized(CSSPixelRect const& viewport_rect, Gfx::FontPixelMetrics const& font_metrics, CSSPixels font_size, CSSPixels root_font_size) const override; + virtual ValueComparingNonnullRefPtr absolutized(CSSPixelRect const& viewport_rect, Gfx::FontPixelMetrics const& font_metrics, CSSPixels font_size, CSSPixels root_font_size) const override; struct Properties { bool is_elliptical; @@ -655,33 +717,33 @@ private: class BorderRadiusShorthandStyleValue final : public StyleValueWithDefaultOperators { public: - static NonnullRefPtr create(NonnullRefPtr top_left, NonnullRefPtr top_right, NonnullRefPtr bottom_right, NonnullRefPtr bottom_left) + static ValueComparingNonnullRefPtr create(ValueComparingNonnullRefPtr top_left, ValueComparingNonnullRefPtr top_right, ValueComparingNonnullRefPtr bottom_right, ValueComparingNonnullRefPtr bottom_left) { return adopt_ref(*new BorderRadiusShorthandStyleValue(move(top_left), move(top_right), move(bottom_right), move(bottom_left))); } virtual ~BorderRadiusShorthandStyleValue() override = default; - NonnullRefPtr top_left() const { return m_properties.top_left; } - NonnullRefPtr top_right() const { return m_properties.top_right; } - NonnullRefPtr bottom_right() const { return m_properties.bottom_right; } - NonnullRefPtr bottom_left() const { return m_properties.bottom_left; } + ValueComparingNonnullRefPtr top_left() const { return m_properties.top_left; } + ValueComparingNonnullRefPtr top_right() const { return m_properties.top_right; } + ValueComparingNonnullRefPtr bottom_right() const { return m_properties.bottom_right; } + ValueComparingNonnullRefPtr bottom_left() const { return m_properties.bottom_left; } virtual ErrorOr to_string() const override; - bool equals(BorderRadiusShorthandStyleValue const& other) const { return m_properties == other.m_properties; } + bool properties_equal(BorderRadiusShorthandStyleValue const& other) const { return m_properties == other.m_properties; } private: - BorderRadiusShorthandStyleValue(NonnullRefPtr top_left, NonnullRefPtr top_right, NonnullRefPtr bottom_right, NonnullRefPtr bottom_left) + BorderRadiusShorthandStyleValue(ValueComparingNonnullRefPtr top_left, ValueComparingNonnullRefPtr top_right, ValueComparingNonnullRefPtr bottom_right, ValueComparingNonnullRefPtr bottom_left) : StyleValueWithDefaultOperators(Type::BorderRadiusShorthand) , m_properties { .top_left = move(top_left), .top_right = move(top_right), .bottom_right = move(bottom_right), .bottom_left = move(bottom_left) } { } struct Properties { - NonnullRefPtr top_left; - NonnullRefPtr top_right; - NonnullRefPtr bottom_right; - NonnullRefPtr bottom_left; + ValueComparingNonnullRefPtr top_left; + ValueComparingNonnullRefPtr top_right; + ValueComparingNonnullRefPtr bottom_right; + ValueComparingNonnullRefPtr bottom_left; bool operator==(Properties const&) const = default; } m_properties; }; @@ -847,13 +909,13 @@ public: CalculationResult resolve(Layout::Node const*, PercentageBasis const& percentage_basis) const; }; - static NonnullRefPtr create(NonnullOwnPtr calc_sum, ResolvedType resolved_type) + static ValueComparingNonnullRefPtr create(NonnullOwnPtr calc_sum, ResolvedType resolved_type) { return adopt_ref(*new CalculatedStyleValue(move(calc_sum), resolved_type)); } ErrorOr to_string() const override; - virtual bool operator==(StyleValue const& other) const override; + virtual bool equals(StyleValue const& other) const override; ResolvedType resolved_type() const { return m_resolved_type; } NonnullOwnPtr const& expression() const { return m_expression; } @@ -897,7 +959,7 @@ private: class ColorStyleValue : public StyleValueWithDefaultOperators { public: - static NonnullRefPtr create(Color color); + static ValueComparingNonnullRefPtr create(Color color); virtual ~ColorStyleValue() override = default; Color color() const { return m_color; } @@ -905,7 +967,7 @@ public: virtual bool has_color() const override { return true; } virtual Color to_color(Layout::NodeWithStyle const&) const override { return m_color; } - bool equals(ColorStyleValue const& other) const { return m_color == other.m_color; }; + bool properties_equal(ColorStyleValue const& other) const { return m_color == other.m_color; }; private: explicit ColorStyleValue(Color color) @@ -919,7 +981,7 @@ private: class ContentStyleValue final : public StyleValueWithDefaultOperators { public: - static NonnullRefPtr create(NonnullRefPtr content, RefPtr alt_text) + static ValueComparingNonnullRefPtr create(ValueComparingNonnullRefPtr content, ValueComparingRefPtr alt_text) { return adopt_ref(*new ContentStyleValue(move(content), move(alt_text))); } @@ -930,25 +992,25 @@ public: virtual ErrorOr to_string() const override; - bool equals(ContentStyleValue const& other) const { return m_properties == other.m_properties; }; + bool properties_equal(ContentStyleValue const& other) const { return m_properties == other.m_properties; }; private: - ContentStyleValue(NonnullRefPtr content, RefPtr alt_text) + ContentStyleValue(ValueComparingNonnullRefPtr content, ValueComparingRefPtr alt_text) : StyleValueWithDefaultOperators(Type::Content) , m_properties { .content = move(content), .alt_text = move(alt_text) } { } struct Properties { - NonnullRefPtr content; - RefPtr alt_text; + ValueComparingNonnullRefPtr content; + ValueComparingRefPtr alt_text; bool operator==(Properties const&) const = default; } m_properties; }; class FilterValueListStyleValue final : public StyleValueWithDefaultOperators { public: - static NonnullRefPtr create( + static ValueComparingNonnullRefPtr create( Vector filter_value_list) { VERIFY(filter_value_list.size() >= 1); @@ -961,7 +1023,7 @@ public: virtual ~FilterValueListStyleValue() override = default; - bool equals(FilterValueListStyleValue const& other) const { return m_filter_value_list == other.m_filter_value_list; }; + bool properties_equal(FilterValueListStyleValue const& other) const { return m_filter_value_list == other.m_filter_value_list; }; private: FilterValueListStyleValue(Vector filter_value_list) @@ -976,103 +1038,103 @@ private: class FlexStyleValue final : public StyleValueWithDefaultOperators { public: - static NonnullRefPtr create( - NonnullRefPtr grow, - NonnullRefPtr shrink, - NonnullRefPtr basis) + static ValueComparingNonnullRefPtr create( + ValueComparingNonnullRefPtr grow, + ValueComparingNonnullRefPtr shrink, + ValueComparingNonnullRefPtr basis) { return adopt_ref(*new FlexStyleValue(move(grow), move(shrink), move(basis))); } virtual ~FlexStyleValue() override = default; - NonnullRefPtr grow() const { return m_properties.grow; } - NonnullRefPtr shrink() const { return m_properties.shrink; } - NonnullRefPtr basis() const { return m_properties.basis; } + ValueComparingNonnullRefPtr grow() const { return m_properties.grow; } + ValueComparingNonnullRefPtr shrink() const { return m_properties.shrink; } + ValueComparingNonnullRefPtr basis() const { return m_properties.basis; } virtual ErrorOr to_string() const override; - bool equals(FlexStyleValue const& other) const { return m_properties == other.m_properties; }; + bool properties_equal(FlexStyleValue const& other) const { return m_properties == other.m_properties; }; private: FlexStyleValue( - NonnullRefPtr grow, - NonnullRefPtr shrink, - NonnullRefPtr basis) + ValueComparingNonnullRefPtr grow, + ValueComparingNonnullRefPtr shrink, + ValueComparingNonnullRefPtr basis) : StyleValueWithDefaultOperators(Type::Flex) , m_properties { .grow = move(grow), .shrink = move(shrink), .basis = move(basis) } { } struct Properties { - NonnullRefPtr grow; - NonnullRefPtr shrink; - NonnullRefPtr basis; + ValueComparingNonnullRefPtr grow; + ValueComparingNonnullRefPtr shrink; + ValueComparingNonnullRefPtr basis; bool operator==(Properties const&) const = default; } m_properties; }; class FlexFlowStyleValue final : public StyleValueWithDefaultOperators { public: - static NonnullRefPtr create(NonnullRefPtr flex_direction, NonnullRefPtr flex_wrap) + static ValueComparingNonnullRefPtr create(ValueComparingNonnullRefPtr flex_direction, ValueComparingNonnullRefPtr flex_wrap) { return adopt_ref(*new FlexFlowStyleValue(move(flex_direction), move(flex_wrap))); } virtual ~FlexFlowStyleValue() override = default; - NonnullRefPtr flex_direction() const { return m_properties.flex_direction; } - NonnullRefPtr flex_wrap() const { return m_properties.flex_wrap; } + ValueComparingNonnullRefPtr flex_direction() const { return m_properties.flex_direction; } + ValueComparingNonnullRefPtr flex_wrap() const { return m_properties.flex_wrap; } virtual ErrorOr to_string() const override; - bool equals(FlexFlowStyleValue const& other) const { return m_properties == other.m_properties; }; + bool properties_equal(FlexFlowStyleValue const& other) const { return m_properties == other.m_properties; }; private: - FlexFlowStyleValue(NonnullRefPtr flex_direction, NonnullRefPtr flex_wrap) + FlexFlowStyleValue(ValueComparingNonnullRefPtr flex_direction, ValueComparingNonnullRefPtr flex_wrap) : StyleValueWithDefaultOperators(Type::FlexFlow) , m_properties { .flex_direction = move(flex_direction), .flex_wrap = move(flex_wrap) } { } struct Properties { - NonnullRefPtr flex_direction; - NonnullRefPtr flex_wrap; + ValueComparingNonnullRefPtr flex_direction; + ValueComparingNonnullRefPtr flex_wrap; bool operator==(Properties const&) const = default; } m_properties; }; class FontStyleValue final : public StyleValueWithDefaultOperators { public: - static NonnullRefPtr create(NonnullRefPtr font_stretch, NonnullRefPtr font_style, NonnullRefPtr font_weight, NonnullRefPtr font_size, NonnullRefPtr line_height, NonnullRefPtr font_families) + static ValueComparingNonnullRefPtr create(ValueComparingNonnullRefPtr font_stretch, ValueComparingNonnullRefPtr font_style, ValueComparingNonnullRefPtr font_weight, ValueComparingNonnullRefPtr font_size, ValueComparingNonnullRefPtr line_height, ValueComparingNonnullRefPtr font_families) { return adopt_ref(*new FontStyleValue(move(font_stretch), move(font_style), move(font_weight), move(font_size), move(line_height), move(font_families))); } virtual ~FontStyleValue() override = default; - NonnullRefPtr font_stretch() const { return m_properties.font_stretch; } - NonnullRefPtr font_style() const { return m_properties.font_style; } - NonnullRefPtr font_weight() const { return m_properties.font_weight; } - NonnullRefPtr font_size() const { return m_properties.font_size; } - NonnullRefPtr line_height() const { return m_properties.line_height; } - NonnullRefPtr font_families() const { return m_properties.font_families; } + ValueComparingNonnullRefPtr font_stretch() const { return m_properties.font_stretch; } + ValueComparingNonnullRefPtr font_style() const { return m_properties.font_style; } + ValueComparingNonnullRefPtr font_weight() const { return m_properties.font_weight; } + ValueComparingNonnullRefPtr font_size() const { return m_properties.font_size; } + ValueComparingNonnullRefPtr line_height() const { return m_properties.line_height; } + ValueComparingNonnullRefPtr font_families() const { return m_properties.font_families; } virtual ErrorOr to_string() const override; - bool equals(FontStyleValue const& other) const { return m_properties == other.m_properties; }; + bool properties_equal(FontStyleValue const& other) const { return m_properties == other.m_properties; }; private: - FontStyleValue(NonnullRefPtr font_stretch, NonnullRefPtr font_style, NonnullRefPtr font_weight, NonnullRefPtr font_size, NonnullRefPtr line_height, NonnullRefPtr font_families) + FontStyleValue(ValueComparingNonnullRefPtr font_stretch, ValueComparingNonnullRefPtr font_style, ValueComparingNonnullRefPtr font_weight, ValueComparingNonnullRefPtr font_size, ValueComparingNonnullRefPtr line_height, ValueComparingNonnullRefPtr font_families) : StyleValueWithDefaultOperators(Type::Font) , m_properties { .font_stretch = move(font_stretch), .font_style = move(font_style), .font_weight = move(font_weight), .font_size = move(font_size), .line_height = move(line_height), .font_families = move(font_families) } { } struct Properties { - NonnullRefPtr font_stretch; - NonnullRefPtr font_style; - NonnullRefPtr font_weight; - NonnullRefPtr font_size; - NonnullRefPtr line_height; - NonnullRefPtr font_families; + ValueComparingNonnullRefPtr font_stretch; + ValueComparingNonnullRefPtr font_style; + ValueComparingNonnullRefPtr font_weight; + ValueComparingNonnullRefPtr font_size; + ValueComparingNonnullRefPtr line_height; + ValueComparingNonnullRefPtr font_families; // FIXME: Implement font-variant. bool operator==(Properties const&) const = default; } m_properties; @@ -1080,7 +1142,7 @@ private: class FrequencyStyleValue : public StyleValueWithDefaultOperators { public: - static NonnullRefPtr create(Frequency frequency) + static ValueComparingNonnullRefPtr create(Frequency frequency) { return adopt_ref(*new FrequencyStyleValue(move(frequency))); } @@ -1090,7 +1152,7 @@ public: virtual ErrorOr to_string() const override { return m_frequency.to_string(); } - bool equals(FrequencyStyleValue const& other) const { return m_frequency == other.m_frequency; }; + bool properties_equal(FrequencyStyleValue const& other) const { return m_frequency == other.m_frequency; }; private: explicit FrequencyStyleValue(Frequency frequency) @@ -1104,13 +1166,13 @@ private: class GridTemplateAreaStyleValue final : public StyleValueWithDefaultOperators { public: - static NonnullRefPtr create(Vector> grid_template_area); + static ValueComparingNonnullRefPtr create(Vector> grid_template_area); virtual ~GridTemplateAreaStyleValue() override = default; Vector> const& grid_template_area() const { return m_grid_template_area; } virtual ErrorOr to_string() const override; - bool equals(GridTemplateAreaStyleValue const& other) const { return m_grid_template_area == other.m_grid_template_area; }; + bool properties_equal(GridTemplateAreaStyleValue const& other) const { return m_grid_template_area == other.m_grid_template_area; }; private: explicit GridTemplateAreaStyleValue(Vector> grid_template_area) @@ -1124,13 +1186,13 @@ private: class GridTrackPlacementStyleValue final : public StyleValueWithDefaultOperators { public: - static NonnullRefPtr create(CSS::GridTrackPlacement grid_track_placement); + static ValueComparingNonnullRefPtr create(CSS::GridTrackPlacement grid_track_placement); virtual ~GridTrackPlacementStyleValue() override = default; CSS::GridTrackPlacement const& grid_track_placement() const { return m_grid_track_placement; } virtual ErrorOr to_string() const override; - bool equals(GridTrackPlacementStyleValue const& other) const { return m_grid_track_placement == other.m_grid_track_placement; }; + bool properties_equal(GridTrackPlacementStyleValue const& other) const { return m_grid_track_placement == other.m_grid_track_placement; }; private: explicit GridTrackPlacementStyleValue(CSS::GridTrackPlacement grid_track_placement) @@ -1144,86 +1206,86 @@ private: class GridTrackPlacementShorthandStyleValue final : public StyleValueWithDefaultOperators { public: - static NonnullRefPtr create(NonnullRefPtr start, NonnullRefPtr end) + static ValueComparingNonnullRefPtr create(ValueComparingNonnullRefPtr start, ValueComparingNonnullRefPtr end) { return adopt_ref(*new GridTrackPlacementShorthandStyleValue(move(start), move(end))); } - static NonnullRefPtr create(GridTrackPlacement start) + static ValueComparingNonnullRefPtr create(GridTrackPlacement start) { return adopt_ref(*new GridTrackPlacementShorthandStyleValue(GridTrackPlacementStyleValue::create(start), GridTrackPlacementStyleValue::create(GridTrackPlacement::make_auto()))); } virtual ~GridTrackPlacementShorthandStyleValue() override = default; - NonnullRefPtr start() const { return m_properties.start; } - NonnullRefPtr end() const { return m_properties.end; } + ValueComparingNonnullRefPtr start() const { return m_properties.start; } + ValueComparingNonnullRefPtr end() const { return m_properties.end; } virtual ErrorOr to_string() const override; - bool equals(GridTrackPlacementShorthandStyleValue const& other) const { return m_properties == other.m_properties; }; + bool properties_equal(GridTrackPlacementShorthandStyleValue const& other) const { return m_properties == other.m_properties; }; private: - GridTrackPlacementShorthandStyleValue(NonnullRefPtr start, NonnullRefPtr end) + GridTrackPlacementShorthandStyleValue(ValueComparingNonnullRefPtr start, ValueComparingNonnullRefPtr end) : StyleValueWithDefaultOperators(Type::GridTrackPlacementShorthand) , m_properties { .start = move(start), .end = move(end) } { } struct Properties { - NonnullRefPtr start; - NonnullRefPtr end; + ValueComparingNonnullRefPtr start; + ValueComparingNonnullRefPtr end; bool operator==(Properties const&) const = default; } m_properties; }; class GridAreaShorthandStyleValue final : public StyleValueWithDefaultOperators { public: - static NonnullRefPtr create(NonnullRefPtr row_start, NonnullRefPtr column_start, NonnullRefPtr row_end, NonnullRefPtr column_end) + static ValueComparingNonnullRefPtr create(ValueComparingNonnullRefPtr row_start, ValueComparingNonnullRefPtr column_start, ValueComparingNonnullRefPtr row_end, ValueComparingNonnullRefPtr column_end) { return adopt_ref(*new GridAreaShorthandStyleValue(row_start, column_start, row_end, column_end)); } - static NonnullRefPtr create(GridTrackPlacement row_start, GridTrackPlacement column_start, GridTrackPlacement row_end, GridTrackPlacement column_end) + static ValueComparingNonnullRefPtr create(GridTrackPlacement row_start, GridTrackPlacement column_start, GridTrackPlacement row_end, GridTrackPlacement column_end) { return adopt_ref(*new GridAreaShorthandStyleValue(GridTrackPlacementStyleValue::create(row_start), GridTrackPlacementStyleValue::create(column_start), GridTrackPlacementStyleValue::create(row_end), GridTrackPlacementStyleValue::create(column_end))); } virtual ~GridAreaShorthandStyleValue() override = default; - NonnullRefPtr row_start() const { return m_properties.row_start; } - NonnullRefPtr column_start() const { return m_properties.column_start; } - NonnullRefPtr row_end() const { return m_properties.row_end; } - NonnullRefPtr column_end() const { return m_properties.column_end; } + ValueComparingNonnullRefPtr row_start() const { return m_properties.row_start; } + ValueComparingNonnullRefPtr column_start() const { return m_properties.column_start; } + ValueComparingNonnullRefPtr row_end() const { return m_properties.row_end; } + ValueComparingNonnullRefPtr column_end() const { return m_properties.column_end; } virtual ErrorOr to_string() const override; - bool equals(GridAreaShorthandStyleValue const& other) const { return m_properties == other.m_properties; } + bool properties_equal(GridAreaShorthandStyleValue const& other) const { return m_properties == other.m_properties; } private: - GridAreaShorthandStyleValue(NonnullRefPtr row_start, NonnullRefPtr column_start, NonnullRefPtr row_end, NonnullRefPtr column_end) + GridAreaShorthandStyleValue(ValueComparingNonnullRefPtr row_start, ValueComparingNonnullRefPtr column_start, ValueComparingNonnullRefPtr row_end, ValueComparingNonnullRefPtr column_end) : StyleValueWithDefaultOperators(Type::GridAreaShorthand) , m_properties { .row_start = move(row_start), .column_start = move(column_start), .row_end = move(row_end), .column_end = move(column_end) } { } struct Properties { - NonnullRefPtr row_start; - NonnullRefPtr column_start; - NonnullRefPtr row_end; - NonnullRefPtr column_end; + ValueComparingNonnullRefPtr row_start; + ValueComparingNonnullRefPtr column_start; + ValueComparingNonnullRefPtr row_end; + ValueComparingNonnullRefPtr column_end; bool operator==(Properties const&) const = default; } m_properties; }; class GridTrackSizeStyleValue final : public StyleValueWithDefaultOperators { public: - static NonnullRefPtr create(CSS::GridTrackSizeList grid_track_size_list); + static ValueComparingNonnullRefPtr create(CSS::GridTrackSizeList grid_track_size_list); virtual ~GridTrackSizeStyleValue() override = default; - static NonnullRefPtr make_auto(); + static ValueComparingNonnullRefPtr make_auto(); CSS::GridTrackSizeList grid_track_size_list() const { return m_grid_track_size_list; } virtual ErrorOr to_string() const override; - bool equals(GridTrackSizeStyleValue const& other) const { return m_grid_track_size_list == other.m_grid_track_size_list; } + 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) @@ -1237,7 +1299,7 @@ private: class IdentifierStyleValue final : public StyleValueWithDefaultOperators { public: - static NonnullRefPtr create(CSS::ValueID id) + static ValueComparingNonnullRefPtr create(CSS::ValueID id) { return adopt_ref(*new IdentifierStyleValue(id)); } @@ -1252,7 +1314,7 @@ public: virtual Color to_color(Layout::NodeWithStyle const& node) const override; virtual ErrorOr to_string() const override; - bool equals(IdentifierStyleValue const& other) const { return m_id == other.m_id; } + bool properties_equal(IdentifierStyleValue const& other) const { return m_id == other.m_id; } private: explicit IdentifierStyleValue(CSS::ValueID id) @@ -1282,11 +1344,11 @@ class ImageStyleValue final : public AbstractImageStyleValue , public ImageResourceClient { public: - static NonnullRefPtr create(AK::URL const& url) { return adopt_ref(*new ImageStyleValue(url)); } + static ValueComparingNonnullRefPtr create(AK::URL const& url) { return adopt_ref(*new ImageStyleValue(url)); } virtual ~ImageStyleValue() override = default; virtual ErrorOr to_string() const override; - virtual bool operator==(StyleValue const& other) const override; + virtual bool equals(StyleValue const& other) const override; virtual void load_any_resources(DOM::Document&) override; @@ -1347,7 +1409,7 @@ public: using Size = Variant; - static NonnullRefPtr create(EndingShape ending_shape, Size size, PositionValue position, Vector color_stop_list, GradientRepeating repeating) + static ValueComparingNonnullRefPtr create(EndingShape ending_shape, Size size, PositionValue position, Vector color_stop_list, GradientRepeating repeating) { VERIFY(color_stop_list.size() >= 2); return adopt_ref(*new RadialGradientStyleValue(ending_shape, size, position, move(color_stop_list), repeating)); @@ -1357,7 +1419,7 @@ public: void paint(PaintContext&, DevicePixelRect const& dest_rect, CSS::ImageRendering) const override; - virtual bool operator==(StyleValue const& other) const override; + virtual bool equals(StyleValue const& other) const override; Vector const& color_stop_list() const { @@ -1401,7 +1463,7 @@ private: class ConicGradientStyleValue final : public AbstractImageStyleValue { public: - static NonnullRefPtr create(Angle from_angle, PositionValue position, Vector color_stop_list, GradientRepeating repeating) + static ValueComparingNonnullRefPtr create(Angle from_angle, PositionValue position, Vector color_stop_list, GradientRepeating repeating) { VERIFY(color_stop_list.size() >= 2); return adopt_ref(*new ConicGradientStyleValue(from_angle, position, move(color_stop_list), repeating)); @@ -1411,7 +1473,7 @@ public: void paint(PaintContext&, DevicePixelRect const& dest_rect, CSS::ImageRendering) const override; - virtual bool operator==(StyleValue const& other) const override; + virtual bool equals(StyleValue const& other) const override; Vector const& color_stop_list() const { @@ -1461,7 +1523,7 @@ public: WebKit }; - static NonnullRefPtr create(GradientDirection direction, Vector color_stop_list, GradientType type, GradientRepeating repeating) + static ValueComparingNonnullRefPtr create(GradientDirection direction, Vector color_stop_list, GradientType type, GradientRepeating repeating) { VERIFY(color_stop_list.size() >= 2); return adopt_ref(*new LinearGradientStyleValue(direction, move(color_stop_list), type, repeating)); @@ -1469,7 +1531,7 @@ public: virtual ErrorOr to_string() const override; virtual ~LinearGradientStyleValue() override = default; - virtual bool operator==(StyleValue const& other) const override; + virtual bool equals(StyleValue const& other) const override; Vector const& color_stop_list() const { @@ -1510,16 +1572,16 @@ private: class InheritStyleValue final : public StyleValueWithDefaultOperators { public: - static NonnullRefPtr the() + static ValueComparingNonnullRefPtr the() { - static NonnullRefPtr instance = adopt_ref(*new InheritStyleValue); + static ValueComparingNonnullRefPtr instance = adopt_ref(*new InheritStyleValue); return instance; } virtual ~InheritStyleValue() override = default; ErrorOr to_string() const override { return String::from_utf8("inherit"sv); } - bool equals(InheritStyleValue const&) const { return true; } + bool properties_equal(InheritStyleValue const&) const { return true; } private: InheritStyleValue() @@ -1530,16 +1592,16 @@ private: class InitialStyleValue final : public StyleValueWithDefaultOperators { public: - static NonnullRefPtr the() + static ValueComparingNonnullRefPtr the() { - static NonnullRefPtr instance = adopt_ref(*new InitialStyleValue); + static ValueComparingNonnullRefPtr instance = adopt_ref(*new InitialStyleValue); return instance; } virtual ~InitialStyleValue() override = default; ErrorOr to_string() const override { return String::from_utf8("initial"sv); } - bool equals(InitialStyleValue const&) const { return true; } + bool properties_equal(InitialStyleValue const&) const { return true; } private: InitialStyleValue() @@ -1550,7 +1612,7 @@ private: class LengthStyleValue : public StyleValueWithDefaultOperators { public: - static NonnullRefPtr create(Length const&); + static ValueComparingNonnullRefPtr create(Length const&); virtual ~LengthStyleValue() override = default; Length const& length() const { return m_length; } @@ -1561,9 +1623,9 @@ public: virtual ErrorOr to_string() const override { return m_length.to_string(); } virtual Length to_length() const override { return m_length; } virtual ValueID to_identifier() const override { return has_auto() ? ValueID::Auto : ValueID::Invalid; } - virtual NonnullRefPtr absolutized(CSSPixelRect const& viewport_rect, Gfx::FontPixelMetrics const& font_metrics, CSSPixels font_size, CSSPixels root_font_size) const override; + virtual ValueComparingNonnullRefPtr absolutized(CSSPixelRect const& viewport_rect, Gfx::FontPixelMetrics const& font_metrics, CSSPixels font_size, CSSPixels root_font_size) const override; - bool equals(LengthStyleValue const& other) const { return m_length == other.m_length; } + bool properties_equal(LengthStyleValue const& other) const { return m_length == other.m_length; } private: explicit LengthStyleValue(Length const& length) @@ -1577,49 +1639,49 @@ private: class ListStyleStyleValue final : public StyleValueWithDefaultOperators { public: - static NonnullRefPtr create( - NonnullRefPtr position, - NonnullRefPtr image, - NonnullRefPtr style_type) + static ValueComparingNonnullRefPtr create( + ValueComparingNonnullRefPtr position, + ValueComparingNonnullRefPtr image, + ValueComparingNonnullRefPtr style_type) { return adopt_ref(*new ListStyleStyleValue(move(position), move(image), move(style_type))); } virtual ~ListStyleStyleValue() override = default; - NonnullRefPtr position() const { return m_properties.position; } - NonnullRefPtr image() const { return m_properties.image; } - NonnullRefPtr style_type() const { return m_properties.style_type; } + ValueComparingNonnullRefPtr position() const { return m_properties.position; } + ValueComparingNonnullRefPtr image() const { return m_properties.image; } + ValueComparingNonnullRefPtr style_type() const { return m_properties.style_type; } virtual ErrorOr to_string() const override; - bool equals(ListStyleStyleValue const& other) const { return m_properties == other.m_properties; } + bool properties_equal(ListStyleStyleValue const& other) const { return m_properties == other.m_properties; } private: ListStyleStyleValue( - NonnullRefPtr position, - NonnullRefPtr image, - NonnullRefPtr style_type) + ValueComparingNonnullRefPtr position, + ValueComparingNonnullRefPtr image, + ValueComparingNonnullRefPtr style_type) : StyleValueWithDefaultOperators(Type::ListStyle) , m_properties { .position = move(position), .image = move(image), .style_type = move(style_type) } { } struct Properties { - NonnullRefPtr position; - NonnullRefPtr image; - NonnullRefPtr style_type; + ValueComparingNonnullRefPtr position; + ValueComparingNonnullRefPtr image; + ValueComparingNonnullRefPtr style_type; bool operator==(Properties const&) const = default; } m_properties; }; class NumericStyleValue : public StyleValueWithDefaultOperators { public: - static NonnullRefPtr create_float(float value) + static ValueComparingNonnullRefPtr create_float(float value) { return adopt_ref(*new NumericStyleValue(value)); } - static NonnullRefPtr create_integer(i64 value) + static ValueComparingNonnullRefPtr create_integer(i64 value) { return adopt_ref(*new NumericStyleValue(value)); } @@ -1640,7 +1702,7 @@ public: virtual ErrorOr to_string() const override; - bool equals(NumericStyleValue const& other) const { return m_value == other.m_value; } + bool properties_equal(NumericStyleValue const& other) const { return m_value == other.m_value; } private: explicit NumericStyleValue(Variant value) @@ -1654,36 +1716,36 @@ private: class OverflowStyleValue final : public StyleValueWithDefaultOperators { public: - static NonnullRefPtr create(NonnullRefPtr overflow_x, NonnullRefPtr overflow_y) + static ValueComparingNonnullRefPtr create(ValueComparingNonnullRefPtr overflow_x, ValueComparingNonnullRefPtr overflow_y) { return adopt_ref(*new OverflowStyleValue(move(overflow_x), move(overflow_y))); } virtual ~OverflowStyleValue() override = default; - NonnullRefPtr overflow_x() const { return m_properties.overflow_x; } - NonnullRefPtr overflow_y() const { return m_properties.overflow_y; } + ValueComparingNonnullRefPtr overflow_x() const { return m_properties.overflow_x; } + ValueComparingNonnullRefPtr overflow_y() const { return m_properties.overflow_y; } virtual ErrorOr to_string() const override; - bool equals(OverflowStyleValue const& other) const { return m_properties == other.m_properties; } + bool properties_equal(OverflowStyleValue const& other) const { return m_properties == other.m_properties; } private: - OverflowStyleValue(NonnullRefPtr overflow_x, NonnullRefPtr overflow_y) + OverflowStyleValue(ValueComparingNonnullRefPtr overflow_x, ValueComparingNonnullRefPtr overflow_y) : StyleValueWithDefaultOperators(Type::Overflow) , m_properties { .overflow_x = move(overflow_x), .overflow_y = move(overflow_y) } { } struct Properties { - NonnullRefPtr overflow_x; - NonnullRefPtr overflow_y; + ValueComparingNonnullRefPtr overflow_x; + ValueComparingNonnullRefPtr overflow_y; bool operator==(Properties const&) const = default; } m_properties; }; class PercentageStyleValue final : public StyleValueWithDefaultOperators { public: - static NonnullRefPtr create(Percentage percentage) + static ValueComparingNonnullRefPtr create(Percentage percentage) { return adopt_ref(*new PercentageStyleValue(move(percentage))); } @@ -1694,7 +1756,7 @@ public: virtual ErrorOr to_string() const override; - bool equals(PercentageStyleValue const& other) const { return m_percentage == other.m_percentage; } + bool properties_equal(PercentageStyleValue const& other) const { return m_percentage == other.m_percentage; } private: PercentageStyleValue(Percentage&& percentage) @@ -1708,7 +1770,7 @@ private: class PositionStyleValue final : public StyleValueWithDefaultOperators { public: - static NonnullRefPtr create(PositionEdge edge_x, LengthPercentage const& offset_x, PositionEdge edge_y, LengthPercentage const& offset_y) + static ValueComparingNonnullRefPtr create(PositionEdge edge_x, LengthPercentage const& offset_x, PositionEdge edge_y, LengthPercentage const& offset_y) { return adopt_ref(*new PositionStyleValue(edge_x, offset_x, edge_y, offset_y)); } @@ -1721,7 +1783,7 @@ public: virtual ErrorOr to_string() const override; - bool equals(PositionStyleValue const& other) const { return m_properties == other.m_properties; } + bool properties_equal(PositionStyleValue const& other) const { return m_properties == other.m_properties; } private: PositionStyleValue(PositionEdge edge_x, LengthPercentage const& offset_x, PositionEdge edge_y, LengthPercentage const& offset_y) @@ -1741,7 +1803,7 @@ private: class ResolutionStyleValue : public StyleValueWithDefaultOperators { public: - static NonnullRefPtr create(Resolution resolution) + static ValueComparingNonnullRefPtr create(Resolution resolution) { return adopt_ref(*new ResolutionStyleValue(move(resolution))); } @@ -1751,7 +1813,7 @@ public: virtual ErrorOr to_string() const override { return m_resolution.to_string(); } - bool equals(ResolutionStyleValue const& other) const { return m_resolution == other.m_resolution; } + bool properties_equal(ResolutionStyleValue const& other) const { return m_resolution == other.m_resolution; } private: explicit ResolutionStyleValue(Resolution resolution) @@ -1765,7 +1827,7 @@ private: class ShadowStyleValue final : public StyleValueWithDefaultOperators { public: - static NonnullRefPtr + static ValueComparingNonnullRefPtr create(Color color, Length const& offset_x, Length const& offset_y, Length const& blur_radius, Length const& spread_distance, ShadowPlacement placement) { return adopt_ref(*new ShadowStyleValue(color, offset_x, offset_y, blur_radius, spread_distance, placement)); @@ -1781,7 +1843,7 @@ public: virtual ErrorOr to_string() const override; - bool equals(ShadowStyleValue const& other) const { return m_properties == other.m_properties; } + bool properties_equal(ShadowStyleValue const& other) const { return m_properties == other.m_properties; } private: explicit ShadowStyleValue(Color color, Length const& offset_x, Length const& offset_y, Length const& blur_radius, Length const& spread_distance, ShadowPlacement placement) @@ -1790,7 +1852,7 @@ private: { } - virtual NonnullRefPtr absolutized(CSSPixelRect const& viewport_rect, Gfx::FontPixelMetrics const& font_metrics, CSSPixels font_size, CSSPixels root_font_size) const override; + virtual ValueComparingNonnullRefPtr absolutized(CSSPixelRect const& viewport_rect, Gfx::FontPixelMetrics const& font_metrics, CSSPixels font_size, CSSPixels root_font_size) const override; struct Properties { Color color; @@ -1805,7 +1867,7 @@ private: class StringStyleValue : public StyleValueWithDefaultOperators { public: - static NonnullRefPtr create(String const& string) + static ValueComparingNonnullRefPtr create(String const& string) { return adopt_ref(*new StringStyleValue(string)); } @@ -1813,7 +1875,7 @@ public: ErrorOr to_string() const override { return m_string; } - bool equals(StringStyleValue const& other) const { return m_string == other.m_string; } + bool properties_equal(StringStyleValue const& other) const { return m_string == other.m_string; } private: explicit StringStyleValue(String const& string) @@ -1827,48 +1889,48 @@ private: class TextDecorationStyleValue final : public StyleValueWithDefaultOperators { public: - static NonnullRefPtr create( - NonnullRefPtr line, - NonnullRefPtr thickness, - NonnullRefPtr style, - NonnullRefPtr color) + static ValueComparingNonnullRefPtr create( + ValueComparingNonnullRefPtr line, + ValueComparingNonnullRefPtr thickness, + ValueComparingNonnullRefPtr style, + ValueComparingNonnullRefPtr color) { return adopt_ref(*new TextDecorationStyleValue(move(line), move(thickness), move(style), move(color))); } virtual ~TextDecorationStyleValue() override = default; - NonnullRefPtr line() const { return m_properties.line; } - NonnullRefPtr thickness() const { return m_properties.thickness; } - NonnullRefPtr style() const { return m_properties.style; } - NonnullRefPtr color() const { return m_properties.color; } + ValueComparingNonnullRefPtr line() const { return m_properties.line; } + ValueComparingNonnullRefPtr thickness() const { return m_properties.thickness; } + ValueComparingNonnullRefPtr style() const { return m_properties.style; } + ValueComparingNonnullRefPtr color() const { return m_properties.color; } virtual ErrorOr to_string() const override; - bool equals(TextDecorationStyleValue const& other) const { return m_properties == other.m_properties; } + bool properties_equal(TextDecorationStyleValue const& other) const { return m_properties == other.m_properties; } private: TextDecorationStyleValue( - NonnullRefPtr line, - NonnullRefPtr thickness, - NonnullRefPtr style, - NonnullRefPtr color) + ValueComparingNonnullRefPtr line, + ValueComparingNonnullRefPtr thickness, + ValueComparingNonnullRefPtr style, + ValueComparingNonnullRefPtr color) : StyleValueWithDefaultOperators(Type::TextDecoration) , m_properties { .line = move(line), .thickness = move(thickness), .style = move(style), .color = move(color) } { } struct Properties { - NonnullRefPtr line; - NonnullRefPtr thickness; - NonnullRefPtr style; - NonnullRefPtr color; + ValueComparingNonnullRefPtr line; + ValueComparingNonnullRefPtr thickness; + ValueComparingNonnullRefPtr style; + ValueComparingNonnullRefPtr color; bool operator==(Properties const&) const = default; } m_properties; }; class TimeStyleValue : public StyleValueWithDefaultOperators { public: - static NonnullRefPtr create(Time time) + static ValueComparingNonnullRefPtr create(Time time) { return adopt_ref(*new TimeStyleValue(move(time))); } @@ -1878,7 +1940,7 @@ public: virtual ErrorOr to_string() const override { return m_time.to_string(); } - bool equals(TimeStyleValue const& other) const { return m_time == other.m_time; } + bool properties_equal(TimeStyleValue const& other) const { return m_time == other.m_time; } private: explicit TimeStyleValue(Time time) @@ -1892,21 +1954,21 @@ private: class TransformationStyleValue final : public StyleValueWithDefaultOperators { public: - static NonnullRefPtr create(CSS::TransformFunction transform_function, NonnullRefPtrVector&& values) + static ValueComparingNonnullRefPtr create(CSS::TransformFunction transform_function, StyleValueVector&& values) { return adopt_ref(*new TransformationStyleValue(transform_function, move(values))); } virtual ~TransformationStyleValue() override = default; CSS::TransformFunction transform_function() const { return m_properties.transform_function; } - NonnullRefPtrVector values() const { return m_properties.values; } + StyleValueVector values() const { return m_properties.values; } virtual ErrorOr to_string() const override; - bool equals(TransformationStyleValue const& other) const { return m_properties == other.m_properties; } + bool properties_equal(TransformationStyleValue const& other) const { return m_properties == other.m_properties; } private: - TransformationStyleValue(CSS::TransformFunction transform_function, NonnullRefPtrVector&& values) + TransformationStyleValue(CSS::TransformFunction transform_function, StyleValueVector&& values) : StyleValueWithDefaultOperators(Type::Transformation) , m_properties { .transform_function = transform_function, .values = move(values) } { @@ -1914,14 +1976,14 @@ private: struct Properties { CSS::TransformFunction transform_function; - NonnullRefPtrVector values; + StyleValueVector values; bool operator==(Properties const& other) const; } m_properties; }; class UnresolvedStyleValue final : public StyleValue { public: - static NonnullRefPtr create(Vector&& values, bool contains_var_or_attr) + static ValueComparingNonnullRefPtr create(Vector&& values, bool contains_var_or_attr) { return adopt_ref(*new UnresolvedStyleValue(move(values), contains_var_or_attr)); } @@ -1932,7 +1994,7 @@ public: Vector const& values() const { return m_values; } bool contains_var_or_attr() const { return m_contains_var_or_attr; } - virtual bool operator==(StyleValue const& other) const override; + virtual bool equals(StyleValue const& other) const override; private: UnresolvedStyleValue(Vector&& values, bool contains_var_or_attr) @@ -1948,16 +2010,16 @@ private: class UnsetStyleValue final : public StyleValueWithDefaultOperators { public: - static NonnullRefPtr the() + static ValueComparingNonnullRefPtr the() { - static NonnullRefPtr instance = adopt_ref(*new UnsetStyleValue); + static ValueComparingNonnullRefPtr instance = adopt_ref(*new UnsetStyleValue); return instance; } virtual ~UnsetStyleValue() override = default; ErrorOr to_string() const override { return String::from_utf8("unset"sv); } - bool equals(UnsetStyleValue const&) const { return true; } + bool properties_equal(UnsetStyleValue const&) const { return true; } private: UnsetStyleValue() @@ -1972,11 +2034,11 @@ public: Space, Comma, }; - static NonnullRefPtr create(NonnullRefPtrVector&& values, Separator separator) { return adopt_ref(*new StyleValueList(move(values), separator)); } + static ValueComparingNonnullRefPtr create(StyleValueVector&& values, Separator separator) { return adopt_ref(*new StyleValueList(move(values), separator)); } size_t size() const { return m_properties.values.size(); } - NonnullRefPtrVector const& values() const { return m_properties.values; } - NonnullRefPtr value_at(size_t i, bool allow_loop) const + StyleValueVector const& values() const { return m_properties.values; } + ValueComparingNonnullRefPtr value_at(size_t i, bool allow_loop) const { if (allow_loop) return m_properties.values[i % size()]; @@ -1985,10 +2047,10 @@ public: virtual ErrorOr to_string() const override; - bool equals(StyleValueList const& other) const { return m_properties == other.m_properties; } + bool properties_equal(StyleValueList const& other) const { return m_properties == other.m_properties; } private: - StyleValueList(NonnullRefPtrVector&& values, Separator separator) + StyleValueList(StyleValueVector&& values, Separator separator) : StyleValueWithDefaultOperators(Type::ValueList) , m_properties { .separator = separator, .values = move(values) } { @@ -1996,14 +2058,14 @@ private: struct Properties { Separator separator; - NonnullRefPtrVector values; + StyleValueVector values; bool operator==(Properties const&) const; } m_properties; }; class RectStyleValue : public StyleValueWithDefaultOperators { public: - static NonnullRefPtr create(EdgeRect rect); + static ValueComparingNonnullRefPtr create(EdgeRect rect); virtual ~RectStyleValue() override = default; EdgeRect rect() const { return m_rect; } @@ -2011,7 +2073,7 @@ public: virtual bool has_rect() const override { return true; } virtual EdgeRect to_rect() const override { return m_rect; } - bool equals(RectStyleValue const& other) const { return m_rect == other.m_rect; } + bool properties_equal(RectStyleValue const& other) const { return m_rect == other.m_rect; } private: explicit RectStyleValue(EdgeRect rect)