Bug 1093949 - Reverse scroll position for RTL content. r=mats, a=lmandel
authorJonathan Kew <jkew@mozilla.com>
Thu, 06 Nov 2014 09:06:22 +0000
changeset 225978 4e453b566e83
parent 225977 53692e16c248
child 225979 557655b23004
push id4090
push userryanvm@gmail.com
push date2014-11-06 15:45 +0000
treeherdermozilla-beta@4e453b566e83 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmats, lmandel
bugs1093949
milestone34.0
Bug 1093949 - Reverse scroll position for RTL content. r=mats, a=lmandel
layout/generic/nsGfxScrollFrame.cpp
layout/xul/nsIScrollbarMediator.h
--- a/layout/generic/nsGfxScrollFrame.cpp
+++ b/layout/generic/nsGfxScrollFrame.cpp
@@ -1127,17 +1127,17 @@ ScrollFrameHelper::ThumbMoved(nsScrollba
                               nscoord aOldPos,
                               nscoord aNewPos)
 {
   MOZ_ASSERT(aScrollbar != nullptr);
   bool isHorizontal = aScrollbar->IsHorizontal();
   nsPoint current = GetScrollPosition();
   nsPoint dest = current;
   if (isHorizontal) {
-    dest.x = aNewPos;
+    dest.x = IsLTR() ? aNewPos : aNewPos - GetScrollRange().width;
   } else {
     dest.y = aNewPos;
   }
   nsRect allowedRange = GetOnePixelRangeAroundPoint(dest, isHorizontal);
 
   // Don't try to scroll if we're already at an acceptable place.
   // Don't call Contains here since Contains returns false when the point is
   // on the bottom or right edge of the rectangle.
--- a/layout/xul/nsIScrollbarMediator.h
+++ b/layout/xul/nsIScrollbarMediator.h
@@ -36,16 +36,19 @@ public:
    * RepeatButtonScroll is called when the scrollbar's button is held down. When the
    * button is first clicked the increment is set; RepeatButtonScroll adds this
    * increment to the current position.
    * @note This method might destroy the frame, pres shell, and other objects.
    */
   virtual void RepeatButtonScroll(nsScrollbarFrame* aScrollbar) = 0;
   /**
    * aOldPos and aNewPos are scroll positions.
+   * The scroll positions start with zero at the left edge; implementors that want
+   * zero at the right edge for RTL content will need to adjust accordingly.
+   * (See ScrollFrameHelper::ThumbMoved in nsGfxScrollFrame.cpp.)
    * @note This method might destroy the frame, pres shell, and other objects.
    */
   virtual void ThumbMoved(nsScrollbarFrame* aScrollbar,
                           nscoord aOldPos,
                           nscoord aNewPos) = 0;
   virtual void VisibilityChanged(bool aVisible) = 0;
 
   /**