LibGC+Everywhere: Factor out a LibGC from LibJS

Resulting in a massive rename across almost everywhere! Alongside the
namespace change, we now have the following names:

 * JS::NonnullGCPtr -> GC::Ref
 * JS::GCPtr -> GC::Ptr
 * JS::HeapFunction -> GC::Function
 * JS::CellImpl -> GC::Cell
 * JS::Handle -> GC::Root
This commit is contained in:
Shannon Booth 2024-11-15 04:01:23 +13:00 committed by Andreas Kling
commit f87041bf3a
Notes: github-actions[bot] 2024-11-15 13:50:17 +00:00
1722 changed files with 9939 additions and 9906 deletions

View file

@ -621,13 +621,13 @@ Optional<MediaFeatureValue> Parser::parse_media_feature_value(MediaFeatureID med
return {};
}
JS::GCPtr<CSSMediaRule> Parser::convert_to_media_rule(AtRule const& rule, Nested nested)
GC::Ptr<CSSMediaRule> Parser::convert_to_media_rule(AtRule const& rule, Nested nested)
{
auto media_query_tokens = TokenStream { rule.prelude };
auto media_query_list = parse_a_media_query_list(media_query_tokens);
auto media_list = MediaList::create(m_context.realm(), move(media_query_list));
JS::MarkedVector<CSSRule*> child_rules { m_context.realm().heap() };
GC::MarkedVector<CSSRule*> child_rules { m_context.realm().heap() };
for (auto const& child : rule.child_rules_and_lists_of_declarations) {
child.visit(
[&](Rule const& rule) {

View file

@ -156,7 +156,7 @@ CSSStyleSheet* Parser::parse_as_css_stylesheet(Optional<URL::URL> location)
auto const& style_sheet = parse_a_stylesheet(m_token_stream, {});
// Interpret all of the resulting top-level qualified rules as style rules, defined below.
JS::MarkedVector<CSSRule*> rules(m_context.realm().heap());
GC::MarkedVector<CSSRule*> rules(m_context.realm().heap());
for (auto const& raw_rule : style_sheet.rules) {
auto rule = convert_to_rule(raw_rule, Nested::No);
// If any style rule is invalid, or any at-rule is not recognized or is invalid according to its grammar or context, its a parse error.

View file

@ -178,16 +178,16 @@ private:
bool is_valid_in_the_current_context(Declaration const&) const;
bool is_valid_in_the_current_context(AtRule const&) const;
bool is_valid_in_the_current_context(QualifiedRule const&) const;
JS::GCPtr<CSSRule> convert_to_rule(Rule const&, Nested);
JS::GCPtr<CSSStyleRule> convert_to_style_rule(QualifiedRule const&, Nested);
JS::GCPtr<CSSFontFaceRule> convert_to_font_face_rule(AtRule const&);
JS::GCPtr<CSSKeyframesRule> convert_to_keyframes_rule(AtRule const&);
JS::GCPtr<CSSImportRule> convert_to_import_rule(AtRule const&);
JS::GCPtr<CSSRule> convert_to_layer_rule(AtRule const&, Nested);
JS::GCPtr<CSSMediaRule> convert_to_media_rule(AtRule const&, Nested);
JS::GCPtr<CSSNamespaceRule> convert_to_namespace_rule(AtRule const&);
JS::GCPtr<CSSSupportsRule> convert_to_supports_rule(AtRule const&, Nested);
JS::GCPtr<CSSPropertyRule> convert_to_property_rule(AtRule const& rule);
GC::Ptr<CSSRule> convert_to_rule(Rule const&, Nested);
GC::Ptr<CSSStyleRule> convert_to_style_rule(QualifiedRule const&, Nested);
GC::Ptr<CSSFontFaceRule> convert_to_font_face_rule(AtRule const&);
GC::Ptr<CSSKeyframesRule> convert_to_keyframes_rule(AtRule const&);
GC::Ptr<CSSImportRule> convert_to_import_rule(AtRule const&);
GC::Ptr<CSSRule> convert_to_layer_rule(AtRule const&, Nested);
GC::Ptr<CSSMediaRule> convert_to_media_rule(AtRule const&, Nested);
GC::Ptr<CSSNamespaceRule> convert_to_namespace_rule(AtRule const&);
GC::Ptr<CSSSupportsRule> convert_to_supports_rule(AtRule const&, Nested);
GC::Ptr<CSSPropertyRule> convert_to_property_rule(AtRule const& rule);
PropertyOwningCSSStyleDeclaration* convert_to_style_declaration(Vector<Declaration> const&);
Optional<StyleProperty> convert_to_style_property(Declaration const&);

View file

@ -39,8 +39,8 @@ public:
JS::Realm& realm() const { return m_realm; }
private:
JS::NonnullGCPtr<JS::Realm> m_realm;
JS::GCPtr<DOM::Document const> m_document;
GC::Ref<JS::Realm> m_realm;
GC::Ptr<DOM::Document const> m_document;
PropertyID m_current_property_id { PropertyID::Invalid };
URL::URL m_url;
Mode m_mode { Mode::Normal };

View file

@ -35,10 +35,10 @@
namespace Web::CSS::Parser {
JS::GCPtr<CSSRule> Parser::convert_to_rule(Rule const& rule, Nested nested)
GC::Ptr<CSSRule> Parser::convert_to_rule(Rule const& rule, Nested nested)
{
return rule.visit(
[this, nested](AtRule const& at_rule) -> JS::GCPtr<CSSRule> {
[this, nested](AtRule const& at_rule) -> GC::Ptr<CSSRule> {
if (has_ignored_vendor_prefix(at_rule.name))
return {};
@ -70,12 +70,12 @@ JS::GCPtr<CSSRule> Parser::convert_to_rule(Rule const& rule, Nested nested)
dbgln_if(CSS_PARSER_DEBUG, "Unrecognized CSS at-rule: @{}", at_rule.name);
return {};
},
[this, nested](QualifiedRule const& qualified_rule) -> JS::GCPtr<CSSRule> {
[this, nested](QualifiedRule const& qualified_rule) -> GC::Ptr<CSSRule> {
return convert_to_style_rule(qualified_rule, nested);
});
}
JS::GCPtr<CSSStyleRule> Parser::convert_to_style_rule(QualifiedRule const& qualified_rule, Nested nested)
GC::Ptr<CSSStyleRule> Parser::convert_to_style_rule(QualifiedRule const& qualified_rule, Nested nested)
{
TokenStream prelude_stream { qualified_rule.prelude };
@ -107,7 +107,7 @@ JS::GCPtr<CSSStyleRule> Parser::convert_to_style_rule(QualifiedRule const& quali
return {};
}
JS::MarkedVector<CSSRule*> child_rules { m_context.realm().heap() };
GC::MarkedVector<CSSRule*> child_rules { m_context.realm().heap() };
for (auto& child : qualified_rule.child_rules) {
child.visit(
[&](Rule const& rule) {
@ -135,7 +135,7 @@ JS::GCPtr<CSSStyleRule> Parser::convert_to_style_rule(QualifiedRule const& quali
return CSSStyleRule::create(m_context.realm(), move(selectors), *declaration, *nested_rules);
}
JS::GCPtr<CSSImportRule> Parser::convert_to_import_rule(AtRule const& rule)
GC::Ptr<CSSImportRule> Parser::convert_to_import_rule(AtRule const& rule)
{
// https://drafts.csswg.org/css-cascade-5/#at-import
// @import [ <url> | <string> ]
@ -220,7 +220,7 @@ Optional<FlyString> Parser::parse_layer_name(TokenStream<ComponentValue>& tokens
return builder.to_fly_string_without_validation();
}
JS::GCPtr<CSSRule> Parser::convert_to_layer_rule(AtRule const& rule, Nested nested)
GC::Ptr<CSSRule> Parser::convert_to_layer_rule(AtRule const& rule, Nested nested)
{
// https://drafts.csswg.org/css-cascade-5/#at-layer
if (!rule.child_rules_and_lists_of_declarations.is_empty()) {
@ -246,7 +246,7 @@ JS::GCPtr<CSSRule> Parser::convert_to_layer_rule(AtRule const& rule, Nested nest
}
// Then the rules
JS::MarkedVector<CSSRule*> child_rules { m_context.realm().heap() };
GC::MarkedVector<CSSRule*> child_rules { m_context.realm().heap() };
for (auto const& child : rule.child_rules_and_lists_of_declarations) {
child.visit(
[&](Rule const& rule) {
@ -298,7 +298,7 @@ JS::GCPtr<CSSRule> Parser::convert_to_layer_rule(AtRule const& rule, Nested nest
return CSSLayerStatementRule::create(m_context.realm(), move(layer_names));
}
JS::GCPtr<CSSKeyframesRule> Parser::convert_to_keyframes_rule(AtRule const& rule)
GC::Ptr<CSSKeyframesRule> Parser::convert_to_keyframes_rule(AtRule const& rule)
{
// https://drafts.csswg.org/css-animations/#keyframes
// @keyframes = @keyframes <keyframes-name> { <qualified-rule-list> }
@ -341,7 +341,7 @@ JS::GCPtr<CSSKeyframesRule> Parser::convert_to_keyframes_rule(AtRule const& rule
auto name = name_token.to_string();
JS::MarkedVector<CSSRule*> keyframes(m_context.realm().heap());
GC::MarkedVector<CSSRule*> keyframes(m_context.realm().heap());
rule.for_each_as_qualified_rule_list([&](auto& qualified_rule) {
if (!qualified_rule.child_rules.is_empty()) {
dbgln_if(CSS_PARSER_DEBUG, "CSSParser: @keyframes keyframe rule contains at-rules; discarding them.");
@ -399,7 +399,7 @@ JS::GCPtr<CSSKeyframesRule> Parser::convert_to_keyframes_rule(AtRule const& rule
return CSSKeyframesRule::create(m_context.realm(), name, CSSRuleList::create(m_context.realm(), move(keyframes)));
}
JS::GCPtr<CSSNamespaceRule> Parser::convert_to_namespace_rule(AtRule const& rule)
GC::Ptr<CSSNamespaceRule> Parser::convert_to_namespace_rule(AtRule const& rule)
{
// https://drafts.csswg.org/css-namespaces/#syntax
// @namespace <namespace-prefix>? [ <string> | <url> ] ;
@ -446,7 +446,7 @@ JS::GCPtr<CSSNamespaceRule> Parser::convert_to_namespace_rule(AtRule const& rule
return CSSNamespaceRule::create(m_context.realm(), prefix, namespace_uri);
}
JS::GCPtr<CSSSupportsRule> Parser::convert_to_supports_rule(AtRule const& rule, Nested nested)
GC::Ptr<CSSSupportsRule> Parser::convert_to_supports_rule(AtRule const& rule, Nested nested)
{
// https://drafts.csswg.org/css-conditional-3/#at-supports
// @supports <supports-condition> {
@ -468,7 +468,7 @@ JS::GCPtr<CSSSupportsRule> Parser::convert_to_supports_rule(AtRule const& rule,
return {};
}
JS::MarkedVector<CSSRule*> child_rules { m_context.realm().heap() };
GC::MarkedVector<CSSRule*> child_rules { m_context.realm().heap() };
for (auto const& child : rule.child_rules_and_lists_of_declarations) {
child.visit(
[&](Rule const& rule) {
@ -489,7 +489,7 @@ JS::GCPtr<CSSSupportsRule> Parser::convert_to_supports_rule(AtRule const& rule,
return CSSSupportsRule::create(m_context.realm(), supports.release_nonnull(), rule_list);
}
JS::GCPtr<CSSPropertyRule> Parser::convert_to_property_rule(AtRule const& rule)
GC::Ptr<CSSPropertyRule> Parser::convert_to_property_rule(AtRule const& rule)
{
// https://drafts.css-houdini.org/css-properties-values-api-1/#at-ruledef-property
// @property <custom-property-name> {
@ -586,7 +586,7 @@ JS::GCPtr<CSSPropertyRule> Parser::convert_to_property_rule(AtRule const& rule)
return {};
}
JS::GCPtr<CSSFontFaceRule> Parser::convert_to_font_face_rule(AtRule const& rule)
GC::Ptr<CSSFontFaceRule> Parser::convert_to_font_face_rule(AtRule const& rule)
{
// https://drafts.csswg.org/css-fonts/#font-face-rule