Bug 1228407 - Rearrange some code by extracting a helper function. r=botond

--HG--
extra : commitid : EZYicbcIoH9
This commit is contained in:
Kartikaya Gupta 2015-12-09 10:13:35 -05:00
parent 6c7c3b6adf
commit 87a2795095
2 changed files with 34 additions and 34 deletions

View File

@ -3164,6 +3164,9 @@ void AsyncPanZoomController::NotifyLayersUpdated(const FrameMetrics& aLayerMetri
CancelAnimation();
mFrameMetrics = aLayerMetrics;
if (scrollOffsetUpdated) {
AcknowledgeScrollUpdate();
}
mLastDispatchedPaintMetrics = aLayerMetrics;
ShareCompositorFrameMetrics();
@ -3223,20 +3226,22 @@ 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
@ -3257,31 +3262,14 @@ void AsyncPanZoomController::NotifyLayersUpdated(const FrameMetrics& aLayerMetri
Stringify(mFrameMetrics.GetScrollOffset()).c_str(),
Stringify(aLayerMetrics.GetSmoothScrollOffset()).c_str());
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.
// See comment on the similar code in the |if (scrollOffsetUpdated)| block
// above.
mFrameMetrics.CopySmoothScrollInfoFrom(aLayerMetrics);
AcknowledgeScrollUpdate();
mLastDispatchedPaintMetrics = aLayerMetrics;
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<GeckoContentController> controller = GetGeckoContentController();
if (controller) {
APZC_LOG("%p sending scroll update acknowledgement with gen %u\n", this, aLayerMetrics.GetScrollGeneration());
controller->AcknowledgeScrollUpdate(aLayerMetrics.GetScrollId(),
aLayerMetrics.GetScrollGeneration());
}
}
if (needContentRepaint) {
@ -3290,6 +3278,21 @@ 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<GeckoContentController> 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;

View File

@ -829,11 +829,6 @@ 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
@ -889,6 +884,8 @@ 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