зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1154615
part 6 - Rename references to players within layout/; r=jwatt
We will rename CSSAnimationPlayer/CSSTransitionPlayer in a separate patch
This commit is contained in:
Родитель
8f5fbac8a9
Коммит
13834006d7
|
@ -731,7 +731,7 @@ Animation::PostUpdate()
|
|||
{
|
||||
AnimationCollection* collection = GetCollection();
|
||||
if (collection) {
|
||||
collection->NotifyPlayerUpdated();
|
||||
collection->NotifyAnimationUpdated();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -3203,12 +3203,12 @@ Element::GetAnimations(nsTArray<nsRefPtr<Animation>>& aAnimations)
|
|||
if (!collection) {
|
||||
continue;
|
||||
}
|
||||
for (size_t playerIdx = 0;
|
||||
playerIdx < collection->mPlayers.Length();
|
||||
playerIdx++) {
|
||||
Animation* player = collection->mPlayers[playerIdx];
|
||||
if (player->IsRelevant()) {
|
||||
aAnimations.AppendElement(player);
|
||||
for (size_t animIdx = 0;
|
||||
animIdx < collection->mAnimations.Length();
|
||||
animIdx++) {
|
||||
Animation* anim = collection->mAnimations[animIdx];
|
||||
if (anim->IsRelevant()) {
|
||||
aAnimations.AppendElement(anim);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -348,13 +348,12 @@ ToTimingFunction(const ComputedTimingFunction& aCTF)
|
|||
|
||||
static void
|
||||
AddAnimationForProperty(nsIFrame* aFrame, const AnimationProperty& aProperty,
|
||||
dom::Animation* aPlayer, Layer* aLayer,
|
||||
dom::Animation* aAnimation, Layer* aLayer,
|
||||
AnimationData& aData, bool aPending)
|
||||
{
|
||||
MOZ_ASSERT(aLayer->AsContainerLayer(), "Should only animate ContainerLayer");
|
||||
MOZ_ASSERT(aPlayer->GetEffect(),
|
||||
"Should not be adding an animation for a player without"
|
||||
" an effect");
|
||||
MOZ_ASSERT(aAnimation->GetEffect(),
|
||||
"Should not be adding an animation without an effect");
|
||||
nsStyleContext* styleContext = aFrame->StyleContext();
|
||||
nsPresContext* presContext = aFrame->PresContext();
|
||||
nsRect bounds = nsDisplayTransform::GetFrameBoundsForTransform(aFrame);
|
||||
|
@ -364,13 +363,13 @@ AddAnimationForProperty(nsIFrame* aFrame, const AnimationProperty& aProperty,
|
|||
aLayer->AddAnimationForNextTransaction() :
|
||||
aLayer->AddAnimation();
|
||||
|
||||
const AnimationTiming& timing = aPlayer->GetEffect()->Timing();
|
||||
Nullable<TimeDuration> startTime = aPlayer->GetCurrentOrPendingStartTime();
|
||||
const AnimationTiming& timing = aAnimation->GetEffect()->Timing();
|
||||
Nullable<TimeDuration> startTime = aAnimation->GetCurrentOrPendingStartTime();
|
||||
animation->startTime() = startTime.IsNull()
|
||||
? TimeStamp()
|
||||
: aPlayer->Timeline()->ToTimeStamp(
|
||||
: aAnimation->Timeline()->ToTimeStamp(
|
||||
startTime.Value() + timing.mDelay);
|
||||
animation->initialCurrentTime() = aPlayer->GetCurrentTime().Value()
|
||||
animation->initialCurrentTime() = aAnimation->GetCurrentTime().Value()
|
||||
- timing.mDelay;
|
||||
animation->duration() = timing.mIterationDuration;
|
||||
animation->iterationCount() = timing.mIterationCount;
|
||||
|
@ -407,7 +406,7 @@ AddAnimationForProperty(nsIFrame* aFrame, const AnimationProperty& aProperty,
|
|||
|
||||
static void
|
||||
AddAnimationsForProperty(nsIFrame* aFrame, nsCSSProperty aProperty,
|
||||
AnimationPlayerPtrArray& aPlayers,
|
||||
AnimationPtrArray& aAnimations,
|
||||
Layer* aLayer, AnimationData& aData,
|
||||
bool aPending)
|
||||
{
|
||||
|
@ -416,13 +415,13 @@ AddAnimationsForProperty(nsIFrame* aFrame, nsCSSProperty aProperty,
|
|||
"inconsistent property flags");
|
||||
|
||||
// Add from first to last (since last overrides)
|
||||
for (size_t playerIdx = 0; playerIdx < aPlayers.Length(); playerIdx++) {
|
||||
dom::Animation* player = aPlayers[playerIdx];
|
||||
if (!player->IsPlaying()) {
|
||||
for (size_t animIdx = 0; animIdx < aAnimations.Length(); animIdx++) {
|
||||
dom::Animation* anim = aAnimations[animIdx];
|
||||
if (!anim->IsPlaying()) {
|
||||
continue;
|
||||
}
|
||||
dom::KeyframeEffectReadonly* effect = player->GetEffect();
|
||||
MOZ_ASSERT(effect, "A playing player should have an effect");
|
||||
dom::KeyframeEffectReadonly* effect = anim->GetEffect();
|
||||
MOZ_ASSERT(effect, "A playing animation should have an effect");
|
||||
const AnimationProperty* property =
|
||||
effect->GetAnimationOfProperty(aProperty);
|
||||
if (!property) {
|
||||
|
@ -450,15 +449,15 @@ AddAnimationsForProperty(nsIFrame* aFrame, nsCSSProperty aProperty,
|
|||
// Instead we leave the animation running on the main thread and the
|
||||
// next time the refresh driver is advanced it will trigger any pending
|
||||
// animations.
|
||||
if (player->PlayState() == AnimationPlayState::Pending) {
|
||||
nsRefreshDriver* driver = player->Timeline()->GetRefreshDriver();
|
||||
if (anim->PlayState() == AnimationPlayState::Pending) {
|
||||
nsRefreshDriver* driver = anim->Timeline()->GetRefreshDriver();
|
||||
if (driver && driver->IsTestControllingRefreshesEnabled()) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
AddAnimationForProperty(aFrame, *property, player, aLayer, aData, aPending);
|
||||
player->SetIsRunningOnCompositor();
|
||||
AddAnimationForProperty(aFrame, *property, anim, aLayer, aData, aPending);
|
||||
anim->SetIsRunningOnCompositor();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -566,12 +565,12 @@ nsDisplayListBuilder::AddAnimationsAndTransitionsToLayer(Layer* aLayer,
|
|||
// When both are running, animations override transitions. We want
|
||||
// to add the ones that override last.
|
||||
if (transitions) {
|
||||
AddAnimationsForProperty(aFrame, aProperty, transitions->mPlayers,
|
||||
AddAnimationsForProperty(aFrame, aProperty, transitions->mAnimations,
|
||||
aLayer, data, pending);
|
||||
}
|
||||
|
||||
if (animations) {
|
||||
AddAnimationsForProperty(aFrame, aProperty, animations->mPlayers,
|
||||
AddAnimationsForProperty(aFrame, aProperty, animations->mAnimations,
|
||||
aLayer, data, pending);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -500,12 +500,12 @@ GetMinAndMaxScaleForAnimationProperty(nsIContent* aContent,
|
|||
gfxSize& aMaxScale,
|
||||
gfxSize& aMinScale)
|
||||
{
|
||||
for (size_t playerIdx = aAnimations->mPlayers.Length(); playerIdx-- != 0; ) {
|
||||
dom::Animation* player = aAnimations->mPlayers[playerIdx];
|
||||
if (!player->GetEffect() || player->GetEffect()->IsFinishedTransition()) {
|
||||
for (size_t animIdx = aAnimations->mAnimations.Length(); animIdx-- != 0; ) {
|
||||
dom::Animation* anim = aAnimations->mAnimations[animIdx];
|
||||
if (!anim->GetEffect() || anim->GetEffect()->IsFinishedTransition()) {
|
||||
continue;
|
||||
}
|
||||
dom::KeyframeEffectReadonly* effect = player->GetEffect();
|
||||
dom::KeyframeEffectReadonly* effect = anim->GetEffect();
|
||||
for (size_t propIdx = effect->Properties().Length(); propIdx-- != 0; ) {
|
||||
AnimationProperty& prop = effect->Properties()[propIdx];
|
||||
if (prop.mProperty == eCSSProperty_transform) {
|
||||
|
|
|
@ -595,14 +595,14 @@ AnimationCollection::CanPerformOnCompositorThread(
|
|||
return false;
|
||||
}
|
||||
|
||||
for (size_t playerIdx = mPlayers.Length(); playerIdx-- != 0; ) {
|
||||
const Animation* player = mPlayers[playerIdx];
|
||||
if (!player->IsPlaying()) {
|
||||
for (size_t animIdx = mAnimations.Length(); animIdx-- != 0; ) {
|
||||
const Animation* anim = mAnimations[animIdx];
|
||||
if (!anim->IsPlaying()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
const KeyframeEffectReadonly* effect = player->GetEffect();
|
||||
MOZ_ASSERT(effect, "A playing player should have an effect");
|
||||
const KeyframeEffectReadonly* effect = anim->GetEffect();
|
||||
MOZ_ASSERT(effect, "A playing animation should have an effect");
|
||||
|
||||
for (size_t propIdx = 0, propEnd = effect->Properties().Length();
|
||||
propIdx != propEnd; ++propIdx) {
|
||||
|
@ -614,14 +614,14 @@ AnimationCollection::CanPerformOnCompositorThread(
|
|||
}
|
||||
|
||||
bool existsProperty = false;
|
||||
for (size_t playerIdx = mPlayers.Length(); playerIdx-- != 0; ) {
|
||||
const Animation* player = mPlayers[playerIdx];
|
||||
if (!player->IsPlaying()) {
|
||||
for (size_t animIdx = mAnimations.Length(); animIdx-- != 0; ) {
|
||||
const Animation* anim = mAnimations[animIdx];
|
||||
if (!anim->IsPlaying()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
const KeyframeEffectReadonly* effect = player->GetEffect();
|
||||
MOZ_ASSERT(effect, "A playing player should have an effect");
|
||||
const KeyframeEffectReadonly* effect = anim->GetEffect();
|
||||
MOZ_ASSERT(effect, "A playing animation should have an effect");
|
||||
|
||||
existsProperty = existsProperty || effect->Properties().Length() > 0;
|
||||
|
||||
|
@ -649,8 +649,8 @@ void
|
|||
AnimationCollection::PostUpdateLayerAnimations()
|
||||
{
|
||||
nsCSSPropertySet propsHandled;
|
||||
for (size_t playerIdx = mPlayers.Length(); playerIdx-- != 0; ) {
|
||||
const auto& properties = mPlayers[playerIdx]->GetEffect()->Properties();
|
||||
for (size_t animIdx = mAnimations.Length(); animIdx-- != 0; ) {
|
||||
const auto& properties = mAnimations[animIdx]->GetEffect()->Properties();
|
||||
for (size_t propIdx = properties.Length(); propIdx-- != 0; ) {
|
||||
nsCSSProperty prop = properties[propIdx].mProperty;
|
||||
if (nsCSSProps::PropHasFlags(prop,
|
||||
|
@ -672,8 +672,8 @@ AnimationCollection::PostUpdateLayerAnimations()
|
|||
bool
|
||||
AnimationCollection::HasAnimationOfProperty(nsCSSProperty aProperty) const
|
||||
{
|
||||
for (size_t playerIdx = mPlayers.Length(); playerIdx-- != 0; ) {
|
||||
const KeyframeEffectReadonly* effect = mPlayers[playerIdx]->GetEffect();
|
||||
for (size_t animIdx = mAnimations.Length(); animIdx-- != 0; ) {
|
||||
const KeyframeEffectReadonly* effect = mAnimations[animIdx]->GetEffect();
|
||||
if (effect && effect->HasAnimationOfProperty(aProperty) &&
|
||||
!effect->IsFinishedTransition()) {
|
||||
return true;
|
||||
|
@ -709,7 +709,7 @@ AnimationCollection::GetElementToRestyle() const
|
|||
}
|
||||
|
||||
void
|
||||
AnimationCollection::NotifyPlayerUpdated()
|
||||
AnimationCollection::NotifyAnimationUpdated()
|
||||
{
|
||||
// On the next flush, force us to update the style rule
|
||||
mNeedsRefreshes = true;
|
||||
|
@ -754,9 +754,9 @@ AnimationCollection::PropertyDtor(void *aObject, nsIAtom *aPropertyName,
|
|||
void
|
||||
AnimationCollection::Tick()
|
||||
{
|
||||
for (size_t playerIdx = 0, playerEnd = mPlayers.Length();
|
||||
playerIdx != playerEnd; playerIdx++) {
|
||||
mPlayers[playerIdx]->Tick();
|
||||
for (size_t animIdx = 0, animEnd = mAnimations.Length();
|
||||
animIdx != animEnd; animIdx++) {
|
||||
mAnimations[animIdx]->Tick();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -782,8 +782,8 @@ AnimationCollection::EnsureStyleRuleFor(TimeStamp aRefreshTime,
|
|||
// mode behavior). CanThrottle returns false for any finishing animations
|
||||
// so we can force style recalculation in that case.
|
||||
if (aFlags == EnsureStyleRule_IsThrottled) {
|
||||
for (size_t playerIdx = mPlayers.Length(); playerIdx-- != 0; ) {
|
||||
if (!mPlayers[playerIdx]->CanThrottle()) {
|
||||
for (size_t animIdx = mAnimations.Length(); animIdx-- != 0; ) {
|
||||
if (!mAnimations[animIdx]->CanThrottle()) {
|
||||
aFlags = EnsureStyleRule_IsNotThrottled;
|
||||
break;
|
||||
}
|
||||
|
@ -811,8 +811,8 @@ AnimationCollection::EnsureStyleRuleFor(TimeStamp aRefreshTime,
|
|||
// property has already been set, we don't leave it.
|
||||
nsCSSPropertySet properties;
|
||||
|
||||
for (size_t playerIdx = mPlayers.Length(); playerIdx-- != 0; ) {
|
||||
mPlayers[playerIdx]->ComposeStyle(mStyleRule, properties, mNeedsRefreshes);
|
||||
for (size_t animIdx = mAnimations.Length(); animIdx-- != 0; ) {
|
||||
mAnimations[animIdx]->ComposeStyle(mStyleRule, properties, mNeedsRefreshes);
|
||||
}
|
||||
|
||||
mManager->MaybeStartObservingRefreshDriver();
|
||||
|
@ -906,8 +906,8 @@ AnimationCollection::UpdateCheckGeneration(
|
|||
bool
|
||||
AnimationCollection::HasCurrentAnimations() const
|
||||
{
|
||||
for (size_t playerIdx = mPlayers.Length(); playerIdx-- != 0; ) {
|
||||
if (mPlayers[playerIdx]->HasCurrentEffect()) {
|
||||
for (size_t animIdx = mAnimations.Length(); animIdx-- != 0; ) {
|
||||
if (mAnimations[animIdx]->HasCurrentEffect()) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -920,11 +920,11 @@ AnimationCollection::HasCurrentAnimationsForProperties(
|
|||
const nsCSSProperty* aProperties,
|
||||
size_t aPropertyCount) const
|
||||
{
|
||||
for (size_t playerIdx = mPlayers.Length(); playerIdx-- != 0; ) {
|
||||
const Animation& player = *mPlayers[playerIdx];
|
||||
const KeyframeEffectReadonly* effect = player.GetEffect();
|
||||
for (size_t animIdx = mAnimations.Length(); animIdx-- != 0; ) {
|
||||
const Animation& anim = *mAnimations[animIdx];
|
||||
const KeyframeEffectReadonly* effect = anim.GetEffect();
|
||||
if (effect &&
|
||||
effect->IsCurrent(player) &&
|
||||
effect->IsCurrent(anim) &&
|
||||
effect->HasAnimationOfProperties(aProperties, aPropertyCount)) {
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -100,7 +100,7 @@ public:
|
|||
return false;
|
||||
}
|
||||
|
||||
// Notify this manager that one of its collections of animation players,
|
||||
// Notify this manager that one of its collections of animations,
|
||||
// has been updated.
|
||||
void NotifyCollectionUpdated(AnimationCollection& aCollection);
|
||||
|
||||
|
@ -223,7 +223,7 @@ private:
|
|||
|
||||
} /* end css sub-namespace */
|
||||
|
||||
typedef InfallibleTArray<nsRefPtr<dom::Animation>> AnimationPlayerPtrArray;
|
||||
typedef InfallibleTArray<nsRefPtr<dom::Animation>> AnimationPtrArray;
|
||||
|
||||
enum EnsureStyleRuleFlags {
|
||||
EnsureStyleRule_IsThrottled,
|
||||
|
@ -258,8 +258,8 @@ struct AnimationCollection : public PRCList
|
|||
|
||||
void Destroy()
|
||||
{
|
||||
for (size_t playerIdx = mPlayers.Length(); playerIdx-- != 0; ) {
|
||||
mPlayers[playerIdx]->Cancel();
|
||||
for (size_t animIdx = mAnimations.Length(); animIdx-- != 0; ) {
|
||||
mAnimations[animIdx]->Cancel();
|
||||
}
|
||||
// This will call our destructor.
|
||||
mElement->DeleteProperty(mElementProperty);
|
||||
|
@ -374,7 +374,7 @@ struct AnimationCollection : public PRCList
|
|||
}
|
||||
}
|
||||
|
||||
void NotifyPlayerUpdated();
|
||||
void NotifyAnimationUpdated();
|
||||
|
||||
static void LogAsyncAnimationFailure(nsCString& aMessage,
|
||||
const nsIContent* aContent = nullptr);
|
||||
|
@ -387,7 +387,7 @@ struct AnimationCollection : public PRCList
|
|||
|
||||
mozilla::css::CommonAnimationManager *mManager;
|
||||
|
||||
mozilla::AnimationPlayerPtrArray mPlayers;
|
||||
mozilla::AnimationPtrArray mAnimations;
|
||||
|
||||
// This style rule contains the style data for currently animating
|
||||
// values. It only matches when styling with animation. When we
|
||||
|
|
|
@ -214,22 +214,22 @@ void
|
|||
nsAnimationManager::QueueEvents(AnimationCollection* aCollection,
|
||||
EventArray& aEventsToDispatch)
|
||||
{
|
||||
for (size_t playerIdx = aCollection->mPlayers.Length(); playerIdx-- != 0; ) {
|
||||
CSSAnimationPlayer* player =
|
||||
aCollection->mPlayers[playerIdx]->AsCSSAnimationPlayer();
|
||||
MOZ_ASSERT(player, "Expected a collection of CSS Animation players");
|
||||
player->QueueEvents(aEventsToDispatch);
|
||||
for (size_t animIdx = aCollection->mAnimations.Length(); animIdx-- != 0; ) {
|
||||
CSSAnimationPlayer* anim =
|
||||
aCollection->mAnimations[animIdx]->AsCSSAnimationPlayer();
|
||||
MOZ_ASSERT(anim, "Expected a collection of CSS Animations");
|
||||
anim->QueueEvents(aEventsToDispatch);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
nsAnimationManager::MaybeUpdateCascadeResults(AnimationCollection* aCollection)
|
||||
{
|
||||
for (size_t playerIdx = aCollection->mPlayers.Length(); playerIdx-- != 0; ) {
|
||||
CSSAnimationPlayer* player =
|
||||
aCollection->mPlayers[playerIdx]->AsCSSAnimationPlayer();
|
||||
for (size_t animIdx = aCollection->mAnimations.Length(); animIdx-- != 0; ) {
|
||||
CSSAnimationPlayer* anim =
|
||||
aCollection->mAnimations[animIdx]->AsCSSAnimationPlayer();
|
||||
|
||||
if (player->IsInEffect() != player->mInEffectForCascadeResults) {
|
||||
if (anim->IsInEffect() != anim->mInEffectForCascadeResults) {
|
||||
// Update our own cascade results.
|
||||
mozilla::dom::Element* element = aCollection->GetElementToRestyle();
|
||||
if (element) {
|
||||
|
@ -291,12 +291,12 @@ nsAnimationManager::CheckAnimationRule(nsStyleContext* aStyleContext,
|
|||
|
||||
// build the animations list
|
||||
dom::DocumentTimeline* timeline = aElement->OwnerDoc()->Timeline();
|
||||
AnimationPlayerPtrArray newPlayers;
|
||||
AnimationPtrArray newAnimations;
|
||||
if (!aStyleContext->IsInDisplayNoneSubtree()) {
|
||||
BuildAnimations(aStyleContext, aElement, timeline, newPlayers);
|
||||
BuildAnimations(aStyleContext, aElement, timeline, newAnimations);
|
||||
}
|
||||
|
||||
if (newPlayers.IsEmpty()) {
|
||||
if (newAnimations.IsEmpty()) {
|
||||
if (collection) {
|
||||
// There might be transitions that run now that animations don't
|
||||
// override them.
|
||||
|
@ -323,10 +323,10 @@ nsAnimationManager::CheckAnimationRule(nsStyleContext* aStyleContext,
|
|||
// In order to honor what the spec said, we'd copy more data over
|
||||
// (or potentially optimize BuildAnimations to avoid rebuilding it
|
||||
// in the first place).
|
||||
if (!collection->mPlayers.IsEmpty()) {
|
||||
if (!collection->mAnimations.IsEmpty()) {
|
||||
|
||||
for (size_t newIdx = newPlayers.Length(); newIdx-- != 0;) {
|
||||
Animation* newPlayer = newPlayers[newIdx];
|
||||
for (size_t newIdx = newAnimations.Length(); newIdx-- != 0;) {
|
||||
Animation* newAnim = newAnimations[newIdx];
|
||||
|
||||
// Find the matching animation with this name in the old list
|
||||
// of animations. We iterate through both lists in a backwards
|
||||
|
@ -334,19 +334,19 @@ nsAnimationManager::CheckAnimationRule(nsStyleContext* aStyleContext,
|
|||
// the new list of animations with a given name than in the old
|
||||
// list, it will be the animations towards the of the beginning of
|
||||
// the list that do not match and are treated as new animations.
|
||||
nsRefPtr<CSSAnimationPlayer> oldPlayer;
|
||||
size_t oldIdx = collection->mPlayers.Length();
|
||||
nsRefPtr<CSSAnimationPlayer> oldAnim;
|
||||
size_t oldIdx = collection->mAnimations.Length();
|
||||
while (oldIdx-- != 0) {
|
||||
CSSAnimationPlayer* a =
|
||||
collection->mPlayers[oldIdx]->AsCSSAnimationPlayer();
|
||||
collection->mAnimations[oldIdx]->AsCSSAnimationPlayer();
|
||||
MOZ_ASSERT(a, "All players in the CSS Animation collection should"
|
||||
" be CSSAnimationPlayer objects");
|
||||
if (a->Name() == newPlayer->Name()) {
|
||||
oldPlayer = a;
|
||||
if (a->Name() == newAnim->Name()) {
|
||||
oldAnim = a;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!oldPlayer) {
|
||||
if (!oldAnim) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -354,9 +354,9 @@ nsAnimationManager::CheckAnimationRule(nsStyleContext* aStyleContext,
|
|||
|
||||
// Update the old from the new so we can keep the original object
|
||||
// identity (and any expando properties attached to it).
|
||||
if (oldPlayer->GetEffect() && newPlayer->GetEffect()) {
|
||||
KeyframeEffectReadonly* oldEffect = oldPlayer->GetEffect();
|
||||
KeyframeEffectReadonly* newEffect = newPlayer->GetEffect();
|
||||
if (oldAnim->GetEffect() && newAnim->GetEffect()) {
|
||||
KeyframeEffectReadonly* oldEffect = oldAnim->GetEffect();
|
||||
KeyframeEffectReadonly* newEffect = newAnim->GetEffect();
|
||||
animationChanged =
|
||||
oldEffect->Timing() != newEffect->Timing() ||
|
||||
oldEffect->Properties() != newEffect->Properties();
|
||||
|
@ -365,56 +365,56 @@ nsAnimationManager::CheckAnimationRule(nsStyleContext* aStyleContext,
|
|||
}
|
||||
|
||||
// Reset compositor state so animation will be re-synchronized.
|
||||
oldPlayer->ClearIsRunningOnCompositor();
|
||||
oldAnim->ClearIsRunningOnCompositor();
|
||||
|
||||
// Handle changes in play state.
|
||||
// CSSAnimationPlayer takes care of override behavior so that,
|
||||
// for example, if the author has called pause(), that will
|
||||
// override the animation-play-state.
|
||||
// (We should check newPlayer->IsStylePaused() but that requires
|
||||
// (We should check newAnim->IsStylePaused() but that requires
|
||||
// downcasting to CSSAnimationPlayer and we happen to know that
|
||||
// newPlayer will only ever be paused by calling PauseFromStyle
|
||||
// newAnim will only ever be paused by calling PauseFromStyle
|
||||
// making IsPausedOrPausing synonymous in this case.)
|
||||
if (!oldPlayer->IsStylePaused() && newPlayer->IsPausedOrPausing()) {
|
||||
oldPlayer->PauseFromStyle();
|
||||
if (!oldAnim->IsStylePaused() && newAnim->IsPausedOrPausing()) {
|
||||
oldAnim->PauseFromStyle();
|
||||
animationChanged = true;
|
||||
} else if (oldPlayer->IsStylePaused() &&
|
||||
!newPlayer->IsPausedOrPausing()) {
|
||||
oldPlayer->PlayFromStyle();
|
||||
} else if (oldAnim->IsStylePaused() &&
|
||||
!newAnim->IsPausedOrPausing()) {
|
||||
oldAnim->PlayFromStyle();
|
||||
animationChanged = true;
|
||||
}
|
||||
|
||||
if (animationChanged) {
|
||||
nsNodeUtils::AnimationChanged(oldPlayer);
|
||||
nsNodeUtils::AnimationChanged(oldAnim);
|
||||
}
|
||||
|
||||
// Replace new animation with the (updated) old one and remove the
|
||||
// old one from the array so we don't try to match it any more.
|
||||
//
|
||||
// Although we're doing this while iterating this is safe because
|
||||
// we're not changing the length of newPlayers and we've finished
|
||||
// we're not changing the length of newAnimations and we've finished
|
||||
// iterating over the list of old iterations.
|
||||
newPlayer->Cancel();
|
||||
newPlayer = nullptr;
|
||||
newPlayers.ReplaceElementAt(newIdx, oldPlayer);
|
||||
collection->mPlayers.RemoveElementAt(oldIdx);
|
||||
newAnim->Cancel();
|
||||
newAnim = nullptr;
|
||||
newAnimations.ReplaceElementAt(newIdx, oldAnim);
|
||||
collection->mAnimations.RemoveElementAt(oldIdx);
|
||||
|
||||
// We've touched the old animation's timing properties, so this
|
||||
// could update the old player's relevance.
|
||||
oldPlayer->UpdateRelevance();
|
||||
// could update the old animation's relevance.
|
||||
oldAnim->UpdateRelevance();
|
||||
}
|
||||
}
|
||||
} else {
|
||||
collection =
|
||||
GetAnimations(aElement, aStyleContext->GetPseudoType(), true);
|
||||
}
|
||||
collection->mPlayers.SwapElements(newPlayers);
|
||||
collection->mAnimations.SwapElements(newAnimations);
|
||||
collection->mNeedsRefreshes = true;
|
||||
collection->Tick();
|
||||
|
||||
// Cancel removed animations
|
||||
for (size_t newPlayerIdx = newPlayers.Length(); newPlayerIdx-- != 0; ) {
|
||||
newPlayers[newPlayerIdx]->Cancel();
|
||||
for (size_t newAnimIdx = newAnimations.Length(); newAnimIdx-- != 0; ) {
|
||||
newAnimations[newAnimIdx]->Cancel();
|
||||
}
|
||||
|
||||
UpdateCascadeResults(aStyleContext, collection);
|
||||
|
@ -488,9 +488,9 @@ void
|
|||
nsAnimationManager::BuildAnimations(nsStyleContext* aStyleContext,
|
||||
dom::Element* aTarget,
|
||||
dom::DocumentTimeline* aTimeline,
|
||||
AnimationPlayerPtrArray& aPlayers)
|
||||
AnimationPtrArray& aAnimations)
|
||||
{
|
||||
MOZ_ASSERT(aPlayers.IsEmpty(), "expect empty array");
|
||||
MOZ_ASSERT(aAnimations.IsEmpty(), "expect empty array");
|
||||
|
||||
ResolvedStyleCache resolvedStyles;
|
||||
|
||||
|
@ -516,7 +516,7 @@ nsAnimationManager::BuildAnimations(nsStyleContext* aStyleContext,
|
|||
}
|
||||
|
||||
nsRefPtr<CSSAnimationPlayer> dest = new CSSAnimationPlayer(aTimeline);
|
||||
aPlayers.AppendElement(dest);
|
||||
aAnimations.AppendElement(dest);
|
||||
|
||||
AnimationTiming timing;
|
||||
timing.mIterationDuration =
|
||||
|
@ -533,8 +533,9 @@ nsAnimationManager::BuildAnimations(nsStyleContext* aStyleContext,
|
|||
dest->SetEffect(destEffect);
|
||||
|
||||
// Even in the case where we call PauseFromStyle below, we still need to
|
||||
// call PlayFromStyle first. This is because a newly-created player is idle
|
||||
// and has no effect until it is played (or otherwise given a start time).
|
||||
// call PlayFromStyle first. This is because a newly-created animation is
|
||||
// idle and has no effect until it is played (or otherwise given a start
|
||||
// time).
|
||||
dest->PlayFromStyle();
|
||||
|
||||
if (src.GetPlayState() == NS_STYLE_ANIMATION_PLAY_STATE_PAUSED) {
|
||||
|
@ -750,10 +751,10 @@ nsAnimationManager::UpdateCascadeResults(
|
|||
{
|
||||
nsCSSPropertySet propertiesToTrackAsSet;
|
||||
|
||||
for (size_t playerIdx = aElementAnimations->mPlayers.Length();
|
||||
playerIdx-- != 0; ) {
|
||||
const Animation* player = aElementAnimations->mPlayers[playerIdx];
|
||||
const KeyframeEffectReadonly* effect = player->GetEffect();
|
||||
for (size_t animIdx = aElementAnimations->mAnimations.Length();
|
||||
animIdx-- != 0; ) {
|
||||
const Animation* anim = aElementAnimations->mAnimations[animIdx];
|
||||
const KeyframeEffectReadonly* effect = anim->GetEffect();
|
||||
if (!effect) {
|
||||
continue;
|
||||
}
|
||||
|
@ -797,13 +798,13 @@ nsAnimationManager::UpdateCascadeResults(
|
|||
*/
|
||||
|
||||
bool changed = false;
|
||||
for (size_t playerIdx = aElementAnimations->mPlayers.Length();
|
||||
playerIdx-- != 0; ) {
|
||||
CSSAnimationPlayer* player =
|
||||
aElementAnimations->mPlayers[playerIdx]->AsCSSAnimationPlayer();
|
||||
KeyframeEffectReadonly* effect = player->GetEffect();
|
||||
for (size_t animIdx = aElementAnimations->mAnimations.Length();
|
||||
animIdx-- != 0; ) {
|
||||
CSSAnimationPlayer* anim =
|
||||
aElementAnimations->mAnimations[animIdx]->AsCSSAnimationPlayer();
|
||||
KeyframeEffectReadonly* effect = anim->GetEffect();
|
||||
|
||||
player->mInEffectForCascadeResults = player->IsInEffect();
|
||||
anim->mInEffectForCascadeResults = anim->IsInEffect();
|
||||
|
||||
if (!effect) {
|
||||
continue;
|
||||
|
@ -823,7 +824,7 @@ nsAnimationManager::UpdateCascadeResults(
|
|||
}
|
||||
prop.mWinsInCascade = newWinsInCascade;
|
||||
|
||||
if (prop.mWinsInCascade && player->mInEffectForCascadeResults) {
|
||||
if (prop.mWinsInCascade && anim->mInEffectForCascadeResults) {
|
||||
// This animation is in effect right now, so it overrides
|
||||
// earlier animations. (For animations that aren't in effect,
|
||||
// we set mWinsInCascade as though they were, but they don't
|
||||
|
|
|
@ -237,7 +237,7 @@ private:
|
|||
void BuildAnimations(nsStyleContext* aStyleContext,
|
||||
mozilla::dom::Element* aTarget,
|
||||
mozilla::dom::DocumentTimeline* aTimeline,
|
||||
mozilla::AnimationPlayerPtrArray& aAnimations);
|
||||
mozilla::AnimationPtrArray& aAnimations);
|
||||
bool BuildSegment(InfallibleTArray<mozilla::AnimationPropertySegment>&
|
||||
aSegments,
|
||||
nsCSSProperty aProperty,
|
||||
|
|
|
@ -312,14 +312,14 @@ nsTransitionManager::StyleContextChanged(dom::Element *aElement,
|
|||
}
|
||||
}
|
||||
|
||||
AnimationPlayerPtrArray& players = collection->mPlayers;
|
||||
size_t i = players.Length();
|
||||
AnimationPtrArray& animations = collection->mAnimations;
|
||||
size_t i = animations.Length();
|
||||
MOZ_ASSERT(i != 0, "empty transitions list?");
|
||||
StyleAnimationValue currentValue;
|
||||
do {
|
||||
--i;
|
||||
Animation* player = players[i];
|
||||
dom::KeyframeEffectReadonly* effect = player->GetEffect();
|
||||
Animation* anim = animations[i];
|
||||
dom::KeyframeEffectReadonly* effect = anim->GetEffect();
|
||||
MOZ_ASSERT(effect && effect->Properties().Length() == 1,
|
||||
"Should have one animation property for a transition");
|
||||
MOZ_ASSERT(effect && effect->Properties()[0].mSegments.Length() == 1,
|
||||
|
@ -338,15 +338,15 @@ nsTransitionManager::StyleContextChanged(dom::Element *aElement,
|
|||
currentValue) ||
|
||||
currentValue != segment.mToValue) {
|
||||
// stop the transition
|
||||
if (!player->GetEffect()->IsFinishedTransition()) {
|
||||
player->Cancel();
|
||||
if (!anim->GetEffect()->IsFinishedTransition()) {
|
||||
anim->Cancel();
|
||||
collection->UpdateAnimationGeneration(mPresContext);
|
||||
}
|
||||
players.RemoveElementAt(i);
|
||||
animations.RemoveElementAt(i);
|
||||
}
|
||||
} while (i != 0);
|
||||
|
||||
if (players.IsEmpty()) {
|
||||
if (animations.IsEmpty()) {
|
||||
collection->Destroy();
|
||||
collection = nullptr;
|
||||
}
|
||||
|
@ -431,10 +431,10 @@ nsTransitionManager::ConsiderStartingTransition(
|
|||
size_t currentIndex = nsTArray<ElementPropertyTransition>::NoIndex;
|
||||
const ElementPropertyTransition *oldPT = nullptr;
|
||||
if (aElementTransitions) {
|
||||
AnimationPlayerPtrArray& players = aElementTransitions->mPlayers;
|
||||
for (size_t i = 0, i_end = players.Length(); i < i_end; ++i) {
|
||||
AnimationPtrArray& animations = aElementTransitions->mAnimations;
|
||||
for (size_t i = 0, i_end = animations.Length(); i < i_end; ++i) {
|
||||
const ElementPropertyTransition *iPt =
|
||||
players[i]->GetEffect()->AsTransition();
|
||||
animations[i]->GetEffect()->AsTransition();
|
||||
if (iPt->TransitionProperty() == aProperty) {
|
||||
haveCurrentTransition = true;
|
||||
currentIndex = i;
|
||||
|
@ -474,13 +474,13 @@ nsTransitionManager::ConsiderStartingTransition(
|
|||
// in-progress value (which is particularly easy to cause when we're
|
||||
// currently in the 'transition-delay'). It also might happen because we
|
||||
// just got a style change to a value that can't be interpolated.
|
||||
AnimationPlayerPtrArray& players = aElementTransitions->mPlayers;
|
||||
players[currentIndex]->Cancel();
|
||||
AnimationPtrArray& animations = aElementTransitions->mAnimations;
|
||||
animations[currentIndex]->Cancel();
|
||||
oldPT = nullptr; // Clear pointer so it doesn't dangle
|
||||
players.RemoveElementAt(currentIndex);
|
||||
animations.RemoveElementAt(currentIndex);
|
||||
aElementTransitions->UpdateAnimationGeneration(mPresContext);
|
||||
|
||||
if (players.IsEmpty()) {
|
||||
if (animations.IsEmpty()) {
|
||||
aElementTransitions->Destroy();
|
||||
// |aElementTransitions| is now a dangling pointer!
|
||||
aElementTransitions = nullptr;
|
||||
|
@ -564,13 +564,13 @@ nsTransitionManager::ConsiderStartingTransition(
|
|||
segment.mToKey = 1;
|
||||
segment.mTimingFunction.Init(tf);
|
||||
|
||||
nsRefPtr<CSSTransitionPlayer> player = new CSSTransitionPlayer(timeline);
|
||||
nsRefPtr<CSSTransitionPlayer> animation = new CSSTransitionPlayer(timeline);
|
||||
// The order of the following two calls is important since PlayFromStyle
|
||||
// will add the player to the PendingAnimationTracker of its effect's
|
||||
// will add the animation to the PendingAnimationTracker of its effect's
|
||||
// document. When we come to make effect writeable (bug 1049975) we should
|
||||
// remove this dependency.
|
||||
player->SetEffect(pt);
|
||||
player->PlayFromStyle();
|
||||
animation->SetEffect(pt);
|
||||
animation->PlayFromStyle();
|
||||
|
||||
if (!aElementTransitions) {
|
||||
aElementTransitions =
|
||||
|
@ -581,23 +581,23 @@ nsTransitionManager::ConsiderStartingTransition(
|
|||
}
|
||||
}
|
||||
|
||||
AnimationPlayerPtrArray& players = aElementTransitions->mPlayers;
|
||||
AnimationPtrArray& animations = aElementTransitions->mAnimations;
|
||||
#ifdef DEBUG
|
||||
for (size_t i = 0, i_end = players.Length(); i < i_end; ++i) {
|
||||
for (size_t i = 0, i_end = animations.Length(); i < i_end; ++i) {
|
||||
MOZ_ASSERT(
|
||||
i == currentIndex ||
|
||||
(players[i]->GetEffect() &&
|
||||
players[i]->GetEffect()->AsTransition()->TransitionProperty()
|
||||
(animations[i]->GetEffect() &&
|
||||
animations[i]->GetEffect()->AsTransition()->TransitionProperty()
|
||||
!= aProperty),
|
||||
"duplicate transitions for property");
|
||||
}
|
||||
#endif
|
||||
if (haveCurrentTransition) {
|
||||
players[currentIndex]->Cancel();
|
||||
animations[currentIndex]->Cancel();
|
||||
oldPT = nullptr; // Clear pointer so it doesn't dangle
|
||||
players[currentIndex] = player;
|
||||
animations[currentIndex] = animation;
|
||||
} else {
|
||||
if (!players.AppendElement(player)) {
|
||||
if (!animations.AppendElement(animation)) {
|
||||
NS_WARNING("out of memory");
|
||||
return;
|
||||
}
|
||||
|
@ -674,12 +674,12 @@ nsTransitionManager::UpdateCascadeResults(AnimationCollection* aTransitions,
|
|||
// property, it doesn't matter what order we iterate the transitions.
|
||||
// But let's go the same way as animations.
|
||||
bool changed = false;
|
||||
AnimationPlayerPtrArray& players = aTransitions->mPlayers;
|
||||
for (size_t playerIdx = players.Length(); playerIdx-- != 0; ) {
|
||||
MOZ_ASSERT(players[playerIdx]->GetEffect() &&
|
||||
players[playerIdx]->GetEffect()->Properties().Length() == 1,
|
||||
AnimationPtrArray& animations = aTransitions->mAnimations;
|
||||
for (size_t animIdx = animations.Length(); animIdx-- != 0; ) {
|
||||
MOZ_ASSERT(animations[animIdx]->GetEffect() &&
|
||||
animations[animIdx]->GetEffect()->Properties().Length() == 1,
|
||||
"Should have one animation property for a transition");
|
||||
AnimationProperty& prop = players[playerIdx]->GetEffect()->Properties()[0];
|
||||
AnimationProperty& prop = animations[animIdx]->GetEffect()->Properties()[0];
|
||||
bool newWinsInCascade = !propertiesUsed.HasProperty(prop.mProperty);
|
||||
if (prop.mWinsInCascade != newWinsInCascade) {
|
||||
changed = true;
|
||||
|
@ -797,22 +797,21 @@ nsTransitionManager::FlushTransitions(FlushFlags aFlags)
|
|||
"Element::UnbindFromTree should have "
|
||||
"destroyed the element transitions object");
|
||||
|
||||
size_t i = collection->mPlayers.Length();
|
||||
size_t i = collection->mAnimations.Length();
|
||||
MOZ_ASSERT(i != 0, "empty transitions list?");
|
||||
bool transitionStartedOrEnded = false;
|
||||
do {
|
||||
--i;
|
||||
Animation* player = collection->mPlayers[i];
|
||||
if (!player->GetEffect()->IsFinishedTransition()) {
|
||||
MOZ_ASSERT(player->GetEffect(),
|
||||
"Transitions should have an effect");
|
||||
Animation* anim = collection->mAnimations[i];
|
||||
if (!anim->GetEffect()->IsFinishedTransition()) {
|
||||
MOZ_ASSERT(anim->GetEffect(), "Transitions should have an effect");
|
||||
ComputedTiming computedTiming =
|
||||
player->GetEffect()->GetComputedTiming();
|
||||
anim->GetEffect()->GetComputedTiming();
|
||||
if (computedTiming.mPhase == ComputedTiming::AnimationPhase_After) {
|
||||
nsCSSProperty prop =
|
||||
player->GetEffect()->AsTransition()->TransitionProperty();
|
||||
anim->GetEffect()->AsTransition()->TransitionProperty();
|
||||
TimeDuration duration =
|
||||
player->GetEffect()->Timing().mIterationDuration;
|
||||
anim->GetEffect()->Timing().mIterationDuration;
|
||||
events.AppendElement(
|
||||
TransitionEventInfo(collection->mElement, prop,
|
||||
duration,
|
||||
|
@ -825,13 +824,13 @@ nsTransitionManager::FlushTransitions(FlushFlags aFlags)
|
|||
// a non-animation style change that would affect it, we need
|
||||
// to know not to start a new transition for the transition
|
||||
// from the almost-completed value to the final value.
|
||||
player->GetEffect()->SetIsFinishedTransition(true);
|
||||
anim->GetEffect()->SetIsFinishedTransition(true);
|
||||
collection->UpdateAnimationGeneration(mPresContext);
|
||||
transitionStartedOrEnded = true;
|
||||
} else if ((computedTiming.mPhase ==
|
||||
ComputedTiming::AnimationPhase_Active) &&
|
||||
canThrottleTick &&
|
||||
!player->IsRunningOnCompositor()) {
|
||||
!anim->IsRunningOnCompositor()) {
|
||||
// Start a transition with a delay where we should start the
|
||||
// transition proper.
|
||||
collection->UpdateAnimationGeneration(mPresContext);
|
||||
|
@ -855,7 +854,7 @@ nsTransitionManager::FlushTransitions(FlushFlags aFlags)
|
|||
didThrottle = true;
|
||||
}
|
||||
|
||||
if (collection->mPlayers.IsEmpty()) {
|
||||
if (collection->mAnimations.IsEmpty()) {
|
||||
collection->Destroy();
|
||||
// |collection| is now a dangling pointer!
|
||||
collection = nullptr;
|
||||
|
|
Загрузка…
Ссылка в новой задаче