mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-07-06 17:11:51 +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
|
@ -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;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue