mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-23 21:01:08 +00:00
Bug 1923208 - Store animation index into AnimationEventDispatcher. r=layout-reviewers,birtles,jwatt,emilio
We need this information when comparing the cancelled transitions/animations in the following patches. Note that we have to reorder the calling of `Animation::Cancel()` and the update of `mAnimationIndex` to make sure we enqueue the cancel event with the correct `mAnimationIndex`. Differential Revision: https://phabricator.services.mozilla.com/D227110
This commit is contained in:
parent
c160b9197b
commit
4f7823a1f0
@ -29,6 +29,12 @@ struct AnimationEventInfo {
|
|||||||
OwningAnimationTarget mTarget;
|
OwningAnimationTarget mTarget;
|
||||||
const EventMessage mMessage;
|
const EventMessage mMessage;
|
||||||
const double mElapsedTime;
|
const double mElapsedTime;
|
||||||
|
// The transition generation or animation relative position in the global
|
||||||
|
// animation list. We use this information to determine the order of
|
||||||
|
// cancelled transitions or animations. (i.e. We override the animation
|
||||||
|
// index of the cancelled transitions/animations because their animation
|
||||||
|
// indexes have been changed.)
|
||||||
|
const uint64_t mAnimationIndex;
|
||||||
// FIXME(emilio): is this needed? This preserves behavior from before
|
// FIXME(emilio): is this needed? This preserves behavior from before
|
||||||
// bug 1847200, but it's unclear what the timeStamp of the event should be.
|
// bug 1847200, but it's unclear what the timeStamp of the event should be.
|
||||||
// See also https://github.com/w3c/csswg-drafts/issues/9167
|
// See also https://github.com/w3c/csswg-drafts/issues/9167
|
||||||
@ -73,13 +79,14 @@ struct AnimationEventInfo {
|
|||||||
AnimationEventInfo(RefPtr<nsAtom> aAnimationName,
|
AnimationEventInfo(RefPtr<nsAtom> aAnimationName,
|
||||||
const NonOwningAnimationTarget& aTarget,
|
const NonOwningAnimationTarget& aTarget,
|
||||||
EventMessage aMessage, double aElapsedTime,
|
EventMessage aMessage, double aElapsedTime,
|
||||||
|
uint64_t aAnimationIndex,
|
||||||
const TimeStamp& aScheduledEventTimeStamp,
|
const TimeStamp& aScheduledEventTimeStamp,
|
||||||
dom::Animation* aAnimation)
|
dom::Animation* aAnimation)
|
||||||
: mAnimation(aAnimation),
|
: mAnimation(aAnimation),
|
||||||
mScheduledEventTimeStamp(aScheduledEventTimeStamp),
|
mScheduledEventTimeStamp(aScheduledEventTimeStamp),
|
||||||
mData(CssAnimationData{
|
mData(CssAnimationData{
|
||||||
{OwningAnimationTarget(aTarget.mElement, aTarget.mPseudoType),
|
{OwningAnimationTarget(aTarget.mElement, aTarget.mPseudoType),
|
||||||
aMessage, aElapsedTime},
|
aMessage, aElapsedTime, aAnimationIndex},
|
||||||
std::move(aAnimationName)}) {
|
std::move(aAnimationName)}) {
|
||||||
if (profiler_thread_is_being_profiled_for_markers()) {
|
if (profiler_thread_is_being_profiled_for_markers()) {
|
||||||
MaybeAddMarker();
|
MaybeAddMarker();
|
||||||
@ -90,13 +97,14 @@ struct AnimationEventInfo {
|
|||||||
AnimationEventInfo(const AnimatedPropertyID& aProperty,
|
AnimationEventInfo(const AnimatedPropertyID& aProperty,
|
||||||
const NonOwningAnimationTarget& aTarget,
|
const NonOwningAnimationTarget& aTarget,
|
||||||
EventMessage aMessage, double aElapsedTime,
|
EventMessage aMessage, double aElapsedTime,
|
||||||
|
uint64_t aTransitionGeneration,
|
||||||
const TimeStamp& aScheduledEventTimeStamp,
|
const TimeStamp& aScheduledEventTimeStamp,
|
||||||
dom::Animation* aAnimation)
|
dom::Animation* aAnimation)
|
||||||
: mAnimation(aAnimation),
|
: mAnimation(aAnimation),
|
||||||
mScheduledEventTimeStamp(aScheduledEventTimeStamp),
|
mScheduledEventTimeStamp(aScheduledEventTimeStamp),
|
||||||
mData(CssTransitionData{
|
mData(CssTransitionData{
|
||||||
{OwningAnimationTarget(aTarget.mElement, aTarget.mPseudoType),
|
{OwningAnimationTarget(aTarget.mElement, aTarget.mPseudoType),
|
||||||
aMessage, aElapsedTime},
|
aMessage, aElapsedTime, aTransitionGeneration},
|
||||||
aProperty}) {
|
aProperty}) {
|
||||||
if (profiler_thread_is_being_profiled_for_markers()) {
|
if (profiler_thread_is_being_profiled_for_markers()) {
|
||||||
MaybeAddMarker();
|
MaybeAddMarker();
|
||||||
|
@ -230,9 +230,9 @@ void CSSAnimation::QueueEvents(const StickyTimeDuration& aActiveTime) {
|
|||||||
elapsedTime = nsRFPService::ReduceTimePrecisionAsSecsRFPOnly(
|
elapsedTime = nsRFPService::ReduceTimePrecisionAsSecsRFPOnly(
|
||||||
elapsedTime, 0, mRTPCallerType);
|
elapsedTime, 0, mRTPCallerType);
|
||||||
}
|
}
|
||||||
events.AppendElement(
|
events.AppendElement(AnimationEventInfo(
|
||||||
AnimationEventInfo(mAnimationName, mOwningElement.Target(), aMessage,
|
mAnimationName, mOwningElement.Target(), aMessage, elapsedTime,
|
||||||
elapsedTime, aScheduledEventTimeStamp, this));
|
mAnimationIndex, aScheduledEventTimeStamp, this));
|
||||||
};
|
};
|
||||||
|
|
||||||
// Handle cancel event first
|
// Handle cancel event first
|
||||||
|
@ -84,6 +84,8 @@ class CSSAnimation final : public Animation {
|
|||||||
void PlayFromStyle();
|
void PlayFromStyle();
|
||||||
void PauseFromStyle();
|
void PauseFromStyle();
|
||||||
void CancelFromStyle(PostRestyleMode aPostRestyle) {
|
void CancelFromStyle(PostRestyleMode aPostRestyle) {
|
||||||
|
Animation::Cancel(aPostRestyle);
|
||||||
|
|
||||||
// When an animation is disassociated with style it enters an odd state
|
// When an animation is disassociated with style it enters an odd state
|
||||||
// where its composite order is undefined until it first transitions
|
// where its composite order is undefined until it first transitions
|
||||||
// out of the idle state.
|
// out of the idle state.
|
||||||
@ -94,11 +96,13 @@ class CSSAnimation final : public Animation {
|
|||||||
// if it had been added to the end of the global animation list so that
|
// if it had been added to the end of the global animation list so that
|
||||||
// its sort order is defined. We'll update this index again once the
|
// its sort order is defined. We'll update this index again once the
|
||||||
// animation leaves the idle state.
|
// animation leaves the idle state.
|
||||||
|
//
|
||||||
|
// Note: We have to update |mAnimationIndex| after calling
|
||||||
|
// Animation::Cancel(), which enqueues animationcancel event, to make sure
|
||||||
|
// we have the correct |mAnimationIndex| in AnimationEventInfo.
|
||||||
mAnimationIndex = sNextAnimationIndex++;
|
mAnimationIndex = sNextAnimationIndex++;
|
||||||
mNeedsNewAnimationIndexWhenRun = true;
|
mNeedsNewAnimationIndexWhenRun = true;
|
||||||
|
|
||||||
Animation::Cancel(aPostRestyle);
|
|
||||||
|
|
||||||
// We need to do this *after* calling Cancel() since
|
// We need to do this *after* calling Cancel() since
|
||||||
// Cancel() might synchronously trigger a cancel event for which
|
// Cancel() might synchronously trigger a cancel event for which
|
||||||
// we need an owning element to target the event at.
|
// we need an owning element to target the event at.
|
||||||
|
@ -120,7 +120,7 @@ void CSSTransition::QueueEvents(const StickyTimeDuration& aActiveTime) {
|
|||||||
}
|
}
|
||||||
events.AppendElement(AnimationEventInfo(
|
events.AppendElement(AnimationEventInfo(
|
||||||
TransitionProperty(), mOwningElement.Target(), aMessage, elapsedTime,
|
TransitionProperty(), mOwningElement.Target(), aMessage, elapsedTime,
|
||||||
aScheduledEventTimeStamp, this));
|
mAnimationIndex, aScheduledEventTimeStamp, this));
|
||||||
};
|
};
|
||||||
|
|
||||||
// Handle cancel events first
|
// Handle cancel events first
|
||||||
|
@ -51,17 +51,21 @@ class CSSTransition final : public Animation {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void CancelFromStyle(PostRestyleMode aPostRestyle) {
|
void CancelFromStyle(PostRestyleMode aPostRestyle) {
|
||||||
|
Animation::Cancel(aPostRestyle);
|
||||||
|
|
||||||
// The animation index to use for compositing will be established when
|
// The animation index to use for compositing will be established when
|
||||||
// this transition next transitions out of the idle state but we still
|
// this transition next transitions out of the idle state but we still
|
||||||
// update it now so that the sort order of this transition remains
|
// update it now so that the sort order of this transition remains
|
||||||
// defined until that moment.
|
// defined until that moment.
|
||||||
//
|
//
|
||||||
// See longer explanation in CSSAnimation::CancelFromStyle.
|
// See longer explanation in CSSAnimation::CancelFromStyle.
|
||||||
|
//
|
||||||
|
// Note: We have to update |mAnimationIndex| after calling
|
||||||
|
// Animation::Cancel(), which enqueues transitioncancel event, to make sure
|
||||||
|
// we have the correct |mAnimationIndex| in AnimationEventInfo.
|
||||||
mAnimationIndex = sNextAnimationIndex++;
|
mAnimationIndex = sNextAnimationIndex++;
|
||||||
mNeedsNewAnimationIndexWhenRun = true;
|
mNeedsNewAnimationIndexWhenRun = true;
|
||||||
|
|
||||||
Animation::Cancel(aPostRestyle);
|
|
||||||
|
|
||||||
// It is important we do this *after* calling Cancel().
|
// It is important we do this *after* calling Cancel().
|
||||||
// This is because Cancel() will end up posting a restyle and
|
// This is because Cancel() will end up posting a restyle and
|
||||||
// that restyle should target the *transitions* level of the cascade.
|
// that restyle should target the *transitions* level of the cascade.
|
||||||
|
Loading…
Reference in New Issue
Block a user