Bug 1846575 - Scroll a full page per repeat timer tick during scrollbar track click-and-hold. r=rzvncj

Differential Revision: https://phabricator.services.mozilla.com/D187152
This commit is contained in:
Botond Ballo 2023-08-31 07:04:56 +00:00
Родитель 816247d153
Коммит 39fbef2cf2
2 изменённых файлов: 24 добавлений и 1 удалений

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

@ -1534,6 +1534,21 @@ void nsSliderFrame::PageScroll(bool aClickAndHold) {
nsPoint pos = sf->GetScrollPosition();
if (mCurrentClickHoldDestination) {
// We may not have arrived at the destination of the scroll from the
// previous repeat timer tick, some of that scroll may still be pending.
nsPoint pendingScroll =
*mCurrentClickHoldDestination - sf->GetScrollPosition();
// Scroll by one page relative to the previous destination, so that we
// scroll at a rate of a full page per repeat timer tick.
pos += pendingScroll;
// Make a corresponding adjustment to the maxium distance we can scroll,
// so we successfully avoid overshoot.
maxDistanceToScroll -= (isHorizontal ? pendingScroll.x : pendingScroll.y);
}
nscoord distanceToScroll =
std::min(abs(maxDistanceToScroll),
CSSPixel::ToAppUnits(CSSCoord(pageLength))) *
@ -1545,6 +1560,7 @@ void nsSliderFrame::PageScroll(bool aClickAndHold) {
pos.y += distanceToScroll;
}
mCurrentClickHoldDestination = Some(pos);
sf->ScrollTo(pos,
StaticPrefs::general_smoothScroll() &&
StaticPrefs::general_smoothScroll_pages()

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

@ -184,7 +184,10 @@ class nsSliderFrame final : public nsContainerFrame {
nsRepeatService::GetInstance()->Start(Notify, this, mContent->OwnerDoc(),
"nsSliderFrame"_ns);
}
void StopRepeat() { nsRepeatService::GetInstance()->Stop(Notify, this); }
void StopRepeat() {
nsRepeatService::GetInstance()->Stop(Notify, this);
mCurrentClickHoldDestination = Nothing();
}
void Notify();
static void Notify(void* aData) {
(static_cast<nsSliderFrame*>(aData))->Notify();
@ -192,6 +195,10 @@ class nsSliderFrame final : public nsContainerFrame {
void PageScroll(bool aClickAndHold);
nsPoint mDestinationPoint;
// If we are in a scrollbar track click-and-hold, this is populated with
// the destination of the scroll started at the most recent tick of the
// repeat timer.
Maybe<nsPoint> mCurrentClickHoldDestination;
RefPtr<nsSliderMediator> mMediator;
float mRatio;