Backout 40683014a638 for causing mochitest orange
authorDavid Zbarsky <dzbarsky@gmail.com>
Mon, 29 Jul 2013 21:11:01 -0700
changeset 140837 74a36d1b28164719f9ad98dcacf503e9cebbf8f6
parent 140836 ef3ae04ebffff294f253936c21aba8e52d16658c
child 140838 9726efc4c4a837d64cd4187285b16fe0bfc750a4
push id270
push userpvanderbeken@mozilla.com
push dateThu, 06 Mar 2014 09:24:21 +0000
milestone25.0a1
backs out40683014a638c15251147b094af445d86f484c06
Backout 40683014a638 for causing mochitest orange
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,34 +20,119 @@ 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,
@@ -57,22 +142,29 @@ Touch::InitializePoints(nsPresContext* a
                                          aEvent,
                                          mRefPoint,
                                          mClientPoint);
   mScreenPoint = nsDOMEvent::GetScreenCoords(aPresContext, aEvent, mRefPoint);
   mPointsInitialized = true;
 }
 
 bool
-Touch::Equals(Touch* aTouch)
+Touch::Equals(nsIDOMTouch* 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 != aTouch->Force()) ||
-         (mRotationAngle != aTouch->RotationAngle()) ||
-         (mRadius.x != aTouch->RadiusX()) || (mRadius.y != aTouch->RadiusY());
+         (mForce != force) ||
+         (mRotationAngle != orientation) ||
+         (mRadius.x != radiusX) || (mRadius.y != 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,28 +1,29 @@
 /* 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 nsISupports
+class Touch MOZ_FINAL : public nsIDOMTouch
                       , public nsWrapperCache
 {
 public:
   static bool PrefEnabled();
 
   Touch(mozilla::dom::EventTarget* aTarget,
         int32_t aIdentifier,
         int32_t aPageX,
@@ -71,24 +72,25 @@ 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(Touch* aTouch);
+  bool Equals(nsIDOMTouch* 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;
@@ -105,22 +107,16 @@ 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,17 +58,19 @@ 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) {
-      aEvent->touches[i]->InitializePoints(mPresContext, aEvent);
+      nsIDOMTouch *touch = aEvent->touches[i];
+      dom::Touch *domtouch = static_cast<dom::Touch*>(touch);
+      domtouch->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) {
-      Touch* touch = touches[i];
+      nsIDOMTouch* 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) {
-      Touch* touch = touches[i];
+      nsIDOMTouch* 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,17 +57,16 @@
 #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,14 +1,47 @@
 /* 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) {
-      dom::Touch* touch = touches[i];
+      nsIDOMTouch* 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) {
-    Touch *touch = touchEvent->touches[i];
+    nsIDOMTouch *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;
     }
 
-    Touch *touch = touchEvent->touches.SafeElementAt(0);
+    nsIDOMTouch *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 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 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).
  *
  * 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,24 +42,32 @@ 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());
 
-    SingleTouchData data(domTouch->Identifier(),
+    // 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,
                          ScreenIntPoint::FromUnknownPoint(
                            gfx::IntPoint(domTouch->mRefPoint.x,
                                          domTouch->mRefPoint.y)),
-                         ScreenSize(domTouch->RadiusX(),
-                                    domTouch->RadiusY()),
-                         domTouch->RotationAngle(),
-                         domTouch->Force());
+                         ScreenSize(radiusX, radiusY),
+                         rotationAngle,
+                         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