diff --git a/Userland/Libraries/LibWeb/CSS/UnicodeRange.h b/Userland/Libraries/LibGfx/Font/UnicodeRange.h similarity index 93% rename from Userland/Libraries/LibWeb/CSS/UnicodeRange.h rename to Userland/Libraries/LibGfx/Font/UnicodeRange.h index 9c717775de..2d58be5d14 100644 --- a/Userland/Libraries/LibWeb/CSS/UnicodeRange.h +++ b/Userland/Libraries/LibGfx/Font/UnicodeRange.h @@ -9,9 +9,8 @@ #include #include -namespace Web::CSS { +namespace Gfx { -// https://www.w3.org/TR/css-syntax-3/#urange-syntax class UnicodeRange { public: UnicodeRange(u32 min_code_point, u32 max_code_point) diff --git a/Userland/Libraries/LibWeb/CSS/FontFace.cpp b/Userland/Libraries/LibWeb/CSS/FontFace.cpp index 1d1eb415a8..1552fc8a63 100644 --- a/Userland/Libraries/LibWeb/CSS/FontFace.cpp +++ b/Userland/Libraries/LibWeb/CSS/FontFace.cpp @@ -9,7 +9,7 @@ namespace Web::CSS { -FontFace::FontFace(FlyString font_family, Optional weight, Optional slope, Vector sources, Vector unicode_ranges) +FontFace::FontFace(FlyString font_family, Optional weight, Optional slope, Vector sources, Vector unicode_ranges) : m_font_family(move(font_family)) , m_weight(weight) , m_slope(slope) diff --git a/Userland/Libraries/LibWeb/CSS/FontFace.h b/Userland/Libraries/LibWeb/CSS/FontFace.h index eb46b3de30..5257b51ac8 100644 --- a/Userland/Libraries/LibWeb/CSS/FontFace.h +++ b/Userland/Libraries/LibWeb/CSS/FontFace.h @@ -9,7 +9,7 @@ #include #include -#include +#include namespace Web::CSS { @@ -21,14 +21,14 @@ public: Optional format; }; - FontFace(FlyString font_family, Optional weight, Optional slope, Vector sources, Vector unicode_ranges); + FontFace(FlyString font_family, Optional weight, Optional slope, Vector sources, Vector unicode_ranges); ~FontFace() = default; FlyString font_family() const { return m_font_family; } Optional weight() const { return m_weight; } Optional slope() const { return m_slope; } Vector const& sources() const { return m_sources; } - Vector const& unicode_ranges() const { return m_unicode_ranges; } + Vector const& unicode_ranges() const { return m_unicode_ranges; } // FIXME: font-stretch, font-feature-settings private: @@ -36,7 +36,7 @@ private: Optional m_weight { 0 }; Optional m_slope { 0 }; Vector m_sources; - Vector m_unicode_ranges; + Vector m_unicode_ranges; }; } diff --git a/Userland/Libraries/LibWeb/CSS/Parser/Parser.cpp b/Userland/Libraries/LibWeb/CSS/Parser/Parser.cpp index 099d0eca3d..97ac03cd0e 100644 --- a/Userland/Libraries/LibWeb/CSS/Parser/Parser.cpp +++ b/Userland/Libraries/LibWeb/CSS/Parser/Parser.cpp @@ -1661,7 +1661,7 @@ Optional Parser::parse_ratio(TokenStream& tokens) } // https://www.w3.org/TR/css-syntax-3/#urange-syntax -Optional Parser::parse_unicode_range(TokenStream& tokens) +Optional Parser::parse_unicode_range(TokenStream& tokens) { auto transaction = tokens.begin_transaction(); tokens.skip_whitespace(); @@ -1687,7 +1687,7 @@ Optional Parser::parse_unicode_range(TokenStream& || component_value.is(Token::Type::Whitespace); }; - auto create_unicode_range = [&](StringView text, auto& local_transaction) -> Optional { + auto create_unicode_range = [&](StringView text, auto& local_transaction) -> Optional { auto maybe_unicode_range = parse_unicode_range(text); if (maybe_unicode_range.has_value()) { local_transaction.commit(); @@ -1769,9 +1769,9 @@ Optional Parser::parse_unicode_range(TokenStream& return {}; } -Optional Parser::parse_unicode_range(StringView text) +Optional Parser::parse_unicode_range(StringView text) { - auto make_valid_unicode_range = [&](u32 start_value, u32 end_value) -> Optional { + auto make_valid_unicode_range = [&](u32 start_value, u32 end_value) -> Optional { // https://www.w3.org/TR/css-syntax-3/#maximum-allowed-code-point constexpr u32 maximum_allowed_code_point = 0x10FFFF; @@ -1790,7 +1790,7 @@ Optional Parser::parse_unicode_range(StringView text) } // 3. Otherwise, the represents a contiguous range of codepoints from start value to end value, inclusive. - return UnicodeRange { start_value, end_value }; + return Gfx::UnicodeRange { start_value, end_value }; }; // 1. Skipping the first u token, concatenate the representations of all the tokens in the production together. @@ -4160,7 +4160,7 @@ CSSRule* Parser::parse_font_face_rule(TokenStream& tokens) Optional font_family; Vector src; - Vector unicode_range; + Vector unicode_range; Optional weight; Optional slope; @@ -4237,7 +4237,7 @@ CSSRule* Parser::parse_font_face_rule(TokenStream& tokens) continue; } if (declaration.name().equals_ignoring_ascii_case("unicode-range"sv)) { - Vector unicode_ranges; + Vector unicode_ranges; bool unicode_range_invalid = false; TokenStream all_tokens { declaration.values() }; auto range_token_lists = parse_a_comma_separated_list_of_component_values(all_tokens); diff --git a/Userland/Libraries/LibWeb/CSS/Parser/Parser.h b/Userland/Libraries/LibWeb/CSS/Parser/Parser.h index 8a02977d57..935be05045 100644 --- a/Userland/Libraries/LibWeb/CSS/Parser/Parser.h +++ b/Userland/Libraries/LibWeb/CSS/Parser/Parser.h @@ -10,6 +10,7 @@ #include #include #include +#include #include #include #include @@ -31,7 +32,6 @@ #include #include #include -#include #include namespace Web::CSS::Parser { @@ -176,8 +176,8 @@ private: Optional parse_length(ComponentValue const&); [[nodiscard]] Optional parse_source_size_value(ComponentValue const&); Optional parse_ratio(TokenStream&); - Optional parse_unicode_range(TokenStream&); - Optional parse_unicode_range(StringView); + Optional parse_unicode_range(TokenStream&); + Optional parse_unicode_range(StringView); Optional parse_grid_size(ComponentValue const&); Optional parse_min_max(Vector const&); Optional parse_repeat(Vector const&); diff --git a/Userland/Libraries/LibWeb/CSS/Serialize.cpp b/Userland/Libraries/LibWeb/CSS/Serialize.cpp index c2119c4c72..42fcdd1b34 100644 --- a/Userland/Libraries/LibWeb/CSS/Serialize.cpp +++ b/Userland/Libraries/LibWeb/CSS/Serialize.cpp @@ -128,9 +128,9 @@ void serialize_a_local(StringBuilder& builder, StringView path) } // NOTE: No spec currently exists for serializing a <'unicode-range'>. -void serialize_unicode_ranges(StringBuilder& builder, Vector const& unicode_ranges) +void serialize_unicode_ranges(StringBuilder& builder, Vector const& unicode_ranges) { - serialize_a_comma_separated_list(builder, unicode_ranges, [](auto& builder, UnicodeRange unicode_range) -> void { + serialize_a_comma_separated_list(builder, unicode_ranges, [](auto& builder, Gfx::UnicodeRange unicode_range) -> void { return serialize_a_string(builder, unicode_range.to_string()); }); } diff --git a/Userland/Libraries/LibWeb/CSS/Serialize.h b/Userland/Libraries/LibWeb/CSS/Serialize.h index 4e672ac1a8..7850004cfa 100644 --- a/Userland/Libraries/LibWeb/CSS/Serialize.h +++ b/Userland/Libraries/LibWeb/CSS/Serialize.h @@ -11,7 +11,7 @@ #include #include #include -#include +#include namespace Web::CSS { @@ -21,7 +21,7 @@ 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 const& unicode_ranges); +void serialize_unicode_ranges(StringBuilder&, Vector const& unicode_ranges); void serialize_a_srgb_value(StringBuilder&, Color color); String escape_a_character(u32 character); diff --git a/Userland/Libraries/LibWeb/Forward.h b/Userland/Libraries/LibWeb/Forward.h index 6964c22693..7884cd4f8a 100644 --- a/Userland/Libraries/LibWeb/Forward.h +++ b/Userland/Libraries/LibWeb/Forward.h @@ -186,7 +186,6 @@ class TimeStyleValue; class Transformation; class TransformationStyleValue; class URLStyleValue; -class UnicodeRange; class UnresolvedStyleValue; class UnsetStyleValue; class VisualViewport;