Bug 1364622 - Consider the async transforms on the scroll thumb when computing the drag start offset during APZ initiation of scrollbar dragging. r=kats
authorBotond Ballo <botond@mozilla.com>
Wed, 17 May 2017 15:03:15 -0400
changeset 579847 1406cf44ee8354e732ba0d4e066c3a0de4ce4b77
parent 579815 0f21e336171cc369ff9bb98caa484d5f64e87c5a
child 581385 8bbf626d8797f1c029623dde461919a15a2d5ebc
push id59380
push userbballo@mozilla.com
push dateWed, 17 May 2017 20:50:07 +0000
reviewerskats
bugs1364622
milestone55.0a1
Bug 1364622 - Consider the async transforms on the scroll thumb when computing the drag start offset during APZ initiation of scrollbar dragging. r=kats MozReview-Commit-ID: 8GA53FX7AEk
gfx/layers/apz/src/APZCTreeManager.cpp
--- a/gfx/layers/apz/src/APZCTreeManager.cpp
+++ b/gfx/layers/apz/src/APZCTreeManager.cpp
@@ -832,17 +832,31 @@ APZCTreeManager::ReceiveInputEvent(Input
           // AsyncPanZoomController::HandleInputEvent() will call
           // TransformToLocal() on the event, but we need its mLocalOrigin now
           // to compute a drag start offset for the AsyncDragMetrics.
           mouseInput.TransformToLocal(apzc->GetTransformToThis());
           CSSCoord dragStart = apzc->ConvertScrollbarPoint(
               mouseInput.mLocalOrigin, thumbData);
           // ConvertScrollbarPoint() got the drag start offset relative to
           // the scroll track. Now get it relative to the thumb.
-          dragStart -= thumbData.mThumbStart;
+          // ScrollThumbData::mThumbStart stores the offset of the thumb
+          // relative to the scroll track at the time of the last paint.
+          // Since that paint, the thumb may have acquired an async transform
+          // due to async scrolling, so look that up and apply it.
+          LayerToParentLayerMatrix4x4 thumbTransform;
+          {
+            MutexAutoLock lock(mTreeLock);
+            thumbTransform = ComputeTransformForNode(hitScrollbarNode);
+          }
+          // Only consider the translation, since we do not support both
+          // zooming and scrollbar dragging on any platform.
+          CSSCoord thumbStart = thumbData.mThumbStart
+                              + ((thumbData.mDirection == ScrollDirection::HORIZONTAL)
+                                 ? thumbTransform._41 : thumbTransform._42);
+          dragStart -= thumbStart;
           mInputQueue->ConfirmDragBlock(
               dragBlockId, apzc,
               AsyncDragMetrics(apzc->GetGuid().mScrollId,
                                apzc->GetGuid().mPresShellId,
                                dragBlockId,
                                dragStart,
                                thumbData.mDirection));
           // Content can't prevent scrollbar dragging with preventDefault(),