Bug 1643042 - Turn the scroll origin parameter into a strongly-typed enum. r=tnikkel

This patch is a fairly mechanical conversion. The old `nullptr` gets converted
to ScrollOrigin::NotSpecified, and all the other possible values get corresponding
values in the new ScrollOrigin enum. A few switch statements are introduced to
clean up big if statements, but other than that, additional cleanups will happen
in later patches.

Differential Revision: https://phabricator.services.mozilla.com/D78438
This commit is contained in:
Kartikaya Gupta 2020-06-05 09:37:51 +00:00
Родитель 79a227b703
Коммит 7ac36807b1
14 изменённых файлов: 282 добавлений и 180 удалений

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

@ -725,7 +725,8 @@ void Element::ScrollBy(const ScrollToOptions& aOptions) {
? ScrollMode::SmoothMsd
: ScrollMode::Instant;
sf->ScrollByCSSPixels(scrollDelta, scrollMode, nsGkAtoms::relative);
sf->ScrollByCSSPixels(scrollDelta, scrollMode,
mozilla::ScrollOrigin::Relative);
}
}

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

@ -3666,7 +3666,8 @@ void nsGlobalWindowInner::ScrollBy(const ScrollToOptions& aOptions) {
? ScrollMode::SmoothMsd
: ScrollMode::Instant;
sf->ScrollByCSSPixels(scrollDelta, scrollMode, nsGkAtoms::relative);
sf->ScrollByCSSPixels(scrollDelta, scrollMode,
mozilla::ScrollOrigin::Relative);
}
}

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

@ -2734,18 +2734,18 @@ void EventStateManager::DoScrollText(nsIScrollableFrame* aScrollableFrame,
nsIScrollbarMediator::ScrollSnapMode snapMode =
nsIScrollbarMediator::DISABLE_SNAP;
nsAtom* origin = nullptr;
mozilla::ScrollOrigin origin = mozilla::ScrollOrigin::NotSpecified;
switch (aEvent->mDeltaMode) {
case WheelEvent_Binding::DOM_DELTA_LINE:
origin = nsGkAtoms::mouseWheel;
origin = mozilla::ScrollOrigin::MouseWheel;
snapMode = nsIScrollableFrame::ENABLE_SNAP;
break;
case WheelEvent_Binding::DOM_DELTA_PAGE:
origin = nsGkAtoms::pages;
origin = mozilla::ScrollOrigin::Pages;
snapMode = nsIScrollableFrame::ENABLE_SNAP;
break;
case WheelEvent_Binding::DOM_DELTA_PIXEL:
origin = nsGkAtoms::pixels;
origin = mozilla::ScrollOrigin::Pixels;
break;
default:
MOZ_CRASH("Invalid deltaMode value comes");

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

@ -137,7 +137,8 @@ static CSSPoint ScrollFrameTo(nsIScrollableFrame* aFrame,
// request because we'll clobber that one, which is bad.
bool scrollInProgress = APZCCallbackHelper::IsScrollInProgress(aFrame);
if (!scrollInProgress) {
aFrame->ScrollToCSSPixelsApproximate(targetScrollPosition, nsGkAtoms::apz);
aFrame->ScrollToCSSPixelsApproximate(targetScrollPosition,
ScrollOrigin::Apz);
geckoScrollPosition = CSSPoint::FromAppUnits(aFrame->GetScrollPosition());
aSuccessOut = true;
}
@ -817,7 +818,7 @@ void APZCCallbackHelper::NotifyFlushComplete(PresShell* aPresShell) {
bool APZCCallbackHelper::IsScrollInProgress(nsIScrollableFrame* aFrame) {
return aFrame->IsProcessingAsyncScroll() ||
nsLayoutUtils::CanScrollOriginClobberApz(aFrame->LastScrollOrigin()) ||
aFrame->LastSmoothScrollOrigin();
aFrame->LastSmoothScrollOrigin() != ScrollOrigin::NotSpecified;
}
/* static */

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

@ -2337,10 +2337,10 @@ PresShell::ScrollPage(bool aForward) {
nsIScrollableFrame* scrollFrame =
GetScrollableFrameToScroll(ScrollableDirection::Vertical);
if (scrollFrame) {
scrollFrame->ScrollBy(nsIntPoint(0, aForward ? 1 : -1), ScrollUnit::PAGES,
ScrollMode::Smooth, nullptr, nullptr,
nsIScrollableFrame::NOT_MOMENTUM,
nsIScrollableFrame::ENABLE_SNAP);
scrollFrame->ScrollBy(
nsIntPoint(0, aForward ? 1 : -1), ScrollUnit::PAGES, ScrollMode::Smooth,
nullptr, mozilla::ScrollOrigin::NotSpecified,
nsIScrollableFrame::NOT_MOMENTUM, nsIScrollableFrame::ENABLE_SNAP);
}
return NS_OK;
}
@ -2353,10 +2353,10 @@ PresShell::ScrollLine(bool aForward) {
int32_t lineCount =
Preferences::GetInt("toolkit.scrollbox.verticalScrollDistance",
NS_DEFAULT_VERTICAL_SCROLL_DISTANCE);
scrollFrame->ScrollBy(nsIntPoint(0, aForward ? lineCount : -lineCount),
ScrollUnit::LINES, ScrollMode::Smooth, nullptr,
nullptr, nsIScrollableFrame::NOT_MOMENTUM,
nsIScrollableFrame::ENABLE_SNAP);
scrollFrame->ScrollBy(
nsIntPoint(0, aForward ? lineCount : -lineCount), ScrollUnit::LINES,
ScrollMode::Smooth, nullptr, mozilla::ScrollOrigin::NotSpecified,
nsIScrollableFrame::NOT_MOMENTUM, nsIScrollableFrame::ENABLE_SNAP);
}
return NS_OK;
}
@ -2369,10 +2369,10 @@ PresShell::ScrollCharacter(bool aRight) {
int32_t h =
Preferences::GetInt("toolkit.scrollbox.horizontalScrollDistance",
NS_DEFAULT_HORIZONTAL_SCROLL_DISTANCE);
scrollFrame->ScrollBy(nsIntPoint(aRight ? h : -h, 0), ScrollUnit::LINES,
ScrollMode::Smooth, nullptr, nullptr,
nsIScrollableFrame::NOT_MOMENTUM,
nsIScrollableFrame::ENABLE_SNAP);
scrollFrame->ScrollBy(
nsIntPoint(aRight ? h : -h, 0), ScrollUnit::LINES, ScrollMode::Smooth,
nullptr, mozilla::ScrollOrigin::NotSpecified,
nsIScrollableFrame::NOT_MOMENTUM, nsIScrollableFrame::ENABLE_SNAP);
}
return NS_OK;
}
@ -2382,10 +2382,10 @@ PresShell::CompleteScroll(bool aForward) {
nsIScrollableFrame* scrollFrame =
GetScrollableFrameToScroll(ScrollableDirection::Vertical);
if (scrollFrame) {
scrollFrame->ScrollBy(nsIntPoint(0, aForward ? 1 : -1), ScrollUnit::WHOLE,
ScrollMode::Smooth, nullptr, nullptr,
nsIScrollableFrame::NOT_MOMENTUM,
nsIScrollableFrame::ENABLE_SNAP);
scrollFrame->ScrollBy(
nsIntPoint(0, aForward ? 1 : -1), ScrollUnit::WHOLE, ScrollMode::Smooth,
nullptr, mozilla::ScrollOrigin::NotSpecified,
nsIScrollableFrame::NOT_MOMENTUM, nsIScrollableFrame::ENABLE_SNAP);
}
return NS_OK;
}

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

@ -24,6 +24,7 @@
#include "mozilla/MemoryReporting.h"
#include "mozilla/PerfStats.h"
#include "mozilla/PresShell.h"
#include "mozilla/ScrollOrigin.h"
#include "mozilla/ServoStyleSetInlines.h"
#include "mozilla/StaticPrefs_apz.h"
#include "mozilla/StaticPrefs_dom.h"
@ -9023,9 +9024,15 @@ void nsLayoutUtils::SetVisualViewportSize(PresShell* aPresShell,
}
/* static */
bool nsLayoutUtils::CanScrollOriginClobberApz(nsAtom* aScrollOrigin) {
return aScrollOrigin != nullptr && aScrollOrigin != nsGkAtoms::apz &&
aScrollOrigin != nsGkAtoms::restore;
bool nsLayoutUtils::CanScrollOriginClobberApz(ScrollOrigin aScrollOrigin) {
switch (aScrollOrigin) {
case ScrollOrigin::NotSpecified:
case ScrollOrigin::Apz:
case ScrollOrigin::Restore:
return false;
default:
return true;
}
}
/* static */
@ -9163,20 +9170,21 @@ ScrollMetadata nsLayoutUtils::ComputeScrollMetadata(
// its scroll offset. We want to distinguish the case where the scroll
// offset was "restored" because in that case the restored scroll position
// should not overwrite a user-driven scroll.
nsAtom* lastOrigin = scrollableFrame->LastScrollOrigin();
if (lastOrigin == nsGkAtoms::restore) {
ScrollOrigin lastOrigin = scrollableFrame->LastScrollOrigin();
if (lastOrigin == ScrollOrigin::Restore) {
metrics.SetScrollGeneration(scrollableFrame->CurrentScrollGeneration());
metrics.SetScrollOffsetUpdateType(FrameMetrics::eRestore);
} else if (CanScrollOriginClobberApz(lastOrigin)) {
if (lastOrigin == nsGkAtoms::relative) {
if (lastOrigin == ScrollOrigin::Relative) {
metrics.SetIsRelative(true);
}
metrics.SetScrollGeneration(scrollableFrame->CurrentScrollGeneration());
metrics.SetScrollOffsetUpdateType(FrameMetrics::eMainThread);
}
nsAtom* lastSmoothScrollOrigin = scrollableFrame->LastSmoothScrollOrigin();
if (lastSmoothScrollOrigin) {
ScrollOrigin lastSmoothScrollOrigin =
scrollableFrame->LastSmoothScrollOrigin();
if (lastSmoothScrollOrigin != ScrollOrigin::NotSpecified) {
metrics.SetSmoothScrollOffsetUpdated(
scrollableFrame->CurrentScrollGeneration());
}

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

@ -74,6 +74,7 @@ class WritingMode;
class DisplayItemClip;
class EffectSet;
struct ActiveScrolledRoot;
enum class ScrollOrigin : uint8_t;
enum class StyleImageOrientation : uint8_t;
namespace dom {
class CanvasRenderingContext2D;
@ -149,6 +150,7 @@ class nsLayoutUtils {
typedef mozilla::ContainerLayerParameters ContainerLayerParameters;
typedef mozilla::IntrinsicSize IntrinsicSize;
typedef mozilla::RelativeTo RelativeTo;
typedef mozilla::ScrollOrigin ScrollOrigin;
typedef mozilla::ViewportType ViewportType;
typedef mozilla::gfx::SourceSurface SourceSurface;
typedef mozilla::gfx::sRGBColor sRGBColor;
@ -2870,7 +2872,7 @@ class nsLayoutUtils {
* returns true for those, and returns false for other origins like APZ
* itself, or scroll position updates from the history restore code.
*/
static bool CanScrollOriginClobberApz(nsAtom* aScrollOrigin);
static bool CanScrollOriginClobberApz(ScrollOrigin aScrollOrigin);
static ScrollMetadata ComputeScrollMetadata(
nsIFrame* aForFrame, nsIFrame* aScrollFrame, nsIContent* aContent,

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

@ -482,7 +482,7 @@ void ScrollAnchorContainer::ApplyAdjustments() {
// We should use AutoRestore here, but that doesn't work with bitfields
mApplyingAnchorAdjustment = true;
mScrollFrame->ScrollTo(mScrollFrame->GetScrollPosition() + physicalAdjustment,
ScrollMode::Instant, nsGkAtoms::relative);
ScrollMode::Instant, ScrollOrigin::Relative);
mApplyingAnchorAdjustment = false;
nsPresContext* pc = Frame()->PresContext();

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

@ -0,0 +1,58 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#ifndef mozilla_ScrollOrigin_h_
#define mozilla_ScrollOrigin_h_
namespace mozilla {
// A scroll origin is a bit of a combination of "what part of the code caused
// this scroll" and "what special properties does this scroll have, in the
// context of what caused it". See specific comments below.
enum class ScrollOrigin : uint8_t {
// This is a default value that we use when we don't know of a more specific
// value that we can use. Note that for the "LastSmoothScrollOrigin" property
// on a scrollable frame, the NotSpecified value is special, in that it means
// there is no smooth scroll in progress.
NotSpecified,
// The scroll came from APZ code.
Apz,
// The scroll came from an attempt at restoring a scroll position saved in
// the bfcache or history.
Restore,
// The scroll came from a "relative" scroll method like ScrollBy, where the
// scroll destination is indicated by a delta from the current position
// instead of an absolute value.
Relative,
// The following scroll origins also are associated with prefs of the form
// general.smoothScroll.<origin>(.*)
// e.g. general.smoothScroll.lines indicates whether or not a scroll with
// origin Lines will be animated smoothly, and e.g. subprefs like
// general.smoothScroll.lines.durationMinMS control some of the animation
// timing behavior.
// The scroll came from some sort of input that's not one of the above or
// below values. Generally this means it came from a content-exposed API,
// like window.scrollTo, but may also be from other sources that don't need
// any particular special handling.
Other,
// The scroll was originated by pixel-scrolling input device (e.g. precision
// mouse wheel).
Pixels,
// The scroll was originated by a line-scrolling input device (e.g. up/down
// keyboard buttons).
Lines,
// The scroll was originated by a page-scrolling input device (e.g. pgup/
// pgdn keyboard buttons).
Pages,
// The scroll was originated by a mousewheel that scrolls by lines.
MouseWheel,
// The scroll was originated by moving the scrollbars.
Scrollbars,
};
} // namespace mozilla
#endif // mozilla_ScrollOrigin_h_

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

@ -151,6 +151,7 @@ EXPORTS.mozilla += [
'ReflowInput.h',
'ReflowOutput.h',
'ScrollbarPreferences.h',
'ScrollOrigin.h',
'ViewportFrame.h',
'WritingModes.h',
]

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

@ -1507,7 +1507,7 @@ void ScrollFrameHelper::ScrollByLine(
nsIntPoint overflow;
ScrollBy(delta, ScrollUnit::LINES, ScrollMode::Smooth, &overflow,
nsGkAtoms::other, nsIScrollableFrame::NOT_MOMENTUM, aSnap);
ScrollOrigin::Other, nsIScrollableFrame::NOT_MOMENTUM, aSnap);
}
void ScrollFrameHelper::RepeatButtonScroll(nsScrollbarFrame* aScrollbar) {
@ -1534,7 +1534,7 @@ void ScrollFrameHelper::ThumbMoved(nsScrollbarFrame* aScrollbar,
return;
}
ScrollTo(dest, ScrollMode::Instant, nsGkAtoms::other, &allowedRange);
ScrollTo(dest, ScrollMode::Instant, ScrollOrigin::Other, &allowedRange);
}
void ScrollFrameHelper::ScrollbarReleased(nsScrollbarFrame* aScrollbar) {
@ -1559,7 +1559,7 @@ void ScrollFrameHelper::ScrollByUnit(
delta.y = aDirection;
}
nsIntPoint overflow;
ScrollBy(delta, aUnit, aMode, &overflow, nsGkAtoms::other,
ScrollBy(delta, aUnit, aMode, &overflow, ScrollOrigin::Other,
nsIScrollableFrame::NOT_MOMENTUM, aSnap);
}
@ -1838,7 +1838,8 @@ class ScrollFrameHelper::AsyncScroll final : public nsARefreshObserver {
typedef mozilla::TimeStamp TimeStamp;
typedef mozilla::TimeDuration TimeDuration;
explicit AsyncScroll() : mCallee(nullptr) {
explicit AsyncScroll()
: mOrigin(ScrollOrigin::NotSpecified), mCallee(nullptr) {
Telemetry::SetHistogramRecordingEnabled(
Telemetry::FX_REFRESH_DRIVER_SYNC_SCROLL_FRAME_DELAY_MS, true);
}
@ -1853,7 +1854,7 @@ class ScrollFrameHelper::AsyncScroll final : public nsARefreshObserver {
public:
void InitSmoothScroll(TimeStamp aTime, nsPoint aInitialPosition,
nsPoint aDestination, nsAtom* aOrigin,
nsPoint aDestination, ScrollOrigin aOrigin,
const nsRect& aRange, const nsSize& aCurrentVelocity);
void Init(const nsRect& aRange) {
mAnimationPhysics = nullptr;
@ -1878,7 +1879,7 @@ class ScrollFrameHelper::AsyncScroll final : public nsARefreshObserver {
}
// Most recent scroll origin.
RefPtr<nsAtom> mOrigin;
ScrollOrigin mOrigin;
// Allowed destination positions around mDestination
nsRect mRange;
@ -1943,7 +1944,7 @@ class ScrollFrameHelper::AsyncScroll final : public nsARefreshObserver {
* origin. (also maintain previous timestamps - which are only used here).
*/
static ScrollAnimationBezierPhysicsSettings
ComputeBezierAnimationSettingsForOrigin(nsAtom* aOrigin) {
ComputeBezierAnimationSettingsForOrigin(ScrollOrigin aOrigin) {
int32_t minMS = 0;
int32_t maxMS = 0;
bool isOriginSmoothnessEnabled = false;
@ -1953,10 +1954,27 @@ ComputeBezierAnimationSettingsForOrigin(nsAtom* aOrigin) {
static const int32_t kDefaultMinMS = 150, kDefaultMaxMS = 150;
static const bool kDefaultIsSmoothEnabled = true;
nsAutoCString originName;
aOrigin->ToUTF8String(originName);
nsAutoCString prefBase =
NS_LITERAL_CSTRING("general.smoothScroll.") + originName;
nsAutoCString prefBase;
switch (aOrigin) {
case ScrollOrigin::Pixels:
prefBase = NS_LITERAL_CSTRING("general.smoothScroll.pixels");
break;
case ScrollOrigin::Lines:
prefBase = NS_LITERAL_CSTRING("general.smoothScroll.lines");
break;
case ScrollOrigin::Pages:
prefBase = NS_LITERAL_CSTRING("general.smoothScroll.pages");
break;
case ScrollOrigin::MouseWheel:
prefBase = NS_LITERAL_CSTRING("general.smoothScroll.mouseWheel");
break;
case ScrollOrigin::Scrollbars:
prefBase = NS_LITERAL_CSTRING("general.smoothScroll.scrollbars");
break;
default:
prefBase = NS_LITERAL_CSTRING("general.smoothScroll.other");
break;
}
isOriginSmoothnessEnabled =
Preferences::GetBool(prefBase.get(), kDefaultIsSmoothEnabled);
@ -1990,17 +2008,26 @@ ComputeBezierAnimationSettingsForOrigin(nsAtom* aOrigin) {
void ScrollFrameHelper::AsyncScroll::InitSmoothScroll(
TimeStamp aTime, nsPoint aInitialPosition, nsPoint aDestination,
nsAtom* aOrigin, const nsRect& aRange, const nsSize& aCurrentVelocity) {
if (!aOrigin || aOrigin == nsGkAtoms::restore ||
aOrigin == nsGkAtoms::relative) {
// We don't have special prefs for "restore", just treat it as "other".
// "restore" scrolls are (for now) always instant anyway so unless something
// changes we should never have aOrigin == nsGkAtoms::restore here.
aOrigin = nsGkAtoms::other;
}
// Likewise we should never get APZ-triggered scrolls here, and if that
// changes something is likely broken somewhere.
MOZ_ASSERT(aOrigin != nsGkAtoms::apz);
ScrollOrigin aOrigin, const nsRect& aRange,
const nsSize& aCurrentVelocity) {
switch (aOrigin) {
case ScrollOrigin::NotSpecified:
case ScrollOrigin::Restore:
case ScrollOrigin::Relative:
// We don't have special prefs for "restore", just treat it as "other".
// "restore" scrolls are (for now) always instant anyway so unless
// something changes we should never have aOrigin ==
// ScrollOrigin::Restore here.
aOrigin = ScrollOrigin::Other;
break;
case ScrollOrigin::Apz:
// Likewise we should never get APZ-triggered scrolls here, and if that
// changes something is likely broken somewhere.
MOZ_ASSERT(false);
break;
default:
break;
};
// Read preferences only on first iteration or for a different event origin.
if (!mAnimationPhysics || aOrigin != mOrigin) {
@ -2062,8 +2089,8 @@ ScrollFrameHelper::ScrollFrameHelper(nsContainerFrame* aOuter, bool aIsRoot)
mReferenceFrameDuringPainting(nullptr),
mAsyncScroll(nullptr),
mAsyncSmoothMSDScroll(nullptr),
mLastScrollOrigin(nsGkAtoms::other),
mLastSmoothScrollOrigin(nullptr),
mLastScrollOrigin(ScrollOrigin::Other),
mLastSmoothScrollOrigin(ScrollOrigin::NotSpecified),
mScrollGeneration(++sScrollGenerationCounter),
mDestination(0, 0),
mRestorePos(-1, -1),
@ -2194,7 +2221,7 @@ void ScrollFrameHelper::AsyncScrollCallback(ScrollFrameHelper* aInstance,
}
void ScrollFrameHelper::CompleteAsyncScroll(const nsRect& aRange,
nsAtom* aOrigin) {
ScrollOrigin aOrigin) {
// Apply desired destination range since this is the last step of scrolling.
RemoveObservers();
AutoWeakFrame weakFrame(mOuter);
@ -2228,17 +2255,17 @@ bool ScrollFrameHelper::HasBgAttachmentLocal() const {
}
void ScrollFrameHelper::ScrollTo(nsPoint aScrollPosition, ScrollMode aMode,
nsAtom* aOrigin, const nsRect* aRange,
ScrollOrigin aOrigin, const nsRect* aRange,
nsIScrollbarMediator::ScrollSnapMode aSnap) {
if (aOrigin == nullptr) {
aOrigin = nsGkAtoms::other;
if (aOrigin == ScrollOrigin::NotSpecified) {
aOrigin = ScrollOrigin::Other;
}
ScrollToWithOrigin(aScrollPosition, aMode, aOrigin, aRange, aSnap);
}
void ScrollFrameHelper::ScrollToCSSPixels(
const CSSIntPoint& aScrollPosition, ScrollMode aMode,
nsIScrollbarMediator::ScrollSnapMode aSnap, nsAtom* aOrigin) {
nsIScrollbarMediator::ScrollSnapMode aSnap, ScrollOrigin aOrigin) {
nsPoint current = GetScrollPosition();
CSSIntPoint currentCSSPixels = GetScrollPositionCSSPixels();
nsPoint pt = CSSPoint::ToAppUnits(aScrollPosition);
@ -2246,8 +2273,8 @@ void ScrollFrameHelper::ScrollToCSSPixels(
aSnap = nsIScrollableFrame::ENABLE_SNAP;
}
if (aOrigin == nullptr) {
aOrigin = nsGkAtoms::other;
if (aOrigin == ScrollOrigin::NotSpecified) {
aOrigin = ScrollOrigin::Other;
}
nscoord halfPixel = nsPresContext::CSSPixelsToAppUnits(0.5f);
@ -2271,7 +2298,7 @@ void ScrollFrameHelper::ScrollToCSSPixels(
}
void ScrollFrameHelper::ScrollToCSSPixelsApproximate(
const CSSPoint& aScrollPosition, nsAtom* aOrigin) {
const CSSPoint& aScrollPosition, ScrollOrigin aOrigin) {
nsPoint pt = CSSPoint::ToAppUnits(aScrollPosition);
nscoord halfRange = nsPresContext::CSSPixelsToAppUnits(1000);
nsRect range(pt.x - halfRange, pt.y - halfRange, 2 * halfRange - 1,
@ -2289,9 +2316,9 @@ CSSIntPoint ScrollFrameHelper::GetScrollPositionCSSPixels() {
* incrementally, based on the setting of the smoothness scroll pref
*/
void ScrollFrameHelper::ScrollToWithOrigin(
nsPoint aScrollPosition, ScrollMode aMode, nsAtom* aOrigin,
nsPoint aScrollPosition, ScrollMode aMode, ScrollOrigin aOrigin,
const nsRect* aRange, nsIScrollbarMediator::ScrollSnapMode aSnap) {
if (aOrigin != nsGkAtoms::restore) {
if (aOrigin != ScrollOrigin::Restore) {
// If we're doing a non-restore scroll, we don't want to later
// override it by restoring our saved scroll position.
mRestorePos.x = mRestorePos.y = -1;
@ -2305,11 +2332,11 @@ void ScrollFrameHelper::ScrollToWithOrigin(
nsRect scrollRange = GetLayoutScrollRange();
mDestination = scrollRange.ClampPoint(aScrollPosition);
if (mDestination != aScrollPosition && aOrigin == nsGkAtoms::restore &&
if (mDestination != aScrollPosition && aOrigin == ScrollOrigin::Restore &&
GetPageLoadingState() != LoadingState::Loading) {
// If we're doing a restore but the scroll position is clamped, promote
// the origin from one that APZ can clobber to one that it can't clobber.
aOrigin = nsGkAtoms::other;
aOrigin = ScrollOrigin::Other;
}
nsRect range =
@ -2704,23 +2731,24 @@ bool ScrollFrameHelper::GetDisplayPortAtLastApproximateFrameVisibilityUpdate(
}
void ScrollFrameHelper::ScrollToImpl(nsPoint aPt, const nsRect& aRange,
nsAtom* aOrigin) {
ScrollOrigin aOrigin) {
// Figure out the effective origin for this scroll request.
if (aOrigin == nullptr) {
if (aOrigin == ScrollOrigin::NotSpecified) {
// If no origin was specified, we still want to set it to something that's
// non-null, so that we can use nullness to distinguish if the frame was
// non-unknown, so that we can use eUnknown to distinguish if the frame was
// scrolled at all. Default it to some generic placeholder.
aOrigin = nsGkAtoms::other;
aOrigin = ScrollOrigin::Other;
}
// If this scroll is |relative|, but we've already had a user scroll that
// was not relative, promote this origin to |other|. This ensures that we
// may only transmit a relative update to APZ if all scrolls since the last
// transaction or repaint request have been relative.
if (aOrigin == nsGkAtoms::relative &&
(mLastScrollOrigin && mLastScrollOrigin != nsGkAtoms::relative &&
mLastScrollOrigin != nsGkAtoms::apz)) {
aOrigin = nsGkAtoms::other;
if (aOrigin == ScrollOrigin::Relative &&
(mLastScrollOrigin != ScrollOrigin::NotSpecified &&
mLastScrollOrigin != ScrollOrigin::Relative &&
mLastScrollOrigin != ScrollOrigin::Apz)) {
aOrigin = ScrollOrigin::Other;
}
// If the origin is a downgrade, and downgrades are allowed, process the
@ -2798,8 +2826,8 @@ void ScrollFrameHelper::ScrollToImpl(nsPoint aPt, const nsRect& aRange,
// Respect the priority of origins (an "eRestore" layout scroll should
// not clobber an "eMainThread" visual scroll.)
bool shouldClobber =
aOrigin == nsGkAtoms::other ||
(aOrigin == nsGkAtoms::restore &&
aOrigin == ScrollOrigin::Other ||
(aOrigin == ScrollOrigin::Restore &&
visualScrollUpdate->mUpdateType == FrameMetrics::eRestore);
if (shouldClobber) {
ps->AcknowledgePendingVisualScrollUpdate();
@ -2858,9 +2886,9 @@ void ScrollFrameHelper::ScrollToImpl(nsPoint aPt, const nsRect& aRange,
mLastScrollOrigin = aOrigin;
mAllowScrollOriginDowngrade = false;
}
mLastSmoothScrollOrigin = nullptr;
mLastSmoothScrollOrigin = ScrollOrigin::NotSpecified;
mScrollGeneration = ++sScrollGenerationCounter;
if (mLastScrollOrigin == nsGkAtoms::apz) {
if (mLastScrollOrigin == ScrollOrigin::Apz) {
mApzScrollPos = GetScrollPosition();
}
@ -2926,7 +2954,7 @@ void ScrollFrameHelper::ScrollToImpl(nsPoint aPt, const nsRect& aRange,
bool apzDisabled = haveScrollLinkedEffects &&
StaticPrefs::apz_disable_for_scroll_linked_effects();
if (!apzDisabled && !HasPluginFrames()) {
if (LastScrollOrigin() == nsGkAtoms::apz) {
if (LastScrollOrigin() == ScrollOrigin::Apz) {
schedulePaint = false;
PAINT_SKIP_LOG("Skipping due to APZ scroll\n");
} else if (mScrollableByAPZ) {
@ -2945,7 +2973,7 @@ void ScrollFrameHelper::ScrollToImpl(nsPoint aPt, const nsRect& aRange,
id,
{mScrollGeneration, CSSPoint::FromAppUnits(GetScrollPosition()),
CSSPoint::FromAppUnits(GetApzScrollPosition()),
mLastScrollOrigin == nsGkAtoms::relative});
mLastScrollOrigin == ScrollOrigin::Relative});
if (success) {
schedulePaint = false;
mOuter->SchedulePaint(nsIFrame::PAINT_COMPOSITE_ONLY);
@ -4248,7 +4276,7 @@ static void CalcRangeForScrollBy(int32_t aDelta, nscoord aPos,
void ScrollFrameHelper::ScrollBy(nsIntPoint aDelta, ScrollUnit aUnit,
ScrollMode aMode, nsIntPoint* aOverflow,
nsAtom* aOrigin,
ScrollOrigin aOrigin,
nsIScrollableFrame::ScrollMomentum aMomentum,
nsIScrollbarMediator::ScrollSnapMode aSnap) {
// When a smooth scroll is being processed on a frame, mouse wheel and
@ -4277,17 +4305,17 @@ void ScrollFrameHelper::ScrollBy(nsIntPoint aDelta, ScrollUnit aUnit,
nsSize deltaMultiplier;
float negativeTolerance;
float positiveTolerance;
if (!aOrigin) {
aOrigin = nsGkAtoms::other;
if (aOrigin == ScrollOrigin::NotSpecified) {
aOrigin = ScrollOrigin::Other;
}
bool isGenericOrigin = (aOrigin == nsGkAtoms::other);
bool isGenericOrigin = (aOrigin == ScrollOrigin::Other);
switch (aUnit) {
case ScrollUnit::DEVICE_PIXELS: {
nscoord appUnitsPerDevPixel =
mOuter->PresContext()->AppUnitsPerDevPixel();
deltaMultiplier = nsSize(appUnitsPerDevPixel, appUnitsPerDevPixel);
if (isGenericOrigin) {
aOrigin = nsGkAtoms::pixels;
aOrigin = ScrollOrigin::Pixels;
}
negativeTolerance = positiveTolerance = 0.5f;
break;
@ -4295,7 +4323,7 @@ void ScrollFrameHelper::ScrollBy(nsIntPoint aDelta, ScrollUnit aUnit,
case ScrollUnit::LINES: {
deltaMultiplier = GetLineScrollAmount();
if (isGenericOrigin) {
aOrigin = nsGkAtoms::lines;
aOrigin = ScrollOrigin::Lines;
}
negativeTolerance = positiveTolerance = 0.1f;
break;
@ -4303,7 +4331,7 @@ void ScrollFrameHelper::ScrollBy(nsIntPoint aDelta, ScrollUnit aUnit,
case ScrollUnit::PAGES: {
deltaMultiplier = GetPageScrollAmount();
if (isGenericOrigin) {
aOrigin = nsGkAtoms::pages;
aOrigin = ScrollOrigin::Pages;
}
negativeTolerance = 0.05f;
positiveTolerance = 0;
@ -4316,7 +4344,7 @@ void ScrollFrameHelper::ScrollBy(nsIntPoint aDelta, ScrollUnit aUnit,
if (aSnap == nsIScrollableFrame::ENABLE_SNAP) {
GetSnapPointForDestination(aUnit, mDestination, pos);
}
ScrollTo(pos, aMode, nsGkAtoms::other);
ScrollTo(pos, aMode, ScrollOrigin::Other);
// 'this' might be destroyed here
if (aOverflow) {
*aOverflow = nsIntPoint(0, 0);
@ -4343,7 +4371,7 @@ void ScrollFrameHelper::ScrollBy(nsIntPoint aDelta, ScrollUnit aUnit,
negativeTolerance = 0.1f;
positiveTolerance = 0;
ScrollUnit snapUnit = aUnit;
if (aOrigin == nsGkAtoms::mouseWheel) {
if (aOrigin == ScrollOrigin::MouseWheel) {
// When using a clicky scroll wheel, snap point selection works the same
// as keyboard up/down/left/right navigation, but with varying amounts
// of scroll delta.
@ -4384,7 +4412,7 @@ void ScrollFrameHelper::ScrollBy(nsIntPoint aDelta, ScrollUnit aUnit,
}
void ScrollFrameHelper::ScrollByCSSPixels(
const CSSIntPoint& aDelta, ScrollMode aMode, nsAtom* aOrigin,
const CSSIntPoint& aDelta, ScrollMode aMode, ScrollOrigin aOrigin,
nsIScrollbarMediator::ScrollSnapMode aSnap) {
nsPoint current = GetScrollPosition();
// `current` value above might be a value which was aligned to in
@ -4403,8 +4431,8 @@ void ScrollFrameHelper::ScrollByCSSPixels(
aSnap = nsIScrollableFrame::ENABLE_SNAP;
}
if (aOrigin == nullptr) {
aOrigin = nsGkAtoms::other;
if (aOrigin == ScrollOrigin::NotSpecified) {
aOrigin = ScrollOrigin::Other;
}
nscoord halfPixel = nsPresContext::CSSPixelsToAppUnits(0.5f);
@ -4451,7 +4479,7 @@ void ScrollFrameHelper::ScrollSnap(const nsPoint& aDestination,
nsPoint snapDestination = scrollRange.ClampPoint(aDestination);
if (GetSnapPointForDestination(ScrollUnit::DEVICE_PIXELS, pos,
snapDestination)) {
ScrollTo(snapDestination, aMode, nsGkAtoms::other);
ScrollTo(snapDestination, aMode, ScrollOrigin::Other);
}
}
@ -4656,10 +4684,10 @@ void ScrollFrameHelper::ScrollToRestoredPosition() {
(GetVisualViewportSize().width - mScrolledFrame->GetRect().width);
}
AutoWeakFrame weakFrame(mOuter);
// It's very important to pass nsGkAtoms::restore here, so
// It's very important to pass ScrollOrigin::Restore here, so
// ScrollToWithOrigin won't clear out mRestorePos.
ScrollToWithOrigin(layoutScrollToPos, ScrollMode::Instant,
nsGkAtoms::restore, nullptr);
ScrollOrigin::Restore, nullptr);
if (!weakFrame.IsAlive()) {
return;
}
@ -5210,7 +5238,7 @@ void ScrollFrameHelper::CurPosAttributeChanged(nsIContent* aContent,
if (aDoScroll) {
ScrollToWithOrigin(dest,
isSmooth ? ScrollMode::Smooth : ScrollMode::Instant,
nsGkAtoms::scrollbars, &allowedRange);
ScrollOrigin::Scrollbars, &allowedRange);
}
// 'this' might be destroyed here
}
@ -6619,7 +6647,8 @@ UniquePtr<PresState> ScrollFrameHelper::SaveState() const {
// Don't store a scroll state if we never have been scrolled or restored
// a previous scroll state, and we're not in the middle of a smooth scroll.
bool isInSmoothScroll = IsProcessingAsyncScroll() || mLastSmoothScrollOrigin;
bool isInSmoothScroll = IsProcessingAsyncScroll() ||
mLastSmoothScrollOrigin != ScrollOrigin::NotSpecified;
if (!mHasBeenScrolled && !mDidHistoryRestore && !isInSmoothScroll) {
return nullptr;
}
@ -6656,7 +6685,7 @@ UniquePtr<PresState> ScrollFrameHelper::SaveState() const {
void ScrollFrameHelper::RestoreState(PresState* aState) {
mRestorePos = aState->scrollState();
MOZ_ASSERT(mLastScrollOrigin == nsGkAtoms::other);
MOZ_ASSERT(mLastScrollOrigin == ScrollOrigin::Other);
mAllowScrollOriginDowngrade = aState->allowScrollOriginDowngrade();
mDidHistoryRestore = true;
mLastPos = mScrolledFrame ? GetLogicalVisualViewportOffset() : nsPoint(0, 0);
@ -7120,7 +7149,7 @@ bool ScrollFrameHelper::DragScroll(WidgetEvent* aEvent) {
if (offset.x || offset.y) {
ScrollTo(GetScrollPosition() + offset, ScrollMode::Normal,
nsGkAtoms::other);
ScrollOrigin::Other);
}
return willScroll;
@ -7174,7 +7203,7 @@ void ScrollFrameHelper::AsyncScrollbarDragRejected() {
}
void ScrollFrameHelper::ApzSmoothScrollTo(const nsPoint& aDestination,
nsAtom* aOrigin) {
ScrollOrigin aOrigin) {
if (mApzSmoothScrollDestination == Some(aDestination) &&
mScrollGeneration == sScrollGenerationCounter) {
// If we already sent APZ a smooth-scroll request to this
@ -7198,6 +7227,7 @@ void ScrollFrameHelper::ApzSmoothScrollTo(const nsPoint& aDestination,
// The animation will be handled in the compositor, pass the
// information needed to start the animation and skip the main-thread
// animation for this scroll.
MOZ_ASSERT(aOrigin != ScrollOrigin::NotSpecified);
mLastSmoothScrollOrigin = aOrigin;
mApzSmoothScrollDestination = Some(aDestination);
mScrollGeneration = ++sScrollGenerationCounter;
@ -7243,8 +7273,8 @@ bool ScrollFrameHelper::SmoothScrollVisual(
// Perform the scroll.
ApzSmoothScrollTo(mDestination, aUpdateType == FrameMetrics::eRestore
? nsGkAtoms::restore
: nsGkAtoms::other);
? ScrollOrigin::Restore
: ScrollOrigin::Other);
return true;
}

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

@ -225,7 +225,8 @@ class ScrollFrameHelper : public nsIReflowCallback {
* This is a closed-ended range --- aRange.XMost()/aRange.YMost() are allowed.
*/
void ScrollTo(nsPoint aScrollPosition, ScrollMode aMode,
nsAtom* aOrigin = nullptr, const nsRect* aRange = nullptr,
ScrollOrigin aOrigin = ScrollOrigin::NotSpecified,
const nsRect* aRange = nullptr,
nsIScrollbarMediator::ScrollSnapMode aSnap =
nsIScrollbarMediator::DISABLE_SNAP);
/**
@ -235,32 +236,34 @@ class ScrollFrameHelper : public nsIReflowCallback {
ScrollMode aMode = ScrollMode::Instant,
nsIScrollbarMediator::ScrollSnapMode aSnap =
nsIScrollbarMediator::DEFAULT,
nsAtom* aOrigin = nullptr);
ScrollOrigin aOrigin = ScrollOrigin::NotSpecified);
/**
* @note This method might destroy the frame, pres shell and other objects.
*/
void ScrollToCSSPixelsApproximate(const mozilla::CSSPoint& aScrollPosition,
nsAtom* aOrigin = nullptr);
void ScrollToCSSPixelsApproximate(
const mozilla::CSSPoint& aScrollPosition,
ScrollOrigin aOrigin = ScrollOrigin::NotSpecified);
CSSIntPoint GetScrollPositionCSSPixels();
/**
* @note This method might destroy the frame, pres shell and other objects.
*/
void ScrollToImpl(nsPoint aScrollPosition, const nsRect& aRange,
nsAtom* aOrigin = nullptr);
ScrollOrigin aOrigin = ScrollOrigin::NotSpecified);
void ScrollVisual();
/**
* @note This method might destroy the frame, pres shell and other objects.
*/
void ScrollBy(nsIntPoint aDelta, mozilla::ScrollUnit aUnit, ScrollMode aMode,
nsIntPoint* aOverflow, nsAtom* aOrigin = nullptr,
nsIntPoint* aOverflow,
ScrollOrigin aOrigin = ScrollOrigin::NotSpecified,
nsIScrollableFrame::ScrollMomentum aMomentum =
nsIScrollableFrame::NOT_MOMENTUM,
nsIScrollbarMediator::ScrollSnapMode aSnap =
nsIScrollbarMediator::DISABLE_SNAP);
void ScrollByCSSPixels(const CSSIntPoint& aDelta,
ScrollMode aMode = ScrollMode::Instant,
nsAtom* aOrigin = nullptr,
ScrollOrigin aOrigin = ScrollOrigin::NotSpecified,
nsIScrollbarMediator::ScrollSnapMode aSnap =
nsIScrollbarMediator::DEFAULT);
/**
@ -455,14 +458,16 @@ class ScrollFrameHelper : public nsIReflowCallback {
void HandleScrollbarStyleSwitching();
nsAtom* LastScrollOrigin() const { return mLastScrollOrigin; }
nsAtom* LastSmoothScrollOrigin() const { return mLastSmoothScrollOrigin; }
ScrollOrigin LastScrollOrigin() const { return mLastScrollOrigin; }
ScrollOrigin LastSmoothScrollOrigin() const {
return mLastSmoothScrollOrigin;
}
uint32_t CurrentScrollGeneration() const { return mScrollGeneration; }
nsPoint LastScrollDestination() const { return mDestination; }
void ResetScrollInfoIfGeneration(uint32_t aGeneration) {
if (aGeneration == mScrollGeneration) {
mLastScrollOrigin = nullptr;
mLastSmoothScrollOrigin = nullptr;
mLastScrollOrigin = ScrollOrigin::NotSpecified;
mLastSmoothScrollOrigin = ScrollOrigin::NotSpecified;
}
}
bool WantAsyncScroll() const;
@ -551,8 +556,8 @@ class ScrollFrameHelper : public nsIReflowCallback {
RefPtr<AsyncSmoothMSDScroll> mAsyncSmoothMSDScroll;
RefPtr<ScrollbarActivity> mScrollbarActivity;
nsTArray<nsIScrollPositionListener*> mListeners;
nsAtom* mLastScrollOrigin;
nsAtom* mLastSmoothScrollOrigin;
ScrollOrigin mLastScrollOrigin;
ScrollOrigin mLastSmoothScrollOrigin;
Maybe<nsPoint> mApzSmoothScrollDestination;
uint32_t mScrollGeneration;
// NOTE: On mobile this value might be factoring into overflow:hidden region
@ -724,12 +729,12 @@ class ScrollFrameHelper : public nsIReflowCallback {
* @note This method might destroy the frame, pres shell and other objects.
*/
void ScrollToWithOrigin(nsPoint aScrollPosition, ScrollMode aMode,
nsAtom* aOrigin, // nullptr indicates "other" origin
const nsRect* aRange,
ScrollOrigin aOrigin, const nsRect* aRange,
nsIScrollbarMediator::ScrollSnapMode aSnap =
nsIScrollbarMediator::DISABLE_SNAP);
void CompleteAsyncScroll(const nsRect& aRange, nsAtom* aOrigin = nullptr);
void CompleteAsyncScroll(const nsRect& aRange,
ScrollOrigin aOrigin = ScrollOrigin::NotSpecified);
bool HasPluginFrames();
bool HasPerspective() const { return mOuter->ChildrenHavePerspective(); }
@ -740,7 +745,7 @@ class ScrollFrameHelper : public nsIReflowCallback {
// This method does not clamp the destination; callers should clamp it to
// either the layout or the visual scroll range (APZ will happily smooth
// scroll to either).
void ApzSmoothScrollTo(const nsPoint& aDestination, nsAtom* aOrigin);
void ApzSmoothScrollTo(const nsPoint& aDestination, ScrollOrigin aOrigin);
// Removes any RefreshDriver observers we might have registered.
void RemoveObservers();
@ -930,20 +935,23 @@ class nsHTMLScrollFrame : public nsContainerFrame,
const nsRect* aRange = nullptr,
nsIScrollbarMediator::ScrollSnapMode aSnap =
nsIScrollbarMediator::DISABLE_SNAP) final {
mHelper.ScrollTo(aScrollPosition, aMode, nsGkAtoms::other, aRange, aSnap);
mHelper.ScrollTo(aScrollPosition, aMode, ScrollOrigin::Other, aRange,
aSnap);
}
/**
* @note This method might destroy the frame, pres shell and other objects.
*/
void ScrollToCSSPixels(const CSSIntPoint& aScrollPosition,
ScrollMode aMode = ScrollMode::Instant,
nsIScrollbarMediator::ScrollSnapMode aSnap =
nsIScrollbarMediator::DEFAULT,
nsAtom* aOrigin = nullptr) final {
void ScrollToCSSPixels(
const CSSIntPoint& aScrollPosition,
ScrollMode aMode = ScrollMode::Instant,
nsIScrollbarMediator::ScrollSnapMode aSnap =
nsIScrollbarMediator::DEFAULT,
ScrollOrigin aOrigin = ScrollOrigin::NotSpecified) final {
mHelper.ScrollToCSSPixels(aScrollPosition, aMode, aSnap, aOrigin);
}
void ScrollToCSSPixelsApproximate(const mozilla::CSSPoint& aScrollPosition,
nsAtom* aOrigin = nullptr) final {
void ScrollToCSSPixelsApproximate(
const mozilla::CSSPoint& aScrollPosition,
ScrollOrigin aOrigin = ScrollOrigin::NotSpecified) final {
mHelper.ScrollToCSSPixelsApproximate(aScrollPosition, aOrigin);
}
/**
@ -956,7 +964,8 @@ class nsHTMLScrollFrame : public nsContainerFrame,
* @note This method might destroy the frame, pres shell and other objects.
*/
void ScrollBy(nsIntPoint aDelta, mozilla::ScrollUnit aUnit, ScrollMode aMode,
nsIntPoint* aOverflow, nsAtom* aOrigin = nullptr,
nsIntPoint* aOverflow,
ScrollOrigin aOrigin = ScrollOrigin::NotSpecified,
nsIScrollableFrame::ScrollMomentum aMomentum =
nsIScrollableFrame::NOT_MOMENTUM,
nsIScrollbarMediator::ScrollSnapMode aSnap =
@ -966,7 +975,7 @@ class nsHTMLScrollFrame : public nsContainerFrame,
}
void ScrollByCSSPixels(const CSSIntPoint& aDelta,
ScrollMode aMode = ScrollMode::Instant,
nsAtom* aOrigin = nullptr,
ScrollOrigin aOrigin = ScrollOrigin::NotSpecified,
nsIScrollbarMediator::ScrollSnapMode aSnap =
nsIScrollbarMediator::DEFAULT) final {
mHelper.ScrollByCSSPixels(aDelta, aMode, aOrigin, aSnap);
@ -1017,8 +1026,8 @@ class nsHTMLScrollFrame : public nsContainerFrame,
nsRect ExpandRectToNearlyVisible(const nsRect& aRect) const final {
return mHelper.ExpandRectToNearlyVisible(aRect);
}
nsAtom* LastScrollOrigin() final { return mHelper.LastScrollOrigin(); }
nsAtom* LastSmoothScrollOrigin() final {
ScrollOrigin LastScrollOrigin() final { return mHelper.LastScrollOrigin(); }
ScrollOrigin LastSmoothScrollOrigin() final {
return mHelper.LastSmoothScrollOrigin();
}
uint32_t CurrentScrollGeneration() final {
@ -1400,20 +1409,23 @@ class nsXULScrollFrame final : public nsBoxFrame,
void ScrollTo(
nsPoint aScrollPosition, ScrollMode aMode, const nsRect* aRange = nullptr,
ScrollSnapMode aSnap = nsIScrollbarMediator::DISABLE_SNAP) final {
mHelper.ScrollTo(aScrollPosition, aMode, nsGkAtoms::other, aRange, aSnap);
mHelper.ScrollTo(aScrollPosition, aMode, ScrollOrigin::Other, aRange,
aSnap);
}
/**
* @note This method might destroy the frame, pres shell and other objects.
*/
void ScrollToCSSPixels(const CSSIntPoint& aScrollPosition,
ScrollMode aMode = ScrollMode::Instant,
nsIScrollbarMediator::ScrollSnapMode aSnap =
nsIScrollbarMediator::DISABLE_SNAP,
nsAtom* aOrigin = nullptr) final {
void ScrollToCSSPixels(
const CSSIntPoint& aScrollPosition,
ScrollMode aMode = ScrollMode::Instant,
nsIScrollbarMediator::ScrollSnapMode aSnap =
nsIScrollbarMediator::DISABLE_SNAP,
ScrollOrigin aOrigin = ScrollOrigin::NotSpecified) final {
mHelper.ScrollToCSSPixels(aScrollPosition, aMode, aSnap, aOrigin);
}
void ScrollToCSSPixelsApproximate(const mozilla::CSSPoint& aScrollPosition,
nsAtom* aOrigin = nullptr) final {
void ScrollToCSSPixelsApproximate(
const mozilla::CSSPoint& aScrollPosition,
ScrollOrigin aOrigin = ScrollOrigin::NotSpecified) final {
mHelper.ScrollToCSSPixelsApproximate(aScrollPosition, aOrigin);
}
CSSIntPoint GetScrollPositionCSSPixels() final {
@ -1423,7 +1435,8 @@ class nsXULScrollFrame final : public nsBoxFrame,
* @note This method might destroy the frame, pres shell and other objects.
*/
void ScrollBy(nsIntPoint aDelta, mozilla::ScrollUnit aUnit, ScrollMode aMode,
nsIntPoint* aOverflow, nsAtom* aOrigin = nullptr,
nsIntPoint* aOverflow,
ScrollOrigin aOrigin = ScrollOrigin::NotSpecified,
nsIScrollableFrame::ScrollMomentum aMomentum =
nsIScrollableFrame::NOT_MOMENTUM,
nsIScrollbarMediator::ScrollSnapMode aSnap =
@ -1433,7 +1446,7 @@ class nsXULScrollFrame final : public nsBoxFrame,
}
void ScrollByCSSPixels(const CSSIntPoint& aDelta,
ScrollMode aMode = ScrollMode::Instant,
nsAtom* aOrigin = nullptr,
ScrollOrigin aOrigin = ScrollOrigin::NotSpecified,
nsIScrollbarMediator::ScrollSnapMode aSnap =
nsIScrollbarMediator::DEFAULT) final {
mHelper.ScrollByCSSPixels(aDelta, aMode, aOrigin, aSnap);
@ -1484,8 +1497,8 @@ class nsXULScrollFrame final : public nsBoxFrame,
nsRect ExpandRectToNearlyVisible(const nsRect& aRect) const final {
return mHelper.ExpandRectToNearlyVisible(aRect);
}
nsAtom* LastScrollOrigin() final { return mHelper.LastScrollOrigin(); }
nsAtom* LastSmoothScrollOrigin() final {
ScrollOrigin LastScrollOrigin() final { return mHelper.LastScrollOrigin(); }
ScrollOrigin LastSmoothScrollOrigin() final {
return mHelper.LastSmoothScrollOrigin();
}
uint32_t CurrentScrollGeneration() final {

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

@ -13,6 +13,7 @@
#include "nsCoord.h"
#include "mozilla/Maybe.h"
#include "mozilla/ScrollOrigin.h"
#include "mozilla/ScrollStyles.h"
#include "mozilla/ScrollTypes.h"
#include "mozilla/gfx/Point.h"
@ -29,7 +30,6 @@ class nsIScrollPositionListener;
class nsIFrame;
class nsPresContext;
class nsIContent;
class nsAtom;
class nsDisplayListBuilder;
namespace mozilla {
@ -57,6 +57,7 @@ class nsIScrollableFrame : public nsIScrollbarMediator {
typedef mozilla::layers::ScrollSnapInfo ScrollSnapInfo;
typedef mozilla::layout::ScrollAnchorContainer ScrollAnchorContainer;
typedef mozilla::ScrollMode ScrollMode;
typedef mozilla::ScrollOrigin ScrollOrigin;
NS_DECL_QUERYFRAME_TARGET(nsIScrollableFrame)
@ -267,11 +268,12 @@ class nsIScrollableFrame : public nsIScrollbarMediator {
* FIXME: Drop |aSnap| argument once after we finished the migration to the
* Scroll Snap Module v1. We should alway use ENABLE_SNAP.
*/
virtual void ScrollToCSSPixels(const CSSIntPoint& aScrollPosition,
ScrollMode aMode = ScrollMode::Instant,
nsIScrollbarMediator::ScrollSnapMode aSnap =
nsIScrollbarMediator::DEFAULT,
nsAtom* aOrigin = nullptr) = 0;
virtual void ScrollToCSSPixels(
const CSSIntPoint& aScrollPosition,
ScrollMode aMode = ScrollMode::Instant,
nsIScrollbarMediator::ScrollSnapMode aSnap =
nsIScrollbarMediator::DEFAULT,
ScrollOrigin aOrigin = ScrollOrigin::NotSpecified) = 0;
/**
* @note This method might destroy the frame, pres shell and other objects.
* Scrolls to a particular position in float CSS pixels.
@ -281,7 +283,8 @@ class nsIScrollableFrame : public nsIScrollbarMediator {
* number of layer pixels (so the operation is fast and looks clean).
*/
virtual void ScrollToCSSPixelsApproximate(
const mozilla::CSSPoint& aScrollPosition, nsAtom* aOrigin = nullptr) = 0;
const mozilla::CSSPoint& aScrollPosition,
ScrollOrigin aOrigin = ScrollOrigin::NotSpecified) = 0;
/**
* Returns the scroll position in integer CSS pixels, rounded to the nearest
@ -300,7 +303,7 @@ class nsIScrollableFrame : public nsIScrollbarMediator {
*/
virtual void ScrollBy(nsIntPoint aDelta, mozilla::ScrollUnit aUnit,
ScrollMode aMode, nsIntPoint* aOverflow = nullptr,
nsAtom* aOrigin = nullptr,
ScrollOrigin aOrigin = ScrollOrigin::NotSpecified,
ScrollMomentum aMomentum = NOT_MOMENTUM,
nsIScrollbarMediator::ScrollSnapMode aSnap =
nsIScrollbarMediator::DISABLE_SNAP) = 0;
@ -309,11 +312,11 @@ class nsIScrollableFrame : public nsIScrollbarMediator {
* FIXME: Drop |aSnap| argument once after we finished the migration to the
* Scroll Snap Module v1. We should alway use ENABLE_SNAP.
*/
virtual void ScrollByCSSPixels(const CSSIntPoint& aDelta,
ScrollMode aMode = ScrollMode::Instant,
nsAtom* aOrigin = nullptr,
nsIScrollbarMediator::ScrollSnapMode aSnap =
nsIScrollbarMediator::DEFAULT) = 0;
virtual void ScrollByCSSPixels(
const CSSIntPoint& aDelta, ScrollMode aMode = ScrollMode::Instant,
ScrollOrigin aOrigin = ScrollOrigin::NotSpecified,
nsIScrollbarMediator::ScrollSnapMode aSnap =
nsIScrollbarMediator::DEFAULT) = 0;
/**
* Perform scroll snapping, possibly resulting in a smooth scroll to
@ -413,13 +416,13 @@ class nsIScrollableFrame : public nsIScrollbarMediator {
virtual nsRect ExpandRectToNearlyVisible(const nsRect& aRect) const = 0;
/**
* Returns the origin that triggered the last instant scroll. Will equal
* nsGkAtoms::apz when the compositor's replica frame metrics includes the
* ScrollOrigin::Apz when the compositor's replica frame metrics includes the
* latest instant scroll.
*/
virtual nsAtom* LastScrollOrigin() = 0;
virtual ScrollOrigin LastScrollOrigin() = 0;
/**
* Returns the origin that triggered the last smooth scroll.
* Will equal nsGkAtoms::apz when the compositor's replica frame
* Will equal ScrollOrigin::Apz when the compositor's replica frame
* metrics includes the latest smooth scroll. The compositor will always
* perform an instant scroll prior to instantiating any smooth scrolls
* if LastScrollOrigin and LastSmoothScrollOrigin indicate that
@ -431,7 +434,7 @@ class nsIScrollableFrame : public nsIScrollbarMediator {
* by an instant scroll before the smooth scroll could be started by the
* compositor, this is set to nullptr to clear the smooth scroll.
*/
virtual nsAtom* LastSmoothScrollOrigin() = 0;
virtual ScrollOrigin LastSmoothScrollOrigin() = 0;
/**
* Returns the current generation counter for the scroll. This counter
* increments every time the scroll position is set.

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

@ -2276,22 +2276,6 @@ STATIC_ATOMS = [
Atom("ForwardMail", "ForwardMail"),
Atom("ReplyToMail", "ReplyToMail"),
# Scroll origins (these are used in various scrolling functions in
# nsIScrollableFrame and ScrollFrameHelper). These are divided into two lists
# - origins in the first one have smooth-scrolling prefs associated with them,
# under the "general.smoothScroll.<origin>.*" pref branch. Origins in the
# second one do not.
Atom("mouseWheel", "mouseWheel"), # For discrete wheel events (e.g. not OSX magic mouse)
Atom("pixels", "pixels"),
Atom("lines", "lines"),
Atom("pages", "pages"),
Atom("scrollbars", "scrollbars"),
# Atom("other", "other"), # "other" is present above
# Scroll origins without smooth-scrolling prefs
Atom("apz", "apz"),
Atom("restore", "restore"),
Atom("relative", "relative"),
Atom("alert", "alert"),
Atom("alertdialog", "alertdialog"),
Atom("application", "application"),