Clamp APZ wheel event deltas to the size of a page scroll. (bug 1146676, r=kats)

This commit is contained in:
David Anderson 2015-03-24 14:59:41 -07:00
Родитель 0edd0b1707
Коммит 1e87fb5a4b
4 изменённых файлов: 34 добавлений и 0 удалений

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

@ -752,6 +752,7 @@ struct ParamTraits<mozilla::layers::FrameMetrics>
WriteParam(aMsg, aParam.mDoSmoothScroll);
WriteParam(aMsg, aParam.mSmoothScrollOffset);
WriteParam(aMsg, aParam.GetLineScrollAmount());
WriteParam(aMsg, aParam.GetPageScrollAmount());
WriteParam(aMsg, aParam.AllowVerticalScrollWithWheel());
WriteParam(aMsg, aParam.GetContentDescription());
}
@ -793,6 +794,7 @@ struct ParamTraits<mozilla::layers::FrameMetrics>
ReadParam(aMsg, aIter, &aResult->mDoSmoothScroll) &&
ReadParam(aMsg, aIter, &aResult->mSmoothScrollOffset) &&
ReadParam(aMsg, aIter, &aResult->mLineScrollAmount) &&
ReadParam(aMsg, aIter, &aResult->mPageScrollAmount) &&
ReadParam(aMsg, aIter, &aResult->mAllowVerticalScrollWithWheel) &&
ReadContentDescription(aMsg, aIter, aResult));
}

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

@ -64,6 +64,7 @@ public:
, mExtraResolution()
, mBackgroundColor(0, 0, 0, 0)
, mLineScrollAmount(0, 0)
, mPageScrollAmount(0, 0)
, mAllowVerticalScrollWithWheel(false)
{
}
@ -96,6 +97,7 @@ public:
mBackgroundColor == aOther.mBackgroundColor &&
mDoSmoothScroll == aOther.mDoSmoothScroll &&
mLineScrollAmount == aOther.mLineScrollAmount &&
mPageScrollAmount == aOther.mPageScrollAmount &&
mAllowVerticalScrollWithWheel == aOther.mAllowVerticalScrollWithWheel;
}
bool operator!=(const FrameMetrics& aOther) const
@ -496,6 +498,16 @@ public:
mLineScrollAmount = size;
}
const LayoutDeviceIntSize& GetPageScrollAmount() const
{
return mPageScrollAmount;
}
void SetPageScrollAmount(const LayoutDeviceIntSize& size)
{
mPageScrollAmount = size;
}
const CSSRect& GetScrollableRect() const
{
return mScrollableRect;
@ -664,6 +676,9 @@ private:
// The value of GetLineScrollAmount(), for scroll frames.
LayoutDeviceIntSize mLineScrollAmount;
// The value of GetPageScrollAmount(), for scroll frames.
LayoutDeviceIntSize mPageScrollAmount;
// Whether or not the frame can be vertically scrolled with a mouse wheel.
bool mAllowVerticalScrollWithWheel;
};

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

@ -1441,6 +1441,18 @@ AsyncPanZoomController::GetScrollWheelDelta(const ScrollWheelInput& aEvent,
default:
MOZ_ASSERT_UNREACHABLE("unexpected scroll delta type");
}
LayoutDeviceIntSize pageScrollSize = mFrameMetrics.GetPageScrollAmount();
if (Abs(aOutDeltaX) > pageScrollSize.width) {
aOutDeltaX = (aOutDeltaX >= 0)
? pageScrollSize.width
: -pageScrollSize.width;
}
if (Abs(aOutDeltaY) > pageScrollSize.height) {
aOutDeltaY = (aOutDeltaY >= 0)
? pageScrollSize.height
: -pageScrollSize.height;
}
}
// Return whether or not the underlying layer can be scrolled on either axis.

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

@ -795,6 +795,11 @@ nsDisplayScrollLayer::ComputeFrameMetrics(nsIFrame* aForFrame,
LayoutDeviceIntSize::FromAppUnitsRounded(lineScrollAmount, presContext->AppUnitsPerDevPixel());
metrics.SetLineScrollAmount(lineScrollAmountInDevPixels);
nsSize pageScrollAmount = scrollableFrame->GetPageScrollAmount();
LayoutDeviceIntSize pageScrollAmountInDevPixels =
LayoutDeviceIntSize::FromAppUnitsRounded(pageScrollAmount, presContext->AppUnitsPerDevPixel());
metrics.SetPageScrollAmount(pageScrollAmountInDevPixels);
if (!aScrollFrame->GetParent() ||
EventStateManager::CanVerticallyScrollFrameWithWheel(aScrollFrame->GetParent()))
{