Bug 1355374 - Use the AsyncDragMetrics to communicate the scroll thumb length to APZ. r=mstange
authorBotond Ballo <botond@mozilla.com>
Fri, 21 Apr 2017 13:57:11 -0400
changeset 354680 687a8e437cdaa14d72b1c2922131fad736133389
parent 354679 49fbd8da1b0e03cc5373191c83901278bb3e1623
child 354681 ef85518ce6ba18f0c001c3dcbaa96b49d68186d1
push id41396
push userbballo@mozilla.com
push dateTue, 25 Apr 2017 01:57:35 +0000
treeherderautoland@ef85518ce6ba [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmstange
bugs1355374
milestone55.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 1355374 - Use the AsyncDragMetrics to communicate the scroll thumb length to APZ. r=mstange MozReview-Commit-ID: DJUKr4s9nWQ
gfx/ipc/GfxMessageUtils.h
gfx/layers/apz/src/AsyncDragMetrics.h
gfx/layers/apz/src/AsyncPanZoomController.cpp
layout/xul/nsSliderFrame.cpp
--- a/gfx/ipc/GfxMessageUtils.h
+++ b/gfx/ipc/GfxMessageUtils.h
@@ -1293,26 +1293,28 @@ struct ParamTraits<mozilla::layers::Asyn
 
   static void Write(Message* aMsg, const paramType& aParam)
   {
     WriteParam(aMsg, aParam.mViewId);
     WriteParam(aMsg, aParam.mPresShellId);
     WriteParam(aMsg, aParam.mDragStartSequenceNumber);
     WriteParam(aMsg, aParam.mScrollbarDragOffset);
     WriteParam(aMsg, aParam.mScrollTrack);
+    WriteParam(aMsg, aParam.mScrollThumbLength);
     WriteParam(aMsg, aParam.mDirection);
   }
 
   static bool Read(const Message* aMsg, PickleIterator* aIter, paramType* aResult)
   {
     return (ReadParam(aMsg, aIter, &aResult->mViewId) &&
             ReadParam(aMsg, aIter, &aResult->mPresShellId) &&
             ReadParam(aMsg, aIter, &aResult->mDragStartSequenceNumber) &&
             ReadParam(aMsg, aIter, &aResult->mScrollbarDragOffset) &&
             ReadParam(aMsg, aIter, &aResult->mScrollTrack) &&
+            ReadParam(aMsg, aIter, &aResult->mScrollThumbLength) &&
             ReadParam(aMsg, aIter, &aResult->mDirection));
   }
 };
 
 template <>
 struct ParamTraits<mozilla::gfx::Glyph>
 {
   typedef mozilla::gfx::Glyph paramType;
--- a/gfx/layers/apz/src/AsyncDragMetrics.h
+++ b/gfx/layers/apz/src/AsyncDragMetrics.h
@@ -29,37 +29,41 @@ public:
   };
 
   // IPC constructor
   AsyncDragMetrics()
     : mViewId(0)
     , mPresShellId(0)
     , mDragStartSequenceNumber(0)
     , mScrollbarDragOffset(0)
+    , mScrollThumbLength(0)
     , mDirection(NONE)
   {}
 
   AsyncDragMetrics(const FrameMetrics::ViewID& aViewId,
                    uint32_t aPresShellId,
                    uint64_t aDragStartSequenceNumber,
                    CSSCoord aScrollbarDragOffset,
                    const CSSRect& aScrollTrack,
+                   CSSCoord aScrollThumbLength,
                    DragDirection aDirection)
     : mViewId(aViewId)
     , mPresShellId(aPresShellId)
     , mDragStartSequenceNumber(aDragStartSequenceNumber)
     , mScrollbarDragOffset(aScrollbarDragOffset)
     , mScrollTrack(aScrollTrack)
+    , mScrollThumbLength(aScrollThumbLength)
     , mDirection(aDirection)
   {}
 
   FrameMetrics::ViewID mViewId;
   uint32_t mPresShellId;
   uint64_t mDragStartSequenceNumber;
   CSSCoord mScrollbarDragOffset;
   CSSRect mScrollTrack;
+  CSSCoord mScrollThumbLength;
   DragDirection mDirection;
 };
 
 }
 }
 
 #endif
--- a/gfx/layers/apz/src/AsyncPanZoomController.cpp
+++ b/gfx/layers/apz/src/AsyncPanZoomController.cpp
@@ -922,19 +922,17 @@ nsEventStatus AsyncPanZoomController::Ha
   CSSRect cssCompositionBound = mFrameMetrics.CalculateCompositedRectInCssPixels();
 
   CSSCoord mousePosition = GetAxisStart(aDragMetrics.mDirection, scrollbarPoint) -
                         aDragMetrics.mScrollbarDragOffset -
                         GetAxisStart(aDragMetrics.mDirection, cssCompositionBound) -
                         GetAxisStart(aDragMetrics.mDirection, aDragMetrics.mScrollTrack);
 
   CSSCoord scrollMax = GetAxisLength(aDragMetrics.mDirection, aDragMetrics.mScrollTrack);
-  scrollMax -= node->GetScrollThumbLength() /
-               GetAxisScale(aDragMetrics.mDirection, mFrameMetrics.GetZoom()) *
-               mFrameMetrics.GetPresShellResolution();
+  scrollMax -= aDragMetrics.mScrollThumbLength;
 
   float scrollPercent = mousePosition / scrollMax;
 
   CSSCoord minScrollPosition =
     GetAxisStart(aDragMetrics.mDirection, mFrameMetrics.GetScrollableRect().TopLeft());
   CSSCoord maxScrollPosition =
     GetAxisLength(aDragMetrics.mDirection, mFrameMetrics.GetScrollableRect()) -
     GetAxisLength(aDragMetrics.mDirection, cssCompositionBound);
--- a/layout/xul/nsSliderFrame.cpp
+++ b/layout/xul/nsSliderFrame.cpp
@@ -1035,16 +1035,24 @@ nsSliderFrame::StartAPZDrag(WidgetGUIEve
     // The scrollbar mediator is not the scroll frame.
     // That means this scroll frame has a custom scrollbar mediator.
     // That's not supported in the APZ codepath.
     if (!scrollFrame) {
       return;
     }
   }
 
+  nsIFrame* thumbFrame = mFrames.FirstChild();
+  if (!thumbFrame) {
+    return;
+  }
+  bool isHorizontal = IsXULHorizontal();
+  nsSize thumbSize = thumbFrame->GetSize();
+  nscoord thumbLength = isHorizontal ? thumbSize.width : thumbSize.height;
+
   mozilla::layers::FrameMetrics::ViewID scrollTargetId;
   bool hasID = nsLayoutUtils::FindIDFor(scrollableContent, &scrollTargetId);
   bool hasAPZView = hasID && (scrollTargetId != layers::FrameMetrics::NULL_SCROLL_ID);
 
   if (!hasAPZView) {
     return;
   }
 
@@ -1060,18 +1068,20 @@ nsSliderFrame::StartAPZDrag(WidgetGUIEve
 
   nsIPresShell* shell = PresContext()->PresShell();
   uint64_t inputblockId = InputAPZContext::GetInputBlockId();
   uint32_t presShellId = shell->GetPresShellId();
   AsyncDragMetrics dragMetrics(scrollTargetId, presShellId, inputblockId,
                                NSAppUnitsToFloatPixels(mDragStart,
                                  float(AppUnitsPerCSSPixel())),
                                sliderTrackCSS,
-                               IsXULHorizontal() ? AsyncDragMetrics::HORIZONTAL :
-                                                   AsyncDragMetrics::VERTICAL);
+                               NSAppUnitsToFloatPixels(thumbLength,
+                                 float(AppUnitsPerCSSPixel())),
+                               isHorizontal ? AsyncDragMetrics::HORIZONTAL :
+                                              AsyncDragMetrics::VERTICAL);
 
   if (!nsLayoutUtils::HasDisplayPort(scrollableContent)) {
     return;
   }
 
   // It's important to set this before calling nsIWidget::StartAsyncScrollbarDrag(),
   // because in some configurations, that can call AsyncScrollbarDragRejected()
   // synchronously, which clears the flag (and we want it to stay cleared in