Bug 920377 part.13 Get rid of nsTouchEvent r=roc
authorMasayuki Nakano <masayuki@d-toybox.com>
Fri, 27 Sep 2013 15:20:57 +0900
changeset 162772 fe2419c32ee75250a3342c08040c462cd5fb2ccc
parent 162771 45f2e3fce2c1141daac7e878197462ce8d234c17
child 162773 46cb542ac785b1777452baaaa771f1a08b8642e8
push id3066
push userakeybl@mozilla.com
push dateMon, 09 Dec 2013 19:58:46 +0000
treeherdermozilla-beta@a31a0dce83aa [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersroc
bugs920377
milestone27.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 920377 part.13 Get rid of nsTouchEvent r=roc
accessible/src/base/nsCoreUtils.cpp
content/events/src/nsDOMEvent.cpp
content/events/src/nsDOMTouchEvent.cpp
content/events/src/nsDOMTouchEvent.h
content/events/src/nsEventDispatcher.cpp
content/events/src/nsEventStateManager.cpp
content/html/content/src/HTMLInputElement.cpp
dom/base/nsDOMWindowUtils.cpp
dom/interfaces/events/nsIDOMEvent.idl
dom/ipc/PBrowser.ipdl
dom/ipc/TabChild.cpp
dom/ipc/TabChild.h
dom/ipc/TabParent.cpp
dom/ipc/TabParent.h
gfx/layers/composite/APZCTreeManager.cpp
gfx/layers/composite/APZCTreeManager.h
layout/base/nsPresShell.cpp
layout/forms/nsRangeFrame.cpp
layout/xul/base/src/nsBoxFrame.cpp
widget/EventForwards.h
widget/InputData.h
widget/TouchEvents.h
widget/android/AndroidJavaWrappers.cpp
widget/android/AndroidJavaWrappers.h
widget/android/nsWindow.cpp
widget/gonk/nsAppShell.cpp
widget/nsGUIEventIPC.h
widget/windows/nsWindow.cpp
widget/windows/winrt/MetroInput.cpp
widget/windows/winrt/MetroInput.h
widget/xpwidgets/InputData.cpp
--- a/accessible/src/base/nsCoreUtils.cpp
+++ b/accessible/src/base/nsCoreUtils.cpp
@@ -139,17 +139,17 @@ nsCoreUtils::DispatchMouseEvent(uint32_t
 void
 nsCoreUtils::DispatchTouchEvent(uint32_t aEventType, int32_t aX, int32_t aY,
                                 nsIContent* aContent, nsIFrame* aFrame,
                                 nsIPresShell* aPresShell, nsIWidget* aRootWidget)
 {
   if (!nsDOMTouchEvent::PrefEnabled())
     return;
 
-  nsTouchEvent event(true, aEventType, aRootWidget);
+  WidgetTouchEvent event(true, aEventType, aRootWidget);
 
   event.time = PR_IntervalNow();
 
   // XXX: Touch has an identifier of -1 to hint that it is synthesized.
   nsRefPtr<mozilla::dom::Touch> t =
     new mozilla::dom::Touch(-1, nsIntPoint(aX, aY),
                             nsIntPoint(1, 1), 0.0f, 1.0f);
   t->SetTarget(aContent);
--- a/content/events/src/nsDOMEvent.cpp
+++ b/content/events/src/nsDOMEvent.cpp
@@ -736,18 +736,18 @@ nsDOMEvent::DuplicatePrivateData()
                                    oldAnimationEvent->elapsedTime,
                                    oldAnimationEvent->pseudoElement);
       animationEvent->AssignAnimationEventData(*oldAnimationEvent, true);
       newEvent = animationEvent;
       break;
     }
     case NS_TOUCH_EVENT:
     {
-      nsTouchEvent* oldTouchEvent = static_cast<nsTouchEvent*>(mEvent);
-      nsTouchEvent* touchEvent = new nsTouchEvent(false, oldTouchEvent);
+      WidgetTouchEvent* oldTouchEvent = static_cast<WidgetTouchEvent*>(mEvent);
+      WidgetTouchEvent* touchEvent = new WidgetTouchEvent(false, oldTouchEvent);
       touchEvent->AssignTouchEventData(*oldTouchEvent, true);
       newEvent = touchEvent;
       break;
     }
     default:
     {
       NS_WARNING("Unknown event type!!!");
       return NS_ERROR_FAILURE;
--- a/content/events/src/nsDOMTouchEvent.cpp
+++ b/content/events/src/nsDOMTouchEvent.cpp
@@ -49,19 +49,19 @@ nsDOMTouchList::IdentifiedTouch(int32_t 
   }
   return nullptr;
 }
 
 // TouchEvent
 
 nsDOMTouchEvent::nsDOMTouchEvent(mozilla::dom::EventTarget* aOwner,
                                  nsPresContext* aPresContext,
-                                 nsTouchEvent* aEvent)
+                                 WidgetTouchEvent* aEvent)
   : nsDOMUIEvent(aOwner, aPresContext,
-                 aEvent ? aEvent : new nsTouchEvent(false, 0, nullptr))
+                 aEvent ? aEvent : new WidgetTouchEvent(false, 0, nullptr))
 {
   if (aEvent) {
     mEventIsInternal = false;
 
     for (uint32_t i = 0; i < aEvent->touches.Length(); ++i) {
       Touch* touch = aEvent->touches[i];
       touch->InitializePoints(mPresContext, aEvent);
     }
@@ -69,17 +69,17 @@ nsDOMTouchEvent::nsDOMTouchEvent(mozilla
     mEventIsInternal = true;
     mEvent->time = PR_Now();
   }
 }
 
 nsDOMTouchEvent::~nsDOMTouchEvent()
 {
   if (mEventIsInternal && mEvent) {
-    delete static_cast<nsTouchEvent*>(mEvent);
+    delete static_cast<WidgetTouchEvent*>(mEvent);
     mEvent = nullptr;
   }
 }
 
 NS_IMPL_CYCLE_COLLECTION_INHERITED_3(nsDOMTouchEvent, nsDOMUIEvent,
                                      mTouches,
                                      mTargetTouches,
                                      mChangedTouches)
@@ -121,17 +121,17 @@ nsDOMTouchEvent::InitTouchEvent(const ns
   mTargetTouches = aTargetTouches;
   mChangedTouches = aChangedTouches;
 }
 
 nsDOMTouchList*
 nsDOMTouchEvent::Touches()
 {
   if (!mTouches) {
-    nsTouchEvent* touchEvent = static_cast<nsTouchEvent*>(mEvent);
+    WidgetTouchEvent* touchEvent = static_cast<WidgetTouchEvent*>(mEvent);
     if (mEvent->message == NS_TOUCH_END || mEvent->message == NS_TOUCH_CANCEL) {
       // for touchend events, remove any changed touches from the touches array
       nsTArray< nsRefPtr<Touch> > unchangedTouches;
       const nsTArray< nsRefPtr<Touch> >& touches = touchEvent->touches;
       for (uint32_t i = 0; i < touches.Length(); ++i) {
         if (!touches[i]->mChanged) {
           unchangedTouches.AppendElement(touches[i]);
         }
@@ -144,17 +144,17 @@ nsDOMTouchEvent::Touches()
   return mTouches;
 }
 
 nsDOMTouchList*
 nsDOMTouchEvent::TargetTouches()
 {
   if (!mTargetTouches) {
     nsTArray< nsRefPtr<Touch> > targetTouches;
-    nsTouchEvent* touchEvent = static_cast<nsTouchEvent*>(mEvent);
+    WidgetTouchEvent* touchEvent = static_cast<WidgetTouchEvent*>(mEvent);
     const nsTArray< nsRefPtr<Touch> >& touches = touchEvent->touches;
     for (uint32_t i = 0; i < touches.Length(); ++i) {
       // for touchend/cancel events, don't append to the target list if this is a
       // touch that is ending
       if ((mEvent->message != NS_TOUCH_END &&
            mEvent->message != NS_TOUCH_CANCEL) || !touches[i]->mChanged) {
         if (touches[i]->mTarget == mEvent->originalTarget) {
           targetTouches.AppendElement(touches[i]);
@@ -166,17 +166,17 @@ nsDOMTouchEvent::TargetTouches()
   return mTargetTouches;
 }
 
 nsDOMTouchList*
 nsDOMTouchEvent::ChangedTouches()
 {
   if (!mChangedTouches) {
     nsTArray< nsRefPtr<Touch> > changedTouches;
-    nsTouchEvent* touchEvent = static_cast<nsTouchEvent*>(mEvent);
+    WidgetTouchEvent* touchEvent = static_cast<WidgetTouchEvent*>(mEvent);
     const nsTArray< nsRefPtr<Touch> >& touches = touchEvent->touches;
     for (uint32_t i = 0; i < touches.Length(); ++i) {
       if (touches[i]->mChanged) {
         changedTouches.AppendElement(touches[i]);
       }
     }
     mChangedTouches = new nsDOMTouchList(ToSupports(this), changedTouches);
   }
@@ -220,13 +220,13 @@ nsDOMTouchEvent::PrefEnabled()
   }
   return prefValue;
 }
 
 nsresult
 NS_NewDOMTouchEvent(nsIDOMEvent** aInstancePtrResult,
                     mozilla::dom::EventTarget* aOwner,
                     nsPresContext* aPresContext,
-                    nsTouchEvent *aEvent)
+                    WidgetTouchEvent* aEvent)
 {
   nsDOMTouchEvent* it = new nsDOMTouchEvent(aOwner, aPresContext, aEvent);
   return CallQueryInterface(it, aInstancePtrResult);
 }
--- a/content/events/src/nsDOMTouchEvent.h
+++ b/content/events/src/nsDOMTouchEvent.h
@@ -77,17 +77,18 @@ protected:
   nsCOMPtr<nsISupports> mParent;
   nsTArray< nsRefPtr<Touch> > mPoints;
 };
 
 class nsDOMTouchEvent : public nsDOMUIEvent
 {
 public:
   nsDOMTouchEvent(mozilla::dom::EventTarget* aOwner,
-                  nsPresContext* aPresContext, nsTouchEvent* aEvent);
+                  nsPresContext* aPresContext,
+                  mozilla::WidgetTouchEvent* aEvent);
   virtual ~nsDOMTouchEvent();
 
   NS_DECL_ISUPPORTS_INHERITED
   NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(nsDOMTouchEvent, nsDOMUIEvent)
 
   virtual JSObject* WrapObject(JSContext* aCx,
                                JS::Handle<JSObject*> aScope) MOZ_OVERRIDE
   {
--- a/content/events/src/nsEventDispatcher.cpp
+++ b/content/events/src/nsEventDispatcher.cpp
@@ -736,17 +736,17 @@ nsEventDispatcher::CreateEvent(mozilla::
     case NS_COMMAND_EVENT:
       return NS_NewDOMCommandEvent(aDOMEvent, aOwner, aPresContext,
                                    static_cast<WidgetCommandEvent*>(aEvent));
     case NS_SIMPLE_GESTURE_EVENT:
       return NS_NewDOMSimpleGestureEvent(aDOMEvent, aOwner, aPresContext,
                                          static_cast<nsSimpleGestureEvent*>(aEvent));
     case NS_TOUCH_EVENT:
       return NS_NewDOMTouchEvent(aDOMEvent, aOwner, aPresContext,
-                                 static_cast<nsTouchEvent*>(aEvent));
+                                 static_cast<WidgetTouchEvent*>(aEvent));
     case NS_TRANSITION_EVENT:
       return NS_NewDOMTransitionEvent(aDOMEvent, aOwner, aPresContext,
                static_cast<InternalTransitionEvent*>(aEvent));
     case NS_ANIMATION_EVENT:
       return NS_NewDOMAnimationEvent(aDOMEvent, aOwner, aPresContext,
                static_cast<InternalAnimationEvent*>(aEvent));
     default:
       // For all other types of events, create a vanilla event object.
--- a/content/events/src/nsEventStateManager.cpp
+++ b/content/events/src/nsEventStateManager.cpp
@@ -1394,17 +1394,17 @@ nsEventStateManager::DispatchCrossProces
   case NS_WHEEL_EVENT: {
     WheelEvent* wheelEvent = static_cast<WheelEvent*>(aEvent);
     return remote->SendMouseWheelEvent(*wheelEvent);
   }
   case NS_TOUCH_EVENT: {
     // Let the child process synthesize a mouse event if needed, and
     // ensure we don't synthesize one in this process.
     *aStatus = nsEventStatus_eConsumeNoDefault;
-    nsTouchEvent* touchEvent = static_cast<nsTouchEvent*>(aEvent);
+    WidgetTouchEvent* touchEvent = static_cast<WidgetTouchEvent*>(aEvent);
     return remote->SendRealTouchEvent(*touchEvent);
   }
   default: {
     MOZ_CRASH("Attempt to send non-whitelisted event?");
   }
   }
 }
 
@@ -1511,17 +1511,17 @@ nsEventStateManager::HandleCrossProcessE
   } else {
     // This is a touch event with possibly multiple touch points.
     // Each touch point may have its own target.  So iterate through
     // all of them and collect the unique set of targets for event
     // forwarding.
     //
     // This loop is similar to the one used in
     // PresShell::DispatchTouchEvent().
-    nsTouchEvent* touchEvent = static_cast<nsTouchEvent*>(aEvent);
+    WidgetTouchEvent* touchEvent = static_cast<WidgetTouchEvent*>(aEvent);
     const nsTArray< nsRefPtr<Touch> >& touches = touchEvent->touches;
     for (uint32_t i = 0; i < touches.Length(); ++i) {
       Touch* touch = touches[i];
       // NB: the |mChanged| check is an optimization, subprocesses can
       // compute this for themselves.  If the touch hasn't changed, we
       // may be able to avoid forwarding the event entirely (which is
       // not free).
       if (!touch || !touch->mChanged) {
--- a/content/html/content/src/HTMLInputElement.cpp
+++ b/content/html/content/src/HTMLInputElement.cpp
@@ -3704,17 +3704,18 @@ HTMLInputElement::PostHandleEventForRang
       if (aVisitor.mEvent->message == NS_MOUSE_BUTTON_DOWN) {
         nsMouseEvent* mouseEvent = static_cast<nsMouseEvent*>(aVisitor.mEvent);
         if (mouseEvent->buttons == nsMouseEvent::eLeftButtonFlag) {
           StartRangeThumbDrag(inputEvent);
         } else if (mIsDraggingRange) {
           CancelRangeThumbDrag();
         }
       } else {
-        nsTouchEvent* touchEvent = static_cast<nsTouchEvent*>(aVisitor.mEvent);
+        WidgetTouchEvent* touchEvent =
+          static_cast<WidgetTouchEvent*>(aVisitor.mEvent);
         if (touchEvent->touches.Length() == 1) {
           StartRangeThumbDrag(inputEvent);
         } else if (mIsDraggingRange) {
           CancelRangeThumbDrag();
         }
       }
       aVisitor.mEvent->mFlags.mMultipleActionsPrevented = true;
     } break;
--- a/dom/base/nsDOMWindowUtils.cpp
+++ b/dom/base/nsDOMWindowUtils.cpp
@@ -871,17 +871,17 @@ nsDOMWindowUtils::SendTouchEvent(const n
     msg = NS_TOUCH_MOVE;
   } else if (aType.EqualsLiteral("touchend")) {
     msg = NS_TOUCH_END;
   } else if (aType.EqualsLiteral("touchcancel")) {
     msg = NS_TOUCH_CANCEL;
   } else {
     return NS_ERROR_UNEXPECTED;
   }
-  nsTouchEvent event(true, msg, widget);
+  WidgetTouchEvent event(true, msg, widget);
   event.modifiers = GetWidgetModifiers(aModifiers);
   event.widget = widget;
   event.time = PR_Now();
 
   nsPresContext* presContext = GetPresContext();
   if (!presContext) {
     return NS_ERROR_FAILURE;
   }
--- a/dom/interfaces/events/nsIDOMEvent.idl
+++ b/dom/interfaces/events/nsIDOMEvent.idl
@@ -370,17 +370,17 @@ nsresult
 NS_NewDOMAnimationEvent(nsIDOMEvent** aInstancePtrResult,
                         mozilla::dom::EventTarget* aOwner,
                         nsPresContext* aPresContext,
                         mozilla::InternalAnimationEvent* aEvent);
 nsresult
 NS_NewDOMTouchEvent(nsIDOMEvent** aInstancePtrResult,
                     mozilla::dom::EventTarget* aOwner,
                     nsPresContext* aPresContext,
-                    nsTouchEvent* aEvent);
+                    mozilla::WidgetTouchEvent* aEvent);
 nsresult
 NS_NewDOMMozSettingsEvent(nsIDOMEvent** aInstancePtrResult,
                           mozilla::dom::EventTarget* aOwner,
                           nsPresContext* aPresContext,
                           nsEvent* aEvent);
 nsresult
 NS_NewDOMMozApplicationEvent(nsIDOMEvent** aInstancePtrResult,
                              mozilla::dom::EventTarget* aOwner,
--- a/dom/ipc/PBrowser.ipdl
+++ b/dom/ipc/PBrowser.ipdl
@@ -44,17 +44,17 @@ using nsIntSize;
 using nsKeyEvent;
 using nsMouseEvent;
 using nsMouseScrollEvent;
 using mozilla::WheelEvent;
 using nsQueryContentEvent;
 using nsRect;
 using nsSelectionEvent;
 using nsTextEvent;
-using nsTouchEvent;
+using mozilla::WidgetTouchEvent;
 using RemoteDOMEvent;
 using mozilla::dom::ScreenOrientation;
 using mozilla::layers::TextureFactoryIdentifier;
 using mozilla::CSSIntPoint;
 using mozilla::CSSToScreenScale;
 namespace mozilla {
 namespace dom {
 
@@ -362,20 +362,20 @@ child:
                int32_t aButton,
                int32_t aClickCount,
                int32_t aModifiers,
                bool aIgnoreRootScrollFrame);
 
     RealMouseEvent(nsMouseEvent event);
     RealKeyEvent(nsKeyEvent event);
     MouseWheelEvent(WheelEvent event);
-    RealTouchEvent(nsTouchEvent event);
+    RealTouchEvent(WidgetTouchEvent event);
     // We use a separate message for touchmove events only to apply
     // compression to them.
-    RealTouchMoveEvent(nsTouchEvent event) compress;
+    RealTouchMoveEvent(WidgetTouchEvent event) compress;
 
     /**
      * @see nsIDOMWindowUtils sendKeyEvent.
      */
     KeyEvent(nsString aType,
              int32_t aKeyCode,
              int32_t aCharCode,
              int32_t aModifiers,
--- a/dom/ipc/TabChild.cpp
+++ b/dom/ipc/TabChild.cpp
@@ -1697,29 +1697,29 @@ TabChild::DispatchSynthesizedMouseEvent(
   if (aMsg != NS_MOUSE_MOVE) {
     event.clickCount = 1;
   }
 
   DispatchWidgetEvent(event);
 }
 
 static Touch*
-GetTouchForIdentifier(const nsTouchEvent& aEvent, int32_t aId)
+GetTouchForIdentifier(const WidgetTouchEvent& aEvent, int32_t aId)
 {
   for (uint32_t i = 0; i < aEvent.touches.Length(); ++i) {
     Touch* touch = static_cast<Touch*>(aEvent.touches[i].get());
     if (touch->mIdentifier == aId) {
       return touch;
     }
   }
   return nullptr;
 }
 
 void
-TabChild::UpdateTapState(const nsTouchEvent& aEvent, nsEventStatus aStatus)
+TabChild::UpdateTapState(const WidgetTouchEvent& aEvent, nsEventStatus aStatus)
 {
   static bool sHavePrefs;
   static bool sClickHoldContextMenusEnabled;
   static nsIntSize sDragThreshold;
   static int32_t sContextMenuDelayMs;
   if (!sHavePrefs) {
     sHavePrefs = true;
     Preferences::AddBoolVarCache(&sClickHoldContextMenusEnabled,
@@ -1828,19 +1828,19 @@ TabChild::CancelTapTracking()
   mActivePointerId = -1;
   if (mTapHoldTimer) {
     mTapHoldTimer->Cancel();
   }
   mTapHoldTimer = nullptr;
 }
 
 bool
-TabChild::RecvRealTouchEvent(const nsTouchEvent& aEvent)
+TabChild::RecvRealTouchEvent(const WidgetTouchEvent& aEvent)
 {
-  nsTouchEvent localEvent(aEvent);
+  WidgetTouchEvent localEvent(aEvent);
   nsEventStatus status = DispatchWidgetEvent(localEvent);
 
   if (IsAsyncPanZoomEnabled()) {
     nsCOMPtr<nsPIDOMWindow> outerWindow = do_GetInterface(mWebNav);
     nsCOMPtr<nsPIDOMWindow> innerWindow = outerWindow->GetCurrentInnerWindow();
 
     if (innerWindow && innerWindow->HasTouchEventListeners()) {
       SendContentReceivedTouch(nsIPresShell::gPreventMouseEvents);
@@ -1848,17 +1848,17 @@ TabChild::RecvRealTouchEvent(const nsTou
   } else {
     UpdateTapState(aEvent, status);
   }
 
   return true;
 }
 
 bool
-TabChild::RecvRealTouchMoveEvent(const nsTouchEvent& aEvent)
+TabChild::RecvRealTouchMoveEvent(const WidgetTouchEvent& aEvent)
 {
   return RecvRealTouchEvent(aEvent);
 }
 
 bool
 TabChild::RecvRealKeyEvent(const nsKeyEvent& event)
 {
   nsKeyEvent localEvent(event);
--- a/dom/ipc/TabChild.h
+++ b/dom/ipc/TabChild.h
@@ -213,18 +213,18 @@ public:
                                 const float&    aY,
                                 const int32_t&  aButton,
                                 const int32_t&  aClickCount,
                                 const int32_t&  aModifiers,
                                 const bool&     aIgnoreRootScrollFrame);
     virtual bool RecvRealMouseEvent(const nsMouseEvent& event);
     virtual bool RecvRealKeyEvent(const nsKeyEvent& event);
     virtual bool RecvMouseWheelEvent(const mozilla::WheelEvent& event);
-    virtual bool RecvRealTouchEvent(const nsTouchEvent& event);
-    virtual bool RecvRealTouchMoveEvent(const nsTouchEvent& event);
+    virtual bool RecvRealTouchEvent(const WidgetTouchEvent& event);
+    virtual bool RecvRealTouchMoveEvent(const WidgetTouchEvent& event);
     virtual bool RecvKeyEvent(const nsString& aType,
                               const int32_t&  aKeyCode,
                               const int32_t&  aCharCode,
                               const int32_t&  aModifiers,
                               const bool&     aPreventDefault);
     virtual bool RecvCompositionEvent(const nsCompositionEvent& event);
     virtual bool RecvTextEvent(const nsTextEvent& event);
     virtual bool RecvSelectionEvent(const nsSelectionEvent& event);
@@ -437,17 +437,17 @@ private:
     // These methods are used for tracking synthetic mouse events
     // dispatched for compatibility.  On each touch event, we
     // UpdateTapState().  If we've detected that the current gesture
     // isn't a tap, then we CancelTapTracking().  In the meantime, we
     // may detect a context-menu event, and if so we
     // FireContextMenuEvent().
     void FireContextMenuEvent();
     void CancelTapTracking();
-    void UpdateTapState(const nsTouchEvent& aEvent, nsEventStatus aStatus);
+    void UpdateTapState(const WidgetTouchEvent& aEvent, nsEventStatus aStatus);
 
     nsresult
     BrowserFrameProvideWindow(nsIDOMWindow* aOpener,
                               nsIURI* aURI,
                               const nsAString& aName,
                               const nsACString& aFeatures,
                               bool* aWindowIsNew,
                               nsIDOMWindow** aReturn);
--- a/dom/ipc/TabParent.cpp
+++ b/dom/ipc/TabParent.cpp
@@ -616,17 +616,17 @@ TabParent::MapEventCoordinatesForChildPr
 void
 TabParent::MapEventCoordinatesForChildProcess(
   const LayoutDeviceIntPoint& aOffset, nsEvent* aEvent)
 {
   if (aEvent->eventStructType != NS_TOUCH_EVENT) {
     aEvent->refPoint = aOffset;
   } else {
     aEvent->refPoint = LayoutDeviceIntPoint();
-    nsTouchEvent* touchEvent = static_cast<nsTouchEvent*>(aEvent);
+    WidgetTouchEvent* touchEvent = static_cast<WidgetTouchEvent*>(aEvent);
     // Then offset all the touch points by that distance, to put them
     // in the space where top-left is 0,0.
     const nsTArray< nsRefPtr<Touch> >& touches = touchEvent->touches;
     for (uint32_t i = 0; i < touches.Length(); ++i) {
       Touch* touch = touches[i];
       if (touch) {
         touch->mRefPoint += LayoutDeviceIntPoint::ToUntyped(aOffset);
       }
@@ -668,17 +668,17 @@ bool TabParent::SendRealKeyEvent(nsKeyEv
   nsKeyEvent e(event);
   MaybeForwardEventToRenderFrame(event, &e);
   if (!MapEventCoordinatesForChildProcess(&e)) {
     return false;
   }
   return PBrowserParent::SendRealKeyEvent(e);
 }
 
-bool TabParent::SendRealTouchEvent(nsTouchEvent& event)
+bool TabParent::SendRealTouchEvent(WidgetTouchEvent& event)
 {
   if (mIsDestroyed) {
     return false;
   }
   if (event.message == NS_TOUCH_START) {
     // Adjust the widget coordinates to be relative to our frame.
     nsRefPtr<nsFrameLoader> frameLoader = GetFrameLoader();
     if (!frameLoader) {
@@ -694,17 +694,17 @@ bool TabParent::SendRealTouchEvent(nsTou
     MOZ_ASSERT((!sEventCapturer && mEventCaptureDepth == 0) ||
                (sEventCapturer == this && mEventCaptureDepth > 0));
     // We want to capture all remaining touch events in this series
     // for fast-path dispatch.
     sEventCapturer = this;
     ++mEventCaptureDepth;
   }
 
-  nsTouchEvent e(event);
+  WidgetTouchEvent e(event);
   // PresShell::HandleEventInternal adds touches on touch end/cancel.
   // This confuses remote content into thinking that the added touches
   // are part of the touchend/cancel, when actually they're not.
   if (event.message == NS_TOUCH_END || event.message == NS_TOUCH_CANCEL) {
     for (int i = e.touches.Length() - 1; i >= 0; i--) {
       if (!e.touches[i]->mChanged) {
         e.touches.RemoveElementAt(i);
       }
@@ -731,17 +731,17 @@ TabParent::TryCapture(const nsGUIEvent& 
 {
   MOZ_ASSERT(sEventCapturer == this && mEventCaptureDepth > 0);
 
   if (aEvent.eventStructType != NS_TOUCH_EVENT) {
     // Only capture of touch events is implemented, for now.
     return false;
   }
 
-  nsTouchEvent event(static_cast<const nsTouchEvent&>(aEvent));
+  WidgetTouchEvent event(static_cast<const WidgetTouchEvent&>(aEvent));
 
   bool isTouchPointUp = (event.message == NS_TOUCH_END ||
                          event.message == NS_TOUCH_CANCEL);
   if (event.message == NS_TOUCH_START || isTouchPointUp) {
     // Let the DOM see touch start/end events so that its touch-point
     // state stays consistent.
     if (isTouchPointUp && 0 == --mEventCaptureDepth) {
       // All event series are un-captured, don't try to catch any
--- a/dom/ipc/TabParent.h
+++ b/dom/ipc/TabParent.h
@@ -191,17 +191,17 @@ public:
                         int32_t aButton, int32_t aClickCount,
                         int32_t aModifiers, bool aIgnoreRootScrollFrame);
     void SendKeyEvent(const nsAString& aType, int32_t aKeyCode,
                       int32_t aCharCode, int32_t aModifiers,
                       bool aPreventDefault);
     bool SendRealMouseEvent(nsMouseEvent& event);
     bool SendMouseWheelEvent(mozilla::WheelEvent& event);
     bool SendRealKeyEvent(nsKeyEvent& event);
-    bool SendRealTouchEvent(nsTouchEvent& event);
+    bool SendRealTouchEvent(WidgetTouchEvent& event);
 
     virtual PDocumentRendererParent*
     AllocPDocumentRendererParent(const nsRect& documentRect, const gfxMatrix& transform,
                                  const nsString& bgcolor,
                                  const uint32_t& renderFlags, const bool& flushLayout,
                                  const nsIntSize& renderSize);
     virtual bool DeallocPDocumentRendererParent(PDocumentRendererParent* actor);
 
--- a/gfx/layers/composite/APZCTreeManager.cpp
+++ b/gfx/layers/composite/APZCTreeManager.cpp
@@ -292,17 +292,18 @@ APZCTreeManager::ReceiveInputEvent(const
       }
       break;
     }
   }
   return result;
 }
 
 AsyncPanZoomController*
-APZCTreeManager::GetTouchInputBlockAPZC(const nsTouchEvent& aEvent, ScreenPoint aPoint)
+APZCTreeManager::GetTouchInputBlockAPZC(const WidgetTouchEvent& aEvent,
+                                        ScreenPoint aPoint)
 {
   nsRefPtr<AsyncPanZoomController> apzc = GetTargetAPZC(aPoint);
   gfx3DMatrix transformToApzc, transformToScreen;
   // Reset the cached apz transform
   mCachedTransformToApzcForInputBlock = transformToApzc;
   if (!apzc) {
     return nullptr;
   }
@@ -320,18 +321,18 @@ APZCTreeManager::GetTouchInputBlockAPZC(
   if (apzc) {
     // Cache apz transform so it can be used for future events in this block.
     GetInputTransforms(apzc, mCachedTransformToApzcForInputBlock, transformToScreen);
   }
   return apzc.get();
 }
 
 nsEventStatus
-APZCTreeManager::ProcessTouchEvent(const nsTouchEvent& aEvent,
-                                   nsTouchEvent* aOutEvent)
+APZCTreeManager::ProcessTouchEvent(const WidgetTouchEvent& aEvent,
+                                   WidgetTouchEvent* aOutEvent)
 {
   // For computing the input for the APZC, used the cached transform.
   // This ensures that the sequence of touch points an APZC sees in an
   // input block are all in the same coordinate space.
   gfx3DMatrix transformToApzc = mCachedTransformToApzcForInputBlock;
   MultiTouchInput inputForApzc(aEvent);
   for (size_t i = 0; i < inputForApzc.mTouches.Length(); i++) {
     ApplyTransform(&(inputForApzc.mTouches[i].mScreenPoint), transformToApzc);
@@ -339,17 +340,17 @@ APZCTreeManager::ProcessTouchEvent(const
   nsEventStatus ret = mApzcForInputBlock->ReceiveInputEvent(inputForApzc);
 
   // For computing the event to pass back to Gecko, use the up-to-date transforms.
   // This ensures that transformToApzc and transformToScreen are in sync
   // (note that transformToScreen isn't cached).
   gfx3DMatrix transformToScreen;
   GetInputTransforms(mApzcForInputBlock, transformToApzc, transformToScreen);
   gfx3DMatrix outTransform = transformToApzc * transformToScreen;
-  nsTouchEvent* outEvent = static_cast<nsTouchEvent*>(aOutEvent);
+  WidgetTouchEvent* outEvent = static_cast<WidgetTouchEvent*>(aOutEvent);
   for (size_t i = 0; i < outEvent->touches.Length(); i++) {
     ApplyTransform(&(outEvent->touches[i]->mRefPoint), outTransform);
   }
 
   // If we have an mApzcForInputBlock and it's the end of the touch sequence
   // then null it out so we don't keep a dangling reference and leak things.
   if (aEvent.message == NS_TOUCH_CANCEL ||
       (aEvent.message == NS_TOUCH_END && aEvent.touches.Length() == 1)) {
@@ -397,28 +398,29 @@ APZCTreeManager::ProcessEvent(const nsIn
 nsEventStatus
 APZCTreeManager::ReceiveInputEvent(const nsInputEvent& aEvent,
                                    nsInputEvent* aOutEvent)
 {
   MOZ_ASSERT(NS_IsMainThread());
 
   switch (aEvent.eventStructType) {
     case NS_TOUCH_EVENT: {
-      const nsTouchEvent& touchEvent = static_cast<const nsTouchEvent&>(aEvent);
+      const WidgetTouchEvent& touchEvent =
+        static_cast<const WidgetTouchEvent&>(aEvent);
       if (!touchEvent.touches.Length()) {
         return nsEventStatus_eIgnore;
       }
       if (touchEvent.message == NS_TOUCH_START) {
         ScreenPoint point = ScreenPoint(touchEvent.touches[0]->mRefPoint.x, touchEvent.touches[0]->mRefPoint.y);
         mApzcForInputBlock = GetTouchInputBlockAPZC(touchEvent, point);
       }
       if (!mApzcForInputBlock) {
         return nsEventStatus_eIgnore;
       }
-      nsTouchEvent* outEvent = static_cast<nsTouchEvent*>(aOutEvent);
+      WidgetTouchEvent* outEvent = static_cast<WidgetTouchEvent*>(aOutEvent);
       return ProcessTouchEvent(touchEvent, outEvent);
     }
     case NS_MOUSE_EVENT: {
       // For b2g emulation
       const nsMouseEvent& mouseEvent = static_cast<const nsMouseEvent&>(aEvent);
       nsMouseEvent* outEvent = static_cast<nsMouseEvent*>(aOutEvent);
       return ProcessMouseEvent(mouseEvent, outEvent);
     }
@@ -430,17 +432,17 @@ APZCTreeManager::ReceiveInputEvent(const
 
 nsEventStatus
 APZCTreeManager::ReceiveInputEvent(nsInputEvent& aEvent)
 {
   MOZ_ASSERT(NS_IsMainThread());
 
   switch (aEvent.eventStructType) {
     case NS_TOUCH_EVENT: {
-      nsTouchEvent& touchEvent = static_cast<nsTouchEvent&>(aEvent);
+      WidgetTouchEvent& touchEvent = static_cast<WidgetTouchEvent&>(aEvent);
       if (!touchEvent.touches.Length()) {
         return nsEventStatus_eIgnore;
       }
       if (touchEvent.message == NS_TOUCH_START) {
         ScreenPoint point = ScreenPoint(touchEvent.touches[0]->mRefPoint.x, touchEvent.touches[0]->mRefPoint.y);
         mApzcForInputBlock = GetTouchInputBlockAPZC(touchEvent, point);
       }
       if (!mApzcForInputBlock) {
--- a/gfx/layers/composite/APZCTreeManager.h
+++ b/gfx/layers/composite/APZCTreeManager.h
@@ -143,17 +143,17 @@ public:
    * based on what type of input it is. For example, a PinchGestureEvent will
    * cause scaling. This should only be called externally to this class.
    */
   nsEventStatus ReceiveInputEvent(const InputData& aEvent);
 
   /**
    * nsInputEvent handler. Sets |aOutEvent| (which is assumed to be an
    * already-existing instance of an nsInputEvent which may be an
-   * nsTouchEvent) to have its coordinates in DOM space. This is so that the
+   * WidgetTouchEvent) to have its coordinates in DOM space. This is so that the
    * event can be passed through the DOM and content can handle them.
    *
    * NOTE: Be careful of invoking the nsInputEvent variant. This can only be
    * called on the main thread. See widget/InputData.h for more information on
    * why we have InputData and nsInputEvent separated.
    * NOTE: On unix, mouse events are treated as touch and are forwarded
    * to the appropriate apz as such.
    *
@@ -295,18 +295,18 @@ public:
   void GetInputTransforms(AsyncPanZoomController *aApzc, gfx3DMatrix& aTransformToApzcOut,
                           gfx3DMatrix& aTransformToScreenOut);
 private:
   /* Helpers */
   AsyncPanZoomController* FindTargetAPZC(AsyncPanZoomController* aApzc, const ScrollableLayerGuid& aGuid);
   AsyncPanZoomController* GetAPZCAtPoint(AsyncPanZoomController* aApzc, const gfxPoint& aHitTestPoint);
   AsyncPanZoomController* CommonAncestor(AsyncPanZoomController* aApzc1, AsyncPanZoomController* aApzc2);
   AsyncPanZoomController* RootAPZCForLayersId(AsyncPanZoomController* aApzc);
-  AsyncPanZoomController* GetTouchInputBlockAPZC(const nsTouchEvent& aEvent, ScreenPoint aPoint);
-  nsEventStatus ProcessTouchEvent(const nsTouchEvent& touchEvent, nsTouchEvent* aOutEvent);
+  AsyncPanZoomController* GetTouchInputBlockAPZC(const WidgetTouchEvent& aEvent, ScreenPoint aPoint);
+  nsEventStatus ProcessTouchEvent(const WidgetTouchEvent& touchEvent, WidgetTouchEvent* aOutEvent);
   nsEventStatus ProcessMouseEvent(const nsMouseEvent& mouseEvent, nsMouseEvent* aOutEvent);
   nsEventStatus ProcessEvent(const nsInputEvent& inputEvent, nsInputEvent* aOutEvent);
 
   /**
    * Recursive helper function to build the APZC tree. The tree of APZC instances has
    * the same shape as the layer tree, but excludes all the layers that are not scrollable.
    * Note that this means APZCs corresponding to layers at different depths in the tree
    * may end up becoming siblings. It also means that the "root" APZC may have siblings.
--- a/layout/base/nsPresShell.cpp
+++ b/layout/base/nsPresShell.cpp
@@ -5955,17 +5955,17 @@ EvictTouchPoint(nsRefPtr<dom::Touch>& aT
   }
   nsPoint pt(aTouch->mRefPoint.x, aTouch->mRefPoint.y);
   widget = frame->GetView()->GetNearestWidget(&pt);
 
   if (!widget) {
     return;
   }
   
-  nsTouchEvent event(true, NS_TOUCH_END, widget);
+  WidgetTouchEvent event(true, NS_TOUCH_END, widget);
   event.widget = widget;
   event.time = PR_IntervalNow();
   event.touches.AppendElement(aTouch);
 
   nsEventStatus status;
   widget->DispatchEvent(&event, status);
 }
 
@@ -6197,17 +6197,17 @@ PresShell::HandleEvent(nsIFrame        *
     // be used instead below. Also keep using the root frame if we're dealing
     // with a window-level mouse exit event since we want to start sending
     // mouse out events at the root EventStateManager.
     if (!captureRetarget && !isWindowLevelMouseExit) {
       nsPoint eventPoint;
       uint32_t flags = 0;
       if (aEvent->message == NS_TOUCH_START) {
         flags |= INPUT_IGNORE_ROOT_SCROLL_FRAME;
-        nsTouchEvent* touchEvent = static_cast<nsTouchEvent*>(aEvent);
+        WidgetTouchEvent* touchEvent = static_cast<WidgetTouchEvent*>(aEvent);
         // if this is a continuing session, ensure that all these events are
         // in the same document by taking the target of the events already in
         // the capture list
         nsCOMPtr<nsIContent> anyTarget;
         if (gCaptureTouchList->Count() > 0) {
           gCaptureTouchList->Enumerate(&FindAnyTarget, &anyTarget);
         } else {
           gPreventMouseEvents = false;
@@ -6329,17 +6329,17 @@ PresShell::HandleEvent(nsIFrame        *
 
     PresShell* shell =
         static_cast<PresShell*>(frame->PresContext()->PresShell());
     switch (aEvent->message) {
       case NS_TOUCH_MOVE:
       case NS_TOUCH_CANCEL:
       case NS_TOUCH_END: {
         // get the correct shell to dispatch to
-        nsTouchEvent* touchEvent = static_cast<nsTouchEvent*>(aEvent);
+        WidgetTouchEvent* touchEvent = static_cast<WidgetTouchEvent*>(aEvent);
         nsTArray< nsRefPtr<dom::Touch> >& touches = touchEvent->touches;
         for (uint32_t i = 0; i < touches.Length(); ++i) {
           dom::Touch* touch = touches[i];
           if (!touch) {
             break;
           }
   
           nsRefPtr<dom::Touch> oldTouch =
@@ -6718,17 +6718,17 @@ PresShell::HandleEventInternal(nsEvent* 
         // Else not full-screen mode or key code is unrestricted, fall
         // through to normal handling.
       }
       case NS_MOUSE_BUTTON_DOWN:
       case NS_MOUSE_BUTTON_UP:
         isHandlingUserInput = true;
         break;
       case NS_TOUCH_START: {
-        nsTouchEvent* touchEvent = static_cast<nsTouchEvent*>(aEvent);
+        WidgetTouchEvent* touchEvent = static_cast<WidgetTouchEvent*>(aEvent);
         // if there is only one touch in this touchstart event, assume that it is
         // the start of a new touch session and evict any old touches in the
         // queue
         if (touchEvent->touches.Length() == 1) {
           nsTArray< nsRefPtr<dom::Touch> > touches;
           gCaptureTouchList->Enumerate(&AppendToTouchList, (void *)&touches);
           for (uint32_t i = 0; i < touches.Length(); ++i) {
             EvictTouchPoint(touches[i]);
@@ -6746,17 +6746,17 @@ PresShell::HandleEventInternal(nsEvent* 
           gCaptureTouchList->Put(id, touch);
         }
         break;
       }
       case NS_TOUCH_CANCEL:
       case NS_TOUCH_END: {
         // Remove the changed touches
         // need to make sure we only remove touches that are ending here
-        nsTouchEvent* touchEvent = static_cast<nsTouchEvent*>(aEvent);
+        WidgetTouchEvent* touchEvent = static_cast<WidgetTouchEvent*>(aEvent);
         nsTArray< nsRefPtr<dom::Touch> >& touches = touchEvent->touches;
         for (uint32_t i = 0; i < touches.Length(); ++i) {
           dom::Touch* touch = touches[i];
           if (!touch) {
             continue;
           }
           touch->mMessage = aEvent->message;
           touch->mChanged = true;
@@ -6773,17 +6773,17 @@ PresShell::HandleEventInternal(nsEvent* 
           gCaptureTouchList->Remove(id);
         }
         // add any touches left in the touch list, but ensure changed=false
         gCaptureTouchList->Enumerate(&AppendToTouchList, (void *)&touches);
         break;
       }
       case NS_TOUCH_MOVE: {
         // Check for touches that changed. Mark them add to queue
-        nsTouchEvent* touchEvent = static_cast<nsTouchEvent*>(aEvent);
+        WidgetTouchEvent* touchEvent = static_cast<WidgetTouchEvent*>(aEvent);
         nsTArray< nsRefPtr<dom::Touch> >& touches = touchEvent->touches;
         bool haveChanged = false;
         for (int32_t i = touches.Length(); i; ) {
           --i;
           dom::Touch* touch = touches[i];
           if (!touch) {
             continue;
           }
@@ -6938,17 +6938,17 @@ PresShell::DispatchTouchEvent(nsEvent *a
                               bool aTouchIsNew)
 {
   // calling preventDefault on touchstart or the first touchmove for a
   // point prevents mouse events
   bool canPrevent = aEvent->message == NS_TOUCH_START ||
               (aEvent->message == NS_TOUCH_MOVE && aTouchIsNew);
   bool preventDefault = false;
   nsEventStatus tmpStatus = nsEventStatus_eIgnore;
-  nsTouchEvent* touchEvent = static_cast<nsTouchEvent*>(aEvent);
+  WidgetTouchEvent* touchEvent = static_cast<WidgetTouchEvent*>(aEvent);
 
   // loop over all touches and dispatch events on any that have changed
   for (uint32_t i = 0; i < touchEvent->touches.Length(); ++i) {
     dom::Touch* touch = touchEvent->touches[i];
     if (!touch || !touch->mChanged) {
       continue;
     }
 
@@ -6963,17 +6963,17 @@ PresShell::DispatchTouchEvent(nsEvent *a
     if (capturingContent) {
       if (capturingContent->OwnerDoc() != doc) {
         // Wrong document, don't dispatch anything.
         continue;
       }
       content = capturingContent;
     }
     // copy the event
-    nsTouchEvent newEvent(touchEvent->mFlags.mIsTrusted, touchEvent);
+    WidgetTouchEvent newEvent(touchEvent->mFlags.mIsTrusted, touchEvent);
     newEvent.target = targetPtr;
 
     nsRefPtr<PresShell> contentPresShell;
     if (doc == mDocument) {
       contentPresShell = static_cast<PresShell*>(doc->GetShell());
       if (contentPresShell) {
         //XXXsmaug huge hack. Pushing possibly capturing content,
         //         even though event target is something else.
--- a/layout/forms/nsRangeFrame.cpp
+++ b/layout/forms/nsRangeFrame.cpp
@@ -472,20 +472,20 @@ nsRangeFrame::GetValueAtEventPoint(nsGUI
              "type=range should have a default maximum/minimum");
   if (maximum <= minimum) {
     return minimum;
   }
   Decimal range = maximum - minimum;
 
   LayoutDeviceIntPoint absPoint;
   if (aEvent->eventStructType == NS_TOUCH_EVENT) {
-    MOZ_ASSERT(static_cast<nsTouchEvent*>(aEvent)->touches.Length() == 1,
+    MOZ_ASSERT(static_cast<WidgetTouchEvent*>(aEvent)->touches.Length() == 1,
                "Unexpected number of touches");
     absPoint = LayoutDeviceIntPoint::FromUntyped(
-      static_cast<nsTouchEvent*>(aEvent)->touches[0]->mRefPoint);
+      static_cast<WidgetTouchEvent*>(aEvent)->touches[0]->mRefPoint);
   } else {
     absPoint = aEvent->refPoint;
   }
   nsPoint point =
     nsLayoutUtils::GetEventCoordinatesRelativeTo(aEvent, 
       LayoutDeviceIntPoint::ToUntyped(absPoint), this);
 
   if (point == nsPoint(NS_UNCONSTRAINEDSIZE, NS_UNCONSTRAINEDSIZE)) {
--- a/layout/xul/base/src/nsBoxFrame.cpp
+++ b/layout/xul/base/src/nsBoxFrame.cpp
@@ -2075,17 +2075,17 @@ nsBoxFrame::GetEventPoint(nsGUIEvent* aE
   return res;
 }
 
 bool
 nsBoxFrame::GetEventPoint(nsGUIEvent* aEvent, nsIntPoint &aPoint) {
   NS_ENSURE_TRUE(aEvent, false);
 
   if (aEvent->eventStructType == NS_TOUCH_EVENT) {
-    nsTouchEvent* touchEvent = static_cast<nsTouchEvent*>(aEvent);
+    WidgetTouchEvent* touchEvent = static_cast<WidgetTouchEvent*>(aEvent);
     // return false if there is more than one touch on the page, or if
     // we can't find a touch point
     if (touchEvent->touches.Length() != 1) {
       return false;
     }
 
     dom::Touch* touch = touchEvent->touches.SafeElementAt(0);
     if (!touch) {
--- a/widget/EventForwards.h
+++ b/widget/EventForwards.h
@@ -122,11 +122,10 @@ typedef mozilla::WidgetDragEvent        
 typedef mozilla::WidgetMouseScrollEvent    nsMouseScrollEvent;
 
 namespace mozilla {
 typedef WidgetWheelEvent                   WheelEvent;
 }
 
 typedef mozilla::WidgetGestureNotifyEvent  nsGestureNotifyEvent;
 typedef mozilla::WidgetSimpleGestureEvent  nsSimpleGestureEvent;
-typedef mozilla::WidgetTouchEvent          nsTouchEvent;
 
 #endif // mozilla_EventForwards_h__
--- a/widget/InputData.h
+++ b/widget/InputData.h
@@ -120,21 +120,22 @@ public:
 
   float mRotationAngle;
 
   // How hard the screen is being pressed.
   float mForce;
 };
 
 /**
- * Similar to nsTouchEvent, but for use off-main-thread. Also only stores a
- * screen touch point instead of the many different coordinate spaces nsTouchEvent
- * stores its touch point in. This includes a way to initialize itself from an
- * nsTouchEvent by copying all relevant data over. Note that this copying from
- * nsTouchEvent functionality can only be used on the main thread.
+ * Similar to WidgetTouchEvent, but for use off-main-thread. Also only stores a
+ * screen touch point instead of the many different coordinate spaces
+ * WidgetTouchEvent stores its touch point in. This includes a way to initialize
+ * itself from a WidgetTouchEvent by copying all relevant data over. Note that
+ * this copying from WidgetTouchEvent functionality can only be used on the main
+ * thread.
  *
  * Stores an array of SingleTouchData.
  */
 class MultiTouchInput : public InputData
 {
 public:
   enum MultiTouchType
   {
@@ -153,17 +154,17 @@ public:
 
 
   }
 
   MultiTouchInput()
   {
   }
 
-  MultiTouchInput(const nsTouchEvent& aTouchEvent);
+  MultiTouchInput(const WidgetTouchEvent& aTouchEvent);
 
   // This conversion from nsMouseEvent to MultiTouchInput is needed because on
   // the B2G emulator we can only receive mouse events, but we need to be able
   // to pan correctly. To do this, we convert the events into a format that the
   // panning code can handle. This code is very limited and only supports
   // SingleTouchData. It also sends garbage for the identifier, radius, force
   // and rotation angle.
   MultiTouchInput(const nsMouseEvent& aMouseEvent);
--- a/widget/TouchEvents.h
+++ b/widget/TouchEvents.h
@@ -136,24 +136,23 @@ public:
 
   ~WidgetTouchEvent()
   {
     MOZ_COUNT_DTOR(WidgetTouchEvent);
   }
 
   nsTArray<nsRefPtr<mozilla::dom::Touch>> touches;
 
-  void AssignTouchEventData(const nsTouchEvent& aEvent, bool aCopyTargets)
+  void AssignTouchEventData(const WidgetTouchEvent& aEvent, bool aCopyTargets)
   {
     AssignInputEventData(aEvent, aCopyTargets);
 
     // Currently, we don't need to copy touches.
   }
 };
 
 } // namespace mozilla
 
 // TODO: Remove following typedefs
 typedef mozilla::WidgetGestureNotifyEvent nsGestureNotifyEvent;
 typedef mozilla::WidgetSimpleGestureEvent nsSimpleGestureEvent;
-typedef mozilla::WidgetTouchEvent         nsTouchEvent;
 
 #endif // mozilla_TouchEvents_h__
--- a/widget/android/AndroidJavaWrappers.cpp
+++ b/widget/android/AndroidJavaWrappers.cpp
@@ -699,17 +699,17 @@ AndroidGeckoEvent::Init(AndroidGeckoEven
     NS_ASSERTION(aResizeEvent->Type() == SIZE_CHANGED, "Init called on non-SIZE_CHANGED event");
 
     mType = FORCED_RESIZE;
     mAckNeeded = false;
     mTime = aResizeEvent->mTime;
     mPoints = aResizeEvent->mPoints; // x,y coordinates
 }
 
-nsTouchEvent
+WidgetTouchEvent
 AndroidGeckoEvent::MakeTouchEvent(nsIWidget* widget)
 {
     int type = NS_EVENT_NULL;
     int startIndex = 0;
     int endIndex = Count();
 
     switch (Action()) {
         case AndroidMotionEvent::ACTION_DOWN:
@@ -732,17 +732,17 @@ AndroidGeckoEvent::MakeTouchEvent(nsIWid
         }
         case AndroidMotionEvent::ACTION_OUTSIDE:
         case AndroidMotionEvent::ACTION_CANCEL: {
             type = NS_TOUCH_CANCEL;
             break;
         }
     }
 
-    nsTouchEvent event(true, type, widget);
+    WidgetTouchEvent event(true, type, widget);
     if (type == NS_EVENT_NULL) {
         // An event we don't know about
         return event;
     }
 
     event.modifiers = 0;
     event.time = Time();
     event.InitBasicModifiers(IsCtrlPressed(),
--- a/widget/android/AndroidJavaWrappers.h
+++ b/widget/android/AndroidJavaWrappers.h
@@ -583,17 +583,17 @@ public:
     bool CanBeMetered() { return mCanBeMetered; }
     bool IsWifi() { return mIsWifi; }
     int DHCPGateway() { return mDHCPGateway; }
     short ScreenOrientation() { return mScreenOrientation; }
     RefCountedJavaObject* ByteBuffer() { return mByteBuffer; }
     int Width() { return mWidth; }
     int Height() { return mHeight; }
     int RequestId() { return mCount; } // for convenience
-    nsTouchEvent MakeTouchEvent(nsIWidget* widget);
+    WidgetTouchEvent MakeTouchEvent(nsIWidget* widget);
     MultiTouchInput MakeMultiTouchInput(nsIWidget* widget);
     void UnionRect(nsIntRect const& aRect);
     nsIObserver *Observer() { return mObserver; }
 
 protected:
     int mAction;
     int mType;
     bool mAckNeeded;
--- a/widget/android/nsWindow.cpp
+++ b/widget/android/nsWindow.cpp
@@ -1223,17 +1223,17 @@ bool nsWindow::OnMultitouchEvent(Android
     // once for a given sequence of touch events. It is reset on the start
     // of the next sequence.
     static bool sDefaultPreventedNotified = false;
     static bool sLastWasDownEvent = false;
 
     bool preventDefaultActions = false;
     bool isDownEvent = false;
 
-    nsTouchEvent event = ae->MakeTouchEvent(this);
+    WidgetTouchEvent event = ae->MakeTouchEvent(this);
     if (event.message != NS_EVENT_NULL) {
         nsEventStatus status;
         DispatchEvent(&event, status);
         // We check mMultipleActionsPrevented because that's what <input type=range>
         // sets when someone starts dragging the thumb. It doesn't set the status
         // because it doesn't want to prevent the code that gives the input focus
         // from running.
         preventDefaultActions = (status == nsEventStatus_eConsumeNoDefault ||
--- a/widget/gonk/nsAppShell.cpp
+++ b/widget/gonk/nsAppShell.cpp
@@ -153,17 +153,17 @@ sendMouseEvent(uint32_t msg, uint64_t ti
         event.clickCount = 1;
 
     event.mFlags.mNoCrossProcessBoundaryForwarding = !forwardToChildren;
 
     nsWindow::DispatchInputEvent(event);
 }
 
 static void
-addDOMTouch(UserInputData& data, nsTouchEvent& event, int i)
+addDOMTouch(UserInputData& data, WidgetTouchEvent& event, int i)
 {
     const ::Touch& touch = data.motion.touches[i];
     event.touches.AppendElement(
         new dom::Touch(touch.id,
                        nsIntPoint(touch.coords.getX(), touch.coords.getY()),
                        nsIntPoint(touch.coords.getAxisValue(AMOTION_EVENT_AXIS_SIZE),
                                   touch.coords.getAxisValue(AMOTION_EVENT_AXIS_SIZE)),
                        0,
@@ -189,17 +189,17 @@ sendTouchEvent(UserInputData& data, bool
         msg = NS_TOUCH_END;
         break;
     case AMOTION_EVENT_ACTION_OUTSIDE:
     case AMOTION_EVENT_ACTION_CANCEL:
         msg = NS_TOUCH_CANCEL;
         break;
     }
 
-    nsTouchEvent event(true, msg, NULL);
+    WidgetTouchEvent event(true, msg, NULL);
 
     event.time = data.timeMs;
 
     int32_t i;
     if (msg == NS_TOUCH_END) {
         i = data.action & AMOTION_EVENT_ACTION_POINTER_INDEX_MASK;
         i >>= AMOTION_EVENT_ACTION_POINTER_INDEX_SHIFT;
         addDOMTouch(data, event, i);
--- a/widget/nsGUIEventIPC.h
+++ b/widget/nsGUIEventIPC.h
@@ -196,19 +196,19 @@ struct ParamTraits<nsMouseEvent>
     aResult->reason = static_cast<nsMouseEvent::reasonType>(reason);
     aResult->context = static_cast<nsMouseEvent::contextType>(context);
     aResult->exit = static_cast<nsMouseEvent::exitType>(exit);
     return rv;
   }
 };
 
 template<>
-struct ParamTraits<nsTouchEvent>
+struct ParamTraits<mozilla::WidgetTouchEvent>
 {
-  typedef nsTouchEvent paramType;
+  typedef mozilla::WidgetTouchEvent paramType;
 
   static void Write(Message* aMsg, const paramType& aParam)
   {
     WriteParam(aMsg, static_cast<const nsInputEvent&>(aParam));
     // Sigh, Touch bites us again!  We want to be able to do
     //   WriteParam(aMsg, aParam.touches);
     const nsTArray< nsRefPtr<mozilla::dom::Touch> >& touches = aParam.touches;
     WriteParam(aMsg, touches.Length());
--- a/widget/windows/nsWindow.cpp
+++ b/widget/windows/nsWindow.cpp
@@ -6075,28 +6075,28 @@ void nsWindow::UserActivity()
 }
 
 bool nsWindow::OnTouch(WPARAM wParam, LPARAM lParam)
 {
   uint32_t cInputs = LOWORD(wParam);
   PTOUCHINPUT pInputs = new TOUCHINPUT[cInputs];
 
   if (mGesture.GetTouchInputInfo((HTOUCHINPUT)lParam, cInputs, pInputs)) {
-    nsTouchEvent* touchEventToSend = nullptr;
-    nsTouchEvent* touchEndEventToSend = nullptr;
+    WidgetTouchEvent* touchEventToSend = nullptr;
+    WidgetTouchEvent* touchEndEventToSend = nullptr;
     nsEventStatus status;
 
     // Walk across the touch point array processing each contact point
     for (uint32_t i = 0; i < cInputs; i++) {
       uint32_t msg;
 
       if (pInputs[i].dwFlags & (TOUCHEVENTF_DOWN | TOUCHEVENTF_MOVE)) {
         // Create a standard touch event to send
         if (!touchEventToSend) {
-          touchEventToSend = new nsTouchEvent(true, NS_TOUCH_MOVE, this);
+          touchEventToSend = new WidgetTouchEvent(true, NS_TOUCH_MOVE, this);
           touchEventToSend->time = ::GetMessageTime();
           ModifierKeyState modifierKeyState;
           modifierKeyState.InitInputEvent(*touchEventToSend);
         }
 
         // Pres shell expects this event to be a NS_TOUCH_START if new contact
         // points have been added since the last event sent.
         if (pInputs[i].dwFlags & TOUCHEVENTF_DOWN) {
@@ -6104,17 +6104,17 @@ bool nsWindow::OnTouch(WPARAM wParam, LP
         } else {
           msg = NS_TOUCH_MOVE;
         }
       } else if (pInputs[i].dwFlags & TOUCHEVENTF_UP) {
         // Pres shell expects removed contacts points to be delivered in a
         // separate NS_TOUCH_END event containing only the contact points
         // that were removed.
         if (!touchEndEventToSend) {
-          touchEndEventToSend = new nsTouchEvent(true, NS_TOUCH_END, this);
+          touchEndEventToSend = new WidgetTouchEvent(true, NS_TOUCH_END, this);
           touchEndEventToSend->time = ::GetMessageTime();
           ModifierKeyState modifierKeyState;
           modifierKeyState.InitInputEvent(*touchEndEventToSend);
         }
         msg = NS_TOUCH_END;
       } else {
         // Filter out spurious Windows events we don't understand, like palm
         // contact.
--- a/widget/windows/winrt/MetroInput.cpp
+++ b/widget/windows/winrt/MetroInput.cpp
@@ -393,17 +393,17 @@ MetroInput::OnPointerNonTouch(UI::Input:
       event->message = NS_MOUSE_BUTTON_UP;
       break;
   }
   InitGeckoMouseEventFromPointerPoint(event, aPoint);
   DispatchAsyncEventIgnoreStatus(event);
 }
 
 void
-MetroInput::InitTouchEventTouchList(nsTouchEvent* aEvent)
+MetroInput::InitTouchEventTouchList(WidgetTouchEvent* aEvent)
 {
   MOZ_ASSERT(aEvent);
   mTouches.Enumerate(&AppendToTouchList,
                       static_cast<void*>(&aEvent->touches));
 }
 
 // This event is raised when the user pushes the left mouse button, presses a
 // pen to the surface, or presses a touch screen.
@@ -434,18 +434,18 @@ MetroInput::OnPointerPressed(UI::Core::I
   // This is touch input.
   // Create the new touch point and add it to our event.
   uint32_t pointerId;
   currentPoint->get_PointerId(&pointerId);
   nsRefPtr<Touch> touch = CreateDOMTouch(currentPoint.Get());
   touch->mChanged = true;
   mTouches.Put(pointerId, touch);
 
-  nsTouchEvent* touchEvent =
-    new nsTouchEvent(true, NS_TOUCH_START, mWidget.Get());
+  WidgetTouchEvent* touchEvent =
+    new WidgetTouchEvent(true, NS_TOUCH_START, mWidget.Get());
 
   if (mTouches.Count() == 1) {
     // If this is the first touchstart of a touch session reset some
     // tracking flags and dispatch the event with a custom callback
     // so we can check preventDefault result.
     mTouchStartDefaultPrevented = false;
     mTouchMoveDefaultPrevented = false;
     mIsFirstTouchMove = true;
@@ -539,29 +539,29 @@ MetroInput::OnPointerMoved(UI::Core::ICo
     // The recognizer needs the intermediate data otherwise it acts flaky
     AddPointerMoveDataToRecognizer(aArgs);
     return S_OK;
   }
 
   // If we've accumulated a batch of pointer moves and we're now on a new batch
   // at a new position send the previous batch. (perf opt)
   if (!mIsFirstTouchMove && touch->mChanged) {
-    nsTouchEvent* touchEvent =
-      new nsTouchEvent(true, NS_TOUCH_MOVE, mWidget.Get());
+    WidgetTouchEvent* touchEvent =
+      new WidgetTouchEvent(true, NS_TOUCH_MOVE, mWidget.Get());
     InitTouchEventTouchList(touchEvent);
     DispatchAsyncTouchEventIgnoreStatus(touchEvent);
   }
 
   touch = CreateDOMTouch(currentPoint.Get());
   touch->mChanged = true;
   // replacing old touch point in mTouches map
   mTouches.Put(pointerId, touch);
 
-  nsTouchEvent* touchEvent =
-    new nsTouchEvent(true, NS_TOUCH_MOVE, mWidget.Get());
+  WidgetTouchEvent* touchEvent =
+    new WidgetTouchEvent(true, NS_TOUCH_MOVE, mWidget.Get());
 
   // If this is the first touch move of our session, we should check the result.
   // Note we may lose some touch move data here for the recognizer since we want
   // to wait until we have the result of the first touchmove dispatch. For gesture
   // based events this shouldn't break anything.
   if (mIsFirstTouchMove) {
     InitTouchEventTouchList(touchEvent);
     DispatchAsyncTouchEventWithCallback(touchEvent, &MetroInput::OnFirstPointerMoveCallback);
@@ -618,30 +618,30 @@ MetroInput::OnPointerReleased(UI::Core::
   // This is touch input.
   // Get the touch associated with this touch point.
   uint32_t pointerId;
   currentPoint->get_PointerId(&pointerId);
   nsRefPtr<Touch> touch = mTouches.Get(pointerId);
 
   // Purge any pending moves for this pointer
   if (touch->mChanged) {
-    nsTouchEvent* touchEvent =
-      new nsTouchEvent(true, NS_TOUCH_MOVE, mWidget.Get());
+    WidgetTouchEvent* touchEvent =
+      new WidgetTouchEvent(true, NS_TOUCH_MOVE, mWidget.Get());
     InitTouchEventTouchList(touchEvent);
     DispatchAsyncTouchEventIgnoreStatus(touchEvent);
   }
 
   // Remove this touch point from our map. Eventually all touch points are
   // removed for this session since we receive released events for every
   // point. 
   mTouches.Remove(pointerId);
 
   // touchend events only have a single touch; the touch that has been removed
-  nsTouchEvent* touchEvent =
-    new nsTouchEvent(true, NS_TOUCH_END, mWidget.Get());
+  WidgetTouchEvent* touchEvent =
+    new WidgetTouchEvent(true, NS_TOUCH_END, mWidget.Get());
   touchEvent->touches.AppendElement(CreateDOMTouch(currentPoint.Get()));
   DispatchAsyncTouchEventIgnoreStatus(touchEvent);
 
   // If content didn't cancel the first touchstart feed touchend data to the
   // recognizer.
   if (!mTouchStartDefaultPrevented && !mTouchMoveDefaultPrevented) {
     mGestureRecognizer->ProcessUpEvent(currentPoint.Get());
   }
@@ -1143,32 +1143,33 @@ MetroInput::DeliverNextQueuedEventIgnore
 {
   nsGUIEvent* event = static_cast<nsGUIEvent*>(mInputEventQueue.PopFront());
   MOZ_ASSERT(event);
   DispatchEventIgnoreStatus(event);
   delete event;
 }
 
 void
-MetroInput::DispatchAsyncTouchEventIgnoreStatus(nsTouchEvent* aEvent)
+MetroInput::DispatchAsyncTouchEventIgnoreStatus(WidgetTouchEvent* aEvent)
 {
   aEvent->time = ::GetMessageTime();
   mModifierKeyState.Update();
   mModifierKeyState.InitInputEvent(*aEvent);
   mInputEventQueue.Push(aEvent);
   nsCOMPtr<nsIRunnable> runnable =
     NS_NewRunnableMethod(this, &MetroInput::DeliverNextQueuedTouchEvent);
   NS_DispatchToCurrentThread(runnable);
 }
 
 nsEventStatus
 MetroInput::DeliverNextQueuedTouchEvent()
 {
   nsEventStatus status;
-  nsTouchEvent* event = static_cast<nsTouchEvent*>(mInputEventQueue.PopFront());
+  WidgetTouchEvent* event =
+    static_cast<WidgetTouchEvent*>(mInputEventQueue.PopFront());
   MOZ_ASSERT(event);
 
   AutoDeleteEvent wrap(event);
 
   /*
    * We go through states here and make different decisions in each:
    *
    * 1) delivering first touchpoint touchstart or its first touchmove
@@ -1207,17 +1208,17 @@ MetroInput::DeliverNextQueuedTouchEvent(
       mWidget->ApzReceiveInputEvent(event);
     }
     mWidget->DispatchEvent(event, status);
     return status;
   }
 
   // Forward event data to apz. If the apz consumes the event, don't forward to
   // content if this is not a cancelable event.
-  nsTouchEvent transformedEvent(*event);
+  WidgetTouchEvent transformedEvent(*event);
   status = mWidget->ApzReceiveInputEvent(event, &transformedEvent);
   if (!mCancelable && status == nsEventStatus_eConsumeNoDefault) {
     if (!mTouchCancelSent) {
       mTouchCancelSent = true;
       DispatchTouchCancel();
     }
     return status;
   }
@@ -1232,23 +1233,24 @@ void
 MetroInput::DispatchTouchCancel()
 {
   LogFunction();
   // From the spec: The touch point or points that were removed must be
   // included in the changedTouches attribute of the TouchEvent, and must
   // not be included in the touches and targetTouches attributes. 
   // (We are 'removing' all touch points that have been sent to content
   // thus far.)
-  nsTouchEvent touchEvent(true, NS_TOUCH_CANCEL, mWidget.Get());
+  WidgetTouchEvent touchEvent(true, NS_TOUCH_CANCEL, mWidget.Get());
   InitTouchEventTouchList(&touchEvent);
   mWidget->DispatchEvent(&touchEvent, sThrowawayStatus);
 }
 
 void
-MetroInput::DispatchAsyncTouchEventWithCallback(nsTouchEvent* aEvent, void (MetroInput::*Callback)())
+MetroInput::DispatchAsyncTouchEventWithCallback(WidgetTouchEvent* aEvent,
+                                                void (MetroInput::*Callback)())
 {
   aEvent->time = ::GetMessageTime();
   mModifierKeyState.Update();
   mModifierKeyState.InitInputEvent(*aEvent);
   mInputEventQueue.Push(aEvent);
   nsCOMPtr<nsIRunnable> runnable =
     NS_NewRunnableMethod(this, Callback);
   NS_DispatchToCurrentThread(runnable);
--- a/widget/windows/winrt/MetroInput.h
+++ b/widget/windows/winrt/MetroInput.h
@@ -218,17 +218,17 @@ private:
   // more gecko events than we would using the Win32 mechanism.  E.g.,
   // for 5 active touchpoints, we would be sending 5 times as many gecko
   // events.  This caused performance to visibly degrade on modestly-powered
   // machines.  In response, we no longer send touch events immediately
   // upon receiving PointerPressed or PointerMoved.  Instead, we store
   // 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.
-  void InitTouchEventTouchList(nsTouchEvent* aEvent);
+  void InitTouchEventTouchList(WidgetTouchEvent* aEvent);
   nsBaseHashtable<nsUint32HashKey,
                   nsRefPtr<mozilla::dom::Touch>,
                   nsRefPtr<mozilla::dom::Touch> > mTouches;
 
   // These registration tokens are set when we register ourselves to receive
   // events from our window.  We must hold on to them for the entire duration
   // that we want to receive these events.  When we are done, we must
   // unregister ourself with the window using these tokens.
@@ -259,18 +259,19 @@ private:
   // on the ui thread via a native event dispatch call get bounced through
   // the gecko thread event queue using runnables. Most events can be sent
   // async without the need to see the status result. Those that do have
   // specialty callbacks. Note any event that arrives to us on the ui thread
   // that originates from another thread is safe to send sync.
 
   // Async event dispatching
   void DispatchAsyncEventIgnoreStatus(nsInputEvent* aEvent);
-  void DispatchAsyncTouchEventIgnoreStatus(nsTouchEvent* aEvent);
-  void DispatchAsyncTouchEventWithCallback(nsTouchEvent* aEvent, void (MetroInput::*Callback)());
+  void DispatchAsyncTouchEventIgnoreStatus(WidgetTouchEvent* aEvent);
+  void DispatchAsyncTouchEventWithCallback(WidgetTouchEvent* aEvent,
+                                           void (MetroInput::*Callback)());
 
   // Async event callbacks
   void DeliverNextQueuedEventIgnoreStatus();
   nsEventStatus DeliverNextQueuedTouchEvent();
 
   // Misc. specialty async callbacks
   void OnPointerPressedCallback();
   void OnFirstPointerMoveCallback();
--- a/widget/xpwidgets/InputData.cpp
+++ b/widget/xpwidgets/InputData.cpp
@@ -10,21 +10,21 @@
 #include "nsThreadUtils.h"
 #include "mozilla/MouseEvents.h"
 #include "mozilla/TouchEvents.h"
 
 namespace mozilla {
 
 using namespace dom;
 
-MultiTouchInput::MultiTouchInput(const nsTouchEvent& aTouchEvent)
+MultiTouchInput::MultiTouchInput(const WidgetTouchEvent& aTouchEvent)
   : InputData(MULTITOUCH_INPUT, aTouchEvent.time)
 {
   NS_ABORT_IF_FALSE(NS_IsMainThread(),
-                    "Can only copy from nsTouchEvent on main thread");
+                    "Can only copy from WidgetTouchEvent on main thread");
 
   switch (aTouchEvent.message) {
     case NS_TOUCH_START:
       mType = MULTITOUCH_START;
       break;
     case NS_TOUCH_MOVE:
       mType = MULTITOUCH_MOVE;
       break;