|
@@ -6,6 +6,7 @@
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
+#include <AK/String.h>
|
|
|
#include <AK/Types.h>
|
|
|
#include <math.h>
|
|
|
|
|
@@ -68,8 +69,23 @@ public:
|
|
|
return { Type::Number, m_value / other.m_value };
|
|
|
}
|
|
|
|
|
|
+ String to_string() const
|
|
|
+ {
|
|
|
+ if (m_type == Type::IntegerWithExplicitSign)
|
|
|
+ return String::formatted("{:+}", m_value);
|
|
|
+ return String::number(m_value);
|
|
|
+ }
|
|
|
+
|
|
|
private:
|
|
|
float m_value { 0 };
|
|
|
Type m_type;
|
|
|
};
|
|
|
}
|
|
|
+
|
|
|
+template<>
|
|
|
+struct AK::Formatter<Web::CSS::Number> : Formatter<StringView> {
|
|
|
+ ErrorOr<void> format(FormatBuilder& builder, Web::CSS::Number const& number)
|
|
|
+ {
|
|
|
+ return Formatter<StringView>::format(builder, number.to_string());
|
|
|
+ }
|
|
|
+};
|