diff --git a/Userland/Libraries/LibWeb/Animations/Animation.cpp b/Userland/Libraries/LibWeb/Animations/Animation.cpp index 625f038e8f..4902b92bf1 100644 --- a/Userland/Libraries/LibWeb/Animations/Animation.cpp +++ b/Userland/Libraries/LibWeb/Animations/Animation.cpp @@ -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::create(JS::Realm& realm, JS::GCPtr effect, JS::GCPtr timeline) +JS::NonnullGCPtr Animation::create(JS::Realm& realm, JS::GCPtr effect, Optional> timeline) { - auto& vm = realm.vm(); - // 1. Let animation be a new Animation object. auto animation = realm.heap().allocate(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::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::create(JS::Realm& realm, JS::GCPtr> Animation::construct_impl(JS::Realm& realm, JS::GCPtr effect, JS::GCPtr timeline) +WebIDL::ExceptionOr> Animation::construct_impl(JS::Realm& realm, JS::GCPtr effect, Optional> timeline) { return create(realm, effect, timeline); } diff --git a/Userland/Libraries/LibWeb/Animations/Animation.h b/Userland/Libraries/LibWeb/Animations/Animation.h index b514f70b4b..212d87fe16 100644 --- a/Userland/Libraries/LibWeb/Animations/Animation.h +++ b/Userland/Libraries/LibWeb/Animations/Animation.h @@ -18,8 +18,8 @@ class Animation : public DOM::EventTarget { JS_DECLARE_ALLOCATOR(Animation); public: - static JS::NonnullGCPtr create(JS::Realm&, JS::GCPtr, JS::GCPtr); - static WebIDL::ExceptionOr> construct_impl(JS::Realm&, JS::GCPtr, JS::GCPtr); + static JS::NonnullGCPtr create(JS::Realm&, JS::GCPtr, Optional>); + static WebIDL::ExceptionOr> construct_impl(JS::Realm&, JS::GCPtr, Optional>); FlyString const& id() const { return m_id; } void set_id(FlyString value) { m_id = move(value); } diff --git a/Userland/Libraries/LibWeb/Animations/Animation.idl b/Userland/Libraries/LibWeb/Animations/Animation.idl index 6df833c909..23c4fe1bf1 100644 --- a/Userland/Libraries/LibWeb/Animations/Animation.idl +++ b/Userland/Libraries/LibWeb/Animations/Animation.idl @@ -6,7 +6,7 @@ [Exposed=Window] interface Animation : EventTarget { constructor(optional AnimationEffect? effect = null, - optional AnimationTimeline? timeline); + [ExplicitNull] optional AnimationTimeline? timeline); attribute DOMString id; attribute AnimationEffect? effect;