Bug 1293106 - Ignore 'spacing' if dom.animations-api.core.enabled is false. r=birtles
authorBoris Chiou <boris.chiou@gmail.com>
Tue, 16 Aug 2016 19:47:00 -0400
changeset 347706 84220f4fafebf8c319ab3064563d2b28416bb268
parent 347705 704c14625c6fdf3ff00962c03dd6350a25a6b11a
child 347707 85f2a3c9618d2d7fd0961ddd2b9036f600a37324
push id6389
push userraliiev@mozilla.com
push dateMon, 19 Sep 2016 13:38:22 +0000
treeherdermozilla-beta@01d67bfe6c81 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbirtles
bugs1293106
milestone50.0a2
Bug 1293106 - Ignore 'spacing' if dom.animations-api.core.enabled is false. r=birtles MozReview-Commit-ID: K7hbCjLP6vB
dom/animation/AnimationUtils.cpp
dom/animation/AnimationUtils.h
dom/animation/KeyframeEffectParams.cpp
--- a/dom/animation/AnimationUtils.cpp
+++ b/dom/animation/AnimationUtils.cpp
@@ -57,9 +57,24 @@ AnimationUtils::IsOffscreenThrottlingEna
     sPrefCached = true;
     Preferences::AddBoolVarCache(&sOffscreenThrottlingEnabled,
                                  "dom.animations.offscreen-throttling");
   }
 
   return sOffscreenThrottlingEnabled;
 }
 
+/* static */ bool
+AnimationUtils::IsCoreAPIEnabled()
+{
+  static bool sCoreAPIEnabled;
+  static bool sPrefCached = false;
+
+  if (!sPrefCached) {
+    sPrefCached = true;
+    Preferences::AddBoolVarCache(&sCoreAPIEnabled,
+                                 "dom.animations-api.core.enabled");
+  }
+
+  return sCoreAPIEnabled;
+}
+
 } // namespace mozilla
--- a/dom/animation/AnimationUtils.h
+++ b/dom/animation/AnimationUtils.h
@@ -55,13 +55,20 @@ public:
   static nsIDocument*
   GetCurrentRealmDocument(JSContext* aCx);
 
   /**
    * Checks if offscreen animation throttling is enabled.
    */
   static bool
   IsOffscreenThrottlingEnabled();
+
+  /**
+   * Returns true if the preference to enable the core Web Animations API is
+   * true.
+   */
+  static bool
+  IsCoreAPIEnabled();
 };
 
 } // namespace mozilla
 
 #endif
--- a/dom/animation/KeyframeEffectParams.cpp
+++ b/dom/animation/KeyframeEffectParams.cpp
@@ -1,16 +1,17 @@
 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
 /* 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 "mozilla/KeyframeEffectParams.h"
 
+#include "mozilla/AnimationUtils.h"
 #include "mozilla/KeyframeUtils.h"
 #include "mozilla/RangedPtr.h"
 #include "nsReadableUtils.h"
 
 namespace mozilla {
 
 static inline bool
 IsLetter(char16_t aCh)
@@ -106,16 +107,23 @@ ConsumeIdentToken(RangedPtr<const char16
 KeyframeEffectParams::ParseSpacing(const nsAString& aSpacing,
                                    SpacingMode& aSpacingMode,
                                    nsCSSProperty& aPacedProperty,
                                    nsAString& aInvalidPacedProperty,
                                    ErrorResult& aRv)
 {
   aInvalidPacedProperty.Truncate();
 
+  // Ignore spacing if the core API is not enabled since it is not yet ready to
+  // ship.
+  if (!AnimationUtils::IsCoreAPIEnabled()) {
+    aSpacingMode = SpacingMode::distribute;
+    return;
+  }
+
   // Parse spacing.
   // distribute | paced({ident})
   // https://w3c.github.io/web-animations/#dom-keyframeeffectreadonly-spacing
   // 1. distribute spacing.
   if (aSpacing.EqualsLiteral("distribute")) {
     aSpacingMode = SpacingMode::distribute;
     return;
   }