Bug 1293106 - Ignore 'spacing' if dom.animations-api.core.enabled is false. draft
authorBoris Chiou <boris.chiou@gmail.com>
Wed, 10 Aug 2016 17:58:49 +0800
changeset 400572 e1e85421be5562bcd91dfad4c50d598e35fe4d81
parent 398604 6cf0089510fad8deb866136f5b92bbced9498447
child 528253 89fc28a6121251afab8687bdab837f88a8a54950
push id26202
push userbmo:boris.chiou@gmail.com
push dateMon, 15 Aug 2016 07:05:24 +0000
bugs1293106
milestone51.0a1
Bug 1293106 - Ignore 'spacing' if dom.animations-api.core.enabled is false. 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;
   }