Bug 1474247 - Introduce nsDOMWindowUtils.isAnimationPending(). r=birtles
authorHiroyuki Ikezoe <hikezoe@mozilla.com>
Thu, 12 Jul 2018 14:37:50 +0900
changeset 426289 ed9f66da4732bffcb12577e0233eb9a5dbb6eae5
parent 426288 bf6c59d38c9c3dfa0670e2c62e07991b7676d829
child 426290 12b9745a2fd0f28afb3ec8f81914570923e588d3
push id34270
push userapavel@mozilla.com
push dateThu, 12 Jul 2018 21:50:22 +0000
treeherdermozilla-central@ccdb64ade35f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbirtles
bugs1474247
milestone63.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 1474247 - Introduce nsDOMWindowUtils.isAnimationPending(). r=birtles It might be possible that we can check whether an animation is being tracked by the pending animation tracker without this function to count layout flush since we force to flush layout if there is any pending animations [1]. But it will probably result complicated test cases. So to make test cases simple, we introduce a new function which just checking whether a given animation is being tracked by the pending animation tracker. [1] https://hg.mozilla.org/mozilla-central/file/3d20b0701781/layout/base/nsRefreshDriver.cpp#l1957 MozReview-Commit-ID: 4lWuOYCucaD
dom/base/nsDOMWindowUtils.cpp
dom/interfaces/base/nsIDOMWindowUtils.idl
--- a/dom/base/nsDOMWindowUtils.cpp
+++ b/dom/base/nsDOMWindowUtils.cpp
@@ -11,16 +11,17 @@
 #include "nsPresContext.h"
 #include "nsError.h"
 #include "nsQueryContentEventResult.h"
 #include "nsGlobalWindow.h"
 #include "nsIDocument.h"
 #include "nsFocusManager.h"
 #include "nsFrameManager.h"
 #include "nsRefreshDriver.h"
+#include "mozilla/dom/Animation.h"
 #include "mozilla/dom/BindingDeclarations.h"
 #include "mozilla/dom/BlobBinding.h"
 #include "mozilla/dom/Event.h"
 #include "mozilla/dom/Touch.h"
 #include "mozilla/PendingAnimationTracker.h"
 #include "nsIObjectLoadingContent.h"
 #include "nsFrame.h"
 #include "mozilla/layers/ShadowLayers.h"
@@ -3801,16 +3802,43 @@ nsDOMWindowUtils::GetOMTCTransform(Eleme
 
   nsAutoString text;
   ErrorResult rv;
   cssValue->GetCssText(text, rv);
   aResult.Assign(text);
   return rv.StealNSResult();
 }
 
+NS_IMETHODIMP
+nsDOMWindowUtils::IsAnimationInPendingTracker(dom::Animation* aAnimation,
+                                              bool* aRetVal)
+{
+  MOZ_ASSERT(aRetVal);
+
+  if (!aAnimation) {
+    return NS_ERROR_INVALID_ARG;
+  }
+
+  nsIDocument* doc = GetDocument();
+  if (!doc) {
+    *aRetVal = false;
+    return NS_OK;
+  }
+
+  PendingAnimationTracker* tracker = doc->GetPendingAnimationTracker();
+  if (!tracker) {
+    *aRetVal = false;
+    return NS_OK;
+  }
+
+  *aRetVal = tracker->IsWaitingToPlay(*aAnimation) ||
+             tracker->IsWaitingToPause(*aAnimation);
+  return NS_OK;
+}
+
 namespace {
 
 class HandlingUserInputHelper final : public nsIJSRAIIHelper
 {
 public:
   explicit HandlingUserInputHelper(bool aHandlingUserInput);
 
   NS_DECL_ISUPPORTS
--- a/dom/interfaces/base/nsIDOMWindowUtils.idl
+++ b/dom/interfaces/base/nsIDOMWindowUtils.idl
@@ -39,16 +39,17 @@ interface nsIFile;
 interface nsIURI;
 interface nsIRunnable;
 interface nsITranslationNodeList;
 interface nsIJSRAIIHelper;
 interface nsIContentPermissionRequest;
 interface nsIObserver;
 interface nsIDOMStorage;
 
+webidl Animation;
 webidl DOMRect;
 webidl Element;
 webidl EventTarget;
 webidl Event;
 webidl Node;
 webidl NodeList;
 
 [scriptable, uuid(4d6732ca-9da7-4176-b8a1-8dde15cd0bf9)]
@@ -1702,16 +1703,22 @@ interface nsIDOMWindowUtils : nsISupport
    * Unlike the above getOMTAStyle, the transform value returned by this
    * includes both of animating and APZ values.
    * Note: This function doesn't work on WebRender at all.  Also this function
    * does work only for transform layer and opacity layer with animations.
    */
   AString getOMTCTransform(in Element aElement,
                            [optional] in AString aPseudoElement);
 
+  /*
+   * Returns true if the given animation is being tracked by the pending
+   * animation tracker for the current document.
+   */
+  bool isAnimationInPendingTracker(in Animation aAnimation);
+
   /**
    * If aHandlingInput is true, this informs the event state manager that
    * we're handling user input. Otherwise, this is a no-op (as by default
    * we're not handling user input).
    * Remember to call destruct() on the return value!
    * See also nsIDOMWindowUtils::isHandlingUserInput.
    */
   nsIJSRAIIHelper setHandlingUserInput(in boolean aHandlingInput);