Bug 986359 part 2 - Factor out GetTransaction in DOMWindowUtils; r=mattwoodrow
authorBrian Birtles <birtles@gmail.com>
Sat, 22 Mar 2014 05:59:57 +0800
changeset 193365 ede022840eedaacd866654cab76ab6cc9c81103c
parent 193364 b71d4895dbe200be716a03bf3b1a44cc038738f6
child 193366 479c13ebde1424c8c1e7056cc49112919cfb367f
push id3624
push userasasaki@mozilla.com
push dateMon, 09 Jun 2014 21:49:01 +0000
treeherdermozilla-beta@b1a5da15899a [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmattwoodrow
bugs986359
milestone31.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 986359 part 2 - Factor out GetTransaction in DOMWindowUtils; r=mattwoodrow
dom/base/nsDOMWindowUtils.cpp
dom/base/nsDOMWindowUtils.h
--- a/dom/base/nsDOMWindowUtils.cpp
+++ b/dom/base/nsDOMWindowUtils.cpp
@@ -157,16 +157,33 @@ nsDOMWindowUtils::GetDocument()
 {
   nsCOMPtr<nsPIDOMWindow> window = do_QueryReferent(mWindow);
   if (!window) {
     return nullptr;
   }
   return window->GetExtantDoc();
 }
 
+LayerTransactionChild*
+nsDOMWindowUtils::GetLayerTransaction()
+{
+  nsIWidget* widget = GetWidget();
+  if (!widget)
+    return nullptr;
+
+  LayerManager* manager = widget->GetLayerManager();
+  if (!manager)
+    return nullptr;
+
+  ShadowLayerForwarder* forwarder = manager->AsShadowForwarder();
+  return forwarder && forwarder->HasShadowManager() ?
+         forwarder->GetShadowManager() :
+         nullptr;
+}
+
 NS_IMETHODIMP
 nsDOMWindowUtils::GetImageAnimationMode(uint16_t *aMode)
 {
   if (!nsContentUtils::IsCallerChrome()) {
     return NS_ERROR_DOM_SECURITY_ERR;
   }
 
   NS_ENSURE_ARG_POINTER(aMode);
@@ -2547,50 +2564,37 @@ nsDOMWindowUtils::AdvanceTimeAndRefresh(
 {
   if (!nsContentUtils::IsCallerChrome()) {
     return NS_ERROR_DOM_SECURITY_ERR;
   }
 
   nsRefreshDriver* driver = GetPresContext()->RefreshDriver();
   driver->AdvanceTimeAndRefresh(aMilliseconds);
 
-  nsIWidget* widget = GetWidget();
-  if (widget) {
-    LayerManager* manager = widget->GetLayerManager();
-    if (manager) {
-      ShadowLayerForwarder* forwarder = manager->AsShadowForwarder();
-      if (forwarder && forwarder->HasShadowManager()) {
-        forwarder->GetShadowManager()->SendSetTestSampleTime(
-          driver->MostRecentRefresh());
-      }
-    }
+  LayerTransactionChild* transaction = GetLayerTransaction();
+  if (transaction) {
+    transaction->SendSetTestSampleTime(driver->MostRecentRefresh());
   }
 
   return NS_OK;
 }
 
 NS_IMETHODIMP
 nsDOMWindowUtils::RestoreNormalRefresh()
 {
   if (!nsContentUtils::IsCallerChrome()) {
     return NS_ERROR_DOM_SECURITY_ERR;
   }
 
   // Kick the compositor out of test mode before the refresh driver, so that
   // the refresh driver doesn't send an update that gets ignored by the
   // compositor.
-  nsIWidget* widget = GetWidget();
-  if (widget) {
-    LayerManager* manager = widget->GetLayerManager();
-    if (manager) {
-      ShadowLayerForwarder* forwarder = manager->AsShadowForwarder();
-      if (forwarder && forwarder->HasShadowManager()) {
-        forwarder->GetShadowManager()->SendLeaveTestMode();
-      }
-    }
+  LayerTransactionChild* transaction = GetLayerTransaction();
+  if (transaction) {
+    transaction->SendLeaveTestMode();
   }
 
   nsRefreshDriver* driver = GetPresContext()->RefreshDriver();
   driver->RestoreNormalRefresh();
 
   return NS_OK;
 }
 
--- a/dom/base/nsDOMWindowUtils.h
+++ b/dom/base/nsDOMWindowUtils.h
@@ -14,16 +14,22 @@
 
 class nsGlobalWindow;
 class nsIPresShell;
 class nsIWidget;
 class nsPresContext;
 class nsPoint;
 class nsIDocument;
 
+namespace mozilla {
+  namespace layers {
+    class LayerTransactionChild;
+  }
+}
+
 class nsDOMWindowUtils MOZ_FINAL : public nsIDOMWindowUtils,
                                    public nsSupportsWeakReference
 {
 public:
   nsDOMWindowUtils(nsGlobalWindow *aWindow);
   ~nsDOMWindowUtils();
   NS_DECL_ISUPPORTS
   NS_DECL_NSIDOMWINDOWUTILS
@@ -36,16 +42,17 @@ protected:
   // Add this offset to any event offset we're given to make it relative to the
   // widget returned by GetWidget.
   nsIWidget* GetWidget(nsPoint* aOffset = nullptr);
   nsIWidget* GetWidgetForElement(nsIDOMElement* aElement);
 
   nsIPresShell* GetPresShell();
   nsPresContext* GetPresContext();
   nsIDocument* GetDocument();
+  mozilla::layers::LayerTransactionChild* GetLayerTransaction();
 
   NS_IMETHOD SendMouseEventCommon(const nsAString& aType,
                                   float aX,
                                   float aY,
                                   int32_t aButton,
                                   int32_t aClickCount,
                                   int32_t aModifiers,
                                   bool aIgnoreRootScrollFrame,