mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-10 13:00:29 +03: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
Notes:
sideshowbarker
2024-07-17 02:38:39 +09:00
Author: https://github.com/mattco98 Commit: https://github.com/SerenityOS/serenity/commit/88518c29ca Pull-request: https://github.com/SerenityOS/serenity/pull/23198
@ -59,13 +59,9 @@ void Animation::set_effect(JS::GCPtr<AnimationEffect> new_effect)
|
||||
return;
|
||||
|
||||
// 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
|
||||
// effect.
|
||||
if (m_pending_play_task == TaskState::Pending)
|
||||
m_pending_play_task = TaskState::RunAsSoonAsReady;
|
||||
// Note: There is no real difference between "pending" and "as soon as possible", so this step is a no-op.
|
||||
|
||||
// 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
|
||||
@ -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
|
||||
// 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_pause_task = TaskState::None;
|
||||
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
|
||||
// steps:
|
||||
if (m_pending_pause_task == TaskState::Pending) {
|
||||
if (m_pending_pause_task == TaskState::Scheduled) {
|
||||
// 1. Set animation’s hold time to seek time.
|
||||
m_hold_time = seek_time;
|
||||
|
||||
@ -281,7 +277,7 @@ Bindings::AnimationPlayState Animation::play_state() const
|
||||
// -> Either of the following conditions are true:
|
||||
// - animation has a pending pause task, or
|
||||
// - 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
|
||||
return Bindings::AnimationPlayState::Paused;
|
||||
}
|
||||
|
@ -44,7 +44,7 @@ public:
|
||||
Bindings::AnimationReplaceState replace_state() const { return m_replace_state; }
|
||||
|
||||
// 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
|
||||
JS::NonnullGCPtr<JS::Object> ready() const { return *current_ready_promise()->promise(); }
|
||||
@ -66,8 +66,7 @@ protected:
|
||||
private:
|
||||
enum class TaskState {
|
||||
None,
|
||||
Pending,
|
||||
RunAsSoonAsReady,
|
||||
Scheduled,
|
||||
};
|
||||
|
||||
enum class DidSeek {
|
||||
|
Loading…
Reference in New Issue
Block a user