mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-12-27 05:05:32 +03:00
LibWeb: Add Animation::is_replaceable()
This commit is contained in:
parent
4e6c74dcf6
commit
2ade834655
Notes:
sideshowbarker
2024-07-17 06:09:44 +09:00
Author: https://github.com/mattco98 Commit: https://github.com/SerenityOS/serenity/commit/2ade834655 Pull-request: https://github.com/SerenityOS/serenity/pull/23257
@ -10,6 +10,7 @@
|
||||
#include <LibWeb/Animations/AnimationPlaybackEvent.h>
|
||||
#include <LibWeb/Animations/DocumentTimeline.h>
|
||||
#include <LibWeb/Bindings/Intrinsics.h>
|
||||
#include <LibWeb/CSS/CSSAnimation.h>
|
||||
#include <LibWeb/DOM/Document.h>
|
||||
#include <LibWeb/HTML/Scripting/TemporaryExecutionContext.h>
|
||||
#include <LibWeb/HTML/Window.h>
|
||||
@ -297,6 +298,44 @@ Bindings::AnimationPlayState Animation::play_state() const
|
||||
return Bindings::AnimationPlayState::Running;
|
||||
}
|
||||
|
||||
// https://www.w3.org/TR/web-animations-1/#replaceable-animation
|
||||
bool Animation::is_replaceable() const
|
||||
{
|
||||
// An animation is replaceable if all of the following conditions are true:
|
||||
|
||||
// - The existence of the animation is not prescribed by markup. That is, it is not a CSS animation with an owning
|
||||
// element, nor a CSS transition with an owning element.
|
||||
// FIXME: Check for transitions
|
||||
if (is_css_animation() && static_cast<CSS::CSSAnimation const*>(this)->owning_element())
|
||||
return false;
|
||||
|
||||
// - The animation's play state is finished.
|
||||
if (play_state() != Bindings::AnimationPlayState::Finished)
|
||||
return false;
|
||||
|
||||
// - The animation's replace state is not removed.
|
||||
if (replace_state() == Bindings::AnimationReplaceState::Removed)
|
||||
return false;
|
||||
|
||||
// - The animation is associated with a monotonically increasing timeline.
|
||||
if (!m_timeline || !m_timeline->is_monotonically_increasing())
|
||||
return false;
|
||||
|
||||
// - The animation has an associated effect.
|
||||
if (!m_effect)
|
||||
return false;
|
||||
|
||||
// - The animation's associated effect is in effect.
|
||||
if (!m_effect->is_in_effect())
|
||||
return false;
|
||||
|
||||
// - The animation's associated effect has an effect target.
|
||||
if (!m_effect->target())
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
// https://www.w3.org/TR/web-animations-1/#dom-animation-play
|
||||
WebIDL::ExceptionOr<void> Animation::play()
|
||||
{
|
||||
|
@ -50,6 +50,7 @@ public:
|
||||
|
||||
Bindings::AnimationPlayState play_state() const;
|
||||
|
||||
bool is_replaceable() const;
|
||||
Bindings::AnimationReplaceState replace_state() const { return m_replace_state; }
|
||||
|
||||
// https://www.w3.org/TR/web-animations-1/#dom-animation-pending
|
||||
|
@ -264,6 +264,14 @@ Optional<double> AnimationEffect::active_time_using_fill(Bindings::FillMode fill
|
||||
return {};
|
||||
}
|
||||
|
||||
// https://www.w3.org/TR/web-animations-1/#in-effect
|
||||
bool AnimationEffect::is_in_effect() const
|
||||
{
|
||||
// An animation effect is in effect if its active time, as calculated according to the procedure in
|
||||
// §4.8.3.1 Calculating the active time, is not unresolved.
|
||||
return active_time().has_value();
|
||||
}
|
||||
|
||||
// https://www.w3.org/TR/web-animations-1/#before-active-boundary-time
|
||||
double AnimationEffect::before_active_boundary_time() const
|
||||
{
|
||||
|
@ -104,6 +104,7 @@ public:
|
||||
double active_duration() const;
|
||||
Optional<double> active_time() const;
|
||||
Optional<double> active_time_using_fill(Bindings::FillMode) const;
|
||||
bool is_in_effect() const;
|
||||
|
||||
double before_active_boundary_time() const;
|
||||
double after_active_boundary_time() const;
|
||||
|
Loading…
Reference in New Issue
Block a user