Bug 1280667 - Don't update the callback transform if the APZ repaint request was rejected by a concurrent main-thread scroll position update. r?botond draft
authorKartikaya Gupta <kgupta@mozilla.com>
Mon, 27 Jun 2016 12:20:30 -0400
changeset 381500 4c372235d949b9b397aab6d7cc7120e1fff4e36c
parent 381476 0e3f8401b804702c894eb5fdf7eae3cbdf618668
child 381501 08646916f72fa99caf0809c8f89032496909374e
push id21502
push userkgupta@mozilla.com
push dateMon, 27 Jun 2016 16:21:00 +0000
reviewersbotond
bugs1280667
milestone50.0a1
Bug 1280667 - Don't update the callback transform if the APZ repaint request was rejected by a concurrent main-thread scroll position update. r?botond MozReview-Commit-ID: 7jCdyN9H6T8
gfx/layers/apz/util/APZCCallbackHelper.cpp
--- a/gfx/layers/apz/util/APZCCallbackHelper.cpp
+++ b/gfx/layers/apz/util/APZCCallbackHelper.cpp
@@ -157,17 +157,25 @@ ScrollFrame(nsIContent* aContent,
   }
 
   aMetrics.SetScrollOffset(actualScrollOffset);
 
   // APZ transforms inputs assuming we applied the exact scroll offset it
   // requested (|apzScrollOffset|). Since we may not have, record the difference
   // between what APZ asked for and what we actually applied, and apply it to
   // input events to compensate.
-  if (aContent) {
+  // Note that if the main-thread had a change in its scroll position, we don't
+  // want to record that difference here, because it can be large and throw off
+  // input events by a large amount. It is also going to be transient, because
+  // any main-thread scroll position change will be synced to APZ and we will
+  // get another repaint request when APZ confirms. In the interval while this
+  // is happening we can just leave the callback transform as it was.
+  bool mainThreadScrollChanged =
+    sf && sf->CurrentScrollGeneration() != aMetrics.GetScrollGeneration();
+  if (aContent && !mainThreadScrollChanged) {
     CSSPoint scrollDelta = apzScrollOffset - actualScrollOffset;
     aContent->SetProperty(nsGkAtoms::apzCallbackTransform, new CSSPoint(scrollDelta),
                           nsINode::DeleteProperty<CSSPoint>);
   }
 }
 
 static void
 SetDisplayPortMargins(nsIPresShell* aPresShell,