зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1171817 part 1 - Cancel animations when destroying the property holding them; r=dbaron
Prior to this patch we cancel animations in AnimationCollection::Destroy but this is not called automatically when the property holding the collection is destroyed via its destructor. When an element is unbound from the tree we destroy its animation properties but don't call AnimationCollection::Destroy. This means, that in such circumstances: * We won't create animation mutation records for the removed animations * Once we start registering animations with a timeline they won't have a chance to remove themselves from the timeline (meaning document.timeline.getAnimations()) will keep returning them * Once we go to implement the animationcancel and transitioncancel events we won't fire them in this case (assuming we implement the queueing/dispatch of those events as part of the cancel code) This patch addresses this by moving the call to cancel each animations to the property destructor for the animation properties. We do this first so we can land this change separately to ease bisecting any regressions it might trigger. --HG-- extra : commitid : KzukSO91RMH extra : rebase_source : 54ed2aeb69d8bceca424c70c7f33d4bf92d54546
This commit is contained in:
Родитель
54a5716d5e
Коммит
e1ae8c1a56
|
@ -355,8 +355,13 @@ Animation::TriggerOnNextTick(const Nullable<TimeDuration>& aReadyTime)
|
|||
void
|
||||
Animation::TriggerNow()
|
||||
{
|
||||
MOZ_ASSERT(PlayState() == AnimationPlayState::Pending,
|
||||
"Expected to start a pending animation");
|
||||
// Normally we expect the play state to be pending but when an animation
|
||||
// is cancelled and its rendered document can't be reached, we can end up
|
||||
// with the animation still in a pending player tracker even after it is
|
||||
// no longer pending.
|
||||
if (PlayState() != AnimationPlayState::Pending) {
|
||||
return;
|
||||
}
|
||||
MOZ_ASSERT(mTimeline && !mTimeline->GetCurrentTime().IsNull(),
|
||||
"Expected an active timeline");
|
||||
|
||||
|
|
|
@ -13,6 +13,7 @@
|
|||
#include "nsCSSPropertySet.h"
|
||||
#include "nsCSSValue.h"
|
||||
#include "nsCycleCollectionParticipant.h"
|
||||
#include "nsDOMMutationObserver.h"
|
||||
#include "nsStyleContext.h"
|
||||
#include "nsIFrame.h"
|
||||
#include "nsLayoutUtils.h"
|
||||
|
@ -770,6 +771,13 @@ AnimationCollection::PropertyDtor(void *aObject, nsIAtom *aPropertyName,
|
|||
MOZ_ASSERT(!collection->mCalledPropertyDtor, "can't call dtor twice");
|
||||
collection->mCalledPropertyDtor = true;
|
||||
#endif
|
||||
{
|
||||
nsAutoAnimationMutationBatch mb(collection->mElement);
|
||||
|
||||
for (size_t animIdx = collection->mAnimations.Length(); animIdx-- != 0; ) {
|
||||
collection->mAnimations[animIdx]->CancelFromStyle();
|
||||
}
|
||||
}
|
||||
delete collection;
|
||||
}
|
||||
|
||||
|
|
|
@ -272,9 +272,6 @@ struct AnimationCollection : public PRCList
|
|||
|
||||
void Destroy()
|
||||
{
|
||||
for (size_t animIdx = mAnimations.Length(); animIdx-- != 0; ) {
|
||||
mAnimations[animIdx]->CancelFromStyle();
|
||||
}
|
||||
// This will call our destructor.
|
||||
mElement->DeleteProperty(mElementProperty);
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче