mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-08-01 05:39:11 +00:00
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:
parent
ce23efc5f6
commit
f87041bf3a
Notes:
github-actions[bot]
2024-11-15 13:50:17 +00:00
Author: https://github.com/shannonbooth
Commit: f87041bf3a
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/2345
1722 changed files with 9939 additions and 9906 deletions
|
@ -10,14 +10,14 @@
|
|||
|
||||
namespace Web::CSS {
|
||||
|
||||
JS_DEFINE_ALLOCATOR(AnimationEvent);
|
||||
GC_DEFINE_ALLOCATOR(AnimationEvent);
|
||||
|
||||
JS::NonnullGCPtr<AnimationEvent> AnimationEvent::create(JS::Realm& realm, FlyString const& type, AnimationEventInit const& event_init)
|
||||
GC::Ref<AnimationEvent> AnimationEvent::create(JS::Realm& realm, FlyString const& type, AnimationEventInit const& event_init)
|
||||
{
|
||||
return realm.create<AnimationEvent>(realm, type, event_init);
|
||||
}
|
||||
|
||||
WebIDL::ExceptionOr<JS::NonnullGCPtr<AnimationEvent>> AnimationEvent::construct_impl(JS::Realm& realm, FlyString const& type, AnimationEventInit const& event_init)
|
||||
WebIDL::ExceptionOr<GC::Ref<AnimationEvent>> AnimationEvent::construct_impl(JS::Realm& realm, FlyString const& type, AnimationEventInit const& event_init)
|
||||
{
|
||||
return create(realm, type, event_init);
|
||||
}
|
||||
|
|
|
@ -21,11 +21,11 @@ struct AnimationEventInit : public DOM::EventInit {
|
|||
// https://www.w3.org/TR/css-animations-1/#animationevent
|
||||
class AnimationEvent : public DOM::Event {
|
||||
WEB_PLATFORM_OBJECT(AnimationEvent, DOM::Event);
|
||||
JS_DECLARE_ALLOCATOR(AnimationEvent);
|
||||
GC_DECLARE_ALLOCATOR(AnimationEvent);
|
||||
|
||||
public:
|
||||
[[nodiscard]] static JS::NonnullGCPtr<AnimationEvent> create(JS::Realm&, FlyString const& type, AnimationEventInit const& event_init = {});
|
||||
static WebIDL::ExceptionOr<JS::NonnullGCPtr<AnimationEvent>> construct_impl(JS::Realm&, FlyString const& type, AnimationEventInit const& event_init);
|
||||
[[nodiscard]] static GC::Ref<AnimationEvent> create(JS::Realm&, FlyString const& type, AnimationEventInit const& event_init = {});
|
||||
static WebIDL::ExceptionOr<GC::Ref<AnimationEvent>> construct_impl(JS::Realm&, FlyString const& type, AnimationEventInit const& event_init);
|
||||
|
||||
virtual ~AnimationEvent() override = default;
|
||||
|
||||
|
|
|
@ -12,17 +12,17 @@
|
|||
|
||||
namespace Web::CSS {
|
||||
|
||||
JS_DEFINE_ALLOCATOR(CSSAnimation);
|
||||
GC_DEFINE_ALLOCATOR(CSSAnimation);
|
||||
|
||||
JS::NonnullGCPtr<CSSAnimation> CSSAnimation::create(JS::Realm& realm)
|
||||
GC::Ref<CSSAnimation> CSSAnimation::create(JS::Realm& realm)
|
||||
{
|
||||
return realm.create<CSSAnimation>(realm);
|
||||
}
|
||||
|
||||
// https://www.w3.org/TR/css-animations-2/#animation-composite-order
|
||||
Optional<int> CSSAnimation::class_specific_composite_order(JS::NonnullGCPtr<Animations::Animation> other_animation) const
|
||||
Optional<int> CSSAnimation::class_specific_composite_order(GC::Ref<Animations::Animation> other_animation) const
|
||||
{
|
||||
auto other = JS::NonnullGCPtr { verify_cast<CSSAnimation>(*other_animation) };
|
||||
auto other = GC::Ref { verify_cast<CSSAnimation>(*other_animation) };
|
||||
|
||||
// The existance of an owning element determines the animation class, so both animations should have their owning
|
||||
// element in the same state
|
||||
|
|
|
@ -15,15 +15,15 @@ namespace Web::CSS {
|
|||
// https://www.w3.org/TR/css-animations-2/#cssanimation
|
||||
class CSSAnimation : public Animations::Animation {
|
||||
WEB_PLATFORM_OBJECT(CSSAnimation, Animations::Animation);
|
||||
JS_DECLARE_ALLOCATOR(CSSAnimation);
|
||||
GC_DECLARE_ALLOCATOR(CSSAnimation);
|
||||
|
||||
public:
|
||||
static JS::NonnullGCPtr<CSSAnimation> create(JS::Realm&);
|
||||
static GC::Ref<CSSAnimation> create(JS::Realm&);
|
||||
|
||||
FlyString const& animation_name() const { return id(); }
|
||||
|
||||
virtual Animations::AnimationClass animation_class() const override;
|
||||
virtual Optional<int> class_specific_composite_order(JS::NonnullGCPtr<Animations::Animation> other) const override;
|
||||
virtual Optional<int> class_specific_composite_order(GC::Ref<Animations::Animation> other) const override;
|
||||
|
||||
private:
|
||||
explicit CSSAnimation(JS::Realm&);
|
||||
|
|
|
@ -15,9 +15,9 @@
|
|||
|
||||
namespace Web::CSS {
|
||||
|
||||
JS_DEFINE_ALLOCATOR(CSSFontFaceRule);
|
||||
GC_DEFINE_ALLOCATOR(CSSFontFaceRule);
|
||||
|
||||
JS::NonnullGCPtr<CSSFontFaceRule> CSSFontFaceRule::create(JS::Realm& realm, ParsedFontFace&& font_face)
|
||||
GC::Ref<CSSFontFaceRule> CSSFontFaceRule::create(JS::Realm& realm, ParsedFontFace&& font_face)
|
||||
{
|
||||
return realm.create<CSSFontFaceRule>(realm, move(font_face));
|
||||
}
|
||||
|
|
|
@ -14,10 +14,10 @@ namespace Web::CSS {
|
|||
|
||||
class CSSFontFaceRule final : public CSSRule {
|
||||
WEB_PLATFORM_OBJECT(CSSFontFaceRule, CSSRule);
|
||||
JS_DECLARE_ALLOCATOR(CSSFontFaceRule);
|
||||
GC_DECLARE_ALLOCATOR(CSSFontFaceRule);
|
||||
|
||||
public:
|
||||
[[nodiscard]] static JS::NonnullGCPtr<CSSFontFaceRule> create(JS::Realm&, ParsedFontFace&&);
|
||||
[[nodiscard]] static GC::Ref<CSSFontFaceRule> create(JS::Realm&, ParsedFontFace&&);
|
||||
|
||||
virtual ~CSSFontFaceRule() override = default;
|
||||
|
||||
|
|
|
@ -38,7 +38,7 @@ protected:
|
|||
virtual void clear_caches() override;
|
||||
|
||||
private:
|
||||
JS::NonnullGCPtr<CSSRuleList> m_rules;
|
||||
GC::Ref<CSSRuleList> m_rules;
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -20,9 +20,9 @@
|
|||
|
||||
namespace Web::CSS {
|
||||
|
||||
JS_DEFINE_ALLOCATOR(CSSImportRule);
|
||||
GC_DEFINE_ALLOCATOR(CSSImportRule);
|
||||
|
||||
JS::NonnullGCPtr<CSSImportRule> CSSImportRule::create(URL::URL url, DOM::Document& document)
|
||||
GC::Ref<CSSImportRule> CSSImportRule::create(URL::URL url, DOM::Document& document)
|
||||
{
|
||||
auto& realm = document.realm();
|
||||
return realm.create<CSSImportRule>(move(url), document);
|
||||
|
|
|
@ -20,10 +20,10 @@ class CSSImportRule final
|
|||
: public CSSRule
|
||||
, public ResourceClient {
|
||||
WEB_PLATFORM_OBJECT(CSSImportRule, CSSRule);
|
||||
JS_DECLARE_ALLOCATOR(CSSImportRule);
|
||||
GC_DECLARE_ALLOCATOR(CSSImportRule);
|
||||
|
||||
public:
|
||||
[[nodiscard]] static JS::NonnullGCPtr<CSSImportRule> create(URL::URL, DOM::Document&);
|
||||
[[nodiscard]] static GC::Ref<CSSImportRule> create(URL::URL, DOM::Document&);
|
||||
|
||||
virtual ~CSSImportRule() = default;
|
||||
|
||||
|
@ -49,8 +49,8 @@ private:
|
|||
virtual void resource_did_load() override;
|
||||
|
||||
URL::URL m_url;
|
||||
JS::GCPtr<DOM::Document> m_document;
|
||||
JS::GCPtr<CSSStyleSheet> m_style_sheet;
|
||||
GC::Ptr<DOM::Document> m_document;
|
||||
GC::Ptr<CSSStyleSheet> m_style_sheet;
|
||||
Optional<DOM::DocumentLoadEventDelayer> m_document_load_event_delayer;
|
||||
};
|
||||
|
||||
|
|
|
@ -11,9 +11,9 @@
|
|||
|
||||
namespace Web::CSS {
|
||||
|
||||
JS_DEFINE_ALLOCATOR(CSSKeyframeRule);
|
||||
GC_DEFINE_ALLOCATOR(CSSKeyframeRule);
|
||||
|
||||
JS::NonnullGCPtr<CSSKeyframeRule> CSSKeyframeRule::create(JS::Realm& realm, CSS::Percentage key, Web::CSS::PropertyOwningCSSStyleDeclaration& declarations)
|
||||
GC::Ref<CSSKeyframeRule> CSSKeyframeRule::create(JS::Realm& realm, CSS::Percentage key, Web::CSS::PropertyOwningCSSStyleDeclaration& declarations)
|
||||
{
|
||||
return realm.create<CSSKeyframeRule>(realm, key, declarations);
|
||||
}
|
||||
|
|
|
@ -18,16 +18,16 @@ namespace Web::CSS {
|
|||
// https://drafts.csswg.org/css-animations/#interface-csskeyframerule
|
||||
class CSSKeyframeRule final : public CSSRule {
|
||||
WEB_PLATFORM_OBJECT(CSSKeyframeRule, CSSRule);
|
||||
JS_DECLARE_ALLOCATOR(CSSKeyframeRule);
|
||||
GC_DECLARE_ALLOCATOR(CSSKeyframeRule);
|
||||
|
||||
public:
|
||||
static JS::NonnullGCPtr<CSSKeyframeRule> create(JS::Realm&, CSS::Percentage key, PropertyOwningCSSStyleDeclaration&);
|
||||
static GC::Ref<CSSKeyframeRule> create(JS::Realm&, CSS::Percentage key, PropertyOwningCSSStyleDeclaration&);
|
||||
|
||||
virtual ~CSSKeyframeRule() = default;
|
||||
|
||||
CSS::Percentage key() const { return m_key; }
|
||||
JS::NonnullGCPtr<CSSStyleDeclaration> style() const { return m_declarations; }
|
||||
JS::NonnullGCPtr<PropertyOwningCSSStyleDeclaration> style_as_property_owning_style_declaration() const { return m_declarations; }
|
||||
GC::Ref<CSSStyleDeclaration> style() const { return m_declarations; }
|
||||
GC::Ref<PropertyOwningCSSStyleDeclaration> style_as_property_owning_style_declaration() const { return m_declarations; }
|
||||
|
||||
String key_text() const
|
||||
{
|
||||
|
@ -47,7 +47,7 @@ private:
|
|||
virtual String serialized() const override;
|
||||
|
||||
CSS::Percentage m_key;
|
||||
JS::NonnullGCPtr<PropertyOwningCSSStyleDeclaration> m_declarations;
|
||||
GC::Ref<PropertyOwningCSSStyleDeclaration> m_declarations;
|
||||
};
|
||||
|
||||
template<>
|
||||
|
|
|
@ -12,14 +12,14 @@
|
|||
|
||||
namespace Web::CSS {
|
||||
|
||||
JS_DEFINE_ALLOCATOR(CSSKeyframesRule);
|
||||
GC_DEFINE_ALLOCATOR(CSSKeyframesRule);
|
||||
|
||||
JS::NonnullGCPtr<CSSKeyframesRule> CSSKeyframesRule::create(JS::Realm& realm, FlyString name, JS::NonnullGCPtr<CSSRuleList> css_rules)
|
||||
GC::Ref<CSSKeyframesRule> CSSKeyframesRule::create(JS::Realm& realm, FlyString name, GC::Ref<CSSRuleList> css_rules)
|
||||
{
|
||||
return realm.create<CSSKeyframesRule>(realm, move(name), move(css_rules));
|
||||
}
|
||||
|
||||
CSSKeyframesRule::CSSKeyframesRule(JS::Realm& realm, FlyString name, JS::NonnullGCPtr<CSSRuleList> keyframes)
|
||||
CSSKeyframesRule::CSSKeyframesRule(JS::Realm& realm, FlyString name, GC::Ref<CSSRuleList> keyframes)
|
||||
: CSSRule(realm, Type::Keyframes)
|
||||
, m_name(move(name))
|
||||
, m_rules(move(keyframes))
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
|
||||
#include <AK/FlyString.h>
|
||||
#include <AK/NonnullRefPtr.h>
|
||||
#include <LibJS/Heap/GCPtr.h>
|
||||
#include <LibGC/Ptr.h>
|
||||
#include <LibWeb/CSS/CSSKeyframeRule.h>
|
||||
#include <LibWeb/CSS/CSSRule.h>
|
||||
#include <LibWeb/Forward.h>
|
||||
|
@ -21,10 +21,10 @@ namespace Web::CSS {
|
|||
// https://drafts.csswg.org/css-animations/#interface-csskeyframesrule
|
||||
class CSSKeyframesRule final : public CSSRule {
|
||||
WEB_PLATFORM_OBJECT(CSSKeyframesRule, CSSRule);
|
||||
JS_DECLARE_ALLOCATOR(CSSKeyframesRule);
|
||||
GC_DECLARE_ALLOCATOR(CSSKeyframesRule);
|
||||
|
||||
public:
|
||||
[[nodiscard]] static JS::NonnullGCPtr<CSSKeyframesRule> create(JS::Realm&, FlyString name, JS::NonnullGCPtr<CSSRuleList>);
|
||||
[[nodiscard]] static GC::Ref<CSSKeyframesRule> create(JS::Realm&, FlyString name, GC::Ref<CSSRuleList>);
|
||||
|
||||
virtual ~CSSKeyframesRule() = default;
|
||||
|
||||
|
@ -35,14 +35,14 @@ public:
|
|||
void set_name(String const& name) { m_name = name; }
|
||||
|
||||
private:
|
||||
CSSKeyframesRule(JS::Realm&, FlyString name, JS::NonnullGCPtr<CSSRuleList> keyframes);
|
||||
CSSKeyframesRule(JS::Realm&, FlyString name, GC::Ref<CSSRuleList> keyframes);
|
||||
virtual void visit_edges(Visitor&) override;
|
||||
|
||||
virtual void initialize(JS::Realm&) override;
|
||||
virtual String serialized() const override;
|
||||
|
||||
FlyString m_name;
|
||||
JS::NonnullGCPtr<CSSRuleList> m_rules;
|
||||
GC::Ref<CSSRuleList> m_rules;
|
||||
};
|
||||
|
||||
template<>
|
||||
|
|
|
@ -11,9 +11,9 @@
|
|||
|
||||
namespace Web::CSS {
|
||||
|
||||
JS_DEFINE_ALLOCATOR(CSSLayerBlockRule);
|
||||
GC_DEFINE_ALLOCATOR(CSSLayerBlockRule);
|
||||
|
||||
JS::NonnullGCPtr<CSSLayerBlockRule> CSSLayerBlockRule::create(JS::Realm& realm, FlyString name, CSSRuleList& rules)
|
||||
GC::Ref<CSSLayerBlockRule> CSSLayerBlockRule::create(JS::Realm& realm, FlyString name, CSSRuleList& rules)
|
||||
{
|
||||
return realm.create<CSSLayerBlockRule>(realm, move(name), rules);
|
||||
}
|
||||
|
|
|
@ -13,10 +13,10 @@ namespace Web::CSS {
|
|||
// https://drafts.csswg.org/css-cascade-5/#the-csslayerblockrule-interface
|
||||
class CSSLayerBlockRule final : public CSSGroupingRule {
|
||||
WEB_PLATFORM_OBJECT(CSSLayerBlockRule, CSSGroupingRule);
|
||||
JS_DECLARE_ALLOCATOR(CSSLayerBlockRule);
|
||||
GC_DECLARE_ALLOCATOR(CSSLayerBlockRule);
|
||||
|
||||
public:
|
||||
[[nodiscard]] static JS::NonnullGCPtr<CSSLayerBlockRule> create(JS::Realm&, FlyString name, CSSRuleList&);
|
||||
[[nodiscard]] static GC::Ref<CSSLayerBlockRule> create(JS::Realm&, FlyString name, CSSRuleList&);
|
||||
|
||||
static FlyString next_unique_anonymous_layer_name();
|
||||
|
||||
|
|
|
@ -11,9 +11,9 @@
|
|||
|
||||
namespace Web::CSS {
|
||||
|
||||
JS_DEFINE_ALLOCATOR(CSSLayerStatementRule);
|
||||
GC_DEFINE_ALLOCATOR(CSSLayerStatementRule);
|
||||
|
||||
JS::NonnullGCPtr<CSSLayerStatementRule> CSSLayerStatementRule::create(JS::Realm& realm, Vector<FlyString> name_list)
|
||||
GC::Ref<CSSLayerStatementRule> CSSLayerStatementRule::create(JS::Realm& realm, Vector<FlyString> name_list)
|
||||
{
|
||||
return realm.create<CSSLayerStatementRule>(realm, move(name_list));
|
||||
}
|
||||
|
|
|
@ -13,10 +13,10 @@ namespace Web::CSS {
|
|||
// https://drafts.csswg.org/css-cascade-5/#the-csslayerstatementrule-interface
|
||||
class CSSLayerStatementRule final : public CSSRule {
|
||||
WEB_PLATFORM_OBJECT(CSSLayerStatementRule, CSSRule);
|
||||
JS_DECLARE_ALLOCATOR(CSSLayerStatementRule);
|
||||
GC_DECLARE_ALLOCATOR(CSSLayerStatementRule);
|
||||
|
||||
public:
|
||||
[[nodiscard]] static JS::NonnullGCPtr<CSSLayerStatementRule> create(JS::Realm&, Vector<FlyString> name_list);
|
||||
[[nodiscard]] static GC::Ref<CSSLayerStatementRule> create(JS::Realm&, Vector<FlyString> name_list);
|
||||
|
||||
virtual ~CSSLayerStatementRule() = default;
|
||||
|
||||
|
|
|
@ -12,9 +12,9 @@
|
|||
|
||||
namespace Web::CSS {
|
||||
|
||||
JS_DEFINE_ALLOCATOR(CSSMediaRule);
|
||||
GC_DEFINE_ALLOCATOR(CSSMediaRule);
|
||||
|
||||
JS::NonnullGCPtr<CSSMediaRule> CSSMediaRule::create(JS::Realm& realm, MediaList& media_queries, CSSRuleList& rules)
|
||||
GC::Ref<CSSMediaRule> CSSMediaRule::create(JS::Realm& realm, MediaList& media_queries, CSSRuleList& rules)
|
||||
{
|
||||
return realm.create<CSSMediaRule>(realm, media_queries, rules);
|
||||
}
|
||||
|
|
|
@ -16,10 +16,10 @@ namespace Web::CSS {
|
|||
// https://www.w3.org/TR/css-conditional-3/#the-cssmediarule-interface
|
||||
class CSSMediaRule final : public CSSConditionRule {
|
||||
WEB_PLATFORM_OBJECT(CSSMediaRule, CSSConditionRule);
|
||||
JS_DECLARE_ALLOCATOR(CSSMediaRule);
|
||||
GC_DECLARE_ALLOCATOR(CSSMediaRule);
|
||||
|
||||
public:
|
||||
[[nodiscard]] static JS::NonnullGCPtr<CSSMediaRule> create(JS::Realm&, MediaList& media_queries, CSSRuleList&);
|
||||
[[nodiscard]] static GC::Ref<CSSMediaRule> create(JS::Realm&, MediaList& media_queries, CSSRuleList&);
|
||||
|
||||
virtual ~CSSMediaRule() = default;
|
||||
|
||||
|
@ -37,7 +37,7 @@ private:
|
|||
virtual void visit_edges(Cell::Visitor&) override;
|
||||
virtual String serialized() const override;
|
||||
|
||||
JS::NonnullGCPtr<MediaList> m_media;
|
||||
GC::Ref<MediaList> m_media;
|
||||
};
|
||||
|
||||
template<>
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#include <LibJS/Heap/Heap.h>
|
||||
#include <LibGC/Heap.h>
|
||||
#include <LibJS/Runtime/Realm.h>
|
||||
#include <LibWeb/Bindings/CSSNamespaceRulePrototype.h>
|
||||
#include <LibWeb/Bindings/Intrinsics.h>
|
||||
|
@ -14,7 +14,7 @@
|
|||
|
||||
namespace Web::CSS {
|
||||
|
||||
JS_DEFINE_ALLOCATOR(CSSNamespaceRule);
|
||||
GC_DEFINE_ALLOCATOR(CSSNamespaceRule);
|
||||
|
||||
CSSNamespaceRule::CSSNamespaceRule(JS::Realm& realm, Optional<FlyString> prefix, FlyString namespace_uri)
|
||||
: CSSRule(realm, Type::Namespace)
|
||||
|
@ -23,7 +23,7 @@ CSSNamespaceRule::CSSNamespaceRule(JS::Realm& realm, Optional<FlyString> prefix,
|
|||
{
|
||||
}
|
||||
|
||||
JS::NonnullGCPtr<CSSNamespaceRule> CSSNamespaceRule::create(JS::Realm& realm, Optional<FlyString> prefix, FlyString namespace_uri)
|
||||
GC::Ref<CSSNamespaceRule> CSSNamespaceRule::create(JS::Realm& realm, Optional<FlyString> prefix, FlyString namespace_uri)
|
||||
{
|
||||
return realm.create<CSSNamespaceRule>(realm, move(prefix), move(namespace_uri));
|
||||
}
|
||||
|
|
|
@ -12,10 +12,10 @@ namespace Web::CSS {
|
|||
|
||||
class CSSNamespaceRule final : public CSSRule {
|
||||
WEB_PLATFORM_OBJECT(CSSNamespaceRule, CSSRule);
|
||||
JS_DECLARE_ALLOCATOR(CSSNamespaceRule);
|
||||
GC_DECLARE_ALLOCATOR(CSSNamespaceRule);
|
||||
|
||||
public:
|
||||
[[nodiscard]] static JS::NonnullGCPtr<CSSNamespaceRule> create(JS::Realm&, Optional<FlyString> prefix, FlyString namespace_uri);
|
||||
[[nodiscard]] static GC::Ref<CSSNamespaceRule> create(JS::Realm&, Optional<FlyString> prefix, FlyString namespace_uri);
|
||||
|
||||
virtual ~CSSNamespaceRule() = default;
|
||||
|
||||
|
|
|
@ -11,9 +11,9 @@
|
|||
|
||||
namespace Web::CSS {
|
||||
|
||||
JS_DEFINE_ALLOCATOR(CSSNestedDeclarations);
|
||||
GC_DEFINE_ALLOCATOR(CSSNestedDeclarations);
|
||||
|
||||
JS::NonnullGCPtr<CSSNestedDeclarations> CSSNestedDeclarations::create(JS::Realm& realm, PropertyOwningCSSStyleDeclaration& declaration)
|
||||
GC::Ref<CSSNestedDeclarations> CSSNestedDeclarations::create(JS::Realm& realm, PropertyOwningCSSStyleDeclaration& declaration)
|
||||
{
|
||||
return realm.create<CSSNestedDeclarations>(realm, declaration);
|
||||
}
|
||||
|
|
|
@ -12,10 +12,10 @@ namespace Web::CSS {
|
|||
|
||||
class CSSNestedDeclarations final : public CSSRule {
|
||||
WEB_PLATFORM_OBJECT(CSSNestedDeclarations, CSSRule);
|
||||
JS_DECLARE_ALLOCATOR(CSSNestedDeclarations);
|
||||
GC_DECLARE_ALLOCATOR(CSSNestedDeclarations);
|
||||
|
||||
public:
|
||||
[[nodiscard]] static JS::NonnullGCPtr<CSSNestedDeclarations> create(JS::Realm&, PropertyOwningCSSStyleDeclaration&);
|
||||
[[nodiscard]] static GC::Ref<CSSNestedDeclarations> create(JS::Realm&, PropertyOwningCSSStyleDeclaration&);
|
||||
|
||||
virtual ~CSSNestedDeclarations() override = default;
|
||||
|
||||
|
@ -33,8 +33,8 @@ private:
|
|||
virtual String serialized() const override;
|
||||
virtual void clear_caches() override;
|
||||
|
||||
JS::NonnullGCPtr<PropertyOwningCSSStyleDeclaration> m_declaration;
|
||||
JS::GCPtr<CSSStyleRule const> mutable m_parent_style_rule;
|
||||
GC::Ref<PropertyOwningCSSStyleDeclaration> m_declaration;
|
||||
GC::Ptr<CSSStyleRule const> mutable m_parent_style_rule;
|
||||
};
|
||||
|
||||
template<>
|
||||
|
|
|
@ -11,9 +11,9 @@
|
|||
|
||||
namespace Web::CSS {
|
||||
|
||||
JS_DEFINE_ALLOCATOR(CSSPropertyRule);
|
||||
GC_DEFINE_ALLOCATOR(CSSPropertyRule);
|
||||
|
||||
JS::NonnullGCPtr<CSSPropertyRule> CSSPropertyRule::create(JS::Realm& realm, FlyString name, FlyString syntax, bool inherits, Optional<String> initial_value)
|
||||
GC::Ref<CSSPropertyRule> CSSPropertyRule::create(JS::Realm& realm, FlyString name, FlyString syntax, bool inherits, Optional<String> initial_value)
|
||||
{
|
||||
return realm.create<CSSPropertyRule>(realm, move(name), move(syntax), inherits, move(initial_value));
|
||||
}
|
||||
|
|
|
@ -18,10 +18,10 @@ namespace Web::CSS {
|
|||
// https://drafts.css-houdini.org/css-properties-values-api/#the-css-property-rule-interface
|
||||
class CSSPropertyRule final : public CSSRule {
|
||||
WEB_PLATFORM_OBJECT(CSSPropertyRule, CSSRule);
|
||||
JS_DECLARE_ALLOCATOR(CSSPropertyRule);
|
||||
GC_DECLARE_ALLOCATOR(CSSPropertyRule);
|
||||
|
||||
public:
|
||||
static JS::NonnullGCPtr<CSSPropertyRule> create(JS::Realm&, FlyString name, FlyString syntax, bool inherits, Optional<String> initial_value);
|
||||
static GC::Ref<CSSPropertyRule> create(JS::Realm&, FlyString name, FlyString syntax, bool inherits, Optional<String> initial_value);
|
||||
|
||||
virtual ~CSSPropertyRule() = default;
|
||||
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
#pragma once
|
||||
|
||||
#include <AK/String.h>
|
||||
#include <LibJS/Heap/GCPtr.h>
|
||||
#include <LibGC/Ptr.h>
|
||||
#include <LibWeb/Bindings/PlatformObject.h>
|
||||
#include <LibWeb/CSS/CSSStyleDeclaration.h>
|
||||
#include <LibWeb/CSS/Selector.h>
|
||||
|
@ -75,8 +75,8 @@ protected:
|
|||
[[nodiscard]] FlyString const& parent_layer_internal_qualified_name_slow_case() const;
|
||||
|
||||
Type m_type;
|
||||
JS::GCPtr<CSSRule> m_parent_rule;
|
||||
JS::GCPtr<CSSStyleSheet> m_parent_style_sheet;
|
||||
GC::Ptr<CSSRule> m_parent_rule;
|
||||
GC::Ptr<CSSStyleSheet> m_parent_style_sheet;
|
||||
|
||||
mutable Optional<FlyString> m_cached_layer_name;
|
||||
};
|
||||
|
|
|
@ -19,9 +19,9 @@
|
|||
|
||||
namespace Web::CSS {
|
||||
|
||||
JS_DEFINE_ALLOCATOR(CSSRuleList);
|
||||
GC_DEFINE_ALLOCATOR(CSSRuleList);
|
||||
|
||||
JS::NonnullGCPtr<CSSRuleList> CSSRuleList::create(JS::Realm& realm, JS::MarkedVector<CSSRule*> const& rules)
|
||||
GC::Ref<CSSRuleList> CSSRuleList::create(JS::Realm& realm, GC::MarkedVector<CSSRule*> const& rules)
|
||||
{
|
||||
auto rule_list = realm.create<CSSRuleList>(realm);
|
||||
for (auto* rule : rules)
|
||||
|
@ -35,7 +35,7 @@ CSSRuleList::CSSRuleList(JS::Realm& realm)
|
|||
m_legacy_platform_object_flags = LegacyPlatformObjectFlags { .supports_indexed_properties = 1 };
|
||||
}
|
||||
|
||||
JS::NonnullGCPtr<CSSRuleList> CSSRuleList::create_empty(JS::Realm& realm)
|
||||
GC::Ref<CSSRuleList> CSSRuleList::create_empty(JS::Realm& realm)
|
||||
{
|
||||
return realm.create<CSSRuleList>(realm);
|
||||
}
|
||||
|
|
|
@ -22,11 +22,11 @@ namespace Web::CSS {
|
|||
// https://www.w3.org/TR/cssom/#the-cssrulelist-interface
|
||||
class CSSRuleList : public Bindings::PlatformObject {
|
||||
WEB_PLATFORM_OBJECT(CSSRuleList, Bindings::PlatformObject);
|
||||
JS_DECLARE_ALLOCATOR(CSSRuleList);
|
||||
GC_DECLARE_ALLOCATOR(CSSRuleList);
|
||||
|
||||
public:
|
||||
[[nodiscard]] static JS::NonnullGCPtr<CSSRuleList> create(JS::Realm&, JS::MarkedVector<CSSRule*> const&);
|
||||
[[nodiscard]] static JS::NonnullGCPtr<CSSRuleList> create_empty(JS::Realm&);
|
||||
[[nodiscard]] static GC::Ref<CSSRuleList> create(JS::Realm&, GC::MarkedVector<CSSRule*> const&);
|
||||
[[nodiscard]] static GC::Ref<CSSRuleList> create_empty(JS::Realm&);
|
||||
|
||||
~CSSRuleList() = default;
|
||||
|
||||
|
@ -61,7 +61,7 @@ public:
|
|||
// Returns whether the match state of any media queries changed after evaluation.
|
||||
bool evaluate_media_queries(HTML::Window const&);
|
||||
|
||||
void set_rules(Badge<CSSStyleSheet>, Vector<JS::NonnullGCPtr<CSSRule>> rules) { m_rules = move(rules); }
|
||||
void set_rules(Badge<CSSStyleSheet>, Vector<GC::Ref<CSSRule>> rules) { m_rules = move(rules); }
|
||||
|
||||
Function<void()> on_change;
|
||||
|
||||
|
@ -71,7 +71,7 @@ private:
|
|||
virtual void initialize(JS::Realm&) override;
|
||||
virtual void visit_edges(Cell::Visitor&) override;
|
||||
|
||||
Vector<JS::NonnullGCPtr<CSSRule>> m_rules;
|
||||
Vector<GC::Ref<CSSRule>> m_rules;
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -17,9 +17,9 @@
|
|||
|
||||
namespace Web::CSS {
|
||||
|
||||
JS_DEFINE_ALLOCATOR(CSSStyleDeclaration);
|
||||
JS_DEFINE_ALLOCATOR(PropertyOwningCSSStyleDeclaration);
|
||||
JS_DEFINE_ALLOCATOR(ElementInlineCSSStyleDeclaration);
|
||||
GC_DEFINE_ALLOCATOR(CSSStyleDeclaration);
|
||||
GC_DEFINE_ALLOCATOR(PropertyOwningCSSStyleDeclaration);
|
||||
GC_DEFINE_ALLOCATOR(ElementInlineCSSStyleDeclaration);
|
||||
|
||||
CSSStyleDeclaration::CSSStyleDeclaration(JS::Realm& realm)
|
||||
: PlatformObject(realm)
|
||||
|
@ -35,12 +35,12 @@ void CSSStyleDeclaration::initialize(JS::Realm& realm)
|
|||
WEB_SET_PROTOTYPE_FOR_INTERFACE(CSSStyleDeclaration);
|
||||
}
|
||||
|
||||
JS::GCPtr<CSSRule> CSSStyleDeclaration::parent_rule() const
|
||||
GC::Ptr<CSSRule> CSSStyleDeclaration::parent_rule() const
|
||||
{
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
JS::NonnullGCPtr<PropertyOwningCSSStyleDeclaration> PropertyOwningCSSStyleDeclaration::create(JS::Realm& realm, Vector<StyleProperty> properties, HashMap<FlyString, StyleProperty> custom_properties)
|
||||
GC::Ref<PropertyOwningCSSStyleDeclaration> PropertyOwningCSSStyleDeclaration::create(JS::Realm& realm, Vector<StyleProperty> properties, HashMap<FlyString, StyleProperty> custom_properties)
|
||||
{
|
||||
return realm.create<PropertyOwningCSSStyleDeclaration>(realm, move(properties), move(custom_properties));
|
||||
}
|
||||
|
@ -69,7 +69,7 @@ String PropertyOwningCSSStyleDeclaration::item(size_t index) const
|
|||
return CSS::string_from_property_id(m_properties[index].property_id).to_string();
|
||||
}
|
||||
|
||||
JS::NonnullGCPtr<ElementInlineCSSStyleDeclaration> ElementInlineCSSStyleDeclaration::create(DOM::Element& element, Vector<StyleProperty> properties, HashMap<FlyString, StyleProperty> custom_properties)
|
||||
GC::Ref<ElementInlineCSSStyleDeclaration> ElementInlineCSSStyleDeclaration::create(DOM::Element& element, Vector<StyleProperty> properties, HashMap<FlyString, StyleProperty> custom_properties)
|
||||
{
|
||||
auto& realm = element.realm();
|
||||
return realm.create<ElementInlineCSSStyleDeclaration>(element, move(properties), move(custom_properties));
|
||||
|
@ -505,12 +505,12 @@ WebIDL::ExceptionOr<void> ElementInlineCSSStyleDeclaration::set_css_text(StringV
|
|||
return {};
|
||||
}
|
||||
|
||||
JS::GCPtr<CSSRule> PropertyOwningCSSStyleDeclaration::parent_rule() const
|
||||
GC::Ptr<CSSRule> PropertyOwningCSSStyleDeclaration::parent_rule() const
|
||||
{
|
||||
return m_parent_rule;
|
||||
}
|
||||
|
||||
void PropertyOwningCSSStyleDeclaration::set_parent_rule(JS::NonnullGCPtr<CSSRule> rule)
|
||||
void PropertyOwningCSSStyleDeclaration::set_parent_rule(GC::Ref<CSSRule> rule)
|
||||
{
|
||||
m_parent_rule = rule;
|
||||
}
|
||||
|
|
|
@ -19,7 +19,7 @@ class CSSStyleDeclaration
|
|||
: public Bindings::PlatformObject
|
||||
, public Bindings::GeneratedCSSStyleProperties {
|
||||
WEB_PLATFORM_OBJECT(CSSStyleDeclaration, Bindings::PlatformObject);
|
||||
JS_DECLARE_ALLOCATOR(CSSStyleDeclaration);
|
||||
GC_DECLARE_ALLOCATOR(CSSStyleDeclaration);
|
||||
|
||||
public:
|
||||
virtual ~CSSStyleDeclaration() = default;
|
||||
|
@ -47,7 +47,7 @@ public:
|
|||
|
||||
virtual String serialized() const = 0;
|
||||
|
||||
virtual JS::GCPtr<CSSRule> parent_rule() const;
|
||||
virtual GC::Ptr<CSSRule> parent_rule() const;
|
||||
|
||||
protected:
|
||||
explicit CSSStyleDeclaration(JS::Realm&);
|
||||
|
@ -61,12 +61,12 @@ private:
|
|||
|
||||
class PropertyOwningCSSStyleDeclaration : public CSSStyleDeclaration {
|
||||
WEB_PLATFORM_OBJECT(PropertyOwningCSSStyleDeclaration, CSSStyleDeclaration);
|
||||
JS_DECLARE_ALLOCATOR(PropertyOwningCSSStyleDeclaration);
|
||||
GC_DECLARE_ALLOCATOR(PropertyOwningCSSStyleDeclaration);
|
||||
|
||||
friend class ElementInlineCSSStyleDeclaration;
|
||||
|
||||
public:
|
||||
[[nodiscard]] static JS::NonnullGCPtr<PropertyOwningCSSStyleDeclaration>
|
||||
[[nodiscard]] static GC::Ref<PropertyOwningCSSStyleDeclaration>
|
||||
create(JS::Realm&, Vector<StyleProperty>, HashMap<FlyString, StyleProperty> custom_properties);
|
||||
|
||||
virtual ~PropertyOwningCSSStyleDeclaration() override = default;
|
||||
|
@ -87,8 +87,8 @@ public:
|
|||
virtual String serialized() const final override;
|
||||
virtual WebIDL::ExceptionOr<void> set_css_text(StringView) override;
|
||||
|
||||
virtual JS::GCPtr<CSSRule> parent_rule() const override;
|
||||
void set_parent_rule(JS::NonnullGCPtr<CSSRule>);
|
||||
virtual GC::Ptr<CSSRule> parent_rule() const override;
|
||||
void set_parent_rule(GC::Ref<CSSRule>);
|
||||
|
||||
protected:
|
||||
PropertyOwningCSSStyleDeclaration(JS::Realm&, Vector<StyleProperty>, HashMap<FlyString, StyleProperty>);
|
||||
|
@ -103,17 +103,17 @@ private:
|
|||
|
||||
virtual void visit_edges(Cell::Visitor&) override;
|
||||
|
||||
JS::GCPtr<CSSRule> m_parent_rule;
|
||||
GC::Ptr<CSSRule> m_parent_rule;
|
||||
Vector<StyleProperty> m_properties;
|
||||
HashMap<FlyString, StyleProperty> m_custom_properties;
|
||||
};
|
||||
|
||||
class ElementInlineCSSStyleDeclaration final : public PropertyOwningCSSStyleDeclaration {
|
||||
WEB_PLATFORM_OBJECT(ElementInlineCSSStyleDeclaration, PropertyOwningCSSStyleDeclaration);
|
||||
JS_DECLARE_ALLOCATOR(ElementInlineCSSStyleDeclaration);
|
||||
GC_DECLARE_ALLOCATOR(ElementInlineCSSStyleDeclaration);
|
||||
|
||||
public:
|
||||
[[nodiscard]] static JS::NonnullGCPtr<ElementInlineCSSStyleDeclaration> create(DOM::Element&, Vector<StyleProperty>, HashMap<FlyString, StyleProperty> custom_properties);
|
||||
[[nodiscard]] static GC::Ref<ElementInlineCSSStyleDeclaration> create(DOM::Element&, Vector<StyleProperty>, HashMap<FlyString, StyleProperty> custom_properties);
|
||||
|
||||
virtual ~ElementInlineCSSStyleDeclaration() override = default;
|
||||
|
||||
|
@ -131,7 +131,7 @@ private:
|
|||
|
||||
virtual void update_style_attribute() override;
|
||||
|
||||
JS::GCPtr<DOM::Element> m_element;
|
||||
GC::Ptr<DOM::Element> m_element;
|
||||
|
||||
// https://drafts.csswg.org/cssom/#cssstyledeclaration-updating-flag
|
||||
bool m_updating { false };
|
||||
|
|
|
@ -14,9 +14,9 @@
|
|||
|
||||
namespace Web::CSS {
|
||||
|
||||
JS_DEFINE_ALLOCATOR(CSSStyleRule);
|
||||
GC_DEFINE_ALLOCATOR(CSSStyleRule);
|
||||
|
||||
JS::NonnullGCPtr<CSSStyleRule> CSSStyleRule::create(JS::Realm& realm, SelectorList&& selectors, PropertyOwningCSSStyleDeclaration& declaration, CSSRuleList& nested_rules)
|
||||
GC::Ref<CSSStyleRule> CSSStyleRule::create(JS::Realm& realm, SelectorList&& selectors, PropertyOwningCSSStyleDeclaration& declaration, CSSRuleList& nested_rules)
|
||||
{
|
||||
return realm.create<CSSStyleRule>(realm, move(selectors), declaration, nested_rules);
|
||||
}
|
||||
|
|
|
@ -16,10 +16,10 @@ namespace Web::CSS {
|
|||
|
||||
class CSSStyleRule final : public CSSGroupingRule {
|
||||
WEB_PLATFORM_OBJECT(CSSStyleRule, CSSGroupingRule);
|
||||
JS_DECLARE_ALLOCATOR(CSSStyleRule);
|
||||
GC_DECLARE_ALLOCATOR(CSSStyleRule);
|
||||
|
||||
public:
|
||||
[[nodiscard]] static JS::NonnullGCPtr<CSSStyleRule> create(JS::Realm&, SelectorList&&, PropertyOwningCSSStyleDeclaration&, CSSRuleList&);
|
||||
[[nodiscard]] static GC::Ref<CSSStyleRule> create(JS::Realm&, SelectorList&&, PropertyOwningCSSStyleDeclaration&, CSSRuleList&);
|
||||
|
||||
virtual ~CSSStyleRule() override = default;
|
||||
|
||||
|
@ -46,7 +46,7 @@ private:
|
|||
|
||||
SelectorList m_selectors;
|
||||
mutable Optional<SelectorList> m_cached_absolutized_selectors;
|
||||
JS::NonnullGCPtr<PropertyOwningCSSStyleDeclaration> m_declaration;
|
||||
GC::Ref<PropertyOwningCSSStyleDeclaration> m_declaration;
|
||||
};
|
||||
|
||||
template<>
|
||||
|
|
|
@ -21,15 +21,15 @@
|
|||
|
||||
namespace Web::CSS {
|
||||
|
||||
JS_DEFINE_ALLOCATOR(CSSStyleSheet);
|
||||
GC_DEFINE_ALLOCATOR(CSSStyleSheet);
|
||||
|
||||
JS::NonnullGCPtr<CSSStyleSheet> CSSStyleSheet::create(JS::Realm& realm, CSSRuleList& rules, MediaList& media, Optional<URL::URL> location)
|
||||
GC::Ref<CSSStyleSheet> CSSStyleSheet::create(JS::Realm& realm, CSSRuleList& rules, MediaList& media, Optional<URL::URL> location)
|
||||
{
|
||||
return realm.create<CSSStyleSheet>(realm, rules, media, move(location));
|
||||
}
|
||||
|
||||
// https://drafts.csswg.org/cssom/#dom-cssstylesheet-cssstylesheet
|
||||
WebIDL::ExceptionOr<JS::NonnullGCPtr<CSSStyleSheet>> CSSStyleSheet::construct_impl(JS::Realm& realm, Optional<CSSStyleSheetInit> const& options)
|
||||
WebIDL::ExceptionOr<GC::Ref<CSSStyleSheet>> CSSStyleSheet::construct_impl(JS::Realm& realm, Optional<CSSStyleSheetInit> const& options)
|
||||
{
|
||||
// 1. Construct a new CSSStyleSheet object sheet.
|
||||
auto sheet = create(realm, CSSRuleList::create_empty(realm), CSS::MediaList::create(realm, {}), {});
|
||||
|
@ -82,7 +82,7 @@ WebIDL::ExceptionOr<JS::NonnullGCPtr<CSSStyleSheet>> CSSStyleSheet::construct_im
|
|||
if (options->media.has<String>()) {
|
||||
sheet->set_media(options->media.get<String>());
|
||||
} else {
|
||||
sheet->m_media = *options->media.get<JS::Handle<MediaList>>();
|
||||
sheet->m_media = *options->media.get<GC::Root<MediaList>>();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -187,7 +187,7 @@ WebIDL::ExceptionOr<void> CSSStyleSheet::delete_rule(unsigned index)
|
|||
}
|
||||
|
||||
// https://drafts.csswg.org/cssom/#dom-cssstylesheet-replace
|
||||
JS::NonnullGCPtr<WebIDL::Promise> CSSStyleSheet::replace(String text)
|
||||
GC::Ref<WebIDL::Promise> CSSStyleSheet::replace(String text)
|
||||
{
|
||||
auto& realm = this->realm();
|
||||
|
||||
|
@ -209,7 +209,7 @@ JS::NonnullGCPtr<WebIDL::Promise> CSSStyleSheet::replace(String text)
|
|||
set_disallow_modification(true);
|
||||
|
||||
// 4. In parallel, do these steps:
|
||||
Platform::EventLoopPlugin::the().deferred_invoke(JS::create_heap_function(realm.heap(), [&realm, this, text = move(text), promise = JS::Handle(promise)] {
|
||||
Platform::EventLoopPlugin::the().deferred_invoke(GC::create_function(realm.heap(), [&realm, this, text = move(text), promise = GC::Root(promise)] {
|
||||
HTML::TemporaryExecutionContext execution_context { realm, HTML::TemporaryExecutionContext::CallbacksEnabled::Yes };
|
||||
|
||||
// 1. Let rules be the result of running parse a stylesheet’s contents from text.
|
||||
|
@ -218,7 +218,7 @@ JS::NonnullGCPtr<WebIDL::Promise> CSSStyleSheet::replace(String text)
|
|||
auto& rules = parsed_stylesheet->rules();
|
||||
|
||||
// 2. If rules contains one or more @import rules, remove those rules from rules.
|
||||
JS::MarkedVector<JS::NonnullGCPtr<CSSRule>> rules_without_import(realm.heap());
|
||||
GC::MarkedVector<GC::Ref<CSSRule>> rules_without_import(realm.heap());
|
||||
for (auto rule : rules) {
|
||||
if (rule->type() != CSSRule::Type::Import)
|
||||
rules_without_import.append(rule);
|
||||
|
@ -252,7 +252,7 @@ WebIDL::ExceptionOr<void> CSSStyleSheet::replace_sync(StringView text)
|
|||
auto& rules = parsed_stylesheet->rules();
|
||||
|
||||
// 3. If rules contains one or more @import rules, remove those rules from rules.
|
||||
JS::MarkedVector<JS::NonnullGCPtr<CSSRule>> rules_without_import(realm().heap());
|
||||
GC::MarkedVector<GC::Ref<CSSRule>> rules_without_import(realm().heap());
|
||||
for (auto rule : rules) {
|
||||
if (rule->type() != CSSRule::Type::Import)
|
||||
rules_without_import.append(rule);
|
||||
|
@ -352,7 +352,7 @@ Optional<FlyString> CSSStyleSheet::default_namespace() const
|
|||
Optional<FlyString> CSSStyleSheet::namespace_uri(StringView namespace_prefix) const
|
||||
{
|
||||
return m_namespace_rules.get(namespace_prefix)
|
||||
.map([](JS::GCPtr<CSSNamespaceRule> namespace_) {
|
||||
.map([](GC::Ptr<CSSNamespaceRule> namespace_) {
|
||||
return namespace_->namespace_uri();
|
||||
});
|
||||
}
|
||||
|
|
|
@ -22,22 +22,22 @@ class FontLoader;
|
|||
|
||||
struct CSSStyleSheetInit {
|
||||
Optional<String> base_url {};
|
||||
Variant<JS::Handle<MediaList>, String> media { String {} };
|
||||
Variant<GC::Root<MediaList>, String> media { String {} };
|
||||
bool disabled { false };
|
||||
};
|
||||
|
||||
class CSSStyleSheet final : public StyleSheet {
|
||||
WEB_PLATFORM_OBJECT(CSSStyleSheet, StyleSheet);
|
||||
JS_DECLARE_ALLOCATOR(CSSStyleSheet);
|
||||
GC_DECLARE_ALLOCATOR(CSSStyleSheet);
|
||||
|
||||
public:
|
||||
[[nodiscard]] static JS::NonnullGCPtr<CSSStyleSheet> create(JS::Realm&, CSSRuleList&, MediaList&, Optional<URL::URL> location);
|
||||
static WebIDL::ExceptionOr<JS::NonnullGCPtr<CSSStyleSheet>> construct_impl(JS::Realm&, Optional<CSSStyleSheetInit> const& options = {});
|
||||
[[nodiscard]] static GC::Ref<CSSStyleSheet> create(JS::Realm&, CSSRuleList&, MediaList&, Optional<URL::URL> location);
|
||||
static WebIDL::ExceptionOr<GC::Ref<CSSStyleSheet>> construct_impl(JS::Realm&, Optional<CSSStyleSheetInit> const& options = {});
|
||||
|
||||
virtual ~CSSStyleSheet() override = default;
|
||||
|
||||
JS::GCPtr<CSSRule const> owner_rule() const { return m_owner_css_rule; }
|
||||
JS::GCPtr<CSSRule> owner_rule() { return m_owner_css_rule; }
|
||||
GC::Ptr<CSSRule const> owner_rule() const { return m_owner_css_rule; }
|
||||
GC::Ptr<CSSRule> owner_rule() { return m_owner_css_rule; }
|
||||
void set_owner_css_rule(CSSRule* rule) { m_owner_css_rule = rule; }
|
||||
|
||||
virtual String type() const override { return "text/css"_string; }
|
||||
|
@ -53,7 +53,7 @@ public:
|
|||
WebIDL::ExceptionOr<void> remove_rule(Optional<WebIDL::UnsignedLong> index);
|
||||
WebIDL::ExceptionOr<void> delete_rule(unsigned index);
|
||||
|
||||
JS::NonnullGCPtr<WebIDL::Promise> replace(String text);
|
||||
GC::Ref<WebIDL::Promise> replace(String text);
|
||||
WebIDL::ExceptionOr<void> replace_sync(StringView text);
|
||||
|
||||
void for_each_effective_rule(TraversalOrder, Function<void(CSSRule const&)> const& callback) const;
|
||||
|
@ -62,23 +62,23 @@ public:
|
|||
bool evaluate_media_queries(HTML::Window const&);
|
||||
void for_each_effective_keyframes_at_rule(Function<void(CSSKeyframesRule const&)> const& callback) const;
|
||||
|
||||
JS::GCPtr<StyleSheetList> style_sheet_list() const { return m_style_sheet_list; }
|
||||
GC::Ptr<StyleSheetList> style_sheet_list() const { return m_style_sheet_list; }
|
||||
void set_style_sheet_list(Badge<StyleSheetList>, StyleSheetList*);
|
||||
|
||||
Optional<FlyString> default_namespace() const;
|
||||
JS::GCPtr<CSSNamespaceRule> default_namespace_rule() const { return m_default_namespace_rule; }
|
||||
GC::Ptr<CSSNamespaceRule> default_namespace_rule() const { return m_default_namespace_rule; }
|
||||
|
||||
Optional<FlyString> namespace_uri(StringView namespace_prefix) const;
|
||||
|
||||
Vector<JS::NonnullGCPtr<CSSImportRule>> const& import_rules() const { return m_import_rules; }
|
||||
Vector<GC::Ref<CSSImportRule>> const& import_rules() const { return m_import_rules; }
|
||||
|
||||
Optional<URL::URL> base_url() const { return m_base_url; }
|
||||
void set_base_url(Optional<URL::URL> base_url) { m_base_url = move(base_url); }
|
||||
|
||||
bool constructed() const { return m_constructed; }
|
||||
|
||||
JS::GCPtr<DOM::Document const> constructor_document() const { return m_constructor_document; }
|
||||
void set_constructor_document(JS::GCPtr<DOM::Document const> constructor_document) { m_constructor_document = constructor_document; }
|
||||
GC::Ptr<DOM::Document const> constructor_document() const { return m_constructor_document; }
|
||||
void set_constructor_document(GC::Ptr<DOM::Document const> constructor_document) { m_constructor_document = constructor_document; }
|
||||
|
||||
bool disallow_modification() const { return m_disallow_modification; }
|
||||
|
||||
|
@ -104,16 +104,16 @@ private:
|
|||
|
||||
Optional<String> m_source_text;
|
||||
|
||||
JS::GCPtr<CSSRuleList> m_rules;
|
||||
JS::GCPtr<CSSNamespaceRule> m_default_namespace_rule;
|
||||
HashMap<FlyString, JS::GCPtr<CSSNamespaceRule>> m_namespace_rules;
|
||||
Vector<JS::NonnullGCPtr<CSSImportRule>> m_import_rules;
|
||||
GC::Ptr<CSSRuleList> m_rules;
|
||||
GC::Ptr<CSSNamespaceRule> m_default_namespace_rule;
|
||||
HashMap<FlyString, GC::Ptr<CSSNamespaceRule>> m_namespace_rules;
|
||||
Vector<GC::Ref<CSSImportRule>> m_import_rules;
|
||||
|
||||
JS::GCPtr<StyleSheetList> m_style_sheet_list;
|
||||
JS::GCPtr<CSSRule> m_owner_css_rule;
|
||||
GC::Ptr<StyleSheetList> m_style_sheet_list;
|
||||
GC::Ptr<CSSRule> m_owner_css_rule;
|
||||
|
||||
Optional<URL::URL> m_base_url;
|
||||
JS::GCPtr<DOM::Document const> m_constructor_document;
|
||||
GC::Ptr<DOM::Document const> m_constructor_document;
|
||||
bool m_constructed { false };
|
||||
bool m_disallow_modification { false };
|
||||
Optional<bool> m_did_match;
|
||||
|
|
|
@ -11,9 +11,9 @@
|
|||
|
||||
namespace Web::CSS {
|
||||
|
||||
JS_DEFINE_ALLOCATOR(CSSSupportsRule);
|
||||
GC_DEFINE_ALLOCATOR(CSSSupportsRule);
|
||||
|
||||
JS::NonnullGCPtr<CSSSupportsRule> CSSSupportsRule::create(JS::Realm& realm, NonnullRefPtr<Supports>&& supports, CSSRuleList& rules)
|
||||
GC::Ref<CSSSupportsRule> CSSSupportsRule::create(JS::Realm& realm, NonnullRefPtr<Supports>&& supports, CSSRuleList& rules)
|
||||
{
|
||||
return realm.create<CSSSupportsRule>(realm, move(supports), rules);
|
||||
}
|
||||
|
|
|
@ -17,10 +17,10 @@ namespace Web::CSS {
|
|||
// https://www.w3.org/TR/css-conditional-3/#the-csssupportsrule-interface
|
||||
class CSSSupportsRule final : public CSSConditionRule {
|
||||
WEB_PLATFORM_OBJECT(CSSSupportsRule, CSSConditionRule);
|
||||
JS_DECLARE_ALLOCATOR(CSSSupportsRule);
|
||||
GC_DECLARE_ALLOCATOR(CSSSupportsRule);
|
||||
|
||||
public:
|
||||
static JS::NonnullGCPtr<CSSSupportsRule> create(JS::Realm&, NonnullRefPtr<Supports>&&, CSSRuleList&);
|
||||
static GC::Ref<CSSSupportsRule> create(JS::Realm&, NonnullRefPtr<Supports>&&, CSSRuleList&);
|
||||
|
||||
virtual ~CSSSupportsRule() = default;
|
||||
|
||||
|
|
|
@ -17,9 +17,9 @@
|
|||
|
||||
namespace Web::CSS {
|
||||
|
||||
JS_DEFINE_ALLOCATOR(CSSTransition);
|
||||
GC_DEFINE_ALLOCATOR(CSSTransition);
|
||||
|
||||
JS::NonnullGCPtr<CSSTransition> CSSTransition::start_a_transition(DOM::Element& element, PropertyID property_id, size_t transition_generation,
|
||||
GC::Ref<CSSTransition> CSSTransition::start_a_transition(DOM::Element& element, PropertyID property_id, size_t transition_generation,
|
||||
double start_time, double end_time, NonnullRefPtr<CSSStyleValue const> start_value, NonnullRefPtr<CSSStyleValue const> end_value,
|
||||
NonnullRefPtr<CSSStyleValue const> reversing_adjusted_start_value, double reversing_shortening_factor)
|
||||
{
|
||||
|
@ -32,9 +32,9 @@ Animations::AnimationClass CSSTransition::animation_class() const
|
|||
return Animations::AnimationClass::CSSTransition;
|
||||
}
|
||||
|
||||
Optional<int> CSSTransition::class_specific_composite_order(JS::NonnullGCPtr<Animations::Animation> other_animation) const
|
||||
Optional<int> CSSTransition::class_specific_composite_order(GC::Ref<Animations::Animation> other_animation) const
|
||||
{
|
||||
auto other = JS::NonnullGCPtr { verify_cast<CSSTransition>(*other_animation) };
|
||||
auto other = GC::Ref { verify_cast<CSSTransition>(*other_animation) };
|
||||
|
||||
// Within the set of CSS Transitions, two animations A and B are sorted in composite order (first to last) as
|
||||
// follows:
|
||||
|
|
|
@ -17,17 +17,17 @@ namespace Web::CSS {
|
|||
|
||||
class CSSTransition : public Animations::Animation {
|
||||
WEB_PLATFORM_OBJECT(CSSTransition, Animations::Animation);
|
||||
JS_DECLARE_ALLOCATOR(CSSTransition);
|
||||
GC_DECLARE_ALLOCATOR(CSSTransition);
|
||||
|
||||
public:
|
||||
static JS::NonnullGCPtr<CSSTransition> start_a_transition(DOM::Element&, PropertyID, size_t transition_generation,
|
||||
static GC::Ref<CSSTransition> start_a_transition(DOM::Element&, PropertyID, size_t transition_generation,
|
||||
double start_time, double end_time, NonnullRefPtr<CSSStyleValue const> start_value, NonnullRefPtr<CSSStyleValue const> end_value,
|
||||
NonnullRefPtr<CSSStyleValue const> reversing_adjusted_start_value, double reversing_shortening_factor);
|
||||
|
||||
StringView transition_property() const { return string_from_property_id(m_transition_property); }
|
||||
|
||||
virtual Animations::AnimationClass animation_class() const override;
|
||||
virtual Optional<int> class_specific_composite_order(JS::NonnullGCPtr<Animations::Animation> other) const override;
|
||||
virtual Optional<int> class_specific_composite_order(GC::Ref<Animations::Animation> other) const override;
|
||||
|
||||
double transition_start_time() const { return m_start_time; }
|
||||
double transition_end_time() const { return m_end_time; }
|
||||
|
@ -72,9 +72,9 @@ private:
|
|||
// https://drafts.csswg.org/css-transitions/#transition-reversing-shortening-factor
|
||||
double m_reversing_shortening_factor;
|
||||
|
||||
JS::NonnullGCPtr<Animations::KeyframeEffect> m_keyframe_effect;
|
||||
GC::Ref<Animations::KeyframeEffect> m_keyframe_effect;
|
||||
|
||||
JS::GCPtr<CSS::CSSStyleDeclaration const> m_cached_declaration;
|
||||
GC::Ptr<CSS::CSSStyleDeclaration const> m_cached_declaration;
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -5,10 +5,10 @@
|
|||
*/
|
||||
|
||||
#include <LibCore/Promise.h>
|
||||
#include <LibGC/Heap.h>
|
||||
#include <LibGfx/Font/Typeface.h>
|
||||
#include <LibGfx/Font/WOFF/Loader.h>
|
||||
#include <LibGfx/Font/WOFF2/Loader.h>
|
||||
#include <LibJS/Heap/Heap.h>
|
||||
#include <LibJS/Runtime/ArrayBuffer.h>
|
||||
#include <LibJS/Runtime/Realm.h>
|
||||
#include <LibWeb/Bindings/FontFacePrototype.h>
|
||||
|
@ -31,7 +31,7 @@ static NonnullRefPtr<Core::Promise<NonnullRefPtr<Gfx::Typeface>>> load_vector_fo
|
|||
|
||||
// FIXME: 'Asynchronously' shouldn't mean 'later on the main thread'.
|
||||
// Can we defer this to a background thread?
|
||||
Platform::EventLoopPlugin::the().deferred_invoke(JS::create_heap_function(realm.heap(), [&data, promise] {
|
||||
Platform::EventLoopPlugin::the().deferred_invoke(GC::create_function(realm.heap(), [&data, promise] {
|
||||
// FIXME: This should be de-duplicated with StyleComputer::FontLoader::try_load_font
|
||||
// We don't have the luxury of knowing the MIME type, so we have to try all formats.
|
||||
auto ttf = Gfx::Typeface::try_load_from_externally_owned_memory(data);
|
||||
|
@ -55,7 +55,7 @@ static NonnullRefPtr<Core::Promise<NonnullRefPtr<Gfx::Typeface>>> load_vector_fo
|
|||
return promise;
|
||||
}
|
||||
|
||||
JS_DEFINE_ALLOCATOR(FontFace);
|
||||
GC_DEFINE_ALLOCATOR(FontFace);
|
||||
|
||||
template<CSS::PropertyID PropertyID>
|
||||
RefPtr<CSSStyleValue const> parse_property_string(JS::Realm& realm, StringView value)
|
||||
|
@ -65,7 +65,7 @@ RefPtr<CSSStyleValue const> parse_property_string(JS::Realm& realm, StringView v
|
|||
}
|
||||
|
||||
// https://drafts.csswg.org/css-font-loading/#font-face-constructor
|
||||
JS::NonnullGCPtr<FontFace> FontFace::construct_impl(JS::Realm& realm, String family, FontFaceSource source, FontFaceDescriptors const& descriptors)
|
||||
GC::Ref<FontFace> FontFace::construct_impl(JS::Realm& realm, String family, FontFaceSource source, FontFaceDescriptors const& descriptors)
|
||||
{
|
||||
auto& vm = realm.vm();
|
||||
auto base_url = HTML::relevant_settings_object(realm.global_object()).api_base_url();
|
||||
|
@ -93,7 +93,7 @@ JS::NonnullGCPtr<FontFace> FontFace::construct_impl(JS::Realm& realm, String fam
|
|||
if (sources.is_empty())
|
||||
WebIDL::reject_promise(realm, promise, WebIDL::SyntaxError::create(realm, "FontFace constructor: Invalid source string"_string));
|
||||
} else {
|
||||
auto buffer_source = source.get<JS::Handle<WebIDL::BufferSource>>();
|
||||
auto buffer_source = source.get<GC::Root<WebIDL::BufferSource>>();
|
||||
auto maybe_buffer = WebIDL::get_buffer_source_copy(buffer_source->raw_object());
|
||||
if (maybe_buffer.is_error()) {
|
||||
VERIFY(maybe_buffer.error().code() == ENOMEM);
|
||||
|
@ -118,7 +118,7 @@ JS::NonnullGCPtr<FontFace> FontFace::construct_impl(JS::Realm& realm, String fam
|
|||
if (font->m_binary_data.is_empty())
|
||||
return font;
|
||||
|
||||
HTML::queue_global_task(HTML::Task::Source::FontLoading, HTML::relevant_global_object(*font), JS::create_heap_function(vm.heap(), [&realm, font] {
|
||||
HTML::queue_global_task(HTML::Task::Source::FontLoading, HTML::relevant_global_object(*font), GC::create_function(vm.heap(), [&realm, font] {
|
||||
// 1. Set font face’s status attribute to "loading".
|
||||
font->m_status = Bindings::FontFaceLoadStatus::Loading;
|
||||
|
||||
|
@ -128,8 +128,8 @@ JS::NonnullGCPtr<FontFace> FontFace::construct_impl(JS::Realm& realm, String fam
|
|||
// When this is completed, successfully or not, queue a task to run the following steps synchronously:
|
||||
font->m_font_load_promise = load_vector_font(realm, font->m_binary_data);
|
||||
|
||||
font->m_font_load_promise->when_resolved([font = JS::make_handle(font)](auto const& vector_font) -> ErrorOr<void> {
|
||||
HTML::queue_global_task(HTML::Task::Source::FontLoading, HTML::relevant_global_object(*font), JS::create_heap_function(font->heap(), [font = JS::NonnullGCPtr(*font), vector_font] {
|
||||
font->m_font_load_promise->when_resolved([font = GC::make_root(font)](auto const& vector_font) -> ErrorOr<void> {
|
||||
HTML::queue_global_task(HTML::Task::Source::FontLoading, HTML::relevant_global_object(*font), GC::create_function(font->heap(), [font = GC::Ref(*font), vector_font] {
|
||||
HTML::TemporaryExecutionContext context(font->realm(), HTML::TemporaryExecutionContext::CallbacksEnabled::Yes);
|
||||
// 1. If the load was successful, font face now represents the parsed font;
|
||||
// fulfill font face’s [[FontStatusPromise]] with font face, and set its status attribute to "loaded".
|
||||
|
@ -145,8 +145,8 @@ JS::NonnullGCPtr<FontFace> FontFace::construct_impl(JS::Realm& realm, String fam
|
|||
}));
|
||||
return {};
|
||||
});
|
||||
font->m_font_load_promise->when_rejected([font = JS::make_handle(font)](auto const& error) {
|
||||
HTML::queue_global_task(HTML::Task::Source::FontLoading, HTML::relevant_global_object(*font), JS::create_heap_function(font->heap(), [font = JS::NonnullGCPtr(*font), error = Error::copy(error)] {
|
||||
font->m_font_load_promise->when_rejected([font = GC::make_root(font)](auto const& error) {
|
||||
HTML::queue_global_task(HTML::Task::Source::FontLoading, HTML::relevant_global_object(*font), GC::create_function(font->heap(), [font = GC::Ref(*font), error = Error::copy(error)] {
|
||||
HTML::TemporaryExecutionContext context(font->realm(), HTML::TemporaryExecutionContext::CallbacksEnabled::Yes);
|
||||
// 2. Otherwise, reject font face’s [[FontStatusPromise]] with a DOMException named "SyntaxError"
|
||||
// and set font face’s status attribute to "error".
|
||||
|
@ -163,7 +163,7 @@ JS::NonnullGCPtr<FontFace> FontFace::construct_impl(JS::Realm& realm, String fam
|
|||
return font;
|
||||
}
|
||||
|
||||
FontFace::FontFace(JS::Realm& realm, JS::NonnullGCPtr<WebIDL::Promise> font_status_promise, Vector<ParsedFontFace::Source> urls, ByteBuffer data, String font_family, FontFaceDescriptors const& descriptors)
|
||||
FontFace::FontFace(JS::Realm& realm, GC::Ref<WebIDL::Promise> font_status_promise, Vector<ParsedFontFace::Source> urls, ByteBuffer data, String font_family, FontFaceDescriptors const& descriptors)
|
||||
: Bindings::PlatformObject(realm)
|
||||
, m_font_status_promise(font_status_promise)
|
||||
, m_urls(move(urls))
|
||||
|
@ -205,7 +205,7 @@ void FontFace::visit_edges(JS::Cell::Visitor& visitor)
|
|||
visitor.visit(m_font_status_promise);
|
||||
}
|
||||
|
||||
JS::NonnullGCPtr<WebIDL::Promise> FontFace::loaded() const
|
||||
GC::Ref<WebIDL::Promise> FontFace::loaded() const
|
||||
{
|
||||
return m_font_status_promise;
|
||||
}
|
||||
|
@ -320,7 +320,7 @@ WebIDL::ExceptionOr<void> FontFace::set_line_gap_override(String const&)
|
|||
}
|
||||
|
||||
// https://drafts.csswg.org/css-font-loading/#dom-fontface-load
|
||||
JS::NonnullGCPtr<WebIDL::Promise> FontFace::load()
|
||||
GC::Ref<WebIDL::Promise> FontFace::load()
|
||||
{
|
||||
// 1. Let font face be the FontFace object on which this method was called.
|
||||
auto& font_face = *this;
|
||||
|
@ -349,13 +349,13 @@ void FontFace::load_font_source()
|
|||
// and continue executing the rest of this algorithm asynchronously.
|
||||
m_status = Bindings::FontFaceLoadStatus::Loading;
|
||||
|
||||
Web::Platform::EventLoopPlugin::the().deferred_invoke(JS::create_heap_function(heap(), [font = JS::make_handle(this)] {
|
||||
Web::Platform::EventLoopPlugin::the().deferred_invoke(GC::create_function(heap(), [font = GC::make_root(this)] {
|
||||
// 4. Using the value of font face’s [[Urls]] slot, attempt to load a font as defined in [CSS-FONTS-3],
|
||||
// as if it was the value of a @font-face rule’s src descriptor.
|
||||
|
||||
// 5. When the load operation completes, successfully or not, queue a task to run the following steps synchronously:
|
||||
auto on_error = [font] {
|
||||
HTML::queue_global_task(HTML::Task::Source::FontLoading, HTML::relevant_global_object(*font), JS::create_heap_function(font->heap(), [font = JS::NonnullGCPtr(*font)] {
|
||||
HTML::queue_global_task(HTML::Task::Source::FontLoading, HTML::relevant_global_object(*font), GC::create_function(font->heap(), [font = GC::Ref(*font)] {
|
||||
HTML::TemporaryExecutionContext context(font->realm(), HTML::TemporaryExecutionContext::CallbacksEnabled::Yes);
|
||||
|
||||
// 1. If the attempt to load fails, reject font face’s [[FontStatusPromise]] with a DOMException whose name
|
||||
|
@ -369,7 +369,7 @@ void FontFace::load_font_source()
|
|||
|
||||
auto on_load = [font](FontLoader const& loader) {
|
||||
// FIXME: We are assuming that the font loader will live as long as the document! This is an unsafe capture
|
||||
HTML::queue_global_task(HTML::Task::Source::FontLoading, HTML::relevant_global_object(*font), JS::create_heap_function(font->heap(), [font = JS::NonnullGCPtr(*font), &loader] {
|
||||
HTML::queue_global_task(HTML::Task::Source::FontLoading, HTML::relevant_global_object(*font), GC::create_function(font->heap(), [font = GC::Ref(*font), &loader] {
|
||||
HTML::TemporaryExecutionContext context(font->realm(), HTML::TemporaryExecutionContext::CallbacksEnabled::Yes);
|
||||
|
||||
// 2. Otherwise, font face now represents the loaded font; fulfill font face’s [[FontStatusPromise]] with font face
|
||||
|
|
|
@ -29,12 +29,12 @@ struct FontFaceDescriptors {
|
|||
|
||||
class FontFace final : public Bindings::PlatformObject {
|
||||
WEB_PLATFORM_OBJECT(FontFace, Bindings::PlatformObject);
|
||||
JS_DECLARE_ALLOCATOR(FontFace);
|
||||
GC_DECLARE_ALLOCATOR(FontFace);
|
||||
|
||||
public:
|
||||
using FontFaceSource = Variant<String, JS::Handle<WebIDL::BufferSource>>;
|
||||
using FontFaceSource = Variant<String, GC::Root<WebIDL::BufferSource>>;
|
||||
|
||||
[[nodiscard]] static JS::NonnullGCPtr<FontFace> construct_impl(JS::Realm&, String family, FontFaceSource source, FontFaceDescriptors const& descriptors);
|
||||
[[nodiscard]] static GC::Ref<FontFace> construct_impl(JS::Realm&, String family, FontFaceSource source, FontFaceDescriptors const& descriptors);
|
||||
virtual ~FontFace() override;
|
||||
|
||||
String family() const { return m_family; }
|
||||
|
@ -74,15 +74,15 @@ public:
|
|||
|
||||
Bindings::FontFaceLoadStatus status() const { return m_status; }
|
||||
|
||||
JS::NonnullGCPtr<WebIDL::Promise> load();
|
||||
JS::NonnullGCPtr<WebIDL::Promise> loaded() const;
|
||||
GC::Ref<WebIDL::Promise> load();
|
||||
GC::Ref<WebIDL::Promise> loaded() const;
|
||||
|
||||
void load_font_source();
|
||||
|
||||
JS::NonnullGCPtr<WebIDL::Promise> font_status_promise() { return m_font_status_promise; }
|
||||
GC::Ref<WebIDL::Promise> font_status_promise() { return m_font_status_promise; }
|
||||
|
||||
private:
|
||||
FontFace(JS::Realm&, JS::NonnullGCPtr<WebIDL::Promise> font_status_promise, Vector<ParsedFontFace::Source> urls, ByteBuffer data, String family, FontFaceDescriptors const& descriptors);
|
||||
FontFace(JS::Realm&, GC::Ref<WebIDL::Promise> font_status_promise, Vector<ParsedFontFace::Source> urls, ByteBuffer data, String family, FontFaceDescriptors const& descriptors);
|
||||
|
||||
virtual void initialize(JS::Realm&) override;
|
||||
virtual void visit_edges(Visitor&) override;
|
||||
|
@ -104,9 +104,9 @@ private:
|
|||
// https://drafts.csswg.org/css-font-loading/#dom-fontface-status
|
||||
Bindings::FontFaceLoadStatus m_status { Bindings::FontFaceLoadStatus::Unloaded };
|
||||
|
||||
JS::NonnullGCPtr<WebIDL::Promise> m_font_status_promise; // [[FontStatusPromise]]
|
||||
Vector<ParsedFontFace::Source> m_urls; // [[Urls]]
|
||||
ByteBuffer m_binary_data; // [[Data]]
|
||||
GC::Ref<WebIDL::Promise> m_font_status_promise; // [[FontStatusPromise]]
|
||||
Vector<ParsedFontFace::Source> m_urls; // [[Urls]]
|
||||
ByteBuffer m_binary_data; // [[Data]]
|
||||
|
||||
RefPtr<Gfx::Typeface> m_parsed_font;
|
||||
RefPtr<Core::Promise<NonnullRefPtr<Gfx::Typeface>>> m_font_load_promise;
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#include <LibJS/Heap/Heap.h>
|
||||
#include <LibGC/Heap.h>
|
||||
#include <LibJS/Runtime/Realm.h>
|
||||
#include <LibJS/Runtime/Set.h>
|
||||
#include <LibWeb/Bindings/ExceptionOrUtils.h>
|
||||
|
@ -25,10 +25,10 @@
|
|||
|
||||
namespace Web::CSS {
|
||||
|
||||
JS_DEFINE_ALLOCATOR(FontFaceSet);
|
||||
GC_DEFINE_ALLOCATOR(FontFaceSet);
|
||||
|
||||
// https://drafts.csswg.org/css-font-loading/#dom-fontfaceset-fontfaceset
|
||||
JS::NonnullGCPtr<FontFaceSet> FontFaceSet::construct_impl(JS::Realm& realm, Vector<JS::Handle<FontFace>> const& initial_faces)
|
||||
GC::Ref<FontFaceSet> FontFaceSet::construct_impl(JS::Realm& realm, Vector<GC::Root<FontFace>> const& initial_faces)
|
||||
{
|
||||
auto ready_promise = WebIDL::create_promise(realm);
|
||||
auto set_entries = JS::Set::create(realm);
|
||||
|
@ -40,12 +40,12 @@ JS::NonnullGCPtr<FontFaceSet> FontFaceSet::construct_impl(JS::Realm& realm, Vect
|
|||
return realm.create<FontFaceSet>(realm, ready_promise, set_entries);
|
||||
}
|
||||
|
||||
JS::NonnullGCPtr<FontFaceSet> FontFaceSet::create(JS::Realm& realm)
|
||||
GC::Ref<FontFaceSet> FontFaceSet::create(JS::Realm& realm)
|
||||
{
|
||||
return construct_impl(realm, {});
|
||||
}
|
||||
|
||||
FontFaceSet::FontFaceSet(JS::Realm& realm, JS::NonnullGCPtr<WebIDL::Promise> ready_promise, JS::NonnullGCPtr<JS::Set> set_entries)
|
||||
FontFaceSet::FontFaceSet(JS::Realm& realm, GC::Ref<WebIDL::Promise> ready_promise, GC::Ref<JS::Set> set_entries)
|
||||
: DOM::EventTarget(realm)
|
||||
, m_set_entries(set_entries)
|
||||
, m_ready_promise(ready_promise)
|
||||
|
@ -71,12 +71,12 @@ void FontFaceSet::visit_edges(Cell::Visitor& visitor)
|
|||
}
|
||||
|
||||
// https://drafts.csswg.org/css-font-loading/#dom-fontfaceset-add
|
||||
WebIDL::ExceptionOr<JS::NonnullGCPtr<FontFaceSet>>
|
||||
FontFaceSet::add(JS::Handle<FontFace> face)
|
||||
WebIDL::ExceptionOr<GC::Ref<FontFaceSet>>
|
||||
FontFaceSet::add(GC::Root<FontFace> face)
|
||||
{
|
||||
// 1. If font is already in the FontFaceSet’s set entries, skip to the last step of this algorithm immediately.
|
||||
if (m_set_entries->set_has(face))
|
||||
return JS::NonnullGCPtr<FontFaceSet>(*this);
|
||||
return GC::Ref<FontFaceSet>(*this);
|
||||
|
||||
// 2. If font is CSS-connected, throw an InvalidModificationError exception and exit this algorithm immediately.
|
||||
if (face->is_css_connected()) {
|
||||
|
@ -99,11 +99,11 @@ FontFaceSet::add(JS::Handle<FontFace> face)
|
|||
}
|
||||
|
||||
// 5. Return the FontFaceSet.
|
||||
return JS::NonnullGCPtr<FontFaceSet>(*this);
|
||||
return GC::Ref<FontFaceSet>(*this);
|
||||
}
|
||||
|
||||
// https://drafts.csswg.org/css-font-loading/#dom-fontfaceset-delete
|
||||
bool FontFaceSet::delete_(JS::Handle<FontFace> face)
|
||||
bool FontFaceSet::delete_(GC::Root<FontFace> face)
|
||||
{
|
||||
// 1. If font is CSS-connected, return false and exit this algorithm immediately.
|
||||
if (face->is_css_connected()) {
|
||||
|
@ -171,7 +171,7 @@ WebIDL::CallbackType* FontFaceSet::onloadingerror()
|
|||
}
|
||||
|
||||
// https://drafts.csswg.org/css-font-loading/#find-the-matching-font-faces
|
||||
static WebIDL::ExceptionOr<JS::NonnullGCPtr<JS::Set>> find_matching_font_faces(JS::Realm& realm, FontFaceSet& font_face_set, String const& font, String const&)
|
||||
static WebIDL::ExceptionOr<GC::Ref<JS::Set>> find_matching_font_faces(JS::Realm& realm, FontFaceSet& font_face_set, String const& font, String const&)
|
||||
{
|
||||
// 1. Parse font using the CSS value syntax of the font property. If a syntax error occurs, return a syntax error.
|
||||
auto parser = CSS::Parser::Parser::create(CSS::Parser::ParsingContext(realm), font);
|
||||
|
@ -227,15 +227,15 @@ static WebIDL::ExceptionOr<JS::NonnullGCPtr<JS::Set>> find_matching_font_faces(J
|
|||
}
|
||||
|
||||
// https://drafts.csswg.org/css-font-loading/#dom-fontfaceset-load
|
||||
JS::ThrowCompletionOr<JS::NonnullGCPtr<WebIDL::Promise>> FontFaceSet::load(String const& font, String const& text)
|
||||
JS::ThrowCompletionOr<GC::Ref<WebIDL::Promise>> FontFaceSet::load(String const& font, String const& text)
|
||||
{
|
||||
auto& realm = this->realm();
|
||||
|
||||
// 1. Let font face set be the FontFaceSet object this method was called on. Let promise be a newly-created promise object.
|
||||
JS::NonnullGCPtr font_face_set = *this;
|
||||
GC::Ref font_face_set = *this;
|
||||
auto promise = WebIDL::create_promise(realm);
|
||||
|
||||
Platform::EventLoopPlugin::the().deferred_invoke(JS::create_heap_function(realm.heap(), [&realm, font_face_set, promise, font, text]() mutable {
|
||||
Platform::EventLoopPlugin::the().deferred_invoke(GC::create_function(realm.heap(), [&realm, font_face_set, promise, font, text]() mutable {
|
||||
// 3. Find the matching font faces from font face set using the font and text arguments passed to the function,
|
||||
// and let font face list be the return value (ignoring the found faces flag). If a syntax error was returned,
|
||||
// reject promise with a SyntaxError exception and terminate these steps.
|
||||
|
@ -249,8 +249,8 @@ JS::ThrowCompletionOr<JS::NonnullGCPtr<WebIDL::Promise>> FontFaceSet::load(Strin
|
|||
auto matched_font_faces = result.release_value();
|
||||
|
||||
// 4. Queue a task to run the following steps synchronously:
|
||||
HTML::queue_a_task(HTML::Task::Source::FontLoading, nullptr, nullptr, JS::create_heap_function(realm.heap(), [&realm, promise, matched_font_faces] {
|
||||
JS::MarkedVector<JS::NonnullGCPtr<WebIDL::Promise>> promises(realm.heap());
|
||||
HTML::queue_a_task(HTML::Task::Source::FontLoading, nullptr, nullptr, GC::create_function(realm.heap(), [&realm, promise, matched_font_faces] {
|
||||
GC::MarkedVector<GC::Ref<WebIDL::Promise>> promises(realm.heap());
|
||||
|
||||
// 1. For all of the font faces in the font face list, call their load() method.
|
||||
for (auto font_face_value : *matched_font_faces) {
|
||||
|
@ -282,7 +282,7 @@ JS::ThrowCompletionOr<JS::NonnullGCPtr<WebIDL::Promise>> FontFaceSet::load(Strin
|
|||
}
|
||||
|
||||
// https://drafts.csswg.org/css-font-loading/#font-face-set-ready
|
||||
JS::NonnullGCPtr<WebIDL::Promise> FontFaceSet::ready() const
|
||||
GC::Ref<WebIDL::Promise> FontFaceSet::ready() const
|
||||
{
|
||||
return m_ready_promise;
|
||||
}
|
||||
|
|
|
@ -18,17 +18,17 @@ namespace Web::CSS {
|
|||
|
||||
class FontFaceSet final : public DOM::EventTarget {
|
||||
WEB_PLATFORM_OBJECT(FontFaceSet, DOM::EventTarget);
|
||||
JS_DECLARE_ALLOCATOR(FontFaceSet);
|
||||
GC_DECLARE_ALLOCATOR(FontFaceSet);
|
||||
|
||||
public:
|
||||
[[nodiscard]] static JS::NonnullGCPtr<FontFaceSet> construct_impl(JS::Realm&, Vector<JS::Handle<FontFace>> const& initial_faces);
|
||||
[[nodiscard]] static JS::NonnullGCPtr<FontFaceSet> create(JS::Realm&);
|
||||
[[nodiscard]] static GC::Ref<FontFaceSet> construct_impl(JS::Realm&, Vector<GC::Root<FontFace>> const& initial_faces);
|
||||
[[nodiscard]] static GC::Ref<FontFaceSet> create(JS::Realm&);
|
||||
virtual ~FontFaceSet() override = default;
|
||||
|
||||
JS::NonnullGCPtr<JS::Set> set_entries() const { return m_set_entries; }
|
||||
GC::Ref<JS::Set> set_entries() const { return m_set_entries; }
|
||||
|
||||
WebIDL::ExceptionOr<JS::NonnullGCPtr<FontFaceSet>> add(JS::Handle<FontFace>);
|
||||
bool delete_(JS::Handle<FontFace>);
|
||||
WebIDL::ExceptionOr<GC::Ref<FontFaceSet>> add(GC::Root<FontFace>);
|
||||
bool delete_(GC::Root<FontFace>);
|
||||
void clear();
|
||||
|
||||
void set_onloading(WebIDL::CallbackType*);
|
||||
|
@ -38,25 +38,25 @@ public:
|
|||
void set_onloadingerror(WebIDL::CallbackType*);
|
||||
WebIDL::CallbackType* onloadingerror();
|
||||
|
||||
JS::ThrowCompletionOr<JS::NonnullGCPtr<WebIDL::Promise>> load(String const& font, String const& text);
|
||||
JS::ThrowCompletionOr<GC::Ref<WebIDL::Promise>> load(String const& font, String const& text);
|
||||
|
||||
JS::NonnullGCPtr<WebIDL::Promise> ready() const;
|
||||
GC::Ref<WebIDL::Promise> ready() const;
|
||||
Bindings::FontFaceSetLoadStatus status() const { return m_status; }
|
||||
|
||||
void resolve_ready_promise();
|
||||
|
||||
private:
|
||||
FontFaceSet(JS::Realm&, JS::NonnullGCPtr<WebIDL::Promise> ready_promise, JS::NonnullGCPtr<JS::Set> set_entries);
|
||||
FontFaceSet(JS::Realm&, GC::Ref<WebIDL::Promise> ready_promise, GC::Ref<JS::Set> set_entries);
|
||||
|
||||
virtual void initialize(JS::Realm&) override;
|
||||
virtual void visit_edges(Cell::Visitor&) override;
|
||||
|
||||
JS::NonnullGCPtr<JS::Set> m_set_entries;
|
||||
JS::NonnullGCPtr<WebIDL::Promise> m_ready_promise; // [[ReadyPromise]]
|
||||
GC::Ref<JS::Set> m_set_entries;
|
||||
GC::Ref<WebIDL::Promise> m_ready_promise; // [[ReadyPromise]]
|
||||
|
||||
Vector<JS::NonnullGCPtr<FontFace>> m_loading_fonts {}; // [[LoadingFonts]]
|
||||
Vector<JS::NonnullGCPtr<FontFace>> m_loaded_fonts {}; // [[LoadedFonts]]
|
||||
Vector<JS::NonnullGCPtr<FontFace>> m_failed_fonts {}; // [[FailedFonts]]
|
||||
Vector<GC::Ref<FontFace>> m_loading_fonts {}; // [[LoadingFonts]]
|
||||
Vector<GC::Ref<FontFace>> m_loaded_fonts {}; // [[LoadedFonts]]
|
||||
Vector<GC::Ref<FontFace>> m_failed_fonts {}; // [[FailedFonts]]
|
||||
|
||||
Bindings::FontFaceSetLoadStatus m_status { Bindings::FontFaceSetLoadStatus::Loading };
|
||||
};
|
||||
|
|
|
@ -13,9 +13,9 @@
|
|||
|
||||
namespace Web::CSS {
|
||||
|
||||
JS_DEFINE_ALLOCATOR(MediaList);
|
||||
GC_DEFINE_ALLOCATOR(MediaList);
|
||||
|
||||
JS::NonnullGCPtr<MediaList> MediaList::create(JS::Realm& realm, Vector<NonnullRefPtr<MediaQuery>>&& media)
|
||||
GC::Ref<MediaList> MediaList::create(JS::Realm& realm, Vector<NonnullRefPtr<MediaQuery>>&& media)
|
||||
{
|
||||
return realm.create<MediaList>(realm, move(media));
|
||||
}
|
||||
|
|
|
@ -18,10 +18,10 @@ namespace Web::CSS {
|
|||
// https://www.w3.org/TR/cssom-1/#the-medialist-interface
|
||||
class MediaList final : public Bindings::PlatformObject {
|
||||
WEB_PLATFORM_OBJECT(MediaList, Bindings::PlatformObject);
|
||||
JS_DECLARE_ALLOCATOR(MediaList);
|
||||
GC_DECLARE_ALLOCATOR(MediaList);
|
||||
|
||||
public:
|
||||
[[nodiscard]] static JS::NonnullGCPtr<MediaList> create(JS::Realm&, Vector<NonnullRefPtr<MediaQuery>>&&);
|
||||
[[nodiscard]] static GC::Ref<MediaList> create(JS::Realm&, Vector<NonnullRefPtr<MediaQuery>>&&);
|
||||
virtual ~MediaList() override = default;
|
||||
|
||||
String media_text() const;
|
||||
|
|
|
@ -15,9 +15,9 @@
|
|||
|
||||
namespace Web::CSS {
|
||||
|
||||
JS_DEFINE_ALLOCATOR(MediaQueryList);
|
||||
GC_DEFINE_ALLOCATOR(MediaQueryList);
|
||||
|
||||
JS::NonnullGCPtr<MediaQueryList> MediaQueryList::create(DOM::Document& document, Vector<NonnullRefPtr<MediaQuery>>&& media)
|
||||
GC::Ref<MediaQueryList> MediaQueryList::create(DOM::Document& document, Vector<NonnullRefPtr<MediaQuery>>&& media)
|
||||
{
|
||||
return document.realm().create<MediaQueryList>(document, move(media));
|
||||
}
|
||||
|
@ -80,7 +80,7 @@ bool MediaQueryList::evaluate()
|
|||
}
|
||||
|
||||
// https://www.w3.org/TR/cssom-view/#dom-mediaquerylist-addlistener
|
||||
void MediaQueryList::add_listener(JS::GCPtr<DOM::IDLEventListener> listener)
|
||||
void MediaQueryList::add_listener(GC::Ptr<DOM::IDLEventListener> listener)
|
||||
{
|
||||
// 1. If listener is null, terminate these steps.
|
||||
if (!listener)
|
||||
|
@ -94,7 +94,7 @@ void MediaQueryList::add_listener(JS::GCPtr<DOM::IDLEventListener> listener)
|
|||
}
|
||||
|
||||
// https://www.w3.org/TR/cssom-view/#dom-mediaquerylist-removelistener
|
||||
void MediaQueryList::remove_listener(JS::GCPtr<DOM::IDLEventListener> listener)
|
||||
void MediaQueryList::remove_listener(GC::Ptr<DOM::IDLEventListener> listener)
|
||||
{
|
||||
// 1. Remove an event listener from the associated list of event listeners, whose type is change, callback is listener, and capture is false.
|
||||
// NOTE: While the spec doesn't technically use remove_event_listener and instead manipulates the list directly, every major engine uses remove_event_listener.
|
||||
|
|
|
@ -15,10 +15,10 @@ namespace Web::CSS {
|
|||
// 4.2. The MediaQueryList Interface, https://drafts.csswg.org/cssom-view/#the-mediaquerylist-interface
|
||||
class MediaQueryList final : public DOM::EventTarget {
|
||||
WEB_PLATFORM_OBJECT(MediaQueryList, DOM::EventTarget);
|
||||
JS_DECLARE_ALLOCATOR(MediaQueryList);
|
||||
GC_DECLARE_ALLOCATOR(MediaQueryList);
|
||||
|
||||
public:
|
||||
[[nodiscard]] static JS::NonnullGCPtr<MediaQueryList> create(DOM::Document&, Vector<NonnullRefPtr<MediaQuery>>&&);
|
||||
[[nodiscard]] static GC::Ref<MediaQueryList> create(DOM::Document&, Vector<NonnullRefPtr<MediaQuery>>&&);
|
||||
|
||||
virtual ~MediaQueryList() override = default;
|
||||
|
||||
|
@ -26,8 +26,8 @@ public:
|
|||
bool matches() const;
|
||||
bool evaluate();
|
||||
|
||||
void add_listener(JS::GCPtr<DOM::IDLEventListener>);
|
||||
void remove_listener(JS::GCPtr<DOM::IDLEventListener>);
|
||||
void add_listener(GC::Ptr<DOM::IDLEventListener>);
|
||||
void remove_listener(GC::Ptr<DOM::IDLEventListener>);
|
||||
|
||||
void set_onchange(WebIDL::CallbackType*);
|
||||
WebIDL::CallbackType* onchange();
|
||||
|
@ -38,7 +38,7 @@ private:
|
|||
virtual void initialize(JS::Realm&) override;
|
||||
virtual void visit_edges(Cell::Visitor&) override;
|
||||
|
||||
JS::NonnullGCPtr<DOM::Document> m_document;
|
||||
GC::Ref<DOM::Document> m_document;
|
||||
Vector<NonnullRefPtr<MediaQuery>> m_media;
|
||||
};
|
||||
|
||||
|
|
|
@ -10,9 +10,9 @@
|
|||
|
||||
namespace Web::CSS {
|
||||
|
||||
JS_DEFINE_ALLOCATOR(MediaQueryListEvent);
|
||||
GC_DEFINE_ALLOCATOR(MediaQueryListEvent);
|
||||
|
||||
JS::NonnullGCPtr<MediaQueryListEvent> MediaQueryListEvent::construct_impl(JS::Realm& realm, FlyString const& event_name, MediaQueryListEventInit const& event_init)
|
||||
GC::Ref<MediaQueryListEvent> MediaQueryListEvent::construct_impl(JS::Realm& realm, FlyString const& event_name, MediaQueryListEventInit const& event_init)
|
||||
{
|
||||
return realm.create<MediaQueryListEvent>(realm, event_name, event_init);
|
||||
}
|
||||
|
|
|
@ -18,10 +18,10 @@ struct MediaQueryListEventInit : public DOM::EventInit {
|
|||
|
||||
class MediaQueryListEvent final : public DOM::Event {
|
||||
WEB_PLATFORM_OBJECT(MediaQueryListEvent, DOM::Event);
|
||||
JS_DECLARE_ALLOCATOR(MediaQueryListEvent);
|
||||
GC_DECLARE_ALLOCATOR(MediaQueryListEvent);
|
||||
|
||||
public:
|
||||
[[nodiscard]] static JS::NonnullGCPtr<MediaQueryListEvent> construct_impl(JS::Realm&, FlyString const& event_name, MediaQueryListEventInit const& = {});
|
||||
[[nodiscard]] static GC::Ref<MediaQueryListEvent> construct_impl(JS::Realm&, FlyString const& event_name, MediaQueryListEventInit const& = {});
|
||||
|
||||
virtual ~MediaQueryListEvent() override;
|
||||
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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, it’s a parse error.
|
||||
|
|
|
@ -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&);
|
||||
|
|
|
@ -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 };
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -43,9 +43,9 @@
|
|||
|
||||
namespace Web::CSS {
|
||||
|
||||
JS_DEFINE_ALLOCATOR(ResolvedCSSStyleDeclaration);
|
||||
GC_DEFINE_ALLOCATOR(ResolvedCSSStyleDeclaration);
|
||||
|
||||
JS::NonnullGCPtr<ResolvedCSSStyleDeclaration> ResolvedCSSStyleDeclaration::create(DOM::Element& element, Optional<Selector::PseudoElement::Type> pseudo_element)
|
||||
GC::Ref<ResolvedCSSStyleDeclaration> ResolvedCSSStyleDeclaration::create(DOM::Element& element, Optional<Selector::PseudoElement::Type> pseudo_element)
|
||||
{
|
||||
return element.realm().create<ResolvedCSSStyleDeclaration>(element, move(pseudo_element));
|
||||
}
|
||||
|
|
|
@ -13,10 +13,10 @@ namespace Web::CSS {
|
|||
|
||||
class ResolvedCSSStyleDeclaration final : public CSSStyleDeclaration {
|
||||
WEB_PLATFORM_OBJECT(ResolvedCSSStyleDeclaration, CSSStyleDeclaration);
|
||||
JS_DECLARE_ALLOCATOR(ResolvedCSSStyleDeclaration);
|
||||
GC_DECLARE_ALLOCATOR(ResolvedCSSStyleDeclaration);
|
||||
|
||||
public:
|
||||
[[nodiscard]] static JS::NonnullGCPtr<ResolvedCSSStyleDeclaration> create(DOM::Element&, Optional<Selector::PseudoElement::Type> = {});
|
||||
[[nodiscard]] static GC::Ref<ResolvedCSSStyleDeclaration> create(DOM::Element&, Optional<Selector::PseudoElement::Type> = {});
|
||||
|
||||
virtual ~ResolvedCSSStyleDeclaration() override = default;
|
||||
|
||||
|
@ -39,7 +39,7 @@ private:
|
|||
|
||||
RefPtr<CSSStyleValue const> style_value_for_property(Layout::NodeWithStyle const&, PropertyID) const;
|
||||
|
||||
JS::NonnullGCPtr<DOM::Element> m_element;
|
||||
GC::Ref<DOM::Element> m_element;
|
||||
Optional<CSS::Selector::PseudoElement::Type> m_pseudo_element;
|
||||
};
|
||||
|
||||
|
|
|
@ -14,9 +14,9 @@
|
|||
|
||||
namespace Web::CSS {
|
||||
|
||||
JS_DEFINE_ALLOCATOR(Screen);
|
||||
GC_DEFINE_ALLOCATOR(Screen);
|
||||
|
||||
JS::NonnullGCPtr<Screen> Screen::create(HTML::Window& window)
|
||||
GC::Ref<Screen> Screen::create(HTML::Window& window)
|
||||
{
|
||||
return window.realm().create<Screen>(window);
|
||||
}
|
||||
|
@ -51,7 +51,7 @@ Gfx::IntRect Screen::screen_rect() const
|
|||
};
|
||||
}
|
||||
|
||||
JS::NonnullGCPtr<ScreenOrientation> Screen::orientation()
|
||||
GC::Ref<ScreenOrientation> Screen::orientation()
|
||||
{
|
||||
if (!m_orientation)
|
||||
m_orientation = ScreenOrientation::create(realm());
|
||||
|
@ -66,13 +66,13 @@ bool Screen::is_extended() const
|
|||
}
|
||||
|
||||
// https://w3c.github.io/window-management/#dom-screen-onchange
|
||||
void Screen::set_onchange(JS::GCPtr<WebIDL::CallbackType> event_handler)
|
||||
void Screen::set_onchange(GC::Ptr<WebIDL::CallbackType> event_handler)
|
||||
{
|
||||
set_event_handler_attribute(HTML::EventNames::change, event_handler);
|
||||
}
|
||||
|
||||
// https://w3c.github.io/window-management/#dom-screen-onchange
|
||||
JS::GCPtr<WebIDL::CallbackType> Screen::onchange()
|
||||
GC::Ptr<WebIDL::CallbackType> Screen::onchange()
|
||||
{
|
||||
return event_handler_attribute(HTML::EventNames::change);
|
||||
}
|
||||
|
|
|
@ -16,10 +16,10 @@ namespace Web::CSS {
|
|||
|
||||
class Screen final : public DOM::EventTarget {
|
||||
WEB_PLATFORM_OBJECT(Screen, DOM::EventTarget);
|
||||
JS_DECLARE_ALLOCATOR(Screen);
|
||||
GC_DECLARE_ALLOCATOR(Screen);
|
||||
|
||||
public:
|
||||
[[nodiscard]] static JS::NonnullGCPtr<Screen> create(HTML::Window&);
|
||||
[[nodiscard]] static GC::Ref<Screen> create(HTML::Window&);
|
||||
|
||||
i32 width() const { return screen_rect().width(); }
|
||||
i32 height() const { return screen_rect().height(); }
|
||||
|
@ -27,12 +27,12 @@ public:
|
|||
i32 avail_height() const { return screen_rect().height(); }
|
||||
u32 color_depth() const { return 24; }
|
||||
u32 pixel_depth() const { return 24; }
|
||||
JS::NonnullGCPtr<ScreenOrientation> orientation();
|
||||
GC::Ref<ScreenOrientation> orientation();
|
||||
|
||||
bool is_extended() const;
|
||||
|
||||
void set_onchange(JS::GCPtr<WebIDL::CallbackType> event_handler);
|
||||
JS::GCPtr<WebIDL::CallbackType> onchange();
|
||||
void set_onchange(GC::Ptr<WebIDL::CallbackType> event_handler);
|
||||
GC::Ptr<WebIDL::CallbackType> onchange();
|
||||
|
||||
private:
|
||||
explicit Screen(HTML::Window&);
|
||||
|
@ -44,8 +44,8 @@ private:
|
|||
|
||||
Gfx::IntRect screen_rect() const;
|
||||
|
||||
JS::NonnullGCPtr<HTML::Window> m_window;
|
||||
JS::GCPtr<ScreenOrientation> m_orientation;
|
||||
GC::Ref<HTML::Window> m_window;
|
||||
GC::Ptr<ScreenOrientation> m_orientation;
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
|
||||
namespace Web::CSS {
|
||||
|
||||
JS_DEFINE_ALLOCATOR(ScreenOrientation);
|
||||
GC_DEFINE_ALLOCATOR(ScreenOrientation);
|
||||
|
||||
ScreenOrientation::ScreenOrientation(JS::Realm& realm)
|
||||
: DOM::EventTarget(realm)
|
||||
|
@ -24,13 +24,13 @@ void ScreenOrientation::initialize(JS::Realm& realm)
|
|||
WEB_SET_PROTOTYPE_FOR_INTERFACE(ScreenOrientation);
|
||||
}
|
||||
|
||||
JS::NonnullGCPtr<ScreenOrientation> ScreenOrientation::create(JS::Realm& realm)
|
||||
GC::Ref<ScreenOrientation> ScreenOrientation::create(JS::Realm& realm)
|
||||
{
|
||||
return realm.create<ScreenOrientation>(realm);
|
||||
}
|
||||
|
||||
// https://w3c.github.io/screen-orientation/#lock-method
|
||||
WebIDL::ExceptionOr<JS::NonnullGCPtr<WebIDL::Promise>> ScreenOrientation::lock(Bindings::OrientationLockType)
|
||||
WebIDL::ExceptionOr<GC::Ref<WebIDL::Promise>> ScreenOrientation::lock(Bindings::OrientationLockType)
|
||||
{
|
||||
return WebIDL::NotSupportedError::create(realm(), "FIXME: ScreenOrientation::lock() is not implemented"_string);
|
||||
}
|
||||
|
@ -56,13 +56,13 @@ WebIDL::UnsignedShort ScreenOrientation::angle() const
|
|||
}
|
||||
|
||||
// https://w3c.github.io/screen-orientation/#onchange-event-handler-attribute
|
||||
void ScreenOrientation::set_onchange(JS::GCPtr<WebIDL::CallbackType> event_handler)
|
||||
void ScreenOrientation::set_onchange(GC::Ptr<WebIDL::CallbackType> event_handler)
|
||||
{
|
||||
set_event_handler_attribute(HTML::EventNames::change, event_handler);
|
||||
}
|
||||
|
||||
// https://w3c.github.io/screen-orientation/#onchange-event-handler-attribute
|
||||
JS::GCPtr<WebIDL::CallbackType> ScreenOrientation::onchange()
|
||||
GC::Ptr<WebIDL::CallbackType> ScreenOrientation::onchange()
|
||||
{
|
||||
return event_handler_attribute(HTML::EventNames::change);
|
||||
}
|
||||
|
|
|
@ -15,18 +15,18 @@ namespace Web::CSS {
|
|||
|
||||
class ScreenOrientation final : public DOM::EventTarget {
|
||||
WEB_PLATFORM_OBJECT(ScreenOrientation, DOM::EventTarget);
|
||||
JS_DECLARE_ALLOCATOR(ScreenOrientation);
|
||||
GC_DECLARE_ALLOCATOR(ScreenOrientation);
|
||||
|
||||
public:
|
||||
[[nodiscard]] static JS::NonnullGCPtr<ScreenOrientation> create(JS::Realm&);
|
||||
[[nodiscard]] static GC::Ref<ScreenOrientation> create(JS::Realm&);
|
||||
|
||||
WebIDL::ExceptionOr<JS::NonnullGCPtr<WebIDL::Promise>> lock(Bindings::OrientationLockType);
|
||||
WebIDL::ExceptionOr<GC::Ref<WebIDL::Promise>> lock(Bindings::OrientationLockType);
|
||||
void unlock();
|
||||
Bindings::OrientationType type() const;
|
||||
WebIDL::UnsignedShort angle() const;
|
||||
|
||||
void set_onchange(JS::GCPtr<WebIDL::CallbackType>);
|
||||
JS::GCPtr<WebIDL::CallbackType> onchange();
|
||||
void set_onchange(GC::Ptr<WebIDL::CallbackType>);
|
||||
GC::Ptr<WebIDL::CallbackType> onchange();
|
||||
|
||||
private:
|
||||
explicit ScreenOrientation(JS::Realm&);
|
||||
|
|
|
@ -35,12 +35,12 @@
|
|||
|
||||
namespace Web::SelectorEngine {
|
||||
|
||||
static inline bool matches(CSS::Selector const& selector, Optional<CSS::CSSStyleSheet const&> style_sheet_for_rule, int component_list_index, DOM::Element const& element, JS::GCPtr<DOM::Element const> shadow_host, JS::GCPtr<DOM::ParentNode const> scope, SelectorKind selector_kind, JS::GCPtr<DOM::Element const> anchor = nullptr);
|
||||
static inline bool matches(CSS::Selector const& selector, Optional<CSS::CSSStyleSheet const&> style_sheet_for_rule, int component_list_index, DOM::Element const& element, GC::Ptr<DOM::Element const> shadow_host, GC::Ptr<DOM::ParentNode const> scope, SelectorKind selector_kind, GC::Ptr<DOM::Element const> anchor = nullptr);
|
||||
|
||||
// Upward traversal for descendant (' ') and immediate child combinator ('>')
|
||||
// If we're starting inside a shadow tree, traversal stops at the nearest shadow host.
|
||||
// This is an implementation detail of the :host selector. Otherwise we would just traverse up to the document root.
|
||||
static inline JS::GCPtr<DOM::Node const> traverse_up(JS::GCPtr<DOM::Node const> node, JS::GCPtr<DOM::Element const> shadow_host)
|
||||
static inline GC::Ptr<DOM::Node const> traverse_up(GC::Ptr<DOM::Node const> node, GC::Ptr<DOM::Element const> shadow_host)
|
||||
{
|
||||
if (!node)
|
||||
return nullptr;
|
||||
|
@ -80,7 +80,7 @@ static inline bool matches_lang_pseudo_class(DOM::Element const& element, Vector
|
|||
}
|
||||
|
||||
// https://drafts.csswg.org/selectors-4/#relational
|
||||
static inline bool matches_relative_selector(CSS::Selector const& selector, size_t compound_index, Optional<CSS::CSSStyleSheet const&> style_sheet_for_rule, DOM::Element const& element, JS::GCPtr<DOM::Element const> shadow_host, JS::NonnullGCPtr<DOM::Element const> anchor)
|
||||
static inline bool matches_relative_selector(CSS::Selector const& selector, size_t compound_index, Optional<CSS::CSSStyleSheet const&> style_sheet_for_rule, DOM::Element const& element, GC::Ptr<DOM::Element const> shadow_host, GC::Ref<DOM::Element const> anchor)
|
||||
{
|
||||
if (compound_index >= selector.compound_selectors().size())
|
||||
return matches(selector, style_sheet_for_rule, element, shadow_host, {}, {}, SelectorKind::Relative, anchor);
|
||||
|
@ -143,7 +143,7 @@ static inline bool matches_relative_selector(CSS::Selector const& selector, size
|
|||
}
|
||||
|
||||
// https://drafts.csswg.org/selectors-4/#relational
|
||||
static inline bool matches_has_pseudo_class(CSS::Selector const& selector, Optional<CSS::CSSStyleSheet const&> style_sheet_for_rule, DOM::Element const& anchor, JS::GCPtr<DOM::Element const> shadow_host)
|
||||
static inline bool matches_has_pseudo_class(CSS::Selector const& selector, Optional<CSS::CSSStyleSheet const&> style_sheet_for_rule, DOM::Element const& anchor, GC::Ptr<DOM::Element const> shadow_host)
|
||||
{
|
||||
return matches_relative_selector(selector, 0, style_sheet_for_rule, anchor, shadow_host, anchor);
|
||||
}
|
||||
|
@ -381,7 +381,7 @@ static bool matches_open_state_pseudo_class(DOM::Element const& element, bool op
|
|||
}
|
||||
|
||||
// https://drafts.csswg.org/css-scoping/#host-selector
|
||||
static inline bool matches_host_pseudo_class(JS::NonnullGCPtr<DOM::Element const> element, JS::GCPtr<DOM::Element const> shadow_host, CSS::SelectorList const& argument_selector_list, Optional<CSS::CSSStyleSheet const&> style_sheet_for_rule)
|
||||
static inline bool matches_host_pseudo_class(GC::Ref<DOM::Element const> element, GC::Ptr<DOM::Element const> shadow_host, CSS::SelectorList const& argument_selector_list, Optional<CSS::CSSStyleSheet const&> style_sheet_for_rule)
|
||||
{
|
||||
// When evaluated in the context of a shadow tree, it matches the shadow tree’s shadow host if the shadow host,
|
||||
// in its normal context, matches the selector argument. In any other context, it matches nothing.
|
||||
|
@ -395,7 +395,7 @@ static inline bool matches_host_pseudo_class(JS::NonnullGCPtr<DOM::Element const
|
|||
return true;
|
||||
}
|
||||
|
||||
static inline bool matches_pseudo_class(CSS::Selector::SimpleSelector::PseudoClassSelector const& pseudo_class, Optional<CSS::CSSStyleSheet const&> style_sheet_for_rule, DOM::Element const& element, JS::GCPtr<DOM::Element const> shadow_host, JS::GCPtr<DOM::ParentNode const> scope, SelectorKind selector_kind)
|
||||
static inline bool matches_pseudo_class(CSS::Selector::SimpleSelector::PseudoClassSelector const& pseudo_class, Optional<CSS::CSSStyleSheet const&> style_sheet_for_rule, DOM::Element const& element, GC::Ptr<DOM::Element const> shadow_host, GC::Ptr<DOM::ParentNode const> scope, SelectorKind selector_kind)
|
||||
{
|
||||
switch (pseudo_class.type) {
|
||||
case CSS::PseudoClass::Link:
|
||||
|
@ -724,7 +724,7 @@ static ALWAYS_INLINE bool matches_namespace(
|
|||
VERIFY_NOT_REACHED();
|
||||
}
|
||||
|
||||
static inline bool matches(CSS::Selector::SimpleSelector const& component, Optional<CSS::CSSStyleSheet const&> style_sheet_for_rule, DOM::Element const& element, JS::GCPtr<DOM::Element const> shadow_host, JS::GCPtr<DOM::ParentNode const> scope, SelectorKind selector_kind, [[maybe_unused]] JS::GCPtr<DOM::Element const> anchor)
|
||||
static inline bool matches(CSS::Selector::SimpleSelector const& component, Optional<CSS::CSSStyleSheet const&> style_sheet_for_rule, DOM::Element const& element, GC::Ptr<DOM::Element const> shadow_host, GC::Ptr<DOM::ParentNode const> scope, SelectorKind selector_kind, [[maybe_unused]] GC::Ptr<DOM::Element const> anchor)
|
||||
{
|
||||
switch (component.type) {
|
||||
case CSS::Selector::SimpleSelector::Type::Universal:
|
||||
|
@ -771,7 +771,7 @@ static inline bool matches(CSS::Selector::SimpleSelector const& component, Optio
|
|||
VERIFY_NOT_REACHED();
|
||||
}
|
||||
|
||||
bool matches(CSS::Selector const& selector, Optional<CSS::CSSStyleSheet const&> style_sheet_for_rule, int component_list_index, DOM::Element const& element, JS::GCPtr<DOM::Element const> shadow_host, JS::GCPtr<DOM::ParentNode const> scope, SelectorKind selector_kind, JS::GCPtr<DOM::Element const> anchor)
|
||||
bool matches(CSS::Selector const& selector, Optional<CSS::CSSStyleSheet const&> style_sheet_for_rule, int component_list_index, DOM::Element const& element, GC::Ptr<DOM::Element const> shadow_host, GC::Ptr<DOM::ParentNode const> scope, SelectorKind selector_kind, GC::Ptr<DOM::Element const> anchor)
|
||||
{
|
||||
auto& compound_selector = selector.compound_selectors()[component_list_index];
|
||||
for (auto& simple_selector : compound_selector.simple_selectors) {
|
||||
|
@ -825,7 +825,7 @@ bool matches(CSS::Selector const& selector, Optional<CSS::CSSStyleSheet const&>
|
|||
VERIFY_NOT_REACHED();
|
||||
}
|
||||
|
||||
bool matches(CSS::Selector const& selector, Optional<CSS::CSSStyleSheet const&> style_sheet_for_rule, DOM::Element const& element, JS::GCPtr<DOM::Element const> shadow_host, Optional<CSS::Selector::PseudoElement::Type> pseudo_element, JS::GCPtr<DOM::ParentNode const> scope, SelectorKind selector_kind, JS::GCPtr<DOM::Element const> anchor)
|
||||
bool matches(CSS::Selector const& selector, Optional<CSS::CSSStyleSheet const&> style_sheet_for_rule, DOM::Element const& element, GC::Ptr<DOM::Element const> shadow_host, Optional<CSS::Selector::PseudoElement::Type> pseudo_element, GC::Ptr<DOM::ParentNode const> scope, SelectorKind selector_kind, GC::Ptr<DOM::Element const> anchor)
|
||||
{
|
||||
VERIFY(!selector.compound_selectors().is_empty());
|
||||
if (pseudo_element.has_value() && selector.pseudo_element().has_value() && selector.pseudo_element().value().type() != pseudo_element)
|
||||
|
@ -835,7 +835,7 @@ bool matches(CSS::Selector const& selector, Optional<CSS::CSSStyleSheet const&>
|
|||
return matches(selector, style_sheet_for_rule, selector.compound_selectors().size() - 1, element, shadow_host, scope, selector_kind, anchor);
|
||||
}
|
||||
|
||||
static bool fast_matches_simple_selector(CSS::Selector::SimpleSelector const& simple_selector, Optional<CSS::CSSStyleSheet const&> style_sheet_for_rule, DOM::Element const& element, JS::GCPtr<DOM::Element const> shadow_host)
|
||||
static bool fast_matches_simple_selector(CSS::Selector::SimpleSelector const& simple_selector, Optional<CSS::CSSStyleSheet const&> style_sheet_for_rule, DOM::Element const& element, GC::Ptr<DOM::Element const> shadow_host)
|
||||
{
|
||||
switch (simple_selector.type) {
|
||||
case CSS::Selector::SimpleSelector::Type::Universal:
|
||||
|
@ -865,7 +865,7 @@ static bool fast_matches_simple_selector(CSS::Selector::SimpleSelector const& si
|
|||
}
|
||||
}
|
||||
|
||||
static bool fast_matches_compound_selector(CSS::Selector::CompoundSelector const& compound_selector, Optional<CSS::CSSStyleSheet const&> style_sheet_for_rule, DOM::Element const& element, JS::GCPtr<DOM::Element const> shadow_host)
|
||||
static bool fast_matches_compound_selector(CSS::Selector::CompoundSelector const& compound_selector, Optional<CSS::CSSStyleSheet const&> style_sheet_for_rule, DOM::Element const& element, GC::Ptr<DOM::Element const> shadow_host)
|
||||
{
|
||||
for (auto const& simple_selector : compound_selector.simple_selectors) {
|
||||
if (!fast_matches_simple_selector(simple_selector, style_sheet_for_rule, element, shadow_host))
|
||||
|
@ -874,7 +874,7 @@ static bool fast_matches_compound_selector(CSS::Selector::CompoundSelector const
|
|||
return true;
|
||||
}
|
||||
|
||||
bool fast_matches(CSS::Selector const& selector, Optional<CSS::CSSStyleSheet const&> style_sheet_for_rule, DOM::Element const& element_to_match, JS::GCPtr<DOM::Element const> shadow_host)
|
||||
bool fast_matches(CSS::Selector const& selector, Optional<CSS::CSSStyleSheet const&> style_sheet_for_rule, DOM::Element const& element_to_match, GC::Ptr<DOM::Element const> shadow_host)
|
||||
{
|
||||
DOM::Element const* current = &element_to_match;
|
||||
|
||||
|
@ -886,7 +886,7 @@ bool fast_matches(CSS::Selector const& selector, Optional<CSS::CSSStyleSheet con
|
|||
// NOTE: If we fail after following a child combinator, we may need to backtrack
|
||||
// to the last matched descendant. We store the state here.
|
||||
struct {
|
||||
JS::GCPtr<DOM::Element const> element;
|
||||
GC::Ptr<DOM::Element const> element;
|
||||
ssize_t compound_selector_index = 0;
|
||||
} backtrack_state;
|
||||
|
||||
|
|
|
@ -16,9 +16,9 @@ enum class SelectorKind {
|
|||
Relative,
|
||||
};
|
||||
|
||||
bool matches(CSS::Selector const&, Optional<CSS::CSSStyleSheet const&> style_sheet_for_rule, DOM::Element const&, JS::GCPtr<DOM::Element const> shadow_host, Optional<CSS::Selector::PseudoElement::Type> = {}, JS::GCPtr<DOM::ParentNode const> scope = {}, SelectorKind selector_kind = SelectorKind::Normal, JS::GCPtr<DOM::Element const> anchor = nullptr);
|
||||
bool matches(CSS::Selector const&, Optional<CSS::CSSStyleSheet const&> style_sheet_for_rule, DOM::Element const&, GC::Ptr<DOM::Element const> shadow_host, Optional<CSS::Selector::PseudoElement::Type> = {}, GC::Ptr<DOM::ParentNode const> scope = {}, SelectorKind selector_kind = SelectorKind::Normal, GC::Ptr<DOM::Element const> anchor = nullptr);
|
||||
|
||||
[[nodiscard]] bool fast_matches(CSS::Selector const&, Optional<CSS::CSSStyleSheet const&> style_sheet_for_rule, DOM::Element const&, JS::GCPtr<DOM::Element const> shadow_host);
|
||||
[[nodiscard]] bool fast_matches(CSS::Selector const&, Optional<CSS::CSSStyleSheet const&> style_sheet_for_rule, DOM::Element const&, GC::Ptr<DOM::Element const> shadow_host);
|
||||
[[nodiscard]] bool can_use_fast_matches(CSS::Selector const&);
|
||||
|
||||
[[nodiscard]] bool matches_hover_pseudo_class(DOM::Element const&);
|
||||
|
|
|
@ -257,40 +257,40 @@ struct StyleComputer::MatchingFontCandidate {
|
|||
|
||||
static CSSStyleSheet& default_stylesheet(DOM::Document const& document)
|
||||
{
|
||||
static JS::Handle<CSSStyleSheet> sheet;
|
||||
static GC::Root<CSSStyleSheet> sheet;
|
||||
if (!sheet.cell()) {
|
||||
extern String default_stylesheet_source;
|
||||
sheet = JS::make_handle(parse_css_stylesheet(CSS::Parser::ParsingContext(document), default_stylesheet_source));
|
||||
sheet = GC::make_root(parse_css_stylesheet(CSS::Parser::ParsingContext(document), default_stylesheet_source));
|
||||
}
|
||||
return *sheet;
|
||||
}
|
||||
|
||||
static CSSStyleSheet& quirks_mode_stylesheet(DOM::Document const& document)
|
||||
{
|
||||
static JS::Handle<CSSStyleSheet> sheet;
|
||||
static GC::Root<CSSStyleSheet> sheet;
|
||||
if (!sheet.cell()) {
|
||||
extern String quirks_mode_stylesheet_source;
|
||||
sheet = JS::make_handle(parse_css_stylesheet(CSS::Parser::ParsingContext(document), quirks_mode_stylesheet_source));
|
||||
sheet = GC::make_root(parse_css_stylesheet(CSS::Parser::ParsingContext(document), quirks_mode_stylesheet_source));
|
||||
}
|
||||
return *sheet;
|
||||
}
|
||||
|
||||
static CSSStyleSheet& mathml_stylesheet(DOM::Document const& document)
|
||||
{
|
||||
static JS::Handle<CSSStyleSheet> sheet;
|
||||
static GC::Root<CSSStyleSheet> sheet;
|
||||
if (!sheet.cell()) {
|
||||
extern String mathml_stylesheet_source;
|
||||
sheet = JS::make_handle(parse_css_stylesheet(CSS::Parser::ParsingContext(document), mathml_stylesheet_source));
|
||||
sheet = GC::make_root(parse_css_stylesheet(CSS::Parser::ParsingContext(document), mathml_stylesheet_source));
|
||||
}
|
||||
return *sheet;
|
||||
}
|
||||
|
||||
static CSSStyleSheet& svg_stylesheet(DOM::Document const& document)
|
||||
{
|
||||
static JS::Handle<CSSStyleSheet> sheet;
|
||||
static GC::Root<CSSStyleSheet> sheet;
|
||||
if (!sheet.cell()) {
|
||||
extern String svg_stylesheet_source;
|
||||
sheet = JS::make_handle(parse_css_stylesheet(CSS::Parser::ParsingContext(document), svg_stylesheet_source));
|
||||
sheet = GC::make_root(parse_css_stylesheet(CSS::Parser::ParsingContext(document), svg_stylesheet_source));
|
||||
}
|
||||
return *sheet;
|
||||
}
|
||||
|
@ -381,7 +381,7 @@ Vector<MatchingRule> StyleComputer::collect_matching_rules(DOM::Element const& e
|
|||
auto const& root_node = element.root();
|
||||
auto shadow_root = is<DOM::ShadowRoot>(root_node) ? static_cast<DOM::ShadowRoot const*>(&root_node) : nullptr;
|
||||
|
||||
JS::GCPtr<DOM::Element const> shadow_host;
|
||||
GC::Ptr<DOM::Element const> shadow_host;
|
||||
if (element.is_shadow_host())
|
||||
shadow_host = element;
|
||||
else if (shadow_root)
|
||||
|
@ -979,7 +979,7 @@ static void cascade_custom_properties(DOM::Element& element, Optional<CSS::Selec
|
|||
}
|
||||
}
|
||||
|
||||
void StyleComputer::collect_animation_into(DOM::Element& element, Optional<CSS::Selector::PseudoElement::Type> pseudo_element, JS::NonnullGCPtr<Animations::KeyframeEffect> effect, StyleProperties& style_properties, AnimationRefresh refresh) const
|
||||
void StyleComputer::collect_animation_into(DOM::Element& element, Optional<CSS::Selector::PseudoElement::Type> pseudo_element, GC::Ref<Animations::KeyframeEffect> effect, StyleProperties& style_properties, AnimationRefresh refresh) const
|
||||
{
|
||||
auto animation = effect->associated_animation();
|
||||
if (!animation)
|
||||
|
@ -2458,7 +2458,7 @@ NonnullOwnPtr<StyleComputer::RuleCache> StyleComputer::make_rule_cache_for_casca
|
|||
|
||||
Vector<MatchingRule> matching_rules;
|
||||
size_t style_sheet_index = 0;
|
||||
for_each_stylesheet(cascade_origin, [&](auto& sheet, JS::GCPtr<DOM::ShadowRoot> shadow_root) {
|
||||
for_each_stylesheet(cascade_origin, [&](auto& sheet, GC::Ptr<DOM::ShadowRoot> shadow_root) {
|
||||
size_t rule_index = 0;
|
||||
sheet.for_each_effective_style_producing_rule([&](auto const& rule) {
|
||||
size_t selector_index = 0;
|
||||
|
@ -2688,7 +2688,7 @@ void StyleComputer::build_qualified_layer_names_cache()
|
|||
|
||||
// Walk all style sheets, identifying when we first see a @layer name, and add its qualified name to the list.
|
||||
// TODO: Separate the light and shadow-dom layers.
|
||||
for_each_stylesheet(CascadeOrigin::Author, [&](auto& sheet, JS::GCPtr<DOM::ShadowRoot>) {
|
||||
for_each_stylesheet(CascadeOrigin::Author, [&](auto& sheet, GC::Ptr<DOM::ShadowRoot>) {
|
||||
// NOTE: Postorder so that a @layer block is iterated after its children,
|
||||
// because we want those children to occur before it in the list.
|
||||
sheet.for_each_effective_rule(TraversalOrder::Postorder, [&](auto& rule) {
|
||||
|
@ -2732,7 +2732,7 @@ void StyleComputer::build_qualified_layer_names_cache()
|
|||
void StyleComputer::build_rule_cache()
|
||||
{
|
||||
if (auto user_style_source = document().page().user_style(); user_style_source.has_value()) {
|
||||
m_user_style_sheet = JS::make_handle(parse_css_stylesheet(CSS::Parser::ParsingContext(document()), user_style_source.value()));
|
||||
m_user_style_sheet = GC::make_root(parse_css_stylesheet(CSS::Parser::ParsingContext(document()), user_style_source.value()));
|
||||
}
|
||||
|
||||
build_qualified_layer_names_cache();
|
||||
|
|
|
@ -81,9 +81,9 @@ enum class CascadeOrigin : u8 {
|
|||
};
|
||||
|
||||
struct MatchingRule {
|
||||
JS::GCPtr<DOM::ShadowRoot const> shadow_root;
|
||||
JS::GCPtr<CSSRule const> rule; // Either CSSStyleRule or CSSNestedDeclarations
|
||||
JS::GCPtr<CSSStyleSheet const> sheet;
|
||||
GC::Ptr<DOM::ShadowRoot const> shadow_root;
|
||||
GC::Ptr<CSSRule const> rule; // Either CSSStyleRule or CSSNestedDeclarations
|
||||
GC::Ptr<CSSStyleSheet const> sheet;
|
||||
size_t style_sheet_index { 0 };
|
||||
size_t rule_index { 0 };
|
||||
size_t selector_index { 0 };
|
||||
|
@ -160,7 +160,7 @@ public:
|
|||
No,
|
||||
Yes,
|
||||
};
|
||||
void collect_animation_into(DOM::Element&, Optional<CSS::Selector::PseudoElement::Type>, JS::NonnullGCPtr<Animations::KeyframeEffect> animation, StyleProperties& style_properties, AnimationRefresh = AnimationRefresh::No) const;
|
||||
void collect_animation_into(DOM::Element&, Optional<CSS::Selector::PseudoElement::Type>, GC::Ref<Animations::KeyframeEffect> animation, StyleProperties& style_properties, AnimationRefresh = AnimationRefresh::No) const;
|
||||
|
||||
[[nodiscard]] bool has_has_selectors() const { return m_has_has_selectors; }
|
||||
|
||||
|
@ -219,7 +219,7 @@ private:
|
|||
void build_rule_cache();
|
||||
void build_rule_cache_if_needed() const;
|
||||
|
||||
JS::NonnullGCPtr<DOM::Document> m_document;
|
||||
GC::Ref<DOM::Document> m_document;
|
||||
|
||||
struct RuleCache {
|
||||
HashMap<FlyString, Vector<MatchingRule>> rules_by_id;
|
||||
|
@ -243,7 +243,7 @@ private:
|
|||
OwnPtr<RuleCache> m_author_rule_cache;
|
||||
OwnPtr<RuleCache> m_user_rule_cache;
|
||||
OwnPtr<RuleCache> m_user_agent_rule_cache;
|
||||
JS::Handle<CSSStyleSheet> m_user_style_sheet;
|
||||
GC::Root<CSSStyleSheet> m_user_style_sheet;
|
||||
|
||||
using FontLoaderList = Vector<NonnullOwnPtr<FontLoader>>;
|
||||
HashMap<FontFaceKey, FontLoaderList> m_loaded_fonts;
|
||||
|
|
|
@ -8,10 +8,10 @@
|
|||
|
||||
#include <AK/HashMap.h>
|
||||
#include <AK/NonnullRefPtr.h>
|
||||
#include <LibGC/Ptr.h>
|
||||
#include <LibGfx/Font/Font.h>
|
||||
#include <LibGfx/FontCascadeList.h>
|
||||
#include <LibGfx/Forward.h>
|
||||
#include <LibJS/Heap/GCPtr.h>
|
||||
#include <LibWeb/CSS/ComputedValues.h>
|
||||
#include <LibWeb/CSS/LengthBox.h>
|
||||
#include <LibWeb/CSS/PropertyID.h>
|
||||
|
@ -30,8 +30,8 @@ private:
|
|||
NonnullRefPtr<Data> clone() const;
|
||||
|
||||
// FIXME: These need protection from GC!
|
||||
JS::GCPtr<CSS::CSSStyleDeclaration const> m_animation_name_source;
|
||||
JS::GCPtr<CSS::CSSStyleDeclaration const> m_transition_property_source;
|
||||
GC::Ptr<CSS::CSSStyleDeclaration const> m_animation_name_source;
|
||||
GC::Ptr<CSS::CSSStyleDeclaration const> m_transition_property_source;
|
||||
|
||||
Array<RefPtr<CSSStyleValue const>, number_of_properties> m_property_values;
|
||||
Array<u8, ceil_div(number_of_properties, 8uz)> m_property_important {};
|
||||
|
@ -80,11 +80,11 @@ public:
|
|||
CSSStyleValue const* maybe_null_property(CSS::PropertyID) const;
|
||||
void revert_property(CSS::PropertyID, StyleProperties const& style_for_revert);
|
||||
|
||||
JS::GCPtr<CSS::CSSStyleDeclaration const> animation_name_source() const { return m_data->m_animation_name_source; }
|
||||
void set_animation_name_source(JS::GCPtr<CSS::CSSStyleDeclaration const> declaration) { m_data->m_animation_name_source = declaration; }
|
||||
GC::Ptr<CSS::CSSStyleDeclaration const> animation_name_source() const { return m_data->m_animation_name_source; }
|
||||
void set_animation_name_source(GC::Ptr<CSS::CSSStyleDeclaration const> declaration) { m_data->m_animation_name_source = declaration; }
|
||||
|
||||
JS::GCPtr<CSS::CSSStyleDeclaration const> transition_property_source() const { return m_data->m_transition_property_source; }
|
||||
void set_transition_property_source(JS::GCPtr<CSS::CSSStyleDeclaration const> declaration) { m_data->m_transition_property_source = declaration; }
|
||||
GC::Ptr<CSS::CSSStyleDeclaration const> transition_property_source() const { return m_data->m_transition_property_source; }
|
||||
void set_transition_property_source(GC::Ptr<CSS::CSSStyleDeclaration const> declaration) { m_data->m_transition_property_source = declaration; }
|
||||
|
||||
CSS::Size size_value(CSS::PropertyID) const;
|
||||
[[nodiscard]] Variant<LengthPercentage, NormalGap> gap_value(CSS::PropertyID) const;
|
||||
|
|
|
@ -60,11 +60,11 @@ protected:
|
|||
explicit StyleSheet(JS::Realm&, MediaList& media);
|
||||
virtual void visit_edges(Cell::Visitor&) override;
|
||||
|
||||
JS::NonnullGCPtr<MediaList> m_media;
|
||||
GC::Ref<MediaList> m_media;
|
||||
|
||||
private:
|
||||
JS::GCPtr<DOM::Element> m_owner_node;
|
||||
JS::GCPtr<CSSStyleSheet> m_parent_style_sheet;
|
||||
GC::Ptr<DOM::Element> m_owner_node;
|
||||
GC::Ptr<CSSStyleSheet> m_parent_style_sheet;
|
||||
|
||||
Optional<String> m_location;
|
||||
String m_title;
|
||||
|
|
|
@ -12,7 +12,7 @@
|
|||
|
||||
namespace Web::CSS {
|
||||
|
||||
JS_DEFINE_ALLOCATOR(StyleSheetList);
|
||||
GC_DEFINE_ALLOCATOR(StyleSheetList);
|
||||
|
||||
// https://www.w3.org/TR/cssom/#remove-a-css-style-sheet
|
||||
void StyleSheetList::remove_a_css_style_sheet(CSS::CSSStyleSheet& sheet)
|
||||
|
@ -128,13 +128,13 @@ void StyleSheetList::remove_sheet(CSSStyleSheet& sheet)
|
|||
document_or_shadow_root().invalidate_style(DOM::StyleInvalidationReason::StyleSheetListRemoveSheet);
|
||||
}
|
||||
|
||||
JS::NonnullGCPtr<StyleSheetList> StyleSheetList::create(JS::NonnullGCPtr<DOM::Node> document_or_shadow_root)
|
||||
GC::Ref<StyleSheetList> StyleSheetList::create(GC::Ref<DOM::Node> document_or_shadow_root)
|
||||
{
|
||||
auto& realm = document_or_shadow_root->realm();
|
||||
return realm.create<StyleSheetList>(document_or_shadow_root);
|
||||
}
|
||||
|
||||
StyleSheetList::StyleSheetList(JS::NonnullGCPtr<DOM::Node> document_or_shadow_root)
|
||||
StyleSheetList::StyleSheetList(GC::Ref<DOM::Node> document_or_shadow_root)
|
||||
: Bindings::PlatformObject(document_or_shadow_root->realm())
|
||||
, m_document_or_shadow_root(document_or_shadow_root)
|
||||
{
|
||||
|
|
|
@ -14,17 +14,17 @@ namespace Web::CSS {
|
|||
|
||||
class StyleSheetList final : public Bindings::PlatformObject {
|
||||
WEB_PLATFORM_OBJECT(StyleSheetList, Bindings::PlatformObject);
|
||||
JS_DECLARE_ALLOCATOR(StyleSheetList);
|
||||
GC_DECLARE_ALLOCATOR(StyleSheetList);
|
||||
|
||||
public:
|
||||
[[nodiscard]] static JS::NonnullGCPtr<StyleSheetList> create(JS::NonnullGCPtr<DOM::Node> document_or_shadow_root);
|
||||
[[nodiscard]] static GC::Ref<StyleSheetList> create(GC::Ref<DOM::Node> document_or_shadow_root);
|
||||
|
||||
void add_a_css_style_sheet(CSS::CSSStyleSheet&);
|
||||
void remove_a_css_style_sheet(CSS::CSSStyleSheet&);
|
||||
void create_a_css_style_sheet(String type, DOM::Element* owner_node, String media, String title, bool alternate, bool origin_clean, Optional<String> location, CSS::CSSStyleSheet* parent_style_sheet, CSS::CSSRule* owner_rule, CSS::CSSStyleSheet&);
|
||||
|
||||
Vector<JS::NonnullGCPtr<CSSStyleSheet>> const& sheets() const { return m_sheets; }
|
||||
Vector<JS::NonnullGCPtr<CSSStyleSheet>>& sheets() { return m_sheets; }
|
||||
Vector<GC::Ref<CSSStyleSheet>> const& sheets() const { return m_sheets; }
|
||||
Vector<GC::Ref<CSSStyleSheet>>& sheets() { return m_sheets; }
|
||||
|
||||
CSSStyleSheet* item(size_t index) const
|
||||
{
|
||||
|
@ -44,7 +44,7 @@ public:
|
|||
[[nodiscard]] DOM::Node const& document_or_shadow_root() const { return m_document_or_shadow_root; }
|
||||
|
||||
private:
|
||||
explicit StyleSheetList(JS::NonnullGCPtr<DOM::Node> document_or_shadow_root);
|
||||
explicit StyleSheetList(GC::Ref<DOM::Node> document_or_shadow_root);
|
||||
|
||||
virtual void initialize(JS::Realm&) override;
|
||||
virtual void visit_edges(Cell::Visitor&) override;
|
||||
|
@ -52,8 +52,8 @@ private:
|
|||
void add_sheet(CSSStyleSheet&);
|
||||
void remove_sheet(CSSStyleSheet&);
|
||||
|
||||
JS::NonnullGCPtr<DOM::Node> m_document_or_shadow_root;
|
||||
Vector<JS::NonnullGCPtr<CSSStyleSheet>> m_sheets;
|
||||
GC::Ref<DOM::Node> m_document_or_shadow_root;
|
||||
Vector<GC::Ref<CSSStyleSheet>> m_sheets;
|
||||
|
||||
// https://www.w3.org/TR/cssom/#preferred-css-style-sheet-set-name
|
||||
String m_preferred_css_style_sheet_set_name;
|
||||
|
|
|
@ -63,7 +63,7 @@ void ImageStyleValue::load_any_resources(DOM::Document& document)
|
|||
if (image_data->is_animated() && image_data->frame_count() > 1) {
|
||||
m_timer = Platform::Timer::create(m_document->heap());
|
||||
m_timer->set_interval(image_data->frame_duration(0));
|
||||
m_timer->on_timeout = JS::create_heap_function(m_document->heap(), [this] { animate(); });
|
||||
m_timer->on_timeout = GC::create_function(m_document->heap(), [this] { animate(); });
|
||||
m_timer->start();
|
||||
}
|
||||
},
|
||||
|
@ -158,7 +158,7 @@ Gfx::ImmutableBitmap const* ImageStyleValue::current_frame_bitmap(DevicePixelRec
|
|||
return bitmap(m_current_frame_index, dest_rect.size().to_type<int>());
|
||||
}
|
||||
|
||||
JS::GCPtr<HTML::DecodedImageData> ImageStyleValue::image_data() const
|
||||
GC::Ptr<HTML::DecodedImageData> ImageStyleValue::image_data() const
|
||||
{
|
||||
if (!m_resource_request)
|
||||
return nullptr;
|
||||
|
|
|
@ -9,8 +9,8 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include <LibGC/Root.h>
|
||||
#include <LibJS/Heap/Cell.h>
|
||||
#include <LibJS/Heap/Handle.h>
|
||||
#include <LibURL/URL.h>
|
||||
#include <LibWeb/CSS/Enums.h>
|
||||
#include <LibWeb/CSS/StyleValues/AbstractImageStyleValue.h>
|
||||
|
@ -47,12 +47,12 @@ public:
|
|||
|
||||
Function<void()> on_animate;
|
||||
|
||||
JS::GCPtr<HTML::DecodedImageData> image_data() const;
|
||||
GC::Ptr<HTML::DecodedImageData> image_data() const;
|
||||
|
||||
private:
|
||||
ImageStyleValue(URL::URL const&);
|
||||
|
||||
JS::GCPtr<HTML::SharedResourceRequest> m_resource_request;
|
||||
GC::Ptr<HTML::SharedResourceRequest> m_resource_request;
|
||||
|
||||
void animate();
|
||||
Gfx::ImmutableBitmap const* bitmap(size_t frame_index, Gfx::IntSize = {}) const;
|
||||
|
@ -62,7 +62,7 @@ private:
|
|||
|
||||
size_t m_current_frame_index { 0 };
|
||||
size_t m_loops_completed { 0 };
|
||||
JS::GCPtr<Platform::Timer> m_timer;
|
||||
GC::Ptr<Platform::Timer> m_timer;
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -15,9 +15,9 @@
|
|||
|
||||
namespace Web::CSS {
|
||||
|
||||
JS_DEFINE_ALLOCATOR(VisualViewport);
|
||||
GC_DEFINE_ALLOCATOR(VisualViewport);
|
||||
|
||||
JS::NonnullGCPtr<VisualViewport> VisualViewport::create(DOM::Document& document)
|
||||
GC::Ref<VisualViewport> VisualViewport::create(DOM::Document& document)
|
||||
{
|
||||
return document.realm().create<VisualViewport>(document);
|
||||
}
|
||||
|
|
|
@ -13,10 +13,10 @@ namespace Web::CSS {
|
|||
// https://drafts.csswg.org/cssom-view/#visualviewport
|
||||
class VisualViewport final : public DOM::EventTarget {
|
||||
WEB_PLATFORM_OBJECT(VisualViewport, DOM::EventTarget);
|
||||
JS_DECLARE_ALLOCATOR(VisualViewport);
|
||||
GC_DECLARE_ALLOCATOR(VisualViewport);
|
||||
|
||||
public:
|
||||
[[nodiscard]] static JS::NonnullGCPtr<VisualViewport> create(DOM::Document&);
|
||||
[[nodiscard]] static GC::Ref<VisualViewport> create(DOM::Document&);
|
||||
|
||||
virtual ~VisualViewport() override = default;
|
||||
|
||||
|
@ -44,7 +44,7 @@ private:
|
|||
virtual void initialize(JS::Realm&) override;
|
||||
virtual void visit_edges(Cell::Visitor&) override;
|
||||
|
||||
JS::NonnullGCPtr<DOM::Document> m_document;
|
||||
GC::Ref<DOM::Document> m_document;
|
||||
};
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue