Bug 1484597 - Clear the APZ callback transform when originating a main thread scroll offset update for the RCD-RSF. r=kats
authorBotond Ballo <botond@mozilla.com>
Fri, 21 Sep 2018 19:01:46 +0000
changeset 438162 bc99ca10fe66cd8b0334142f84bb7d8328eea4d3
parent 438161 595b2c7f7d8582ea80ddd7af1f865ee320934ec8
child 438163 951f04d1bb518e722e13b2a15580921590eb2b44
push id69917
push userbballo@mozilla.com
push dateTue, 25 Sep 2018 17:56:36 +0000
treeherderautoland@bc99ca10fe66 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerskats
bugs1484597
milestone64.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1484597 - Clear the APZ callback transform when originating a main thread scroll offset update for the RCD-RSF. r=kats Depends on D6076 Differential Revision: https://phabricator.services.mozilla.com/D6077
layout/generic/nsGfxScrollFrame.cpp
--- a/layout/generic/nsGfxScrollFrame.cpp
+++ b/layout/generic/nsGfxScrollFrame.cpp
@@ -2936,16 +2936,28 @@ ScrollFrameHelper::ScrollToImpl(nsPoint 
     !isScrollOriginDowngrade;
   if (allowScrollOriginChange) {
     mLastScrollOrigin = aOrigin;
     mAllowScrollOriginDowngrade = false;
   }
   mLastSmoothScrollOrigin = nullptr;
   mScrollGeneration = ++sScrollGenerationCounter;
 
+  // If the new scroll offset is going to clobber APZ's scroll offset, for
+  // the RCD-RSF this will have the effect of resetting the visual viewport
+  // offset to be the same as the new scroll (= layout viewport) offset.
+  // The APZ callback transform, which reflects the difference between these
+  // offsets, will subsequently be cleared. However, it we wait for APZ to
+  // clear it, the main thread could end up using the old value and get
+  // incorrect results, so just clear it now.
+  if (mIsRoot && nsLayoutUtils::CanScrollOriginClobberApz(mLastScrollOrigin)) {
+    content->SetProperty(nsGkAtoms::apzCallbackTransform, new CSSPoint(),
+                         nsINode::DeleteProperty<CSSPoint>);
+  }
+
   ScrollVisual();
 
   bool schedulePaint = true;
   if (nsLayoutUtils::AsyncPanZoomEnabled(mOuter) &&
       !nsLayoutUtils::ShouldDisableApzForElement(content) &&
       gfxPrefs::APZPaintSkipping()) {
     // If APZ is enabled with paint-skipping, there are certain conditions in
     // which we can skip paints: