summaryrefslogtreecommitdiff
path: root/Userland/Libraries/LibWeb
diff options
context:
space:
mode:
authorSam Atkins <atkinssj@serenityos.org>2022-01-19 17:30:29 +0000
committerAndreas Kling <kling@serenityos.org>2022-01-20 00:04:10 +0100
commitb34950a8258ae88e039720cf85864c37236616c1 (patch)
tree0265bfc3ccda8f758f6c17fe079aef6ef8edb419 /Userland/Libraries/LibWeb
parentbfcbab0dcfe642021ec279f30209cf4c07993f54 (diff)
downloadserenity-b34950a8258ae88e039720cf85864c37236616c1.zip
LibWeb: Add Formatters for Length, Percentage and LengthPercentage
Diffstat (limited to 'Userland/Libraries/LibWeb')
-rw-r--r--Userland/Libraries/LibWeb/CSS/Length.h8
-rw-r--r--Userland/Libraries/LibWeb/CSS/Percentage.h16
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());
+ }
+};