Bug 1244641 - Part 2: Add duration implementation in dom/animation/AnimationEffectTiming.cpp. r=hiro, r=smaug
authorRyo Motozawa <motozawa@mozilla-japan.org>
Sat, 27 Feb 2016 06:39:39 +0900
changeset 324214 bb39a42909ea76e5488ce754202bc5281c1f1f83
parent 324213 72317916a0f3f4994b2382d150e542646a448640
child 324215 0907eee5c44aa77a04d667a2ac458de5d2f63f5d
push id1128
push userjlund@mozilla.com
push dateWed, 01 Jun 2016 01:31:59 +0000
treeherdermozilla-release@fe0d30de989d [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewershiro, smaug
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 2: Add duration implementation in dom/animation/AnimationEffectTiming.cpp. r=hiro, r=smaug MozReview-Commit-ID: K5wmKo1U2JP
dom/animation/AnimationEffectTiming.cpp
dom/animation/AnimationEffectTiming.h
dom/webidl/AnimationEffectTiming.webidl
--- a/dom/animation/AnimationEffectTiming.cpp
+++ b/dom/animation/AnimationEffectTiming.cpp
@@ -13,10 +13,33 @@ namespace mozilla {
 namespace dom {
 
 JSObject*
 AnimationEffectTiming::WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto)
 {
   return AnimationEffectTimingBinding::Wrap(aCx, this, aGivenProto);
 }
 
+void
+AnimationEffectTiming::SetDuration(const UnrestrictedDoubleOrString& aDuration)
+{
+  if (mTiming.mDuration.IsUnrestrictedDouble() &&
+      aDuration.IsUnrestrictedDouble() &&
+      mTiming.mDuration.GetAsUnrestrictedDouble() ==
+        aDuration.GetAsUnrestrictedDouble()) {
+    return;
+  }
+
+  if (mTiming.mDuration.IsString() && aDuration.IsString() &&
+      mTiming.mDuration.GetAsString() == aDuration.GetAsString()) {
+    return;
+  }
+
+  if (aDuration.IsUnrestrictedDouble()) {
+    mTiming.mDuration.SetAsUnrestrictedDouble() =
+      aDuration.GetAsUnrestrictedDouble();
+  } else {
+    mTiming.mDuration.SetAsString() = aDuration.GetAsString();
+  }
+}
+
 } // namespace dom
 } // namespace mozilla
--- a/dom/animation/AnimationEffectTiming.h
+++ b/dom/animation/AnimationEffectTiming.h
@@ -19,16 +19,18 @@ public:
   AnimationEffectTiming(const TimingParams& aTiming, KeyframeEffect* aEffect)
     : AnimationEffectTimingReadOnly(aTiming)
     , mEffect(aEffect) { }
 
   JSObject* WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto) override;
 
   void Unlink() override { mEffect = nullptr; }
 
+  void SetDuration(const UnrestrictedDoubleOrString& aDuration);
+
 private:
   KeyframeEffect* MOZ_NON_OWNING_REF mEffect;
 };
 
 } // namespace dom
 } // namespace mozilla
 
 #endif // mozilla_dom_AnimationEffectTiming_h
--- a/dom/webidl/AnimationEffectTiming.webidl
+++ b/dom/webidl/AnimationEffectTiming.webidl
@@ -17,15 +17,14 @@ interface AnimationEffectTiming : Animat
    //Bug 1244635 - implement AnimationEffectTiming endDelay
    //inherit attribute double                             endDelay;
    //Bug 1244637 - implement AnimationEffectTiming fill
    //inherit attribute FillMode                           fill;
    //Bug 1244638 - implement AnimationEffectTiming iterationStart
    //inherit attribute double                             iterationStart;
    //Bug 1244640 - implement AnimationEffectTiming iterations
    //inherit attribute unrestricted double                iterations;
-   //Bug 1244641 - implement AnimationEffectTiming duration
-   //inherit attribute (unrestricted double or DOMString) duration;
+   inherit attribute (unrestricted double or DOMString) duration;
    //Bug 1244642 - implement AnimationEffectTiming direction
    //inherit attribute PlaybackDirection                  direction;
    //Bug 1244643 - implement AnimationEffectTiming easing
    //inherit attribute DOMString                          easing;
 };