Bug 1244641 - Part 1: Let AnimationEffectTiming have an effect. r=hiro
authorRyo Motozawa <motozawa@mozilla-japan.org>
Sat, 27 Feb 2016 06:39:30 +0900
changeset 322310 72317916a0f3f4994b2382d150e542646a448640
parent 322309 49ab89b42dbfdeefa71873bc31c66a0051ec582b
child 322311 bb39a42909ea76e5488ce754202bc5281c1f1f83
push id5913
push userjlund@mozilla.com
push dateMon, 25 Apr 2016 16:57:49 +0000
treeherdermozilla-beta@dcaf0a6fa115 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewershiro
bugs1244641
milestone47.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
Bug 1244641 - Part 1: Let AnimationEffectTiming have an effect. r=hiro MozReview-Commit-ID: REfKyGs4HK
dom/animation/AnimationEffectTiming.h
dom/animation/AnimationEffectTimingReadOnly.h
dom/animation/KeyframeEffect.cpp
dom/animation/KeyframeEffect.h
--- a/dom/animation/AnimationEffectTiming.h
+++ b/dom/animation/AnimationEffectTiming.h
@@ -3,25 +3,32 @@
 /* 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/. */
 
 #ifndef mozilla_dom_AnimationEffectTiming_h
 #define mozilla_dom_AnimationEffectTiming_h
 
 #include "mozilla/dom/AnimationEffectTimingReadOnly.h"
+#include "mozilla/Attributes.h" // For MOZ_NON_OWNING_REF
 
 namespace mozilla {
 namespace dom {
 
 class AnimationEffectTiming : public AnimationEffectTimingReadOnly
 {
 public:
-  explicit AnimationEffectTiming(const TimingParams& aTiming)
-    : AnimationEffectTimingReadOnly(aTiming) { }
+  AnimationEffectTiming(const TimingParams& aTiming, KeyframeEffect* aEffect)
+    : AnimationEffectTimingReadOnly(aTiming)
+    , mEffect(aEffect) { }
 
   JSObject* WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto) override;
+
+  void Unlink() override { mEffect = nullptr; }
+
+private:
+  KeyframeEffect* MOZ_NON_OWNING_REF mEffect;
 };
 
 } // namespace dom
 } // namespace mozilla
 
 #endif // mozilla_dom_AnimationEffectTiming_h
--- a/dom/animation/AnimationEffectTimingReadOnly.h
+++ b/dom/animation/AnimationEffectTimingReadOnly.h
@@ -92,16 +92,18 @@ public:
     aRetVal = mTiming.mDuration;
   }
   PlaybackDirection Direction() const { return mTiming.mDirection; }
   void GetEasing(nsString& aRetVal) const;
 
   const TimingParams& AsTimingParams() const { return mTiming; }
   void SetTimingParams(const TimingParams& aTiming) { mTiming = aTiming; }
 
+  virtual void Unlink() { }
+
 protected:
   nsCOMPtr<nsISupports> mParent;
   TimingParams mTiming;
 };
 
 } // namespace dom
 } // namespace mozilla
 
--- a/dom/animation/KeyframeEffect.cpp
+++ b/dom/animation/KeyframeEffect.cpp
@@ -2137,21 +2137,26 @@ KeyframeEffectReadOnly::ShouldBlockCompo
 //
 //---------------------------------------------------------------------
 
 KeyframeEffect::KeyframeEffect(nsIDocument* aDocument,
                                Element* aTarget,
                                CSSPseudoElementType aPseudoType,
                                const TimingParams& aTiming)
   : KeyframeEffectReadOnly(aDocument, aTarget, aPseudoType,
-                           new AnimationEffectTiming(aTiming))
+                           new AnimationEffectTiming(aTiming, this))
 {
 }
 
 JSObject*
 KeyframeEffect::WrapObject(JSContext* aCx,
                            JS::Handle<JSObject*> aGivenProto)
 {
   return KeyframeEffectBinding::Wrap(aCx, this, aGivenProto);
 }
 
+KeyframeEffect::~KeyframeEffect()
+{
+  mTiming->Unlink();
+}
+
 } // namespace dom
 } // namespace mozilla
--- a/dom/animation/KeyframeEffect.h
+++ b/dom/animation/KeyframeEffect.h
@@ -14,17 +14,16 @@
 #include "mozilla/Attributes.h"
 #include "mozilla/ComputedTimingFunction.h" // ComputedTimingFunction
 #include "mozilla/LayerAnimationInfo.h"     // LayerAnimations::kRecords
 #include "mozilla/OwningNonNull.h"          // OwningNonNull<...>
 #include "mozilla/StickyTimeDuration.h"
 #include "mozilla/StyleAnimationValue.h"
 #include "mozilla/TimeStamp.h"
 #include "mozilla/dom/AnimationEffectReadOnly.h"
-#include "mozilla/dom/AnimationEffectTiming.h"
 #include "mozilla/dom/AnimationEffectTimingReadOnly.h" // TimingParams
 #include "mozilla/dom/Element.h"
 #include "mozilla/dom/KeyframeBinding.h"
 #include "mozilla/dom/Nullable.h"
 
 
 struct JSContext;
 class nsCSSPropertySet;
@@ -423,14 +422,17 @@ public:
                      const Nullable<ElementOrCSSPseudoElement>& aTarget,
                      JS::Handle<JSObject*> aFrames,
                      const TimingParams& aTiming,
                      ErrorResult& aRv)
   {
     return ConstructKeyframeEffect<KeyframeEffect>(aGlobal, aTarget, aFrames,
                                                    aTiming, aRv);
   }
+
+protected:
+  ~KeyframeEffect() override;
 };
 
 } // namespace dom
 } // namespace mozilla
 
 #endif // mozilla_dom_KeyframeEffect_h