Bug 1493742 - When accepting a layout viewport update from the main thread, constrain its position to enclose the visual viewport. r=kats, a=RyanVM
authorBotond Ballo <botond@mozilla.com>
Wed, 24 Oct 2018 18:14:55 +0000
changeset 498186 805ba967bcb5ad545958544a1ad0206d900a3fe8
parent 498185 08d5049ad5d9690ed1f80409a58a9d58415437e6
child 498187 2e302b256039185f559d5ac6f621783bc83cbfa5
push id10058
push userryanvm@gmail.com
push dateMon, 29 Oct 2018 13:32:17 +0000
treeherdermozilla-beta@52d060761f0c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerskats, RyanVM
bugs1493742
milestone64.0
Bug 1493742 - When accepting a layout viewport update from the main thread, constrain its position to enclose the visual viewport. r=kats, a=RyanVM 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
@@ -4422,16 +4422,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() {