Bug 722965 - Remove MOZ_TOUCH ifdefs. r=smaug
authorWes Johnston <wjohnston@mozilla.com>
Mon, 19 Mar 2012 14:34:34 -0700
changeset 91592 b7d5d46662bc7624d4be983c1cbb6dc49eec5019
parent 91591 c6f23448ec624a52e8caa798e4c966c74066130c
child 91593 0f6ef3a02450fc494a446fb2080558c5503879bf
push idunknown
push userunknown
push dateunknown
reviewerssmaug
bugs722965
milestone14.0a1
Bug 722965 - Remove MOZ_TOUCH ifdefs. r=smaug
config/autoconf.mk.in
configure.in
content/events/src/nsDOMMouseEvent.cpp
content/events/src/nsDOMUIEvent.cpp
layout/base/nsLayoutUtils.cpp
layout/base/nsPresShell.cpp
--- a/config/autoconf.mk.in
+++ b/config/autoconf.mk.in
@@ -149,17 +149,16 @@ MOZ_UPDATE_CHANNEL	= @MOZ_UPDATE_CHANNEL
 MOZ_UPDATE_PACKAGING	= @MOZ_UPDATE_PACKAGING@
 MOZ_DISABLE_PARENTAL_CONTROLS = @MOZ_DISABLE_PARENTAL_CONTROLS@
 NS_ENABLE_TSF = @NS_ENABLE_TSF@
 MOZ_SPELLCHECK = @MOZ_SPELLCHECK@
 MOZ_ANDROID_HISTORY = @MOZ_ANDROID_HISTORY@
 MOZ_WEBSMS_BACKEND = @MOZ_WEBSMS_BACKEND@
 MOZ_JAVA_COMPOSITOR = @MOZ_JAVA_COMPOSITOR@
 MOZ_ONLY_TOUCH_EVENTS = @MOZ_ONLY_TOUCH_EVENTS@
-MOZ_TOUCH = @MOZ_TOUCH@
 MOZ_PROFILELOCKING = @MOZ_PROFILELOCKING@
 MOZ_FEEDS = @MOZ_FEEDS@
 MOZ_TOOLKIT_SEARCH = @MOZ_TOOLKIT_SEARCH@
 MOZ_PLACES = @MOZ_PLACES@
 MOZ_SAFE_BROWSING = @MOZ_SAFE_BROWSING@
 MOZ_URL_CLASSIFIER = @MOZ_URL_CLASSIFIER@
 MOZ_ZIPWRITER = @MOZ_ZIPWRITER@
 MOZ_OGG = @MOZ_OGG@
--- a/configure.in
+++ b/configure.in
@@ -4846,27 +4846,25 @@ cairo-uikit)
     CXXFLAGS="$CXXFLAGS $TK_CFLAGS"
     LIBXUL_LIBS='$(XPCOM_FROZEN_LDOPTS) $(LIBXUL_DIST)/bin/XUL'
     MOZ_USER_DIR="Mozilla"
     MOZ_FS_LAYOUT=bundle
     ;;
 
 cairo-android)
     AC_DEFINE(MOZ_WIDGET_ANDROID)
-    AC_DEFINE(MOZ_TOUCH)
     MOZ_WIDGET_TOOLKIT=android
     TK_CFLAGS='$(MOZ_CAIRO_CFLAGS)'
     TK_LIBS='$(MOZ_CAIRO_LIBS)'
     MOZ_WEBGL=1
     MOZ_PDF_PRINTING=1
     MOZ_INSTRUMENT_EVENT_LOOP=1
     if test "$MOZ_BUILD_APP" = "mobile/xul"; then
         MOZ_OLD_LINKER=1
     fi
-    MOZ_TOUCH=1
     ;;
 
 cairo-gonk)
     AC_DEFINE(MOZ_WIDGET_GONK)
     AC_DEFINE(MOZ_TOUCH)
     MOZ_WIDGET_TOOLKIT=gonk
     TK_CFLAGS='$(MOZ_CAIRO_CFLAGS)'
     TK_LIBS='$(MOZ_CAIRO_LIBS)'
--- a/content/events/src/nsDOMMouseEvent.cpp
+++ b/content/events/src/nsDOMMouseEvent.cpp
@@ -231,67 +231,51 @@ nsDOMMouseEvent::GetRelatedTarget(nsIDOM
     CallQueryInterface(relatedTarget, aRelatedTarget);
   }
   return NS_OK;
 }
 
 NS_METHOD nsDOMMouseEvent::GetScreenX(PRInt32* aScreenX)
 {
   NS_ENSURE_ARG_POINTER(aScreenX);
-#ifdef MOZ_TOUCH
   *aScreenX = nsDOMEvent::GetScreenCoords(mPresContext,
                                           mEvent,
                                           mEvent->refPoint).x;
-#else
-  *aScreenX = GetScreenPoint().x;
-#endif
   return NS_OK;
 }
 
 NS_IMETHODIMP
 nsDOMMouseEvent::GetScreenY(PRInt32* aScreenY)
 {
   NS_ENSURE_ARG_POINTER(aScreenY);
-#ifdef MOZ_TOUCH
   *aScreenY = nsDOMEvent::GetScreenCoords(mPresContext,
                                           mEvent,
                                           mEvent->refPoint).y;
-#else
-  *aScreenY = GetScreenPoint().y;
-#endif
   return NS_OK;
 }
 
 
 NS_METHOD nsDOMMouseEvent::GetClientX(PRInt32* aClientX)
 {
   NS_ENSURE_ARG_POINTER(aClientX);
-#ifdef MOZ_TOUCH
   *aClientX = nsDOMEvent::GetClientCoords(mPresContext,
                                           mEvent,
                                           mEvent->refPoint,
                                           mClientPoint).x;
-#else
-  *aClientX = GetClientPoint().x;
-#endif
   return NS_OK;
 }
 
 NS_IMETHODIMP
 nsDOMMouseEvent::GetClientY(PRInt32* aClientY)
 {
   NS_ENSURE_ARG_POINTER(aClientY);
-#ifdef MOZ_TOUCH
   *aClientY = nsDOMEvent::GetClientCoords(mPresContext,
                                           mEvent,
                                           mEvent->refPoint,
                                           mClientPoint).y;
-#else
-  *aClientY = GetClientPoint().y;
-#endif
   return NS_OK;
 }
 
 NS_IMETHODIMP
 nsDOMMouseEvent::GetAltKey(bool* aIsDown)
 {
   NS_ENSURE_ARG_POINTER(aIsDown);
   *aIsDown = ((nsInputEvent*)mEvent)->isAlt;
--- a/content/events/src/nsDOMUIEvent.cpp
+++ b/content/events/src/nsDOMUIEvent.cpp
@@ -239,47 +239,39 @@ nsDOMUIEvent::GetPagePoint()
 
   return pagePoint;
 }
 
 NS_IMETHODIMP
 nsDOMUIEvent::GetPageX(PRInt32* aPageX)
 {
   NS_ENSURE_ARG_POINTER(aPageX);
-#ifdef MOZ_TOUCH
   if (mPrivateDataDuplicated) {
     *aPageX = mPagePoint.x;
   } else {
     *aPageX = nsDOMEvent::GetPageCoords(mPresContext,
                                         mEvent,
                                         mEvent->refPoint,
                                         mClientPoint).x;
   }
-#else
-  *aPageX = GetPagePoint().x;
-#endif
   return NS_OK;
 }
 
 NS_IMETHODIMP
 nsDOMUIEvent::GetPageY(PRInt32* aPageY)
 {
   NS_ENSURE_ARG_POINTER(aPageY);
-#ifdef MOZ_TOUCH
   if (mPrivateDataDuplicated) {
     *aPageY = mPagePoint.y;
   } else {
     *aPageY = nsDOMEvent::GetPageCoords(mPresContext,
                                         mEvent,
                                         mEvent->refPoint,
                                         mClientPoint).y;
   }
-#else
-  *aPageY = GetPagePoint().y;
-#endif
   return NS_OK;
 }
 
 NS_IMETHODIMP
 nsDOMUIEvent::GetWhich(PRUint32* aWhich)
 {
   return Which(aWhich);
 }
@@ -408,37 +400,29 @@ nsDOMUIEvent::GetIsChar(bool* aIsChar)
       *aIsChar = false;
       return NS_OK;
   }
 }
 
 NS_METHOD
 nsDOMUIEvent::DuplicatePrivateData()
 {
-#ifdef MOZ_TOUCH
   mClientPoint = nsDOMEvent::GetClientCoords(mPresContext,
                                              mEvent,
                                              mEvent->refPoint,
                                              mClientPoint);
   mLayerPoint = GetLayerPoint();
   mPagePoint = nsDOMEvent::GetPageCoords(mPresContext,
                                          mEvent,
                                          mEvent->refPoint,
                                          mClientPoint);
   // GetScreenPoint converts mEvent->refPoint to right coordinates.
   nsIntPoint screenPoint = nsDOMEvent::GetScreenCoords(mPresContext,
                                                        mEvent,
                                                        mEvent->refPoint);
-#else
-  mClientPoint = GetClientPoint();
-  mLayerPoint = GetLayerPoint();
-  mPagePoint = GetPagePoint();
-  // GetScreenPoint converts mEvent->refPoint to right coordinates.
-  nsIntPoint screenPoint = GetScreenPoint();
-#endif
   nsresult rv = nsDOMEvent::DuplicatePrivateData();
   if (NS_SUCCEEDED(rv)) {
     mEvent->refPoint = screenPoint;
   }
   return rv;
 }
 
 void
--- a/layout/base/nsLayoutUtils.cpp
+++ b/layout/base/nsLayoutUtils.cpp
@@ -953,86 +953,24 @@ nsPoint
 nsLayoutUtils::GetEventCoordinatesRelativeTo(const nsEvent* aEvent, nsIFrame* aFrame)
 {
   if (!aEvent || (aEvent->eventStructType != NS_MOUSE_EVENT &&
                   aEvent->eventStructType != NS_MOUSE_SCROLL_EVENT &&
                   aEvent->eventStructType != NS_DRAG_EVENT &&
                   aEvent->eventStructType != NS_SIMPLE_GESTURE_EVENT &&
                   aEvent->eventStructType != NS_GESTURENOTIFY_EVENT &&
                   aEvent->eventStructType != NS_MOZTOUCH_EVENT &&
-#ifdef MOZ_TOUCH
                   aEvent->eventStructType != NS_TOUCH_EVENT &&
-#endif
                   aEvent->eventStructType != NS_QUERY_CONTENT_EVENT))
     return nsPoint(NS_UNCONSTRAINEDSIZE, NS_UNCONSTRAINEDSIZE);
 
   const nsGUIEvent* GUIEvent = static_cast<const nsGUIEvent*>(aEvent);
-#ifdef MOZ_TOUCH
   return GetEventCoordinatesRelativeTo(aEvent,
                                        GUIEvent->refPoint,
                                        aFrame);
-#else
-  if (!GUIEvent->widget)
-    return nsPoint(NS_UNCONSTRAINEDSIZE, NS_UNCONSTRAINEDSIZE);
-
-  nsIView* view = aFrame->GetView();
-  if (view) {
-    nsIWidget* widget = view->GetWidget();
-    if (widget && widget == GUIEvent->widget) {
-      // Special case this cause it happens a lot.
-      // This also fixes bug 664707, events in the extra-special case of select
-      // dropdown popups that are transformed.
-      nsPresContext* presContext = aFrame->PresContext();
-      nsPoint pt(presContext->DevPixelsToAppUnits(GUIEvent->refPoint.x),
-                 presContext->DevPixelsToAppUnits(GUIEvent->refPoint.y));
-      return pt - view->ViewToWidgetOffset();
-    }
-  }
-
-  /* If we walk up the frame tree and discover that any of the frames are
-   * transformed, we need to do extra work to convert from the global
-   * space to the local space.
-   */
-  nsIFrame* rootFrame = aFrame;
-  bool transformFound = false;
-
-  for (nsIFrame* f = aFrame; f; f = GetCrossDocParentFrame(f)) {
-    if (f->IsTransformed())
-      transformFound = true;
-    rootFrame = f;
-  }
-
-  nsIView* rootView = rootFrame->GetView();
-  if (!rootView)
-    return nsPoint(NS_UNCONSTRAINEDSIZE, NS_UNCONSTRAINEDSIZE);
-
-  nsPoint widgetToView = TranslateWidgetToView(rootFrame->PresContext(),
-                               GUIEvent->widget, GUIEvent->refPoint,
-                               rootView);
-
-  if (widgetToView == nsPoint(NS_UNCONSTRAINEDSIZE, NS_UNCONSTRAINEDSIZE))
-    return nsPoint(NS_UNCONSTRAINEDSIZE, NS_UNCONSTRAINEDSIZE);
-
-  // Convert from root document app units to app units of the document aFrame
-  // is in.
-  PRInt32 rootAPD = rootFrame->PresContext()->AppUnitsPerDevPixel();
-  PRInt32 localAPD = aFrame->PresContext()->AppUnitsPerDevPixel();
-  widgetToView = widgetToView.ConvertAppUnits(rootAPD, localAPD);
-
-  /* If we encountered a transform, we can't do simple arithmetic to figure
-   * out how to convert back to aFrame's coordinates and must use the CTM.
-   */
-  if (transformFound)
-    return TransformRootPointToFrame(aFrame, widgetToView);
-
-  /* Otherwise, all coordinate systems are translations of one another,
-   * so we can just subtract out the different.
-   */
-  return widgetToView - aFrame->GetOffsetToCrossDoc(rootFrame);
-#endif
 }
 
 nsPoint
 nsLayoutUtils::GetEventCoordinatesRelativeTo(const nsEvent* aEvent,
                                              const nsIntPoint aPoint,
                                              nsIFrame* aFrame)
 {
   if (!aFrame) {
--- a/layout/base/nsPresShell.cpp
+++ b/layout/base/nsPresShell.cpp
@@ -5657,17 +5657,16 @@ PresShell::RecordMouseLocation(nsGUIEven
     printf("[ps=%p]got mouse exit for %p\n",
            this, aEvent->widget);
     printf("[ps=%p]clearing mouse location\n",
            this);
 #endif
   }
 }
 
-#ifdef MOZ_TOUCH
 static void
 EvictTouchPoint(nsCOMPtr<nsIDOMTouch>& aTouch)
 {
   nsIWidget *widget = nsnull;
   // is there an easier/better way to dig out the widget?
   nsCOMPtr<nsINode> node(do_QueryInterface(aTouch->GetTarget()));
   if (!node) {
     return;
@@ -5705,17 +5704,16 @@ EvictTouchPoint(nsCOMPtr<nsIDOMTouch>& a
 static PLDHashOperator
 AppendToTouchList(const PRUint32& aKey, nsCOMPtr<nsIDOMTouch>& aData, void *aTouchList)
 {
   nsTArray<nsCOMPtr<nsIDOMTouch> > *touches = static_cast<nsTArray<nsCOMPtr<nsIDOMTouch> > *>(aTouchList);
   aData->mChanged = false;
   touches->AppendElement(aData);
   return PL_DHASH_NEXT;
 }
-#endif // MOZ_TOUCH
 
 nsresult
 PresShell::HandleEvent(nsIFrame        *aFrame,
                        nsGUIEvent*     aEvent,
                        bool            aDontRetargetEvents,
                        nsEventStatus*  aEventStatus)
 {
   NS_ASSERTION(aFrame, "null frame");
@@ -5919,17 +5917,16 @@ PresShell::HandleEvent(nsIFrame        *
       (static_cast<nsMouseEvent*>(aEvent)->exit == nsMouseEvent::eTopLevel);
 
     // Get the frame at the event point. However, don't do this if we're
     // capturing and retargeting the event because the captured frame will
     // 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) {
-#ifdef MOZ_TOUCH
       nsPoint eventPoint;
       if (aEvent->message == NS_TOUCH_START) {
         // Add any new touches to the queue
         nsTouchEvent* touchEvent = static_cast<nsTouchEvent*>(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) {
@@ -5968,20 +5965,16 @@ PresShell::HandleEvent(nsIFrame        *
               domtouch->SetTarget(targetPtr);
               gCaptureTouchList.Put(id, touch);
             }
           }
         }
       } else {
         eventPoint = nsLayoutUtils::GetEventCoordinatesRelativeTo(aEvent, frame);
       }
-#else
-      nsPoint eventPoint
-          = nsLayoutUtils::GetEventCoordinatesRelativeTo(aEvent, frame);
-#endif
       {
         bool ignoreRootScrollFrame = false;
         if (aEvent->eventStructType == NS_MOUSE_EVENT) {
           ignoreRootScrollFrame = static_cast<nsMouseEvent*>(aEvent)->ignoreRootScrollFrame;
         }
         nsIFrame* target = nsLayoutUtils::GetFrameForPoint(frame, eventPoint,
                                                            false, ignoreRootScrollFrame);
         if (target) {
@@ -6371,19 +6364,17 @@ PresShell::HandleEventInternal(nsEvent* 
     }
   }
 #endif
 
   nsRefPtr<nsEventStateManager> manager = mPresContext->EventStateManager();
   nsresult rv = NS_OK;
 
   if (!NS_EVENT_NEEDS_FRAME(aEvent) || GetCurrentEventFrame()) {
-#ifdef MOZ_TOUCH
     bool touchIsNew = false;
-#endif
     bool isHandlingUserInput = false;
 
     // XXX How about IME events and input events for plugins?
     if (NS_IS_TRUSTED_EVENT(aEvent)) {
       switch (aEvent->message) {
       case NS_KEY_PRESS:
       case NS_KEY_DOWN:
       case NS_KEY_UP: {
@@ -6416,17 +6407,16 @@ 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;
-#ifdef MOZ_TOUCH
       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);
         nsTArray<nsCOMPtr<nsIDOMTouch> >  &touches = touchEvent->touches;
         for (PRUint32 i = 0; i < touches.Length(); ++i) {
           nsIDOMTouch *touch = touches[i];
@@ -6496,17 +6486,16 @@ PresShell::HandleEventInternal(nsEvent* 
         if (!haveChanged) {
           if (gPreventMouseEvents) {
               *aStatus = nsEventStatus_eConsumeNoDefault;
           }
           return NS_OK;
         }
         break;
       }
-#endif
       case NS_DRAGDROP_DROP:
         nsCOMPtr<nsIDragSession> session = nsContentUtils::GetDragSession();
         if (session) {
           bool onlyChromeDrop = false;
           session->GetOnlyChromeDrop(&onlyChromeDrop);
           if (onlyChromeDrop) {
             aEvent->flags |= NS_EVENT_FLAG_ONLY_CHROME_DISPATCH;
           }
@@ -6555,24 +6544,20 @@ PresShell::HandleEventInternal(nsEvent* 
         nsContentUtils::SetIsHandlingKeyBoardEvent(true);
       }
       // We want synthesized mouse moves to cause mouseover and mouseout
       // DOM events (PreHandleEvent above), but not mousemove DOM events.
       // Synthesized button up events also do not cause DOM events
       // because they do not have a reliable refPoint.
       if (!IsSynthesizedMouseEvent(aEvent)) {
         nsPresShellEventCB eventCB(this);
-#ifdef MOZ_TOUCH
         if (aEvent->eventStructType == NS_TOUCH_EVENT) {
           DispatchTouchEvent(aEvent, aStatus, &eventCB, touchIsNew);
         }
         else if (mCurrentEventContent) {
-#else
-        if (mCurrentEventContent) {
-#endif
           nsEventDispatcher::Dispatch(mCurrentEventContent, mPresContext,
                                       aEvent, nsnull, aStatus, &eventCB);
         }
         else {
           nsCOMPtr<nsIContent> targetContent;
           rv = mCurrentEventFrame->GetContentForEvent(aEvent,
                                                       getter_AddRefs(targetContent));
           if (NS_SUCCEEDED(rv) && targetContent) {