Bug 1355374 - Use the AsyncDragMetrics to communicate the scroll thumb length to APZ. r=mstange
MozReview-Commit-ID: DJUKr4s9nWQ
--- a/gfx/ipc/GfxMessageUtils.h
+++ b/gfx/ipc/GfxMessageUtils.h
@@ -1293,26 +1293,28 @@ struct ParamTraits<mozilla::layers::Asyn
static void Write(Message* aMsg, const paramType& aParam)
{
WriteParam(aMsg, aParam.mViewId);
WriteParam(aMsg, aParam.mPresShellId);
WriteParam(aMsg, aParam.mDragStartSequenceNumber);
WriteParam(aMsg, aParam.mScrollbarDragOffset);
WriteParam(aMsg, aParam.mScrollTrack);
+ WriteParam(aMsg, aParam.mScrollThumbLength);
WriteParam(aMsg, aParam.mDirection);
}
static bool Read(const Message* aMsg, PickleIterator* aIter, paramType* aResult)
{
return (ReadParam(aMsg, aIter, &aResult->mViewId) &&
ReadParam(aMsg, aIter, &aResult->mPresShellId) &&
ReadParam(aMsg, aIter, &aResult->mDragStartSequenceNumber) &&
ReadParam(aMsg, aIter, &aResult->mScrollbarDragOffset) &&
ReadParam(aMsg, aIter, &aResult->mScrollTrack) &&
+ ReadParam(aMsg, aIter, &aResult->mScrollThumbLength) &&
ReadParam(aMsg, aIter, &aResult->mDirection));
}
};
template <>
struct ParamTraits<mozilla::gfx::Glyph>
{
typedef mozilla::gfx::Glyph paramType;
--- a/gfx/layers/apz/src/AsyncDragMetrics.h
+++ b/gfx/layers/apz/src/AsyncDragMetrics.h
@@ -29,37 +29,41 @@ public:
};
// IPC constructor
AsyncDragMetrics()
: mViewId(0)
, mPresShellId(0)
, mDragStartSequenceNumber(0)
, mScrollbarDragOffset(0)
+ , mScrollThumbLength(0)
, mDirection(NONE)
{}
AsyncDragMetrics(const FrameMetrics::ViewID& aViewId,
uint32_t aPresShellId,
uint64_t aDragStartSequenceNumber,
CSSCoord aScrollbarDragOffset,
const CSSRect& aScrollTrack,
+ CSSCoord aScrollThumbLength,
DragDirection aDirection)
: mViewId(aViewId)
, mPresShellId(aPresShellId)
, mDragStartSequenceNumber(aDragStartSequenceNumber)
, mScrollbarDragOffset(aScrollbarDragOffset)
, mScrollTrack(aScrollTrack)
+ , mScrollThumbLength(aScrollThumbLength)
, mDirection(aDirection)
{}
FrameMetrics::ViewID mViewId;
uint32_t mPresShellId;
uint64_t mDragStartSequenceNumber;
CSSCoord mScrollbarDragOffset;
CSSRect mScrollTrack;
+ CSSCoord mScrollThumbLength;
DragDirection mDirection;
};
}
}
#endif
--- a/gfx/layers/apz/src/AsyncPanZoomController.cpp
+++ b/gfx/layers/apz/src/AsyncPanZoomController.cpp
@@ -922,19 +922,17 @@ nsEventStatus AsyncPanZoomController::Ha
CSSRect cssCompositionBound = mFrameMetrics.CalculateCompositedRectInCssPixels();
CSSCoord mousePosition = GetAxisStart(aDragMetrics.mDirection, scrollbarPoint) -
aDragMetrics.mScrollbarDragOffset -
GetAxisStart(aDragMetrics.mDirection, cssCompositionBound) -
GetAxisStart(aDragMetrics.mDirection, aDragMetrics.mScrollTrack);
CSSCoord scrollMax = GetAxisLength(aDragMetrics.mDirection, aDragMetrics.mScrollTrack);
- scrollMax -= node->GetScrollThumbLength() /
- GetAxisScale(aDragMetrics.mDirection, mFrameMetrics.GetZoom()) *
- mFrameMetrics.GetPresShellResolution();
+ scrollMax -= aDragMetrics.mScrollThumbLength;
float scrollPercent = mousePosition / scrollMax;
CSSCoord minScrollPosition =
GetAxisStart(aDragMetrics.mDirection, mFrameMetrics.GetScrollableRect().TopLeft());
CSSCoord maxScrollPosition =
GetAxisLength(aDragMetrics.mDirection, mFrameMetrics.GetScrollableRect()) -
GetAxisLength(aDragMetrics.mDirection, cssCompositionBound);
--- a/layout/xul/nsSliderFrame.cpp
+++ b/layout/xul/nsSliderFrame.cpp
@@ -1035,16 +1035,24 @@ nsSliderFrame::StartAPZDrag(WidgetGUIEve
// The scrollbar mediator is not the scroll frame.
// That means this scroll frame has a custom scrollbar mediator.
// That's not supported in the APZ codepath.
if (!scrollFrame) {
return;
}
}
+ nsIFrame* thumbFrame = mFrames.FirstChild();
+ if (!thumbFrame) {
+ return;
+ }
+ bool isHorizontal = IsXULHorizontal();
+ nsSize thumbSize = thumbFrame->GetSize();
+ nscoord thumbLength = isHorizontal ? thumbSize.width : thumbSize.height;
+
mozilla::layers::FrameMetrics::ViewID scrollTargetId;
bool hasID = nsLayoutUtils::FindIDFor(scrollableContent, &scrollTargetId);
bool hasAPZView = hasID && (scrollTargetId != layers::FrameMetrics::NULL_SCROLL_ID);
if (!hasAPZView) {
return;
}
@@ -1060,18 +1068,20 @@ nsSliderFrame::StartAPZDrag(WidgetGUIEve
nsIPresShell* shell = PresContext()->PresShell();
uint64_t inputblockId = InputAPZContext::GetInputBlockId();
uint32_t presShellId = shell->GetPresShellId();
AsyncDragMetrics dragMetrics(scrollTargetId, presShellId, inputblockId,
NSAppUnitsToFloatPixels(mDragStart,
float(AppUnitsPerCSSPixel())),
sliderTrackCSS,
- IsXULHorizontal() ? AsyncDragMetrics::HORIZONTAL :
- AsyncDragMetrics::VERTICAL);
+ NSAppUnitsToFloatPixels(thumbLength,
+ float(AppUnitsPerCSSPixel())),
+ isHorizontal ? AsyncDragMetrics::HORIZONTAL :
+ AsyncDragMetrics::VERTICAL);
if (!nsLayoutUtils::HasDisplayPort(scrollableContent)) {
return;
}
// It's important to set this before calling nsIWidget::StartAsyncScrollbarDrag(),
// because in some configurations, that can call AsyncScrollbarDragRejected()
// synchronously, which clears the flag (and we want it to stay cleared in