Bug 949132 - Use the FrameMetrics flag on the layers update to update APZC scroll offset instead of tracking it in widget code. r=Cwiiis
authorKartikaya Gupta <kgupta@mozilla.com>
Mon, 16 Dec 2013 12:04:46 -0500
changeset 160632 5047906b359fc944b48d1dc19f77c2a74a55fe44
parent 160631 d49be6bd6378e1906472430697735f97f5ab0c33
child 160633 d6b04a89595c992b450634dfd66f862d0d6d5089
push id1
push userroot
push dateMon, 20 Oct 2014 17:29:22 +0000
reviewersCwiiis
bugs949132
milestone29.0a1
Bug 949132 - Use the FrameMetrics flag on the layers update to update APZC scroll offset instead of tracking it in widget code. r=Cwiiis
browser/metro/base/content/apzc.js
browser/metro/base/content/bindings/browser.js
dom/ipc/PBrowser.ipdl
dom/ipc/TabChild.cpp
dom/ipc/TabChild.h
dom/ipc/TabParent.cpp
dom/ipc/TabParent.h
gfx/layers/composite/APZCTreeManager.cpp
gfx/layers/composite/APZCTreeManager.h
gfx/layers/ipc/AsyncPanZoomController.cpp
gfx/layers/ipc/AsyncPanZoomController.h
layout/ipc/RenderFrameParent.cpp
layout/ipc/RenderFrameParent.h
mobile/android/base/gfx/GeckoLayerClient.java
mobile/android/base/gfx/JavaPanZoomController.java
mobile/android/base/gfx/NativePanZoomController.java
mobile/android/base/gfx/PanZoomController.java
mozglue/android/jni-stubs.inc
widget/android/AndroidJNI.cpp
widget/windows/winrt/APZController.cpp
widget/windows/winrt/APZController.h
widget/windows/winrt/MetroWidget.cpp
--- a/browser/metro/base/content/apzc.js
+++ b/browser/metro/base/content/apzc.js
@@ -29,32 +29,30 @@ var APZCObserver = {
 
     let os = Services.obs;
     os.addObserver(this, "apzc-transform-begin", false);
 
     // Fired by ContentAreaObserver
     window.addEventListener("SizeChanged", this, true);
     Elements.tabList.addEventListener("TabSelect", this, true);
     Elements.browsers.addEventListener("pageshow", this, true);
-    messageManager.addMessageListener("Browser:ContentScroll", this);
     messageManager.addMessageListener("Content:ZoomToRect", this);
   },
 
   shutdown: function shutdown() {
     if (!this._enabled) {
       return;
     }
 
     let os = Services.obs;
     os.removeObserver(this, "apzc-transform-begin");
 
     window.removeEventListener("SizeChanged", this, true);
     Elements.tabList.removeEventListener("TabSelect", this, true);
     Elements.browsers.removeEventListener("pageshow", this, true);
-    messageManager.removeMessageListener("Browser:ContentScroll", this);
     messageManager.removeMessageListener("Content:ZoomToRect", this);
   },
 
   handleEvent: function APZC_handleEvent(aEvent) {
     switch (aEvent.type) {
       case "SizeChanged":
       case 'TabSelect':
         this._resetDisplayPort();
@@ -80,26 +78,16 @@ var APZCObserver = {
       }
     }
   },
 
   receiveMessage: function(aMessage) {
     let json = aMessage.json;
     let browser = aMessage.target;
     switch (aMessage.name) {
-       // Content notifies us here (syncronously) if it has scrolled
-       // independent of the apz. This can happen in a lot of
-       // cases: keyboard shortcuts, scroll wheel, or content script.
-       // Let the apz know about this change so that it can update
-       // its scroll offset data.
-      case "Browser:ContentScroll": {
-        let data = json.viewId + " " + json.presShellId + " (" + json.scrollOffset.x + ", " + json.scrollOffset.y + ")";
-        Services.obs.notifyObservers(null, "apzc-scroll-offset-changed", data);
-        break;
-      }
       case "Content:ZoomToRect": {
         let { presShellId, viewId } = json;
         let rect = Rect.fromRect(json.rect);
         if (this.isRectZoomedIn(rect, browser.contentViewportBounds)) {
           // If we're already zoomed in, zoom out instead.
           rect = new Rect(0,0,0,0);
         }
         let data = [rect.x, rect.y, rect.width, rect.height, presShellId, viewId].join(",");
--- a/browser/metro/base/content/bindings/browser.js
+++ b/browser/metro/base/content/bindings/browser.js
@@ -558,19 +558,16 @@ DOMEvents.init();
 
 let ContentScroll =  {
   // The most recent offset set by APZC for the root scroll frame
   _scrollOffset: { x: 0, y: 0 },
 
   init: function() {
     addMessageListener("Content:SetWindowSize", this);
 
-    if (Services.prefs.getBoolPref("layers.async-pan-zoom.enabled")) {
-      addEventListener("scroll", this, true);
-    }
     addEventListener("pagehide", this, false);
     addEventListener("MozScrolledAreaChanged", this, false);
   },
 
   getScrollOffset: function(aWindow) {
     let cwu = aWindow.QueryInterface(Ci.nsIInterfaceRequestor).getInterface(Ci.nsIDOMWindowUtils);
     let scrollX = {}, scrollY = {};
     cwu.getScrollXY(false, scrollX, scrollY);
@@ -596,21 +593,16 @@ let ContentScroll =  {
   },
 
   handleEvent: function(aEvent) {
     switch (aEvent.type) {
       case "pagehide":
         this._scrollOffset = { x: 0, y: 0 };
         break;
 
-      case "scroll": {
-        this.notifyChromeAboutContentScroll(aEvent.target);
-        break;
-      }
-
       case "MozScrolledAreaChanged": {
         let doc = aEvent.originalTarget;
         if (content != doc.defaultView) // We are only interested in root scroll pane changes
           return;
 
         sendAsyncMessage("MozScrolledAreaChanged", {
           width: aEvent.width,
           height: aEvent.height,
@@ -622,57 +614,16 @@ let ContentScroll =  {
         addEventListener("MozAfterPaint", function afterPaint() {
           removeEventListener("MozAfterPaint", afterPaint, false);
           sendAsyncMessage("Content:UpdateDisplayPort");
         }, false);
 
         break;
       }
     }
-  },
-
-  /*
-  * DOM scroll handler - if we receive this, content or the dom scrolled
-  * content without going through the apz. This can happen in a lot of
-  * cases, keyboard shortcuts, scroll wheel, or content script. Messages
-  * chrome via a sync call which messages the apz about the update.
-  */
-  notifyChromeAboutContentScroll: function (target) {
-    let isRoot = false;
-    if (target instanceof Ci.nsIDOMDocument) {
-      var window = target.defaultView;
-      var scrollOffset = this.getScrollOffset(window);
-      var element = target.documentElement;
-
-      if (target == content.document) {
-        if (this._scrollOffset.x == scrollOffset.x && this._scrollOffset.y == scrollOffset.y) {
-          // Don't send a scroll message back to APZC if it's the same as the
-          // last one.
-          return;
-        }
-        this._scrollOffset = scrollOffset;
-        isRoot = true;
-      }
-    } else {
-      var window = target.ownerDocument.defaultView;
-      var scrollOffset = this.getScrollOffsetForElement(target);
-      var element = target;
-    }
-
-    let utils = window.QueryInterface(Ci.nsIInterfaceRequestor).getInterface(Ci.nsIDOMWindowUtils);
-    let presShellId = {};
-    utils.getPresShellId(presShellId);
-    let viewId = utils.getViewId(element);
-    // Must be synchronous to prevent redraw getting out of sync from
-    // composition.
-    sendSyncMessage("Browser:ContentScroll",
-      { presShellId: presShellId.value,
-        viewId: viewId,
-        scrollOffset: scrollOffset,
-        isRoot: isRoot });
   }
 };
 
 ContentScroll.init();
 
 let ContentActive =  {
   init: function() {
     addMessageListener("Content:Activate", this);
--- a/dom/ipc/PBrowser.ipdl
+++ b/dom/ipc/PBrowser.ipdl
@@ -291,23 +291,16 @@ parent:
     /**
      * Updates the zoom constraints for a scrollable frame in this tab.
      * The zoom controller code lives on the parent side and so this allows it to
      * have up-to-date zoom constraints.
      */
     UpdateZoomConstraints(uint32_t aPresShellId, ViewID aViewId, bool aIsRoot,
                           bool aAllowZoom, CSSToScreenScale aMinZoom, CSSToScreenScale aMaxZoom);
 
-    /**
-     * Notifies the parent about a scroll event. The pres shell ID and
-     * view ID identify which scrollable (sub-)frame was scrolled, and
-     * the new scroll offset for that frame is sent.
-     */
-    UpdateScrollOffset(uint32_t aPresShellId, ViewID aViewId, CSSIntPoint aScrollOffset);
-
     __delete__();
 
 child:
     /**
      * Notify the remote browser that it has been Show()n on this
      * side, with the given |visibleRect|.  This message is expected
      * to trigger creation of the remote browser's "widget".
      *
--- a/dom/ipc/TabChild.cpp
+++ b/dom/ipc/TabChild.cpp
@@ -294,63 +294,16 @@ NS_IMETHODIMP
 TabChild::HandleEvent(nsIDOMEvent* aEvent)
 {
   nsAutoString eventType;
   aEvent->GetType(eventType);
   if (eventType.EqualsLiteral("DOMMetaAdded")) {
     // This meta data may or may not have been a meta viewport tag. If it was,
     // we should handle it immediately.
     HandlePossibleViewportChange();
-  } else if (eventType.EqualsLiteral("scroll")) {
-    nsCOMPtr<nsIDOMEventTarget> target;
-    aEvent->GetTarget(getter_AddRefs(target));
-
-    ViewID viewId;
-    uint32_t presShellId;
-
-    nsCOMPtr<nsIContent> content;
-    if (nsCOMPtr<nsIDocument> doc = do_QueryInterface(target))
-      content = doc->GetDocumentElement();
-    else
-      content = do_QueryInterface(target);
-
-    nsCOMPtr<nsIDOMWindowUtils> utils = APZCCallbackHelper::GetDOMWindowUtils(content);
-    utils->GetPresShellId(&presShellId);
-
-    if (!nsLayoutUtils::FindIDFor(content, &viewId))
-      return NS_ERROR_UNEXPECTED;
-
-    nsIScrollableFrame* scrollFrame = nsLayoutUtils::FindScrollableFrameFor(viewId);
-    if (!scrollFrame)
-      return NS_OK;
-
-    CSSIntPoint scrollOffset = scrollFrame->GetScrollPositionCSSPixels();
-
-    if (viewId == mLastRootMetrics.mScrollId) {
-      // We store the last metrics that was sent via the TabParent (This is
-      // updated in ProcessUpdateFrame and RecvUpdateFrame).
-      // We use this here to avoid sending APZC back a scroll event that
-      // originally came from APZC (besides being unnecessary, the event might
-      // be slightly out of date by the time it reaches APZC).
-      if (RoundedToInt(mLastRootMetrics.mScrollOffset) == scrollOffset) {
-        return NS_OK;
-      }
-
-      // Update the last scroll offset now, otherwise RecvUpdateDimensions()
-      // might trigger a scroll to the old offset before RecvUpdateFrame()
-      // gets a chance to update it.
-      mLastRootMetrics.mScrollOffset = scrollOffset;
-    } else if (viewId == mLastSubFrameMetrics.mScrollId) {
-      if (RoundedToInt(mLastSubFrameMetrics.mScrollOffset) == scrollOffset) {
-        return NS_OK;
-      }
-      mLastSubFrameMetrics.mScrollOffset = scrollOffset;
-    }
-
-    SendUpdateScrollOffset(presShellId, viewId, scrollOffset);
   }
 
   return NS_OK;
 }
 
 NS_IMETHODIMP
 TabChild::Observe(nsISupports *aSubject,
                   const char *aTopic,
@@ -1544,17 +1497,16 @@ TabChild::RecvUpdateFrame(const FrameMet
   } else {
     // aFrameMetrics.mIsRoot is false, so we are trying to update a subframe.
     // This requires special handling.
     nsCOMPtr<nsIContent> content = nsLayoutUtils::FindContentFor(
                                       aFrameMetrics.mScrollId);
     if (content) {
       FrameMetrics newSubFrameMetrics(aFrameMetrics);
       APZCCallbackHelper::UpdateSubFrame(content, newSubFrameMetrics);
-      mLastSubFrameMetrics = newSubFrameMetrics;
       return true;
     }
   }
 
   // We've recieved a message that is out of date and we want to ignore.
   // However we can't reply without painting so we reply by painting the
   // exact same thing as we did before.
   return ProcessUpdateFrame(mLastRootMetrics);
@@ -2239,17 +2191,16 @@ TabChild::InitTabChildGlobal(FrameScript
 
     scope->Init();
 
     nsCOMPtr<nsPIWindowRoot> root = do_QueryInterface(chromeHandler);
     NS_ENSURE_TRUE(root, false);
     root->SetParentTarget(scope);
 
     chromeHandler->AddEventListener(NS_LITERAL_STRING("DOMMetaAdded"), this, false);
-    chromeHandler->AddEventListener(NS_LITERAL_STRING("scroll"), this, true);
   }
 
   if (aScriptLoading != DONT_LOAD_SCRIPTS && !mTriedBrowserInit) {
     mTriedBrowserInit = true;
     // Initialize the child side of the browser element machinery,
     // if appropriate.
     if (IsBrowserOrApp()) {
       RecvLoadRemoteScript(BROWSER_ELEMENT_CHILD_SCRIPT);
--- a/dom/ipc/TabChild.h
+++ b/dom/ipc/TabChild.h
@@ -464,17 +464,16 @@ private:
     class CachedFileDescriptorInfo;
     class CachedFileDescriptorCallbackRunnable;
 
     TextureFactoryIdentifier mTextureFactoryIdentifier;
     nsCOMPtr<nsIWebNavigation> mWebNav;
     nsCOMPtr<nsIWidget> mWidget;
     nsCOMPtr<nsIURI> mLastURI;
     FrameMetrics mLastRootMetrics;
-    FrameMetrics mLastSubFrameMetrics;
     RenderFrameChild* mRemoteFrame;
     nsRefPtr<ContentChild> mManager;
     nsRefPtr<TabChildGlobal> mTabChildGlobal;
     uint32_t mChromeFlags;
     nsIntRect mOuterRect;
     ScreenIntSize mInnerSize;
     // When we're tracking a possible tap gesture, this is the "down"
     // point of the touchstart.
--- a/dom/ipc/TabParent.cpp
+++ b/dom/ipc/TabParent.cpp
@@ -1717,27 +1717,16 @@ TabParent::RecvUpdateZoomConstraints(con
 {
   if (RenderFrameParent* rfp = GetRenderFrame()) {
     rfp->UpdateZoomConstraints(aPresShellId, aViewId, aIsRoot, aAllowZoom, aMinZoom, aMaxZoom);
   }
   return true;
 }
 
 bool
-TabParent::RecvUpdateScrollOffset(const uint32_t& aPresShellId,
-                                  const ViewID& aViewId,
-                                  const CSSIntPoint& aScrollOffset)
-{
-  if (RenderFrameParent* rfp = GetRenderFrame()) {
-    rfp->UpdateScrollOffset(aPresShellId, aViewId, aScrollOffset);
-  }
-  return true;
-}
-
-bool
 TabParent::RecvContentReceivedTouch(const ScrollableLayerGuid& aGuid,
                                     const bool& aPreventDefault)
 {
   if (RenderFrameParent* rfp = GetRenderFrame()) {
     rfp->ContentReceivedTouch(aGuid, aPreventDefault);
   }
   return true;
 }
--- a/dom/ipc/TabParent.h
+++ b/dom/ipc/TabParent.h
@@ -166,17 +166,16 @@ public:
                                 const ViewID& aViewId,
                                 const CSSRect& aRect);
     virtual bool RecvUpdateZoomConstraints(const uint32_t& aPresShellId,
                                            const ViewID& aViewId,
                                            const bool& aIsRoot,
                                            const bool& aAllowZoom,
                                            const CSSToScreenScale& aMinZoom,
                                            const CSSToScreenScale& aMaxZoom);
-    virtual bool RecvUpdateScrollOffset(const uint32_t& aPresShellId, const ViewID& aViewId, const CSSIntPoint& aScrollOffset);
     virtual bool RecvContentReceivedTouch(const ScrollableLayerGuid& aGuid,
                                           const bool& aPreventDefault);
     virtual PContentDialogParent* AllocPContentDialogParent(const uint32_t& aType,
                                                             const nsCString& aName,
                                                             const nsCString& aFeatures,
                                                             const InfallibleTArray<int>& aIntParams,
                                                             const InfallibleTArray<nsString>& aStringParams);
     virtual bool DeallocPContentDialogParent(PContentDialogParent* aDialog)
--- a/gfx/layers/composite/APZCTreeManager.cpp
+++ b/gfx/layers/composite/APZCTreeManager.cpp
@@ -615,26 +615,16 @@ APZCTreeManager::UpdateZoomConstraintsRe
     // We can have subtrees with their own layers id - leave those alone.
     if (!child->IsRootForLayersId()) {
       UpdateZoomConstraintsRecursively(child, aAllowZoom, aMinScale, aMaxScale);
     }
   }
 }
 
 void
-APZCTreeManager::UpdateScrollOffset(const ScrollableLayerGuid& aGuid,
-                                    const CSSPoint& aScrollOffset)
-{
-  nsRefPtr<AsyncPanZoomController> apzc = GetTargetAPZC(aGuid);
-  if (apzc) {
-    apzc->UpdateScrollOffset(aScrollOffset);
-  }
-}
-
-void
 APZCTreeManager::CancelAnimation(const ScrollableLayerGuid &aGuid)
 {
   nsRefPtr<AsyncPanZoomController> apzc = GetTargetAPZC(aGuid);
   if (apzc) {
     apzc->CancelAnimation();
   }
 }
 
--- a/gfx/layers/composite/APZCTreeManager.h
+++ b/gfx/layers/composite/APZCTreeManager.h
@@ -168,24 +168,16 @@ public:
    * minimum-scale, maximum-scale, and user-scalable.
    */
   void UpdateZoomConstraints(const ScrollableLayerGuid& aGuid,
                              bool aAllowZoom,
                              const CSSToScreenScale& aMinScale,
                              const CSSToScreenScale& aMaxScale);
 
   /**
-   * Update mFrameMetrics.mScrollOffset to the given offset.
-   * This is necessary in cases where a scroll is not caused by user
-   * input (for example, a content scrollTo()).
-   */
-  void UpdateScrollOffset(const ScrollableLayerGuid& aGuid,
-                          const CSSPoint& aScrollOffset);
-
-  /**
    * Cancels any currently running animation. Note that all this does is set the
    * state of the AsyncPanZoomController back to NOTHING, but it is the
    * animation's responsibility to check this before advancing.
    */
   void CancelAnimation(const ScrollableLayerGuid &aGuid);
 
   /**
    * Calls Destroy() on all APZC instances attached to the tree, and resets the
--- a/gfx/layers/ipc/AsyncPanZoomController.cpp
+++ b/gfx/layers/ipc/AsyncPanZoomController.cpp
@@ -56,25 +56,26 @@
 
 // #define APZC_ENABLE_RENDERTRACE
 
 #define APZC_LOG(...)
 // #define APZC_LOG(...) printf_stderr("APZC: " __VA_ARGS__)
 #define APZC_LOG_FM(fm, prefix, ...) \
   APZC_LOG(prefix ":" \
            " i=(%ld %lld) cb=(%d %d %d %d) dp=(%.3f %.3f %.3f %.3f) v=(%.3f %.3f %.3f %.3f) " \
-           "s=(%.3f %.3f) sr=(%.3f %.3f %.3f %.3f) z=(%.3f %.3f %.3f %.3f)\n", \
+           "s=(%.3f %.3f) sr=(%.3f %.3f %.3f %.3f) z=(%.3f %.3f %.3f %.3f) %d\n", \
            __VA_ARGS__, \
            fm.mPresShellId, fm.mScrollId, \
            fm.mCompositionBounds.x, fm.mCompositionBounds.y, fm.mCompositionBounds.width, fm.mCompositionBounds.height, \
            fm.mDisplayPort.x, fm.mDisplayPort.y, fm.mDisplayPort.width, fm.mDisplayPort.height, \
            fm.mViewport.x, fm.mViewport.y, fm.mViewport.width, fm.mViewport.height, \
            fm.mScrollOffset.x, fm.mScrollOffset.y, \
            fm.mScrollableRect.x, fm.mScrollableRect.y, fm.mScrollableRect.width, fm.mScrollableRect.height, \
-           fm.mDevPixelsPerCSSPixel.scale, fm.mResolution.scale, fm.mCumulativeResolution.scale, fm.mZoom.scale); \
+           fm.mDevPixelsPerCSSPixel.scale, fm.mResolution.scale, fm.mCumulativeResolution.scale, fm.mZoom.scale, \
+           fm.mUpdateScrollOffset); \
 
 // Static helper functions
 namespace {
 
 int32_t
 WidgetModifiersToDOMModifiers(mozilla::Modifiers aModifiers)
 {
   int32_t result = 0;
@@ -1470,16 +1471,26 @@ void AsyncPanZoomController::NotifyLayer
     // determined by Gecko and our copy in mFrameMetrics may be stale.
     mFrameMetrics.mScrollableRect = aLayerMetrics.mScrollableRect;
     mFrameMetrics.mCompositionBounds = aLayerMetrics.mCompositionBounds;
     float parentResolutionChange = aLayerMetrics.GetParentResolution().scale
                                  / mFrameMetrics.GetParentResolution().scale;
     mFrameMetrics.mZoom.scale *= parentResolutionChange;
     mFrameMetrics.mResolution = aLayerMetrics.mResolution;
     mFrameMetrics.mCumulativeResolution = aLayerMetrics.mCumulativeResolution;
+
+    // If the layers update was not triggered by our own repaint request, then
+    // we want to take the new scroll offset.
+    if (aLayerMetrics.mUpdateScrollOffset) {
+      APZC_LOG("Updating scroll offset from (%f, %f) to (%f, %f)\n",
+        mFrameMetrics.mScrollOffset.x, mFrameMetrics.mScrollOffset.y,
+        aLayerMetrics.mScrollOffset.x, aLayerMetrics.mScrollOffset.y);
+
+      mFrameMetrics.mScrollOffset = aLayerMetrics.mScrollOffset;
+    }
   }
 
   if (needContentRepaint) {
     RequestContentRepaint();
   }
 }
 
 const FrameMetrics& AsyncPanZoomController::GetFrameMetrics() {
@@ -1712,26 +1723,16 @@ void AsyncPanZoomController::SendAsyncSc
     scrollableSize = mFrameMetrics.mScrollableRect.Size();
     contentRect = mFrameMetrics.CalculateCompositedRectInCssPixels();
     contentRect.MoveTo(mCurrentAsyncScrollOffset);
   }
 
   controller->SendAsyncScrollDOMEvent(isRoot, contentRect, scrollableSize);
 }
 
-void AsyncPanZoomController::UpdateScrollOffset(const CSSPoint& aScrollOffset)
-{
-  APZC_LOG("Updating scroll offset from (%f, %f) to (%f, %f)\n",
-    mFrameMetrics.mScrollOffset.x, mFrameMetrics.mScrollOffset.y,
-    aScrollOffset.x, aScrollOffset.y);
-
-  ReentrantMonitorAutoEnter lock(mMonitor);
-  mFrameMetrics.mScrollOffset = aScrollOffset;
-}
-
 bool AsyncPanZoomController::Matches(const ScrollableLayerGuid& aGuid)
 {
   return aGuid == ScrollableLayerGuid(mLayersId, mFrameMetrics);
 }
 
 void AsyncPanZoomController::GetGuid(ScrollableLayerGuid* aGuidOut)
 {
   if (!aGuidOut) {
--- a/gfx/layers/ipc/AsyncPanZoomController.h
+++ b/gfx/layers/ipc/AsyncPanZoomController.h
@@ -255,23 +255,16 @@ public:
 
   /**
    * Sync panning and zooming animation using a fixed frame time.
    * This will ensure that we animate the APZC correctly with other external
    * animations to the same timestamp.
    */
   static void SetFrameTime(const TimeStamp& aMilliseconds);
 
-  /**
-   * Update mFrameMetrics.mScrollOffset to the given offset.
-   * This is necessary in cases where a scroll is not caused by user
-   * input (for example, a content scrollTo()).
-   */
-  void UpdateScrollOffset(const CSSPoint& aScrollOffset);
-
   void StartAnimation(AsyncPanZoomAnimation* aAnimation);
 
   /**
    * Cancels any currently running animation. Note that all this does is set the
    * state of the AsyncPanZoomController back to NOTHING, but it is the
    * animation's responsibility to check this before advancing.
    */
   void CancelAnimation();
--- a/layout/ipc/RenderFrameParent.cpp
+++ b/layout/ipc/RenderFrameParent.cpp
@@ -1110,25 +1110,16 @@ RenderFrameParent::UpdateZoomConstraints
     mContentController->SaveZoomConstraints(aAllowZoom, aMinZoom, aMaxZoom);
   }
   if (GetApzcTreeManager()) {
     GetApzcTreeManager()->UpdateZoomConstraints(ScrollableLayerGuid(mLayersId, aPresShellId, aViewId),
                                                 aAllowZoom, aMinZoom, aMaxZoom);
   }
 }
 
-void
-RenderFrameParent::UpdateScrollOffset(uint32_t aPresShellId, ViewID aViewId, const CSSIntPoint& aScrollOffset)
-{
-  if (GetApzcTreeManager()) {
-    GetApzcTreeManager()->UpdateScrollOffset(ScrollableLayerGuid(mLayersId, aPresShellId, aViewId),
-                                             aScrollOffset);
-  }
-}
-
 bool
 RenderFrameParent::HitTest(const nsRect& aRect)
 {
   return mTouchRegion.Contains(aRect);
 }
 
 }  // namespace layout
 }  // namespace mozilla
--- a/layout/ipc/RenderFrameParent.h
+++ b/layout/ipc/RenderFrameParent.h
@@ -119,20 +119,16 @@ public:
 
   void UpdateZoomConstraints(uint32_t aPresShellId,
                              ViewID aViewId,
                              bool aIsRoot,
                              bool aAllowZoom,
                              const CSSToScreenScale& aMinZoom,
                              const CSSToScreenScale& aMaxZoom);
 
-  void UpdateScrollOffset(uint32_t aPresShellId,
-                          ViewID aViewId,
-                          const CSSIntPoint& aScrollOffset);
-
   bool HitTest(const nsRect& aRect);
 
 protected:
   void ActorDestroy(ActorDestroyReason why) MOZ_OVERRIDE;
 
   virtual bool RecvNotifyCompositorTransaction() MOZ_OVERRIDE;
 
   virtual bool RecvUpdateHitRegion(const nsRegion& aRegion) MOZ_OVERRIDE;
--- a/mobile/android/base/gfx/GeckoLayerClient.java
+++ b/mobile/android/base/gfx/GeckoLayerClient.java
@@ -378,19 +378,16 @@ public class GeckoLayerClient implements
             switch (type) {
             default:
             case UPDATE:
                 // Keep the old viewport size
                 newMetrics = messageMetrics.setViewportSize(oldMetrics.getWidth(), oldMetrics.getHeight());
                 if (!oldMetrics.fuzzyEquals(newMetrics)) {
                     abortPanZoomAnimation();
                 }
-                mPanZoomController.updateScrollOffset(
-                		messageMetrics.viewportRectLeft / messageMetrics.zoomFactor,
-                		messageMetrics.viewportRectTop / messageMetrics.zoomFactor);
                 break;
             case PAGE_SIZE:
                 // adjust the page dimensions to account for differences in zoom
                 // between the rendered content (which is what Gecko tells us)
                 // and our zoom level (which may have diverged).
                 float scaleFactor = oldMetrics.zoomFactor / messageMetrics.zoomFactor;
                 newMetrics = oldMetrics.setPageRect(RectUtils.scale(messageMetrics.getPageRect(), scaleFactor), messageMetrics.getCssPageRect());
                 break;
--- a/mobile/android/base/gfx/JavaPanZoomController.java
+++ b/mobile/android/base/gfx/JavaPanZoomController.java
@@ -1453,17 +1453,12 @@ class JavaPanZoomController
     }
 
     @Override
     public int getOverScrollMode() {
         return mX.getOverScrollMode();
     }
 
     @Override
-    public void updateScrollOffset(float cssX, float cssY) {
-        // Nothing to update, this class doesn't store the scroll offset locally.
-    }
-
-    @Override
     public void setOverscrollHandler(final Overscroll handler) {
         mOverscroll = handler;
     }
 }
--- a/mobile/android/base/gfx/NativePanZoomController.java
+++ b/mobile/android/base/gfx/NativePanZoomController.java
@@ -98,13 +98,11 @@ class NativePanZoomController implements
         public void run() {
             long nextDelay = runDelayedCallback();
             if (nextDelay >= 0) {
                 mTarget.postDelayed(this, nextDelay);
             }
         }
     }
 
-    public native void updateScrollOffset(float cssX, float cssY);
-
     public void setOverscrollHandler(final Overscroll listener) {
     }
 }
--- a/mobile/android/base/gfx/PanZoomController.java
+++ b/mobile/android/base/gfx/PanZoomController.java
@@ -39,12 +39,10 @@ public interface PanZoomController {
 
     public void pageRectUpdated();
     public void abortPanning();
     public void abortAnimation();
 
     public void setOverScrollMode(int overscrollMode);
     public int getOverScrollMode();
 
-    public void updateScrollOffset(float cssX, float cssY);
-
     public void setOverscrollHandler(final Overscroll controller);
 }
--- a/mozglue/android/jni-stubs.inc
+++ b/mozglue/android/jni-stubs.inc
@@ -528,35 +528,16 @@ Java_org_mozilla_gecko_gfx_NativePanZoom
 #endif
 
 #ifdef JNI_BINDINGS
   xul_dlsym("Java_org_mozilla_gecko_gfx_NativePanZoomController_getOverScrollMode", &f_Java_org_mozilla_gecko_gfx_NativePanZoomController_getOverScrollMode);
 #endif
 
 #ifdef JNI_STUBS
 
-typedef void (*Java_org_mozilla_gecko_gfx_NativePanZoomController_updateScrollOffset_t)(JNIEnv *, jobject, jfloat, jfloat);
-static Java_org_mozilla_gecko_gfx_NativePanZoomController_updateScrollOffset_t f_Java_org_mozilla_gecko_gfx_NativePanZoomController_updateScrollOffset;
-extern "C" NS_EXPORT void JNICALL
-Java_org_mozilla_gecko_gfx_NativePanZoomController_updateScrollOffset(JNIEnv * arg0, jobject arg1, jfloat arg2, jfloat arg3) {
-    if (!f_Java_org_mozilla_gecko_gfx_NativePanZoomController_updateScrollOffset) {
-        arg0->ThrowNew(arg0->FindClass("java/lang/UnsupportedOperationException"),
-                       "JNI Function called before it was loaded");
-        return ;
-    }
-     f_Java_org_mozilla_gecko_gfx_NativePanZoomController_updateScrollOffset(arg0, arg1, arg2, arg3);
-}
-#endif
-
-#ifdef JNI_BINDINGS
-  xul_dlsym("Java_org_mozilla_gecko_gfx_NativePanZoomController_updateScrollOffset", &f_Java_org_mozilla_gecko_gfx_NativePanZoomController_updateScrollOffset);
-#endif
-
-#ifdef JNI_STUBS
-
 typedef jboolean (*Java_org_mozilla_gecko_ANRReporter_requestNativeStack_t)(JNIEnv *, jclass);
 static Java_org_mozilla_gecko_ANRReporter_requestNativeStack_t f_Java_org_mozilla_gecko_ANRReporter_requestNativeStack;
 extern "C" NS_EXPORT jboolean JNICALL
 Java_org_mozilla_gecko_ANRReporter_requestNativeStack(JNIEnv * arg0, jclass arg1) {
     if (!f_Java_org_mozilla_gecko_ANRReporter_requestNativeStack) {
         arg0->ThrowNew(arg0->FindClass("java/lang/UnsupportedOperationException"),
                        "JNI Function called before it was loaded");
         return false;
--- a/widget/android/AndroidJNI.cpp
+++ b/widget/android/AndroidJNI.cpp
@@ -944,26 +944,16 @@ Java_org_mozilla_gecko_gfx_NativePanZoom
 
 NS_EXPORT jint JNICALL
 Java_org_mozilla_gecko_gfx_NativePanZoomController_getOverScrollMode(JNIEnv* env, jobject instance)
 {
     // FIXME implement this
     return 0;
 }
 
-NS_EXPORT void JNICALL
-Java_org_mozilla_gecko_gfx_NativePanZoomController_updateScrollOffset(JNIEnv* env, jobject instance, jfloat cssX, jfloat cssY)
-{
-    APZCTreeManager *controller = nsWindow::GetAPZCTreeManager();
-    if (controller) {
-        // TODO: Pass in correct values for presShellId and viewId.
-        controller->UpdateScrollOffset(ScrollableLayerGuid(nsWindow::RootLayerTreeId(), 0, 0), CSSPoint(cssX, cssY));
-    }
-}
-
 NS_EXPORT jboolean JNICALL
 Java_org_mozilla_gecko_ANRReporter_requestNativeStack(JNIEnv*, jclass)
 {
     if (profiler_is_active()) {
         // Don't proceed if profiler is already running
         return JNI_FALSE;
     }
     // WARNING: we are on the ANR reporter thread at this point and it is
--- a/widget/windows/winrt/APZController.cpp
+++ b/widget/windows/winrt/APZController.cpp
@@ -78,27 +78,22 @@ GetDOMTargets(uint64_t aScrollId,
   }
 
   return true;
 }
 
 class RequestContentRepaintEvent : public nsRunnable
 {
   typedef mozilla::layers::FrameMetrics FrameMetrics;
-  typedef mozilla::layers::ScrollableLayerGuid ScrollableLayerGuid;
 
 public:
   RequestContentRepaintEvent(const FrameMetrics& aFrameMetrics,
-                             nsIWidgetListener* aListener,
-                             CSSIntPoint* aLastOffsetOut,
-                             ScrollableLayerGuid* aLastScrollId) :
+                             nsIWidgetListener* aListener) :
     mFrameMetrics(aFrameMetrics),
-    mWidgetListener(aListener),
-    mLastOffsetOut(aLastOffsetOut),
-    mLastScrollIdOut(aLastScrollId)
+    mWidgetListener(aListener)
   {
   }
 
   NS_IMETHOD Run() {
     // This must be on the gecko thread since we access the dom
     MOZ_ASSERT(NS_IsMainThread());
 
 #ifdef DEBUG_CONTROLLER
@@ -130,43 +125,31 @@ public:
     // We're dealing with a tab, call UpdateRootFrame.
     nsCOMPtr<nsIDOMWindowUtils> utils;
     nsCOMPtr<nsIDOMWindow> window = subDocument->GetDefaultView();
     if (window) {
       utils = do_GetInterface(window);
       if (utils) {
         APZCCallbackHelper::UpdateRootFrame(utils, mFrameMetrics);
 
-        // Return the actual scroll value so we can use it to filter
-        // out scroll messages triggered by setting the display port.
-        if (mLastOffsetOut) {
-          *mLastOffsetOut = mozilla::gfx::RoundedToInt(mFrameMetrics.mScrollOffset);
-        }
-        if (mLastScrollIdOut) {
-          mLastScrollIdOut->mScrollId = mFrameMetrics.mScrollId;
-          mLastScrollIdOut->mPresShellId = mFrameMetrics.mPresShellId;
-        }
-
 #ifdef DEBUG_CONTROLLER
         WinUtils::Log("APZController: %I64d mDisplayPort: %0.2f %0.2f %0.2f %0.2f",
           mFrameMetrics.mScrollId,
           mFrameMetrics.mDisplayPort.x,
           mFrameMetrics.mDisplayPort.y,
           mFrameMetrics.mDisplayPort.width,
           mFrameMetrics.mDisplayPort.height);
 #endif
       }
     }
     return NS_OK;
   }
 protected:
   FrameMetrics mFrameMetrics;
   nsIWidgetListener* mWidgetListener;
-  CSSIntPoint* mLastOffsetOut;
-  ScrollableLayerGuid* mLastScrollIdOut;
 };
 
 void
 APZController::SetWidgetListener(nsIWidgetListener* aWidgetListener)
 {
   mWidgetListener = aWidgetListener;
 }
 
@@ -236,53 +219,24 @@ APZController::RequestContentRepaint(con
     return;
   }
 
 #ifdef DEBUG_CONTROLLER
   WinUtils::Log("APZController::RequestContentRepaint scrollid=%I64d",
     aFrameMetrics.mScrollId);
 #endif
   nsCOMPtr<nsIRunnable> r1 = new RequestContentRepaintEvent(aFrameMetrics,
-                                                            mWidgetListener,
-                                                            &mLastScrollOffset,
-                                                            &mLastScrollLayerGuid);
+                                                            mWidgetListener);
   if (!NS_IsMainThread()) {
     NS_DispatchToMainThread(r1);
   } else {
     r1->Run();
   }
 }
 
-// Content send us this when it detect content has scrolled via
-// a dom scroll event. Note we get these in response to dom scroll
-// events and as a result of apzc scrolling which we filter out.
-void
-APZController::UpdateScrollOffset(const mozilla::layers::ScrollableLayerGuid& aScrollLayerId,
-                                  CSSIntPoint& aScrollOffset)
-{
-#ifdef DEBUG_CONTROLLER
-  WinUtils::Log("APZController::UpdateScrollOffset: scrollid:%I64d == %I64d offsets: %d,%d == %d,%d",
-    aScrollLayerId.mScrollId, aScrollLayerId.mScrollId,
-    aScrollOffset.x, aScrollOffset.y,
-    mLastScrollOffset.x, mLastScrollOffset.y);
-#endif
-
-  // Bail if this the same scroll guid the apzc just scrolled and the offsets
-  // equal the offset the apzc set.
-  if (!sAPZC || (mLastScrollLayerGuid.mScrollId == aScrollLayerId.mScrollId &&
-                 mLastScrollLayerGuid.mPresShellId == aScrollLayerId.mPresShellId &&
-                 mLastScrollOffset == aScrollOffset)) {
-#ifdef DEBUG_CONTROLLER
-    WinUtils::Log("Skipping UpdateScrollOffset");
-#endif
-    return;
-  }
-  sAPZC->UpdateScrollOffset(aScrollLayerId, aScrollOffset);
-}
-
 void
 APZController::HandleDoubleTap(const CSSIntPoint& aPoint, int32_t aModifiers)
 {
   NS_ConvertASCIItoUTF16 data(
       nsPrintfCString("{ \"x\": %d, \"y\": %d, \"modifiers\": %d }",
       (int32_t)aPoint.x, (int32_t)aPoint.y, aModifiers));
   MetroUtils::FireObserver("Gesture:DoubleTap", data.get());
 }
--- a/widget/windows/winrt/APZController.h
+++ b/widget/windows/winrt/APZController.h
@@ -37,17 +37,16 @@ public:
   virtual void HandleLongTap(const mozilla::CSSIntPoint& aPoint, int32_t aModifiers);
   virtual void HandleLongTapUp(const mozilla::CSSIntPoint& aPoint, int32_t aModifiers);
   virtual void SendAsyncScrollDOMEvent(bool aIsRoot, const mozilla::CSSRect &aContentRect, const mozilla::CSSSize &aScrollableSize);
   virtual void PostDelayedTask(Task* aTask, int aDelayMs);
   virtual void NotifyTransformBegin(const ScrollableLayerGuid& aGuid);
   virtual void NotifyTransformEnd(const ScrollableLayerGuid& aGuid);
   
   void SetWidgetListener(nsIWidgetListener* aWidgetListener);
-  void UpdateScrollOffset(const mozilla::layers::ScrollableLayerGuid& aScrollLayerId, CSSIntPoint& aScrollOffset);
 
   bool HitTestAPZC(mozilla::ScreenIntPoint& aPoint);
   void TransformCoordinateToGecko(const mozilla::ScreenIntPoint& aPoint,
                                   LayoutDeviceIntPoint* aRefPointOut);
   void ContentReceivedTouch(const ScrollableLayerGuid& aGuid, bool aPreventDefault);
   nsEventStatus ReceiveInputEvent(mozilla::WidgetInputEvent* aEvent,
                                   ScrollableLayerGuid* aOutTargetGuid);
   nsEventStatus ReceiveInputEvent(mozilla::WidgetInputEvent* aInEvent,
@@ -55,13 +54,11 @@ public:
                                   mozilla::WidgetInputEvent* aOutEvent);
 
 public:
   // todo: make this a member variable as prep for multiple views
   static nsRefPtr<mozilla::layers::APZCTreeManager> sAPZC;
 
 private:
   nsIWidgetListener* mWidgetListener;
-  ScrollableLayerGuid mLastScrollLayerGuid;
-  CSSIntPoint mLastScrollOffset;
 };
 
 } } }
--- a/widget/windows/winrt/MetroWidget.cpp
+++ b/widget/windows/winrt/MetroWidget.cpp
@@ -1584,37 +1584,17 @@ MetroWidget::HasPendingInputEvent()
     return true;
   return false;
 }
 
 NS_IMETHODIMP
 MetroWidget::Observe(nsISupports *subject, const char *topic, const PRUnichar *data)
 {
   NS_ENSURE_ARG_POINTER(topic);
-  if (!strcmp(topic, "apzc-scroll-offset-changed")) {
-    uint64_t scrollId;
-    int32_t presShellId;
-    CSSIntPoint scrollOffset;
-    int matched = sscanf(NS_LossyConvertUTF16toASCII(data).get(),
-                         "%llu %d (%d, %d)",
-                         &scrollId,
-                         &presShellId,
-                         &scrollOffset.x,
-                         &scrollOffset.y);
-    if (matched != 4) {
-      NS_WARNING("Malformed scroll-offset-changed message");
-      return NS_ERROR_UNEXPECTED;
-    }
-    if (!mController) {
-      return NS_ERROR_UNEXPECTED;
-    }
-    mController->UpdateScrollOffset(ScrollableLayerGuid(mRootLayerTreeId, presShellId, scrollId),
-                                    scrollOffset);
-  }
-  else if (!strcmp(topic, "apzc-zoom-to-rect")) {
+  if (!strcmp(topic, "apzc-zoom-to-rect")) {
     CSSRect rect = CSSRect();
     uint64_t viewId = 0;
     int32_t presShellId = 0;
 
     int reScan = swscanf(data, L"%f,%f,%f,%f,%d,%llu",
                  &rect.x, &rect.y, &rect.width, &rect.height,
                  &presShellId, &viewId);
     if(reScan != 6) {