mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-04-21 03:55:24 +00:00
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:
parent
3f113e728f
commit
3a5eabc43b
Notes:
sideshowbarker
2024-07-16 21:42:29 +09:00
Author: https://github.com/ADKaster Commit: https://github.com/SerenityOS/serenity/commit/3a5eabc43b Pull-request: https://github.com/SerenityOS/serenity/pull/24255 Issue: https://github.com/SerenityOS/serenity/issues/22014
8 changed files with 23 additions and 23 deletions
|
@ -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
|
||||
|
|
|
@ -16,12 +16,12 @@ namespace Web::CSS {
|
|||
|
||||
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));
|
||||
}
|
||||
|
||||
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<URL::URL>()) {
|
||||
serialize_a_url(builder, MUST(source.local_or_url.get<URL::URL>().to_string()));
|
||||
} else {
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
#pragma once
|
||||
|
||||
#include <LibWeb/CSS/CSSRule.h>
|
||||
#include <LibWeb/CSS/FontFace.h>
|
||||
#include <LibWeb/CSS/ParsedFontFace.h>
|
||||
|
||||
namespace Web::CSS {
|
||||
|
||||
|
@ -17,22 +17,22 @@ class CSSFontFaceRule final : public CSSRule {
|
|||
JS_DECLARE_ALLOCATOR(CSSFontFaceRule);
|
||||
|
||||
public:
|
||||
[[nodiscard]] static JS::NonnullGCPtr<CSSFontFaceRule> create(JS::Realm&, FontFace&&);
|
||||
[[nodiscard]] static JS::NonnullGCPtr<CSSFontFaceRule> 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<>
|
||||
|
|
|
@ -5,11 +5,11 @@
|
|||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#include <LibWeb/CSS/FontFace.h>
|
||||
#include <LibWeb/CSS/ParsedFontFace.h>
|
||||
|
||||
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_weight(weight)
|
||||
, m_slope(slope)
|
|
@ -13,7 +13,7 @@
|
|||
|
||||
namespace Web::CSS {
|
||||
|
||||
class FontFace {
|
||||
class ParsedFontFace {
|
||||
public:
|
||||
struct Source {
|
||||
Variant<String, URL::URL> local_or_url;
|
||||
|
@ -21,8 +21,8 @@ public:
|
|||
Optional<FlyString> format;
|
||||
};
|
||||
|
||||
FontFace(FlyString font_family, Optional<int> weight, Optional<int> slope, Vector<Source> sources, Vector<Gfx::UnicodeRange> unicode_ranges);
|
||||
~FontFace() = default;
|
||||
ParsedFontFace(FlyString font_family, Optional<int> weight, Optional<int> slope, Vector<Source> sources, Vector<Gfx::UnicodeRange> unicode_ranges);
|
||||
~ParsedFontFace() = default;
|
||||
|
||||
FlyString font_family() const { return m_font_family; }
|
||||
Optional<int> weight() const { return m_weight; }
|
|
@ -4448,7 +4448,7 @@ CSSRule* Parser::parse_font_face_rule(TokenStream<ComponentValue>& tokens)
|
|||
auto declarations_and_at_rules = parse_a_list_of_declarations(tokens);
|
||||
|
||||
Optional<FlyString> font_family;
|
||||
Vector<FontFace::Source> src;
|
||||
Vector<ParsedFontFace::Source> src;
|
||||
Vector<Gfx::UnicodeRange> unicode_range;
|
||||
Optional<int> weight;
|
||||
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)) {
|
||||
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())
|
||||
src = move(supported_sources);
|
||||
continue;
|
||||
|
@ -4560,10 +4560,10 @@ CSSRule* Parser::parse_font_face_rule(TokenStream<ComponentValue>& 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<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?
|
||||
// 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;
|
||||
};
|
||||
|
||||
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);
|
||||
for (auto const& source_token_list : list_of_source_token_lists) {
|
||||
|
|
|
@ -12,9 +12,9 @@
|
|||
#include <AK/Vector.h>
|
||||
#include <LibGfx/Font/UnicodeRange.h>
|
||||
#include <LibWeb/CSS/CSSStyleDeclaration.h>
|
||||
#include <LibWeb/CSS/FontFace.h>
|
||||
#include <LibWeb/CSS/GeneralEnclosed.h>
|
||||
#include <LibWeb/CSS/MediaQuery.h>
|
||||
#include <LibWeb/CSS/ParsedFontFace.h>
|
||||
#include <LibWeb/CSS/Parser/Block.h>
|
||||
#include <LibWeb/CSS/Parser/ComponentValue.h>
|
||||
#include <LibWeb/CSS/Parser/Declaration.h>
|
||||
|
@ -162,7 +162,7 @@ private:
|
|||
Optional<GeneralEnclosed> parse_general_enclosed(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>);
|
||||
CSSMediaRule* convert_to_media_rule(NonnullRefPtr<Rule>);
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Add table
Reference in a new issue