mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 05:17:35 +00:00
LibWeb: Track an Animation's play/pause task state
This only tracks whether the relevant steps should be executed at some future (but very soon) time. This time will eventually be whenever the "update animations and send events" procedure is invoked.
This commit is contained in:
parent
422f43f4fc
commit
9802995de8
2 changed files with 26 additions and 5 deletions
|
@ -54,10 +54,14 @@ void Animation::set_effect(JS::GCPtr<AnimationEffect> new_effect)
|
||||||
if (new_effect == old_effect)
|
if (new_effect == old_effect)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// FIXME: 3. If animation has a pending pause task, reschedule that task to run as soon as animation is ready.
|
// 3. If animation has a pending pause task, reschedule that task to run as soon as animation is ready.
|
||||||
|
if (m_pending_pause_task == TaskState::Pending)
|
||||||
|
m_pending_pause_task = TaskState::RunAsSoonAsReady;
|
||||||
|
|
||||||
// FIXME: 4. If animation has a pending play task, reschedule that task to run as soon as animation is ready to play
|
// 4. If animation has a pending play task, reschedule that task to run as soon as animation is ready to play ne
|
||||||
// new effect.
|
// effect.
|
||||||
|
if (m_pending_play_task == TaskState::Pending)
|
||||||
|
m_pending_play_task = TaskState::RunAsSoonAsReady;
|
||||||
|
|
||||||
// 5. If new effect is not null and if new effect is the associated effect of another animation, previous animation,
|
// 5. If new effect is not null and if new effect is the associated effect of another animation, previous animation,
|
||||||
// run the procedure to set the associated effect of an animation (this procedure) on previous animation passing
|
// run the procedure to set the associated effect of an animation (this procedure) on previous animation passing
|
||||||
|
@ -143,8 +147,13 @@ void Animation::set_start_time(Optional<double> const& new_start_time)
|
||||||
m_hold_time = previous_current_time;
|
m_hold_time = previous_current_time;
|
||||||
}
|
}
|
||||||
|
|
||||||
// FIXME: 7. If animation has a pending play task or a pending pause task, cancel that task and resolve animation’s
|
// 7. If animation has a pending play task or a pending pause task, cancel that task and resolve animation’s current
|
||||||
// current ready promise with animation.
|
// ready promise with animation.
|
||||||
|
if (m_pending_play_task == TaskState::Pending || m_pending_pause_task == TaskState::Pending) {
|
||||||
|
m_pending_play_task = TaskState::None;
|
||||||
|
m_pending_pause_task = TaskState::None;
|
||||||
|
WebIDL::resolve_promise(realm(), current_ready_promise(), this);
|
||||||
|
}
|
||||||
|
|
||||||
// FIXME: 8. Run the procedure to update an animation’s finished state for animation with the did seek flag set to
|
// FIXME: 8. Run the procedure to update an animation’s finished state for animation with the did seek flag set to
|
||||||
// true, and the synchronously notify flag set to false.
|
// true, and the synchronously notify flag set to false.
|
||||||
|
|
|
@ -55,6 +55,12 @@ protected:
|
||||||
virtual void visit_edges(Cell::Visitor&) override;
|
virtual void visit_edges(Cell::Visitor&) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
enum class TaskState {
|
||||||
|
None,
|
||||||
|
Pending,
|
||||||
|
RunAsSoonAsReady,
|
||||||
|
};
|
||||||
|
|
||||||
void apply_any_pending_playback_rate();
|
void apply_any_pending_playback_rate();
|
||||||
|
|
||||||
JS::NonnullGCPtr<WebIDL::Promise> current_ready_promise() const;
|
JS::NonnullGCPtr<WebIDL::Promise> current_ready_promise() const;
|
||||||
|
@ -90,6 +96,12 @@ private:
|
||||||
|
|
||||||
// https://www.w3.org/TR/web-animations-1/#current-finished-promise
|
// https://www.w3.org/TR/web-animations-1/#current-finished-promise
|
||||||
mutable JS::GCPtr<WebIDL::Promise> m_current_finished_promise;
|
mutable JS::GCPtr<WebIDL::Promise> m_current_finished_promise;
|
||||||
|
|
||||||
|
// https://www.w3.org/TR/web-animations-1/#pending-play-task
|
||||||
|
TaskState m_pending_play_task { TaskState::None };
|
||||||
|
|
||||||
|
// https://www.w3.org/TR/web-animations-1/#pending-pause-task
|
||||||
|
TaskState m_pending_pause_task { TaskState::None };
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue