Bug 1066934 - Don't allow the snapped scrollbar thumb to extend past the scrollbar bounds. r=roc, a=sledru
authorMarkus Stange <mstange@themasta.com>
Thu, 18 Sep 2014 10:52:38 +0200
changeset 216805 f14c89b414b6
parent 216804 90713d332601
child 216806 389dd23d771c
push id3920
push userryanvm@gmail.com
push date2014-09-19 21:55 +0000
treeherdermozilla-beta@f14c89b414b6 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersroc, sledru
bugs1066934
milestone33.0
Bug 1066934 - Don't allow the snapped scrollbar thumb to extend past the scrollbar bounds. r=roc, a=sledru
layout/xul/nsSliderFrame.cpp
--- a/layout/xul/nsSliderFrame.cpp
+++ b/layout/xul/nsSliderFrame.cpp
@@ -655,17 +655,25 @@ nsSliderFrame::CurrentPositionChanged()
 
   if (IsHorizontal())
      newThumbRect.x = clientRect.x + NSToCoordRound(pos * mRatio);
   else
      newThumbRect.y = clientRect.y + NSToCoordRound(pos * mRatio);
 
   // avoid putting the scroll thumb at subpixel positions which cause needless invalidations
   nscoord appUnitsPerPixel = PresContext()->AppUnitsPerDevPixel();
-  newThumbRect = newThumbRect.ToNearestPixels(appUnitsPerPixel).ToAppUnits(appUnitsPerPixel);
+  nsRect snappedThumbRect = newThumbRect.ToNearestPixels(appUnitsPerPixel).ToAppUnits(appUnitsPerPixel);
+  if (IsHorizontal()) {
+    newThumbRect.x = snappedThumbRect.x;
+    newThumbRect.width = snappedThumbRect.width;
+  } else {
+    newThumbRect.y = snappedThumbRect.y;
+    newThumbRect.height = snappedThumbRect.height;
+  }
+  newThumbRect = newThumbRect.Intersect(clientRect);
 
   // set the rect
   thumbFrame->SetRect(newThumbRect);
 
   // Request a repaint of the scrollbar
   SchedulePaint();
 
   mCurPos = curPos;