From 9491a614c4e0e89e3da6e8ab3cf7818debda5d38 Mon Sep 17 00:00:00 2001 From: Kartikaya Gupta Date: Tue, 8 Dec 2015 21:00:30 -0500 Subject: [PATCH] Back out three patches from bug 1228407 on a CLOSED TREE for causing various mochitest failures. r=backout --HG-- extra : commitid : 7gaWjh5Noye --- gfx/layers/apz/src/AsyncPanZoomController.cpp | 75 ++++++++----------- gfx/layers/apz/src/AsyncPanZoomController.h | 7 +- layout/generic/nsGfxScrollFrame.cpp | 20 ----- layout/generic/nsGfxScrollFrame.h | 1 - 4 files changed, 35 insertions(+), 68 deletions(-) diff --git a/gfx/layers/apz/src/AsyncPanZoomController.cpp b/gfx/layers/apz/src/AsyncPanZoomController.cpp index 9481593e10e4..ad816df735b6 100644 --- a/gfx/layers/apz/src/AsyncPanZoomController.cpp +++ b/gfx/layers/apz/src/AsyncPanZoomController.cpp @@ -797,12 +797,6 @@ public: return true; } - - void SetDestination(const nsPoint& aNewDestination) { - mXAxisModel.SetDestination(static_cast(aNewDestination.x)); - mYAxisModel.SetDestination(static_cast(aNewDestination.y)); - } - private: AsyncPanZoomController& mApzc; AxisPhysicsMSDModel mXAxisModel, mYAxisModel; @@ -3229,22 +3223,20 @@ void AsyncPanZoomController::NotifyLayersUpdated(const FrameMetrics& aLayerMetri ToString(mFrameMetrics.GetScrollOffset()).c_str(), ToString(aLayerMetrics.GetScrollOffset()).c_str()); - // Send an acknowledgement with the new scroll generation so that any - // repaint requests later in this function go through. - // Because of the scroll generation update, any inflight paint requests are - // going to be ignored by layout, and so mLastDispatchedPaintMetrics - // becomes incorrect for the purposes of calculating the LD transform. To - // correct this we need to update mLastDispatchedPaintMetrics to be the - // last thing we know was painted by Gecko. mFrameMetrics.CopyScrollInfoFrom(aLayerMetrics); - AcknowledgeScrollUpdate(); - mLastDispatchedPaintMetrics = aLayerMetrics; // Cancel the animation (which might also trigger a repaint request) // after we update the scroll offset above. Otherwise we can be left // in a state where things are out of sync. CancelAnimation(); + // Because of the scroll offset update, any inflight paint requests are + // going to be ignored by layout, and so mLastDispatchedPaintMetrics + // becomes incorrect for the purposes of calculating the LD transform. To + // correct this we need to update mLastDispatchedPaintMetrics to be the + // last thing we know was painted by Gecko. + mLastDispatchedPaintMetrics = aLayerMetrics; + // Since the scroll offset has changed, we need to recompute the // displayport margins and send them to layout. Otherwise there might be // scenarios where for example we scroll from the top of a page (where the @@ -3261,26 +3253,34 @@ void AsyncPanZoomController::NotifyLayersUpdated(const FrameMetrics& aLayerMetri // thread. This flag will be reset by the main thread when it receives // the scroll update acknowledgement. - APZC_LOG("%p smooth scrolling from %s to %s in state %d\n", this, + APZC_LOG("%p smooth scrolling from %s to %s\n", this, Stringify(mFrameMetrics.GetScrollOffset()).c_str(), - Stringify(aLayerMetrics.GetSmoothScrollOffset()).c_str(), - mState); + Stringify(aLayerMetrics.GetSmoothScrollOffset()).c_str()); - // See comment on the similar code in the |if (scrollOffsetUpdated)| block - // above. + CancelAnimation(); + + // It's important to not send repaint requests between this + // CopySmoothScrollInfo call and the sending of the scroll update + // acknowledgement below, otherwise that repaint request will get rejected + // on the main thread but mLastPaintRequestMetrics will have the new scroll + // generation; this would leave the main thread out of date. mFrameMetrics.CopySmoothScrollInfoFrom(aLayerMetrics); - AcknowledgeScrollUpdate(); mLastDispatchedPaintMetrics = aLayerMetrics; + StartSmoothScroll(ScrollSource::DOM); - if (mState == SMOOTH_SCROLL && mAnimation) { - APZC_LOG("%p updating destination on existing animation\n", this); - RefPtr animation( - static_cast(mAnimation.get())); - animation->SetDestination( - CSSPoint::ToAppUnits(aLayerMetrics.GetSmoothScrollOffset())); - } else { - CancelAnimation(); - StartSmoothScroll(ScrollSource::DOM); + scrollOffsetUpdated = true; // Ensure that AcknowledgeScrollUpdate is called + } + + if (scrollOffsetUpdated) { + // Once layout issues a scroll offset update, it becomes impervious to + // scroll offset updates from APZ until we acknowledge the update it sent. + // This prevents APZ updates from clobbering scroll updates from other + // more "legitimate" sources like content scripts. + RefPtr controller = GetGeckoContentController(); + if (controller) { + APZC_LOG("%p sending scroll update acknowledgement with gen %u\n", this, aLayerMetrics.GetScrollGeneration()); + controller->AcknowledgeScrollUpdate(aLayerMetrics.GetScrollId(), + aLayerMetrics.GetScrollGeneration()); } } @@ -3290,21 +3290,6 @@ void AsyncPanZoomController::NotifyLayersUpdated(const FrameMetrics& aLayerMetri UpdateSharedCompositorFrameMetrics(); } -void -AsyncPanZoomController::AcknowledgeScrollUpdate() const -{ - // Once layout issues a scroll offset update, it becomes impervious to - // scroll offset updates from APZ until we acknowledge the update it sent. - // This prevents APZ updates from clobbering scroll updates from other - // more "legitimate" sources like content scripts. - RefPtr controller = GetGeckoContentController(); - if (controller) { - APZC_LOG("%p sending scroll update acknowledgement with gen %u\n", this, mFrameMetrics.GetScrollGeneration()); - controller->AcknowledgeScrollUpdate(mFrameMetrics.GetScrollId(), - mFrameMetrics.GetScrollGeneration()); - } -} - const FrameMetrics& AsyncPanZoomController::GetFrameMetrics() const { mMonitor.AssertCurrentThreadIn(); return mFrameMetrics; diff --git a/gfx/layers/apz/src/AsyncPanZoomController.h b/gfx/layers/apz/src/AsyncPanZoomController.h index 7185ccdcdfb9..4bc1779cc7e9 100644 --- a/gfx/layers/apz/src/AsyncPanZoomController.h +++ b/gfx/layers/apz/src/AsyncPanZoomController.h @@ -829,6 +829,11 @@ private: PanGestureBlockState* CurrentPanGestureBlock(); + /* =================================================================== + * The functions and members in this section are used to manage + * pan gestures. + */ + private: /* =================================================================== * The functions and members in this section are used to manage @@ -884,8 +889,6 @@ private: // Returns whether overscroll is allowed during an event. bool AllowScrollHandoffInCurrentBlock() const; - void AcknowledgeScrollUpdate() const; - /* =================================================================== * The functions and members in this section are used to make ancestor chains * out of APZC instances. These chains can only be walked or manipulated diff --git a/layout/generic/nsGfxScrollFrame.cpp b/layout/generic/nsGfxScrollFrame.cpp index a2ece4707695..6323743cb220 100644 --- a/layout/generic/nsGfxScrollFrame.cpp +++ b/layout/generic/nsGfxScrollFrame.cpp @@ -2121,30 +2121,10 @@ ScrollFrameHelper::ScrollToWithOrigin(nsPoint aScrollPosition, } if (nsLayoutUtils::AsyncPanZoomEnabled(mOuter)) { - if (mApzSmoothScrollDestination == mDestination && - mScrollGeneration == sScrollGenerationCounter) { - // If we already sent APZ a smooth-scroll request to this - // destination with this generation (i.e. it was the last request - // we sent), then don't send another one because it is redundant. - // This is to avoid a scenario where pages do repeated scrollBy - // calls, incrementing the generation counter, and blocking APZ from - // syncing the scroll offset back to the main thread. - // Note that if we get two smooth-scroll requests to the same - // destination with some other scroll in between, mDestination will - // get reset and so we shouldn't have the problem where this check - // discards a legitimate smooth-scroll. - // Note: if there are two separate scrollframes both getting smooth - // scrolled at the same time, sScrollGenerationCounter can get - // incremented and this early-exit won't get taken. Bug 1231177 is - // on file for this. - return; - } - // The animation will be handled in the compositor, pass the // information needed to start the animation and skip the main-thread // animation for this scroll. mLastSmoothScrollOrigin = aOrigin; - mApzSmoothScrollDestination = mDestination; mScrollGeneration = ++sScrollGenerationCounter; if (!nsLayoutUtils::GetDisplayPort(mOuter->GetContent())) { diff --git a/layout/generic/nsGfxScrollFrame.h b/layout/generic/nsGfxScrollFrame.h index e048980dea47..4c3093ef250f 100644 --- a/layout/generic/nsGfxScrollFrame.h +++ b/layout/generic/nsGfxScrollFrame.h @@ -432,7 +432,6 @@ public: nsTArray mListeners; nsIAtom* mLastScrollOrigin; nsIAtom* mLastSmoothScrollOrigin; - nsPoint mApzSmoothScrollDestination; uint32_t mScrollGeneration; nsRect mScrollPort; // Where we're currently scrolling to, if we're scrolling asynchronously.