Bug 1493742 - When accepting a layout viewport update from the main thread, constrain its position to enclose the visual viewport. r=kats, a=pascalc
authorBotond Ballo <botond@mozilla.com>
Wed, 24 Oct 2018 18:14:55 +0000
changeset 492966 032ed494717a
parent 492965 defc169a1ee3
child 492967 b71bed0c6a40
push id1843
push userryanvm@gmail.com
push dateMon, 05 Nov 2018 14:45:45 +0000
treeherdermozilla-release@b71bed0c6a40 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerskats, pascalc
bugs1493742
milestone63.0.2
Bug 1493742 - When accepting a layout viewport update from the main thread, constrain its position to enclose the visual viewport. r=kats, a=pascalc 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
@@ -4395,16 +4395,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() {