diff --git a/gfx/layers/Layers.h b/gfx/layers/Layers.h index c02cb07b477d..8af620bddee9 100644 --- a/gfx/layers/Layers.h +++ b/gfx/layers/Layers.h @@ -1711,8 +1711,10 @@ protected: nsAutoPtr mStickyPositionData; FrameMetrics::ViewID mScrollbarTargetId; ScrollDirection mScrollbarDirection; - float mScrollbarThumbRatio; // Ratio of the thumb position to the scroll - // position, in app units. + // The scrollbar thumb ratio is the ratio of the thumb position (in the CSS + // pixels of the scrollframe's parent's space) to the scroll position (in the + // CSS pixels of the scrollframe's space). + float mScrollbarThumbRatio; bool mIsScrollbarContainer; DebugOnly mDebugColorIndex; // If this layer is used for OMTA, then this counter is used to ensure we diff --git a/gfx/layers/composite/AsyncCompositionManager.cpp b/gfx/layers/composite/AsyncCompositionManager.cpp index 407ff546c19a..652c787e5025 100644 --- a/gfx/layers/composite/AsyncCompositionManager.cpp +++ b/gfx/layers/composite/AsyncCompositionManager.cpp @@ -726,8 +726,12 @@ ApplyAsyncTransformToScrollbarForContent(Layer* aScrollbar, const CSSCoord compositedHeight = (metrics.mCompositionBounds / effectiveZoom).height; const CSSCoord scrollableHeight = metrics.GetScrollableRect().height; - // The scrollbar thumb ratio is in AppUnits. - const float ratio = aScrollbar->GetScrollbarThumbRatio(); + const LayoutDeviceToParentLayerScale nonLayoutScale = effectiveZoom / + metrics.GetDevPixelsPerCSSPixel(); + // Here we convert the scrollbar thumb ratio into a true unitless ratio by + // dividing out the conversion factor from the scrollframe's parent's space + // to the scrollframe's space. + const float ratio = aScrollbar->GetScrollbarThumbRatio() / nonLayoutScale.scale; ParentLayerCoord yTranslation = -asyncScrollY * ratio; // The scroll thumb additionally needs to be translated to compensate for @@ -773,8 +777,9 @@ ApplyAsyncTransformToScrollbarForContent(Layer* aScrollbar, const CSSCoord compositedWidth = (metrics.mCompositionBounds / effectiveZoom).width; const CSSCoord scrollableWidth = metrics.GetScrollableRect().width; - // The scrollbar thumb ratio is in AppUnits. - const float ratio = aScrollbar->GetScrollbarThumbRatio(); + const LayoutDeviceToParentLayerScale nonLayoutScale = effectiveZoom / + metrics.GetDevPixelsPerCSSPixel(); + const float ratio = aScrollbar->GetScrollbarThumbRatio() / nonLayoutScale.scale; ParentLayerCoord xTranslation = -asyncScrollX * ratio; const CSSCoord thumbOrigin = (metrics.GetScrollOffset().x / scrollableWidth) * compositedWidth; diff --git a/layout/xul/nsSliderFrame.cpp b/layout/xul/nsSliderFrame.cpp index 9ad1d07e7ac5..63c11d8b5d2e 100644 --- a/layout/xul/nsSliderFrame.cpp +++ b/layout/xul/nsSliderFrame.cpp @@ -1317,7 +1317,9 @@ float nsSliderFrame::GetThumbRatio() const { // mRatio is in thumb app units per scrolled css pixels. Convert it to a - // a true unitless ratio. + // ratio of the thumb's CSS pixels per scrolled CSS pixels. (Note the thumb + // is in the scrollframe's parent's space whereas the scrolled CSS pixels + // are in the scrollframe's space). return mRatio / mozilla::AppUnitsPerCSSPixel(); }