diff --git a/dom/ipc/TabChild.cpp b/dom/ipc/TabChild.cpp index 1cd1074a82c..3bcad6e62a8 100644 --- a/dom/ipc/TabChild.cpp +++ b/dom/ipc/TabChild.cpp @@ -539,7 +539,6 @@ TabChildBase::UpdateFrameHandler(const FrameMetrics& aFrameMetrics) nsCOMPtr utils(GetDOMWindowUtils()); if (APZCCallbackHelper::HasValidPresShellId(utils, aFrameMetrics)) { mLastRootMetrics = ProcessUpdateFrame(aFrameMetrics); - APZCCallbackHelper::UpdateCallbackTransform(aFrameMetrics, mLastRootMetrics); return true; } } else { @@ -550,7 +549,6 @@ TabChildBase::UpdateFrameHandler(const FrameMetrics& aFrameMetrics) if (content) { FrameMetrics newSubFrameMetrics(aFrameMetrics); APZCCallbackHelper::UpdateSubFrame(content, newSubFrameMetrics); - APZCCallbackHelper::UpdateCallbackTransform(aFrameMetrics, newSubFrameMetrics); return true; } } diff --git a/gfx/layers/apz/util/APZCCallbackHelper.cpp b/gfx/layers/apz/util/APZCCallbackHelper.cpp index d8f06beafc9..988717a9090 100644 --- a/gfx/layers/apz/util/APZCCallbackHelper.cpp +++ b/gfx/layers/apz/util/APZCCallbackHelper.cpp @@ -111,8 +111,9 @@ ScrollFrameTo(nsIScrollableFrame* aFrame, const CSSPoint& aPoint, bool& aSuccess * requested in |aMetrics|. * The scroll offset in |aMetrics| is updated to reflect the actual scroll * position. - * The displayport stored in |aMetrics| is updated to reflect any difference - * between the requested and actual scroll positions. + * The displayport stored in |aMetrics| and the callback-transform stored on + * the content are updated to reflect any difference between the requested + * and actual scroll positions. */ static void ScrollFrame(nsIContent* aContent, @@ -121,7 +122,8 @@ ScrollFrame(nsIContent* aContent, // Scroll the window to the desired spot nsIScrollableFrame* sf = nsLayoutUtils::FindScrollableFrameFor(aMetrics.GetScrollId()); bool scrollUpdated = false; - CSSPoint actualScrollOffset = ScrollFrameTo(sf, aMetrics.GetScrollOffset(), scrollUpdated); + CSSPoint apzScrollOffset = aMetrics.GetScrollOffset(); + CSSPoint actualScrollOffset = ScrollFrameTo(sf, apzScrollOffset, scrollUpdated); if (scrollUpdated) { // Correct the display port due to the difference between mScrollOffset and the @@ -138,6 +140,16 @@ ScrollFrame(nsIContent* aContent, } aMetrics.SetScrollOffset(actualScrollOffset); + + // APZ transforms inputs assuming we applied the exact scroll offset it + // requested (|apzScrollOffset|). Since we may not have, record the difference + // between what APZ asked for and what we actually applied, and apply it to + // input events to compensate. + if (aContent) { + CSSPoint scrollDelta = apzScrollOffset - actualScrollOffset; + aContent->SetProperty(nsGkAtoms::apzCallbackTransform, new CSSPoint(scrollDelta), + nsINode::DeleteProperty); + } } static void @@ -300,18 +312,6 @@ APZCCallbackHelper::AcknowledgeScrollUpdate(const FrameMetrics::ViewID& aScrollI } } -void -APZCCallbackHelper::UpdateCallbackTransform(const FrameMetrics& aApzcMetrics, const FrameMetrics& aActualMetrics) -{ - nsCOMPtr content = nsLayoutUtils::FindContentFor(aApzcMetrics.GetScrollId()); - if (!content) { - return; - } - CSSPoint scrollDelta = aApzcMetrics.GetScrollOffset() - aActualMetrics.GetScrollOffset(); - content->SetProperty(nsGkAtoms::apzCallbackTransform, new CSSPoint(scrollDelta), - nsINode::DeleteProperty); -} - CSSPoint APZCCallbackHelper::ApplyCallbackTransform(const CSSPoint& aInput, const ScrollableLayerGuid& aGuid, diff --git a/gfx/layers/apz/util/APZCCallbackHelper.h b/gfx/layers/apz/util/APZCCallbackHelper.h index a0c2b48ba77..838e5b71d61 100644 --- a/gfx/layers/apz/util/APZCCallbackHelper.h +++ b/gfx/layers/apz/util/APZCCallbackHelper.h @@ -75,19 +75,6 @@ public: static void AcknowledgeScrollUpdate(const FrameMetrics::ViewID& aScrollId, const uint32_t& aScrollGeneration); - /* Save an "input transform" property on the content element corresponding to - the scrollable content. This is needed because in some cases when the APZ code - sends a paint request via the GeckoContentController interface, we don't always - apply the scroll offset that was requested. Since the APZ code doesn't know - that we didn't apply it, it will transform inputs assuming that we had applied - it, and so we need to apply a fixup to the input to account for the fact that - we didn't. - The |aApzcMetrics| argument are the metrics that the APZ sent us, and the - |aActualMetrics| argument are the metrics representing the gecko state after we - applied some or all of the APZ metrics. */ - static void UpdateCallbackTransform(const FrameMetrics& aApzcMetrics, - const FrameMetrics& aActualMetrics); - /* Apply an "input transform" to the given |aInput| and return the transformed value. The input transform applied is the one for the content element corresponding to |aGuid|; this is populated in a previous call to UpdateCallbackTransform. See that diff --git a/widget/android/APZCCallbackHandler.cpp b/widget/android/APZCCallbackHandler.cpp index c1a6b04bafc..8c4b52ef8f8 100644 --- a/widget/android/APZCCallbackHandler.cpp +++ b/widget/android/APZCCallbackHandler.cpp @@ -90,7 +90,6 @@ APZCCallbackHandler::RequestContentRepaint(const FrameMetrics& aFrameMetrics) if (utils && APZCCallbackHelper::HasValidPresShellId(utils, aFrameMetrics)) { FrameMetrics metrics = aFrameMetrics; APZCCallbackHelper::UpdateRootFrame(utils, metrics); - APZCCallbackHelper::UpdateCallbackTransform(aFrameMetrics, metrics); } } else { // aFrameMetrics.mIsRoot is false, so we are trying to update a subframe. @@ -99,7 +98,6 @@ APZCCallbackHandler::RequestContentRepaint(const FrameMetrics& aFrameMetrics) if (content) { FrameMetrics newSubFrameMetrics(aFrameMetrics); APZCCallbackHelper::UpdateSubFrame(content, newSubFrameMetrics); - APZCCallbackHelper::UpdateCallbackTransform(aFrameMetrics, newSubFrameMetrics); } } }