Bug 1602258. Make ScrollFrameHelper::GetAvailableScrollingDirectionsForUserInputEvents check for at least half a screen pixel of scroll range instead of one app unit. r=botond

This is similar to GetAvailableScrollingDirections but also takes into account any resolution.

Differential Revision: https://phabricator.services.mozilla.com/D57610

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Timothy Nikkel 2019-12-18 23:08:11 +00:00
Родитель af1f827e43
Коммит 8d223d13dd
1 изменённых файлов: 11 добавлений и 2 удалений

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

@ -6685,11 +6685,20 @@ uint32_t ScrollFrameHelper::GetAvailableScrollingDirectionsForUserInputEvents()
scrollRange.width = std::max(scrolledRect.width - scrollPort.width, 0);
scrollRange.height = std::max(scrolledRect.height - scrollPort.height, 0);
// We check if there is at least one half of a screen pixel of scroll range to
// roughly match what apz does when it checks if the change in scroll position
// in screen pixels round to zero or not.
// (https://searchfox.org/mozilla-central/rev/2f09184ec781a2667feec87499d4b81b32b6c48e/gfx/layers/apz/src/AsyncPanZoomController.cpp#3210)
// This isn't quite half a screen pixel, it doesn't take into account CSS
// transforms, but should be good enough.
float halfScreenPixel =
GetScrolledFrame()->PresContext()->AppUnitsPerDevPixel() /
(mOuter->PresShell()->GetCumulativeResolution() * 2.f);
uint32_t directions = 0;
if (scrollRange.width > 0) {
if (scrollRange.width >= halfScreenPixel) {
directions |= nsIScrollableFrame::HORIZONTAL;
}
if (scrollRange.height > 0) {
if (scrollRange.height >= halfScreenPixel) {
directions |= nsIScrollableFrame::VERTICAL;
}
return directions;