Bug 775447: Rip out old checks for DOM touch listeners r=cjones
authorDoug Sherk <dsherk2@mozilla.com>
Tue, 21 Aug 2012 21:37:09 -0700
changeset 105049 408707dae83791046256889add0b364c82f40727
parent 105048 746eb3e15dec03fb1e3b133b9d57b0e9de8f2fb5
child 105050 59a7c786871107092f045cb30065177ffd4930ab
push id55
push usershu@rfrn.org
push dateThu, 30 Aug 2012 01:33:09 +0000
reviewerscjones
bugs775447
milestone17.0a1
Bug 775447: Rip out old checks for DOM touch listeners r=cjones
dom/ipc/PBrowser.ipdl
dom/ipc/TabChild.cpp
dom/ipc/TabParent.cpp
dom/ipc/TabParent.h
gfx/layers/ipc/AsyncPanZoomController.cpp
gfx/layers/ipc/AsyncPanZoomController.h
layout/ipc/RenderFrameParent.cpp
layout/ipc/RenderFrameParent.h
--- a/dom/ipc/PBrowser.ipdl
+++ b/dom/ipc/PBrowser.ipdl
@@ -246,18 +246,16 @@ parent:
      * the window.open.
      *
      * @param opener the PBrowser whose content called window.open.
      */
     sync BrowserFrameOpenWindow(PBrowser opener, nsString aURL,
                                 nsString aName, nsString aFeatures)
       returns (bool windowOpened);
 
-    NotifyDOMTouchListenerAdded();
-
     /**
      * Instructs the TabParent to forward a request to zoom to a rect given in
      * CSS pixels. This rect is relative to the document.
      */
     ZoomToRect(gfxRect aRect);
 
     /**
      * We know for sure that content has either preventDefaulted or not
--- a/dom/ipc/TabChild.cpp
+++ b/dom/ipc/TabChild.cpp
@@ -109,25 +109,17 @@ TabChild::TabChild(PRUint32 aChromeFlags
     printf("creating %d!\n", NS_IsMainThread());
 }
 
 nsresult
 TabChild::Observe(nsISupports *aSubject,
                   const char *aTopic,
                   const PRUnichar *aData)
 {
-  if (!strcmp(aTopic, "dom-touch-listener-added")) {
-    nsCOMPtr<nsIDOMWindow> subject(do_QueryInterface(aSubject));
-    nsCOMPtr<nsIDOMWindow> win(do_GetInterface(mWebNav));
-    nsCOMPtr<nsIDOMWindow> topSubject;
-    subject->GetTop(getter_AddRefs(topSubject));
-    if (win == topSubject) {
-      SendNotifyDOMTouchListenerAdded();
-    }
-  } else if (!strcmp(aTopic, "cancel-default-pan-zoom")) {
+  if (!strcmp(aTopic, "cancel-default-pan-zoom")) {
     nsCOMPtr<nsIDocShell> docShell(do_QueryInterface(aSubject));
     nsCOMPtr<nsITabChild> tabChild(GetTabChildFrom(docShell));
     if (tabChild == this) {
       mRemoteFrame->CancelDefaultPanZoom();
     }
   } else if (!strcmp(aTopic, "browser-zoom-to-rect")) {
     nsCOMPtr<nsIDocShell> docShell(do_QueryInterface(aSubject));
     nsCOMPtr<nsITabChild> tabChild(GetTabChildFrom(docShell));
@@ -159,19 +151,16 @@ TabChild::Init()
   nsCOMPtr<nsIDocShellTreeItem> docShellItem(do_QueryInterface(mWebNav));
   docShellItem->SetItemType(nsIDocShellTreeItem::typeContentWrapper);
 
   nsCOMPtr<nsIObserverService> observerService =
     do_GetService(NS_OBSERVERSERVICE_CONTRACTID);
 
   if (observerService) {
     observerService->AddObserver(this,
-                                 "dom-touch-listener-added",
-                                 false);
-    observerService->AddObserver(this,
                                  "cancel-default-pan-zoom",
                                  false);
     observerService->AddObserver(this,
                                  "browser-zoom-to-rect",
                                  false);
   }
 
   return NS_OK;
--- a/dom/ipc/TabParent.cpp
+++ b/dom/ipc/TabParent.cpp
@@ -1094,25 +1094,16 @@ TabParent::RecvBrowserFrameOpenWindow(PB
 {
   *aOutWindowOpened =
     BrowserElementParent::OpenWindowOOP(static_cast<TabParent*>(aOpener),
                                         this, aURL, aName, aFeatures);
   return true;
 }
 
 bool
-TabParent::RecvNotifyDOMTouchListenerAdded()
-{
-  if (RenderFrameParent* rfp = GetRenderFrame()) {
-    rfp->NotifyDOMTouchListenerAdded();
-  }
-  return true;
-}
-
-bool
 TabParent::RecvZoomToRect(const gfxRect& aRect)
 {
   if (RenderFrameParent* rfp = GetRenderFrame()) {
     rfp->ZoomToRect(aRect);
   }
   return true;
 }
 
--- a/dom/ipc/TabParent.h
+++ b/dom/ipc/TabParent.h
@@ -100,17 +100,16 @@ public:
                                      const nsString& aType,
                                      const nsString& aActionHint,
                                      const PRInt32& aCause,
                                      const PRInt32& aFocusChange);
     virtual bool RecvSetCursor(const PRUint32& aValue);
     virtual bool RecvSetBackgroundColor(const nscolor& aValue);
     virtual bool RecvGetDPI(float* aValue);
     virtual bool RecvGetWidgetNativeData(WindowsHandle* aValue);
-    virtual bool RecvNotifyDOMTouchListenerAdded();
     virtual bool RecvZoomToRect(const gfxRect& aRect);
     virtual bool RecvContentReceivedTouch(const bool& aPreventDefault);
     virtual PContentDialogParent* AllocPContentDialog(const PRUint32& aType,
                                                       const nsCString& aName,
                                                       const nsCString& aFeatures,
                                                       const InfallibleTArray<int>& aIntParams,
                                                       const InfallibleTArray<nsString>& aStringParams);
     virtual bool DeallocPContentDialog(PContentDialogParent* aDialog)
--- a/gfx/layers/ipc/AsyncPanZoomController.cpp
+++ b/gfx/layers/ipc/AsyncPanZoomController.cpp
@@ -85,17 +85,16 @@ AsyncPanZoomController::AsyncPanZoomCont
      mTouchListenerTimeoutTask(nullptr),
      mX(this),
      mY(this),
      mMonitor("AsyncPanZoomController"),
      mLastSampleTime(TimeStamp::Now()),
      mState(NOTHING),
      mDPI(72),
      mContentPainterStatus(CONTENT_IDLE),
-     mMayHaveTouchListeners(false),
      mDisableNextTouchBatch(false),
      mHandlingTouchQueue(false)
 {
   if (aGestures == USE_GESTURE_DETECTOR) {
     mGestureEventListener = new GestureEventListener(this);
   }
 
   SetDPI(mDPI);
@@ -185,16 +184,22 @@ AsyncPanZoomController::ReceiveInputEven
     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
+  // hundred ms of lag.
   if (mFrameMetrics.mMayHaveTouchListeners && aEvent.mInputType == MULTITOUCH_INPUT &&
       (mState == NOTHING || mState == TOUCHING || mState == PANNING)) {
     const MultiTouchInput& multiTouchInput = aEvent.AsMultiTouchInput();
     if (multiTouchInput.mType == MultiTouchInput::MULTITOUCH_START) {
       SetState(WAITING_LISTENERS);
     }
   }
 
@@ -942,20 +947,16 @@ void AsyncPanZoomController::NotifyLayer
     mFrameMetrics.mResolution.width = 1 / mFrameMetrics.mResolution.width;
     mFrameMetrics.mResolution.height = 1 / mFrameMetrics.mResolution.height;
     SetPageRect(mFrameMetrics.mCSSContentRect);
 
     // Bug 776413/fixme: Request a repaint as soon as a page is loaded so that
     // we get a larger displayport. This is very bad because we're wasting a
     // paint and not initializating the displayport correctly.
     RequestContentRepaint();
-
-    // Assuming a first paint means a new page has been loaded, clear the flag
-    // indicating that we may have touch listeners.
-    mMayHaveTouchListeners = false;
   } else if (!mFrameMetrics.mCSSContentRect.IsEqualEdges(aViewportFrame.mCSSContentRect)) {
     mFrameMetrics.mCSSContentRect = aViewportFrame.mCSSContentRect;
     SetPageRect(mFrameMetrics.mCSSContentRect);
   }
 }
 
 const FrameMetrics& AsyncPanZoomController::GetFrameMetrics() {
   mMonitor.AssertCurrentThreadOwns();
@@ -964,19 +965,16 @@ const FrameMetrics& AsyncPanZoomControll
 
 void AsyncPanZoomController::UpdateViewportSize(int aWidth, int aHeight) {
   MonitorAutoLock mon(mMonitor);
   FrameMetrics metrics = GetFrameMetrics();
   metrics.mViewport = nsIntRect(0, 0, aWidth, aHeight);
   mFrameMetrics = metrics;
 }
 
-void AsyncPanZoomController::NotifyDOMTouchListenerAdded() {
-}
-
 void AsyncPanZoomController::CancelDefaultPanZoom() {
   mDisableNextTouchBatch = true;
   if (mGestureEventListener) {
     mGestureEventListener->CancelGesture();
   }
 }
 
 void AsyncPanZoomController::ZoomToRect(const gfxRect& aRect) {
--- a/gfx/layers/ipc/AsyncPanZoomController.h
+++ b/gfx/layers/ipc/AsyncPanZoomController.h
@@ -105,26 +105,16 @@ public:
    * how large of a displayport to set so we use these dimensions plus some
    * extra.
    *
    * XXX: Use nsIntRect instead.
    */
   void UpdateViewportSize(int aWidth, int aHeight);
 
   /**
-   * A DOM touch listener has been added. When called, we enable the machinery
-   * that allows touch listeners to preventDefault any touch inputs. This should
-   * not be called 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 hundred ms of lag.
-   */
-  void NotifyDOMTouchListenerAdded();
-
-  /**
    * We have found a scrollable subframe, so disable our machinery until we hit
    * a touch end or a new touch start. This prevents us from accidentally
    * panning both the subframe and the parent frame.
    *
    * XXX/bug 775452: We should eventually be supporting async scrollable
    * subframes.
    */
   void CancelDefaultPanZoom();
@@ -504,20 +494,16 @@ private:
   int mDPI;
 
   // Stores the current paint status of the frame that we're managing. Repaints
   // may be triggered by other things (like content doing things), in which case
   // this status will not be updated. It is only changed when this class
   // requests a repaint.
   ContentPainterStatus mContentPainterStatus;
 
-  // Whether or not we might have touch listeners. This is a conservative
-  // approximation and may not be accurate.
-  bool mMayHaveTouchListeners;
-
   // Flag used to determine whether or not we should disable handling of the
   // next batch of touch events. This is used for sync scrolling of subframes.
   bool mDisableNextTouchBatch;
 
   // Flag used to determine whether or not we should try to enter the
   // WAITING_LISTENERS state. This is used in the case that we are processing a
   // queued up event block. If set, this means that we are handling this queue
   // and we don't want to queue the events back up again.
--- a/layout/ipc/RenderFrameParent.cpp
+++ b/layout/ipc/RenderFrameParent.cpp
@@ -878,24 +878,16 @@ RenderFrameParent::BuildDisplayList(nsDi
   nsRect bounds = aFrame->EnsureInnerView()->GetBounds() + offset;
 
   return aLists.Content()->AppendNewToTop(
     new (aBuilder) nsDisplayClip(aBuilder, aFrame, &shadowTree,
                                  bounds));
 }
 
 void
-RenderFrameParent::NotifyDOMTouchListenerAdded()
-{
-  if (mPanZoomController) {
-    mPanZoomController->NotifyDOMTouchListenerAdded();
-  }
-}
-
-void
 RenderFrameParent::ZoomToRect(const gfxRect& aRect)
 {
   if (mPanZoomController) {
     mPanZoomController->ZoomToRect(aRect);
   }
 }
 
 void
--- a/layout/ipc/RenderFrameParent.h
+++ b/layout/ipc/RenderFrameParent.h
@@ -89,18 +89,16 @@ public:
 
   void SetBackgroundColor(nscolor aColor) { mBackgroundColor = gfxRGBA(aColor); };
 
   void NotifyInputEvent(const nsInputEvent& aEvent,
                         nsInputEvent* aOutEvent);
 
   void NotifyDimensionsChanged(int width, int height);
 
-  void NotifyDOMTouchListenerAdded();
-
   void ZoomToRect(const gfxRect& aRect);
 
   void ContentReceivedTouch(bool aPreventDefault);
 
 protected:
   void ActorDestroy(ActorDestroyReason why) MOZ_OVERRIDE;
 
   virtual bool RecvNotifyCompositorTransaction() MOZ_OVERRIDE;