... |
... |
@@ -41,41 +41,33 @@ AnimationTimeline::~AnimationTimeline() { mAnimationOrder.clear(); } |
41
|
41
|
bool AnimationTimeline::Tick() {
|
42
|
42
|
bool needsTicks = false;
|
43
|
43
|
|
44
|
|
- nsTArray<Animation*> animationsToRemove;
|
45
|
|
-
|
46
|
|
- for (Animation* animation = mAnimationOrder.getFirst(); animation;
|
47
|
|
- animation =
|
48
|
|
- static_cast<LinkedListElement<Animation>*>(animation)->getNext()) {
|
|
44
|
+ AutoTArray<RefPtr<Animation>, 32> animationsToTick;
|
|
45
|
+ for (Animation* animation : mAnimationOrder) {
|
49
|
46
|
MOZ_ASSERT(mAnimations.Contains(animation),
|
50
|
47
|
"The sampling order list should be a subset of the hashset");
|
51
|
48
|
MOZ_ASSERT(!animation->IsHiddenByContentVisibility(),
|
52
|
49
|
"The sampling order list should not contain any animations "
|
53
|
50
|
"that are hidden by content-visibility");
|
|
51
|
+ animationsToTick.AppendElement(animation);
|
|
52
|
+ }
|
54
|
53
|
|
|
54
|
+ for (Animation* animation : animationsToTick) {
|
55
|
55
|
// Skip any animations that are longer need associated with this timeline.
|
56
|
56
|
if (animation->GetTimeline() != this) {
|
57
|
|
- // If animation has some other timeline, it better not be also in the
|
58
|
|
- // animation list of this timeline object!
|
59
|
|
- MOZ_ASSERT(!animation->GetTimeline());
|
60
|
|
- animationsToRemove.AppendElement(animation);
|
|
57
|
+ RemoveAnimation(animation);
|
61
|
58
|
continue;
|
62
|
59
|
}
|
63
|
60
|
|
64
|
61
|
needsTicks |= animation->NeedsTicks();
|
65
|
|
- // Even if |animation| doesn't need future ticks, we should still
|
66
|
|
- // Tick it this time around since it might just need a one-off tick in
|
67
|
|
- // order to dispatch events.
|
|
62
|
+ // Even if |animation| doesn't need future ticks, we should still Tick it
|
|
63
|
+ // this time around since it might just need a one-off tick in order to
|
|
64
|
+ // dispatch events.
|
68
|
65
|
animation->Tick();
|
69
|
|
-
|
70
|
66
|
if (!animation->NeedsTicks()) {
|
71
|
|
- animationsToRemove.AppendElement(animation);
|
|
67
|
+ RemoveAnimation(animation);
|
72
|
68
|
}
|
73
|
69
|
}
|
74
|
70
|
|
75
|
|
- for (Animation* animation : animationsToRemove) {
|
76
|
|
- RemoveAnimation(animation);
|
77
|
|
- }
|
78
|
|
-
|
79
|
71
|
return needsTicks;
|
80
|
72
|
}
|
81
|
73
|
|
... |
... |
@@ -91,11 +83,12 @@ void AnimationTimeline::NotifyAnimationUpdated(Animation& aAnimation) { |
91
|
83
|
}
|
92
|
84
|
|
93
|
85
|
void AnimationTimeline::RemoveAnimation(Animation* aAnimation) {
|
94
|
|
- MOZ_ASSERT(!aAnimation->GetTimeline() || aAnimation->GetTimeline() == this);
|
95
|
|
- if (static_cast<LinkedListElement<Animation>*>(aAnimation)->isInList()) {
|
|
86
|
+ if (static_cast<LinkedListElement<Animation>*>(aAnimation)->isInList() &&
|
|
87
|
+ MOZ_LIKELY(!aAnimation->GetTimeline() ||
|
|
88
|
+ aAnimation->GetTimeline() == this)) {
|
|
89
|
+ static_cast<LinkedListElement<Animation>*>(aAnimation)->remove();
|
96
|
90
|
MOZ_ASSERT(mAnimations.Contains(aAnimation),
|
97
|
91
|
"The sampling order list should be a subset of the hashset");
|
98
|
|
- static_cast<LinkedListElement<Animation>*>(aAnimation)->remove();
|
99
|
92
|
}
|
100
|
93
|
mAnimations.Remove(aAnimation);
|
101
|
94
|
}
|