Bug 1493742 - When accepting a layout viewport update from the main thread, constrain its position to enclose the visual viewport. r=kats
authorBotond Ballo <botond@mozilla.com>
Wed, 24 Oct 2018 18:14:55 +0000
changeset 491190 1d3872dd20e192fba9c2e2f2dd4cff1e476e869a
parent 491189 4833b89bb969cf1709eba8f8960136c85e750d94
child 491191 fb10b0a27752dd20111cf8790f6d3fbde9513d91
push id247
push userfmarier@mozilla.com
push dateSat, 27 Oct 2018 01:06:44 +0000
reviewerskats
bugs1493742
milestone65.0a1
Bug 1493742 - When accepting a layout viewport update from the main thread, constrain its position to enclose the visual viewport. r=kats APZ wants the *size* of the layout viewport from the main thread, but it knows the position better. Differential Revision: https://phabricator.services.mozilla.com/D9448
gfx/layers/apz/src/AsyncPanZoomController.cpp
--- a/gfx/layers/apz/src/AsyncPanZoomController.cpp
+++ b/gfx/layers/apz/src/AsyncPanZoomController.cpp
@@ -4426,16 +4426,26 @@ void AsyncPanZoomController::NotifyLayer
     // above.
     Metrics().CopySmoothScrollInfoFrom(aLayerMetrics);
     needContentRepaint = true;
     mExpectedGeckoMetrics = aLayerMetrics;
 
     SmoothScrollTo(Metrics().GetSmoothScrollOffset());
   }
 
+  if (viewportUpdated) {
+    // While we want to accept the main thread's layout viewport _size_,
+    // its position may be out of date in light of async scrolling, to
+    // adjust it if necessary to make sure it continues to enclose the
+    // visual viewport.
+    // Note: it's important to do this _after_ we've accepted any
+    // updated composition bounds.
+    Metrics().RecalculateViewportOffset();
+  }
+
   if (needContentRepaint) {
     // This repaint request is not driven by a user action on the APZ side
     RequestContentRepaint(false);
   }
   UpdateSharedCompositorFrameMetrics();
 }
 
 FrameMetrics& AsyncPanZoomController::Metrics() {