1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 14:48:14 +00:00

LibWeb: Make the CSS serialization functions actually output things :^)

Pro tip: If your function takes a StringBuilder by value, it doesn't
actually append anything to the caller's StringBuilder. On the plus
side, I probably won't make this mistake for a while? I hope?
This commit is contained in:
Sam Atkins 2021-10-17 19:54:07 +01:00 committed by Linus Groh
parent 48687c3fbb
commit 0588db5c30
2 changed files with 10 additions and 10 deletions

View file

@ -11,20 +11,20 @@
namespace Web::CSS {
// https://www.w3.org/TR/cssom-1/#escape-a-character
void escape_a_character(StringBuilder builder, u32 character)
void escape_a_character(StringBuilder& builder, u32 character)
{
builder.append('\\');
builder.append_code_point(character);
}
// https://www.w3.org/TR/cssom-1/#escape-a-character-as-code-point
void escape_a_character_as_code_point(StringBuilder builder, u32 character)
void escape_a_character_as_code_point(StringBuilder& builder, u32 character)
{
builder.appendff("\\{:x} ", character);
}
// https://www.w3.org/TR/cssom-1/#serialize-an-identifier
void serialize_an_identifier(StringBuilder builder, StringView const& ident)
void serialize_an_identifier(StringBuilder& builder, StringView const& ident)
{
Utf8View characters { ident };
auto first_character = characters.is_empty() ? 0 : *characters.begin();
@ -76,7 +76,7 @@ void serialize_an_identifier(StringBuilder builder, StringView const& ident)
}
// https://www.w3.org/TR/cssom-1/#serialize-a-string
void serialize_a_string(StringBuilder builder, StringView const& string)
void serialize_a_string(StringBuilder& builder, StringView const& string)
{
Utf8View characters { string };
@ -108,7 +108,7 @@ void serialize_a_string(StringBuilder builder, StringView const& string)
}
// https://www.w3.org/TR/cssom-1/#serialize-a-url
void serialize_a_url(StringBuilder builder, StringView const& url)
void serialize_a_url(StringBuilder& builder, StringView const& url)
{
// To serialize a URL means to create a string represented by "url(",
// followed by the serialization of the URL as a string, followed by ")".