Bug 898105 - Remove nsIDOMTouch r=reuben
☠☠ backed out by 74a36d1b2816 ☠ ☠
authorDavid Zbarsky <dzbarsky@gmail.com>
Mon, 29 Jul 2013 16:04:09 -0700
changeset 152743 40683014a638c15251147b094af445d86f484c06
parent 152742 f10e28d8278658c8d3fa14caa87427376dbb1403
child 152744 a0868fe02c2a6b597086aa33ddb9ff495404af74
push id2859
push userakeybl@mozilla.com
push dateMon, 16 Sep 2013 19:14:59 +0000
treeherdermozilla-beta@87d3c51cd2bf [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersreuben
bugs898105
milestone25.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 898105 - Remove nsIDOMTouch r=reuben
content/events/src/Touch.cpp
content/events/src/Touch.h
content/events/src/nsDOMTouchEvent.cpp
content/events/src/nsEventStateManager.cpp
dom/base/nsGlobalWindow.h
dom/interfaces/events/nsIDOMTouchEvent.idl
gfx/layers/ipc/AsyncPanZoomController.cpp
layout/base/nsPresShell.cpp
layout/xul/base/src/nsBoxFrame.cpp
widget/InputData.h
widget/xpwidgets/InputData.cpp
--- a/content/events/src/Touch.cpp
+++ b/content/events/src/Touch.cpp
@@ -20,119 +20,34 @@ Touch::PrefEnabled()
 {
   return nsDOMTouchEvent::PrefEnabled();
 }
 
 NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE_1(Touch, mTarget)
 
 NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(Touch)
   NS_WRAPPERCACHE_INTERFACE_MAP_ENTRY
-  NS_INTERFACE_MAP_ENTRY(nsIDOMTouch)
   NS_INTERFACE_MAP_ENTRY(nsISupports)
 NS_INTERFACE_MAP_END
 
 NS_IMPL_CYCLE_COLLECTING_ADDREF(Touch)
 NS_IMPL_CYCLE_COLLECTING_RELEASE(Touch)
 
-NS_IMETHODIMP
-Touch::GetIdentifier(int32_t* aIdentifier)
-{
-  *aIdentifier = Identifier();
-  return NS_OK;
-}
-
-NS_IMETHODIMP
-Touch::GetTarget(nsIDOMEventTarget** aTarget)
-{
-  NS_ADDREF(*aTarget = Target());
-  return NS_OK;
-}
-
 EventTarget*
 Touch::Target() const
 {
   nsCOMPtr<nsIContent> content = do_QueryInterface(mTarget);
   if (content && content->ChromeOnlyAccess() &&
       !nsContentUtils::CanAccessNativeAnon()) {
     return content->FindFirstNonChromeOnlyAccessContent();
   }
 
   return mTarget;
 }
 
-NS_IMETHODIMP
-Touch::GetScreenX(int32_t* aScreenX)
-{
-  *aScreenX = ScreenX();
-  return NS_OK;
-}
-
-NS_IMETHODIMP
-Touch::GetScreenY(int32_t* aScreenY)
-{
-  *aScreenY = ScreenY();
-  return NS_OK;
-}
-
-NS_IMETHODIMP
-Touch::GetClientX(int32_t* aClientX)
-{
-  *aClientX = ClientX();
-  return NS_OK;
-}
-
-NS_IMETHODIMP
-Touch::GetClientY(int32_t* aClientY)
-{
-  *aClientY = ClientY();
-  return NS_OK;
-}
-
-NS_IMETHODIMP
-Touch::GetPageX(int32_t* aPageX)
-{
-  *aPageX = PageX();
-  return NS_OK;
-}
-
-NS_IMETHODIMP
-Touch::GetPageY(int32_t* aPageY)
-{
-  *aPageY = PageY();
-  return NS_OK;
-}
-
-NS_IMETHODIMP
-Touch::GetRadiusX(int32_t* aRadiusX)
-{
-  *aRadiusX = RadiusX();
-  return NS_OK;
-}
-                                             
-NS_IMETHODIMP
-Touch::GetRadiusY(int32_t* aRadiusY)
-{
-  *aRadiusY = RadiusY();
-  return NS_OK;
-}
-
-NS_IMETHODIMP
-Touch::GetRotationAngle(float* aRotationAngle)
-{
-  *aRotationAngle = RotationAngle();
-  return NS_OK;
-}
-
-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,
@@ -142,29 +57,22 @@ Touch::InitializePoints(nsPresContext* a
                                          aEvent,
                                          mRefPoint,
                                          mClientPoint);
   mScreenPoint = nsDOMEvent::GetScreenCoords(aPresContext, aEvent, mRefPoint);
   mPointsInitialized = true;
 }
 
 bool
-Touch::Equals(nsIDOMTouch* aTouch)
+Touch::Equals(Touch* aTouch)
 {
-  float force;
-  float orientation;
-  int32_t radiusX, radiusY;
-  aTouch->GetForce(&force);
-  aTouch->GetRotationAngle(&orientation);
-  aTouch->GetRadiusX(&radiusX);
-  aTouch->GetRadiusY(&radiusY);
   return mRefPoint != aTouch->mRefPoint ||
-         (mForce != force) ||
-         (mRotationAngle != orientation) ||
-         (mRadius.x != radiusX) || (mRadius.y != radiusY);
+         (mForce != aTouch->Force()) ||
+         (mRotationAngle != aTouch->RotationAngle()) ||
+         (mRadius.x != aTouch->RadiusX()) || (mRadius.y != aTouch->RadiusY());
 }
 
 /* virtual */ JSObject*
 Touch::WrapObject(JSContext* aCx, JS::Handle<JSObject*> aScope)
 {
   return TouchBinding::Wrap(aCx, aScope, this);
 }
 
--- a/content/events/src/Touch.h
+++ b/content/events/src/Touch.h
@@ -1,29 +1,28 @@
 /* vim: set shiftwidth=2 tabstop=8 autoindent cindent expandtab: */
 /* 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/. */
 
 #ifndef mozilla_dom_Touch_h
 #define mozilla_dom_Touch_h
 
-#include "nsIDOMTouchEvent.h"
 #include "nsString.h"
 #include "nsTArray.h"
 #include "mozilla/Attributes.h"
 #include "nsJSEnvironment.h"
 #include "nsWrapperCache.h"
 #include "mozilla/dom/EventTarget.h"
 #include "Units.h"
 
 namespace mozilla {
 namespace dom {
 
-class Touch MOZ_FINAL : public nsIDOMTouch
+class Touch MOZ_FINAL : public nsISupports
                       , public nsWrapperCache
 {
 public:
   static bool PrefEnabled();
 
   Touch(mozilla::dom::EventTarget* aTarget,
         int32_t aIdentifier,
         int32_t aPageX,
@@ -72,25 +71,24 @@ public:
       mForce = aForce;
 
       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);
 
   void SetTarget(mozilla::dom::EventTarget *aTarget)
   {
     mTarget = aTarget;
   }
-  bool Equals(nsIDOMTouch* aTouch);
+  bool Equals(Touch* aTouch);
 
   virtual JSObject* WrapObject(JSContext* aCx,
                                JS::Handle<JSObject*> aScope) MOZ_OVERRIDE;
   EventTarget* GetParentObject() { return mTarget; }
 
   // WebIDL
   int32_t Identifier() const { return mIdentifier; }
   EventTarget* Target() const;
@@ -107,16 +105,22 @@ public:
 
   int32_t mIdentifier;
   CSSIntPoint mPagePoint;
   CSSIntPoint mClientPoint;
   nsIntPoint mScreenPoint;
   nsIntPoint mRadius;
   float mRotationAngle;
   float mForce;
+  nsCOMPtr<mozilla::dom::EventTarget> mTarget;
+  mozilla::dom::EventTarget *GetTarget() { return mTarget; }
+  nsIntPoint mRefPoint;
+  bool mChanged;
+  uint32_t mMessage;
+
 protected:
   bool mPointsInitialized;
 };
 
 } // namespace dom
 } // namespace mozilla
 
 #endif // mozilla_dom_Touch_h
--- a/content/events/src/nsDOMTouchEvent.cpp
+++ b/content/events/src/nsDOMTouchEvent.cpp
@@ -58,19 +58,17 @@ nsDOMTouchEvent::nsDOMTouchEvent(mozilla
                                  nsTouchEvent* aEvent)
   : nsDOMUIEvent(aOwner, aPresContext,
                  aEvent ? aEvent : new nsTouchEvent(false, 0, nullptr))
 {
   if (aEvent) {
     mEventIsInternal = false;
 
     for (uint32_t i = 0; i < aEvent->touches.Length(); ++i) {
-      nsIDOMTouch *touch = aEvent->touches[i];
-      dom::Touch *domtouch = static_cast<dom::Touch*>(touch);
-      domtouch->InitializePoints(mPresContext, aEvent);
+      aEvent->touches[i]->InitializePoints(mPresContext, aEvent);
     }
   } else {
     mEventIsInternal = true;
     mEvent->time = PR_Now();
   }
 }
 
 nsDOMTouchEvent::~nsDOMTouchEvent()
--- a/content/events/src/nsEventStateManager.cpp
+++ b/content/events/src/nsEventStateManager.cpp
@@ -1552,17 +1552,17 @@ nsEventStateManager::MapEventCoordinates
     aEvent->refPoint = aOffsetIntPoint;
   } else {
     aEvent->refPoint = nsIntPoint();
     nsTouchEvent* touchEvent = static_cast<nsTouchEvent*>(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) {
-      nsIDOMTouch* touch = touches[i];
+      Touch* touch = touches[i];
       if (touch) {
         touch->mRefPoint += aOffsetIntPoint;
       }
     }
   }
 }
 
 /*static*/ void
@@ -1636,17 +1636,17 @@ nsEventStateManager::HandleCrossProcessE
     // 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);
     const nsTArray< nsRefPtr<Touch> >& touches = touchEvent->touches;
     for (uint32_t i = 0; i < touches.Length(); ++i) {
-      nsIDOMTouch* touch = touches[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) {
         continue;
       }
       nsCOMPtr<EventTarget> targetPtr = touch->GetTarget();
--- a/dom/base/nsGlobalWindow.h
+++ b/dom/base/nsGlobalWindow.h
@@ -57,16 +57,17 @@
 #include "nsIInlineEventHandlers.h"
 #include "nsWrapperCacheInlines.h"
 #include "nsIIdleObserver.h"
 #include "nsIDOMWakeLock.h"
 #ifdef MOZ_GAMEPAD
 #include "mozilla/dom/Gamepad.h"
 #endif
 #include "nsIDocument.h"
+#include "nsIDOMTouchEvent.h"
 
 #include "mozilla/dom/EventTarget.h"
 #include "Units.h"
 
 // JS includes
 #include "jsapi.h"
 
 #ifdef MOZ_B2G
--- a/dom/interfaces/events/nsIDOMTouchEvent.idl
+++ b/dom/interfaces/events/nsIDOMTouchEvent.idl
@@ -1,47 +1,14 @@
 /* vim: set shiftwidth=2 tabstop=8 autoindent cindent expandtab: */
 /* 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 "nsIDOMUIEvent.idl"
-%{C++
-#include "nsWeakPtr.h"
-#include "nsPoint.h"
-%}
-interface nsIVariant;
-
-/**
- * @see http://dvcs.w3.org/hg/webevents/raw-file/tip/touchevents.html
- */
-
-[scriptable, builtinclass, uuid(98bc0f7d-5bff-4387-9c42-58af54b48dd5)]
-interface nsIDOMTouch : nsISupports {
-  readonly attribute long              identifier;
-  readonly attribute nsIDOMEventTarget target;
-  readonly attribute long              pageX;
-  readonly attribute long              pageY;
-  readonly attribute long              screenX;
-  readonly attribute long              screenY;
-  readonly attribute long              clientX;
-  readonly attribute long              clientY;
-  readonly attribute long              radiusX;
-  readonly attribute long              radiusY;
-  readonly attribute float             rotationAngle;
-  readonly attribute float             force;
-  %{C++
-    nsCOMPtr<mozilla::dom::EventTarget> mTarget;
-    mozilla::dom::EventTarget *GetTarget() { return mTarget; }
-    void SetTarget(mozilla::dom::EventTarget *target) { mTarget = target; }
-    nsIntPoint mRefPoint;
-    bool mChanged;
-    uint32_t mMessage;
-  %}
-};
 
 [scriptable, uuid(6d5484f7-92ac-45f8-9388-39b5bad055ce)]
 interface nsITouchEventReceiver : nsISupports {
   [implicit_jscontext] attribute jsval           ontouchstart;
   [implicit_jscontext] attribute jsval           ontouchend;
   [implicit_jscontext] attribute jsval           ontouchmove;
   [implicit_jscontext] attribute jsval           ontouchenter;
   [implicit_jscontext] attribute jsval           ontouchleave;
--- a/gfx/layers/ipc/AsyncPanZoomController.cpp
+++ b/gfx/layers/ipc/AsyncPanZoomController.cpp
@@ -265,17 +265,17 @@ AsyncPanZoomController::ReceiveInputEven
     break;
   }
 
   switch (aEvent.eventStructType) {
   case NS_TOUCH_EVENT: {
     nsTouchEvent* touchEvent = static_cast<nsTouchEvent*>(aOutEvent);
     const nsTArray< nsRefPtr<dom::Touch> >& touches = touchEvent->touches;
     for (uint32_t i = 0; i < touches.Length(); ++i) {
-      nsIDOMTouch* touch = touches[i];
+      dom::Touch* touch = touches[i];
       if (touch) {
         CSSPoint refCSSPoint = WidgetSpaceToCompensatedViewportSpace(
           ScreenPoint::FromUnknownPoint(gfx::Point(
             touch->mRefPoint.x, touch->mRefPoint.y)),
           currentResolution);
         LayoutDevicePoint refPoint = refCSSPoint * mFrameMetrics.mDevPixelsPerCSSPixel;
         touch->mRefPoint = nsIntPoint(refPoint.x, refPoint.y);
       }
--- a/layout/base/nsPresShell.cpp
+++ b/layout/base/nsPresShell.cpp
@@ -6881,17 +6881,17 @@ PresShell::DispatchTouchEvent(nsEvent *a
   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);
 
   // loop over all touches and dispatch events on any that have changed
   for (uint32_t i = 0; i < touchEvent->touches.Length(); ++i) {
-    nsIDOMTouch *touch = touchEvent->touches[i];
+    Touch *touch = touchEvent->touches[i];
     if (!touch || !touch->mChanged) {
       continue;
     }
 
     nsCOMPtr<EventTarget> targetPtr = touch->GetTarget();
     nsCOMPtr<nsIContent> content = do_QueryInterface(targetPtr);
     if (!content) {
       continue;
--- a/layout/xul/base/src/nsBoxFrame.cpp
+++ b/layout/xul/base/src/nsBoxFrame.cpp
@@ -2072,17 +2072,17 @@ nsBoxFrame::GetEventPoint(nsGUIEvent* aE
   if (aEvent->eventStructType == NS_TOUCH_EVENT) {
     nsTouchEvent* touchEvent = static_cast<nsTouchEvent*>(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;
     }
 
-    nsIDOMTouch *touch = touchEvent->touches.SafeElementAt(0);
+    Touch *touch = touchEvent->touches.SafeElementAt(0);
     if (!touch) {
       return false;
     }
     Touch* domtouch = static_cast<Touch*>(touch);
     aPoint = domtouch->mRefPoint;
   } else {
     aPoint = aEvent->refPoint;
   }
--- a/widget/InputData.h
+++ b/widget/InputData.h
@@ -65,21 +65,21 @@ protected:
 
 
   }
 };
 
 /**
  * Data container for a single touch input. Similar to dom::Touch, but used in
  * off-main-thread situations. This is more for just storing touch data, whereas
- * dom::Touch derives from nsIDOMTouch so it is more useful for dispatching
- * through the DOM (which can only happen on the main thread). dom::Touch also
- * bears the problem of storing pointers to nsIWidget instances which can only
- * be used on the main thread, so if instead we used dom::Touch and ever set
- * these pointers off-main-thread, Bad Things Can Happen(tm).
+ * dom::Touch is more useful for dispatching through the DOM (which can only
+ * happen on the main thread). dom::Touch also bears the problem of storing
+ * pointers to nsIWidget instances which can only be used on the main thread,
+ * so if instead we used dom::Touch and ever set these pointers
+ * off-main-thread, Bad Things Can Happen(tm).
  *
  * Note that this doesn't inherit from InputData because this itself is not an
  * event. It is only a container/struct that should have any number of instances
  * within a MultiTouchInput.
  *
  * fixme/bug 775746: Make dom::Touch inherit from this class.
  */
 class SingleTouchData
--- a/widget/xpwidgets/InputData.cpp
+++ b/widget/xpwidgets/InputData.cpp
@@ -42,32 +42,24 @@ MultiTouchInput::MultiTouchInput(const n
     default:
       NS_WARNING("Did not assign a type to a MultiTouchInput");
       break;
   }
 
   for (size_t i = 0; i < aTouchEvent.touches.Length(); i++) {
     Touch* domTouch = static_cast<Touch*>(aTouchEvent.touches[i].get());
 
-    // Extract data from weird interfaces.
-    int32_t identifier, radiusX, radiusY;
-    float rotationAngle, force;
-    domTouch->GetIdentifier(&identifier);
-    domTouch->GetRadiusX(&radiusX);
-    domTouch->GetRadiusY(&radiusY);
-    domTouch->GetRotationAngle(&rotationAngle);
-    domTouch->GetForce(&force);
-
-    SingleTouchData data(identifier,
+    SingleTouchData data(domTouch->Identifier(),
                          ScreenIntPoint::FromUnknownPoint(
                            gfx::IntPoint(domTouch->mRefPoint.x,
                                          domTouch->mRefPoint.y)),
-                         ScreenSize(radiusX, radiusY),
-                         rotationAngle,
-                         force);
+                         ScreenSize(domTouch->RadiusX(),
+                                    domTouch->RadiusY()),
+                         domTouch->RotationAngle(),
+                         domTouch->Force());
 
     mTouches.AppendElement(data);
   }
 }
 
 // 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