author | Brian Birtles <birtles@gmail.com> |
Tue, 21 Apr 2015 10:22:10 +0900 | |
changeset 240078 | 2bb61d7addb344c0ac6eac3a9dad1df564f48c0e |
parent 240077 | 675592491434e6eaff47f551938cff48ebd76443 |
child 240079 | 023fdd5ebd3fe2bcb7c75b3bb68663700da6f4ae |
push id | 28621 |
push user | cbook@mozilla.com |
push date | Tue, 21 Apr 2015 09:59:54 +0000 |
treeherder | mozilla-central@ef3c6dd09234 [default view] [failures only] |
perfherder | [talos] [build metrics] [platform microbench] (compared to previous push) |
reviewers | jwatt |
bugs | 1154615 |
milestone | 40.0a1 |
first release with | nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
|
last release without | nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
|
--- a/dom/animation/Animation.cpp +++ b/dom/animation/Animation.cpp @@ -2,17 +2,17 @@ /* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ #include "Animation.h" #include "AnimationUtils.h" #include "mozilla/dom/AnimationBinding.h" #include "mozilla/AutoRestore.h" -#include "AnimationCommon.h" // For AnimationPlayerCollection, +#include "AnimationCommon.h" // For AnimationCollection, // CommonAnimationManager #include "nsIDocument.h" // For nsIDocument #include "nsIPresShell.h" // For nsIPresShell #include "nsLayoutUtils.h" // For PostRestyleEvent (remove after bug 1073336) #include "PendingAnimationTracker.h" // For PendingAnimationTracker namespace mozilla { namespace dom { @@ -724,17 +724,17 @@ Animation::FlushStyle() const if (doc) { doc->FlushPendingNotifications(Flush_Style); } } void Animation::PostUpdate() { - AnimationPlayerCollection* collection = GetCollection(); + AnimationCollection* collection = GetCollection(); if (collection) { collection->NotifyPlayerUpdated(); } } void Animation::CancelPendingTasks() { @@ -862,17 +862,17 @@ Animation::GetPresContext() const } nsIPresShell* shell = doc->GetShell(); if (!shell) { return nullptr; } return shell->GetPresContext(); } -AnimationPlayerCollection* +AnimationCollection* Animation::GetCollection() const { css::CommonAnimationManager* manager = GetAnimationManager(); if (!manager) { return nullptr; } MOZ_ASSERT(mEffect, "An animation with an animation manager must have an effect");
--- a/dom/animation/Animation.h +++ b/dom/animation/Animation.h @@ -28,17 +28,17 @@ #endif struct JSContext; class nsCSSPropertySet; class nsIDocument; class nsPresContext; namespace mozilla { -struct AnimationPlayerCollection; +struct AnimationCollection; namespace css { class AnimValuesStyleRule; class CommonAnimationManager; } // namespace css class CSSAnimationPlayer; class CSSTransitionPlayer; @@ -296,17 +296,17 @@ protected: bool IsFinished() const; bool IsPossiblyOrphanedPendingAnimation() const; StickyTimeDuration EffectEnd() const; nsIDocument* GetRenderedDocument() const; nsPresContext* GetPresContext() const; virtual css::CommonAnimationManager* GetAnimationManager() const = 0; - AnimationPlayerCollection* GetCollection() const; + AnimationCollection* GetCollection() const; nsRefPtr<DocumentTimeline> mTimeline; nsRefPtr<KeyframeEffectReadonly> mEffect; // The beginning of the delay period. Nullable<TimeDuration> mStartTime; // Timeline timescale Nullable<TimeDuration> mHoldTime; // Animation timescale Nullable<TimeDuration> mPendingReadyTime; // Timeline timescale Nullable<TimeDuration> mPreviousCurrentTime; // Animation timescale
--- a/dom/animation/KeyframeEffect.cpp +++ b/dom/animation/KeyframeEffect.cpp @@ -320,17 +320,17 @@ KeyframeEffectReadonly::ComposeStyle( { const AnimationProperty& prop = mProperties[propIdx]; MOZ_ASSERT(prop.mSegments[0].mFromKey == 0.0, "incorrect first from key"); MOZ_ASSERT(prop.mSegments[prop.mSegments.Length() - 1].mToKey == 1.0, "incorrect last to key"); if (aSetProperties.HasProperty(prop.mProperty)) { - // Animations are composed by AnimationPlayerCollection by iterating + // Animations are composed by AnimationCollection by iterating // from the last animation to first. For animations targetting the // same property, the later one wins. So if this property is already set, // we should not override it. continue; } if (!prop.mWinsInCascade) { // This isn't the winning declaration, so don't add it to style.
--- a/dom/base/Element.cpp +++ b/dom/base/Element.cpp @@ -3192,18 +3192,18 @@ Element::GetAnimations(nsTArray<nsRefPtr if (doc) { doc->FlushPendingNotifications(Flush_Style); } nsIAtom* properties[] = { nsGkAtoms::transitionsProperty, nsGkAtoms::animationsProperty }; for (size_t propIdx = 0; propIdx < MOZ_ARRAY_LENGTH(properties); propIdx++) { - AnimationPlayerCollection* collection = - static_cast<AnimationPlayerCollection*>( + AnimationCollection* collection = + static_cast<AnimationCollection*>( GetProperty(properties[propIdx])); if (!collection) { continue; } for (size_t playerIdx = 0; playerIdx < collection->mPlayers.Length(); playerIdx++) { Animation* player = collection->mPlayers[playerIdx];
--- a/layout/base/RestyleManager.cpp +++ b/layout/base/RestyleManager.cpp @@ -1228,20 +1228,20 @@ RestyleManager::GetMaxAnimationGeneratio { nsIContent* content = aFrame->GetContent(); if (!content || !content->IsElement()) { return 0; } nsCSSPseudoElements::Type pseudoType = aFrame->StyleContext()->GetPseudoType(); - AnimationPlayerCollection* transitions = + AnimationCollection* transitions = aFrame->PresContext()->TransitionManager()->GetAnimations( content->AsElement(), pseudoType, false /* don't create */); - AnimationPlayerCollection* animations = + AnimationCollection* animations = aFrame->PresContext()->AnimationManager()->GetAnimations( content->AsElement(), pseudoType, false /* don't create */); return std::max(transitions ? transitions->mAnimationGeneration : 0, animations ? animations->mAnimationGeneration : 0); } void
--- a/layout/base/nsDisplayList.cpp +++ b/layout/base/nsDisplayList.cpp @@ -498,19 +498,19 @@ nsDisplayListBuilder::AddAnimationsAndTr uint64_t animationGeneration = RestyleManager::GetMaxAnimationGenerationForFrame(aFrame); aLayer->SetAnimationGeneration(animationGeneration); nsIContent* content = aFrame->GetContent(); if (!content) { return; } - AnimationPlayerCollection* transitions = + AnimationCollection* transitions = nsTransitionManager::GetAnimationsForCompositor(content, aProperty); - AnimationPlayerCollection* animations = + AnimationCollection* animations = nsAnimationManager::GetAnimationsForCompositor(content, aProperty); if (!animations && !transitions) { return; } // If the frame is not prerendered, bail out. // Do this check only during layer construction; during updating the @@ -5452,18 +5452,18 @@ nsDisplayOpacity::CanUseAsyncAnimations( { if (ActiveLayerTracker::IsStyleAnimated(aBuilder, mFrame, eCSSProperty_opacity)) { return true; } if (nsLayoutUtils::IsAnimationLoggingEnabled()) { nsCString message; message.AppendLiteral("Performance warning: Async animation disabled because frame was not marked active for opacity animation"); - AnimationPlayerCollection::LogAsyncAnimationFailure(message, - Frame()->GetContent()); + AnimationCollection::LogAsyncAnimationFailure(message, + Frame()->GetContent()); } return false; } bool nsDisplayTransform::ShouldPrerender(nsDisplayListBuilder* aBuilder) { if (!mMaybePrerender) { return false; @@ -5506,18 +5506,18 @@ nsDisplayTransform::ShouldPrerenderTrans // the ActiveLayerManager may not have been notified yet. if (!ActiveLayerTracker::IsStyleMaybeAnimated(aFrame, eCSSProperty_transform) && (!aFrame->GetContent() || !nsLayoutUtils::HasAnimationsForCompositor(aFrame->GetContent(), eCSSProperty_transform))) { if (aLogAnimations) { nsCString message; message.AppendLiteral("Performance warning: Async animation disabled because frame was not marked active for transform animation"); - AnimationPlayerCollection::LogAsyncAnimationFailure(message, - aFrame->GetContent()); + AnimationCollection::LogAsyncAnimationFailure(message, + aFrame->GetContent()); } return false; } nsSize refSize = aBuilder->RootReferenceFrame()->GetSize(); // Only prerender if the transformed frame's size is <= the // reference frame size (~viewport), allowing a 1/8th fuzz factor // for shadows, borders, etc. @@ -5546,18 +5546,18 @@ nsDisplayTransform::ShouldPrerenderTrans message.AppendInt(nsPresContext::AppUnitsToIntCSSPixels(refSize.height)); message.AppendLiteral(") or the visual rectangle ("); message.AppendInt(nsPresContext::AppUnitsToIntCSSPixels(visual.width)); message.AppendLiteral(", "); message.AppendInt(nsPresContext::AppUnitsToIntCSSPixels(visual.height)); message.AppendLiteral(") is larger than the max allowable value ("); message.AppendInt(nsPresContext::AppUnitsToIntCSSPixels(maxInAppUnits)); message.Append(')'); - AnimationPlayerCollection::LogAsyncAnimationFailure(message, - aFrame->GetContent()); + AnimationCollection::LogAsyncAnimationFailure(message, + aFrame->GetContent()); } return false; } /* If the matrix is singular, or a hidden backface is shown, the frame won't be visible or hit. */ static bool IsFrameVisible(nsIFrame* aFrame, const Matrix4x4& aMatrix) { if (aMatrix.IsSingular()) {
--- a/layout/base/nsLayoutUtils.cpp +++ b/layout/base/nsLayoutUtils.cpp @@ -371,23 +371,23 @@ TextAlignTrueEnabledPrefChangeCallback(c bool nsLayoutUtils::HasAnimationsForCompositor(nsIContent* aContent, nsCSSProperty aProperty) { return nsAnimationManager::GetAnimationsForCompositor(aContent, aProperty) || nsTransitionManager::GetAnimationsForCompositor(aContent, aProperty); } -static AnimationPlayerCollection* +static AnimationCollection* GetAnimationsOrTransitions(nsIContent* aContent, nsIAtom* aAnimationProperty, nsCSSProperty aProperty) { - AnimationPlayerCollection* collection = - static_cast<AnimationPlayerCollection*>(aContent->GetProperty( + AnimationCollection* collection = + static_cast<AnimationCollection*>(aContent->GetProperty( aAnimationProperty)); if (collection) { bool propertyMatches = collection->HasAnimationOfProperty(aProperty); if (propertyMatches) { return collection; } } return nullptr; @@ -407,36 +407,36 @@ nsLayoutUtils::HasAnimations(nsIContent* bool nsLayoutUtils::HasCurrentAnimations(nsIContent* aContent, nsIAtom* aAnimationProperty) { if (!aContent->MayHaveAnimations()) return false; - AnimationPlayerCollection* collection = - static_cast<AnimationPlayerCollection*>( + AnimationCollection* collection = + static_cast<AnimationCollection*>( aContent->GetProperty(aAnimationProperty)); return (collection && collection->HasCurrentAnimations()); } bool nsLayoutUtils::HasCurrentAnimationsForProperties(nsIContent* aContent, const nsCSSProperty* aProperties, size_t aPropertyCount) { if (!aContent->MayHaveAnimations()) return false; static nsIAtom* const sAnimProps[] = { nsGkAtoms::transitionsProperty, nsGkAtoms::animationsProperty, nullptr }; for (nsIAtom* const* animProp = sAnimProps; *animProp; animProp++) { - AnimationPlayerCollection* collection = - static_cast<AnimationPlayerCollection*>(aContent->GetProperty(*animProp)); + AnimationCollection* collection = + static_cast<AnimationCollection*>(aContent->GetProperty(*animProp)); if (collection && collection->HasCurrentAnimationsForProperties(aProperties, aPropertyCount)) { return true; } } return false; @@ -491,22 +491,22 @@ GetSuitableScale(float aMaxScale, float return aMaxScale; } return 1.0f; } static void GetMinAndMaxScaleForAnimationProperty(nsIContent* aContent, - AnimationPlayerCollection* aPlayers, + AnimationCollection* aAnimations, gfxSize& aMaxScale, gfxSize& aMinScale) { - for (size_t playerIdx = aPlayers->mPlayers.Length(); playerIdx-- != 0; ) { - dom::Animation* player = aPlayers->mPlayers[playerIdx]; + for (size_t playerIdx = aAnimations->mPlayers.Length(); playerIdx-- != 0; ) { + dom::Animation* player = aAnimations->mPlayers[playerIdx]; if (!player->GetEffect() || player->GetEffect()->IsFinishedTransition()) { continue; } dom::KeyframeEffectReadonly* effect = player->GetEffect(); for (size_t propIdx = effect->Properties().Length(); propIdx-- != 0; ) { AnimationProperty& prop = effect->Properties()[propIdx]; if (prop.mProperty == eCSSProperty_transform) { for (uint32_t segIdx = prop.mSegments.Length(); segIdx-- != 0; ) { @@ -532,17 +532,17 @@ GetMinAndMaxScaleForAnimationProperty(ns gfxSize nsLayoutUtils::ComputeSuitableScaleForAnimation(nsIContent* aContent) { gfxSize maxScale(std::numeric_limits<gfxFloat>::min(), std::numeric_limits<gfxFloat>::min()); gfxSize minScale(std::numeric_limits<gfxFloat>::max(), std::numeric_limits<gfxFloat>::max()); - AnimationPlayerCollection* animations = + AnimationCollection* animations = nsAnimationManager::GetAnimationsForCompositor(aContent, eCSSProperty_transform); if (animations) { GetMinAndMaxScaleForAnimationProperty(aContent, animations, maxScale, minScale); } animations =
--- a/layout/style/AnimationCommon.cpp +++ b/layout/style/AnimationCommon.cpp @@ -69,37 +69,35 @@ CommonAnimationManager::Disconnect() { // Content nodes might outlive the transition or animation manager. RemoveAllElementCollections(); mPresContext = nullptr; } void -CommonAnimationManager::AddElementCollection(AnimationPlayerCollection* - aCollection) +CommonAnimationManager::AddElementCollection(AnimationCollection* aCollection) { if (!mIsObservingRefreshDriver) { NS_ASSERTION(aCollection->mNeedsRefreshes, "Added data which doesn't need refreshing?"); // We need to observe the refresh driver. mPresContext->RefreshDriver()->AddRefreshObserver(this, Flush_Style); mIsObservingRefreshDriver = true; } PR_INSERT_BEFORE(aCollection, &mElementCollections); } void CommonAnimationManager::RemoveAllElementCollections() { while (!PR_CLIST_IS_EMPTY(&mElementCollections)) { - AnimationPlayerCollection* head = - static_cast<AnimationPlayerCollection*>( - PR_LIST_HEAD(&mElementCollections)); + AnimationCollection* head = + static_cast<AnimationCollection*>(PR_LIST_HEAD(&mElementCollections)); head->Destroy(); } } void CommonAnimationManager::MaybeStartObservingRefreshDriver() { if (mIsObservingRefreshDriver || !NeedsRefresh()) { @@ -123,38 +121,37 @@ CommonAnimationManager::MaybeStartOrStop } bool CommonAnimationManager::NeedsRefresh() const { for (PRCList *l = PR_LIST_HEAD(&mElementCollections); l != &mElementCollections; l = PR_NEXT_LINK(l)) { - if (static_cast<AnimationPlayerCollection*>(l)->mNeedsRefreshes) { + if (static_cast<AnimationCollection*>(l)->mNeedsRefreshes) { return true; } } return false; } -AnimationPlayerCollection* +AnimationCollection* CommonAnimationManager::GetAnimationsForCompositor(nsIContent* aContent, nsIAtom* aElementProperty, nsCSSProperty aProperty) { if (!aContent->MayHaveAnimations()) return nullptr; - AnimationPlayerCollection* collection = - static_cast<AnimationPlayerCollection*>( - aContent->GetProperty(aElementProperty)); + AnimationCollection* collection = + static_cast<AnimationCollection*>(aContent->GetProperty(aElementProperty)); if (!collection || !collection->HasAnimationOfProperty(aProperty) || !collection->CanPerformOnCompositorThread( - AnimationPlayerCollection::CanAnimate_AllowPartial)) { + AnimationCollection::CanAnimate_AllowPartial)) { return nullptr; } // This animation can be done on the compositor. return collection; } /* @@ -258,33 +255,32 @@ CommonAnimationManager::SizeOfIncludingT void CommonAnimationManager::AddStyleUpdatesTo(RestyleTracker& aTracker) { TimeStamp now = mPresContext->RefreshDriver()->MostRecentRefresh(); PRCList* next = PR_LIST_HEAD(&mElementCollections); while (next != &mElementCollections) { - AnimationPlayerCollection* collection = - static_cast<AnimationPlayerCollection*>(next); + AnimationCollection* collection = static_cast<AnimationCollection*>(next); next = PR_NEXT_LINK(next); collection->EnsureStyleRuleFor(now, EnsureStyleRule_IsNotThrottled); dom::Element* elementToRestyle = collection->GetElementToRestyle(); if (elementToRestyle) { nsRestyleHint rshint = collection->IsForTransitions() ? eRestyle_CSSTransitions : eRestyle_CSSAnimations; aTracker.AddPendingRestyle(elementToRestyle, rshint, nsChangeHint(0)); } } } void -CommonAnimationManager::NotifyCollectionUpdated(AnimationPlayerCollection& +CommonAnimationManager::NotifyCollectionUpdated(AnimationCollection& aCollection) { MaybeStartObservingRefreshDriver(); mPresContext->ClearLastStyleUpdateForAllAnimations(); mPresContext->RestyleManager()->IncrementAnimationGeneration(); aCollection.UpdateAnimationGeneration(mPresContext); aCollection.PostRestyleForAnimation(mPresContext); } @@ -303,17 +299,17 @@ CommonAnimationManager::ExtractComputedV StyleAnimationValue::eUnit_Enumerated, "unexpected unit"); aComputedValue.SetIntValue(aComputedValue.GetIntValue(), StyleAnimationValue::eUnit_Visibility); } return result; } -AnimationPlayerCollection* +AnimationCollection* CommonAnimationManager::GetAnimations(dom::Element *aElement, nsCSSPseudoElements::Type aPseudoType, bool aCreateIfNeeded) { if (!aCreateIfNeeded && PR_CLIST_IS_EMPTY(&mElementCollections)) { // Early return for the most common case. return nullptr; } @@ -326,25 +322,24 @@ CommonAnimationManager::GetAnimations(do } else if (aPseudoType == nsCSSPseudoElements::ePseudo_after) { propName = GetAnimationsAfterAtom(); } else { NS_ASSERTION(!aCreateIfNeeded, "should never try to create transitions for pseudo " "other than :before or :after"); return nullptr; } - AnimationPlayerCollection* collection = - static_cast<AnimationPlayerCollection*>(aElement->GetProperty(propName)); + AnimationCollection* collection = + static_cast<AnimationCollection*>(aElement->GetProperty(propName)); if (!collection && aCreateIfNeeded) { // FIXME: Consider arena-allocating? - collection = - new AnimationPlayerCollection(aElement, propName, this); + collection = new AnimationCollection(aElement, propName, this); nsresult rv = aElement->SetProperty(propName, collection, - &AnimationPlayerCollection::PropertyDtor, false); + &AnimationCollection::PropertyDtor, false); if (NS_FAILED(rv)) { NS_WARNING("SetProperty failed"); delete collection; return nullptr; } if (propName == nsGkAtoms::animationsProperty || propName == nsGkAtoms::transitionsProperty) { aElement->SetMayHaveAnimations(); @@ -366,17 +361,17 @@ CommonAnimationManager::GetAnimationRule aPseudoType == nsCSSPseudoElements::ePseudo_after, "forbidden pseudo type"); if (!mPresContext->IsDynamic()) { // For print or print preview, ignore animations. return nullptr; } - AnimationPlayerCollection* collection = + AnimationCollection* collection = GetAnimations(aElement, aPseudoType, false); if (!collection) { return nullptr; } RestyleManager* restyleManager = mPresContext->RestyleManager(); if (restyleManager->SkipAnimationRules()) { return nullptr; @@ -500,17 +495,17 @@ AnimValuesStyleRule::List(FILE* out, int str.AppendLiteral("}\n"); fprintf_stderr(out, "%s", str.get()); } #endif } /* end sub-namespace css */ bool -AnimationPlayerCollection::CanAnimatePropertyOnCompositor( +AnimationCollection::CanAnimatePropertyOnCompositor( const dom::Element *aElement, nsCSSProperty aProperty, CanAnimateFlags aFlags) { bool shouldLog = nsLayoutUtils::IsAnimationLoggingEnabled(); if (!gfxPlatform::OffMainThreadCompositingEnabled()) { if (shouldLog) { nsCString message; @@ -566,25 +561,25 @@ AnimationPlayerCollection::CanAnimatePro } bool propertyAllowed = (aProperty == eCSSProperty_transform) || (aProperty == eCSSProperty_opacity) || (aFlags & CanAnimate_AllowPartial); return enabled && propertyAllowed; } /* static */ bool -AnimationPlayerCollection::IsCompositorAnimationDisabledForFrame( +AnimationCollection::IsCompositorAnimationDisabledForFrame( nsIFrame* aFrame) { void* prop = aFrame->Properties().Get(nsIFrame::RefusedAsyncAnimation()); return bool(reinterpret_cast<intptr_t>(prop)); } bool -AnimationPlayerCollection::CanPerformOnCompositorThread( +AnimationCollection::CanPerformOnCompositorThread( CanAnimateFlags aFlags) const { nsIFrame* frame = nsLayoutUtils::GetStyleFrame(mElement); if (!frame) { return false; } if (mElementProperty != nsGkAtoms::transitionsProperty && @@ -646,17 +641,17 @@ AnimationPlayerCollection::CanPerformOnC if (!existsProperty) { return false; } return true; } void -AnimationPlayerCollection::PostUpdateLayerAnimations() +AnimationCollection::PostUpdateLayerAnimations() { nsCSSPropertySet propsHandled; for (size_t playerIdx = mPlayers.Length(); playerIdx-- != 0; ) { const auto& properties = mPlayers[playerIdx]->GetEffect()->Properties(); for (size_t propIdx = properties.Length(); propIdx-- != 0; ) { nsCSSProperty prop = properties[propIdx].mProperty; if (nsCSSProps::PropHasFlags(prop, CSS_PROPERTY_CAN_ANIMATE_ON_COMPOSITOR) && @@ -670,31 +665,30 @@ AnimationPlayerCollection::PostUpdateLay PostRestyleEvent(element, nsRestyleHint(0), changeHint); } } } } } bool -AnimationPlayerCollection::HasAnimationOfProperty( - nsCSSProperty aProperty) const +AnimationCollection::HasAnimationOfProperty(nsCSSProperty aProperty) const { for (size_t playerIdx = mPlayers.Length(); playerIdx-- != 0; ) { const KeyframeEffectReadonly* effect = mPlayers[playerIdx]->GetEffect(); if (effect && effect->HasAnimationOfProperty(aProperty) && !effect->IsFinishedTransition()) { return true; } } return false; } mozilla::dom::Element* -AnimationPlayerCollection::GetElementToRestyle() const +AnimationCollection::GetElementToRestyle() const { if (IsForElement()) { return mElement; } nsIFrame* primaryFrame = mElement->GetPrimaryFrame(); if (!primaryFrame) { return nullptr; @@ -710,27 +704,27 @@ AnimationPlayerCollection::GetElementToR } if (!pseudoFrame) { return nullptr; } return pseudoFrame->GetContent()->AsElement(); } void -AnimationPlayerCollection::NotifyPlayerUpdated() +AnimationCollection::NotifyPlayerUpdated() { // On the next flush, force us to update the style rule mNeedsRefreshes = true; mStyleRuleRefreshTime = TimeStamp(); mManager->NotifyCollectionUpdated(*this); } /* static */ void -AnimationPlayerCollection::LogAsyncAnimationFailure(nsCString& aMessage, +AnimationCollection::LogAsyncAnimationFailure(nsCString& aMessage, const nsIContent* aContent) { if (aContent) { aMessage.AppendLiteral(" ["); aMessage.Append(nsAtomCString(aContent->NodeInfo()->NameAtom())); nsIAtom* id = aContent->GetID(); if (id) { @@ -740,40 +734,40 @@ AnimationPlayerCollection::LogAsyncAnima } aMessage.Append(']'); } aMessage.Append('\n'); printf_stderr("%s", aMessage.get()); } /*static*/ void -AnimationPlayerCollection::PropertyDtor(void *aObject, nsIAtom *aPropertyName, - void *aPropertyValue, void *aData) +AnimationCollection::PropertyDtor(void *aObject, nsIAtom *aPropertyName, + void *aPropertyValue, void *aData) { - AnimationPlayerCollection* collection = - static_cast<AnimationPlayerCollection*>(aPropertyValue); + AnimationCollection* collection = + static_cast<AnimationCollection*>(aPropertyValue); #ifdef DEBUG MOZ_ASSERT(!collection->mCalledPropertyDtor, "can't call dtor twice"); collection->mCalledPropertyDtor = true; #endif delete collection; } void -AnimationPlayerCollection::Tick() +AnimationCollection::Tick() { for (size_t playerIdx = 0, playerEnd = mPlayers.Length(); playerIdx != playerEnd; playerIdx++) { mPlayers[playerIdx]->Tick(); } } void -AnimationPlayerCollection::EnsureStyleRuleFor(TimeStamp aRefreshTime, - EnsureStyleRuleFlags aFlags) +AnimationCollection::EnsureStyleRuleFor(TimeStamp aRefreshTime, + EnsureStyleRuleFlags aFlags) { if (!mNeedsRefreshes) { mStyleRuleRefreshTime = aRefreshTime; return; } if (!mStyleRuleRefreshTime.IsNull() && mStyleRuleRefreshTime == aRefreshTime) { @@ -820,17 +814,17 @@ AnimationPlayerCollection::EnsureStyleRu for (size_t playerIdx = mPlayers.Length(); playerIdx-- != 0; ) { mPlayers[playerIdx]->ComposeStyle(mStyleRule, properties, mNeedsRefreshes); } mManager->MaybeStartObservingRefreshDriver(); } bool -AnimationPlayerCollection::CanThrottleTransformChanges(TimeStamp aTime) +AnimationCollection::CanThrottleTransformChanges(TimeStamp aTime) { if (!nsLayoutUtils::AreAsyncAnimationsEnabled()) { return false; } // If we know that the animation cannot cause overflow, // we can just disable flushes for this animation. @@ -859,17 +853,17 @@ AnimationPlayerCollection::CanThrottleTr scrollable->GetLogicalScrollPosition() == nsPoint(0, 0)) { return true; } return false; } bool -AnimationPlayerCollection::CanThrottleAnimation(TimeStamp aTime) +AnimationCollection::CanThrottleAnimation(TimeStamp aTime) { nsIFrame* frame = nsLayoutUtils::GetStyleFrame(mElement); if (!frame) { return false; } const auto& info = css::CommonAnimationManager::sLayerAnimationInfo; @@ -890,45 +884,44 @@ AnimationPlayerCollection::CanThrottleAn return false; } } return true; } void -AnimationPlayerCollection::UpdateAnimationGeneration( - nsPresContext* aPresContext) +AnimationCollection::UpdateAnimationGeneration(nsPresContext* aPresContext) { mAnimationGeneration = aPresContext->RestyleManager()->GetAnimationGeneration(); } void -AnimationPlayerCollection::UpdateCheckGeneration( +AnimationCollection::UpdateCheckGeneration( nsPresContext* aPresContext) { mCheckGeneration = aPresContext->RestyleManager()->GetAnimationGeneration(); } bool -AnimationPlayerCollection::HasCurrentAnimations() const +AnimationCollection::HasCurrentAnimations() const { for (size_t playerIdx = mPlayers.Length(); playerIdx-- != 0; ) { if (mPlayers[playerIdx]->HasCurrentEffect()) { return true; } } return false; } bool -AnimationPlayerCollection::HasCurrentAnimationsForProperties( +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(); if (effect && effect->IsCurrent(player) &&
--- a/layout/style/AnimationCommon.h +++ b/layout/style/AnimationCommon.h @@ -28,17 +28,17 @@ class nsIFrame; class nsPresContext; class nsStyleChangeList; namespace mozilla { class RestyleTracker; -struct AnimationPlayerCollection; +struct AnimationCollection; namespace css { bool IsGeometricProperty(nsCSSProperty aProperty); class CommonAnimationManager : public nsIStyleRuleProcessor, public nsARefreshObserver { public: @@ -77,17 +77,17 @@ public: */ void Disconnect(); // Tell the restyle tracker about all the styles that we're currently // animating, so that it can update the animation rule for these // elements. void AddStyleUpdatesTo(mozilla::RestyleTracker& aTracker); - AnimationPlayerCollection* + AnimationCollection* GetAnimations(dom::Element *aElement, nsCSSPseudoElements::Type aPseudoType, bool aCreateIfNeeded); // Returns true if aContent or any of its ancestors has an animation // or transition. static bool ContentOrAncestorHasAnimation(nsIContent* aContent) { do { @@ -97,17 +97,17 @@ public: } } while ((aContent = aContent->GetParent())); return false; } // Notify this manager that one of its collections of animation players, // has been updated. - void NotifyCollectionUpdated(AnimationPlayerCollection& aCollection); + void NotifyCollectionUpdated(AnimationCollection& aCollection); enum FlushFlags { Can_Throttle, Cannot_Throttle }; nsIStyleRule* GetAnimationRule(mozilla::dom::Element* aElement, nsCSSPseudoElements::Type aPseudoType); @@ -136,19 +136,19 @@ public: // on such properties. static const LayerAnimationRecord* LayerAnimationRecordFor(nsCSSProperty aProperty); protected: virtual ~CommonAnimationManager(); // For ElementCollectionRemoved - friend struct mozilla::AnimationPlayerCollection; + friend struct mozilla::AnimationCollection; - void AddElementCollection(AnimationPlayerCollection* aCollection); + void AddElementCollection(AnimationCollection* aCollection); void ElementCollectionRemoved() { MaybeStartOrStopObservingRefreshDriver(); } void RemoveAllElementCollections(); // We should normally only call MaybeStartOrStopObservingRefreshDriver in // situations where we will also queue events since otherwise we may stop // getting refresh driver ticks before we queue the necessary events. void MaybeStartObservingRefreshDriver(); void MaybeStartOrStopObservingRefreshDriver(); @@ -157,17 +157,17 @@ protected: virtual nsIAtom* GetAnimationsAtom() = 0; virtual nsIAtom* GetAnimationsBeforeAtom() = 0; virtual nsIAtom* GetAnimationsAfterAtom() = 0; virtual bool IsAnimationManager() { return false; } - static AnimationPlayerCollection* + static AnimationCollection* GetAnimationsForCompositor(nsIContent* aContent, nsIAtom* aElementProperty, nsCSSProperty aProperty); PRCList mElementCollections; nsPresContext *mPresContext; // weak (non-null from ctor to Disconnect) bool mIsObservingRefreshDriver; }; @@ -225,38 +225,38 @@ private: typedef InfallibleTArray<nsRefPtr<dom::Animation>> AnimationPlayerPtrArray; enum EnsureStyleRuleFlags { EnsureStyleRule_IsThrottled, EnsureStyleRule_IsNotThrottled }; -struct AnimationPlayerCollection : public PRCList +struct AnimationCollection : public PRCList { - AnimationPlayerCollection(dom::Element *aElement, nsIAtom *aElementProperty, - mozilla::css::CommonAnimationManager *aManager) + AnimationCollection(dom::Element *aElement, nsIAtom *aElementProperty, + mozilla::css::CommonAnimationManager *aManager) : mElement(aElement) , mElementProperty(aElementProperty) , mManager(aManager) , mAnimationGeneration(0) , mCheckGeneration(0) , mNeedsRefreshes(true) #ifdef DEBUG , mCalledPropertyDtor(false) #endif { - MOZ_COUNT_CTOR(AnimationPlayerCollection); + MOZ_COUNT_CTOR(AnimationCollection); PR_INIT_CLIST(this); } - ~AnimationPlayerCollection() + ~AnimationCollection() { MOZ_ASSERT(mCalledPropertyDtor, "must call destructor through element property dtor"); - MOZ_COUNT_DTOR(AnimationPlayerCollection); + MOZ_COUNT_DTOR(AnimationCollection); PR_REMOVE_LINK(this); mManager->ElementCollectionRemoved(); } void Destroy() { for (size_t playerIdx = mPlayers.Length(); playerIdx-- != 0; ) { mPlayers[playerIdx]->Cancel();
--- a/layout/style/nsAnimationManager.cpp +++ b/layout/style/nsAnimationManager.cpp @@ -197,39 +197,38 @@ CSSAnimationPlayer::PseudoTypeAsString(n case nsCSSPseudoElements::ePseudo_after: return NS_LITERAL_STRING("::after"); default: return EmptyString(); } } void -nsAnimationManager::UpdateStyleAndEvents(AnimationPlayerCollection* - aCollection, +nsAnimationManager::UpdateStyleAndEvents(AnimationCollection* aCollection, TimeStamp aRefreshTime, EnsureStyleRuleFlags aFlags) { aCollection->EnsureStyleRuleFor(aRefreshTime, aFlags); QueueEvents(aCollection, mPendingEvents); } void -nsAnimationManager::QueueEvents(AnimationPlayerCollection* aCollection, +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); } } void -nsAnimationManager::MaybeUpdateCascadeResults(AnimationPlayerCollection* aCollection) +nsAnimationManager::MaybeUpdateCascadeResults(AnimationCollection* aCollection) { for (size_t playerIdx = aCollection->mPlayers.Length(); playerIdx-- != 0; ) { CSSAnimationPlayer* player = aCollection->mPlayers[playerIdx]->AsCSSAnimationPlayer(); if (player->IsInEffect() != player->mInEffectForCascadeResults) { // Update our own cascade results. mozilla::dom::Element* element = aCollection->GetElementToRestyle(); @@ -275,17 +274,17 @@ nsAnimationManager::CheckAnimationRule(n } // Everything that causes our animation data to change triggers a // style change, which in turn triggers a non-animation restyle. // Likewise, when we initially construct frames, we're not in a // style change, but also not in an animation restyle. const nsStyleDisplay* disp = aStyleContext->StyleDisplay(); - AnimationPlayerCollection* collection = + AnimationCollection* collection = GetAnimations(aElement, aStyleContext->GetPseudoType(), false); if (!collection && disp->mAnimationNameCount == 1 && disp->mAnimations[0].GetName().IsEmpty()) { return nullptr; } nsAutoAnimationMutationBatch mb(aElement); @@ -733,17 +732,17 @@ nsAnimationManager::BuildSegment(Infalli segment.mTimingFunction.Init(*tf); return true; } /* static */ void nsAnimationManager::UpdateCascadeResults( nsStyleContext* aStyleContext, - AnimationPlayerCollection* aElementAnimations) + AnimationCollection* aElementAnimations) { /* * Figure out which properties we need to examine. */ // size of 2 since we only currently have 2 properties we animate on // the compositor nsAutoTArray<nsCSSProperty, 2> propertiesToTrack; @@ -786,20 +785,19 @@ nsAnimationManager::UpdateCascadeResults propertiesOverridden); /* * Set mWinsInCascade based both on what is overridden at levels * higher than animations and based on one animation overriding * another. * * We iterate from the last animation to the first, just like we do - * when calling ComposeStyle from - * AnimationPlayerCollection::EnsureStyleRuleFor. Later animations - * override earlier ones, so we add properties to the set of - * overridden properties as we encounter them, if the animation is + * when calling ComposeStyle from AnimationCollection::EnsureStyleRuleFor. + * Later animations override earlier ones, so we add properties to the set + * of overridden properties as we encounter them, if the animation is * currently in effect. */ bool changed = false; for (size_t playerIdx = aElementAnimations->mPlayers.Length(); playerIdx-- != 0; ) { CSSAnimationPlayer* player = aElementAnimations->mPlayers[playerIdx]->AsCSSAnimationPlayer(); @@ -869,25 +867,24 @@ nsAnimationManager::WillRefresh(mozilla: void nsAnimationManager::FlushAnimations(FlushFlags aFlags) { TimeStamp now = mPresContext->RefreshDriver()->MostRecentRefresh(); bool didThrottle = false; for (PRCList *l = PR_LIST_HEAD(&mElementCollections); l != &mElementCollections; l = PR_NEXT_LINK(l)) { - AnimationPlayerCollection* collection = - static_cast<AnimationPlayerCollection*>(l); + AnimationCollection* collection = static_cast<AnimationCollection*>(l); nsAutoAnimationMutationBatch mb(collection->mElement); collection->Tick(); bool canThrottleTick = aFlags == Can_Throttle && collection->CanPerformOnCompositorThread( - AnimationPlayerCollection::CanAnimateFlags(0)) && + AnimationCollection::CanAnimateFlags(0)) && collection->CanThrottleAnimation(now); nsRefPtr<css::AnimValuesStyleRule> oldStyleRule = collection->mStyleRule; UpdateStyleAndEvents(collection, now, canThrottleTick ? EnsureStyleRule_IsThrottled : EnsureStyleRule_IsNotThrottled); if (oldStyleRule != collection->mStyleRule) { collection->PostRestyleForAnimation(mPresContext);
--- a/layout/style/nsAnimationManager.h +++ b/layout/style/nsAnimationManager.h @@ -160,31 +160,30 @@ class nsAnimationManager final : public mozilla::css::CommonAnimationManager { public: explicit nsAnimationManager(nsPresContext *aPresContext) : mozilla::css::CommonAnimationManager(aPresContext) { } - static mozilla::AnimationPlayerCollection* + static mozilla::AnimationCollection* GetAnimationsForCompositor(nsIContent* aContent, nsCSSProperty aProperty) { return mozilla::css::CommonAnimationManager::GetAnimationsForCompositor( aContent, nsGkAtoms::animationsProperty, aProperty); } - void UpdateStyleAndEvents(mozilla::AnimationPlayerCollection* aEA, + void UpdateStyleAndEvents(mozilla::AnimationCollection* aEA, mozilla::TimeStamp aRefreshTime, mozilla::EnsureStyleRuleFlags aFlags); - void QueueEvents(mozilla::AnimationPlayerCollection* aEA, + void QueueEvents(mozilla::AnimationCollection* aEA, mozilla::EventArray &aEventsToDispatch); - void MaybeUpdateCascadeResults(mozilla::AnimationPlayerCollection* - aCollection); + void MaybeUpdateCascadeResults(mozilla::AnimationCollection* aCollection); // nsIStyleRuleProcessor (parts) virtual size_t SizeOfExcludingThis(mozilla::MallocSizeOf aMallocSizeOf) const MOZ_MUST_OVERRIDE override; virtual size_t SizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf) const MOZ_MUST_OVERRIDE override; // nsARefreshObserver @@ -243,17 +242,17 @@ private: aSegments, nsCSSProperty aProperty, const mozilla::StyleAnimation& aAnimation, float aFromKey, nsStyleContext* aFromContext, mozilla::css::Declaration* aFromDeclaration, float aToKey, nsStyleContext* aToContext); static void UpdateCascadeResults(nsStyleContext* aStyleContext, - mozilla::AnimationPlayerCollection* + mozilla::AnimationCollection* aElementAnimations); // The guts of DispatchEvents void DoDispatchEvents(); mozilla::EventArray mPendingEvents; };
--- a/layout/style/nsTransitionManager.cpp +++ b/layout/style/nsTransitionManager.cpp @@ -178,18 +178,17 @@ nsTransitionManager::StyleContextChanged aElement->NodeInfo()->NameAtom() == nsGkAtoms::mozgeneratedcontentafter), "Unexpected aElement coming through"); // Else the element we want to use from now on is the element the // :before or :after is attached to. aElement = aElement->GetParent()->AsElement(); } - AnimationPlayerCollection* collection = - GetAnimations(aElement, pseudoType, false); + AnimationCollection* collection = GetAnimations(aElement, pseudoType, false); if (!collection && disp->mTransitionPropertyCount == 1 && disp->mTransitions[0].GetCombinedDuration() <= 0.0f) { return; } if (collection && collection->mCheckGeneration == @@ -379,17 +378,17 @@ nsTransitionManager::StyleContextChanged } } void nsTransitionManager::ConsiderStartingTransition( nsCSSProperty aProperty, const StyleTransition& aTransition, dom::Element* aElement, - AnimationPlayerCollection*& aElementTransitions, + AnimationCollection*& aElementTransitions, nsStyleContext* aOldStyleContext, nsStyleContext* aNewStyleContext, bool* aStartedAny, nsCSSPropertySet* aWhichStarted) { // IsShorthand itself will assert if aProperty is not a property. MOZ_ASSERT(!nsCSSProps::IsShorthand(aProperty), "property out of range"); @@ -606,54 +605,51 @@ nsTransitionManager::ConsiderStartingTra aElementTransitions->UpdateAnimationGeneration(mPresContext); *aStartedAny = true; aWhichStarted->AddProperty(aProperty); } void nsTransitionManager::UpdateCascadeResultsWithTransitions( - AnimationPlayerCollection* aTransitions) + AnimationCollection* aTransitions) { - AnimationPlayerCollection* animations = - mPresContext->AnimationManager()-> + AnimationCollection* animations = mPresContext->AnimationManager()-> GetAnimations(aTransitions->mElement, aTransitions->PseudoElementType(), false); UpdateCascadeResults(aTransitions, animations); } void nsTransitionManager::UpdateCascadeResultsWithAnimations( - AnimationPlayerCollection* aAnimations) + AnimationCollection* aAnimations) { - AnimationPlayerCollection* transitions = - mPresContext->TransitionManager()-> + AnimationCollection* transitions = mPresContext->TransitionManager()-> GetAnimations(aAnimations->mElement, aAnimations->PseudoElementType(), false); UpdateCascadeResults(transitions, aAnimations); } void nsTransitionManager::UpdateCascadeResultsWithAnimationsToBeDestroyed( - const AnimationPlayerCollection* aAnimations) + const AnimationCollection* aAnimations) { // aAnimations is about to be destroyed. So get transitions from it, // but then don't pass it to UpdateCascadeResults, since it has // information that may now be incorrect. - AnimationPlayerCollection* transitions = + AnimationCollection* transitions = mPresContext->TransitionManager()-> GetAnimations(aAnimations->mElement, aAnimations->PseudoElementType(), false); UpdateCascadeResults(transitions, nullptr); } void -nsTransitionManager::UpdateCascadeResults( - AnimationPlayerCollection* aTransitions, - AnimationPlayerCollection* aAnimations) +nsTransitionManager::UpdateCascadeResults(AnimationCollection* aTransitions, + AnimationCollection* aAnimations) { if (!aTransitions) { // Nothing to do. return; } nsCSSPropertySet propertiesUsed; #ifdef DEBUG @@ -780,26 +776,25 @@ nsTransitionManager::FlushTransitions(Fl nsTArray<TransitionEventInfo> events; TimeStamp now = mPresContext->RefreshDriver()->MostRecentRefresh(); bool didThrottle = false; // Trim transitions that have completed, post restyle events for frames that // are still transitioning, and start transitions with delays. { PRCList *next = PR_LIST_HEAD(&mElementCollections); while (next != &mElementCollections) { - AnimationPlayerCollection* collection = - static_cast<AnimationPlayerCollection*>(next); + AnimationCollection* collection = static_cast<AnimationCollection*>(next); next = PR_NEXT_LINK(next); nsAutoAnimationMutationBatch mb(collection->mElement); collection->Tick(); bool canThrottleTick = aFlags == Can_Throttle && collection->CanPerformOnCompositorThread( - AnimationPlayerCollection::CanAnimateFlags(0)) && + AnimationCollection::CanAnimateFlags(0)) && collection->CanThrottleAnimation(now); MOZ_ASSERT(collection->mElement->GetCrossShadowCurrentDoc() == mPresContext->Document(), "Element::UnbindFromTree should have " "destroyed the element transitions object"); size_t i = collection->mPlayers.Length();
--- a/layout/style/nsTransitionManager.h +++ b/layout/style/nsTransitionManager.h @@ -106,19 +106,19 @@ class nsTransitionManager final { public: explicit nsTransitionManager(nsPresContext *aPresContext) : mozilla::css::CommonAnimationManager(aPresContext) , mInAnimationOnlyStyleUpdate(false) { } - typedef mozilla::AnimationPlayerCollection AnimationPlayerCollection; + typedef mozilla::AnimationCollection AnimationCollection; - static AnimationPlayerCollection* + static AnimationCollection* GetAnimationsForCompositor(nsIContent* aContent, nsCSSProperty aProperty) { return mozilla::css::CommonAnimationManager::GetAnimationsForCompositor( aContent, nsGkAtoms::transitionsProperty, aProperty); } /** * StyleContextChanged @@ -133,24 +133,22 @@ public: * *aNewStyleContext) to cover up some of the changes for the duration * of the restyling of descendants. If it does, this function will * take care of causing the necessary restyle afterwards. */ void StyleContextChanged(mozilla::dom::Element *aElement, nsStyleContext *aOldStyleContext, nsRefPtr<nsStyleContext>* aNewStyleContext /* inout */); - void UpdateCascadeResultsWithTransitions( - AnimationPlayerCollection* aTransitions); - void UpdateCascadeResultsWithAnimations( - AnimationPlayerCollection* aAnimations); + void UpdateCascadeResultsWithTransitions(AnimationCollection* aTransitions); + void UpdateCascadeResultsWithAnimations(AnimationCollection* aAnimations); void UpdateCascadeResultsWithAnimationsToBeDestroyed( - const AnimationPlayerCollection* aAnimations); - void UpdateCascadeResults(AnimationPlayerCollection* aTransitions, - AnimationPlayerCollection* aAnimations); + const AnimationCollection* aAnimations); + void UpdateCascadeResults(AnimationCollection* aTransitions, + AnimationCollection* aAnimations); void SetInAnimationOnlyStyleUpdate(bool aInAnimationOnlyUpdate) { mInAnimationOnlyStyleUpdate = aInAnimationOnlyUpdate; } bool InAnimationOnlyStyleUpdate() const { return mInAnimationOnlyStyleUpdate; } @@ -176,17 +174,17 @@ protected: return nsGkAtoms::transitionsOfAfterProperty; } private: void ConsiderStartingTransition(nsCSSProperty aProperty, const mozilla::StyleTransition& aTransition, mozilla::dom::Element* aElement, - AnimationPlayerCollection*& aElementTransitions, + AnimationCollection*& aElementTransitions, nsStyleContext* aOldStyleContext, nsStyleContext* aNewStyleContext, bool* aStartedAny, nsCSSPropertySet* aWhichStarted); bool mInAnimationOnlyStyleUpdate; };