Bug 864206 - Use dom::Touch instead of nsIDOMTouch where possible r=Ms2ger
authorDavid Zbarsky <dzbarsky@gmail.com>
Fri, 17 May 2013 13:17:53 -0700
changeset 132283 43872f1bfbda7fad90b5d1d79ffd09f3e1e4d5e7
parent 132282 e5e7221a2c8279fb383d9fc429fe4ee4789b7e41
child 132284 8096f5bdab923055e627e73bd04db3c855ac2c8b
push id24691
push userryanvm@gmail.com
push dateSat, 18 May 2013 01:41:18 +0000
treeherdermozilla-central@6e2789a70f6b [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersMs2ger
bugs864206
milestone24.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 864206 - Use dom::Touch instead of nsIDOMTouch where possible r=Ms2ger
content/base/src/nsDocument.cpp
content/events/src/Touch.cpp
content/events/src/Touch.h
dom/base/Navigator.cpp
dom/base/nsDOMWindowUtils.cpp
dom/ipc/ContentParent.cpp
dom/ipc/ProcessPriorityManager.cpp
dom/media/MediaManager.cpp
dom/mobilemessage/src/ipc/SmsParent.cpp
dom/plugins/ipc/PluginIdentifierParent.cpp
dom/power/WakeLock.cpp
dom/time/TimeChangeObserver.cpp
extensions/cookie/nsPermissionManager.cpp
hal/Hal.cpp
layout/base/nsPresShell.h
widget/android/AndroidJavaWrappers.cpp
widget/android/AndroidJavaWrappers.h
widget/windows/nsWindow.cpp
widget/windows/winrt/MetroInput.cpp
widget/windows/winrt/MetroInput.h
widget/xpwidgets/InputData.cpp
--- a/content/base/src/nsDocument.cpp
+++ b/content/base/src/nsDocument.cpp
@@ -9257,32 +9257,32 @@ nsDocument::CreateTouchList(nsIVariant* 
     uint16_t type;
     aPoints->GetDataType(&type);
     if (type == nsIDataType::VTYPE_INTERFACE ||
         type == nsIDataType::VTYPE_INTERFACE_IS) {
       nsCOMPtr<nsISupports> data;
       aPoints->GetAsISupports(getter_AddRefs(data));
       nsCOMPtr<nsIDOMTouch> point = do_QueryInterface(data);
       if (point) {
-        retval->Append(point);
+        retval->Append(static_cast<Touch*>(point.get()));
       }
     } else if (type == nsIDataType::VTYPE_ARRAY) {
       uint16_t valueType;
       nsIID iid;
       uint32_t valueCount;
       void* rawArray;
       aPoints->GetAsArray(&valueType, &iid, &valueCount, &rawArray);
       if (valueType == nsIDataType::VTYPE_INTERFACE ||
           valueType == nsIDataType::VTYPE_INTERFACE_IS) {
         nsISupports** values = static_cast<nsISupports**>(rawArray);
         for (uint32_t i = 0; i < valueCount; ++i) {
           nsCOMPtr<nsISupports> supports = dont_AddRef(values[i]);
           nsCOMPtr<nsIDOMTouch> point = do_QueryInterface(supports);
           if (point) {
-            retval->Append(point);
+            retval->Append(static_cast<Touch*>(point.get()));
           }
         }
       }
       nsMemory::Free(rawArray);
     }
   }
 
   *aRetVal = retval.forget().get();
--- a/content/events/src/Touch.cpp
+++ b/content/events/src/Touch.cpp
@@ -123,16 +123,34 @@ Touch::GetRotationAngle(float* aRotation
 
 NS_IMETHODIMP
 Touch::GetForce(float* aForce)
 {
   *aForce = Force();
   return NS_OK;
 }
 
+void
+Touch::InitializePoints(nsPresContext* aPresContext, nsEvent* aEvent)
+{
+  if (mPointsInitialized) {
+    return;
+  }
+  mClientPoint = nsDOMEvent::GetClientCoords(aPresContext,
+                                             aEvent,
+                                             mRefPoint,
+                                             mClientPoint);
+  mPagePoint = nsDOMEvent::GetPageCoords(aPresContext,
+                                         aEvent,
+                                         mRefPoint,
+                                         mClientPoint);
+  mScreenPoint = nsDOMEvent::GetScreenCoords(aPresContext, aEvent, mRefPoint);
+  mPointsInitialized = true;
+}
+
 bool
 Touch::Equals(nsIDOMTouch* aTouch)
 {
   float force;
   float orientation;
   int32_t radiusX, radiusY;
   aTouch->GetForce(&force);
   aTouch->GetRotationAngle(&orientation);
--- a/content/events/src/Touch.h
+++ b/content/events/src/Touch.h
@@ -71,40 +71,27 @@ public:
 
       mChanged = false;
       mMessage = 0;
       nsJSContext::LikelyShortLivingObjectCreated();
     }
   NS_DECL_CYCLE_COLLECTING_ISUPPORTS
   NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(Touch)
   NS_DECL_NSIDOMTOUCH
-  void InitializePoints(nsPresContext* aPresContext, nsEvent* aEvent)
-  {
-    if (mPointsInitialized) {
-      return;
-    }
-    mClientPoint = nsDOMEvent::GetClientCoords(aPresContext,
-                                               aEvent,
-                                               mRefPoint,
-                                               mClientPoint);
-    mPagePoint = nsDOMEvent::GetPageCoords(aPresContext,
-                                           aEvent,
-                                           mRefPoint,
-                                           mClientPoint);
-    mScreenPoint = nsDOMEvent::GetScreenCoords(aPresContext, aEvent, mRefPoint);
-    mPointsInitialized = true;
-  }
+
+  void InitializePoints(nsPresContext* aPresContext, nsEvent* aEvent);
+
   void SetTarget(mozilla::dom::EventTarget *aTarget)
   {
     mTarget = aTarget;
   }
   bool Equals(nsIDOMTouch* aTouch);
 
   virtual JSObject* WrapObject(JSContext* aCx,
-			       JS::Handle<JSObject*> aScope) MOZ_OVERRIDE;
+                               JS::Handle<JSObject*> aScope) MOZ_OVERRIDE;
   EventTarget* GetParentObject() { return mTarget; }
 
   // WebIDL
   int32_t Identifier() const { return mIdentifier; }
   EventTarget* Target() const;
   int32_t ScreenX() const { return mScreenPoint.x; }
   int32_t ScreenY() const { return mScreenPoint.y; }
   int32_t ClientX() const { return mClientPoint.x; }
--- a/dom/base/Navigator.cpp
+++ b/dom/base/Navigator.cpp
@@ -32,16 +32,18 @@
 #include "mozilla/dom/MobileMessageManager.h"
 #include "nsISmsService.h"
 #include "mozilla/Hal.h"
 #include "nsIWebNavigation.h"
 #include "nsISiteSpecificUserAgent.h"
 #include "mozilla/ClearOnShutdown.h"
 #include "mozilla/StaticPtr.h"
 #include "Connection.h"
+#include "nsDOMClassInfo.h"
+#include "nsDOMEvent.h"
 #ifdef MOZ_B2G_RIL
 #include "MobileConnection.h"
 #include "mozilla/dom/CellBroadcast.h"
 #include "mozilla/dom/Voicemail.h"
 #endif
 #include "nsIIdleObserver.h"
 #include "nsIPermissionManager.h"
 #include "nsNetUtil.h"
--- a/dom/base/nsDOMWindowUtils.cpp
+++ b/dom/base/nsDOMWindowUtils.cpp
@@ -851,21 +851,21 @@ nsDOMWindowUtils::SendTouchEvent(const n
 
   nsPresContext* presContext = GetPresContext();
   if (!presContext) {
     return NS_ERROR_FAILURE;
   }
   event.touches.SetCapacity(aCount);
   for (uint32_t i = 0; i < aCount; ++i) {
     nsIntPoint pt = ToWidgetPoint(aXs[i], aYs[i], offset, presContext);
-    nsCOMPtr<nsIDOMTouch> t(new Touch(aIdentifiers[i],
-                                      pt,
-                                      nsIntPoint(aRxs[i], aRys[i]),
-                                      aRotationAngles[i],
-                                      aForces[i]));
+    nsRefPtr<Touch> t = new Touch(aIdentifiers[i],
+                                  pt,
+                                  nsIntPoint(aRxs[i], aRys[i]),
+                                  aRotationAngles[i],
+                                  aForces[i]);
     event.touches.AppendElement(t);
   }
 
   nsEventStatus status;
   nsresult rv = widget->DispatchEvent(&event, status);
   *aPreventDefault = (status == nsEventStatus_eConsumeNoDefault);
   return rv;
 }
--- a/dom/ipc/ContentParent.cpp
+++ b/dom/ipc/ContentParent.cpp
@@ -21,16 +21,17 @@
 #include "AudioChannelService.h"
 #include "CrashReporterParent.h"
 #include "IHistory.h"
 #include "IDBFactory.h"
 #include "IndexedDBParent.h"
 #include "IndexedDatabaseManager.h"
 #include "mozIApplication.h"
 #include "mozilla/ClearOnShutdown.h"
+#include "mozilla/dom/Element.h"
 #include "mozilla/dom/ExternalHelperAppParent.h"
 #include "mozilla/dom/PMemoryReportRequestParent.h"
 #include "mozilla/dom/power/PowerManagerService.h"
 #include "mozilla/dom/DOMStorageIPC.h"
 #include "mozilla/dom/bluetooth/PBluetoothParent.h"
 #include "mozilla/dom/devicestorage/DeviceStorageRequestParent.h"
 #include "SmsParent.h"
 #include "mozilla/Hal.h"
--- a/dom/ipc/ProcessPriorityManager.cpp
+++ b/dom/ipc/ProcessPriorityManager.cpp
@@ -12,16 +12,17 @@
 #include "mozilla/Preferences.h"
 #include "mozilla/Services.h"
 #include "mozilla/unused.h"
 #include "AudioChannelService.h"
 #include "prlog.h"
 #include "nsPrintfCString.h"
 #include "nsWeakPtr.h"
 #include "nsXULAppAPI.h"
+#include "nsIFrameLoader.h"
 #include "nsIInterfaceRequestorUtils.h"
 #include "nsITimer.h"
 #include "nsIObserver.h"
 #include "nsIObserverService.h"
 #include "nsIDocument.h"
 #include "nsIDOMEventListener.h"
 #include "nsIDOMWindow.h"
 #include "nsIDOMEvent.h"
--- a/dom/media/MediaManager.cpp
+++ b/dom/media/MediaManager.cpp
@@ -7,16 +7,17 @@
 #include "MediaStreamGraph.h"
 #include "nsIDOMFile.h"
 #include "nsIEventTarget.h"
 #include "nsIUUIDGenerator.h"
 #include "nsIScriptGlobalObject.h"
 #include "nsIPopupWindowManager.h"
 #include "nsISupportsArray.h"
 #include "nsIDocShell.h"
+#include "nsIDocument.h"
 
 // For PR_snprintf
 #include "prprf.h"
 
 #include "nsJSUtils.h"
 #include "nsDOMFile.h"
 #include "nsGlobalWindow.h"
 
--- a/dom/mobilemessage/src/ipc/SmsParent.cpp
+++ b/dom/mobilemessage/src/ipc/SmsParent.cpp
@@ -16,16 +16,17 @@
 #include "MmsMessage.h"
 #include "nsIMobileMessageDatabaseService.h"
 #include "SmsFilter.h"
 #include "SmsSegmentInfo.h"
 #include "MobileMessageThread.h"
 #include "nsIDOMFile.h"
 #include "mozilla/dom/ipc/Blob.h"
 #include "mozilla/dom/ContentParent.h"
+#include "nsContentUtils.h"
 #include "nsTArrayHelpers.h"
 
 namespace mozilla {
 namespace dom {
 namespace mobilemessage {
 
 static JSObject*
 MmsAttachmentDataToJSObject(JSContext* aContext,
--- a/dom/plugins/ipc/PluginIdentifierParent.cpp
+++ b/dom/plugins/ipc/PluginIdentifierParent.cpp
@@ -1,18 +1,19 @@
 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*-
  * vim: sw=2 ts=2 et :
  * 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 "PluginIdentifierParent.h"
 
+#include "nsContentUtils.h"
+#include "nsNPAPIPlugin.h"
 #include "nsServiceManagerUtils.h"
-#include "nsNPAPIPlugin.h"
 #include "PluginScriptableObjectUtils.h"
 #include "mozilla/unused.h"
 
 using namespace mozilla::plugins::parent;
 
 namespace mozilla {
 namespace plugins {
 
--- a/dom/power/WakeLock.cpp
+++ b/dom/power/WakeLock.cpp
@@ -3,17 +3,19 @@
  * 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 "WakeLock.h"
 #include "mozilla/dom/ContentParent.h"
 #include "mozilla/Hal.h"
 #include "mozilla/HalWakeLock.h"
 #include "nsDOMClassInfoID.h"
+#include "nsDOMEvent.h"
 #include "nsError.h"
+#include "nsIDocument.h"
 #include "nsIDOMWindow.h"
 #include "nsIDOMEvent.h"
 #include "nsPIDOMWindow.h"
 #include "PowerManager.h"
 
 DOMCI_DATA(MozWakeLock, mozilla::dom::power::WakeLock)
 
 using namespace mozilla::hal;
--- a/dom/time/TimeChangeObserver.cpp
+++ b/dom/time/TimeChangeObserver.cpp
@@ -6,16 +6,17 @@
 #include "TimeChangeObserver.h"
 #include "mozilla/ClearOnShutdown.h"
 #include "mozilla/Services.h"
 #include "mozilla/StaticPtr.h"
 #include "nsPIDOMWindow.h"
 #include "nsDOMEvent.h"
 #include "nsContentUtils.h"
 #include "nsIObserverService.h"
+#include "nsIDocument.h"
 
 using namespace mozilla;
 using namespace mozilla::hal;
 using namespace mozilla::services;
 
 StaticAutoPtr<nsSystemTimeChangeObserver> sObserver;
 
 nsSystemTimeChangeObserver* nsSystemTimeChangeObserver::GetInstance()
--- a/extensions/cookie/nsPermissionManager.cpp
+++ b/extensions/cookie/nsPermissionManager.cpp
@@ -25,16 +25,18 @@
 #include "mozilla/Attributes.h"
 #include "nsXULAppAPI.h"
 #include "nsIPrincipal.h"
 #include "nsContentUtils.h"
 #include "nsIScriptSecurityManager.h"
 #include "nsIAppsService.h"
 #include "mozIApplication.h"
 #include "nsIEffectiveTLDService.h"
+#include "nsPIDOMWindow.h"
+#include "nsIDocument.h"
 
 static nsPermissionManager *gPermissionManager = nullptr;
 
 using mozilla::dom::ContentParent;
 using mozilla::dom::ContentChild;
 using mozilla::unused; // ha!
 
 static bool
--- a/hal/Hal.cpp
+++ b/hal/Hal.cpp
@@ -6,17 +6,19 @@
 
 #include "Hal.h"
 #include "HalImpl.h"
 #include "HalSandbox.h"
 #include "mozilla/Util.h"
 #include "nsThreadUtils.h"
 #include "nsXULAppAPI.h"
 #include "mozilla/Observer.h"
+#include "nsIDocument.h"
 #include "nsIDOMDocument.h"
+#include "nsPIDOMWindow.h"
 #include "nsIDOMWindow.h"
 #include "mozilla/Services.h"
 #include "nsIWebNavigation.h"
 #include "nsITabChild.h"
 #include "nsIDocShell.h"
 #include "mozilla/StaticPtr.h"
 #include "mozilla/ClearOnShutdown.h"
 #include "WindowIdentifier.h"
--- a/layout/base/nsPresShell.h
+++ b/layout/base/nsPresShell.h
@@ -347,17 +347,16 @@ protected:
 
   void WillCauseReflow() {
     nsContentUtils::AddScriptBlocker();
     ++mChangeNestCount;
   }
   nsresult DidCauseReflow();
   friend class nsAutoCauseReflowNotifier;
 
-  bool TouchesAreEqual(nsIDOMTouch *aTouch1, nsIDOMTouch *aTouch2);
   void DispatchTouchEvent(nsEvent *aEvent,
                           nsEventStatus* aStatus,
                           nsPresShellEventCB* aEventCB,
                           bool aTouchIsNew);
 
   void     WillDoReflow();
 
   /**
--- a/widget/android/AndroidJavaWrappers.cpp
+++ b/widget/android/AndroidJavaWrappers.cpp
@@ -2,18 +2,21 @@
  * 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 "AndroidJavaWrappers.h"
 #include "AndroidBridge.h"
 #include "nsIAndroidBridge.h"
 #include "nsIDOMKeyEvent.h"
+#include "nsIWidget.h"
+#include "nsGUIEvent.h"
 
 using namespace mozilla;
+using namespace mozilla::dom;
 
 jclass AndroidGeckoEvent::jGeckoEventClass = 0;
 jfieldID AndroidGeckoEvent::jActionField = 0;
 jfieldID AndroidGeckoEvent::jTypeField = 0;
 jfieldID AndroidGeckoEvent::jAckNeededField = 0;
 jfieldID AndroidGeckoEvent::jTimeField = 0;
 jfieldID AndroidGeckoEvent::jPoints = 0;
 jfieldID AndroidGeckoEvent::jPointIndicies = 0;
@@ -731,21 +734,21 @@ AndroidGeckoEvent::MakeTouchEvent(nsIWid
     event.InitBasicModifiers(IsCtrlPressed(),
                              IsAltPressed(),
                              IsShiftPressed(),
                              IsMetaPressed());
 
     const nsIntPoint& offset = widget->WidgetToScreenOffset();
     event.touches.SetCapacity(endIndex - startIndex);
     for (int i = startIndex; i < endIndex; i++) {
-        nsCOMPtr<nsIDOMTouch> t(new dom::Touch(PointIndicies()[i],
-                                               Points()[i] - offset,
-                                               PointRadii()[i],
-                                               Orientations()[i],
-                                               Pressures()[i]));
+        nsRefPtr<Touch> t = new Touch(PointIndicies()[i],
+                                      Points()[i] - offset,
+                                      PointRadii()[i],
+                                      Orientations()[i],
+                                      Pressures()[i]);
         event.touches.AppendElement(t);
     }
 
     return event;
 }
 
 MultiTouchInput
 AndroidGeckoEvent::MakeMultiTouchInput(nsIWidget* widget)
--- a/widget/android/AndroidJavaWrappers.h
+++ b/widget/android/AndroidJavaWrappers.h
@@ -26,16 +26,17 @@
 #define ALOG(args...)  __android_log_print(ANDROID_LOG_INFO, "Gecko" , ## args)
 #else
 #define ALOG(args...) ((void)0)
 #endif
 #endif
 
 class nsIAndroidDisplayport;
 class nsIAndroidViewport;
+class nsIWidget;
 
 namespace mozilla {
 
 class AndroidGeckoLayerClient;
 class AutoLocalJNIFrame;
 
 void InitAndroidJavaWrappers(JNIEnv *jEnv);
 
--- a/widget/windows/nsWindow.cpp
+++ b/widget/windows/nsWindow.cpp
@@ -6328,17 +6328,17 @@ bool nsWindow::OnTouch(WPARAM wParam, LP
         continue;
       }
 
       // Setup the touch point we'll append to the touch event array
       nsPointWin touchPoint;
       touchPoint.x = TOUCH_COORD_TO_PIXEL(pInputs[i].x);
       touchPoint.y = TOUCH_COORD_TO_PIXEL(pInputs[i].y);
       touchPoint.ScreenToClient(mWnd);
-      nsCOMPtr<nsIDOMTouch> touch =
+      nsRefPtr<Touch> touch =
         new Touch(pInputs[i].dwID,
                   touchPoint,
                   /* radius, if known */
                   pInputs[i].dwFlags & TOUCHINPUTMASKF_CONTACTAREA ?
                     nsIntPoint(
                       TOUCH_COORD_TO_PIXEL(pInputs[i].cxContact) / 2,
                       TOUCH_COORD_TO_PIXEL(pInputs[i].cyContact) / 2) :
                     nsIntPoint(1,1),
--- a/widget/windows/winrt/MetroInput.cpp
+++ b/widget/windows/winrt/MetroInput.cpp
@@ -126,35 +126,35 @@ namespace {
                   == aDeviceType) {
       aMozInputSource = nsIDOMMouseEvent::MOZ_SOURCE_PEN;
     }
   }
 
   /**
    * This function is for use with mTouches.Enumerate.  It will
    * append each element it encounters to the {@link nsTArray}
-   * of {@link nsIDOMTouch}es passed in through the third (void*)
+   * of {@link mozilla::dom::Touch}es passed in through the third (void*)
    * parameter.
    *
    * NOTE: This function will set the `mChanged` member of each
    * element it encounters to `false`, since this function is only
    * used to populate a touchlist that is about to be dispatched
    * in a gecko touch event.
    *
    * @param aKey the key of the current element being enumerated
    * @param aData the value of the current element being enumerated
    * @param aTouchList the {@link nsTArray} to append to
    */
   PLDHashOperator
   AppendToTouchList(const unsigned int& aKey,
-                    nsCOMPtr<nsIDOMTouch>& aData,
+                    nsRefPtr<Touch>& aData,
                     void *aTouchList)
   {
-    nsTArray<nsCOMPtr<nsIDOMTouch> > *touches =
-              static_cast<nsTArray<nsCOMPtr<nsIDOMTouch> > *>(aTouchList);
+    nsTArray<nsRefPtr<Touch> > *touches =
+              static_cast<nsTArray<nsRefPtr<Touch> > *>(aTouchList);
     touches->AppendElement(aData);
     aData->mChanged = false;
     return PL_DHASH_NEXT;
   }
 
   // In response to keyboard events, we create an `NPEvent` and point the
   // `pluginEvent` member of our `nsInputEvent` to it.  We must set the
   // `wParam` and `lParam` members of our `NPEvent` according to what
@@ -800,17 +800,17 @@ MetroInput::OnPointerPressed(UI::Core::I
     mGestureRecognizer->ProcessDownEvent(currentPoint.Get());
     return S_OK;
   }
 
   // This is touch input.
   // Create the new touch point and add it to our event.
   uint32_t pointerId;
   currentPoint->get_PointerId(&pointerId);
-  nsCOMPtr<nsIDOMTouch> touch = CreateDOMTouch(currentPoint.Get());
+  nsRefPtr<Touch> touch = CreateDOMTouch(currentPoint.Get());
   touch->mChanged = true;
   mTouches.Put(pointerId, touch);
   mTouchEvent.message = NS_TOUCH_START;
 
   // If this is the first touchstart of a touch session,
   // dispatch it now so we can see if preventDefault gets called on it.
   if (mTouches.Count() == 1) {
     nsEventStatus status;
@@ -859,17 +859,17 @@ MetroInput::OnPointerReleased(UI::Core::
     mGestureRecognizer->ProcessUpEvent(currentPoint.Get());
     return S_OK;
   }
 
   // This is touch input.
   // Get the touch associated with this touch point.
   uint32_t pointerId;
   currentPoint->get_PointerId(&pointerId);
-  nsCOMPtr<nsIDOMTouch> touch = mTouches.Get(pointerId);
+  nsRefPtr<Touch> touch = mTouches.Get(pointerId);
 
   // We are about to dispatch a touchend.  Before we do that, we should make
   // sure that we don't have a touchmove or touchstart sitting around for this
   // point.
   if (touch->mChanged) {
     DispatchPendingTouchEvent();
   }
   mTouches.Remove(pointerId);
@@ -928,17 +928,17 @@ MetroInput::OnPointerMoved(UI::Core::ICo
     mGestureRecognizer->ProcessMoveEvents(pointerPoints.Get());
     return S_OK;
   }
 
   // This is touch input.
   // Get the touch associated with this touch point.
   uint32_t pointerId;
   currentPoint->get_PointerId(&pointerId);
-  nsCOMPtr<nsIDOMTouch> touch = mTouches.Get(pointerId);
+  nsRefPtr<Touch> touch = mTouches.Get(pointerId);
 
   // Some old drivers cause us to receive a PointerMoved event for a touchId
   // after we've already received a PointerReleased event for that touchId.
   // To work around those busted drivers, we simply ignore TouchMoved events
   // for touchIds that we are not currently tracking.  See bug 819223.
   if (!touch) {
     return S_OK;
   }
--- a/widget/windows/winrt/MetroInput.h
+++ b/widget/windows/winrt/MetroInput.h
@@ -15,21 +15,26 @@
 // System headers (alphabetical)
 #include <EventToken.h>     // EventRegistrationToken
 #include <stdint.h>         // uint32_t
 #include <wrl\client.h>     // Microsoft::WRL::ComPtr class
 #include <wrl\implements.h> // Microsoft::WRL::InspectableClass macro
 
 // Moz forward declarations
 class MetroWidget;
-class nsIDOMTouch;
 enum nsEventStatus;
 class nsGUIEvent;
 struct nsIntPoint;
 
+namespace mozilla {
+namespace dom {
+class Touch;
+}
+}
+
 // Windows forward declarations
 namespace ABI {
   namespace Windows {
     namespace Devices {
       namespace Input {
         enum PointerDeviceType;
       }
     };
@@ -230,18 +235,18 @@ private:
   // the updated touchpoint info and record the fact that the touchpoint
   // has changed.  If ever we try to update a touchpoint has already
   // changed, we dispatch a touch event containing all the changed touches.
   nsEventStatus mTouchEventStatus;
   nsTouchEvent mTouchEvent;
   void DispatchPendingTouchEvent();
   void DispatchPendingTouchEvent(nsEventStatus& status);
   nsBaseHashtable<nsUint32HashKey,
-                  nsCOMPtr<nsIDOMTouch>,
-                  nsCOMPtr<nsIDOMTouch> > mTouches;
+                  nsRefPtr<mozilla::dom::Touch>,
+                  nsRefPtr<mozilla::dom::Touch> > mTouches;
 
   // When a key press is received, we convert the Windows virtual key
   // into a gecko virtual key to send in a gecko event.
   //
   // Source:
   // http://msdn.microsoft.com
   //       /en-us/library/windows/apps/windows.system.virtualkey.aspx
   static uint32_t sVirtualKeyMap[255];
--- a/widget/xpwidgets/InputData.cpp
+++ b/widget/xpwidgets/InputData.cpp
@@ -3,16 +3,17 @@
  * 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 "InputData.h"
 
 #include "nsGUIEvent.h"
 #include "mozilla/dom/Touch.h"
 #include "nsDebug.h"
+#include "nsThreadUtils.h"
 
 namespace mozilla {
 
 using namespace dom;
 
 MultiTouchInput::MultiTouchInput(const nsTouchEvent& aTouchEvent)
   : InputData(MULTITOUCH_INPUT, aTouchEvent.time)
 {