mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-08-26 12:17:52 +00:00
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:
parent
3fe3adadc4
commit
bc2ca96f50
Notes:
github-actions[bot]
2025-08-11 16:11:16 +00:00
Author: https://github.com/Calme1709
Commit: bc2ca96f50
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/5734
Reviewed-by: https://github.com/AtkinsSJ ✅
Reviewed-by: https://github.com/Hendiadyoin1
Reviewed-by: https://github.com/gmta
Reviewed-by: https://github.com/tcl3
3 changed files with 6 additions and 3 deletions
|
@ -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));
|
||||
|
|
|
@ -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
|
||||
{
|
||||
|
|
|
@ -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));
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue