Bug 1539684 - Don't let scrollPercent become NaN if maxThumbPos is zero. r=botond
authorKartikaya Gupta <kgupta@mozilla.com>
Fri, 29 Mar 2019 15:39:35 +0000
changeset 466782 e711067609323aaed6ebfb0286cb14be35bd5859
parent 466781 7f9e2ce2bf14b4be1ab91cc0f72159ed5f3c7328
child 466783 2cbcf3ac7ca69ca7717c8a8232b293f75ef2ca8a
push id35780
push useropoprus@mozilla.com
push dateFri, 29 Mar 2019 21:53:01 +0000
treeherdermozilla-central@414f37afbe07 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbotond
bugs1539684
milestone68.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 1539684 - Don't let scrollPercent become NaN if maxThumbPos is zero. r=botond Differential Revision: https://phabricator.services.mozilla.com/D25405
gfx/layers/apz/src/AsyncPanZoomController.cpp
--- a/gfx/layers/apz/src/AsyncPanZoomController.cpp
+++ b/gfx/layers/apz/src/AsyncPanZoomController.cpp
@@ -1077,17 +1077,18 @@ nsEventStatus AsyncPanZoomController::Ha
   } else {
     thumbPosition = ConvertScrollbarPoint(aEvent.mLocalOrigin, scrollbarData) -
                     aDragMetrics.mScrollbarDragOffset;
   }
 
   CSSCoord maxThumbPos = scrollbarData.mScrollTrackLength;
   maxThumbPos -= scrollbarData.mThumbLength;
 
-  float scrollPercent = thumbPosition / maxThumbPos;
+  float scrollPercent =
+      maxThumbPos.value == 0.0f ? 0.0f : (float)(thumbPosition / maxThumbPos);
   APZC_LOG("%p scrollbar dragged to %f percent\n", this, scrollPercent);
 
   CSSCoord minScrollPosition =
       GetAxisStart(direction, Metrics().GetScrollableRect().TopLeft());
   CSSCoord maxScrollPosition =
       GetAxisStart(direction, Metrics().GetScrollableRect().BottomRight()) -
       GetAxisLength(
           direction,