diff --git a/Userland/Libraries/LibWeb/CSS/Angle.h b/Userland/Libraries/LibWeb/CSS/Angle.h index 9795ac2a62..ed49a80bcb 100644 --- a/Userland/Libraries/LibWeb/CSS/Angle.h +++ b/Userland/Libraries/LibWeb/CSS/Angle.h @@ -7,6 +7,7 @@ #pragma once #include +#include #include namespace Web::CSS { @@ -55,3 +56,11 @@ private: }; } + +template<> +struct AK::Formatter : Formatter { + ErrorOr format(FormatBuilder& builder, Web::CSS::Angle const& angle) + { + return Formatter::format(builder, angle.to_string()); + } +}; diff --git a/Userland/Libraries/LibWeb/CSS/Frequency.h b/Userland/Libraries/LibWeb/CSS/Frequency.h index c71cc67a1a..0c0c326549 100644 --- a/Userland/Libraries/LibWeb/CSS/Frequency.h +++ b/Userland/Libraries/LibWeb/CSS/Frequency.h @@ -7,6 +7,7 @@ #pragma once #include +#include #include namespace Web::CSS { @@ -50,4 +51,13 @@ private: float m_value { 0 }; RefPtr m_calculated_style; }; + } + +template<> +struct AK::Formatter : Formatter { + ErrorOr format(FormatBuilder& builder, Web::CSS::Frequency const& frequency) + { + return Formatter::format(builder, frequency.to_string()); + } +}; diff --git a/Userland/Libraries/LibWeb/CSS/Number.h b/Userland/Libraries/LibWeb/CSS/Number.h index 3d78e28e78..feb2259f3b 100644 --- a/Userland/Libraries/LibWeb/CSS/Number.h +++ b/Userland/Libraries/LibWeb/CSS/Number.h @@ -6,6 +6,7 @@ #pragma once +#include #include #include @@ -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 : Formatter { + ErrorOr format(FormatBuilder& builder, Web::CSS::Number const& number) + { + return Formatter::format(builder, number.to_string()); + } +}; diff --git a/Userland/Libraries/LibWeb/CSS/Time.h b/Userland/Libraries/LibWeb/CSS/Time.h index add8b692a0..1c2d1b140a 100644 --- a/Userland/Libraries/LibWeb/CSS/Time.h +++ b/Userland/Libraries/LibWeb/CSS/Time.h @@ -7,6 +7,7 @@ #pragma once #include +#include #include namespace Web::CSS { @@ -53,3 +54,11 @@ private: }; } + +template<> +struct AK::Formatter : Formatter { + ErrorOr format(FormatBuilder& builder, Web::CSS::Time const& time) + { + return Formatter::format(builder, time.to_string()); + } +};