Bug 1349750 - Store the thumb's start offset in ScrollThumbData. r=kats
Also add a comment to AsyncDragMetrics documenting that mScrollbarDragOffset
is relative to the thumb's start offset.
MozReview-Commit-ID: uipsOCzs2N
--- a/gfx/layers/LayerAttributes.h
+++ b/gfx/layers/LayerAttributes.h
@@ -21,42 +21,46 @@ namespace layers {
struct ScrollThumbData {
ScrollThumbData()
: mDirection(ScrollDirection::NONE)
, mThumbRatio(0.0f)
, mIsAsyncDraggable(false)
{}
ScrollThumbData(ScrollDirection aDirection,
float aThumbRatio,
+ CSSCoord aThumbStart,
CSSCoord aThumbLength,
bool aIsAsyncDraggable,
CSSCoord aScrollTrackStart,
CSSCoord aScrollTrackLength)
: mDirection(aDirection)
, mThumbRatio(aThumbRatio)
+ , mThumbStart(aThumbStart)
, mThumbLength(aThumbLength)
, mIsAsyncDraggable(aIsAsyncDraggable)
, mScrollTrackStart(aScrollTrackStart)
, mScrollTrackLength(aScrollTrackLength)
{}
ScrollDirection mDirection;
// 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 mThumbRatio;
+ CSSCoord mThumbStart;
CSSCoord mThumbLength;
// Whether the scrollbar thumb can be dragged asynchronously.
bool mIsAsyncDraggable;
CSSCoord mScrollTrackStart;
CSSCoord mScrollTrackLength;
bool operator==(const ScrollThumbData& aOther) const {
return mDirection == aOther.mDirection &&
mThumbRatio == aOther.mThumbRatio &&
+ mThumbStart == aOther.mThumbStart &&
mThumbLength == aOther.mThumbLength &&
mIsAsyncDraggable == aOther.mIsAsyncDraggable &&
mScrollTrackStart == aOther.mScrollTrackStart &&
mScrollTrackLength == aOther.mScrollTrackLength;
}
bool operator!=(const ScrollThumbData& aOther) const {
return !(*this == aOther);
}
--- a/gfx/layers/apz/src/AsyncDragMetrics.h
+++ b/gfx/layers/apz/src/AsyncDragMetrics.h
@@ -41,16 +41,16 @@ public:
, mDragStartSequenceNumber(aDragStartSequenceNumber)
, mScrollbarDragOffset(aScrollbarDragOffset)
, mDirection(aDirection)
{}
FrameMetrics::ViewID mViewId;
uint32_t mPresShellId;
uint64_t mDragStartSequenceNumber;
- CSSCoord mScrollbarDragOffset;
+ CSSCoord mScrollbarDragOffset; // relative to the thumb's start offset
ScrollDirection mDirection;
};
}
}
#endif
--- a/layout/xul/nsSliderFrame.cpp
+++ b/layout/xul/nsSliderFrame.cpp
@@ -403,16 +403,18 @@ nsSliderFrame::BuildDisplayListForChildr
// This rect is the range in which the scroll thumb can slide in.
sliderTrack = sliderTrack + GetRect().TopLeft() + scrollbarBox->GetPosition() -
scrollPortOrigin;
CSSCoord sliderTrackStart = NSAppUnitsToFloatPixels(
isHorizontal ? sliderTrack.x : sliderTrack.y, appUnitsPerCss);
CSSCoord sliderTrackLength = NSAppUnitsToFloatPixels(
isHorizontal ? sliderTrack.width : sliderTrack.height, appUnitsPerCss);
+ CSSCoord thumbStart = NSAppUnitsToFloatPixels(
+ isHorizontal ? thumbRect.x : thumbRect.y, appUnitsPerCss);
nsDisplayListBuilder::AutoContainerASRTracker contASRTracker(aBuilder);
nsDisplayListCollection tempLists;
nsBoxFrame::BuildDisplayListForChildren(aBuilder, aDirtyRect, tempLists);
// This is a bit of a hack. Collect up all descendant display items
// and merge them into a single Content() list.
nsDisplayList masterList;
@@ -427,16 +429,17 @@ nsSliderFrame::BuildDisplayListForChildr
const ActiveScrolledRoot* ownLayerASR = contASRTracker.GetContainerASR();
DisplayListClipState::AutoSaveRestore ownLayerClipState(aBuilder);
ownLayerClipState.ClearUpToASR(ownLayerASR);
aLists.Content()->AppendNewToTop(new (aBuilder)
nsDisplayOwnLayer(aBuilder, this, &masterList, ownLayerASR,
flags, scrollTargetId,
ScrollThumbData{scrollDirection,
GetThumbRatio(),
+ thumbStart,
thumbLength,
isAsyncDraggable,
sliderTrackStart,
sliderTrackLength}));
return;
}
}