From 3a5eabc43b318ebdeed1e1d1afab39199f19e39c Mon Sep 17 00:00:00 2001 From: Andrew Kaster Date: Tue, 7 May 2024 09:18:37 -0600 Subject: [PATCH] LibWeb: Rename CSS::FontFace to CSS::ParsedFontFace This implementation detail of CSSFontFaceRule is hogging the name of a Web API from CSS Font Loading Module Level 3. --- Userland/Libraries/LibWeb/CMakeLists.txt | 2 +- Userland/Libraries/LibWeb/CSS/CSSFontFaceRule.cpp | 8 ++++---- Userland/Libraries/LibWeb/CSS/CSSFontFaceRule.h | 10 +++++----- .../LibWeb/CSS/{FontFace.cpp => ParsedFontFace.cpp} | 4 ++-- .../LibWeb/CSS/{FontFace.h => ParsedFontFace.h} | 6 +++--- Userland/Libraries/LibWeb/CSS/Parser/Parser.cpp | 10 +++++----- Userland/Libraries/LibWeb/CSS/Parser/Parser.h | 4 ++-- Userland/Libraries/LibWeb/Forward.h | 2 +- 8 files changed, 23 insertions(+), 23 deletions(-) rename Userland/Libraries/LibWeb/CSS/{FontFace.cpp => ParsedFontFace.cpp} (64%) rename Userland/Libraries/LibWeb/CSS/{FontFace.h => ParsedFontFace.h} (84%) diff --git a/Userland/Libraries/LibWeb/CMakeLists.txt b/Userland/Libraries/LibWeb/CMakeLists.txt index c9f8a03cc13122..e1f9417041e0a5 100644 --- a/Userland/Libraries/LibWeb/CMakeLists.txt +++ b/Userland/Libraries/LibWeb/CMakeLists.txt @@ -55,7 +55,6 @@ set(SOURCES CSS/Display.cpp CSS/EdgeRect.cpp CSS/Flex.cpp - CSS/FontFace.cpp CSS/Frequency.cpp CSS/GridTrackPlacement.cpp CSS/GridTrackSize.cpp @@ -79,6 +78,7 @@ set(SOURCES CSS/Parser/SelectorParsing.cpp CSS/Parser/Token.cpp CSS/Parser/Tokenizer.cpp + CSS/ParsedFontFace.cpp CSS/PercentageOr.cpp CSS/PreferredColorScheme.cpp CSS/Ratio.cpp diff --git a/Userland/Libraries/LibWeb/CSS/CSSFontFaceRule.cpp b/Userland/Libraries/LibWeb/CSS/CSSFontFaceRule.cpp index 7711f44b1c96f7..d1c223f93ce4c2 100644 --- a/Userland/Libraries/LibWeb/CSS/CSSFontFaceRule.cpp +++ b/Userland/Libraries/LibWeb/CSS/CSSFontFaceRule.cpp @@ -16,12 +16,12 @@ namespace Web::CSS { JS_DEFINE_ALLOCATOR(CSSFontFaceRule); -JS::NonnullGCPtr CSSFontFaceRule::create(JS::Realm& realm, FontFace&& font_face) +JS::NonnullGCPtr CSSFontFaceRule::create(JS::Realm& realm, ParsedFontFace&& font_face) { return realm.heap().allocate(realm, realm, move(font_face)); } -CSSFontFaceRule::CSSFontFaceRule(JS::Realm& realm, FontFace&& font_face) +CSSFontFaceRule::CSSFontFaceRule(JS::Realm& realm, ParsedFontFace&& font_face) : CSSRule(realm) , m_font_face(move(font_face)) { @@ -35,7 +35,7 @@ void CSSFontFaceRule::initialize(JS::Realm& realm) CSSStyleDeclaration* CSSFontFaceRule::style() { - // FIXME: Return a CSSStyleDeclaration subclass that directs changes to the FontFace. + // FIXME: Return a CSSStyleDeclaration subclass that directs changes to the ParsedFontFace. return nullptr; } @@ -63,7 +63,7 @@ String CSSFontFaceRule::serialized() const builder.append(" src: "sv); // 2. The result of invoking serialize a comma-separated list on performing serialize a URL or serialize a LOCAL for each source on the source list. - serialize_a_comma_separated_list(builder, m_font_face.sources(), [&](StringBuilder& builder, FontFace::Source source) -> void { + serialize_a_comma_separated_list(builder, m_font_face.sources(), [&](StringBuilder& builder, ParsedFontFace::Source source) -> void { if (source.local_or_url.has()) { serialize_a_url(builder, MUST(source.local_or_url.get().to_string())); } else { diff --git a/Userland/Libraries/LibWeb/CSS/CSSFontFaceRule.h b/Userland/Libraries/LibWeb/CSS/CSSFontFaceRule.h index 1468a8ea1c3b5e..92ff77dc9b2cc6 100644 --- a/Userland/Libraries/LibWeb/CSS/CSSFontFaceRule.h +++ b/Userland/Libraries/LibWeb/CSS/CSSFontFaceRule.h @@ -8,7 +8,7 @@ #pragma once #include -#include +#include namespace Web::CSS { @@ -17,22 +17,22 @@ class CSSFontFaceRule final : public CSSRule { JS_DECLARE_ALLOCATOR(CSSFontFaceRule); public: - [[nodiscard]] static JS::NonnullGCPtr create(JS::Realm&, FontFace&&); + [[nodiscard]] static JS::NonnullGCPtr create(JS::Realm&, ParsedFontFace&&); virtual ~CSSFontFaceRule() override = default; virtual Type type() const override { return Type::FontFace; } - FontFace const& font_face() const { return m_font_face; } + ParsedFontFace const& font_face() const { return m_font_face; } CSSStyleDeclaration* style(); private: - CSSFontFaceRule(JS::Realm&, FontFace&&); + CSSFontFaceRule(JS::Realm&, ParsedFontFace&&); virtual void initialize(JS::Realm&) override; virtual String serialized() const override; - FontFace m_font_face; + ParsedFontFace m_font_face; }; template<> diff --git a/Userland/Libraries/LibWeb/CSS/FontFace.cpp b/Userland/Libraries/LibWeb/CSS/ParsedFontFace.cpp similarity index 64% rename from Userland/Libraries/LibWeb/CSS/FontFace.cpp rename to Userland/Libraries/LibWeb/CSS/ParsedFontFace.cpp index 1552fc8a639842..1a6f42bd1a3087 100644 --- a/Userland/Libraries/LibWeb/CSS/FontFace.cpp +++ b/Userland/Libraries/LibWeb/CSS/ParsedFontFace.cpp @@ -5,11 +5,11 @@ * SPDX-License-Identifier: BSD-2-Clause */ -#include +#include namespace Web::CSS { -FontFace::FontFace(FlyString font_family, Optional weight, Optional slope, Vector sources, Vector unicode_ranges) +ParsedFontFace::ParsedFontFace(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/ParsedFontFace.h similarity index 84% rename from Userland/Libraries/LibWeb/CSS/FontFace.h rename to Userland/Libraries/LibWeb/CSS/ParsedFontFace.h index c415b40ab9de5c..f2321ee087687f 100644 --- a/Userland/Libraries/LibWeb/CSS/FontFace.h +++ b/Userland/Libraries/LibWeb/CSS/ParsedFontFace.h @@ -13,7 +13,7 @@ namespace Web::CSS { -class FontFace { +class ParsedFontFace { public: struct Source { Variant local_or_url; @@ -21,8 +21,8 @@ class FontFace { Optional format; }; - FontFace(FlyString font_family, Optional weight, Optional slope, Vector sources, Vector unicode_ranges); - ~FontFace() = default; + ParsedFontFace(FlyString font_family, Optional weight, Optional slope, Vector sources, Vector unicode_ranges); + ~ParsedFontFace() = default; FlyString font_family() const { return m_font_family; } Optional weight() const { return m_weight; } diff --git a/Userland/Libraries/LibWeb/CSS/Parser/Parser.cpp b/Userland/Libraries/LibWeb/CSS/Parser/Parser.cpp index 21efde0cefb36b..e06f3e1dcec2a9 100644 --- a/Userland/Libraries/LibWeb/CSS/Parser/Parser.cpp +++ b/Userland/Libraries/LibWeb/CSS/Parser/Parser.cpp @@ -4448,7 +4448,7 @@ CSSRule* Parser::parse_font_face_rule(TokenStream& tokens) auto declarations_and_at_rules = parse_a_list_of_declarations(tokens); Optional font_family; - Vector src; + Vector src; Vector unicode_range; Optional weight; Optional slope; @@ -4520,7 +4520,7 @@ CSSRule* Parser::parse_font_face_rule(TokenStream& tokens) } if (declaration.name().equals_ignoring_ascii_case("src"sv)) { TokenStream token_stream { declaration.values() }; - Vector supported_sources = parse_font_face_src(token_stream); + Vector supported_sources = parse_font_face_src(token_stream); if (!supported_sources.is_empty()) src = move(supported_sources); continue; @@ -4560,10 +4560,10 @@ CSSRule* Parser::parse_font_face_rule(TokenStream& tokens) unicode_range.empend(0x0u, 0x10FFFFu); } - return CSSFontFaceRule::create(m_context.realm(), FontFace { font_family.release_value(), weight, slope, move(src), move(unicode_range) }); + return CSSFontFaceRule::create(m_context.realm(), ParsedFontFace { font_family.release_value(), weight, slope, move(src), move(unicode_range) }); } -Vector Parser::parse_font_face_src(TokenStream& component_values) +Vector Parser::parse_font_face_src(TokenStream& component_values) { // FIXME: Get this information from the system somehow? // Format-name table: https://www.w3.org/TR/css-fonts-4/#font-format-definitions @@ -4574,7 +4574,7 @@ Vector Parser::parse_font_face_src(TokenStream return false; }; - Vector supported_sources; + Vector supported_sources; auto list_of_source_token_lists = parse_a_comma_separated_list_of_component_values(component_values); for (auto const& source_token_list : list_of_source_token_lists) { diff --git a/Userland/Libraries/LibWeb/CSS/Parser/Parser.h b/Userland/Libraries/LibWeb/CSS/Parser/Parser.h index 7e8617d132a28f..be9980aac68369 100644 --- a/Userland/Libraries/LibWeb/CSS/Parser/Parser.h +++ b/Userland/Libraries/LibWeb/CSS/Parser/Parser.h @@ -12,9 +12,9 @@ #include #include #include -#include #include #include +#include #include #include #include @@ -162,7 +162,7 @@ class Parser { Optional parse_general_enclosed(TokenStream&); CSSRule* parse_font_face_rule(TokenStream&); - Vector parse_font_face_src(TokenStream&); + Vector parse_font_face_src(TokenStream&); CSSRule* convert_to_rule(NonnullRefPtr); CSSMediaRule* convert_to_media_rule(NonnullRefPtr); diff --git a/Userland/Libraries/LibWeb/Forward.h b/Userland/Libraries/LibWeb/Forward.h index 8daa2e66cf0143..ecf0ce8067a048 100644 --- a/Userland/Libraries/LibWeb/Forward.h +++ b/Userland/Libraries/LibWeb/Forward.h @@ -124,7 +124,6 @@ class FilterValueListStyleValue; class Flex; class FlexOrCalculated; class FlexStyleValue; -class FontFace; class Frequency; class FrequencyOrCalculated; class FrequencyPercentage; @@ -159,6 +158,7 @@ class MediaQueryListEvent; class Number; class NumberOrCalculated; class NumberStyleValue; +class ParsedFontFace; class Percentage; class PercentageOrCalculated; class PercentageStyleValue;