summaryrefslogtreecommitdiffstats
path: root/layout/style/nsTransitionManager.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'layout/style/nsTransitionManager.cpp')
-rw-r--r--layout/style/nsTransitionManager.cpp113
1 files changed, 82 insertions, 31 deletions
diff --git a/layout/style/nsTransitionManager.cpp b/layout/style/nsTransitionManager.cpp
index 4a1a5b7ad..118702e8f 100644
--- a/layout/style/nsTransitionManager.cpp
+++ b/layout/style/nsTransitionManager.cpp
@@ -46,8 +46,6 @@ using mozilla::dom::KeyframeEffectReadOnly;
using namespace mozilla;
using namespace mozilla::css;
-typedef mozilla::ComputedTiming::AnimationPhase AnimationPhase;
-
namespace {
struct TransitionEventParams {
EventMessage mMessage;
@@ -180,10 +178,9 @@ CSSTransition::UpdateTiming(SeekFlag aSeekFlag, SyncNotifyFlag aSyncNotifyFlag)
}
void
-CSSTransition::QueueEvents()
+CSSTransition::QueueEvents(StickyTimeDuration aActiveTime)
{
- if (!mEffect ||
- !mOwningElement.IsSet()) {
+ if (!mOwningElement.IsSet()) {
return;
}
@@ -197,69 +194,123 @@ CSSTransition::QueueEvents()
return;
}
- ComputedTiming computedTiming = mEffect->GetComputedTiming();
- 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);
+ const StickyTimeDuration zeroDuration = StickyTimeDuration();
+
+ TransitionPhase currentPhase;
+ StickyTimeDuration intervalStartTime;
+ StickyTimeDuration intervalEndTime;
+
+ if (!mEffect) {
+ currentPhase = GetAnimationPhaseWithoutEffect<TransitionPhase>(*this);
+ intervalStartTime = zeroDuration;
+ intervalEndTime = zeroDuration;
+ } else {
+ ComputedTiming computedTiming = mEffect->GetComputedTiming();
+
+ currentPhase = static_cast<TransitionPhase>(computedTiming.mPhase);
+ intervalStartTime =
+ std::max(std::min(StickyTimeDuration(-mEffect->SpecifiedTiming().mDelay),
+ computedTiming.mActiveDuration), zeroDuration);
+ intervalEndTime =
+ std::max(std::min((EffectEnd() - mEffect->SpecifiedTiming().mDelay),
+ computedTiming.mActiveDuration), zeroDuration);
+ }
// TimeStamps to use for ordering the events when they are dispatched. We
// use a TimeStamp so we can compare events produced by different elements,
// perhaps even with different timelines.
// The zero timestamp is for transitionrun events where we ignore the delay
// for the purpose of ordering events.
- TimeStamp startTimeStamp = ElapsedTimeToTimeStamp(intervalStartTime);
- TimeStamp endTimeStamp = ElapsedTimeToTimeStamp(intervalEndTime);
+ TimeStamp zeroTimeStamp = AnimationTimeToTimeStamp(zeroDuration);
+ TimeStamp startTimeStamp = ElapsedTimeToTimeStamp(intervalStartTime);
+ TimeStamp endTimeStamp = ElapsedTimeToTimeStamp(intervalEndTime);
- TransitionPhase currentPhase;
if (mPendingState != PendingState::NotPending &&
(mPreviousTransitionPhase == TransitionPhase::Idle ||
mPreviousTransitionPhase == TransitionPhase::Pending))
{
currentPhase = TransitionPhase::Pending;
- } else {
- currentPhase = static_cast<TransitionPhase>(computedTiming.mPhase);
}
AutoTArray<TransitionEventParams, 3> events;
+
+ // Handle cancel events firts
+ if (mPreviousTransitionPhase != TransitionPhase::Idle &&
+ currentPhase == TransitionPhase::Idle) {
+ TimeStamp activeTimeStamp = ElapsedTimeToTimeStamp(aActiveTime);
+ events.AppendElement(TransitionEventParams{ eTransitionCancel,
+ aActiveTime,
+ activeTimeStamp });
+ }
+
+ // All other events
switch (mPreviousTransitionPhase) {
case TransitionPhase::Idle:
- if (currentPhase == TransitionPhase::After) {
+ if (currentPhase == TransitionPhase::Pending ||
+ currentPhase == TransitionPhase::Before) {
+ events.AppendElement(TransitionEventParams{ eTransitionRun,
+ intervalStartTime,
+ zeroTimeStamp });
+ } else if (currentPhase == TransitionPhase::Active) {
+ events.AppendElement(TransitionEventParams{ eTransitionRun,
+ intervalStartTime,
+ zeroTimeStamp });
+ events.AppendElement(TransitionEventParams{ eTransitionStart,
+ intervalStartTime,
+ startTimeStamp });
+ } else if (currentPhase == TransitionPhase::After) {
+ events.AppendElement(TransitionEventParams{ eTransitionRun,
+ intervalStartTime,
+ zeroTimeStamp });
+ events.AppendElement(TransitionEventParams{ eTransitionStart,
+ intervalStartTime,
+ startTimeStamp });
events.AppendElement(TransitionEventParams{ eTransitionEnd,
- intervalEndTime,
- endTimeStamp });
+ intervalEndTime,
+ endTimeStamp });
}
break;
case TransitionPhase::Pending:
case TransitionPhase::Before:
- if (currentPhase == TransitionPhase::After) {
+ if (currentPhase == TransitionPhase::Active) {
+ events.AppendElement(TransitionEventParams{ eTransitionStart,
+ intervalStartTime,
+ startTimeStamp });
+ } else if (currentPhase == TransitionPhase::After) {
+ events.AppendElement(TransitionEventParams{ eTransitionStart,
+ intervalStartTime,
+ startTimeStamp });
events.AppendElement(TransitionEventParams{ eTransitionEnd,
- intervalEndTime,
- endTimeStamp });
+ intervalEndTime,
+ endTimeStamp });
}
break;
case TransitionPhase::Active:
if (currentPhase == TransitionPhase::After) {
events.AppendElement(TransitionEventParams{ eTransitionEnd,
- intervalEndTime,
- endTimeStamp });
+ intervalEndTime,
+ endTimeStamp });
} else if (currentPhase == TransitionPhase::Before) {
events.AppendElement(TransitionEventParams{ eTransitionEnd,
- intervalStartTime,
- startTimeStamp });
+ intervalStartTime,
+ startTimeStamp });
}
break;
case TransitionPhase::After:
- if (currentPhase == TransitionPhase::Before) {
+ if (currentPhase == TransitionPhase::Active) {
+ events.AppendElement(TransitionEventParams{ eTransitionStart,
+ intervalEndTime,
+ startTimeStamp });
+ } else if (currentPhase == TransitionPhase::Before) {
+ events.AppendElement(TransitionEventParams{ eTransitionStart,
+ intervalEndTime,
+ startTimeStamp });
events.AppendElement(TransitionEventParams{ eTransitionEnd,
- intervalStartTime,
- endTimeStamp });
+ intervalStartTime,
+ endTimeStamp });
}
break;
}