LibGC+Everywhere: Factor out a LibGC from LibJS

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

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

View file

@ -19,10 +19,10 @@
namespace Web::Animations {
// https://www.w3.org/TR/web-animations-1/#dom-animatable-animate
WebIDL::ExceptionOr<JS::NonnullGCPtr<Animation>> Animatable::animate(Optional<JS::Handle<JS::Object>> keyframes, Variant<Empty, double, KeyframeAnimationOptions> options)
WebIDL::ExceptionOr<GC::Ref<Animation>> Animatable::animate(Optional<GC::Root<JS::Object>> keyframes, Variant<Empty, double, KeyframeAnimationOptions> options)
{
// 1. Let target be the object on which this method was called.
JS::NonnullGCPtr target { *static_cast<DOM::Element*>(this) };
GC::Ref target { *static_cast<DOM::Element*>(this) };
auto& realm = target->realm();
// 2. Construct a new KeyframeEffect object, effect, in the relevant Realm of target by using the same procedure as
@ -37,7 +37,7 @@ WebIDL::ExceptionOr<JS::NonnullGCPtr<Animation>> Animatable::animate(Optional<JS
// 3. If options is a KeyframeAnimationOptions object, let timeline be the timeline member of options or, if
// timeline member of options is missing, be the default document timeline of the node document of the element
// on which this method was called.
Optional<JS::GCPtr<AnimationTimeline>> timeline;
Optional<GC::Ptr<AnimationTimeline>> timeline;
if (options.has<KeyframeAnimationOptions>())
timeline = options.get<KeyframeAnimationOptions>().timeline;
if (!timeline.has_value())
@ -60,13 +60,13 @@ WebIDL::ExceptionOr<JS::NonnullGCPtr<Animation>> Animatable::animate(Optional<JS
}
// https://drafts.csswg.org/web-animations-1/#dom-animatable-getanimations
WebIDL::ExceptionOr<Vector<JS::NonnullGCPtr<Animation>>> Animatable::get_animations(Optional<GetAnimationsOptions> options)
WebIDL::ExceptionOr<Vector<GC::Ref<Animation>>> Animatable::get_animations(Optional<GetAnimationsOptions> options)
{
verify_cast<DOM::Element>(*this).document().update_style();
return get_animations_internal(options);
}
WebIDL::ExceptionOr<Vector<JS::NonnullGCPtr<Animation>>> Animatable::get_animations_internal(Optional<GetAnimationsOptions> options)
WebIDL::ExceptionOr<Vector<GC::Ref<Animation>>> Animatable::get_animations_internal(Optional<GetAnimationsOptions> options)
{
// 1. Let object be the object on which this method was called.
@ -82,11 +82,11 @@ WebIDL::ExceptionOr<Vector<JS::NonnullGCPtr<Animation>>> Animatable::get_animati
// Otherwise, let target be object.
// FIXME: We can't refer to pseudo-elements directly, and they also can't be animated yet.
(void)pseudo_element;
JS::NonnullGCPtr target { *static_cast<DOM::Element*>(this) };
GC::Ref target { *static_cast<DOM::Element*>(this) };
// 4. If options is passed with subtree set to true, then return the set of relevant animations for a subtree of target.
// Otherwise, return the set of relevant animations for target.
Vector<JS::NonnullGCPtr<Animation>> relevant_animations;
Vector<GC::Ref<Animation>> relevant_animations;
for (auto const& animation : m_associated_animations) {
if (animation->is_relevant())
relevant_animations.append(*animation);
@ -102,7 +102,7 @@ WebIDL::ExceptionOr<Vector<JS::NonnullGCPtr<Animation>>> Animatable::get_animati
// The returned list is sorted using the composite order described for the associated animations of effects in
// §5.4.2 The effect stack.
quick_sort(relevant_animations, [](JS::NonnullGCPtr<Animation>& a, JS::NonnullGCPtr<Animation>& b) {
quick_sort(relevant_animations, [](GC::Ref<Animation>& a, GC::Ref<Animation>& b) {
auto& a_effect = verify_cast<KeyframeEffect>(*a->effect());
auto& b_effect = verify_cast<KeyframeEffect>(*b->effect());
return KeyframeEffect::composite_order(a_effect, b_effect) < 0;
@ -111,13 +111,13 @@ WebIDL::ExceptionOr<Vector<JS::NonnullGCPtr<Animation>>> Animatable::get_animati
return relevant_animations;
}
void Animatable::associate_with_animation(JS::NonnullGCPtr<Animation> animation)
void Animatable::associate_with_animation(GC::Ref<Animation> animation)
{
m_associated_animations.append(animation);
m_is_sorted_by_composite_order = false;
}
void Animatable::disassociate_with_animation(JS::NonnullGCPtr<Animation> animation)
void Animatable::disassociate_with_animation(GC::Ref<Animation> animation)
{
m_associated_animations.remove_first_matching([&](auto element) { return animation == element; });
}
@ -148,14 +148,14 @@ Optional<Animatable::TransitionAttributes const&> Animatable::property_transitio
return {};
}
JS::GCPtr<CSS::CSSTransition> Animatable::property_transition(CSS::PropertyID property) const
GC::Ptr<CSS::CSSTransition> Animatable::property_transition(CSS::PropertyID property) const
{
if (auto maybe_animation = m_associated_transitions.get(property); maybe_animation.has_value())
return maybe_animation.value();
return {};
}
void Animatable::set_transition(CSS::PropertyID property, JS::NonnullGCPtr<CSS::CSSTransition> animation)
void Animatable::set_transition(CSS::PropertyID property, GC::Ref<CSS::CSSTransition> animation)
{
VERIFY(!m_associated_transitions.contains(property));
m_associated_transitions.set(property, animation);
@ -185,14 +185,14 @@ void Animatable::visit_edges(JS::Cell::Visitor& visitor)
visitor.visit(m_associated_transitions);
}
JS::GCPtr<CSS::CSSStyleDeclaration const> Animatable::cached_animation_name_source(Optional<CSS::Selector::PseudoElement::Type> pseudo_element) const
GC::Ptr<CSS::CSSStyleDeclaration const> Animatable::cached_animation_name_source(Optional<CSS::Selector::PseudoElement::Type> pseudo_element) const
{
if (pseudo_element.has_value())
return m_cached_animation_name_source[to_underlying(pseudo_element.value()) + 1];
return m_cached_animation_name_source[0];
}
void Animatable::set_cached_animation_name_source(JS::GCPtr<CSS::CSSStyleDeclaration const> value, Optional<CSS::Selector::PseudoElement::Type> pseudo_element)
void Animatable::set_cached_animation_name_source(GC::Ptr<CSS::CSSStyleDeclaration const> value, Optional<CSS::Selector::PseudoElement::Type> pseudo_element)
{
if (pseudo_element.has_value()) {
m_cached_animation_name_source[to_underlying(pseudo_element.value()) + 1] = value;
@ -201,14 +201,14 @@ void Animatable::set_cached_animation_name_source(JS::GCPtr<CSS::CSSStyleDeclara
}
}
JS::GCPtr<Animations::Animation> Animatable::cached_animation_name_animation(Optional<CSS::Selector::PseudoElement::Type> pseudo_element) const
GC::Ptr<Animations::Animation> Animatable::cached_animation_name_animation(Optional<CSS::Selector::PseudoElement::Type> pseudo_element) const
{
if (pseudo_element.has_value())
return m_cached_animation_name_animation[to_underlying(pseudo_element.value()) + 1];
return m_cached_animation_name_animation[0];
}
void Animatable::set_cached_animation_name_animation(JS::GCPtr<Animations::Animation> value, Optional<CSS::Selector::PseudoElement::Type> pseudo_element)
void Animatable::set_cached_animation_name_animation(GC::Ptr<Animations::Animation> value, Optional<CSS::Selector::PseudoElement::Type> pseudo_element)
{
if (pseudo_element.has_value()) {
m_cached_animation_name_animation[to_underlying(pseudo_element.value()) + 1] = value;

View file

@ -20,7 +20,7 @@ namespace Web::Animations {
// https://drafts.csswg.org/web-animations-1/#dictdef-keyframeanimationoptions
struct KeyframeAnimationOptions : public KeyframeEffectOptions {
FlyString id { ""_fly_string };
Optional<JS::GCPtr<AnimationTimeline>> timeline;
Optional<GC::Ptr<AnimationTimeline>> timeline;
};
// https://drafts.csswg.org/web-animations-1/#dictdef-getanimationsoptions
@ -40,43 +40,43 @@ public:
virtual ~Animatable() = default;
WebIDL::ExceptionOr<JS::NonnullGCPtr<Animation>> animate(Optional<JS::Handle<JS::Object>> keyframes, Variant<Empty, double, KeyframeAnimationOptions> options = {});
WebIDL::ExceptionOr<Vector<JS::NonnullGCPtr<Animation>>> get_animations(Optional<GetAnimationsOptions> options = {});
WebIDL::ExceptionOr<Vector<JS::NonnullGCPtr<Animation>>> get_animations_internal(Optional<GetAnimationsOptions> options = {});
WebIDL::ExceptionOr<GC::Ref<Animation>> animate(Optional<GC::Root<JS::Object>> keyframes, Variant<Empty, double, KeyframeAnimationOptions> options = {});
WebIDL::ExceptionOr<Vector<GC::Ref<Animation>>> get_animations(Optional<GetAnimationsOptions> options = {});
WebIDL::ExceptionOr<Vector<GC::Ref<Animation>>> get_animations_internal(Optional<GetAnimationsOptions> options = {});
void associate_with_animation(JS::NonnullGCPtr<Animation>);
void disassociate_with_animation(JS::NonnullGCPtr<Animation>);
void associate_with_animation(GC::Ref<Animation>);
void disassociate_with_animation(GC::Ref<Animation>);
JS::GCPtr<CSS::CSSStyleDeclaration const> cached_animation_name_source(Optional<CSS::Selector::PseudoElement::Type>) const;
void set_cached_animation_name_source(JS::GCPtr<CSS::CSSStyleDeclaration const> value, Optional<CSS::Selector::PseudoElement::Type>);
GC::Ptr<CSS::CSSStyleDeclaration const> cached_animation_name_source(Optional<CSS::Selector::PseudoElement::Type>) const;
void set_cached_animation_name_source(GC::Ptr<CSS::CSSStyleDeclaration const> value, Optional<CSS::Selector::PseudoElement::Type>);
JS::GCPtr<Animations::Animation> cached_animation_name_animation(Optional<CSS::Selector::PseudoElement::Type>) const;
void set_cached_animation_name_animation(JS::GCPtr<Animations::Animation> value, Optional<CSS::Selector::PseudoElement::Type>);
GC::Ptr<Animations::Animation> cached_animation_name_animation(Optional<CSS::Selector::PseudoElement::Type>) const;
void set_cached_animation_name_animation(GC::Ptr<Animations::Animation> value, Optional<CSS::Selector::PseudoElement::Type>);
JS::GCPtr<CSS::CSSStyleDeclaration const> cached_transition_property_source() const { return m_cached_transition_property_source; }
void set_cached_transition_property_source(JS::GCPtr<CSS::CSSStyleDeclaration const> value) { m_cached_transition_property_source = value; }
GC::Ptr<CSS::CSSStyleDeclaration const> cached_transition_property_source() const { return m_cached_transition_property_source; }
void set_cached_transition_property_source(GC::Ptr<CSS::CSSStyleDeclaration const> value) { m_cached_transition_property_source = value; }
void add_transitioned_properties(Vector<Vector<CSS::PropertyID>> properties, CSS::StyleValueVector delays, CSS::StyleValueVector durations, CSS::StyleValueVector timing_functions);
Optional<TransitionAttributes const&> property_transition_attributes(CSS::PropertyID) const;
void set_transition(CSS::PropertyID, JS::NonnullGCPtr<CSS::CSSTransition>);
void set_transition(CSS::PropertyID, GC::Ref<CSS::CSSTransition>);
void remove_transition(CSS::PropertyID);
JS::GCPtr<CSS::CSSTransition> property_transition(CSS::PropertyID) const;
GC::Ptr<CSS::CSSTransition> property_transition(CSS::PropertyID) const;
void clear_transitions();
protected:
void visit_edges(JS::Cell::Visitor&);
private:
Vector<JS::NonnullGCPtr<Animation>> m_associated_animations;
Vector<GC::Ref<Animation>> m_associated_animations;
bool m_is_sorted_by_composite_order { true };
Array<JS::GCPtr<CSS::CSSStyleDeclaration const>, to_underlying(CSS::Selector::PseudoElement::Type::KnownPseudoElementCount) + 1> m_cached_animation_name_source;
Array<JS::GCPtr<Animations::Animation>, to_underlying(CSS::Selector::PseudoElement::Type::KnownPseudoElementCount) + 1> m_cached_animation_name_animation;
Array<GC::Ptr<CSS::CSSStyleDeclaration const>, to_underlying(CSS::Selector::PseudoElement::Type::KnownPseudoElementCount) + 1> m_cached_animation_name_source;
Array<GC::Ptr<Animations::Animation>, to_underlying(CSS::Selector::PseudoElement::Type::KnownPseudoElementCount) + 1> m_cached_animation_name_animation;
HashMap<CSS::PropertyID, size_t> m_transition_attribute_indices;
Vector<TransitionAttributes> m_transition_attributes;
JS::GCPtr<CSS::CSSStyleDeclaration const> m_cached_transition_property_source;
HashMap<CSS::PropertyID, JS::NonnullGCPtr<CSS::CSSTransition>> m_associated_transitions;
GC::Ptr<CSS::CSSStyleDeclaration const> m_cached_transition_property_source;
HashMap<CSS::PropertyID, GC::Ref<CSS::CSSTransition>> m_associated_transitions;
};
}

View file

@ -22,10 +22,10 @@
namespace Web::Animations {
JS_DEFINE_ALLOCATOR(Animation);
GC_DEFINE_ALLOCATOR(Animation);
// https://www.w3.org/TR/web-animations-1/#dom-animation-animation
JS::NonnullGCPtr<Animation> Animation::create(JS::Realm& realm, JS::GCPtr<AnimationEffect> effect, Optional<JS::GCPtr<AnimationTimeline>> timeline)
GC::Ref<Animation> Animation::create(JS::Realm& realm, GC::Ptr<AnimationEffect> effect, Optional<GC::Ptr<AnimationTimeline>> timeline)
{
// 1. Let animation be a new Animation object.
auto animation = realm.create<Animation>(realm);
@ -45,13 +45,13 @@ JS::NonnullGCPtr<Animation> Animation::create(JS::Realm& realm, JS::GCPtr<Animat
return animation;
}
WebIDL::ExceptionOr<JS::NonnullGCPtr<Animation>> Animation::construct_impl(JS::Realm& realm, JS::GCPtr<AnimationEffect> effect, Optional<JS::GCPtr<AnimationTimeline>> timeline)
WebIDL::ExceptionOr<GC::Ref<Animation>> Animation::construct_impl(JS::Realm& realm, GC::Ptr<AnimationEffect> effect, Optional<GC::Ptr<AnimationTimeline>> timeline)
{
return create(realm, effect, timeline);
}
// https://www.w3.org/TR/web-animations-1/#animation-set-the-associated-effect-of-an-animation
void Animation::set_effect(JS::GCPtr<AnimationEffect> new_effect)
void Animation::set_effect(GC::Ptr<AnimationEffect> new_effect)
{
// Setting this attribute updates the objects associated effect using the procedure to set the associated effect of
// an animation.
@ -97,7 +97,7 @@ void Animation::set_effect(JS::GCPtr<AnimationEffect> new_effect)
}
// https://www.w3.org/TR/web-animations-1/#animation-set-the-timeline-of-an-animation
void Animation::set_timeline(JS::GCPtr<AnimationTimeline> new_timeline)
void Animation::set_timeline(GC::Ptr<AnimationTimeline> new_timeline)
{
// Setting this attribute updates the objects timeline using the procedure to set the timeline of an animation.
@ -376,37 +376,37 @@ void Animation::set_replace_state(Bindings::AnimationReplaceState value)
}
// https://www.w3.org/TR/web-animations-1/#dom-animation-onfinish
JS::GCPtr<WebIDL::CallbackType> Animation::onfinish()
GC::Ptr<WebIDL::CallbackType> Animation::onfinish()
{
return event_handler_attribute(HTML::EventNames::finish);
}
// https://www.w3.org/TR/web-animations-1/#dom-animation-onfinish
void Animation::set_onfinish(JS::GCPtr<WebIDL::CallbackType> event_handler)
void Animation::set_onfinish(GC::Ptr<WebIDL::CallbackType> event_handler)
{
set_event_handler_attribute(HTML::EventNames::finish, event_handler);
}
// https://www.w3.org/TR/web-animations-1/#dom-animation-oncancel
JS::GCPtr<WebIDL::CallbackType> Animation::oncancel()
GC::Ptr<WebIDL::CallbackType> Animation::oncancel()
{
return event_handler_attribute(HTML::EventNames::cancel);
}
// https://www.w3.org/TR/web-animations-1/#dom-animation-oncancel
void Animation::set_oncancel(JS::GCPtr<WebIDL::CallbackType> event_handler)
void Animation::set_oncancel(GC::Ptr<WebIDL::CallbackType> event_handler)
{
set_event_handler_attribute(HTML::EventNames::cancel, event_handler);
}
// https://www.w3.org/TR/web-animations-1/#dom-animation-onremove
JS::GCPtr<WebIDL::CallbackType> Animation::onremove()
GC::Ptr<WebIDL::CallbackType> Animation::onremove()
{
return event_handler_attribute(HTML::EventNames::remove);
}
// https://www.w3.org/TR/web-animations-1/#dom-animation-onremove
void Animation::set_onremove(JS::GCPtr<WebIDL::CallbackType> event_handler)
void Animation::set_onremove(GC::Ptr<WebIDL::CallbackType> event_handler)
{
set_event_handler_attribute(HTML::EventNames::remove, event_handler);
}
@ -463,7 +463,7 @@ void Animation::cancel(ShouldInvalidate should_invalidate)
scheduled_event_time = m_timeline->convert_a_timeline_time_to_an_origin_relative_time(m_timeline->current_time());
document->append_pending_animation_event({ cancel_event, *this, *this, scheduled_event_time });
} else {
HTML::queue_global_task(HTML::Task::Source::DOMManipulation, realm.global_object(), JS::create_heap_function(heap(), [this, cancel_event]() {
HTML::queue_global_task(HTML::Task::Source::DOMManipulation, realm.global_object(), GC::create_function(heap(), [this, cancel_event]() {
dispatch_event(cancel_event);
}));
}
@ -918,7 +918,7 @@ Optional<double> Animation::convert_a_timeline_time_to_an_origin_relative_time(O
}
// https://www.w3.org/TR/web-animations-1/#animation-document-for-timing
JS::GCPtr<DOM::Document> Animation::document_for_timing() const
GC::Ptr<DOM::Document> Animation::document_for_timing() const
{
// An animations document for timing is the Document with which its timeline is associated. If an animation is not
// associated with a timeline, or its timeline is not associated with a document, then it has no document for
@ -1105,7 +1105,7 @@ void Animation::update_finished_state(DidSeek did_seek, SynchronouslyNotify sync
// steps:
if (current_finished_state && !m_is_finished) {
// 1. Let finish notification steps refer to the following procedure:
auto finish_notification_steps = JS::create_heap_function(heap(), [this, &realm]() {
auto finish_notification_steps = GC::create_function(heap(), [this, &realm]() {
// 1. If animations play state is not equal to finished, abort these steps.
if (play_state() != Bindings::AnimationPlayState::Finished)
return;
@ -1147,7 +1147,7 @@ void Animation::update_finished_state(DidSeek did_seek, SynchronouslyNotify sync
// Manually create a task so its ID can be saved
auto& document = verify_cast<HTML::Window>(realm.global_object()).associated_document();
auto task = HTML::Task::create(vm(), HTML::Task::Source::DOMManipulation, &document,
JS::create_heap_function(heap(), [this, finish_event]() {
GC::create_function(heap(), [this, finish_event]() {
dispatch_event(finish_event);
}));
m_pending_finish_microtask_id = task->id();
@ -1304,7 +1304,7 @@ void Animation::run_pending_pause_task()
update_finished_state(DidSeek::No, SynchronouslyNotify::No);
}
JS::NonnullGCPtr<WebIDL::Promise> Animation::current_ready_promise() const
GC::Ref<WebIDL::Promise> Animation::current_ready_promise() const
{
if (!m_current_ready_promise) {
// The current ready promise is initially a resolved Promise created using the procedure to create a new
@ -1315,7 +1315,7 @@ JS::NonnullGCPtr<WebIDL::Promise> Animation::current_ready_promise() const
return *m_current_ready_promise;
}
JS::NonnullGCPtr<WebIDL::Promise> Animation::current_finished_promise() const
GC::Ref<WebIDL::Promise> Animation::current_finished_promise() const
{
if (!m_current_finished_promise) {
// The current finished promise is initially a pending Promise object.

View file

@ -24,20 +24,20 @@ enum class AnimationClass {
// https://www.w3.org/TR/web-animations-1/#the-animation-interface
class Animation : public DOM::EventTarget {
WEB_PLATFORM_OBJECT(Animation, DOM::EventTarget);
JS_DECLARE_ALLOCATOR(Animation);
GC_DECLARE_ALLOCATOR(Animation);
public:
static JS::NonnullGCPtr<Animation> create(JS::Realm&, JS::GCPtr<AnimationEffect>, Optional<JS::GCPtr<AnimationTimeline>>);
static WebIDL::ExceptionOr<JS::NonnullGCPtr<Animation>> construct_impl(JS::Realm&, JS::GCPtr<AnimationEffect>, Optional<JS::GCPtr<AnimationTimeline>>);
static GC::Ref<Animation> create(JS::Realm&, GC::Ptr<AnimationEffect>, Optional<GC::Ptr<AnimationTimeline>>);
static WebIDL::ExceptionOr<GC::Ref<Animation>> construct_impl(JS::Realm&, GC::Ptr<AnimationEffect>, Optional<GC::Ptr<AnimationTimeline>>);
FlyString const& id() const { return m_id; }
void set_id(FlyString value) { m_id = move(value); }
JS::GCPtr<AnimationEffect> effect() const { return m_effect; }
void set_effect(JS::GCPtr<AnimationEffect>);
GC::Ptr<AnimationEffect> effect() const { return m_effect; }
void set_effect(GC::Ptr<AnimationEffect>);
JS::GCPtr<AnimationTimeline> timeline() const { return m_timeline; }
void set_timeline(JS::GCPtr<AnimationTimeline>);
GC::Ptr<AnimationTimeline> timeline() const { return m_timeline; }
void set_timeline(GC::Ptr<AnimationTimeline>);
Optional<double> const& start_time() const { return m_start_time; }
void set_start_time(Optional<double> const&);
@ -60,18 +60,18 @@ public:
bool pending() const { return m_pending_play_task == TaskState::Scheduled || m_pending_pause_task == TaskState::Scheduled; }
// https://www.w3.org/TR/web-animations-1/#dom-animation-ready
JS::NonnullGCPtr<WebIDL::Promise> ready() const { return current_ready_promise(); }
GC::Ref<WebIDL::Promise> ready() const { return current_ready_promise(); }
// https://www.w3.org/TR/web-animations-1/#dom-animation-finished
JS::NonnullGCPtr<WebIDL::Promise> finished() const { return current_finished_promise(); }
GC::Ref<WebIDL::Promise> finished() const { return current_finished_promise(); }
bool is_finished() const { return m_is_finished; }
JS::GCPtr<WebIDL::CallbackType> onfinish();
void set_onfinish(JS::GCPtr<WebIDL::CallbackType>);
JS::GCPtr<WebIDL::CallbackType> oncancel();
void set_oncancel(JS::GCPtr<WebIDL::CallbackType>);
JS::GCPtr<WebIDL::CallbackType> onremove();
void set_onremove(JS::GCPtr<WebIDL::CallbackType>);
GC::Ptr<WebIDL::CallbackType> onfinish();
void set_onfinish(GC::Ptr<WebIDL::CallbackType>);
GC::Ptr<WebIDL::CallbackType> oncancel();
void set_oncancel(GC::Ptr<WebIDL::CallbackType>);
GC::Ptr<WebIDL::CallbackType> onremove();
void set_onremove(GC::Ptr<WebIDL::CallbackType>);
enum class AutoRewind {
Yes,
@ -93,7 +93,7 @@ public:
Optional<double> convert_an_animation_time_to_timeline_time(Optional<double>) const;
Optional<double> convert_a_timeline_time_to_an_origin_relative_time(Optional<double>) const;
JS::GCPtr<DOM::Document> document_for_timing() const;
GC::Ptr<DOM::Document> document_for_timing() const;
void notify_timeline_time_did_change();
void effect_timing_changed(Badge<AnimationEffect>);
@ -101,11 +101,11 @@ public:
virtual bool is_css_animation() const { return false; }
virtual bool is_css_transition() const { return false; }
JS::GCPtr<DOM::Element> owning_element() const { return m_owning_element; }
void set_owning_element(JS::GCPtr<DOM::Element> value) { m_owning_element = value; }
GC::Ptr<DOM::Element> owning_element() const { return m_owning_element; }
void set_owning_element(GC::Ptr<DOM::Element> value) { m_owning_element = value; }
virtual AnimationClass animation_class() const { return AnimationClass::None; }
virtual Optional<int> class_specific_composite_order(JS::NonnullGCPtr<Animation>) const { return {}; }
virtual Optional<int> class_specific_composite_order(GC::Ref<Animation>) const { return {}; }
unsigned int global_animation_list_order() const { return m_global_animation_list_order; }
@ -144,8 +144,8 @@ private:
void run_pending_play_task();
void run_pending_pause_task();
JS::NonnullGCPtr<WebIDL::Promise> current_ready_promise() const;
JS::NonnullGCPtr<WebIDL::Promise> current_finished_promise() const;
GC::Ref<WebIDL::Promise> current_ready_promise() const;
GC::Ref<WebIDL::Promise> current_finished_promise() const;
void invalidate_effect();
@ -156,10 +156,10 @@ private:
unsigned int m_global_animation_list_order { 0 };
// https://www.w3.org/TR/web-animations-1/#dom-animation-effect
JS::GCPtr<AnimationEffect> m_effect;
GC::Ptr<AnimationEffect> m_effect;
// https://www.w3.org/TR/web-animations-1/#dom-animation-timeline
JS::GCPtr<AnimationTimeline> m_timeline;
GC::Ptr<AnimationTimeline> m_timeline;
// https://www.w3.org/TR/web-animations-1/#animation-start-time
Optional<double> m_start_time {};
@ -181,10 +181,10 @@ private:
// Note: The following promises are initialized lazily to avoid constructing them outside of an execution context
// https://www.w3.org/TR/web-animations-1/#current-ready-promise
mutable JS::GCPtr<WebIDL::Promise> m_current_ready_promise;
mutable GC::Ptr<WebIDL::Promise> m_current_ready_promise;
// https://www.w3.org/TR/web-animations-1/#current-finished-promise
mutable JS::GCPtr<WebIDL::Promise> m_current_finished_promise;
mutable GC::Ptr<WebIDL::Promise> m_current_finished_promise;
bool m_is_finished { false };
// https://www.w3.org/TR/web-animations-1/#pending-play-task
@ -194,7 +194,7 @@ private:
TaskState m_pending_pause_task { TaskState::None };
// https://www.w3.org/TR/css-animations-2/#owning-element-section
JS::GCPtr<DOM::Element> m_owning_element;
GC::Ptr<DOM::Element> m_owning_element;
Optional<HTML::TaskID> m_pending_finish_microtask_id;

View file

@ -15,7 +15,7 @@
namespace Web::Animations {
JS_DEFINE_ALLOCATOR(AnimationEffect);
GC_DEFINE_ALLOCATOR(AnimationEffect);
Bindings::FillMode css_fill_mode_to_bindings_fill_mode(CSS::AnimationFillMode mode)
{
@ -201,7 +201,7 @@ WebIDL::ExceptionOr<void> AnimationEffect::update_timing(OptionalEffectTiming ti
return {};
}
void AnimationEffect::set_associated_animation(JS::GCPtr<Animation> value)
void AnimationEffect::set_associated_animation(GC::Ptr<Animation> value)
{
m_associated_animation = value;
}

View file

@ -62,7 +62,7 @@ Bindings::PlaybackDirection css_animation_direction_to_bindings_playback_directi
// https://www.w3.org/TR/web-animations-1/#the-animationeffect-interface
class AnimationEffect : public Bindings::PlatformObject {
WEB_PLATFORM_OBJECT(AnimationEffect, Bindings::PlatformObject);
JS_DECLARE_ALLOCATOR(AnimationEffect);
GC_DECLARE_ALLOCATOR(AnimationEffect);
public:
static RefPtr<CSS::CSSStyleValue const> parse_easing_string(JS::Realm& realm, StringView value);
@ -95,8 +95,8 @@ public:
CSS::EasingStyleValue::Function const& timing_function() { return m_timing_function; }
void set_timing_function(CSS::EasingStyleValue::Function value) { m_timing_function = move(value); }
JS::GCPtr<Animation> associated_animation() const { return m_associated_animation; }
void set_associated_animation(JS::GCPtr<Animation> value);
GC::Ptr<Animation> associated_animation() const { return m_associated_animation; }
void set_associated_animation(GC::Ptr<Animation> value);
AnimationDirection animation_direction() const;
@ -175,7 +175,7 @@ protected:
Bindings::PlaybackDirection m_playback_direction { Bindings::PlaybackDirection::Normal };
// https://www.w3.org/TR/web-animations-1/#animation-associated-effect
JS::GCPtr<Animation> m_associated_animation {};
GC::Ptr<Animation> m_associated_animation {};
// https://www.w3.org/TR/web-animations-1/#time-transformations
CSS::EasingStyleValue::Function m_timing_function { CSS::EasingStyleValue::Linear::identity() };

View file

@ -10,15 +10,15 @@
namespace Web::Animations {
JS_DEFINE_ALLOCATOR(AnimationPlaybackEvent);
GC_DEFINE_ALLOCATOR(AnimationPlaybackEvent);
JS::NonnullGCPtr<AnimationPlaybackEvent> AnimationPlaybackEvent::create(JS::Realm& realm, FlyString const& type, AnimationPlaybackEventInit const& event_init)
GC::Ref<AnimationPlaybackEvent> AnimationPlaybackEvent::create(JS::Realm& realm, FlyString const& type, AnimationPlaybackEventInit const& event_init)
{
return realm.create<AnimationPlaybackEvent>(realm, type, event_init);
}
// https://www.w3.org/TR/web-animations-1/#dom-animationplaybackevent-animationplaybackevent
WebIDL::ExceptionOr<JS::NonnullGCPtr<AnimationPlaybackEvent>> AnimationPlaybackEvent::construct_impl(JS::Realm& realm, FlyString const& type, AnimationPlaybackEventInit const& event_init)
WebIDL::ExceptionOr<GC::Ref<AnimationPlaybackEvent>> AnimationPlaybackEvent::construct_impl(JS::Realm& realm, FlyString const& type, AnimationPlaybackEventInit const& event_init)
{
return create(realm, type, event_init);
}

View file

@ -20,11 +20,11 @@ struct AnimationPlaybackEventInit : public DOM::EventInit {
// https://www.w3.org/TR/web-animations-1/#animationplaybackevent
class AnimationPlaybackEvent : public DOM::Event {
WEB_PLATFORM_OBJECT(AnimationPlaybackEvent, DOM::Event);
JS_DECLARE_ALLOCATOR(AnimationPlaybackEvent);
GC_DECLARE_ALLOCATOR(AnimationPlaybackEvent);
public:
[[nodiscard]] static JS::NonnullGCPtr<AnimationPlaybackEvent> create(JS::Realm&, FlyString const& type, AnimationPlaybackEventInit const& event_init = {});
static WebIDL::ExceptionOr<JS::NonnullGCPtr<AnimationPlaybackEvent>> construct_impl(JS::Realm&, FlyString const& type, AnimationPlaybackEventInit const& event_init);
[[nodiscard]] static GC::Ref<AnimationPlaybackEvent> create(JS::Realm&, FlyString const& type, AnimationPlaybackEventInit const& event_init = {});
static WebIDL::ExceptionOr<GC::Ref<AnimationPlaybackEvent>> construct_impl(JS::Realm&, FlyString const& type, AnimationPlaybackEventInit const& event_init);
virtual ~AnimationPlaybackEvent() override = default;

View file

@ -11,7 +11,7 @@
namespace Web::Animations {
JS_DEFINE_ALLOCATOR(AnimationTimeline);
GC_DEFINE_ALLOCATOR(AnimationTimeline);
void AnimationTimeline::set_current_time(Optional<double> value)
{
@ -28,7 +28,7 @@ void AnimationTimeline::set_current_time(Optional<double> value)
animation->notify_timeline_time_did_change();
}
void AnimationTimeline::set_associated_document(JS::GCPtr<DOM::Document> document)
void AnimationTimeline::set_associated_document(GC::Ptr<DOM::Document> document)
{
if (document)
document->associate_with_timeline(*this);

View file

@ -13,14 +13,14 @@ namespace Web::Animations {
// https://www.w3.org/TR/web-animations-1/#animationtimeline
class AnimationTimeline : public Bindings::PlatformObject {
WEB_PLATFORM_OBJECT(AnimationTimeline, Bindings::PlatformObject);
JS_DECLARE_ALLOCATOR(AnimationTimeline);
GC_DECLARE_ALLOCATOR(AnimationTimeline);
public:
Optional<double> current_time() const { return m_current_time; }
virtual void set_current_time(Optional<double>);
JS::GCPtr<DOM::Document> associated_document() const { return m_associated_document; }
void set_associated_document(JS::GCPtr<DOM::Document>);
GC::Ptr<DOM::Document> associated_document() const { return m_associated_document; }
void set_associated_document(GC::Ptr<DOM::Document>);
virtual bool is_inactive() const;
bool is_monotonically_increasing() const { return m_is_monotonically_increasing; }
@ -29,9 +29,9 @@ public:
virtual Optional<double> convert_a_timeline_time_to_an_origin_relative_time(Optional<double>) { VERIFY_NOT_REACHED(); }
virtual bool can_convert_a_timeline_time_to_an_origin_relative_time() const { return false; }
void associate_with_animation(JS::NonnullGCPtr<Animation> value) { m_associated_animations.set(value); }
void disassociate_with_animation(JS::NonnullGCPtr<Animation> value) { m_associated_animations.remove(value); }
HashTable<JS::NonnullGCPtr<Animation>> const& associated_animations() const { return m_associated_animations; }
void associate_with_animation(GC::Ref<Animation> value) { m_associated_animations.set(value); }
void disassociate_with_animation(GC::Ref<Animation> value) { m_associated_animations.remove(value); }
HashTable<GC::Ref<Animation>> const& associated_animations() const { return m_associated_animations; }
protected:
AnimationTimeline(JS::Realm&);
@ -47,9 +47,9 @@ protected:
bool m_is_monotonically_increasing { true };
// https://www.w3.org/TR/web-animations-1/#timeline-associated-with-a-document
JS::GCPtr<DOM::Document> m_associated_document {};
GC::Ptr<DOM::Document> m_associated_document {};
HashTable<JS::NonnullGCPtr<Animation>> m_associated_animations {};
HashTable<GC::Ref<Animation>> m_associated_animations {};
};
}

View file

@ -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/Animations/DocumentTimeline.h>
#include <LibWeb/Bindings/DocumentTimelinePrototype.h>
@ -15,9 +15,9 @@
namespace Web::Animations {
JS_DEFINE_ALLOCATOR(DocumentTimeline);
GC_DEFINE_ALLOCATOR(DocumentTimeline);
JS::NonnullGCPtr<DocumentTimeline> DocumentTimeline::create(JS::Realm& realm, DOM::Document& document, HighResolutionTime::DOMHighResTimeStamp origin_time)
GC::Ref<DocumentTimeline> DocumentTimeline::create(JS::Realm& realm, DOM::Document& document, HighResolutionTime::DOMHighResTimeStamp origin_time)
{
auto timeline = realm.create<DocumentTimeline>(realm, document, origin_time);
auto current_time = document.last_animation_frame_timestamp();
@ -32,7 +32,7 @@ JS::NonnullGCPtr<DocumentTimeline> DocumentTimeline::create(JS::Realm& realm, DO
}
// https://www.w3.org/TR/web-animations-1/#dom-documenttimeline-documenttimeline
WebIDL::ExceptionOr<JS::NonnullGCPtr<DocumentTimeline>> DocumentTimeline::construct_impl(JS::Realm& realm, DocumentTimelineOptions options)
WebIDL::ExceptionOr<GC::Ref<DocumentTimeline>> DocumentTimeline::construct_impl(JS::Realm& realm, DocumentTimelineOptions options)
{
// Creates a new DocumentTimeline. The Document with which the timeline is associated is the Document associated
// with the Window that is the current global object.

View file

@ -20,11 +20,11 @@ struct DocumentTimelineOptions {
// https://www.w3.org/TR/web-animations-1/#the-documenttimeline-interface
class DocumentTimeline : public AnimationTimeline {
WEB_PLATFORM_OBJECT(DocumentTimeline, AnimationTimeline);
JS_DECLARE_ALLOCATOR(DocumentTimeline);
GC_DECLARE_ALLOCATOR(DocumentTimeline);
public:
static JS::NonnullGCPtr<DocumentTimeline> create(JS::Realm&, DOM::Document&, HighResolutionTime::DOMHighResTimeStamp origin_time);
static WebIDL::ExceptionOr<JS::NonnullGCPtr<DocumentTimeline>> construct_impl(JS::Realm&, DocumentTimelineOptions options = {});
static GC::Ref<DocumentTimeline> create(JS::Realm&, DOM::Document&, HighResolutionTime::DOMHighResTimeStamp origin_time);
static WebIDL::ExceptionOr<GC::Ref<DocumentTimeline>> construct_impl(JS::Realm&, DocumentTimelineOptions options = {});
virtual void set_current_time(Optional<double> current_time) override;
virtual bool is_inactive() const override;

View file

@ -18,7 +18,7 @@
namespace Web::Animations {
JS_DEFINE_ALLOCATOR(KeyframeEffect);
GC_DEFINE_ALLOCATOR(KeyframeEffect);
template<typename T>
WebIDL::ExceptionOr<Variant<T, Vector<T>>> convert_value_to_maybe_list(JS::Realm& realm, JS::Value value, Function<WebIDL::ExceptionOr<T>(JS::Value)>& value_converter)
@ -312,7 +312,7 @@ static bool is_loosely_sorted_by_offset(Vector<BaseKeyframe> const& keyframes)
}
// https://www.w3.org/TR/web-animations-1/#process-a-keyframes-argument
static WebIDL::ExceptionOr<Vector<BaseKeyframe>> process_a_keyframes_argument(JS::Realm& realm, JS::GCPtr<JS::Object> object)
static WebIDL::ExceptionOr<Vector<BaseKeyframe>> process_a_keyframes_argument(JS::Realm& realm, GC::Ptr<JS::Object> object)
{
auto& vm = realm.vm();
@ -617,7 +617,7 @@ void KeyframeEffect::generate_initial_and_final_frames(RefPtr<KeyFrameSet> keyfr
}
// https://www.w3.org/TR/web-animations-1/#animation-composite-order
int KeyframeEffect::composite_order(JS::NonnullGCPtr<KeyframeEffect> a, JS::NonnullGCPtr<KeyframeEffect> b)
int KeyframeEffect::composite_order(GC::Ref<KeyframeEffect> a, GC::Ref<KeyframeEffect> b)
{
// 1. Let the associated animation of an animation effect be the animation associated with the animation effect.
auto a_animation = a->associated_animation();
@ -646,16 +646,16 @@ int KeyframeEffect::composite_order(JS::NonnullGCPtr<KeyframeEffect> a, JS::Nonn
return a_animation->global_animation_list_order() - b_animation->global_animation_list_order();
}
JS::NonnullGCPtr<KeyframeEffect> KeyframeEffect::create(JS::Realm& realm)
GC::Ref<KeyframeEffect> KeyframeEffect::create(JS::Realm& realm)
{
return realm.create<KeyframeEffect>(realm);
}
// https://www.w3.org/TR/web-animations-1/#dom-keyframeeffect-keyframeeffect
WebIDL::ExceptionOr<JS::NonnullGCPtr<KeyframeEffect>> KeyframeEffect::construct_impl(
WebIDL::ExceptionOr<GC::Ref<KeyframeEffect>> KeyframeEffect::construct_impl(
JS::Realm& realm,
JS::Handle<DOM::Element> const& target,
Optional<JS::Handle<JS::Object>> const& keyframes,
GC::Root<DOM::Element> const& target,
Optional<GC::Root<JS::Object>> const& keyframes,
Variant<double, KeyframeEffectOptions> options)
{
// 1. Create a new KeyframeEffect object, effect.
@ -717,7 +717,7 @@ WebIDL::ExceptionOr<JS::NonnullGCPtr<KeyframeEffect>> KeyframeEffect::construct_
}
// https://www.w3.org/TR/web-animations-1/#dom-keyframeeffect-keyframeeffect-source
WebIDL::ExceptionOr<JS::NonnullGCPtr<KeyframeEffect>> KeyframeEffect::construct_impl(JS::Realm& realm, JS::NonnullGCPtr<KeyframeEffect> source)
WebIDL::ExceptionOr<GC::Ref<KeyframeEffect>> KeyframeEffect::construct_impl(JS::Realm& realm, GC::Ref<KeyframeEffect> source)
{
// 1. Create a new KeyframeEffect object, effect.
auto effect = realm.create<KeyframeEffect>(realm);
@ -798,7 +798,7 @@ Optional<CSS::Selector::PseudoElement::Type> KeyframeEffect::pseudo_element_type
}
// https://www.w3.org/TR/web-animations-1/#dom-keyframeeffect-getkeyframes
WebIDL::ExceptionOr<JS::MarkedVector<JS::Object*>> KeyframeEffect::get_keyframes()
WebIDL::ExceptionOr<GC::MarkedVector<JS::Object*>> KeyframeEffect::get_keyframes()
{
if (m_keyframe_objects.size() != m_keyframes.size()) {
auto& vm = this->vm();
@ -833,17 +833,17 @@ WebIDL::ExceptionOr<JS::MarkedVector<JS::Object*>> KeyframeEffect::get_keyframes
}
}
JS::MarkedVector<JS::Object*> keyframes { heap() };
GC::MarkedVector<JS::Object*> keyframes { heap() };
for (auto const& keyframe : m_keyframe_objects)
keyframes.append(keyframe);
return keyframes;
}
// https://www.w3.org/TR/web-animations-1/#dom-keyframeeffect-setkeyframes
WebIDL::ExceptionOr<void> KeyframeEffect::set_keyframes(Optional<JS::Handle<JS::Object>> const& keyframe_object)
WebIDL::ExceptionOr<void> KeyframeEffect::set_keyframes(Optional<GC::Root<JS::Object>> const& keyframe_object)
{
m_keyframe_objects.clear();
m_keyframes = TRY(process_a_keyframes_argument(realm(), keyframe_object.has_value() ? JS::GCPtr { keyframe_object->ptr() } : JS::GCPtr<Object> {}));
m_keyframes = TRY(process_a_keyframes_argument(realm(), keyframe_object.has_value() ? GC::Ptr { keyframe_object->ptr() } : GC::Ptr<Object> {}));
// FIXME: After processing the keyframe argument, we need to turn the set of keyframes into a set of computed
// keyframes using the procedure outlined in the second half of
// https://www.w3.org/TR/web-animations-1/#calculating-computed-keyframes. For now, just compute the

View file

@ -56,7 +56,7 @@ struct BaseKeyframe {
// https://www.w3.org/TR/web-animations-1/#the-keyframeeffect-interface
class KeyframeEffect : public AnimationEffect {
WEB_PLATFORM_OBJECT(KeyframeEffect, AnimationEffect);
JS_DECLARE_ALLOCATOR(KeyframeEffect);
GC_DECLARE_ALLOCATOR(KeyframeEffect);
public:
constexpr static double AnimationKeyFrameKeyScaleFactor = 1000.0; // 0..100000
@ -72,17 +72,17 @@ public:
};
static void generate_initial_and_final_frames(RefPtr<KeyFrameSet>, HashTable<CSS::PropertyID> const& animated_properties);
static int composite_order(JS::NonnullGCPtr<KeyframeEffect>, JS::NonnullGCPtr<KeyframeEffect>);
static int composite_order(GC::Ref<KeyframeEffect>, GC::Ref<KeyframeEffect>);
static JS::NonnullGCPtr<KeyframeEffect> create(JS::Realm&);
static GC::Ref<KeyframeEffect> create(JS::Realm&);
static WebIDL::ExceptionOr<JS::NonnullGCPtr<KeyframeEffect>> construct_impl(
static WebIDL::ExceptionOr<GC::Ref<KeyframeEffect>> construct_impl(
JS::Realm&,
JS::Handle<DOM::Element> const& target,
Optional<JS::Handle<JS::Object>> const& keyframes,
GC::Root<DOM::Element> const& target,
Optional<GC::Root<JS::Object>> const& keyframes,
Variant<double, KeyframeEffectOptions> options = KeyframeEffectOptions {});
static WebIDL::ExceptionOr<JS::NonnullGCPtr<KeyframeEffect>> construct_impl(JS::Realm&, JS::NonnullGCPtr<KeyframeEffect> source);
static WebIDL::ExceptionOr<GC::Ref<KeyframeEffect>> construct_impl(JS::Realm&, GC::Ref<KeyframeEffect> source);
DOM::Element* target() const override { return m_target_element; }
void set_target(DOM::Element* target);
@ -97,8 +97,8 @@ public:
Bindings::CompositeOperation composite() const { return m_composite; }
void set_composite(Bindings::CompositeOperation value) { m_composite = value; }
WebIDL::ExceptionOr<JS::MarkedVector<JS::Object*>> get_keyframes();
WebIDL::ExceptionOr<void> set_keyframes(Optional<JS::Handle<JS::Object>> const&);
WebIDL::ExceptionOr<GC::MarkedVector<JS::Object*>> get_keyframes();
WebIDL::ExceptionOr<void> set_keyframes(Optional<GC::Root<JS::Object>> const&);
KeyFrameSet const* key_frame_set() { return m_key_frame_set; }
void set_key_frame_set(RefPtr<KeyFrameSet const> key_frame_set) { m_key_frame_set = key_frame_set; }
@ -118,7 +118,7 @@ private:
virtual void visit_edges(Cell::Visitor&) override;
// https://www.w3.org/TR/web-animations-1/#effect-target-target-element
JS::GCPtr<DOM::Element> m_target_element {};
GC::Ptr<DOM::Element> m_target_element {};
// https://www.w3.org/TR/web-animations-1/#dom-keyframeeffect-pseudoelement
Optional<CSS::Selector::PseudoElement> m_target_pseudo_selector {};
@ -130,7 +130,7 @@ private:
Vector<BaseKeyframe> m_keyframes {};
// A cached version of m_keyframes suitable for returning from get_keyframes()
Vector<JS::NonnullGCPtr<JS::Object>> m_keyframe_objects {};
Vector<GC::Ref<JS::Object>> m_keyframe_objects {};
RefPtr<KeyFrameSet const> m_key_frame_set {};