mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 09:17:35 +00:00
LibWeb: Combine "pending" and "ASAP" animation task states
It seems that the difference between pending and ASAP in the spec is only to allow the implementation to perform implementation-defined operations between the two states. We don't need to distinguish the two states, so lets just combine them for now.
This commit is contained in:
parent
66859c8cd8
commit
88518c29ca
2 changed files with 6 additions and 11 deletions
|
@ -59,13 +59,9 @@ void Animation::set_effect(JS::GCPtr<AnimationEffect> new_effect)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// 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;
|
|
||||||
|
|
||||||
// 4. If animation has a pending play task, reschedule that task to run as soon as animation is ready to play ne
|
// 4. If animation has a pending play task, reschedule that task to run as soon as animation is ready to play ne
|
||||||
// effect.
|
// effect.
|
||||||
if (m_pending_play_task == TaskState::Pending)
|
// Note: There is no real difference between "pending" and "as soon as possible", so this step is a no-op.
|
||||||
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
|
||||||
|
@ -155,7 +151,7 @@ void Animation::set_start_time(Optional<double> const& new_start_time)
|
||||||
|
|
||||||
// 7. If animation has a pending play task or a pending pause task, cancel that task and resolve animation’s current
|
// 7. If animation has a pending play task or a pending pause task, cancel that task and resolve animation’s current
|
||||||
// ready promise with animation.
|
// ready promise with animation.
|
||||||
if (m_pending_play_task == TaskState::Pending || m_pending_pause_task == TaskState::Pending) {
|
if (pending()) {
|
||||||
m_pending_play_task = TaskState::None;
|
m_pending_play_task = TaskState::None;
|
||||||
m_pending_pause_task = TaskState::None;
|
m_pending_pause_task = TaskState::None;
|
||||||
WebIDL::resolve_promise(realm(), current_ready_promise(), this);
|
WebIDL::resolve_promise(realm(), current_ready_promise(), this);
|
||||||
|
@ -201,7 +197,7 @@ WebIDL::ExceptionOr<void> Animation::set_current_time(Optional<double> const& se
|
||||||
|
|
||||||
// 2. If animation has a pending pause task, synchronously complete the pause operation by performing the following
|
// 2. If animation has a pending pause task, synchronously complete the pause operation by performing the following
|
||||||
// steps:
|
// steps:
|
||||||
if (m_pending_pause_task == TaskState::Pending) {
|
if (m_pending_pause_task == TaskState::Scheduled) {
|
||||||
// 1. Set animation’s hold time to seek time.
|
// 1. Set animation’s hold time to seek time.
|
||||||
m_hold_time = seek_time;
|
m_hold_time = seek_time;
|
||||||
|
|
||||||
|
@ -281,7 +277,7 @@ Bindings::AnimationPlayState Animation::play_state() const
|
||||||
// -> Either of the following conditions are true:
|
// -> Either of the following conditions are true:
|
||||||
// - animation has a pending pause task, or
|
// - animation has a pending pause task, or
|
||||||
// - both the start time of animation is unresolved and it does not have a pending play task,
|
// - both the start time of animation is unresolved and it does not have a pending play task,
|
||||||
if (m_pending_pause_task == TaskState::Pending || (!m_start_time.has_value() && m_pending_play_task == TaskState::None)) {
|
if (m_pending_pause_task == TaskState::Scheduled || (!m_start_time.has_value() && m_pending_play_task == TaskState::None)) {
|
||||||
// → paused
|
// → paused
|
||||||
return Bindings::AnimationPlayState::Paused;
|
return Bindings::AnimationPlayState::Paused;
|
||||||
}
|
}
|
||||||
|
|
|
@ -44,7 +44,7 @@ public:
|
||||||
Bindings::AnimationReplaceState replace_state() const { return m_replace_state; }
|
Bindings::AnimationReplaceState replace_state() const { return m_replace_state; }
|
||||||
|
|
||||||
// https://www.w3.org/TR/web-animations-1/#dom-animation-pending
|
// https://www.w3.org/TR/web-animations-1/#dom-animation-pending
|
||||||
bool pending() const { return m_pending_pause_task != TaskState::None || m_pending_play_task != TaskState::None; }
|
bool pending() const { return m_pending_play_task == TaskState::Scheduled || m_pending_pause_task == TaskState::Scheduled; }
|
||||||
|
|
||||||
// https://www.w3.org/TR/web-animations-1/#dom-animation-ready
|
// https://www.w3.org/TR/web-animations-1/#dom-animation-ready
|
||||||
JS::NonnullGCPtr<JS::Object> ready() const { return *current_ready_promise()->promise(); }
|
JS::NonnullGCPtr<JS::Object> ready() const { return *current_ready_promise()->promise(); }
|
||||||
|
@ -66,8 +66,7 @@ protected:
|
||||||
private:
|
private:
|
||||||
enum class TaskState {
|
enum class TaskState {
|
||||||
None,
|
None,
|
||||||
Pending,
|
Scheduled,
|
||||||
RunAsSoonAsReady,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
enum class DidSeek {
|
enum class DidSeek {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue