Bug 1349750 - Add a ConvertScrollbarPoint() helper to AsyncPanZoomController. r=kats

MozReview-Commit-ID: ESbWqhy1tKT

--HG--
extra : rebase_source : a380346fefd9e0fbcbbbcdcd61c0272b727acfed
This commit is contained in:
Botond Ballo 2017-05-10 19:25:27 -04:00
Родитель e1636dd2cd
Коммит f5c583a72c
2 изменённых файлов: 30 добавлений и 11 удалений

Просмотреть файл

@ -917,16 +917,8 @@ nsEventStatus AsyncPanZoomController::HandleDragEvent(const MouseInput& aEvent,
(uint32_t) ScrollInputMethod::ApzScrollbarDrag);
ReentrantMonitorAutoEnter lock(mMonitor);
CSSPoint scrollFramePoint = aEvent.mLocalOrigin / GetFrameMetrics().GetZoom();
// The scrollbar can be transformed with the frame but the pres shell
// resolution is only applied to the scroll frame.
CSSPoint scrollbarPoint = scrollFramePoint * mFrameMetrics.GetPresShellResolution();
CSSRect cssCompositionBound = mFrameMetrics.CalculateCompositedRectInCssPixels();
CSSCoord mousePosition = GetAxisStart(aDragMetrics.mDirection, scrollbarPoint) -
aDragMetrics.mScrollbarDragOffset -
GetAxisStart(aDragMetrics.mDirection, cssCompositionBound) -
thumbData.mScrollTrackStart;
CSSCoord mousePosition = ConvertScrollbarPoint(aEvent.mLocalOrigin, thumbData) -
aDragMetrics.mScrollbarDragOffset;
CSSCoord scrollMax = thumbData.mScrollTrackLength;
scrollMax -= thumbData.mThumbLength;
@ -937,7 +929,7 @@ nsEventStatus AsyncPanZoomController::HandleDragEvent(const MouseInput& aEvent,
GetAxisStart(aDragMetrics.mDirection, mFrameMetrics.GetScrollableRect().TopLeft());
CSSCoord maxScrollPosition =
GetAxisLength(aDragMetrics.mDirection, mFrameMetrics.GetScrollableRect()) -
GetAxisLength(aDragMetrics.mDirection, cssCompositionBound);
GetAxisLength(aDragMetrics.mDirection, mFrameMetrics.CalculateCompositedRectInCssPixels());
CSSCoord scrollPosition = scrollPercent * maxScrollPosition;
scrollPosition = std::max(scrollPosition, minScrollPosition);
@ -1575,6 +1567,25 @@ AsyncPanZoomController::ConvertToGecko(const ScreenIntPoint& aPoint, LayoutDevic
return false;
}
CSSCoord
AsyncPanZoomController::ConvertScrollbarPoint(const ParentLayerPoint& aScrollbarPoint,
const ScrollThumbData& aThumbData) const
{
ReentrantMonitorAutoEnter lock(mMonitor);
// First, get it into the right coordinate space.
CSSPoint scrollbarPoint = aScrollbarPoint / mFrameMetrics.GetZoom();
// The scrollbar can be transformed with the frame but the pres shell
// resolution is only applied to the scroll frame.
scrollbarPoint = scrollbarPoint * mFrameMetrics.GetPresShellResolution();
// Now, get it to be relative to the beginning of the scroll track.
CSSRect cssCompositionBound = mFrameMetrics.CalculateCompositedRectInCssPixels();
return GetAxisStart(aThumbData.mDirection, scrollbarPoint)
- GetAxisStart(aThumbData.mDirection, cssCompositionBound)
- aThumbData.mScrollTrackStart;
}
static bool
AllowsScrollingMoreThanOnePage(double aMultiplier)
{

Просмотреть файл

@ -403,6 +403,14 @@ public:
// in the given direction.
bool CanScroll(ScrollDirection aDirection) const;
/**
* Convert a point on the scrollbar from this APZC's ParentLayer coordinates
* to CSS coordinates relative to the beginning of the scroll track.
* Only the component in the direction of scrolling is returned.
*/
CSSCoord ConvertScrollbarPoint(const ParentLayerPoint& aScrollbarPoint,
const ScrollThumbData& aThumbData) const;
void NotifyMozMouseScrollEvent(const nsString& aString) const;
protected: