diff --git a/dom/animation/Animation.h b/dom/animation/Animation.h index 9bccdf63da33..0fe71ad68d49 100644 --- a/dom/animation/Animation.h +++ b/dom/animation/Animation.h @@ -249,7 +249,7 @@ public: return mTiming; } - const nsString& Name() const { + virtual const nsString& Name() const { return mName; } diff --git a/dom/animation/test/css-transitions/test_animation-effect-name.html b/dom/animation/test/css-transitions/test_animation-effect-name.html index 637e995fee3b..b764723cfc9f 100644 --- a/dom/animation/test/css-transitions/test_animation-effect-name.html +++ b/dom/animation/test/css-transitions/test_animation-effect-name.html @@ -16,8 +16,9 @@ test(function(t) { div.style.transition = 'all 100s'; div.style.left = '100px'; - assert_equals(div.getAnimations()[0].source.effect.name, '', - 'Animation effects for transitions have an empty name'); + assert_equals(div.getAnimations()[0].source.effect.name, 'left', + 'The name for the transitions corresponds to the property ' + + 'being transitioned'); }, 'Effect name for transitions'); diff --git a/layout/style/nsTransitionManager.cpp b/layout/style/nsTransitionManager.cpp index c2cfe1cb3801..5779569a4f2d 100644 --- a/layout/style/nsTransitionManager.cpp +++ b/layout/style/nsTransitionManager.cpp @@ -24,6 +24,7 @@ #include "nsIFrame.h" #include "Layers.h" #include "FrameLayerBuilder.h" +#include "nsCSSProps.h" #include "nsDisplayList.h" #include "nsStyleChangeList.h" #include "nsStyleSet.h" @@ -39,6 +40,16 @@ using namespace mozilla; using namespace mozilla::layers; using namespace mozilla::css; +const nsString& +ElementPropertyTransition::Name() const +{ + if (!mName.Length()) { + const_cast(this)->mName = + NS_ConvertUTF8toUTF16(nsCSSProps::GetStringValue(TransitionProperty())); + } + return dom::Animation::Name(); +} + double ElementPropertyTransition::CurrentValuePortion() const { diff --git a/layout/style/nsTransitionManager.h b/layout/style/nsTransitionManager.h index a197e5b43f7c..3b376741096e 100644 --- a/layout/style/nsTransitionManager.h +++ b/layout/style/nsTransitionManager.h @@ -42,6 +42,8 @@ struct ElementPropertyTransition : public dom::Animation virtual ElementPropertyTransition* AsTransition() { return this; } virtual const ElementPropertyTransition* AsTransition() const { return this; } + virtual const nsString& Name() const; + nsCSSProperty TransitionProperty() const { MOZ_ASSERT(Properties().Length() == 1, "Transitions should have exactly one animation property. "