summaryrefslogtreecommitdiffstats
path: root/layout/style/nsAnimationManager.cpp
diff options
context:
space:
mode:
authorjanekptacijarabaci <janekptacijarabaci@seznam.cz>2018-03-14 11:45:38 +0100
committerjanekptacijarabaci <janekptacijarabaci@seznam.cz>2018-03-14 11:45:38 +0100
commitaade91b13a50ee4f246016fa8d8d1561f58f80ee (patch)
tree5deac61e124e06478040bedfbb1784b68fc8cc97 /layout/style/nsAnimationManager.cpp
parentdcc00ffadf64270b0ae82431f5b71c527590e91b (diff)
downloadUXP-aade91b13a50ee4f246016fa8d8d1561f58f80ee.tar
UXP-aade91b13a50ee4f246016fa8d8d1561f58f80ee.tar.gz
UXP-aade91b13a50ee4f246016fa8d8d1561f58f80ee.tar.lz
UXP-aade91b13a50ee4f246016fa8d8d1561f58f80ee.tar.xz
UXP-aade91b13a50ee4f246016fa8d8d1561f58f80ee.zip
moebius#89: DOM - implement animationcancel event
Issue #55
Diffstat (limited to 'layout/style/nsAnimationManager.cpp')
-rw-r--r--layout/style/nsAnimationManager.cpp75
1 files changed, 46 insertions, 29 deletions
diff --git a/layout/style/nsAnimationManager.cpp b/layout/style/nsAnimationManager.cpp
index 8d4e8fcee..aa1b6fe78 100644
--- a/layout/style/nsAnimationManager.cpp
+++ b/layout/style/nsAnimationManager.cpp
@@ -158,12 +158,8 @@ CSSAnimation::HasLowerCompositeOrderThan(const CSSAnimation& aOther) const
}
void
-CSSAnimation::QueueEvents()
+CSSAnimation::QueueEvents(StickyTimeDuration aActiveTime)
{
- if (!mEffect) {
- return;
- }
-
// If the animation is pending, we ignore animation events until we finish
// pending.
if (mPendingState != PendingState::NotPending) {
@@ -198,39 +194,60 @@ CSSAnimation::QueueEvents()
}
nsAnimationManager* manager = presContext->AnimationManager();
- ComputedTiming computedTiming = mEffect->GetComputedTiming();
-
- ComputedTiming::AnimationPhase currentPhase = computedTiming.mPhase;
- uint64_t currentIteration = computedTiming.mCurrentIteration;
- if (currentPhase == mPreviousPhase &&
- currentIteration == mPreviousIteration) {
- return;
- }
const StickyTimeDuration zeroDuration;
- StickyTimeDuration intervalStartTime =
- std::max(std::min(StickyTimeDuration(-mEffect->SpecifiedTiming().mDelay),
- computedTiming.mActiveDuration),
- zeroDuration);
- StickyTimeDuration intervalEndTime =
- std::max(std::min((EffectEnd() - mEffect->SpecifiedTiming().mDelay),
- computedTiming.mActiveDuration),
- zeroDuration);
-
- uint64_t iterationBoundary = mPreviousIteration > currentIteration
- ? currentIteration + 1
- : currentIteration;
- StickyTimeDuration iterationStartTime =
- computedTiming.mDuration.MultDouble(
- (iterationBoundary - computedTiming.mIterationStart));
+ uint64_t currentIteration = 0;
+ ComputedTiming::AnimationPhase currentPhase;
+ StickyTimeDuration intervalStartTime;
+ StickyTimeDuration intervalEndTime;
+ StickyTimeDuration iterationStartTime;
+
+ if (!mEffect) {
+ currentPhase = GetAnimationPhaseWithoutEffect
+ <ComputedTiming::AnimationPhase>(*this);
+ } else {
+ ComputedTiming computedTiming = mEffect->GetComputedTiming();
+ currentPhase = computedTiming.mPhase;
+ currentIteration = computedTiming.mCurrentIteration;
+ if (currentPhase == mPreviousPhase &&
+ currentIteration == mPreviousIteration) {
+ return;
+ }
+ intervalStartTime =
+ std::max(std::min(StickyTimeDuration(-mEffect->SpecifiedTiming().mDelay),
+ computedTiming.mActiveDuration),
+ zeroDuration);
+ intervalEndTime =
+ std::max(std::min((EffectEnd() - mEffect->SpecifiedTiming().mDelay),
+ computedTiming.mActiveDuration),
+ zeroDuration);
+
+ uint64_t iterationBoundary = mPreviousIteration > currentIteration
+ ? currentIteration + 1
+ : currentIteration;
+ iterationStartTime =
+ computedTiming.mDuration.MultDouble(
+ (iterationBoundary - computedTiming.mIterationStart));
+ }
TimeStamp startTimeStamp = ElapsedTimeToTimeStamp(intervalStartTime);
TimeStamp endTimeStamp = ElapsedTimeToTimeStamp(intervalEndTime);
TimeStamp iterationTimeStamp = ElapsedTimeToTimeStamp(iterationStartTime);
AutoTArray<AnimationEventParams, 2> events;
+
+ // Handle cancel event first
+ if ((mPreviousPhase != AnimationPhase::Idle &&
+ mPreviousPhase != AnimationPhase::After) &&
+ currentPhase == AnimationPhase::Idle) {
+ TimeStamp activeTimeStamp = ElapsedTimeToTimeStamp(aActiveTime);
+ events.AppendElement(AnimationEventParams{ eAnimationCancel,
+ aActiveTime,
+ activeTimeStamp });
+ }
+
switch (mPreviousPhase) {
- case AnimationPhase::Null:
+ case AnimationPhase::Idle:
case AnimationPhase::Before:
if (currentPhase == AnimationPhase::Active) {
events.AppendElement(AnimationEventParams{ eAnimationStart,