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

LibWeb: Use [ExplicitNull] in Animation.idl

This commit is contained in:
Matthew Olsson 2024-02-18 10:55:45 -07:00 committed by Tim Flynn
parent 39f5e32ee9
commit cac11ac891
3 changed files with 7 additions and 9 deletions

View file

@ -21,21 +21,19 @@ namespace Web::Animations {
JS_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, JS::GCPtr<AnimationTimeline> timeline)
JS::NonnullGCPtr<Animation> Animation::create(JS::Realm& realm, JS::GCPtr<AnimationEffect> effect, Optional<JS::GCPtr<AnimationTimeline>> timeline)
{
auto& vm = realm.vm();
// 1. Let animation be a new Animation object.
auto animation = realm.heap().allocate<Animation>(realm, realm);
// 2. Run the procedure to set the timeline of an animation on animation passing timeline as the new timeline or, if
// a timeline argument is missing, passing the default document timeline of the Document associated with the
// Window that is the current global object.
if (vm.argument_count() < 2) {
if (!timeline.has_value()) {
auto& window = verify_cast<HTML::Window>(HTML::current_global_object());
timeline = window.associated_document().timeline();
}
animation->set_timeline(timeline);
animation->set_timeline(timeline.release_value());
// 3. Run the procedure to set the associated effect of an animation on animation passing source as the new effect.
animation->set_effect(effect);
@ -43,7 +41,7 @@ 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, JS::GCPtr<AnimationTimeline> timeline)
WebIDL::ExceptionOr<JS::NonnullGCPtr<Animation>> Animation::construct_impl(JS::Realm& realm, JS::GCPtr<AnimationEffect> effect, Optional<JS::GCPtr<AnimationTimeline>> timeline)
{
return create(realm, effect, timeline);
}