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.
This commit is contained in:
Callum Law 2025-08-06 22:19:09 +12:00 committed by Sam Atkins
commit bc2ca96f50
Notes: github-actions[bot] 2025-08-11 16:11:16 +00:00
3 changed files with 6 additions and 3 deletions

View file

@ -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));

View file

@ -8,6 +8,7 @@
#include <AK/String.h>
#include <AK/Types.h>
#include <LibWeb/CSS/SerializationMode.h>
#include <math.h>
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
{

View file

@ -8,6 +8,8 @@
#include <AK/String.h>
#include <AK/Variant.h>
#include <LibWeb/CSS/SerializationMode.h>
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));
}