From a6970a6f1a0f4cda2df17175771011efe48b1a34 Mon Sep 17 00:00:00 2001 From: "Carsten \"Tomcat\" Book" Date: Tue, 7 Jul 2015 14:21:33 +0200 Subject: [PATCH] Backed out changeset 22cafa2fd162 (bug 1179111) --- dom/animation/Animation.h | 5 +++++ dom/animation/KeyframeEffect.h | 15 ++++++++++++++- layout/style/nsAnimationManager.cpp | 12 ++++++------ layout/style/nsAnimationManager.h | 16 ++-------------- layout/style/nsTransitionManager.cpp | 22 ++++++++++------------ layout/style/nsTransitionManager.h | 7 +++++-- 6 files changed, 42 insertions(+), 35 deletions(-) diff --git a/dom/animation/Animation.h b/dom/animation/Animation.h index c9e58cb00cb..f340c9f14f7 100644 --- a/dom/animation/Animation.h +++ b/dom/animation/Animation.h @@ -218,6 +218,11 @@ public: */ Nullable GetCurrentOrPendingStartTime() const; + const nsString& Name() const + { + return mEffect ? mEffect->Name() : EmptyString(); + } + bool IsPausedOrPausing() const { return PlayState() == AnimationPlayState::Paused || diff --git a/dom/animation/KeyframeEffect.h b/dom/animation/KeyframeEffect.h index 4493f4da496..d6fbb4c2e84 100644 --- a/dom/animation/KeyframeEffect.h +++ b/dom/animation/KeyframeEffect.h @@ -193,10 +193,12 @@ public: KeyframeEffectReadOnly(nsIDocument* aDocument, Element* aTarget, nsCSSPseudoElements::Type aPseudoType, - const AnimationTiming &aTiming) + const AnimationTiming &aTiming, + const nsSubstring& aName) : AnimationEffectReadOnly(aDocument) , mTarget(aTarget) , mTiming(aTiming) + , mName(aName) , mIsFinishedTransition(false) , mPseudoType(aPseudoType) { @@ -225,6 +227,10 @@ public: " pseudo-element is not yet supported."); return mTarget; } + void GetName(nsString& aRetVal) const + { + aRetVal = Name(); + } // Temporary workaround to return both the target element and pseudo-type // until we implement PseudoElement. @@ -233,6 +239,12 @@ public: aTarget = mTarget; aPseudoType = mPseudoType; } + // Alternative to GetName that returns a reference to the member for + // more efficient internal usage. + virtual const nsString& Name() const + { + return mName; + } void SetParentTime(Nullable aParentTime); @@ -328,6 +340,7 @@ protected: Nullable mParentTime; AnimationTiming mTiming; + nsString mName; // A flag to mark transitions that have finished and are due to // be removed on the next throttle-able cycle. bool mIsFinishedTransition; diff --git a/layout/style/nsAnimationManager.cpp b/layout/style/nsAnimationManager.cpp index 6407ef2ced9..ffd8dbc18ea 100644 --- a/layout/style/nsAnimationManager.cpp +++ b/layout/style/nsAnimationManager.cpp @@ -173,7 +173,7 @@ CSSAnimation::QueueEvents(EventArray& aEventsToDispatch) StickyTimeDuration elapsedTime = std::min(StickyTimeDuration(mEffect->InitialAdvance()), computedTiming.mActiveDuration); - AnimationEventInfo ei(target, mAnimationName, NS_ANIMATION_START, + AnimationEventInfo ei(target, Name(), NS_ANIMATION_START, elapsedTime, PseudoTypeAsString(targetPseudoType)); aEventsToDispatch.AppendElement(ei); @@ -196,7 +196,7 @@ CSSAnimation::QueueEvents(EventArray& aEventsToDispatch) elapsedTime = computedTiming.mActiveDuration; } - AnimationEventInfo ei(target, mAnimationName, message, elapsedTime, + AnimationEventInfo ei(target, Name(), message, elapsedTime, PseudoTypeAsString(targetPseudoType)); aEventsToDispatch.AppendElement(ei); } @@ -373,8 +373,7 @@ nsAnimationManager::CheckAnimationRule(nsStyleContext* aStyleContext, CSSAnimation* a = collection->mAnimations[oldIdx]->AsCSSAnimation(); MOZ_ASSERT(a, "All animations in the CSS Animation collection should" " be CSSAnimation objects"); - if (a->AnimationName() == - newAnim->AsCSSAnimation()->AnimationName()) { + if (a->Name() == newAnim->Name()) { oldAnim = a; break; } @@ -551,7 +550,7 @@ nsAnimationManager::BuildAnimations(nsStyleContext* aStyleContext, continue; } - nsRefPtr dest = new CSSAnimation(aTimeline, src.GetName()); + nsRefPtr dest = new CSSAnimation(aTimeline); aAnimations.AppendElement(dest); AnimationTiming timing; @@ -564,7 +563,8 @@ nsAnimationManager::BuildAnimations(nsStyleContext* aStyleContext, nsRefPtr destEffect = new KeyframeEffectReadOnly(mPresContext->Document(), aTarget, - aStyleContext->GetPseudoType(), timing); + aStyleContext->GetPseudoType(), timing, + src.GetName()); dest->SetEffect(destEffect); if (src.GetPlayState() == NS_STYLE_ANIMATION_PLAY_STATE_PAUSED) { diff --git a/layout/style/nsAnimationManager.h b/layout/style/nsAnimationManager.h index 84e94cb77ec..d782115fdaf 100644 --- a/layout/style/nsAnimationManager.h +++ b/layout/style/nsAnimationManager.h @@ -56,18 +56,12 @@ namespace dom { class CSSAnimation final : public Animation { public: - explicit CSSAnimation(DocumentTimeline* aTimeline, - const nsSubstring& aAnimationName) + explicit CSSAnimation(DocumentTimeline* aTimeline) : Animation(aTimeline) - , mAnimationName(aAnimationName) , mIsStylePaused(false) , mPauseShouldStick(false) , mPreviousPhaseOrIteration(PREVIOUS_PHASE_BEFORE) { - // We might need to drop this assertion once we add a script-accessible - // constructor but for animations generated from CSS markup the - // animation-name should never be empty. - MOZ_ASSERT(!mAnimationName.IsEmpty(), "animation-name should not be empty"); } JSObject* WrapObject(JSContext* aCx, @@ -76,11 +70,7 @@ public: virtual CSSAnimation* AsCSSAnimation() override { return this; } // CSSAnimation interface - void GetAnimationName(nsString& aRetVal) const { aRetVal = mAnimationName; } - - // Alternative to GetAnimationName that returns a reference to the member - // for more efficient internal usage. - const nsString& AnimationName() const { return mAnimationName; } + void GetAnimationName(nsString& aRetVal) const { aRetVal = Name(); } // Animation interface overrides virtual Promise* GetReady(ErrorResult& aRv) override; @@ -110,8 +100,6 @@ protected: static nsString PseudoTypeAsString(nsCSSPseudoElements::Type aPseudoType); - nsString mAnimationName; - // When combining animation-play-state with play() / pause() the following // behavior applies: // 1. pause() is sticky and always overrides the underlying diff --git a/layout/style/nsTransitionManager.cpp b/layout/style/nsTransitionManager.cpp index eebeb7a1ca3..618e757d1d6 100644 --- a/layout/style/nsTransitionManager.cpp +++ b/layout/style/nsTransitionManager.cpp @@ -41,6 +41,16 @@ using mozilla::dom::KeyframeEffectReadOnly; using namespace mozilla; using namespace mozilla::css; +const nsString& +ElementPropertyTransition::Name() const +{ + if (!mName.Length()) { + const_cast(this)->mName = + NS_ConvertUTF8toUTF16(nsCSSProps::GetStringValue(TransitionProperty())); + } + return dom::KeyframeEffectReadOnly::Name(); +} + double ElementPropertyTransition::CurrentValuePortion() const { @@ -83,18 +93,6 @@ CSSTransition::WrapObject(JSContext* aCx, JS::Handle aGivenProto) return dom::CSSTransitionBinding::Wrap(aCx, this, aGivenProto); } -void -CSSTransition::GetTransitionProperty(nsString& aRetVal) const -{ - // Once we make the effect property settable (bug 1049975) we will need - // to store the transition property on the CSSTransition itself but for - // now we can just query the effect. - MOZ_ASSERT(mEffect && mEffect->AsTransition(), - "Transitions should have a transition effect"); - nsCSSProperty prop = mEffect->AsTransition()->TransitionProperty(); - aRetVal = NS_ConvertUTF8toUTF16(nsCSSProps::GetStringValue(prop)); -} - AnimationPlayState CSSTransition::PlayStateFromJS() const { diff --git a/layout/style/nsTransitionManager.h b/layout/style/nsTransitionManager.h index cfb7c11a04d..26e4397fc9e 100644 --- a/layout/style/nsTransitionManager.h +++ b/layout/style/nsTransitionManager.h @@ -35,12 +35,15 @@ struct ElementPropertyTransition : public dom::KeyframeEffectReadOnly dom::Element* aTarget, nsCSSPseudoElements::Type aPseudoType, const AnimationTiming &aTiming) - : dom::KeyframeEffectReadOnly(aDocument, aTarget, aPseudoType, aTiming) + : dom::KeyframeEffectReadOnly(aDocument, aTarget, aPseudoType, + aTiming, EmptyString()) { } virtual ElementPropertyTransition* AsTransition() override { return this; } virtual const ElementPropertyTransition* AsTransition() const override { return this; } + virtual const nsString& Name() const override; + nsCSSProperty TransitionProperty() const { MOZ_ASSERT(Properties().Length() == 1, "Transitions should have exactly one animation property. " @@ -87,7 +90,7 @@ public: virtual CSSTransition* AsCSSTransition() override { return this; } // CSSTransition interface - void GetTransitionProperty(nsString& aRetVal) const; + void GetTransitionProperty(nsString& aRetVal) const { aRetVal = Name(); } // Animation interface overrides virtual AnimationPlayState PlayStateFromJS() const override;