From d1b06af307068bf5e06bac8a433df299a5f7c274 Mon Sep 17 00:00:00 2001 From: MacDue Date: Mon, 7 Nov 2022 19:02:00 +0100 Subject: [PATCH] LibWeb: Add missing equals() function for ConicGradientStyleValue Also, tidy up the one for LinearGradientStyleValue. --- Userland/Libraries/LibWeb/CSS/StyleValue.cpp | 27 +++++++++----------- 1 file changed, 12 insertions(+), 15 deletions(-) diff --git a/Userland/Libraries/LibWeb/CSS/StyleValue.cpp b/Userland/Libraries/LibWeb/CSS/StyleValue.cpp index e6fee9c440..ff4b975f68 100644 --- a/Userland/Libraries/LibWeb/CSS/StyleValue.cpp +++ b/Userland/Libraries/LibWeb/CSS/StyleValue.cpp @@ -1821,19 +1821,10 @@ bool LinearGradientStyleValue::equals(StyleValue const& other_) const if (type() != other_.type()) return false; auto& other = other_.as_linear_gradient(); - - if (m_gradient_type != other.m_gradient_type - || m_repeating != other.m_repeating - || m_direction != other.m_direction - || m_color_stop_list.size() != other.m_color_stop_list.size()) { - return false; - } - - for (size_t i = 0; i < m_color_stop_list.size(); i++) { - if (m_color_stop_list[i] != other.m_color_stop_list[i]) - return false; - } - return true; + return (m_gradient_type == other.m_gradient_type + && m_repeating == other.m_repeating + && m_direction == other.m_direction + && m_color_stop_list == other.m_color_stop_list); } float LinearGradientStyleValue::angle_degrees(Gfx::FloatSize const& gradient_size) const @@ -2183,9 +2174,15 @@ void ConicGradientStyleValue::paint(PaintContext& context, Gfx::IntRect const& d Painting::paint_conic_gradient(context, dest_rect, m_resolved->data, m_resolved->position.to_rounded()); } -bool ConicGradientStyleValue::equals(StyleValue const&) const +bool ConicGradientStyleValue::equals(StyleValue const& other) const { - return false; + if (type() != other.type()) + return false; + auto& other_gradient = other.as_conic_gradient(); + return (m_from_angle == other_gradient.m_from_angle + && m_position == other_gradient.m_position + && m_color_stop_list == other_gradient.m_color_stop_list + && m_repeating == other_gradient.m_repeating); } float ConicGradientStyleValue::angle_degrees() const