Bug 1264125: Fire transitioncancel event when a transition is canceled - part 1 (in the description)

Issue #55
part 1 - Add transitioncancel event handler
part 2 - Add ontransitioncancel EventHandler to WebIDL
part 3 - Add member of active time to ComputedTiming
This commit is contained in:
janekptacijarabaci 2018-03-14 08:52:52 +01:00 • committed by Roy Tam
commit a89e7c6858
6 changed files with 17 additions and 10 deletions

View file

@ -127,10 +127,6 @@ AnimationEffectReadOnly::GetComputedTimingAt(
} }
const TimeDuration& localTime = aLocalTime.Value(); const TimeDuration& localTime = aLocalTime.Value();
// Calculate the time within the active interval.
// https://w3c.github.io/web-animations/#active-time
StickyTimeDuration activeTime;
StickyTimeDuration beforeActiveBoundary = StickyTimeDuration beforeActiveBoundary =
std::max(std::min(StickyTimeDuration(aTiming.mDelay), result.mEndTime), std::max(std::min(StickyTimeDuration(aTiming.mDelay), result.mEndTime),
zeroDuration); zeroDuration);
@ -148,7 +144,7 @@ AnimationEffectReadOnly::GetComputedTimingAt(
// The animation isn't active or filling at this time. // The animation isn't active or filling at this time.
return result; return result;
} }
activeTime = result.mActiveTime =
std::max(std::min(StickyTimeDuration(localTime - aTiming.mDelay), std::max(std::min(StickyTimeDuration(localTime - aTiming.mDelay),
result.mActiveDuration), result.mActiveDuration),
zeroDuration); zeroDuration);
@ -159,13 +155,14 @@ AnimationEffectReadOnly::GetComputedTimingAt(
// The animation isn't active or filling at this time. // The animation isn't active or filling at this time.
return result; return result;
} }
activeTime = std::max(StickyTimeDuration(localTime - aTiming.mDelay), result.mActiveTime
zeroDuration); = std::max(StickyTimeDuration(localTime - aTiming.mDelay),
zeroDuration);
} else { } else {
MOZ_ASSERT(result.mActiveDuration != zeroDuration, MOZ_ASSERT(result.mActiveDuration != zeroDuration,
"How can we be in the middle of a zero-duration interval?"); "How can we be in the middle of a zero-duration interval?");
result.mPhase = ComputedTiming::AnimationPhase::Active; result.mPhase = ComputedTiming::AnimationPhase::Active;
activeTime = localTime - aTiming.mDelay; result.mActiveTime = localTime - aTiming.mDelay;
} }
// Convert active time to a multiple of iterations. // Convert active time to a multiple of iterations.
@ -176,7 +173,7 @@ AnimationEffectReadOnly::GetComputedTimingAt(
? 0.0 ? 0.0
: result.mIterations; : result.mIterations;
} else { } else {
overallProgress = activeTime / result.mDuration; overallProgress = result.mActiveTime / result.mDuration;
} }
// Factor in iteration start offset. // Factor in iteration start offset.
@ -208,7 +205,8 @@ AnimationEffectReadOnly::GetComputedTimingAt(
if (result.mPhase == ComputedTiming::AnimationPhase::After && if (result.mPhase == ComputedTiming::AnimationPhase::After &&
progress == 0.0 && progress == 0.0 &&
result.mIterations != 0.0 && result.mIterations != 0.0 &&
(activeTime != zeroDuration || result.mDuration == zeroDuration)) { (result.mActiveTime != zeroDuration ||
result.mDuration == zeroDuration)) {
// The only way we can be in the after phase with a progress of zero and // The only way we can be in the after phase with a progress of zero and
// a current iteration of zero, is if we have a zero iteration count or // a current iteration of zero, is if we have a zero iteration count or
// were clipped using a negative end delay--both of which we should have // were clipped using a negative end delay--both of which we should have

View file

@ -29,6 +29,8 @@ struct ComputedTiming
// Will equal StickyTimeDuration::Forever() if the animation repeats // Will equal StickyTimeDuration::Forever() if the animation repeats
// indefinitely. // indefinitely.
StickyTimeDuration mActiveDuration; StickyTimeDuration mActiveDuration;
// The time within the active interval.
StickyTimeDuration mActiveTime;
// The effect end time in local time (i.e. an offset from the effect's // The effect end time in local time (i.e. an offset from the effect's
// start time). Will equal StickyTimeDuration::Forever() if the animation // start time). Will equal StickyTimeDuration::Forever() if the animation
// plays indefinitely. // plays indefinitely.

View file

@ -942,6 +942,7 @@ GK_ATOM(ontouchstart, "ontouchstart")
GK_ATOM(ontouchend, "ontouchend") GK_ATOM(ontouchend, "ontouchend")
GK_ATOM(ontouchmove, "ontouchmove") GK_ATOM(ontouchmove, "ontouchmove")
GK_ATOM(ontouchcancel, "ontouchcancel") GK_ATOM(ontouchcancel, "ontouchcancel")
GK_ATOM(ontransitioncancel, "ontransitioncancel")
GK_ATOM(ontransitionend, "ontransitionend") GK_ATOM(ontransitionend, "ontransitionend")
GK_ATOM(ontransitionrun, "ontransitionrun") GK_ATOM(ontransitionrun, "ontransitionrun")
GK_ATOM(ontransitionstart, "ontransitionstart") GK_ATOM(ontransitionstart, "ontransitionstart")

View file

@ -1007,6 +1007,10 @@ EVENT(transitionend,
eTransitionEnd, eTransitionEnd,
EventNameType_All, EventNameType_All,
eTransitionEventClass) eTransitionEventClass)
EVENT(transitioncancel,
eTransitionCancel,
EventNameType_All,
eTransitionEventClass)
EVENT(animationstart, EVENT(animationstart,
eAnimationStart, eAnimationStart,
EventNameType_All, EventNameType_All,

View file

@ -132,6 +132,7 @@ interface GlobalEventHandlers {
attribute EventHandler onanimationend; attribute EventHandler onanimationend;
attribute EventHandler onanimationiteration; attribute EventHandler onanimationiteration;
attribute EventHandler onanimationstart; attribute EventHandler onanimationstart;
attribute EventHandler ontransitioncancel;
attribute EventHandler ontransitionend; attribute EventHandler ontransitionend;
// We will ship transitionrun and transitionstart events // We will ship transitionrun and transitionstart events
// on Firefox 53. (For detail, see bug 1324985) // on Firefox 53. (For detail, see bug 1324985)

View file

@ -341,6 +341,7 @@ NS_EVENT_MESSAGE(eScrolledAreaChanged)
NS_EVENT_MESSAGE(eTransitionStart) NS_EVENT_MESSAGE(eTransitionStart)
NS_EVENT_MESSAGE(eTransitionRun) NS_EVENT_MESSAGE(eTransitionRun)
NS_EVENT_MESSAGE(eTransitionEnd) NS_EVENT_MESSAGE(eTransitionEnd)
NS_EVENT_MESSAGE(eTransitionCancel)
NS_EVENT_MESSAGE(eAnimationStart) NS_EVENT_MESSAGE(eAnimationStart)
NS_EVENT_MESSAGE(eAnimationEnd) NS_EVENT_MESSAGE(eAnimationEnd)
NS_EVENT_MESSAGE(eAnimationIteration) NS_EVENT_MESSAGE(eAnimationIteration)