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.
This commit is contained in:
Andrew Kaster 2024-05-07 09:18:37 -06:00 committed by Andreas Kling
parent 3f113e728f
commit 3a5eabc43b
Notes: sideshowbarker 2024-07-16 21:42:29 +09:00
8 changed files with 23 additions and 23 deletions

View file

@ -55,7 +55,6 @@ set(SOURCES
CSS/Display.cpp CSS/Display.cpp
CSS/EdgeRect.cpp CSS/EdgeRect.cpp
CSS/Flex.cpp CSS/Flex.cpp
CSS/FontFace.cpp
CSS/Frequency.cpp CSS/Frequency.cpp
CSS/GridTrackPlacement.cpp CSS/GridTrackPlacement.cpp
CSS/GridTrackSize.cpp CSS/GridTrackSize.cpp
@ -79,6 +78,7 @@ set(SOURCES
CSS/Parser/SelectorParsing.cpp CSS/Parser/SelectorParsing.cpp
CSS/Parser/Token.cpp CSS/Parser/Token.cpp
CSS/Parser/Tokenizer.cpp CSS/Parser/Tokenizer.cpp
CSS/ParsedFontFace.cpp
CSS/PercentageOr.cpp CSS/PercentageOr.cpp
CSS/PreferredColorScheme.cpp CSS/PreferredColorScheme.cpp
CSS/Ratio.cpp CSS/Ratio.cpp

View file

@ -16,12 +16,12 @@ namespace Web::CSS {
JS_DEFINE_ALLOCATOR(CSSFontFaceRule); JS_DEFINE_ALLOCATOR(CSSFontFaceRule);
JS::NonnullGCPtr<CSSFontFaceRule> CSSFontFaceRule::create(JS::Realm& realm, FontFace&& font_face) JS::NonnullGCPtr<CSSFontFaceRule> CSSFontFaceRule::create(JS::Realm& realm, ParsedFontFace&& font_face)
{ {
return realm.heap().allocate<CSSFontFaceRule>(realm, realm, move(font_face)); return realm.heap().allocate<CSSFontFaceRule>(realm, realm, move(font_face));
} }
CSSFontFaceRule::CSSFontFaceRule(JS::Realm& realm, FontFace&& font_face) CSSFontFaceRule::CSSFontFaceRule(JS::Realm& realm, ParsedFontFace&& font_face)
: CSSRule(realm) : CSSRule(realm)
, m_font_face(move(font_face)) , m_font_face(move(font_face))
{ {
@ -35,7 +35,7 @@ void CSSFontFaceRule::initialize(JS::Realm& realm)
CSSStyleDeclaration* CSSFontFaceRule::style() 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; return nullptr;
} }
@ -63,7 +63,7 @@ String CSSFontFaceRule::serialized() const
builder.append(" src: "sv); 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. // 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<URL::URL>()) { if (source.local_or_url.has<URL::URL>()) {
serialize_a_url(builder, MUST(source.local_or_url.get<URL::URL>().to_string())); serialize_a_url(builder, MUST(source.local_or_url.get<URL::URL>().to_string()));
} else { } else {

View file

@ -8,7 +8,7 @@
#pragma once #pragma once
#include <LibWeb/CSS/CSSRule.h> #include <LibWeb/CSS/CSSRule.h>
#include <LibWeb/CSS/FontFace.h> #include <LibWeb/CSS/ParsedFontFace.h>
namespace Web::CSS { namespace Web::CSS {
@ -17,22 +17,22 @@ class CSSFontFaceRule final : public CSSRule {
JS_DECLARE_ALLOCATOR(CSSFontFaceRule); JS_DECLARE_ALLOCATOR(CSSFontFaceRule);
public: public:
[[nodiscard]] static JS::NonnullGCPtr<CSSFontFaceRule> create(JS::Realm&, FontFace&&); [[nodiscard]] static JS::NonnullGCPtr<CSSFontFaceRule> create(JS::Realm&, ParsedFontFace&&);
virtual ~CSSFontFaceRule() override = default; virtual ~CSSFontFaceRule() override = default;
virtual Type type() const override { return Type::FontFace; } 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(); CSSStyleDeclaration* style();
private: private:
CSSFontFaceRule(JS::Realm&, FontFace&&); CSSFontFaceRule(JS::Realm&, ParsedFontFace&&);
virtual void initialize(JS::Realm&) override; virtual void initialize(JS::Realm&) override;
virtual String serialized() const override; virtual String serialized() const override;
FontFace m_font_face; ParsedFontFace m_font_face;
}; };
template<> template<>

View file

@ -5,11 +5,11 @@
* SPDX-License-Identifier: BSD-2-Clause * SPDX-License-Identifier: BSD-2-Clause
*/ */
#include <LibWeb/CSS/FontFace.h> #include <LibWeb/CSS/ParsedFontFace.h>
namespace Web::CSS { namespace Web::CSS {
FontFace::FontFace(FlyString font_family, Optional<int> weight, Optional<int> slope, Vector<Source> sources, Vector<Gfx::UnicodeRange> unicode_ranges) ParsedFontFace::ParsedFontFace(FlyString font_family, Optional<int> weight, Optional<int> slope, Vector<Source> sources, Vector<Gfx::UnicodeRange> unicode_ranges)
: m_font_family(move(font_family)) : m_font_family(move(font_family))
, m_weight(weight) , m_weight(weight)
, m_slope(slope) , m_slope(slope)

View file

@ -13,7 +13,7 @@
namespace Web::CSS { namespace Web::CSS {
class FontFace { class ParsedFontFace {
public: public:
struct Source { struct Source {
Variant<String, URL::URL> local_or_url; Variant<String, URL::URL> local_or_url;
@ -21,8 +21,8 @@ public:
Optional<FlyString> format; Optional<FlyString> format;
}; };
FontFace(FlyString font_family, Optional<int> weight, Optional<int> slope, Vector<Source> sources, Vector<Gfx::UnicodeRange> unicode_ranges); ParsedFontFace(FlyString font_family, Optional<int> weight, Optional<int> slope, Vector<Source> sources, Vector<Gfx::UnicodeRange> unicode_ranges);
~FontFace() = default; ~ParsedFontFace() = default;
FlyString font_family() const { return m_font_family; } FlyString font_family() const { return m_font_family; }
Optional<int> weight() const { return m_weight; } Optional<int> weight() const { return m_weight; }

View file

@ -4448,7 +4448,7 @@ CSSRule* Parser::parse_font_face_rule(TokenStream<ComponentValue>& tokens)
auto declarations_and_at_rules = parse_a_list_of_declarations(tokens); auto declarations_and_at_rules = parse_a_list_of_declarations(tokens);
Optional<FlyString> font_family; Optional<FlyString> font_family;
Vector<FontFace::Source> src; Vector<ParsedFontFace::Source> src;
Vector<Gfx::UnicodeRange> unicode_range; Vector<Gfx::UnicodeRange> unicode_range;
Optional<int> weight; Optional<int> weight;
Optional<int> slope; Optional<int> slope;
@ -4520,7 +4520,7 @@ CSSRule* Parser::parse_font_face_rule(TokenStream<ComponentValue>& tokens)
} }
if (declaration.name().equals_ignoring_ascii_case("src"sv)) { if (declaration.name().equals_ignoring_ascii_case("src"sv)) {
TokenStream token_stream { declaration.values() }; TokenStream token_stream { declaration.values() };
Vector<FontFace::Source> supported_sources = parse_font_face_src(token_stream); Vector<ParsedFontFace::Source> supported_sources = parse_font_face_src(token_stream);
if (!supported_sources.is_empty()) if (!supported_sources.is_empty())
src = move(supported_sources); src = move(supported_sources);
continue; continue;
@ -4560,10 +4560,10 @@ CSSRule* Parser::parse_font_face_rule(TokenStream<ComponentValue>& tokens)
unicode_range.empend(0x0u, 0x10FFFFu); 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<FontFace::Source> Parser::parse_font_face_src(TokenStream<ComponentValue>& component_values) Vector<ParsedFontFace::Source> Parser::parse_font_face_src(TokenStream<ComponentValue>& component_values)
{ {
// FIXME: Get this information from the system somehow? // FIXME: Get this information from the system somehow?
// Format-name table: https://www.w3.org/TR/css-fonts-4/#font-format-definitions // Format-name table: https://www.w3.org/TR/css-fonts-4/#font-format-definitions
@ -4574,7 +4574,7 @@ Vector<FontFace::Source> Parser::parse_font_face_src(TokenStream<ComponentValue>
return false; return false;
}; };
Vector<FontFace::Source> supported_sources; Vector<ParsedFontFace::Source> supported_sources;
auto list_of_source_token_lists = parse_a_comma_separated_list_of_component_values(component_values); 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) { for (auto const& source_token_list : list_of_source_token_lists) {

View file

@ -12,9 +12,9 @@
#include <AK/Vector.h> #include <AK/Vector.h>
#include <LibGfx/Font/UnicodeRange.h> #include <LibGfx/Font/UnicodeRange.h>
#include <LibWeb/CSS/CSSStyleDeclaration.h> #include <LibWeb/CSS/CSSStyleDeclaration.h>
#include <LibWeb/CSS/FontFace.h>
#include <LibWeb/CSS/GeneralEnclosed.h> #include <LibWeb/CSS/GeneralEnclosed.h>
#include <LibWeb/CSS/MediaQuery.h> #include <LibWeb/CSS/MediaQuery.h>
#include <LibWeb/CSS/ParsedFontFace.h>
#include <LibWeb/CSS/Parser/Block.h> #include <LibWeb/CSS/Parser/Block.h>
#include <LibWeb/CSS/Parser/ComponentValue.h> #include <LibWeb/CSS/Parser/ComponentValue.h>
#include <LibWeb/CSS/Parser/Declaration.h> #include <LibWeb/CSS/Parser/Declaration.h>
@ -162,7 +162,7 @@ private:
Optional<GeneralEnclosed> parse_general_enclosed(TokenStream<ComponentValue>&); Optional<GeneralEnclosed> parse_general_enclosed(TokenStream<ComponentValue>&);
CSSRule* parse_font_face_rule(TokenStream<ComponentValue>&); CSSRule* parse_font_face_rule(TokenStream<ComponentValue>&);
Vector<FontFace::Source> parse_font_face_src(TokenStream<ComponentValue>&); Vector<ParsedFontFace::Source> parse_font_face_src(TokenStream<ComponentValue>&);
CSSRule* convert_to_rule(NonnullRefPtr<Rule>); CSSRule* convert_to_rule(NonnullRefPtr<Rule>);
CSSMediaRule* convert_to_media_rule(NonnullRefPtr<Rule>); CSSMediaRule* convert_to_media_rule(NonnullRefPtr<Rule>);

View file

@ -124,7 +124,6 @@ class FilterValueListStyleValue;
class Flex; class Flex;
class FlexOrCalculated; class FlexOrCalculated;
class FlexStyleValue; class FlexStyleValue;
class FontFace;
class Frequency; class Frequency;
class FrequencyOrCalculated; class FrequencyOrCalculated;
class FrequencyPercentage; class FrequencyPercentage;
@ -159,6 +158,7 @@ class MediaQueryListEvent;
class Number; class Number;
class NumberOrCalculated; class NumberOrCalculated;
class NumberStyleValue; class NumberStyleValue;
class ParsedFontFace;
class Percentage; class Percentage;
class PercentageOrCalculated; class PercentageOrCalculated;
class PercentageStyleValue; class PercentageStyleValue;