Backout 8a6cacf047a1 (bug 833795) to fix bug 856083
authorAnthony Jones <ajones@mozilla.com>
Fri, 05 Apr 2013 18:19:08 +1300
changeset 138707 bc159983a018b10ff2e3a0572d8a1e70783f49e4
parent 138706 aaae69fde5623b8ae0325f5485a7e168b8caf4d7
child 138708 8fc33d047ed60ff108695ea3bf613c536e14a7a9
push id2579
push userakeybl@mozilla.com
push dateMon, 24 Jun 2013 18:52:47 +0000
treeherdermozilla-beta@b69b7de8a05a [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs833795, 856083
milestone23.0a1
backs out8a6cacf047a1bec50e3e3540bfff13703d591485
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
Backout 8a6cacf047a1 (bug 833795) to fix bug 856083
dom/ipc/TabParent.cpp
gfx/layers/ipc/AsyncPanZoomController.cpp
gfx/layers/ipc/AsyncPanZoomController.h
layout/ipc/RenderFrameParent.cpp
layout/ipc/RenderFrameParent.h
--- a/dom/ipc/TabParent.cpp
+++ b/dom/ipc/TabParent.cpp
@@ -641,20 +641,16 @@ TabParent::GetEventCapturer()
   return sEventCapturer;
 }
 
 bool
 TabParent::TryCapture(const nsGUIEvent& aEvent)
 {
   MOZ_ASSERT(sEventCapturer == this && mEventCaptureDepth > 0);
 
-  if (mIsDestroyed) {
-    return false;
-  }
-
   if (aEvent.eventStructType != NS_TOUCH_EVENT) {
     // Only capture of touch events is implemented, for now.
     return false;
   }
 
   nsTouchEvent event(static_cast<const nsTouchEvent&>(aEvent));
 
   bool isTouchPointUp = (event.message == NS_TOUCH_END ||
@@ -665,39 +661,29 @@ TabParent::TryCapture(const nsGUIEvent& 
     if (isTouchPointUp && 0 == --mEventCaptureDepth) {
       // All event series are un-captured, don't try to catch any
       // more.
       sEventCapturer = nullptr;
     }
     return false;
   }
 
-  if (RenderFrameParent* rfp = GetRenderFrame()) {
-    // We need to process screen relative events co-ordinates for gestures to
-    // avoid phantom movement when the frame moves.
-    rfp->NotifyInputEvent(event);
-
-    // Adjust the widget coordinates to be relative to our frame.
-    nsRefPtr<nsFrameLoader> frameLoader = GetFrameLoader();
+  // Adjust the widget coordinates to be relative to our frame.
+  nsRefPtr<nsFrameLoader> frameLoader = GetFrameLoader();
 
-    if (!frameLoader) {
-      // No frame anymore?
-      sEventCapturer = nullptr;
-      return false;
-    }
-
-    // Remove the frame offset and compensate for zoom.
-    nsEventStateManager::MapEventCoordinatesForChildProcess(frameLoader,
-                                                            &event);
-    rfp->ApplyZoomCompensationToEvent(&event);
+  if (!frameLoader) {
+    // No frame anymore?
+    sEventCapturer = nullptr;
+    return false;
   }
 
-  return (event.message == NS_TOUCH_MOVE) ?
-    PBrowserParent::SendRealTouchMoveEvent(event) :
-    PBrowserParent::SendRealTouchEvent(event);
+  nsEventStateManager::MapEventCoordinatesForChildProcess(frameLoader, &event);
+
+  SendRealTouchEvent(event);
+  return true;
 }
 
 bool
 TabParent::RecvSyncMessage(const nsString& aMessage,
                            const ClonedMessageData& aData,
                            InfallibleTArray<nsString>* aJSONRetVal)
 {
   StructuredCloneData cloneData = ipc::UnpackClonedMessageDataForParent(aData);
@@ -1399,18 +1385,17 @@ TabParent::UseAsyncPanZoom()
           GetScrollingBehavior() == ASYNC_PAN_ZOOM);
 }
 
 void
 TabParent::MaybeForwardEventToRenderFrame(const nsInputEvent& aEvent,
                                           nsInputEvent* aOutEvent)
 {
   if (RenderFrameParent* rfp = GetRenderFrame()) {
-    rfp->NotifyInputEvent(aEvent);
-    rfp->ApplyZoomCompensationToEvent(aOutEvent);
+    rfp->NotifyInputEvent(aEvent, aOutEvent);
   }
 }
 
 bool
 TabParent::RecvBrowserFrameOpenWindow(PBrowserParent* aOpener,
                                       const nsString& aURL,
                                       const nsString& aName,
                                       const nsString& aFeatures,
--- a/gfx/layers/ipc/AsyncPanZoomController.cpp
+++ b/gfx/layers/ipc/AsyncPanZoomController.cpp
@@ -220,18 +220,30 @@ WidgetSpaceToCompensatedViewportSpace(co
   // know what content CSS pixel is at widget point 0,0 based on information
   // available here.  So we use this hacky implementation for now, which works
   // in quiescent states.
 
   return pt;
 }
 
 nsEventStatus
-AsyncPanZoomController::ReceiveMainThreadInputEvent(const nsInputEvent& aEvent)
+AsyncPanZoomController::ReceiveInputEvent(const nsInputEvent& aEvent,
+                                          nsInputEvent* aOutEvent)
 {
+  gfxFloat currentResolution;
+  gfx::Point currentScrollOffset, lastScrollOffset;
+  {
+    MonitorAutoLock monitor(mMonitor);
+    currentResolution = CalculateResolution(mFrameMetrics).width;
+    currentScrollOffset = gfx::Point(mFrameMetrics.mScrollOffset.x,
+                                     mFrameMetrics.mScrollOffset.y);
+    lastScrollOffset = gfx::Point(mLastContentPaintMetrics.mScrollOffset.x,
+                                  mLastContentPaintMetrics.mScrollOffset.y);
+  }
+
   nsEventStatus status;
   switch (aEvent.eventStructType) {
   case NS_TOUCH_EVENT: {
     MultiTouchInput event(static_cast<const nsTouchEvent&>(aEvent));
     status = ReceiveInputEvent(event);
     break;
   }
   case NS_MOUSE_EVENT: {
@@ -239,51 +251,41 @@ AsyncPanZoomController::ReceiveMainThrea
     status = ReceiveInputEvent(event);
     break;
   }
   default:
     status = nsEventStatus_eIgnore;
     break;
   }
 
-  return status;
-}
-
-void
-AsyncPanZoomController::ApplyZoomCompensationToEvent(nsInputEvent* aEvent)
-{
-  gfxFloat currentResolution;
-  {
-    MonitorAutoLock monitor(mMonitor);
-    currentResolution = CalculateResolution(mFrameMetrics).width;
-  }
-
-  switch (aEvent->eventStructType) {
+  switch (aEvent.eventStructType) {
   case NS_TOUCH_EVENT: {
-    nsTouchEvent* touchEvent = static_cast<nsTouchEvent*>(aEvent);
+    nsTouchEvent* touchEvent = static_cast<nsTouchEvent*>(aOutEvent);
     const nsTArray<nsCOMPtr<nsIDOMTouch> >& touches = touchEvent->touches;
     for (uint32_t i = 0; i < touches.Length(); ++i) {
       nsIDOMTouch* touch = touches[i];
       if (touch) {
         gfx::Point refPoint = WidgetSpaceToCompensatedViewportSpace(
           gfx::Point(touch->mRefPoint.x, touch->mRefPoint.y),
           currentResolution);
         touch->mRefPoint = nsIntPoint(refPoint.x, refPoint.y);
       }
     }
     break;
   }
   default: {
     gfx::Point refPoint = WidgetSpaceToCompensatedViewportSpace(
-      gfx::Point(aEvent->refPoint.x, aEvent->refPoint.y),
+      gfx::Point(aOutEvent->refPoint.x, aOutEvent->refPoint.y),
       currentResolution);
-    aEvent->refPoint = nsIntPoint(refPoint.x, refPoint.y);
+    aOutEvent->refPoint = nsIntPoint(refPoint.x, refPoint.y);
     break;
   }
   }
+
+  return status;
 }
 
 nsEventStatus AsyncPanZoomController::ReceiveInputEvent(const InputData& aEvent) {
   // If we may have touch listeners, we enable the machinery that allows touch
   // listeners to preventDefault any touch inputs. This should not happen unless
   // there are actually touch listeners as it introduces potentially unbounded
   // lag because it causes a round-trip through content.  Usually, if content is
   // responding in a timely fashion, this only introduces a nearly constant few
--- a/gfx/layers/ipc/AsyncPanZoomController.h
+++ b/gfx/layers/ipc/AsyncPanZoomController.h
@@ -87,32 +87,27 @@ public:
    * General handler for incoming input events. Manipulates the frame metrics
    * basde on what type of input it is. For example, a PinchGestureEvent will
    * cause scaling. This should only be called externally to this class.
    * HandleInputEvent() should be used internally.
    */
   nsEventStatus ReceiveInputEvent(const InputData& aEvent);
 
   /**
-   * Special handler for nsInputEvents. |aEvent| is in screen relative
-   * co-ordinates.
+   * Special handler for nsInputEvents. Also sets |aOutEvent| (which is assumed
+   * to be an already-existing instance of an nsInputEvent which may be an
+   * nsTouchEvent) to have its touch points in DOM space. This is so that the
+   * touches can be passed through the DOM and content can handle them.
    *
-   * NOTE: 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: 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.
    */
-  nsEventStatus ReceiveMainThreadInputEvent(const nsInputEvent& aEvent);
-
-  /**
-   * Transform from frame relative co-ordinates to DOM relative co-ordinates.
-   * This method updates |aEvent| (which is assumed to be an already-existing
-   * instance of an nsInputEvent which may be an nsTouchEvent) to have its touch
-   * points in DOM space. This is so that the touches can be passed through the
-   * DOM and content can handle them.
-   */
-  void ApplyZoomCompensationToEvent(nsInputEvent* aEvent);
+  nsEventStatus ReceiveInputEvent(const nsInputEvent& aEvent,
+                                  nsInputEvent* aOutEvent);
 
   /**
    * Updates the composition bounds, i.e. the dimensions of the final size of
    * the frame this is tied to during composition onto, in device pixels. In
    * general, this will just be:
    * { x = 0, y = 0, width = surface.width, height = surface.height }, however
    * there is no hard requirement for this.
    */
--- a/layout/ipc/RenderFrameParent.cpp
+++ b/layout/ipc/RenderFrameParent.cpp
@@ -776,28 +776,21 @@ void
 RenderFrameParent::OwnerContentChanged(nsIContent* aContent)
 {
   NS_ABORT_IF_FALSE(mFrameLoader->GetOwnerContent() == aContent,
                     "Don't build new map if owner is same!");
   BuildViewMap();
 }
 
 void
-RenderFrameParent::NotifyInputEvent(const nsInputEvent& aEvent)
+RenderFrameParent::NotifyInputEvent(const nsInputEvent& aEvent,
+                                    nsInputEvent* aOutEvent)
 {
   if (mPanZoomController) {
-    mPanZoomController->ReceiveMainThreadInputEvent(aEvent);
-  }
-}
-
-void
-RenderFrameParent::ApplyZoomCompensationToEvent(nsInputEvent* aEvent)
-{
-  if (mPanZoomController) {
-    mPanZoomController->ApplyZoomCompensationToEvent(aEvent);
+    mPanZoomController->ReceiveInputEvent(aEvent, aOutEvent);
   }
 }
 
 void
 RenderFrameParent::NotifyDimensionsChanged(int width, int height)
 {
   if (mPanZoomController) {
     mPanZoomController->UpdateCompositionBounds(
--- a/layout/ipc/RenderFrameParent.h
+++ b/layout/ipc/RenderFrameParent.h
@@ -87,19 +87,18 @@ public:
                                      const nsIntRect& aVisibleRect,
                                      nsDisplayItem* aItem,
                                      const ContainerParameters& aContainerParameters);
 
   void OwnerContentChanged(nsIContent* aContent);
 
   void SetBackgroundColor(nscolor aColor) { mBackgroundColor = gfxRGBA(aColor); };
 
-  void NotifyInputEvent(const nsInputEvent& aEvent);
-
-  void ApplyZoomCompensationToEvent(nsInputEvent* aEvent);
+  void NotifyInputEvent(const nsInputEvent& aEvent,
+                        nsInputEvent* aOutEvent);
 
   void NotifyDimensionsChanged(int width, int height);
 
   void ZoomToRect(const gfxRect& aRect);
 
   void ContentReceivedTouch(bool aPreventDefault);
 
   void UpdateZoomConstraints(bool aAllowZoom, float aMinZoom, float aMaxZoom);