mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 05:07:45 +00:00
LibWeb: Use [ExplicitNull] in Animation.idl
This commit is contained in:
parent
39f5e32ee9
commit
cac11ac891
3 changed files with 7 additions and 9 deletions
|
@ -21,21 +21,19 @@ namespace Web::Animations {
|
||||||
JS_DEFINE_ALLOCATOR(Animation);
|
JS_DEFINE_ALLOCATOR(Animation);
|
||||||
|
|
||||||
// https://www.w3.org/TR/web-animations-1/#dom-animation-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.
|
// 1. Let animation be a new Animation object.
|
||||||
auto animation = realm.heap().allocate<Animation>(realm, realm);
|
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
|
// 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
|
// a timeline argument is missing, passing the default document timeline of the Document associated with the
|
||||||
// Window that is the current global object.
|
// 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());
|
auto& window = verify_cast<HTML::Window>(HTML::current_global_object());
|
||||||
timeline = window.associated_document().timeline();
|
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.
|
// 3. Run the procedure to set the associated effect of an animation on animation passing source as the new effect.
|
||||||
animation->set_effect(effect);
|
animation->set_effect(effect);
|
||||||
|
@ -43,7 +41,7 @@ JS::NonnullGCPtr<Animation> Animation::create(JS::Realm& realm, JS::GCPtr<Animat
|
||||||
return animation;
|
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);
|
return create(realm, effect, timeline);
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,8 +18,8 @@ class Animation : public DOM::EventTarget {
|
||||||
JS_DECLARE_ALLOCATOR(Animation);
|
JS_DECLARE_ALLOCATOR(Animation);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
static JS::NonnullGCPtr<Animation> create(JS::Realm&, JS::GCPtr<AnimationEffect>, JS::GCPtr<AnimationTimeline>);
|
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>, JS::GCPtr<AnimationTimeline>);
|
static WebIDL::ExceptionOr<JS::NonnullGCPtr<Animation>> construct_impl(JS::Realm&, JS::GCPtr<AnimationEffect>, Optional<JS::GCPtr<AnimationTimeline>>);
|
||||||
|
|
||||||
FlyString const& id() const { return m_id; }
|
FlyString const& id() const { return m_id; }
|
||||||
void set_id(FlyString value) { m_id = move(value); }
|
void set_id(FlyString value) { m_id = move(value); }
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
[Exposed=Window]
|
[Exposed=Window]
|
||||||
interface Animation : EventTarget {
|
interface Animation : EventTarget {
|
||||||
constructor(optional AnimationEffect? effect = null,
|
constructor(optional AnimationEffect? effect = null,
|
||||||
optional AnimationTimeline? timeline);
|
[ExplicitNull] optional AnimationTimeline? timeline);
|
||||||
|
|
||||||
attribute DOMString id;
|
attribute DOMString id;
|
||||||
attribute AnimationEffect? effect;
|
attribute AnimationEffect? effect;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue