From bc2ca96f50bfe7dca8ff37c0da53b705e3dae512 Mon Sep 17 00:00:00 2001 From: Callum Law Date: Wed, 6 Aug 2025 22:19:09 +1200 Subject: [PATCH] LibWeb: Make signature of CSS::{Percentage,Number}::to_string consistent By making this consistent with the other numeric data type classes we can simplify cases where we are dealing with variants containing these types. --- Libraries/LibWeb/CSS/Number.cpp | 2 +- Libraries/LibWeb/CSS/Number.h | 3 ++- Libraries/LibWeb/CSS/Percentage.h | 4 +++- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/Libraries/LibWeb/CSS/Number.cpp b/Libraries/LibWeb/CSS/Number.cpp index b6c6c49b807..3e19325e997 100644 --- a/Libraries/LibWeb/CSS/Number.cpp +++ b/Libraries/LibWeb/CSS/Number.cpp @@ -9,7 +9,7 @@ namespace Web::CSS { -String Number::to_string() const +String Number::to_string(SerializationMode) const { if (m_type == Type::IntegerWithExplicitSign) return MUST(String::formatted("{:+}", m_value)); diff --git a/Libraries/LibWeb/CSS/Number.h b/Libraries/LibWeb/CSS/Number.h index 5ec670bb9dd..a5d494c81fa 100644 --- a/Libraries/LibWeb/CSS/Number.h +++ b/Libraries/LibWeb/CSS/Number.h @@ -8,6 +8,7 @@ #include #include +#include #include namespace Web::CSS { @@ -70,7 +71,7 @@ public: return { Type::Number, m_value / other.m_value }; } - String to_string() const; + String to_string(SerializationMode = SerializationMode::Normal) const; bool operator==(Number const& other) const { diff --git a/Libraries/LibWeb/CSS/Percentage.h b/Libraries/LibWeb/CSS/Percentage.h index ea71db3befa..7262c21029e 100644 --- a/Libraries/LibWeb/CSS/Percentage.h +++ b/Libraries/LibWeb/CSS/Percentage.h @@ -8,6 +8,8 @@ #include #include +#include + namespace Web::CSS { class Percentage { @@ -20,7 +22,7 @@ public: double value() const { return m_value; } double as_fraction() const { return m_value * 0.01; } - String to_string() const + String to_string(SerializationMode = SerializationMode::Normal) const { return MUST(String::formatted("{}%", m_value)); }