1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 16:07:46 +00:00

AK+Everywhere: Rename FlyString to DeprecatedFlyString

DeprecatedFlyString relies heavily on DeprecatedString's StringImpl, so
let's rename it to A) match the name of DeprecatedString, B) write a new
FlyString class that is tied to String.
This commit is contained in:
Timothy Flynn 2023-01-08 19:23:00 -05:00 committed by Linus Groh
parent 2eacc7aec1
commit f3db548a3d
316 changed files with 1177 additions and 1177 deletions

View file

@ -8,7 +8,7 @@
namespace Web::CSS {
FontFace::FontFace(FlyString font_family, Vector<Source> sources, Vector<UnicodeRange> unicode_ranges)
FontFace::FontFace(DeprecatedFlyString font_family, Vector<Source> sources, Vector<UnicodeRange> unicode_ranges)
: m_font_family(move(font_family))
, m_sources(move(sources))
, m_unicode_ranges(move(unicode_ranges))

View file

@ -6,7 +6,7 @@
#pragma once
#include <AK/FlyString.h>
#include <AK/DeprecatedFlyString.h>
#include <AK/URL.h>
#include <LibWeb/CSS/UnicodeRange.h>
@ -17,19 +17,19 @@ public:
struct Source {
AK::URL url;
// FIXME: Do we need to keep this around, or is it only needed to discard unwanted formats during parsing?
Optional<FlyString> format;
Optional<DeprecatedFlyString> format;
};
FontFace(FlyString font_family, Vector<Source> sources, Vector<UnicodeRange> unicode_ranges);
FontFace(DeprecatedFlyString font_family, Vector<Source> sources, Vector<UnicodeRange> unicode_ranges);
~FontFace() = default;
FlyString font_family() const { return m_font_family; }
DeprecatedFlyString font_family() const { return m_font_family; }
Vector<Source> const& sources() const { return m_sources; }
Vector<UnicodeRange> const& unicode_ranges() const { return m_unicode_ranges; }
// FIXME: font-style, font-weight, font-stretch, font-feature-settings
private:
FlyString m_font_family;
DeprecatedFlyString m_font_family;
Vector<Source> m_sources;
Vector<UnicodeRange> m_unicode_ranges;
};

View file

@ -6,7 +6,7 @@
#pragma once
#include <AK/FlyString.h>
#include <AK/DeprecatedFlyString.h>
#include <AK/NonnullOwnPtrVector.h>
#include <AK/NonnullRefPtr.h>
#include <AK/Optional.h>

View file

@ -10,12 +10,12 @@
namespace Web::CSS {
MediaQueryListEvent* MediaQueryListEvent::construct_impl(JS::Realm& realm, FlyString const& event_name, MediaQueryListEventInit const& event_init)
MediaQueryListEvent* MediaQueryListEvent::construct_impl(JS::Realm& realm, DeprecatedFlyString const& event_name, MediaQueryListEventInit const& event_init)
{
return realm.heap().allocate<MediaQueryListEvent>(realm, realm, event_name, event_init);
}
MediaQueryListEvent::MediaQueryListEvent(JS::Realm& realm, FlyString const& event_name, MediaQueryListEventInit const& event_init)
MediaQueryListEvent::MediaQueryListEvent(JS::Realm& realm, DeprecatedFlyString const& event_name, MediaQueryListEventInit const& event_init)
: DOM::Event(realm, event_name, event_init)
, m_media(event_init.media)
, m_matches(event_init.matches)

View file

@ -19,7 +19,7 @@ class MediaQueryListEvent final : public DOM::Event {
WEB_PLATFORM_OBJECT(MediaQueryListEvent, DOM::Event);
public:
static MediaQueryListEvent* construct_impl(JS::Realm&, FlyString const& event_name, MediaQueryListEventInit const& event_init = {});
static MediaQueryListEvent* construct_impl(JS::Realm&, DeprecatedFlyString const& event_name, MediaQueryListEventInit const& event_init = {});
virtual ~MediaQueryListEvent() override;
@ -27,7 +27,7 @@ public:
bool matches() const { return m_matches; }
private:
MediaQueryListEvent(JS::Realm&, FlyString const& event_name, MediaQueryListEventInit const& event_init);
MediaQueryListEvent(JS::Realm&, DeprecatedFlyString const& event_name, MediaQueryListEventInit const& event_init);
DeprecatedString m_media;
bool m_matches;

View file

@ -10,7 +10,7 @@
namespace Web::CSS::Parser {
Declaration::Declaration(FlyString name, Vector<ComponentValue> values, Important important)
Declaration::Declaration(DeprecatedFlyString name, Vector<ComponentValue> values, Important important)
: m_name(move(name))
, m_values(move(values))
, m_important(move(important))

View file

@ -15,7 +15,7 @@ namespace Web::CSS::Parser {
class Declaration {
public:
Declaration(FlyString name, Vector<ComponentValue> values, Important);
Declaration(DeprecatedFlyString name, Vector<ComponentValue> values, Important);
~Declaration();
StringView name() const { return m_name; }
@ -25,7 +25,7 @@ public:
DeprecatedString to_deprecated_string() const;
private:
FlyString m_name;
DeprecatedFlyString m_name;
Vector<ComponentValue> m_values;
Important m_important { Important::No };
};

View file

@ -10,7 +10,7 @@
namespace Web::CSS::Parser {
Function::Function(FlyString name, Vector<ComponentValue>&& values)
Function::Function(DeprecatedFlyString name, Vector<ComponentValue>&& values)
: m_name(move(name))
, m_values(move(values))
{

View file

@ -7,8 +7,8 @@
#pragma once
#include <AK/DeprecatedFlyString.h>
#include <AK/DeprecatedString.h>
#include <AK/FlyString.h>
#include <AK/RefCounted.h>
#include <AK/Vector.h>
#include <LibWeb/CSS/Parser/ComponentValue.h>
@ -18,7 +18,7 @@ namespace Web::CSS::Parser {
class Function : public RefCounted<Function> {
public:
static NonnullRefPtr<Function> create(FlyString name, Vector<ComponentValue>&& values)
static NonnullRefPtr<Function> create(DeprecatedFlyString name, Vector<ComponentValue>&& values)
{
return adopt_ref(*new Function(move(name), move(values)));
}
@ -31,9 +31,9 @@ public:
DeprecatedString to_deprecated_string() const;
private:
Function(FlyString name, Vector<ComponentValue>&& values);
Function(DeprecatedFlyString name, Vector<ComponentValue>&& values);
FlyString m_name;
DeprecatedFlyString m_name;
Vector<ComponentValue> m_values;
};
}

View file

@ -561,7 +561,7 @@ Parser::ParseErrorOr<Selector::SimpleSelector> Parser::parse_pseudo_simple_selec
return ParseError::SyntaxError;
}
// FIXME: Support multiple, comma-separated, language ranges.
Vector<FlyString> languages;
Vector<DeprecatedFlyString> languages;
languages.append(pseudo_function.values().first().token().to_deprecated_string());
return Selector::SimpleSelector {
.type = Selector::SimpleSelector::Type::PseudoClass,
@ -1518,7 +1518,7 @@ NonnullRefPtr<Rule> Parser::consume_an_at_rule(TokenStream<T>& tokens)
// Create a new at-rule with its name set to the value of the current input token, its prelude initially set to an empty list, and its value initially set to nothing.
// NOTE: We create the Rule fully initialized when we return it instead.
FlyString at_rule_name = ((Token)name_ident).at_keyword();
DeprecatedFlyString at_rule_name = ((Token)name_ident).at_keyword();
Vector<ComponentValue> prelude;
RefPtr<Block> block;
@ -1801,7 +1801,7 @@ NonnullRefPtr<Function> Parser::consume_a_function(TokenStream<T>& tokens)
// Create a function with its name equal to the value of the current input token
// and with its value initially set to an empty list.
// NOTE: We create the Function fully initialized when we return it instead.
FlyString function_name = ((Token)name_ident).function();
DeprecatedFlyString function_name = ((Token)name_ident).function();
Vector<ComponentValue> function_values;
// Repeatedly consume the next input token and process it as follows:
@ -1856,7 +1856,7 @@ Optional<Declaration> Parser::consume_a_declaration(TokenStream<T>& tokens)
// Create a new declaration with its name set to the value of the current input token
// and its value initially set to the empty list.
// NOTE: We create a fully-initialized Declaration just before returning it instead.
FlyString declaration_name = ((Token)token).ident();
DeprecatedFlyString declaration_name = ((Token)token).ident();
Vector<ComponentValue> declaration_values;
Important declaration_important = Important::No;
@ -5289,7 +5289,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;
Optional<DeprecatedFlyString> font_family;
Vector<FontFace::Source> src;
Vector<UnicodeRange> unicode_range;
@ -5412,7 +5412,7 @@ Vector<FontFace::Source> Parser::parse_font_face_src(TokenStream<ComponentValue>
// FIXME: Implement optional tech() function from CSS-Fonts-4.
if (auto maybe_url = parse_url_function(first, AllowedDataUrlType::Font); maybe_url.has_value()) {
auto url = maybe_url.release_value();
Optional<FlyString> format;
Optional<DeprecatedFlyString> format;
source_tokens.skip_whitespace();
if (!source_tokens.has_next_token()) {

View file

@ -10,7 +10,7 @@
namespace Web::CSS::Parser {
Rule::Rule(Rule::Type type, FlyString name, Vector<ComponentValue> prelude, RefPtr<Block> block)
Rule::Rule(Rule::Type type, DeprecatedFlyString name, Vector<ComponentValue> prelude, RefPtr<Block> block)
: m_type(type)
, m_at_rule_name(move(name))
, m_prelude(move(prelude))

View file

@ -7,7 +7,7 @@
#pragma once
#include <AK/FlyString.h>
#include <AK/DeprecatedFlyString.h>
#include <AK/RefCounted.h>
#include <AK/Vector.h>
#include <LibWeb/CSS/Parser/Block.h>
@ -22,7 +22,7 @@ public:
Qualified,
};
static NonnullRefPtr<Rule> make_at_rule(FlyString name, Vector<ComponentValue> prelude, RefPtr<Block> block)
static NonnullRefPtr<Rule> make_at_rule(DeprecatedFlyString name, Vector<ComponentValue> prelude, RefPtr<Block> block)
{
return adopt_ref(*new Rule(Type::At, move(name), move(prelude), move(block)));
}
@ -44,10 +44,10 @@ public:
DeprecatedString to_deprecated_string() const;
private:
Rule(Type, FlyString name, Vector<ComponentValue> prelude, RefPtr<Block>);
Rule(Type, DeprecatedFlyString name, Vector<ComponentValue> prelude, RefPtr<Block>);
Type const m_type;
FlyString m_at_rule_name;
DeprecatedFlyString m_at_rule_name;
Vector<ComponentValue> m_prelude;
RefPtr<Block> m_block;
};

View file

@ -7,8 +7,8 @@
#pragma once
#include <AK/DeprecatedFlyString.h>
#include <AK/DeprecatedString.h>
#include <AK/FlyString.h>
#include <AK/Utf8View.h>
#include <LibWeb/CSS/Number.h>
@ -151,7 +151,7 @@ public:
Position const& start_position() const { return m_start_position; }
Position const& end_position() const { return m_end_position; }
static Token of_string(FlyString str)
static Token of_string(DeprecatedFlyString str)
{
Token token;
token.m_type = Type::String;
@ -178,7 +178,7 @@ public:
private:
Type m_type { Type::Invalid };
FlyString m_value;
DeprecatedFlyString m_value;
Number m_number_value;
HashType m_hash_type { HashType::Unrestricted };

View file

@ -7,8 +7,8 @@
#pragma once
#include <AK/DeprecatedFlyString.h>
#include <AK/DeprecatedString.h>
#include <AK/FlyString.h>
#include <AK/NonnullRefPtrVector.h>
#include <AK/RefCounted.h>
#include <AK/Vector.h>
@ -121,7 +121,7 @@ public:
SelectorList argument_selector_list {};
// Used for :lang(en-gb,dk)
Vector<FlyString> languages {};
Vector<DeprecatedFlyString> languages {};
};
struct Attribute {
@ -140,20 +140,20 @@ public:
CaseInsensitiveMatch,
};
MatchType match_type;
FlyString name {};
DeprecatedFlyString name {};
DeprecatedString value {};
CaseType case_type;
};
struct Name {
Name(FlyString n)
Name(DeprecatedFlyString n)
: name(move(n))
, lowercase_name(name.to_lowercase())
{
}
FlyString name;
FlyString lowercase_name;
DeprecatedFlyString name;
DeprecatedFlyString lowercase_name;
};
Type type;
@ -166,10 +166,10 @@ public:
PseudoElement const& pseudo_element() const { return value.get<PseudoElement>(); }
PseudoElement& pseudo_element() { return value.get<PseudoElement>(); }
FlyString const& name() const { return value.get<Name>().name; }
FlyString& name() { return value.get<Name>().name; }
FlyString const& lowercase_name() const { return value.get<Name>().lowercase_name; }
FlyString& lowercase_name() { return value.get<Name>().lowercase_name; }
DeprecatedFlyString const& name() const { return value.get<Name>().name; }
DeprecatedFlyString& name() { return value.get<Name>().name; }
DeprecatedFlyString const& lowercase_name() const { return value.get<Name>().lowercase_name; }
DeprecatedFlyString& lowercase_name() { return value.get<Name>().lowercase_name; }
DeprecatedString serialize() const;
};

View file

@ -25,9 +25,9 @@
namespace Web::SelectorEngine {
// https://drafts.csswg.org/selectors-4/#the-lang-pseudo
static inline bool matches_lang_pseudo_class(DOM::Element const& element, Vector<FlyString> const& languages)
static inline bool matches_lang_pseudo_class(DOM::Element const& element, Vector<DeprecatedFlyString> const& languages)
{
FlyString element_language;
DeprecatedFlyString element_language;
for (auto const* e = &element; e; e = e->parent_element()) {
auto lang = e->attribute(HTML::AttributeNames::lang);
if (!lang.is_null()) {

View file

@ -43,7 +43,7 @@ StyleComputer::~StyleComputer() = default;
class StyleComputer::FontLoader : public ResourceClient {
public:
explicit FontLoader(StyleComputer& style_computer, FlyString family_name, AK::URL url)
explicit FontLoader(StyleComputer& style_computer, DeprecatedFlyString family_name, AK::URL url)
: m_style_computer(style_computer)
, m_family_name(move(family_name))
{
@ -105,7 +105,7 @@ private:
}
StyleComputer& m_style_computer;
FlyString m_family_name;
DeprecatedFlyString m_family_name;
RefPtr<Gfx::VectorFont> m_vector_font;
HashMap<float, NonnullRefPtr<Gfx::ScaledFont>> mutable m_cached_fonts;
@ -571,7 +571,7 @@ static void set_property_expanding_shorthands(StyleProperties& style, CSS::Prope
style.set_property(property_id, value);
}
static RefPtr<StyleValue> get_custom_property(DOM::Element const& element, FlyString const& custom_property_name)
static RefPtr<StyleValue> get_custom_property(DOM::Element const& element, DeprecatedFlyString const& custom_property_name)
{
for (auto const* current_element = &element; current_element; current_element = current_element->parent_element()) {
if (auto it = current_element->custom_properties().find(custom_property_name); it != current_element->custom_properties().end())
@ -580,7 +580,7 @@ static RefPtr<StyleValue> get_custom_property(DOM::Element const& element, FlySt
return nullptr;
}
bool StyleComputer::expand_variables(DOM::Element& element, StringView property_name, HashMap<FlyString, NonnullRefPtr<PropertyDependencyNode>>& dependencies, Parser::TokenStream<Parser::ComponentValue>& source, Vector<Parser::ComponentValue>& dest) const
bool StyleComputer::expand_variables(DOM::Element& element, StringView property_name, HashMap<DeprecatedFlyString, NonnullRefPtr<PropertyDependencyNode>>& dependencies, Parser::TokenStream<Parser::ComponentValue>& source, Vector<Parser::ComponentValue>& dest) const
{
// Arbitrary large value chosen to avoid the billion-laughs attack.
// https://www.w3.org/TR/css-variables-1/#long-variables
@ -761,7 +761,7 @@ RefPtr<StyleValue> StyleComputer::resolve_unresolved_style_value(DOM::Element& e
Parser::TokenStream unresolved_values_without_variables_expanded { unresolved.values() };
Vector<Parser::ComponentValue> values_with_variables_expanded;
HashMap<FlyString, NonnullRefPtr<PropertyDependencyNode>> dependencies;
HashMap<DeprecatedFlyString, NonnullRefPtr<PropertyDependencyNode>> dependencies;
if (!expand_variables(element, string_from_property_id(property_id), dependencies, unresolved_values_without_variables_expanded, values_with_variables_expanded))
return {};
@ -817,7 +817,7 @@ static ErrorOr<void> cascade_custom_properties(DOM::Element& element, Vector<Mat
if (auto const* inline_style = verify_cast<PropertyOwningCSSStyleDeclaration>(element.inline_style()))
needed_capacity += inline_style->custom_properties().size();
HashMap<FlyString, StyleProperty> custom_properties;
HashMap<DeprecatedFlyString, StyleProperty> custom_properties;
TRY(custom_properties.try_ensure_capacity(needed_capacity));
for (auto const& matching_rule : matching_rules) {
@ -1444,7 +1444,7 @@ CSSPixelRect StyleComputer::viewport_rect() const
return {};
}
void StyleComputer::did_load_font([[maybe_unused]] FlyString const& family_name)
void StyleComputer::did_load_font([[maybe_unused]] DeprecatedFlyString const& family_name)
{
document().invalidate_layout();
}

View file

@ -73,7 +73,7 @@ public:
Gfx::Font const& initial_font() const;
void did_load_font(FlyString const& family_name);
void did_load_font(DeprecatedFlyString const& family_name);
void load_fonts_from_sheet(CSSStyleSheet const&);
@ -87,7 +87,7 @@ private:
void compute_defaulted_property_value(StyleProperties&, DOM::Element const*, CSS::PropertyID, Optional<CSS::Selector::PseudoElement>) const;
RefPtr<StyleValue> resolve_unresolved_style_value(DOM::Element&, PropertyID, UnresolvedStyleValue const&) const;
bool expand_variables(DOM::Element&, StringView property_name, HashMap<FlyString, NonnullRefPtr<PropertyDependencyNode>>& dependencies, Parser::TokenStream<Parser::ComponentValue>& source, Vector<Parser::ComponentValue>& dest) const;
bool expand_variables(DOM::Element&, StringView property_name, HashMap<DeprecatedFlyString, NonnullRefPtr<PropertyDependencyNode>>& dependencies, Parser::TokenStream<Parser::ComponentValue>& source, Vector<Parser::ComponentValue>& dest) const;
bool expand_unresolved_values(DOM::Element&, StringView property_name, Parser::TokenStream<Parser::ComponentValue>& source, Vector<Parser::ComponentValue>& dest) const;
template<typename Callback>
@ -109,9 +109,9 @@ private:
DOM::Document& m_document;
struct RuleCache {
HashMap<FlyString, Vector<MatchingRule>> rules_by_id;
HashMap<FlyString, Vector<MatchingRule>> rules_by_class;
HashMap<FlyString, Vector<MatchingRule>> rules_by_tag_name;
HashMap<DeprecatedFlyString, Vector<MatchingRule>> rules_by_id;
HashMap<DeprecatedFlyString, Vector<MatchingRule>> rules_by_class;
HashMap<DeprecatedFlyString, Vector<MatchingRule>> rules_by_tag_name;
HashMap<Selector::PseudoElement, Vector<MatchingRule>> rules_by_pseudo_element;
Vector<MatchingRule> other_rules;
};