diff options
author | Sam Atkins <atkinssj@serenityos.org> | 2022-01-19 17:30:29 +0000 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2022-01-20 00:04:10 +0100 |
commit | b34950a8258ae88e039720cf85864c37236616c1 (patch) | |
tree | 0265bfc3ccda8f758f6c17fe079aef6ef8edb419 /Userland | |
parent | bfcbab0dcfe642021ec279f30209cf4c07993f54 (diff) | |
download | serenity-b34950a8258ae88e039720cf85864c37236616c1.zip |
LibWeb: Add Formatters for Length, Percentage and LengthPercentage
Diffstat (limited to 'Userland')
-rw-r--r-- | Userland/Libraries/LibWeb/CSS/Length.h | 8 | ||||
-rw-r--r-- | Userland/Libraries/LibWeb/CSS/Percentage.h | 16 |
2 files changed, 24 insertions, 0 deletions
diff --git a/Userland/Libraries/LibWeb/CSS/Length.h b/Userland/Libraries/LibWeb/CSS/Length.h index db84635bd3..ed7335c6a2 100644 --- a/Userland/Libraries/LibWeb/CSS/Length.h +++ b/Userland/Libraries/LibWeb/CSS/Length.h @@ -147,3 +147,11 @@ private: }; } + +template<> +struct AK::Formatter<Web::CSS::Length> : Formatter<StringView> { + ErrorOr<void> format(FormatBuilder& builder, Web::CSS::Length const& length) + { + return Formatter<StringView>::format(builder, length.to_string()); + } +}; diff --git a/Userland/Libraries/LibWeb/CSS/Percentage.h b/Userland/Libraries/LibWeb/CSS/Percentage.h index 86dce08e6d..74ad35989e 100644 --- a/Userland/Libraries/LibWeb/CSS/Percentage.h +++ b/Userland/Libraries/LibWeb/CSS/Percentage.h @@ -139,3 +139,19 @@ public: }; } + +template<> +struct AK::Formatter<Web::CSS::Percentage> : Formatter<StringView> { + ErrorOr<void> format(FormatBuilder& builder, Web::CSS::Percentage const& percentage) + { + return Formatter<StringView>::format(builder, percentage.to_string()); + } +}; + +template<> +struct AK::Formatter<Web::CSS::LengthPercentage> : Formatter<StringView> { + ErrorOr<void> format(FormatBuilder& builder, Web::CSS::LengthPercentage const& length_percentage) + { + return Formatter<StringView>::format(builder, length_percentage.to_string()); + } +}; |