2021-10-06 10:27:13 -03:00
|
|
|
/*
|
2025-05-21 12:56:49 -03:00
|
|
|
* Copyright (c) 2021-2025, Sam Atkins <sam@ladybird.org>
|
2021-10-06 10:27:13 -03:00
|
|
|
*
|
|
|
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
2023-01-06 15:02:26 -03:00
|
|
|
#include <AK/String.h>
|
2021-10-14 12:50:43 -03:00
|
|
|
#include <AK/StringBuilder.h>
|
2021-10-06 10:27:13 -03:00
|
|
|
#include <AK/StringView.h>
|
2026-06-22 09:15:11 -03:00
|
|
|
#include <AK/Utf16StringBuilder.h>
|
2022-09-11 13:20:16 -03:00
|
|
|
#include <AK/Vector.h>
|
2022-07-12 11:30:13 -03:00
|
|
|
#include <LibGfx/Color.h>
|
2023-12-09 19:30:01 -03:00
|
|
|
#include <LibGfx/Font/UnicodeRange.h>
|
2026-01-04 00:27:41 -03:00
|
|
|
#include <LibWeb/CSS/SerializationMode.h>
|
2025-03-26 13:20:55 -03:00
|
|
|
#include <LibWeb/CSS/StyleProperty.h>
|
2025-07-19 23:35:33 -03:00
|
|
|
#include <LibWeb/Export.h>
|
2021-10-06 10:27:13 -03:00
|
|
|
|
|
|
|
|
namespace Web::CSS {
|
|
|
|
|
|
2023-08-22 08:05:44 -03:00
|
|
|
void escape_a_character(StringBuilder&, u32 character);
|
|
|
|
|
void escape_a_character_as_code_point(StringBuilder&, u32 character);
|
2025-07-19 23:35:33 -03:00
|
|
|
WEB_API void serialize_an_identifier(StringBuilder&, StringView ident);
|
2023-08-22 08:05:44 -03:00
|
|
|
void serialize_a_string(StringBuilder&, StringView string);
|
2025-07-19 23:35:33 -03:00
|
|
|
WEB_API void serialize_a_url(StringBuilder&, StringView url);
|
2023-12-09 19:30:01 -03:00
|
|
|
void serialize_unicode_ranges(StringBuilder&, Vector<Gfx::UnicodeRange> const& unicode_ranges);
|
2026-01-08 09:02:18 -03:00
|
|
|
WEB_API void serialize_a_number(StringBuilder&, double value);
|
2026-06-22 09:15:11 -03:00
|
|
|
WEB_API void serialize_a_number(Utf16StringBuilder&, double value);
|
2021-10-14 12:50:43 -03:00
|
|
|
|
2023-08-22 08:05:44 -03:00
|
|
|
String serialize_an_identifier(StringView ident);
|
|
|
|
|
String serialize_a_string(StringView string);
|
|
|
|
|
String serialize_a_url(StringView url);
|
2025-08-18 12:07:12 -03:00
|
|
|
String serialize_a_number(double value);
|
2021-10-06 10:27:13 -03:00
|
|
|
|
2024-11-28 13:26:57 -03:00
|
|
|
// https://www.w3.org/TR/cssom/#serialize-a-comma-separated-list
|
2022-09-11 13:20:16 -03:00
|
|
|
template<typename T, typename SerializeItem>
|
2023-08-22 08:05:44 -03:00
|
|
|
void serialize_a_comma_separated_list(StringBuilder& builder, Vector<T> const& items, SerializeItem serialize_item)
|
2022-09-11 13:20:16 -03:00
|
|
|
{
|
2024-11-28 13:26:57 -03:00
|
|
|
// To serialize a comma-separated list concatenate all items of the list in list order
|
|
|
|
|
// while separating them by ", ", i.e., COMMA (U+002C) followed by a single SPACE (U+0020).
|
2022-09-11 13:20:16 -03:00
|
|
|
for (size_t i = 0; i < items.size(); i++) {
|
|
|
|
|
auto& item = items.at(i);
|
2023-08-22 08:05:44 -03:00
|
|
|
serialize_item(builder, item);
|
2022-09-11 13:20:16 -03:00
|
|
|
if ((i + 1) < items.size()) {
|
2024-11-28 13:26:57 -03:00
|
|
|
builder.append(", "sv);
|
2022-09-11 13:20:16 -03:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2025-03-26 13:20:55 -03:00
|
|
|
String serialize_a_css_declaration(StringView property, StringView value, Important = Important::No);
|
|
|
|
|
|
2025-10-30 13:14:54 -03:00
|
|
|
String serialize_a_series_of_component_values(ReadonlySpan<Parser::ComponentValue>);
|
2026-05-27 17:23:52 -03:00
|
|
|
String serialize_a_series_of_component_values_preserving_original_source_text(ReadonlySpan<Parser::ComponentValue>);
|
2026-01-04 00:27:41 -03:00
|
|
|
String serialize_a_positional_value_list(StyleValueVector const& values, SerializationMode mode);
|
2025-05-21 12:56:49 -03:00
|
|
|
|
2021-10-06 10:27:13 -03:00
|
|
|
}
|