summaryrefslogtreecommitdiff
path: root/Userland/Libraries/LibWeb/CSS/Serialize.h
diff options
context:
space:
mode:
authorelectrikmilk <brandonjordan124@gmail.com>2022-09-11 12:20:16 -0400
committerSam Atkins <atkinssj@gmail.com>2022-09-14 10:50:33 +0100
commitfdd202259d936b516d0c4171fa5af6933c0a56fa (patch)
tree1e5da90b4589f62c20f9a955d80f7489282cb3f9 /Userland/Libraries/LibWeb/CSS/Serialize.h
parentb0f9ad00008a48d98d4681e7622c7921783167d9 (diff)
downloadserenity-fdd202259d936b516d0c4171fa5af6933c0a56fa.zip
LibWeb: Add partial serialization for CSSFontFaceRule
This partially adds serialization code for `CSSFontFaceRule::serialized()` to spec. This is only partially implemented as some parts of the `@font-face` rule are not implemented yet.
Diffstat (limited to 'Userland/Libraries/LibWeb/CSS/Serialize.h')
-rw-r--r--Userland/Libraries/LibWeb/CSS/Serialize.h16
1 files changed, 16 insertions, 0 deletions
diff --git a/Userland/Libraries/LibWeb/CSS/Serialize.h b/Userland/Libraries/LibWeb/CSS/Serialize.h
index 3988c2ba61..c8461fda0a 100644
--- a/Userland/Libraries/LibWeb/CSS/Serialize.h
+++ b/Userland/Libraries/LibWeb/CSS/Serialize.h
@@ -9,7 +9,9 @@
#include <AK/String.h>
#include <AK/StringBuilder.h>
#include <AK/StringView.h>
+#include <AK/Vector.h>
#include <LibGfx/Color.h>
+#include <LibWeb/CSS/UnicodeRange.h>
namespace Web::CSS {
@@ -18,6 +20,8 @@ void escape_a_character_as_code_point(StringBuilder&, u32 character);
void serialize_an_identifier(StringBuilder&, StringView ident);
void serialize_a_string(StringBuilder&, StringView string);
void serialize_a_url(StringBuilder&, StringView url);
+void serialize_a_local(StringBuilder&, StringView path);
+void serialize_unicode_ranges(StringBuilder&, Vector<UnicodeRange> const& unicode_ranges);
void serialize_a_srgb_value(StringBuilder&, Color color);
String escape_a_character(u32 character);
@@ -27,4 +31,16 @@ String serialize_a_string(StringView string);
String serialize_a_url(StringView url);
String serialize_a_srgb_value(Color color);
+template<typename T, typename SerializeItem>
+void serialize_a_comma_separated_list(StringBuilder& builder, Vector<T> const& items, SerializeItem serialize_item)
+{
+ for (size_t i = 0; i < items.size(); i++) {
+ auto& item = items.at(i);
+ serialize_item(item);
+ if ((i + 1) < items.size()) {
+ builder.append(",\n"sv);
+ }
+ }
+}
+
}