Bug 1602088 - Move nsIScrollableFrame::ScrollUnit to namespace scope. r=botond

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

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Kousuke Takaki 2020-01-30 09:13:19 +00:00
Родитель 2143f0959d
Коммит 9681569b70
17 изменённых файлов: 106 добавлений и 111 удалений

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

@ -3659,8 +3659,7 @@ void nsGlobalWindowInner::ScrollByLines(int32_t numLines,
? ScrollMode::SmoothMsd
: ScrollMode::Instant;
sf->ScrollBy(nsIntPoint(0, numLines), nsIScrollableFrame::LINES,
scrollMode);
sf->ScrollBy(nsIntPoint(0, numLines), ScrollUnit::LINES, scrollMode);
}
}
@ -3676,8 +3675,7 @@ void nsGlobalWindowInner::ScrollByPages(int32_t numPages,
? ScrollMode::SmoothMsd
: ScrollMode::Instant;
sf->ScrollBy(nsIntPoint(0, numPages), nsIScrollableFrame::PAGES,
scrollMode);
sf->ScrollBy(nsIntPoint(0, numPages), ScrollUnit::PAGES, scrollMode);
}
}

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

@ -2856,8 +2856,8 @@ void EventStateManager::DoScrollText(nsIScrollableFrame* aScrollableFrame,
nsIntPoint overflow;
aScrollableFrame->ScrollBy(actualDevPixelScrollAmount,
nsIScrollableFrame::DEVICE_PIXELS, mode, &overflow,
origin, momentum, snapMode);
ScrollUnit::DEVICE_PIXELS, mode, &overflow, origin,
momentum, snapMode);
if (!scrollFrameWeak.IsAlive()) {
// If the scroll causes changing the layout, we can think that the event
@ -5874,16 +5874,16 @@ nsresult EventStateManager::DoContentCommandScrollEvent(
NS_ENSURE_TRUE(presShell, NS_ERROR_NOT_AVAILABLE);
NS_ENSURE_TRUE(aEvent->mScroll.mAmount != 0, NS_ERROR_INVALID_ARG);
nsIScrollableFrame::ScrollUnit scrollUnit;
ScrollUnit scrollUnit;
switch (aEvent->mScroll.mUnit) {
case WidgetContentCommandEvent::eCmdScrollUnit_Line:
scrollUnit = nsIScrollableFrame::LINES;
scrollUnit = ScrollUnit::LINES;
break;
case WidgetContentCommandEvent::eCmdScrollUnit_Page:
scrollUnit = nsIScrollableFrame::PAGES;
scrollUnit = ScrollUnit::PAGES;
break;
case WidgetContentCommandEvent::eCmdScrollUnit_Whole:
scrollUnit = nsIScrollableFrame::WHOLE;
scrollUnit = ScrollUnit::WHOLE;
break;
default:
return NS_ERROR_INVALID_ARG;

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

@ -45,6 +45,7 @@
#include "mozilla/ShortcutKeys.h"
#include "mozilla/KeyEventHandler.h"
#include "mozilla/dom/KeyboardEvent.h"
#include "mozilla/ScrollTypes.h"
namespace mozilla {
@ -685,8 +686,8 @@ TextInputSelectionController::CompleteScroll(bool aForward) {
if (!mScrollFrame) {
return NS_ERROR_NOT_INITIALIZED;
}
mScrollFrame->ScrollBy(nsIntPoint(0, aForward ? 1 : -1),
nsIScrollableFrame::WHOLE, ScrollMode::Instant);
mScrollFrame->ScrollBy(nsIntPoint(0, aForward ? 1 : -1), ScrollUnit::WHOLE,
ScrollMode::Instant);
return NS_OK;
}
@ -733,8 +734,8 @@ TextInputSelectionController::ScrollPage(bool aForward) {
if (!mScrollFrame) {
return NS_ERROR_NOT_INITIALIZED;
}
mScrollFrame->ScrollBy(nsIntPoint(0, aForward ? 1 : -1),
nsIScrollableFrame::PAGES, ScrollMode::Smooth);
mScrollFrame->ScrollBy(nsIntPoint(0, aForward ? 1 : -1), ScrollUnit::PAGES,
ScrollMode::Smooth);
return NS_OK;
}
@ -743,8 +744,8 @@ TextInputSelectionController::ScrollLine(bool aForward) {
if (!mScrollFrame) {
return NS_ERROR_NOT_INITIALIZED;
}
mScrollFrame->ScrollBy(nsIntPoint(0, aForward ? 1 : -1),
nsIScrollableFrame::LINES, ScrollMode::Smooth);
mScrollFrame->ScrollBy(nsIntPoint(0, aForward ? 1 : -1), ScrollUnit::LINES,
ScrollMode::Smooth);
return NS_OK;
}
@ -753,8 +754,8 @@ TextInputSelectionController::ScrollCharacter(bool aRight) {
if (!mScrollFrame) {
return NS_ERROR_NOT_INITIALIZED;
}
mScrollFrame->ScrollBy(nsIntPoint(aRight ? 1 : -1, 0),
nsIScrollableFrame::LINES, ScrollMode::Smooth);
mScrollFrame->ScrollBy(nsIntPoint(aRight ? 1 : -1, 0), ScrollUnit::LINES,
ScrollMode::Smooth);
return NS_OK;
}

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

@ -45,6 +45,7 @@
#include "mozilla/Preferences.h" // for Preferences
#include "mozilla/RecursiveMutex.h" // for RecursiveMutexAutoLock, etc
#include "mozilla/RefPtr.h" // for RefPtr
#include "mozilla/ScrollTypes.h"
#include "mozilla/StaticPrefs_apz.h"
#include "mozilla/StaticPrefs_general.h"
#include "mozilla/StaticPrefs_gfx.h"
@ -5305,7 +5306,7 @@ void AsyncPanZoomController::SetTestAsyncZoom(
}
Maybe<CSSPoint> AsyncPanZoomController::FindSnapPointNear(
const CSSPoint& aDestination, nsIScrollableFrame::ScrollUnit aUnit) {
const CSSPoint& aDestination, ScrollUnit aUnit) {
mRecursiveMutex.AssertCurrentThreadIn();
APZC_LOG("%p scroll snapping near %s\n", this,
Stringify(aDestination).c_str());
@ -5327,7 +5328,7 @@ Maybe<CSSPoint> AsyncPanZoomController::FindSnapPointNear(
void AsyncPanZoomController::ScrollSnapNear(const CSSPoint& aDestination) {
if (Maybe<CSSPoint> snapPoint =
FindSnapPointNear(aDestination, nsIScrollableFrame::DEVICE_PIXELS)) {
FindSnapPointNear(aDestination, ScrollUnit::DEVICE_PIXELS)) {
if (*snapPoint != Metrics().GetScrollOffset()) {
APZC_LOG("%p smooth scrolling to snap point %s\n", this,
Stringify(*snapPoint).c_str());
@ -5366,8 +5367,8 @@ void AsyncPanZoomController::ScrollSnapToDestination() {
}
CSSPoint startPosition = Metrics().GetScrollOffset();
if (MaybeAdjustDeltaForScrollSnapping(nsIScrollableFrame::LINES,
predictedDelta, startPosition)) {
if (MaybeAdjustDeltaForScrollSnapping(ScrollUnit::LINES, predictedDelta,
startPosition)) {
APZC_LOG(
"%p fling snapping. friction: %f velocity: %f, %f "
"predictedDelta: %f, %f position: %f, %f "
@ -5382,8 +5383,7 @@ void AsyncPanZoomController::ScrollSnapToDestination() {
}
bool AsyncPanZoomController::MaybeAdjustDeltaForScrollSnapping(
nsIScrollableFrame::ScrollUnit aUnit, ParentLayerPoint& aDelta,
CSSPoint& aStartPosition) {
ScrollUnit aUnit, ParentLayerPoint& aDelta, CSSPoint& aStartPosition) {
RecursiveMutexAutoLock lock(mRecursiveMutex);
CSSToParentLayerScale2D zoom = Metrics().GetZoom();
CSSPoint destination = Metrics().CalculateScrollRange().ClampPoint(
@ -5414,8 +5414,7 @@ bool AsyncPanZoomController::MaybeAdjustDeltaForScrollSnappingOnWheelInput(
bool AsyncPanZoomController::MaybeAdjustDestinationForScrollSnapping(
const KeyboardInput& aEvent, CSSPoint& aDestination) {
RecursiveMutexAutoLock lock(mRecursiveMutex);
nsIScrollableFrame::ScrollUnit unit =
KeyboardScrollAction::GetScrollUnit(aEvent.mAction.mType);
ScrollUnit unit = KeyboardScrollAction::GetScrollUnit(aEvent.mAction.mType);
if (Maybe<CSSPoint> snapPoint = FindSnapPointNear(aDestination, unit)) {
aDestination = *snapPoint;

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

@ -17,6 +17,7 @@
#include "mozilla/Monitor.h"
#include "mozilla/RecursiveMutex.h"
#include "mozilla/RefPtr.h"
#include "mozilla/ScrollTypes.h"
#include "mozilla/StaticPrefs_apz.h"
#include "mozilla/UniquePtr.h"
#include "InputData.h"
@ -26,7 +27,6 @@
#include "Layers.h" // for Layer::ScrollDirection
#include "LayersTypes.h"
#include "mozilla/gfx/Matrix.h"
#include "nsIScrollableFrame.h"
#include "nsRegion.h"
#include "nsTArray.h"
#include "PotentialCheckerboardDurationTracker.h"
@ -1681,7 +1681,7 @@ class AsyncPanZoomController {
// |aUnit| affects the snapping behaviour (see ScrollSnapUtils::
// GetSnapPointForDestination).
// Returns true iff. a target snap point was found.
bool MaybeAdjustDeltaForScrollSnapping(nsIScrollableFrame::ScrollUnit aUnit,
bool MaybeAdjustDeltaForScrollSnapping(ScrollUnit aUnit,
ParentLayerPoint& aDelta,
CSSPoint& aStartPosition);
@ -1710,7 +1710,7 @@ class AsyncPanZoomController {
// GetSnapPointForDestination). It should generally be determined by the
// type of event that's triggering the scroll.
Maybe<CSSPoint> FindSnapPointNear(const CSSPoint& aDestination,
nsIScrollableFrame::ScrollUnit aUnit);
ScrollUnit aUnit);
};
} // namespace layers

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

@ -9,21 +9,21 @@
namespace mozilla {
namespace layers {
/* static */ nsIScrollableFrame::ScrollUnit KeyboardScrollAction::GetScrollUnit(
/* static */ ScrollUnit KeyboardScrollAction::GetScrollUnit(
KeyboardScrollAction::KeyboardScrollActionType aDeltaType) {
switch (aDeltaType) {
case KeyboardScrollAction::eScrollCharacter:
return nsIScrollableFrame::LINES;
return ScrollUnit::LINES;
case KeyboardScrollAction::eScrollLine:
return nsIScrollableFrame::LINES;
return ScrollUnit::LINES;
case KeyboardScrollAction::eScrollPage:
return nsIScrollableFrame::PAGES;
return ScrollUnit::PAGES;
case KeyboardScrollAction::eScrollComplete:
return nsIScrollableFrame::WHOLE;
return ScrollUnit::WHOLE;
}
// Silence an overzealous warning
return nsIScrollableFrame::WHOLE;
return ScrollUnit::WHOLE;
}
KeyboardScrollAction::KeyboardScrollAction()

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

@ -7,8 +7,8 @@
#ifndef mozilla_layers_KeyboardScrollAction_h
#define mozilla_layers_KeyboardScrollAction_h
#include "mozilla/ScrollTypes.h"
#include "mozilla/DefineEnum.h" // for MOZ_DEFINE_ENUM
#include "nsIScrollableFrame.h" // for nsIScrollableFrame::ScrollUnit
namespace mozilla {
namespace layers {
@ -29,8 +29,7 @@ struct KeyboardScrollAction final {
));
// clang-format on
static nsIScrollableFrame::ScrollUnit GetScrollUnit(
KeyboardScrollActionType aDeltaType);
static ScrollUnit GetScrollUnit(KeyboardScrollActionType aDeltaType);
KeyboardScrollAction();
KeyboardScrollAction(KeyboardScrollActionType aType, bool aForward);

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

@ -186,6 +186,7 @@
#include "mozilla/layers/WebRenderLayerManager.h"
#include "mozilla/layers/WebRenderUserData.h"
#include "mozilla/layout/ScrollAnchorContainer.h"
#include "mozilla/ScrollTypes.h"
#include "mozilla/ServoBindings.h"
#include "mozilla/ServoStyleSet.h"
#include "mozilla/StyleSheet.h"
@ -2251,9 +2252,9 @@ PresShell::ScrollPage(bool aForward) {
nsIScrollableFrame* scrollFrame =
GetScrollableFrameToScroll(ScrollableDirection::Vertical);
if (scrollFrame) {
scrollFrame->ScrollBy(nsIntPoint(0, aForward ? 1 : -1),
nsIScrollableFrame::PAGES, ScrollMode::Smooth,
nullptr, nullptr, nsIScrollableFrame::NOT_MOMENTUM,
scrollFrame->ScrollBy(nsIntPoint(0, aForward ? 1 : -1), ScrollUnit::PAGES,
ScrollMode::Smooth, nullptr, nullptr,
nsIScrollableFrame::NOT_MOMENTUM,
nsIScrollableFrame::ENABLE_SNAP);
}
return NS_OK;
@ -2268,8 +2269,8 @@ PresShell::ScrollLine(bool aForward) {
Preferences::GetInt("toolkit.scrollbox.verticalScrollDistance",
NS_DEFAULT_VERTICAL_SCROLL_DISTANCE);
scrollFrame->ScrollBy(nsIntPoint(0, aForward ? lineCount : -lineCount),
nsIScrollableFrame::LINES, ScrollMode::Smooth,
nullptr, nullptr, nsIScrollableFrame::NOT_MOMENTUM,
ScrollUnit::LINES, ScrollMode::Smooth, nullptr,
nullptr, nsIScrollableFrame::NOT_MOMENTUM,
nsIScrollableFrame::ENABLE_SNAP);
}
return NS_OK;
@ -2283,9 +2284,9 @@ PresShell::ScrollCharacter(bool aRight) {
int32_t h =
Preferences::GetInt("toolkit.scrollbox.horizontalScrollDistance",
NS_DEFAULT_HORIZONTAL_SCROLL_DISTANCE);
scrollFrame->ScrollBy(nsIntPoint(aRight ? h : -h, 0),
nsIScrollableFrame::LINES, ScrollMode::Smooth,
nullptr, nullptr, nsIScrollableFrame::NOT_MOMENTUM,
scrollFrame->ScrollBy(nsIntPoint(aRight ? h : -h, 0), ScrollUnit::LINES,
ScrollMode::Smooth, nullptr, nullptr,
nsIScrollableFrame::NOT_MOMENTUM,
nsIScrollableFrame::ENABLE_SNAP);
}
return NS_OK;
@ -2296,9 +2297,9 @@ PresShell::CompleteScroll(bool aForward) {
nsIScrollableFrame* scrollFrame =
GetScrollableFrameToScroll(ScrollableDirection::Vertical);
if (scrollFrame) {
scrollFrame->ScrollBy(nsIntPoint(0, aForward ? 1 : -1),
nsIScrollableFrame::WHOLE, ScrollMode::Smooth,
nullptr, nullptr, nsIScrollableFrame::NOT_MOMENTUM,
scrollFrame->ScrollBy(nsIntPoint(0, aForward ? 1 : -1), ScrollUnit::WHOLE,
ScrollMode::Smooth, nullptr, nullptr,
nsIScrollableFrame::NOT_MOMENTUM,
nsIScrollableFrame::ENABLE_SNAP);
}
return NS_OK;

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

@ -41,6 +41,11 @@ namespace mozilla {
*/
enum class ScrollMode { Instant, Smooth, SmoothMsd, Normal };
/**
* When scrolling by a relative amount, we can choose various units.
*/
enum class ScrollUnit { DEVICE_PIXELS, LINES, PAGES, WHOLE };
} // namespace mozilla
#endif // mozilla_ScrollTypes_h

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

@ -23,8 +23,8 @@ using layers::ScrollSnapInfo;
*/
class CalcSnapPoints final {
public:
CalcSnapPoints(nsIScrollableFrame::ScrollUnit aUnit,
const nsPoint& aDestination, const nsPoint& aStartPos);
CalcSnapPoints(ScrollUnit aUnit, const nsPoint& aDestination,
const nsPoint& aStartPos);
void AddHorizontalEdge(nscoord aEdge);
void AddVerticalEdge(nscoord aEdge);
void AddEdge(nscoord aEdge, nscoord aDestination, nscoord aStartPos,
@ -43,7 +43,7 @@ class CalcSnapPoints final {
}
protected:
nsIScrollableFrame::ScrollUnit mUnit;
ScrollUnit mUnit;
nsPoint mDestination; // gives the position after scrolling but before
// snapping
nsPoint mStartPos; // gives the position before scrolling
@ -57,8 +57,7 @@ class CalcSnapPoints final {
// edge
};
CalcSnapPoints::CalcSnapPoints(nsIScrollableFrame::ScrollUnit aUnit,
const nsPoint& aDestination,
CalcSnapPoints::CalcSnapPoints(ScrollUnit aUnit, const nsPoint& aDestination,
const nsPoint& aStartPos) {
mUnit = aUnit;
mDestination = aDestination;
@ -103,24 +102,24 @@ void CalcSnapPoints::AddEdge(nscoord aEdge, nscoord aDestination,
nscoord aStartPos, nscoord aScrollingDirection,
nscoord* aBestEdge, nscoord* aSecondBestEdge,
bool* aEdgeFound) {
// nsIScrollableFrame::DEVICE_PIXELS indicates that we are releasing a drag
// ScrollUnit::DEVICE_PIXELS indicates that we are releasing a drag
// gesture or any other user input event that sets an absolute scroll
// position. In this case, scroll snapping is expected to travel in any
// direction. Otherwise, we will restrict the direction of the scroll
// snapping movement based on aScrollingDirection.
if (mUnit != nsIScrollableFrame::DEVICE_PIXELS) {
if (mUnit != ScrollUnit::DEVICE_PIXELS) {
// Unless DEVICE_PIXELS, we only want to snap to points ahead of the
// direction we are scrolling
if (aScrollingDirection == 0) {
// The scroll direction is neutral - will not hit a snap point.
return;
}
// nsIScrollableFrame::WHOLE indicates that we are navigating to "home" or
// ScrollUnit::WHOLE indicates that we are navigating to "home" or
// "end". In this case, we will always select the first or last snap point
// regardless of the direction of the scroll. Otherwise, we will select
// scroll snapping points only in the direction specified by
// aScrollingDirection.
if (mUnit != nsIScrollableFrame::WHOLE) {
if (mUnit != ScrollUnit::WHOLE) {
// Direction of the edge from the current position (before scrolling) in
// the direction of scrolling
nscoord direction = (aEdge - aStartPos) * aScrollingDirection;
@ -151,12 +150,11 @@ void CalcSnapPoints::AddEdge(nscoord aEdge, nscoord aDestination,
}
};
if (mUnit == nsIScrollableFrame::DEVICE_PIXELS ||
mUnit == nsIScrollableFrame::LINES) {
if (mUnit == ScrollUnit::DEVICE_PIXELS || mUnit == ScrollUnit::LINES) {
nscoord distance = std::abs(aEdge - aDestination);
updateBestEdges(distance < std::abs(*aBestEdge - aDestination),
distance < std::abs(*aSecondBestEdge - aDestination));
} else if (mUnit == nsIScrollableFrame::PAGES) {
} else if (mUnit == ScrollUnit::PAGES) {
// distance to the edge from the scrolling destination in the direction of
// scrolling
nscoord overshoot = (aEdge - aDestination) * aScrollingDirection;
@ -178,7 +176,7 @@ void CalcSnapPoints::AddEdge(nscoord aEdge, nscoord aDestination,
if (overshoot > 0) {
updateBestEdges(overshoot < curOvershoot, overshoot < secondOvershoot);
}
} else if (mUnit == nsIScrollableFrame::WHOLE) {
} else if (mUnit == ScrollUnit::WHOLE) {
// the edge closest to the top/bottom/left/right is used, depending on
// scrolling direction
if (aScrollingDirection > 0) {
@ -240,7 +238,7 @@ static void ProcessSnapPositions(CalcSnapPoints& aCalcSnapPoints,
}
Maybe<nsPoint> ScrollSnapUtils::GetSnapPointForDestination(
const ScrollSnapInfo& aSnapInfo, nsIScrollableFrame::ScrollUnit aUnit,
const ScrollSnapInfo& aSnapInfo, ScrollUnit aUnit,
const nsRect& aScrollRange, const nsPoint& aStartPos,
const nsPoint& aDestination) {
if (aSnapInfo.mScrollSnapStrictnessY == StyleScrollSnapStrictness::None &&

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

@ -7,8 +7,8 @@
#ifndef mozilla_layout_ScrollSnap_h_
#define mozilla_layout_ScrollSnap_h_
#include "mozilla/ScrollTypes.h"
#include "mozilla/Maybe.h"
#include "nsIScrollableFrame.h"
namespace mozilla {
@ -32,9 +32,9 @@ struct ScrollSnapUtils {
* appropriate locking.
*/
static mozilla::Maybe<nsPoint> GetSnapPointForDestination(
const layers::ScrollSnapInfo& aSnapInfo,
nsIScrollableFrame::ScrollUnit aUnit, const nsRect& aScrollRange,
const nsPoint& aStartPos, const nsPoint& aDestination);
const layers::ScrollSnapInfo& aSnapInfo, ScrollUnit aUnit,
const nsRect& aScrollRange, const nsPoint& aStartPos,
const nsPoint& aDestination);
};
} // namespace mozilla

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

@ -16,6 +16,7 @@
#include "mozilla/EventStates.h"
#include "mozilla/HTMLEditor.h"
#include "mozilla/PresShell.h"
#include "mozilla/ScrollTypes.h"
#include "mozilla/StaticPrefs_dom.h"
#include "nsCOMPtr.h"
@ -1765,7 +1766,7 @@ nsresult nsFrameSelection::PageMove(bool aForward, bool aExtend,
? ScrollMode::Instant
: ScrollMode::Smooth;
scrollableFrame->ScrollBy(nsIntPoint(0, aForward ? 1 : -1),
nsIScrollableFrame::PAGES, scrollMode);
ScrollUnit::PAGES, scrollMode);
}
// Finally, scroll selection into view if requested.

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

@ -1448,15 +1448,15 @@ static nsRect GetOnePixelRangeAroundPoint(const nsPoint& aPoint,
void ScrollFrameHelper::ScrollByPage(
nsScrollbarFrame* aScrollbar, int32_t aDirection,
nsIScrollbarMediator::ScrollSnapMode aSnap) {
ScrollByUnit(aScrollbar, ScrollMode::Smooth, aDirection,
nsIScrollableFrame::PAGES, aSnap);
ScrollByUnit(aScrollbar, ScrollMode::Smooth, aDirection, ScrollUnit::PAGES,
aSnap);
}
void ScrollFrameHelper::ScrollByWhole(
nsScrollbarFrame* aScrollbar, int32_t aDirection,
nsIScrollbarMediator::ScrollSnapMode aSnap) {
ScrollByUnit(aScrollbar, ScrollMode::Instant, aDirection,
nsIScrollableFrame::WHOLE, aSnap);
ScrollByUnit(aScrollbar, ScrollMode::Instant, aDirection, ScrollUnit::WHOLE,
aSnap);
}
void ScrollFrameHelper::ScrollByLine(
@ -1491,7 +1491,7 @@ void ScrollFrameHelper::ScrollByLine(
}
nsIntPoint overflow;
ScrollBy(delta, nsIScrollableFrame::LINES, ScrollMode::Smooth, &overflow,
ScrollBy(delta, ScrollUnit::LINES, ScrollMode::Smooth, &overflow,
nsGkAtoms::other, nsIScrollableFrame::NOT_MOMENTUM, aSnap);
}
@ -1534,8 +1534,7 @@ void ScrollFrameHelper::ScrollbarReleased(nsScrollbarFrame* aScrollbar) {
void ScrollFrameHelper::ScrollByUnit(
nsScrollbarFrame* aScrollbar, ScrollMode aMode, int32_t aDirection,
nsIScrollableFrame::ScrollUnit aUnit,
nsIScrollbarMediator::ScrollSnapMode aSnap) {
ScrollUnit aUnit, nsIScrollbarMediator::ScrollSnapMode aSnap) {
MOZ_ASSERT(aScrollbar != nullptr);
bool isHorizontal = aScrollbar->IsXULHorizontal();
nsIntPoint delta;
@ -2289,7 +2288,7 @@ void ScrollFrameHelper::ScrollToWithOrigin(
bool willSnap = false;
if (aSnap == nsIScrollableFrame::ENABLE_SNAP) {
willSnap = GetSnapPointForDestination(nsIScrollableFrame::DEVICE_PIXELS,
willSnap = GetSnapPointForDestination(ScrollUnit::DEVICE_PIXELS,
mDestination, aScrollPosition);
}
@ -4195,8 +4194,7 @@ static void CalcRangeForScrollBy(int32_t aDelta, nscoord aPos,
(aDelta > 0 ? aPosTolerance : aNegTolerance));
}
void ScrollFrameHelper::ScrollBy(nsIntPoint aDelta,
nsIScrollableFrame::ScrollUnit aUnit,
void ScrollFrameHelper::ScrollBy(nsIntPoint aDelta, ScrollUnit aUnit,
ScrollMode aMode, nsIntPoint* aOverflow,
nsAtom* aOrigin,
nsIScrollableFrame::ScrollMomentum aMomentum,
@ -4232,7 +4230,7 @@ void ScrollFrameHelper::ScrollBy(nsIntPoint aDelta,
}
bool isGenericOrigin = (aOrigin == nsGkAtoms::other);
switch (aUnit) {
case nsIScrollableFrame::DEVICE_PIXELS: {
case ScrollUnit::DEVICE_PIXELS: {
nscoord appUnitsPerDevPixel =
mOuter->PresContext()->AppUnitsPerDevPixel();
deltaMultiplier = nsSize(appUnitsPerDevPixel, appUnitsPerDevPixel);
@ -4242,7 +4240,7 @@ void ScrollFrameHelper::ScrollBy(nsIntPoint aDelta,
negativeTolerance = positiveTolerance = 0.5f;
break;
}
case nsIScrollableFrame::LINES: {
case ScrollUnit::LINES: {
deltaMultiplier = GetLineScrollAmount();
if (isGenericOrigin) {
aOrigin = nsGkAtoms::lines;
@ -4250,7 +4248,7 @@ void ScrollFrameHelper::ScrollBy(nsIntPoint aDelta,
negativeTolerance = positiveTolerance = 0.1f;
break;
}
case nsIScrollableFrame::PAGES: {
case ScrollUnit::PAGES: {
deltaMultiplier = GetPageScrollAmount();
if (isGenericOrigin) {
aOrigin = nsGkAtoms::pages;
@ -4259,7 +4257,7 @@ void ScrollFrameHelper::ScrollBy(nsIntPoint aDelta,
positiveTolerance = 0;
break;
}
case nsIScrollableFrame::WHOLE: {
case ScrollUnit::WHOLE: {
nsPoint pos = GetScrollPosition();
AdjustForWholeDelta(aDelta.x, &pos.x);
AdjustForWholeDelta(aDelta.y, &pos.y);
@ -4288,12 +4286,12 @@ void ScrollFrameHelper::ScrollBy(nsIntPoint aDelta,
deltaMultiplier = nsSize(appUnitsPerDevPixel, appUnitsPerDevPixel);
negativeTolerance = 0.1f;
positiveTolerance = 0;
nsIScrollableFrame::ScrollUnit snapUnit = aUnit;
ScrollUnit snapUnit = aUnit;
if (aOrigin == nsGkAtoms::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.
snapUnit = nsIScrollableFrame::LINES;
snapUnit = ScrollUnit::LINES;
}
GetSnapPointForDestination(snapUnit, mDestination, newPos);
}
@ -4321,7 +4319,7 @@ void ScrollFrameHelper::ScrollBy(nsIntPoint aDelta,
NSAppUnitsToIntPixels(clampAmount.y, appUnitsPerDevPixel));
}
if (aUnit == nsIScrollableFrame::DEVICE_PIXELS &&
if (aUnit == ScrollUnit::DEVICE_PIXELS &&
!nsLayoutUtils::AsyncPanZoomEnabled(mOuter)) {
// When APZ is disabled, we must track the velocity
// on the main thread; otherwise, the APZC will manage this.
@ -4395,7 +4393,7 @@ void ScrollFrameHelper::ScrollSnap(const nsPoint& aDestination,
nsRect scrollRange = GetLayoutScrollRange();
nsPoint pos = GetScrollPosition();
nsPoint snapDestination = scrollRange.ClampPoint(aDestination);
if (GetSnapPointForDestination(nsIScrollableFrame::DEVICE_PIXELS, pos,
if (GetSnapPointForDestination(ScrollUnit::DEVICE_PIXELS, pos,
snapDestination)) {
ScrollTo(snapDestination, aMode, nsGkAtoms::other);
}
@ -6977,9 +6975,9 @@ layers::ScrollSnapInfo ScrollFrameHelper::GetScrollSnapInfo(
return ComputeScrollSnapInfo(aDestination);
}
bool ScrollFrameHelper::GetSnapPointForDestination(
nsIScrollableFrame::ScrollUnit aUnit, nsPoint aStartPos,
nsPoint& aDestination) {
bool ScrollFrameHelper::GetSnapPointForDestination(ScrollUnit aUnit,
nsPoint aStartPos,
nsPoint& aDestination) {
Maybe<nsPoint> snapPoint = ScrollSnapUtils::GetSnapPointForDestination(
GetScrollSnapInfo(Some(aDestination)), aUnit, GetLayoutScrollRange(),
aStartPos, aDestination);

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

@ -24,6 +24,7 @@
#include "nsExpirationTracker.h"
#include "TextOverflow.h"
#include "ScrollVelocityQueue.h"
#include "mozilla/ScrollTypes.h"
#include "mozilla/PresState.h"
#include "mozilla/layout/ScrollAnchorContainer.h"
@ -249,9 +250,8 @@ class ScrollFrameHelper : public nsIReflowCallback {
/**
* @note This method might destroy the frame, pres shell and other objects.
*/
void ScrollBy(nsIntPoint aDelta, nsIScrollableFrame::ScrollUnit aUnit,
ScrollMode aMode, nsIntPoint* aOverflow,
nsAtom* aOrigin = nullptr,
void ScrollBy(nsIntPoint aDelta, mozilla::ScrollUnit aUnit, ScrollMode aMode,
nsIntPoint* aOverflow, nsAtom* aOrigin = nullptr,
nsIScrollableFrame::ScrollMomentum aMomentum =
nsIScrollableFrame::NOT_MOMENTUM,
nsIScrollbarMediator::ScrollSnapMode aSnap =
@ -278,8 +278,8 @@ class ScrollFrameHelper : public nsIReflowCallback {
* Returns true if a suitable snap point could be found and aDestination has
* been updated to a valid snapping position.
*/
bool GetSnapPointForDestination(nsIScrollableFrame::ScrollUnit aUnit,
nsPoint aStartPos, nsPoint& aDestination);
bool GetSnapPointForDestination(mozilla::ScrollUnit aUnit, nsPoint aStartPos,
nsPoint& aDestination);
nsMargin GetScrollPadding() const;
@ -485,7 +485,7 @@ class ScrollFrameHelper : public nsIReflowCallback {
nscoord aNewPos);
void ScrollbarReleased(nsScrollbarFrame* aScrollbar);
void ScrollByUnit(nsScrollbarFrame* aScrollbar, ScrollMode aMode,
int32_t aDirection, nsIScrollableFrame::ScrollUnit aUnit,
int32_t aDirection, mozilla::ScrollUnit aUnit,
nsIScrollbarMediator::ScrollSnapMode aSnap =
nsIScrollbarMediator::DISABLE_SNAP);
bool ShouldSuppressScrollbarRepaints() const {
@ -952,7 +952,7 @@ class nsHTMLScrollFrame : public nsContainerFrame,
/**
* @note This method might destroy the frame, pres shell and other objects.
*/
void ScrollBy(nsIntPoint aDelta, ScrollUnit aUnit, ScrollMode aMode,
void ScrollBy(nsIntPoint aDelta, mozilla::ScrollUnit aUnit, ScrollMode aMode,
nsIntPoint* aOverflow, nsAtom* aOrigin = nullptr,
nsIScrollableFrame::ScrollMomentum aMomentum =
nsIScrollableFrame::NOT_MOMENTUM,
@ -1416,7 +1416,7 @@ class nsXULScrollFrame final : public nsBoxFrame,
/**
* @note This method might destroy the frame, pres shell and other objects.
*/
void ScrollBy(nsIntPoint aDelta, ScrollUnit aUnit, ScrollMode aMode,
void ScrollBy(nsIntPoint aDelta, mozilla::ScrollUnit aUnit, ScrollMode aMode,
nsIntPoint* aOverflow, nsAtom* aOrigin = nullptr,
nsIScrollableFrame::ScrollMomentum aMomentum =
nsIScrollableFrame::NOT_MOMENTUM,

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

@ -282,10 +282,6 @@ class nsIScrollableFrame : public nsIScrollbarMediator {
* pixel.
*/
virtual CSSIntPoint GetScrollPositionCSSPixels() = 0;
/**
* When scrolling by a relative amount, we can choose various units.
*/
enum ScrollUnit { DEVICE_PIXELS, LINES, PAGES, WHOLE };
/**
* @note This method might destroy the frame, pres shell and other objects.
* Modifies the current scroll position by aDelta units given by aUnit,
@ -296,8 +292,8 @@ class nsIScrollableFrame : public nsIScrollbarMediator {
* to bring it back into the legal range). This is never negative. The
* values are in device pixels.
*/
virtual void ScrollBy(nsIntPoint aDelta, ScrollUnit aUnit, ScrollMode aMode,
nsIntPoint* aOverflow = nullptr,
virtual void ScrollBy(nsIntPoint aDelta, mozilla::ScrollUnit aUnit,
ScrollMode aMode, nsIntPoint* aOverflow = nullptr,
nsAtom* aOrigin = nullptr,
ScrollMomentum aMomentum = NOT_MOMENTUM,
nsIScrollbarMediator::ScrollSnapMode aSnap =

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

@ -685,19 +685,19 @@ uint32_t ScrollWheelInput::DeltaModeForDeltaType(ScrollDeltaType aDeltaType) {
}
}
nsIScrollableFrame::ScrollUnit ScrollWheelInput::ScrollUnitForDeltaType(
ScrollUnit ScrollWheelInput::ScrollUnitForDeltaType(
ScrollDeltaType aDeltaType) {
switch (aDeltaType) {
case SCROLLDELTA_LINE:
return nsIScrollableFrame::LINES;
return ScrollUnit::LINES;
case SCROLLDELTA_PAGE:
return nsIScrollableFrame::PAGES;
return ScrollUnit::PAGES;
case SCROLLDELTA_PIXEL:
return nsIScrollableFrame::DEVICE_PIXELS;
return ScrollUnit::DEVICE_PIXELS;
default:
MOZ_CRASH();
}
return nsIScrollableFrame::LINES;
return ScrollUnit::LINES;
}
WidgetWheelEvent ScrollWheelInput::ToWidgetWheelEvent(

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

@ -7,10 +7,10 @@
#define InputData_h__
#include "nsDebug.h"
#include "nsIScrollableFrame.h"
#include "nsPoint.h"
#include "nsTArray.h"
#include "Units.h"
#include "mozilla/ScrollTypes.h"
#include "mozilla/DefineEnum.h"
#include "mozilla/EventForwards.h"
#include "mozilla/TimeStamp.h"
@ -586,8 +586,7 @@ class ScrollWheelInput : public InputData {
static ScrollDeltaType DeltaTypeForDeltaMode(uint32_t aDeltaMode);
static uint32_t DeltaModeForDeltaType(ScrollDeltaType aDeltaType);
static nsIScrollableFrame::ScrollUnit ScrollUnitForDeltaType(
ScrollDeltaType aDeltaType);
static mozilla::ScrollUnit ScrollUnitForDeltaType(ScrollDeltaType aDeltaType);
WidgetWheelEvent ToWidgetWheelEvent(nsIWidget* aWidget) const;
bool TransformToLocal(const ScreenToParentLayerMatrix4x4& aTransform);