Bug 913114 - Fix ref counting in winrt widget's GeckoContentController. r=bbondy
authorJim Mathies <jmathies@mozilla.com>
Fri, 06 Sep 2013 14:56:14 -0500
changeset 158906 471064addd39902c32b250bf7011ccb133f5487d
parent 158905 4b03903fb8f5c888d2c273c4e3e26dfd04b81db9
child 158907 1b8afdbb8cf112e90eaab17533e85e16de2275cb
push id2961
push userlsblakk@mozilla.com
push dateMon, 28 Oct 2013 21:59:28 +0000
treeherdermozilla-beta@73ef4f13486f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbbondy
bugs913114
milestone26.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 913114 - Fix ref counting in winrt widget's GeckoContentController. r=bbondy
widget/windows/winrt/APZController.cpp
widget/windows/winrt/APZController.h
widget/windows/winrt/FrameworkView.cpp
widget/windows/winrt/FrameworkView.h
widget/windows/winrt/MetroApp.cpp
widget/windows/winrt/MetroInput.cpp
widget/windows/winrt/MetroInput.h
widget/windows/winrt/MetroWidget.cpp
widget/windows/winrt/MetroWidget.h
widget/windows/winrt/moz.build
new file mode 100644
--- /dev/null
+++ b/widget/windows/winrt/APZController.cpp
@@ -0,0 +1,107 @@
+/* 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 "APZController.h"
+#include "base/message_loop.h"
+#include "mozilla/layers/GeckoContentController.h"
+#include "nsThreadUtils.h"
+#include "MetroUtils.h"
+#include "nsPrintfCString.h"
+
+namespace mozilla {
+namespace widget {
+namespace winrt {
+
+class RequestContentRepaintEvent : public nsRunnable
+{
+    typedef mozilla::layers::FrameMetrics FrameMetrics;
+
+public:
+    RequestContentRepaintEvent(const FrameMetrics& aFrameMetrics) : mFrameMetrics(aFrameMetrics)
+    {
+    }
+
+    NS_IMETHOD Run() {
+        // This event shuts down the worker thread and so must be main thread.
+        MOZ_ASSERT(NS_IsMainThread());
+
+        CSSToScreenScale resolution = mFrameMetrics.mZoom;
+        CSSRect compositedRect = mFrameMetrics.CalculateCompositedRectInCssPixels();
+
+        NS_ConvertASCIItoUTF16 data(nsPrintfCString("{ " \
+                                                    "  \"resolution\": %.2f, " \
+                                                    "  \"scrollId\": %d, " \
+                                                    "  \"compositedRect\": { \"width\": %d, \"height\": %d }, " \
+                                                    "  \"displayPort\":    { \"x\": %d, \"y\": %d, \"width\": %d, \"height\": %d }, " \
+                                                    "  \"scrollTo\":       { \"x\": %d, \"y\": %d }" \
+                                                    "}",
+                                                    (float)(resolution.scale / mFrameMetrics.mDevPixelsPerCSSPixel.scale),
+                                                    (int)mFrameMetrics.mScrollId,
+                                                    (int)compositedRect.width,
+                                                    (int)compositedRect.height,
+                                                    (int)mFrameMetrics.mDisplayPort.x,
+                                                    (int)mFrameMetrics.mDisplayPort.y,
+                                                    (int)mFrameMetrics.mDisplayPort.width,
+                                                    (int)mFrameMetrics.mDisplayPort.height,
+                                                    (int)mFrameMetrics.mScrollOffset.x,
+                                                    (int)mFrameMetrics.mScrollOffset.y));
+
+        MetroUtils::FireObserver("apzc-request-content-repaint", data.get());
+        return NS_OK;
+    }
+protected:
+    const FrameMetrics mFrameMetrics;
+};
+
+void
+APZController::RequestContentRepaint(const FrameMetrics& aFrameMetrics)
+{
+  // Send the result back to the main thread so that it can shutdown
+  nsCOMPtr<nsIRunnable> r1 = new RequestContentRepaintEvent(aFrameMetrics);
+  if (!NS_IsMainThread()) {
+    NS_DispatchToMainThread(r1);
+  } else {
+    r1->Run();
+  }
+}
+
+void
+APZController::HandleDoubleTap(const CSSIntPoint& aPoint)
+{
+}
+
+void
+APZController::HandleSingleTap(const CSSIntPoint& aPoint)
+{
+}
+
+void
+APZController::HandleLongTap(const CSSIntPoint& aPoint)
+{
+}
+
+void
+APZController::SendAsyncScrollDOMEvent(FrameMetrics::ViewID aScrollId, const CSSRect &aContentRect, const CSSSize &aScrollableSize)
+{
+}
+
+void
+APZController::PostDelayedTask(Task* aTask, int aDelayMs)
+{
+  MessageLoop::current()->PostDelayedTask(FROM_HERE, aTask, aDelayMs);
+}
+
+void
+APZController::HandlePanBegin()
+{
+  MetroUtils::FireObserver("apzc-handle-pan-begin", L"");
+}
+
+void
+APZController::HandlePanEnd()
+{
+  MetroUtils::FireObserver("apzc-handle-pan-end", L"");
+}
+
+} } }
\ No newline at end of file
new file mode 100644
--- /dev/null
+++ b/widget/windows/winrt/APZController.h
@@ -0,0 +1,32 @@
+/* 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/. */
+
+#pragma once
+
+#include "mozwrlbase.h"
+
+#include "mozilla/layers/GeckoContentController.h"
+#include "FrameMetrics.h"
+#include "Units.h"
+
+namespace mozilla {
+namespace widget {
+namespace winrt {
+
+class APZController : public mozilla::layers::GeckoContentController
+{
+  typedef mozilla::layers::FrameMetrics FrameMetrics;
+
+public:
+  virtual void RequestContentRepaint(const FrameMetrics& aFrameMetrics);
+  virtual void HandleDoubleTap(const mozilla::CSSIntPoint& aPoint);
+  virtual void HandleSingleTap(const mozilla::CSSIntPoint& aPoint);
+  virtual void HandleLongTap(const mozilla::CSSIntPoint& aPoint);
+  virtual void SendAsyncScrollDOMEvent(FrameMetrics::ViewID aScrollId, const mozilla::CSSRect &aContentRect, const mozilla::CSSSize &aScrollableSize);
+  virtual void PostDelayedTask(Task* aTask, int aDelayMs);
+  virtual void HandlePanBegin();
+  virtual void HandlePanEnd();
+};
+
+} } }
\ No newline at end of file
--- a/widget/windows/winrt/FrameworkView.cpp
+++ b/widget/windows/winrt/FrameworkView.cpp
@@ -192,17 +192,16 @@ FrameworkView::ShutdownXPCOM()
     mAutomationProvider.As(&provider);
     if (provider) {
       provider->Disconnect();
     }
   }
   mAutomationProvider = nullptr;
 
   mMetroInput = nullptr;
-  mD2DWindowSurface = nullptr;
   delete sSettingsArray;
   sSettingsArray = nullptr;
   mWidget = nullptr;
   mMetroApp = nullptr;
   mWindow = nullptr;
 }
 
 void
--- a/widget/windows/winrt/FrameworkView.h
+++ b/widget/windows/winrt/FrameworkView.h
@@ -2,16 +2,17 @@
 /* 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/. */
 
 #pragma once
 
 #include "nsGUIEvent.h"
 #include "MetroWidget.h"
+#include "MetroInput.h"
 #include "gfxWindowsPlatform.h"
 #include "gfxD2DSurface.h"
 #include "nsDataHashtable.h"
 
 #include "mozwrlbase.h"
 
 #include <windows.system.h>
 #include <Windows.ApplicationModel.core.h>
@@ -171,17 +172,16 @@ private:
   EventRegistrationToken mAutomationProviderRequested;
   EventRegistrationToken mDataTransferRequested;
   EventRegistrationToken mSearchQuerySubmitted;
   EventRegistrationToken mPlayToRequested;
   EventRegistrationToken mSettingsPane;
   EventRegistrationToken mPrintManager;
 
 private:
-  nsRefPtr<gfxD2DSurface> mD2DWindowSurface;
   nsIntRect mWindowBounds; // in device-pixel coordinates
   float mDPI;
   bool mShuttingDown;
   nsAutoString mActivationURI;
   nsAutoString mActivationCommandLine;
   Microsoft::WRL::ComPtr<IInspectable> mAutomationProvider;
   //Microsoft::WRL::ComPtr<ID2D1PrintControl> mD2DPrintControl;
   // Private critical section protects D2D device context for on-screen
--- a/widget/windows/winrt/MetroApp.cpp
+++ b/widget/windows/winrt/MetroApp.cpp
@@ -102,16 +102,17 @@ MetroApp::ShutdownXPCOM()
   // Shut down xpcom
   XRE_metroShutdown();
 }
 
 // Request a shutdown of the application
 void
 MetroApp::CoreExit()
 {
+  LogFunction();
   HRESULT hr;
   ComPtr<ICoreApplicationExit> coreExit;
   HStringReference className(RuntimeClass_Windows_ApplicationModel_Core_CoreApplication);
   hr = GetActivationFactory(className.Get(), coreExit.GetAddressOf());
   NS_ASSERTION(SUCCEEDED(hr), "Activation of ICoreApplicationExit");
   if (SUCCEEDED(hr)) {
     coreExit->Exit();
   }
--- a/widget/windows/winrt/MetroInput.cpp
+++ b/widget/windows/winrt/MetroInput.cpp
@@ -1,14 +1,15 @@
 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 /* 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/. */
 
 // Moz headers (alphabetical)
+#include "MetroInput.h"
 #include "MetroUtils.h" // Logging, POINT_CEIL_*, ActivateGenericInstance, etc
 #include "MetroWidget.h" // MetroInput::mWidget
 #include "mozilla/dom/Touch.h"  // Touch
 #include "nsTArray.h" // Touch lists
 #include "nsIDOMSimpleGestureEvent.h" // Constants for gesture events
 #include "InputData.h"
 #include "UIABridgePrivate.h"
 
@@ -156,18 +157,16 @@ MetroInput::MetroInput(MetroWidget* aWid
                        UI::Core::ICoreWindow* aWindow)
               : mWidget(aWidget),
                 mWindow(aWindow)
 {
   LogFunction();
   NS_ASSERTION(aWidget, "Attempted to create MetroInput for null widget!");
   NS_ASSERTION(aWindow, "Attempted to create MetroInput for null window!");
 
-  mWidget->SetMetroInput(this);
-
   mTokenPointerPressed.value = 0;
   mTokenPointerReleased.value = 0;
   mTokenPointerMoved.value = 0;
   mTokenPointerEntered.value = 0;
   mTokenPointerExited.value = 0;
   mTokenEdgeStarted.value = 0;
   mTokenEdgeCanceled.value = 0;
   mTokenEdgeCompleted.value = 0;
@@ -923,37 +922,16 @@ MetroInput::OnRightTapped(UI::Input::IGe
   Foundation::Point position;
   aArgs->get_Position(&position);
   HandleLongTap(
     LayoutDeviceIntPoint::FromUntyped(MetroUtils::LogToPhys(position)));
 
   return S_OK;
 }
 
-// Used by MetroWidget GeckoContentController callbacks
-void
-MetroInput::HandleDoubleTap(const LayoutDeviceIntPoint& aPoint)
-{
-#ifdef DEBUG_INPUT
-  LogFunction();
-#endif
-  nsSimpleGestureEvent* tapEvent =
-    new nsSimpleGestureEvent(true,
-                             NS_SIMPLE_GESTURE_TAP,
-                             mWidget.Get(),
-                             0,
-                             0.0);
-
-  tapEvent->inputSource = nsIDOMMouseEvent::MOZ_SOURCE_TOUCH;
-  tapEvent->refPoint = aPoint;
-  tapEvent->clickCount = 2;
-  tapEvent->pressure = 1;
-  DispatchAsyncEventIgnoreStatus(tapEvent);
-}
-
 void
 MetroInput::HandleSingleTap(const LayoutDeviceIntPoint& aPoint)
 {
 #ifdef DEBUG_INPUT
   LogFunction();
 #endif
 
   // send mousemove
--- a/widget/windows/winrt/MetroInput.h
+++ b/widget/windows/winrt/MetroInput.h
@@ -142,18 +142,16 @@ public:
   HRESULT OnManipulationUpdated(IGestureRecognizer* aSender,
                                 IManipulationUpdatedEventArgs* aArgs);
   HRESULT OnManipulationCompleted(IGestureRecognizer* aSender,
                                   IManipulationCompletedEventArgs* aArgs);
   HRESULT OnTapped(IGestureRecognizer* aSender, ITappedEventArgs* aArgs);
   HRESULT OnRightTapped(IGestureRecognizer* aSender,
                         IRightTappedEventArgs* aArgs);
 
-  // Used by MetroWidget GeckoContentController callbacks
-  void HandleDoubleTap(const mozilla::LayoutDeviceIntPoint& aPoint);
   void HandleSingleTap(const mozilla::LayoutDeviceIntPoint& aPoint);
   void HandleLongTap(const mozilla::LayoutDeviceIntPoint& aPoint);
 
 private:
   Microsoft::WRL::ComPtr<ICoreWindow> mWindow;
   Microsoft::WRL::ComPtr<MetroWidget> mWidget;
   Microsoft::WRL::ComPtr<IGestureRecognizer> mGestureRecognizer;
 
--- a/widget/windows/winrt/MetroWidget.cpp
+++ b/widget/windows/winrt/MetroWidget.cpp
@@ -957,17 +957,18 @@ MetroWidget::ShouldUseAPZC()
 }
 
 CompositorParent* MetroWidget::NewCompositorParent(int aSurfaceWidth, int aSurfaceHeight)
 {
   CompositorParent *compositor = nsBaseWidget::NewCompositorParent(aSurfaceWidth, aSurfaceHeight);
 
   if (ShouldUseAPZC()) {
     mRootLayerTreeId = compositor->RootLayerTreeId();
-    CompositorParent::SetControllerForLayerTree(mRootLayerTreeId, this);
+    mController = new APZController();
+    CompositorParent::SetControllerForLayerTree(mRootLayerTreeId, mController);
 
     MetroWidget::sAPZC = CompositorParent::GetAPZCTreeManager(compositor->RootLayerTreeId());
     MetroWidget::sAPZC->SetDPI(GetDPI());
 
     nsresult rv;
     nsCOMPtr<nsIObserverService> observerService = do_GetService("@mozilla.org/observer-service;1", &rv);
     if (NS_SUCCEEDED(rv)) {
       observerService->AddObserver(this, "scroll-offset-changed", false);
@@ -1469,113 +1470,16 @@ MetroWidget::PickerClosed()
 bool
 MetroWidget::HasPendingInputEvent()
 {
   if (HIWORD(GetQueueStatus(QS_INPUT)))
     return true;
   return false;
 }
 
-// GeckoContentController interface impl
-
-class RequestContentRepaintEvent : public nsRunnable
-{
-public:
-    RequestContentRepaintEvent(const FrameMetrics& aFrameMetrics) : mFrameMetrics(aFrameMetrics)
-    {
-    }
-
-    NS_IMETHOD Run() {
-        // This event shuts down the worker thread and so must be main thread.
-        MOZ_ASSERT(NS_IsMainThread());
-
-        CSSToScreenScale resolution = mFrameMetrics.mZoom;
-        CSSRect compositedRect = mFrameMetrics.CalculateCompositedRectInCssPixels();
-
-        NS_ConvertASCIItoUTF16 data(nsPrintfCString("{ " \
-                                                    "  \"resolution\": %.2f, " \
-                                                    "  \"scrollId\": %d, " \
-                                                    "  \"compositedRect\": { \"width\": %d, \"height\": %d }, " \
-                                                    "  \"displayPort\":    { \"x\": %d, \"y\": %d, \"width\": %d, \"height\": %d }, " \
-                                                    "  \"scrollTo\":       { \"x\": %d, \"y\": %d }" \
-                                                    "}",
-                                                    (float)(resolution.scale / mFrameMetrics.mDevPixelsPerCSSPixel.scale),
-                                                    (int)mFrameMetrics.mScrollId,
-                                                    (int)compositedRect.width,
-                                                    (int)compositedRect.height,
-                                                    (int)mFrameMetrics.mDisplayPort.x,
-                                                    (int)mFrameMetrics.mDisplayPort.y,
-                                                    (int)mFrameMetrics.mDisplayPort.width,
-                                                    (int)mFrameMetrics.mDisplayPort.height,
-                                                    (int)mFrameMetrics.mScrollOffset.x,
-                                                    (int)mFrameMetrics.mScrollOffset.y));
-
-        MetroUtils::FireObserver("apzc-request-content-repaint", data.get());
-        return NS_OK;
-    }
-protected:
-    const FrameMetrics mFrameMetrics;
-};
-
-void
-MetroWidget::RequestContentRepaint(const FrameMetrics& aFrameMetrics)
-{
-  LogFunction();
-
-  // Send the result back to the main thread so that it can shutdown
-  nsCOMPtr<nsIRunnable> r1 = new RequestContentRepaintEvent(aFrameMetrics);
-  if (!NS_IsMainThread()) {
-    NS_DispatchToMainThread(r1);
-  } else {
-    r1->Run();
-  }
-}
-
-void
-MetroWidget::HandleDoubleTap(const CSSIntPoint& aPoint)
-{
-}
-
-void
-MetroWidget::HandleSingleTap(const CSSIntPoint& aPoint)
-{
-}
-
-void
-MetroWidget::HandleLongTap(const CSSIntPoint& aPoint)
-{
-}
-
-void
-MetroWidget::SendAsyncScrollDOMEvent(FrameMetrics::ViewID aScrollId, const CSSRect &aContentRect, const CSSSize &aScrollableSize)
-{
-  LogFunction();
-}
-
-void
-MetroWidget::PostDelayedTask(Task* aTask, int aDelayMs)
-{
-  LogFunction();
-  MessageLoop::current()->PostDelayedTask(FROM_HERE, aTask, aDelayMs);
-}
-
-void
-MetroWidget::HandlePanBegin()
-{
-  LogFunction();
-  MetroUtils::FireObserver("apzc-handle-pan-begin", L"");
-}
-
-void
-MetroWidget::HandlePanEnd()
-{
-  LogFunction();
-  MetroUtils::FireObserver("apzc-handle-pan-end", L"");
-}
-
 NS_IMETHODIMP
 MetroWidget::Observe(nsISupports *subject, const char *topic, const PRUnichar *data)
 {
   NS_ENSURE_ARG_POINTER(topic);
   if (!strcmp(topic, "scroll-offset-changed")) {
     uint64_t scrollId;
     int32_t presShellId;
     CSSIntPoint scrollOffset;
--- a/widget/windows/winrt/MetroWidget.h
+++ b/widget/windows/winrt/MetroWidget.h
@@ -17,21 +17,21 @@
 #include "nsWindowDbg.h"
 #include "WindowHook.h"
 #include "TaskbarWindowPreview.h"
 #include "nsIdleService.h"
 #ifdef ACCESSIBILITY
 #include "mozilla/a11y/Accessible.h"
 #endif
 #include "mozilla/layers/CompositorParent.h"
-#include "mozilla/layers/GeckoContentController.h"
 #include "mozilla/layers/APZCTreeManager.h"
 #include "mozilla/layers/LayerManagerComposite.h"
 #include "Units.h"
-#include "MetroInput.h"
+#include "nsDeque.h"
+#include "APZController.h"
 
 #include "mozwrlbase.h"
 
 #include <windows.system.h>
 #include <windows.ui.core.h>
 #include <Windows.ApplicationModel.core.h>
 #include <Windows.ApplicationModel.h>
 #include <Windows.Applicationmodel.Activation.h>
@@ -43,27 +43,26 @@ namespace winrt {
 
 class FrameworkView;
 
 } } }
 
 class DispatchMsg;
 
 class MetroWidget : public nsWindowBase,
-                    public mozilla::layers::GeckoContentController,
                     public nsIObserver
 {
   typedef mozilla::widget::WindowHook WindowHook;
   typedef mozilla::widget::TaskbarWindowPreview TaskbarWindowPreview;
   typedef ABI::Windows::UI::Input::IPointerPoint IPointerPoint;
   typedef ABI::Windows::UI::Core::IPointerEventArgs IPointerEventArgs;
   typedef ABI::Windows::UI::Core::IKeyEventArgs IKeyEventArgs;
   typedef ABI::Windows::UI::Core::ICharacterReceivedEventArgs ICharacterReceivedEventArgs;
   typedef mozilla::widget::winrt::FrameworkView FrameworkView;
-  typedef mozilla::layers::FrameMetrics FrameMetrics;
+  typedef mozilla::widget::winrt::APZController APZController;
 
   static LRESULT CALLBACK
   StaticWindowProcedure(HWND aWnd, UINT aMsg, WPARAM aWParan, LPARAM aLParam);
   LRESULT WindowProcedure(HWND aWnd, UINT aMsg, WPARAM aWParan, LPARAM aLParam);
 
 public:
   MetroWidget();
   virtual ~MetroWidget();
@@ -195,31 +194,16 @@ public:
   void SetView(FrameworkView* aView);
   void FindMetroWindow();
   virtual void SetTransparencyMode(nsTransparencyMode aMode);
   virtual nsTransparencyMode GetTransparencyMode();
 
   nsresult RequestContentScroll();
   void RequestContentRepaintImplMainThread();
 
-  // GeckoContentController interface impl
-  virtual void RequestContentRepaint(const FrameMetrics& aFrameMetrics);
-  virtual void HandleDoubleTap(const mozilla::CSSIntPoint& aPoint);
-  virtual void HandleSingleTap(const mozilla::CSSIntPoint& aPoint);
-  virtual void HandleLongTap(const mozilla::CSSIntPoint& aPoint);
-  virtual void SendAsyncScrollDOMEvent(FrameMetrics::ViewID aScrollId, const mozilla::CSSRect &aContentRect, const mozilla::CSSSize &aScrollableSize);
-  virtual void PostDelayedTask(Task* aTask, int aDelayMs);
-  virtual void HandlePanBegin();
-  virtual void HandlePanEnd();
-
-  void SetMetroInput(mozilla::widget::winrt::MetroInput* aMetroInput)
-  {
-    mMetroInput = aMetroInput;
-  }
-
 protected:
   friend class FrameworkView;
 
   struct OleInitializeWrapper {
     HRESULT const hr;
 
     OleInitializeWrapper()
       : hr(::OleInitialize(NULL))
@@ -233,34 +217,33 @@ protected:
       }
     }
   };
 
   void SetSubclass();
   void RemoveSubclass();
   nsIWidgetListener* GetPaintListener();
 
+  // Async event dispatching
+  void DispatchAsyncScrollEvent(DispatchMsg* aEvent);
+  void DeliverNextScrollEvent();
+  void DeliverNextKeyboardEvent();
+  DispatchMsg* CreateDispatchMsg(UINT aMsg, WPARAM aWParam, LPARAM aLParam);
+
+public:
+  static nsRefPtr<mozilla::layers::APZCTreeManager> sAPZC;
+
+protected:
   OleInitializeWrapper mOleInitializeWrapper;
   WindowHook mWindowHook;
   Microsoft::WRL::ComPtr<FrameworkView> mView;
   nsTransparencyMode mTransparencyMode;
   nsIntRegion mInvalidatedRegion;
   nsCOMPtr<nsIdleService> mIdleService;
   HWND mWnd;
   static HWND sICoreHwnd;
   WNDPROC mMetroWndProc;
   bool mTempBasicLayerInUse;
-  Microsoft::WRL::ComPtr<mozilla::widget::winrt::MetroInput> mMetroInput;
-  mozilla::layers::FrameMetrics mFrameMetrics;
   uint64_t mRootLayerTreeId;
-
-  // Async event dispatching
-  void DispatchAsyncScrollEvent(DispatchMsg* aEvent);
-  void DeliverNextScrollEvent();
-  void DeliverNextKeyboardEvent();
-  DispatchMsg* CreateDispatchMsg(UINT aMsg, WPARAM aWParam, LPARAM aLParam);
-
   nsDeque mMsgEventQueue;
   nsDeque mKeyEventQueue;
-
-public:
-  static nsRefPtr<mozilla::layers::APZCTreeManager> sAPZC;
+  nsRefPtr<APZController> mController;
 };
--- a/widget/windows/winrt/moz.build
+++ b/widget/windows/winrt/moz.build
@@ -14,16 +14,17 @@ CPP_SOURCES += [
     'MetroInput.cpp',
     'MetroUtils.cpp',
     'MetroWidget.cpp',
     'ToastNotificationHandler.cpp',
     'UIAAccessibilityBridge.cpp',
     'UIABridge.cpp',
     'nsMetroFilePicker.cpp',
     'nsWinMetroUtils.cpp',
+    'APZController.cpp',
 ]
 
 EXTRA_COMPONENTS += [
     'MetroUIUtils.js',
     'MetroUIUtils.manifest',
 ]
 
 LIBXUL_LIBRARY = True