mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 969250 - Part 1: Implement scroll snapping for scrollbars (v7 Patch),r=roc
This commit is contained in:
parent
3d56eac828
commit
5fc1e25b4b
@ -2431,7 +2431,7 @@ EventStateManager::DoScrollText(nsIScrollableFrame* aScrollableFrame,
|
||||
actualDevPixelScrollAmount.y = 0;
|
||||
}
|
||||
|
||||
nsIScrollableFrame::ScrollSnapMode snapMode = nsIScrollableFrame::DISABLE_SNAP;
|
||||
nsIScrollbarMediator::ScrollSnapMode snapMode = nsIScrollbarMediator::DISABLE_SNAP;
|
||||
nsIAtom* origin = nullptr;
|
||||
switch (aEvent->deltaMode) {
|
||||
case nsIDOMWheelEvent::DOM_DELTA_LINE:
|
||||
|
@ -1126,21 +1126,24 @@ GetOnePixelRangeAroundPoint(nsPoint aPoint, bool aIsHorizontal)
|
||||
}
|
||||
|
||||
void
|
||||
ScrollFrameHelper::ScrollByPage(nsScrollbarFrame* aScrollbar, int32_t aDirection)
|
||||
ScrollFrameHelper::ScrollByPage(nsScrollbarFrame* aScrollbar, int32_t aDirection,
|
||||
nsIScrollbarMediator::ScrollSnapMode aSnap)
|
||||
{
|
||||
ScrollByUnit(aScrollbar, nsIScrollableFrame::SMOOTH, aDirection,
|
||||
nsIScrollableFrame::PAGES);
|
||||
nsIScrollableFrame::PAGES, aSnap);
|
||||
}
|
||||
|
||||
void
|
||||
ScrollFrameHelper::ScrollByWhole(nsScrollbarFrame* aScrollbar, int32_t aDirection)
|
||||
ScrollFrameHelper::ScrollByWhole(nsScrollbarFrame* aScrollbar, int32_t aDirection,
|
||||
nsIScrollbarMediator::ScrollSnapMode aSnap)
|
||||
{
|
||||
ScrollByUnit(aScrollbar, nsIScrollableFrame::INSTANT, aDirection,
|
||||
nsIScrollableFrame::WHOLE);
|
||||
nsIScrollableFrame::WHOLE, aSnap);
|
||||
}
|
||||
|
||||
void
|
||||
ScrollFrameHelper::ScrollByLine(nsScrollbarFrame* aScrollbar, int32_t aDirection)
|
||||
ScrollFrameHelper::ScrollByLine(nsScrollbarFrame* aScrollbar, int32_t aDirection,
|
||||
nsIScrollbarMediator::ScrollSnapMode aSnap)
|
||||
{
|
||||
bool isHorizontal = aScrollbar->IsHorizontal();
|
||||
nsIntPoint delta;
|
||||
@ -1172,7 +1175,8 @@ ScrollFrameHelper::ScrollByLine(nsScrollbarFrame* aScrollbar, int32_t aDirection
|
||||
|
||||
nsIntPoint overflow;
|
||||
ScrollBy(delta, nsIScrollableFrame::LINES, nsIScrollableFrame::SMOOTH,
|
||||
&overflow, nsGkAtoms::other);
|
||||
&overflow, nsGkAtoms::other, nsIScrollableFrame::NOT_MOMENTUM,
|
||||
aSnap);
|
||||
}
|
||||
|
||||
void
|
||||
@ -1207,11 +1211,24 @@ ScrollFrameHelper::ThumbMoved(nsScrollbarFrame* aScrollbar,
|
||||
ScrollTo(dest, nsIScrollableFrame::INSTANT, &allowedRange);
|
||||
}
|
||||
|
||||
void
|
||||
ScrollFrameHelper::ScrollbarReleased(nsScrollbarFrame* aScrollbar)
|
||||
{
|
||||
// Scrollbar scrolling does not result in fling gestures, clear any
|
||||
// accumulated velocity
|
||||
mVelocityQueue.Reset();
|
||||
|
||||
// Perform scroll snapping, if needed. Scrollbar movement uses the same
|
||||
// smooth scrolling animation as keyboard scrolling.
|
||||
ScrollSnap(mDestination, nsIScrollableFrame::SMOOTH);
|
||||
}
|
||||
|
||||
void
|
||||
ScrollFrameHelper::ScrollByUnit(nsScrollbarFrame* aScrollbar,
|
||||
nsIScrollableFrame::ScrollMode aMode,
|
||||
int32_t aDirection,
|
||||
nsIScrollableFrame::ScrollUnit aUnit)
|
||||
nsIScrollableFrame::ScrollUnit aUnit,
|
||||
nsIScrollbarMediator::ScrollSnapMode aSnap)
|
||||
{
|
||||
MOZ_ASSERT(aScrollbar != nullptr);
|
||||
bool isHorizontal = aScrollbar->IsHorizontal();
|
||||
@ -1222,7 +1239,8 @@ ScrollFrameHelper::ScrollByUnit(nsScrollbarFrame* aScrollbar,
|
||||
delta.y = aDirection;
|
||||
}
|
||||
nsIntPoint overflow;
|
||||
ScrollBy(delta, aUnit, aMode, &overflow, nsGkAtoms::other);
|
||||
ScrollBy(delta, aUnit, aMode, &overflow, nsGkAtoms::other,
|
||||
nsIScrollableFrame::NOT_MOMENTUM, aSnap);
|
||||
}
|
||||
|
||||
nsresult
|
||||
@ -2094,7 +2112,7 @@ ScrollFrameHelper::ScrollToWithOrigin(nsPoint aScrollPosition,
|
||||
nsIScrollableFrame::ScrollMode aMode,
|
||||
nsIAtom *aOrigin,
|
||||
const nsRect* aRange,
|
||||
nsIScrollableFrame::ScrollSnapMode aSnap)
|
||||
nsIScrollbarMediator::ScrollSnapMode aSnap)
|
||||
{
|
||||
|
||||
if (aSnap == nsIScrollableFrame::ENABLE_SNAP) {
|
||||
@ -3368,7 +3386,7 @@ ScrollFrameHelper::ScrollBy(nsIntPoint aDelta,
|
||||
nsIntPoint* aOverflow,
|
||||
nsIAtom *aOrigin,
|
||||
nsIScrollableFrame::ScrollMomentum aMomentum,
|
||||
nsIScrollableFrame::ScrollSnapMode aSnap)
|
||||
nsIScrollbarMediator::ScrollSnapMode aSnap)
|
||||
{
|
||||
// When a smooth scroll is being processed on a frame, mouse wheel and trackpad
|
||||
// momentum scroll event updates must notcancel the SMOOTH or SMOOTH_MSD
|
||||
@ -3500,7 +3518,7 @@ ScrollFrameHelper::ScrollBy(nsIntPoint aDelta,
|
||||
}
|
||||
|
||||
void
|
||||
ScrollFrameHelper::ScrollSnap()
|
||||
ScrollFrameHelper::ScrollSnap(nsIScrollableFrame::ScrollMode aMode)
|
||||
{
|
||||
float flingSensitivity = gfxPrefs::ScrollSnapPredictionSensitivity();
|
||||
int maxVelocity = gfxPrefs::ScrollSnapPredictionMaxVelocity();
|
||||
@ -3513,7 +3531,7 @@ ScrollFrameHelper::ScrollSnap()
|
||||
predictedOffset.Clamp(maxOffset);
|
||||
nsPoint pos = GetScrollPosition();
|
||||
nsPoint destinationPos = pos + predictedOffset;
|
||||
ScrollSnap(destinationPos);
|
||||
ScrollSnap(destinationPos, aMode);
|
||||
}
|
||||
|
||||
void
|
||||
@ -3523,7 +3541,8 @@ ScrollFrameHelper::FlingSnap(const mozilla::CSSPoint& aDestination)
|
||||
}
|
||||
|
||||
void
|
||||
ScrollFrameHelper::ScrollSnap(const nsPoint &aDestination)
|
||||
ScrollFrameHelper::ScrollSnap(const nsPoint &aDestination,
|
||||
nsIScrollableFrame::ScrollMode aMode)
|
||||
{
|
||||
nsRect scrollRange = GetScrollRangeForClamping();
|
||||
nsPoint pos = GetScrollPosition();
|
||||
@ -3531,7 +3550,7 @@ ScrollFrameHelper::ScrollSnap(const nsPoint &aDestination)
|
||||
if (GetSnapPointForDestination(nsIScrollableFrame::DEVICE_PIXELS,
|
||||
pos,
|
||||
snapDestination)) {
|
||||
ScrollTo(snapDestination, nsIScrollableFrame::SMOOTH_MSD);
|
||||
ScrollTo(snapDestination, aMode);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -181,8 +181,9 @@ public:
|
||||
void SetResolution(float aResolution);
|
||||
void SetResolutionAndScaleTo(float aResolution);
|
||||
void FlingSnap(const mozilla::CSSPoint& aDestination);
|
||||
void ScrollSnap();
|
||||
void ScrollSnap(const nsPoint &aDestination);
|
||||
void ScrollSnap(nsIScrollableFrame::ScrollMode aMode = nsIScrollableFrame::SMOOTH_MSD);
|
||||
void ScrollSnap(const nsPoint &aDestination,
|
||||
nsIScrollableFrame::ScrollMode aMode = nsIScrollableFrame::SMOOTH_MSD);
|
||||
|
||||
protected:
|
||||
nsRect GetScrollRangeForClamping() const;
|
||||
@ -200,7 +201,8 @@ public:
|
||||
*/
|
||||
void ScrollTo(nsPoint aScrollPosition, nsIScrollableFrame::ScrollMode aMode,
|
||||
const nsRect* aRange = nullptr,
|
||||
nsIScrollableFrame::ScrollSnapMode aSnap = nsIScrollableFrame::DISABLE_SNAP) {
|
||||
nsIScrollbarMediator::ScrollSnapMode aSnap
|
||||
= nsIScrollbarMediator::DISABLE_SNAP) {
|
||||
ScrollToWithOrigin(aScrollPosition, aMode, nsGkAtoms::other, aRange,
|
||||
aSnap);
|
||||
}
|
||||
@ -229,7 +231,8 @@ public:
|
||||
nsIScrollableFrame::ScrollMode aMode, nsIntPoint* aOverflow,
|
||||
nsIAtom* aOrigin = nullptr,
|
||||
nsIScrollableFrame::ScrollMomentum aMomentum = nsIScrollableFrame::NOT_MOMENTUM,
|
||||
nsIScrollableFrame::ScrollSnapMode aSnap = nsIScrollableFrame::DISABLE_SNAP);
|
||||
nsIScrollbarMediator::ScrollSnapMode aSnap
|
||||
= nsIScrollbarMediator::DISABLE_SNAP);
|
||||
/**
|
||||
* @note This method might destroy the frame, pres shell and other objects.
|
||||
*/
|
||||
@ -380,17 +383,26 @@ public:
|
||||
nsTArray<FrameMetrics>* aOutput) const;
|
||||
|
||||
// nsIScrollbarMediator
|
||||
void ScrollByPage(nsScrollbarFrame* aScrollbar, int32_t aDirection);
|
||||
void ScrollByWhole(nsScrollbarFrame* aScrollbar, int32_t aDirection);
|
||||
void ScrollByLine(nsScrollbarFrame* aScrollbar, int32_t aDirection);
|
||||
void ScrollByPage(nsScrollbarFrame* aScrollbar, int32_t aDirection,
|
||||
nsIScrollbarMediator::ScrollSnapMode aSnap
|
||||
= nsIScrollbarMediator::DISABLE_SNAP);
|
||||
void ScrollByWhole(nsScrollbarFrame* aScrollbar, int32_t aDirection,
|
||||
nsIScrollbarMediator::ScrollSnapMode aSnap
|
||||
= nsIScrollbarMediator::DISABLE_SNAP);
|
||||
void ScrollByLine(nsScrollbarFrame* aScrollbar, int32_t aDirection,
|
||||
nsIScrollbarMediator::ScrollSnapMode aSnap
|
||||
= nsIScrollbarMediator::DISABLE_SNAP);
|
||||
void RepeatButtonScroll(nsScrollbarFrame* aScrollbar);
|
||||
void ThumbMoved(nsScrollbarFrame* aScrollbar,
|
||||
nscoord aOldPos,
|
||||
nscoord aNewPos);
|
||||
void ScrollbarReleased(nsScrollbarFrame* aScrollbar);
|
||||
void ScrollByUnit(nsScrollbarFrame* aScrollbar,
|
||||
nsIScrollableFrame::ScrollMode aMode,
|
||||
int32_t aDirection,
|
||||
nsIScrollableFrame::ScrollUnit aUnit);
|
||||
nsIScrollableFrame::ScrollUnit aUnit,
|
||||
nsIScrollbarMediator::ScrollSnapMode aSnap
|
||||
= nsIScrollbarMediator::DISABLE_SNAP);
|
||||
|
||||
// owning references to the nsIAnonymousContentCreator-built content
|
||||
nsCOMPtr<nsIContent> mHScrollbarContent;
|
||||
@ -520,7 +532,8 @@ protected:
|
||||
nsIScrollableFrame::ScrollMode aMode,
|
||||
nsIAtom *aOrigin, // nullptr indicates "other" origin
|
||||
const nsRect* aRange,
|
||||
nsIScrollableFrame::ScrollSnapMode aSnap = nsIScrollableFrame::DISABLE_SNAP);
|
||||
nsIScrollbarMediator::ScrollSnapMode aSnap
|
||||
= nsIScrollbarMediator::DISABLE_SNAP);
|
||||
|
||||
void CompleteAsyncScroll(const nsRect &aRange, nsIAtom* aOrigin = nullptr);
|
||||
|
||||
@ -709,7 +722,8 @@ public:
|
||||
*/
|
||||
virtual void ScrollTo(nsPoint aScrollPosition, ScrollMode aMode,
|
||||
const nsRect* aRange = nullptr,
|
||||
nsIScrollableFrame::ScrollSnapMode aSnap = nsIScrollableFrame::DISABLE_SNAP)
|
||||
nsIScrollbarMediator::ScrollSnapMode aSnap
|
||||
= nsIScrollbarMediator::DISABLE_SNAP)
|
||||
override {
|
||||
mHelper.ScrollTo(aScrollPosition, aMode, aRange, aSnap);
|
||||
}
|
||||
@ -737,7 +751,8 @@ public:
|
||||
virtual void ScrollBy(nsIntPoint aDelta, ScrollUnit aUnit, ScrollMode aMode,
|
||||
nsIntPoint* aOverflow, nsIAtom* aOrigin = nullptr,
|
||||
nsIScrollableFrame::ScrollMomentum aMomentum = nsIScrollableFrame::NOT_MOMENTUM,
|
||||
nsIScrollableFrame::ScrollSnapMode aSnap = nsIScrollableFrame::DISABLE_SNAP)
|
||||
nsIScrollbarMediator::ScrollSnapMode aSnap
|
||||
= nsIScrollbarMediator::DISABLE_SNAP)
|
||||
override {
|
||||
mHelper.ScrollBy(aDelta, aUnit, aMode, aOverflow, aOrigin, aMomentum, aSnap);
|
||||
}
|
||||
@ -845,14 +860,20 @@ public:
|
||||
virtual nsIAtom* GetType() const override;
|
||||
|
||||
// nsIScrollbarMediator
|
||||
virtual void ScrollByPage(nsScrollbarFrame* aScrollbar, int32_t aDirection) override {
|
||||
mHelper.ScrollByPage(aScrollbar, aDirection);
|
||||
virtual void ScrollByPage(nsScrollbarFrame* aScrollbar, int32_t aDirection,
|
||||
nsIScrollbarMediator::ScrollSnapMode aSnap
|
||||
= nsIScrollbarMediator::DISABLE_SNAP) override {
|
||||
mHelper.ScrollByPage(aScrollbar, aDirection, aSnap);
|
||||
}
|
||||
virtual void ScrollByWhole(nsScrollbarFrame* aScrollbar, int32_t aDirection) override {
|
||||
mHelper.ScrollByWhole(aScrollbar, aDirection);
|
||||
virtual void ScrollByWhole(nsScrollbarFrame* aScrollbar, int32_t aDirection,
|
||||
nsIScrollbarMediator::ScrollSnapMode aSnap
|
||||
= nsIScrollbarMediator::DISABLE_SNAP) override {
|
||||
mHelper.ScrollByWhole(aScrollbar, aDirection, aSnap);
|
||||
}
|
||||
virtual void ScrollByLine(nsScrollbarFrame* aScrollbar, int32_t aDirection) override {
|
||||
mHelper.ScrollByLine(aScrollbar, aDirection);
|
||||
virtual void ScrollByLine(nsScrollbarFrame* aScrollbar, int32_t aDirection,
|
||||
nsIScrollbarMediator::ScrollSnapMode aSnap
|
||||
= nsIScrollbarMediator::DISABLE_SNAP) override {
|
||||
mHelper.ScrollByLine(aScrollbar, aDirection, aSnap);
|
||||
}
|
||||
virtual void RepeatButtonScroll(nsScrollbarFrame* aScrollbar) override {
|
||||
mHelper.RepeatButtonScroll(aScrollbar);
|
||||
@ -862,6 +883,9 @@ public:
|
||||
nscoord aNewPos) override {
|
||||
mHelper.ThumbMoved(aScrollbar, aOldPos, aNewPos);
|
||||
}
|
||||
virtual void ScrollbarReleased(nsScrollbarFrame* aScrollbar) override {
|
||||
mHelper.ScrollbarReleased(aScrollbar);
|
||||
}
|
||||
virtual void VisibilityChanged(bool aVisible) override {}
|
||||
virtual nsIFrame* GetScrollbarBox(bool aVertical) override {
|
||||
return mHelper.GetScrollbarBox(aVertical);
|
||||
@ -1090,7 +1114,8 @@ public:
|
||||
*/
|
||||
virtual void ScrollTo(nsPoint aScrollPosition, ScrollMode aMode,
|
||||
const nsRect* aRange = nullptr,
|
||||
ScrollSnapMode aSnap = nsIScrollableFrame::DISABLE_SNAP) override {
|
||||
ScrollSnapMode aSnap = nsIScrollbarMediator::DISABLE_SNAP)
|
||||
override {
|
||||
mHelper.ScrollTo(aScrollPosition, aMode, aRange, aSnap);
|
||||
}
|
||||
/**
|
||||
@ -1114,7 +1139,8 @@ public:
|
||||
virtual void ScrollBy(nsIntPoint aDelta, ScrollUnit aUnit, ScrollMode aMode,
|
||||
nsIntPoint* aOverflow, nsIAtom* aOrigin = nullptr,
|
||||
nsIScrollableFrame::ScrollMomentum aMomentum = nsIScrollableFrame::NOT_MOMENTUM,
|
||||
nsIScrollableFrame::ScrollSnapMode aSnap = nsIScrollableFrame::DISABLE_SNAP)
|
||||
nsIScrollbarMediator::ScrollSnapMode aSnap
|
||||
= nsIScrollbarMediator::DISABLE_SNAP)
|
||||
override {
|
||||
mHelper.ScrollBy(aDelta, aUnit, aMode, aOverflow, aOrigin, aMomentum, aSnap);
|
||||
}
|
||||
@ -1229,14 +1255,20 @@ public:
|
||||
return nsBoxFrame::IsFrameOfType(aFlags);
|
||||
}
|
||||
|
||||
virtual void ScrollByPage(nsScrollbarFrame* aScrollbar, int32_t aDirection) override {
|
||||
mHelper.ScrollByPage(aScrollbar, aDirection);
|
||||
virtual void ScrollByPage(nsScrollbarFrame* aScrollbar, int32_t aDirection,
|
||||
nsIScrollbarMediator::ScrollSnapMode aSnap
|
||||
= nsIScrollbarMediator::DISABLE_SNAP) override {
|
||||
mHelper.ScrollByPage(aScrollbar, aDirection, aSnap);
|
||||
}
|
||||
virtual void ScrollByWhole(nsScrollbarFrame* aScrollbar, int32_t aDirection) override {
|
||||
mHelper.ScrollByWhole(aScrollbar, aDirection);
|
||||
virtual void ScrollByWhole(nsScrollbarFrame* aScrollbar, int32_t aDirection,
|
||||
nsIScrollbarMediator::ScrollSnapMode aSnap
|
||||
= nsIScrollbarMediator::DISABLE_SNAP) override {
|
||||
mHelper.ScrollByWhole(aScrollbar, aDirection, aSnap);
|
||||
}
|
||||
virtual void ScrollByLine(nsScrollbarFrame* aScrollbar, int32_t aDirection) override {
|
||||
mHelper.ScrollByLine(aScrollbar, aDirection);
|
||||
virtual void ScrollByLine(nsScrollbarFrame* aScrollbar, int32_t aDirection,
|
||||
nsIScrollbarMediator::ScrollSnapMode aSnap
|
||||
= nsIScrollbarMediator::DISABLE_SNAP) override {
|
||||
mHelper.ScrollByLine(aScrollbar, aDirection, aSnap);
|
||||
}
|
||||
virtual void RepeatButtonScroll(nsScrollbarFrame* aScrollbar) override {
|
||||
mHelper.RepeatButtonScroll(aScrollbar);
|
||||
@ -1246,6 +1278,9 @@ public:
|
||||
nscoord aNewPos) override {
|
||||
mHelper.ThumbMoved(aScrollbar, aOldPos, aNewPos);
|
||||
}
|
||||
virtual void ScrollbarReleased(nsScrollbarFrame* aScrollbar) override {
|
||||
mHelper.ScrollbarReleased(aScrollbar);
|
||||
}
|
||||
virtual void VisibilityChanged(bool aVisible) override {}
|
||||
virtual nsIFrame* GetScrollbarBox(bool aVertical) override {
|
||||
return mHelper.GetScrollbarBox(aVertical);
|
||||
|
@ -207,13 +207,6 @@ public:
|
||||
* been started since the last actual user input.
|
||||
*/
|
||||
enum ScrollMomentum { NOT_MOMENTUM, SYNTHESIZED_MOMENTUM_EVENT };
|
||||
/**
|
||||
* When set to ENABLE_SNAP, additional scrolling will be performed after the
|
||||
* scroll operation to maintain the constraints set by CSS Scroll snapping.
|
||||
* The additional scrolling may include asynchronous smooth scrolls that
|
||||
* continue to animate after the initial scroll position has been set.
|
||||
*/
|
||||
enum ScrollSnapMode { DISABLE_SNAP, ENABLE_SNAP };
|
||||
/**
|
||||
* @note This method might destroy the frame, pres shell and other objects.
|
||||
* Clamps aScrollPosition to GetScrollRange and sets the scroll position
|
||||
@ -225,7 +218,8 @@ public:
|
||||
*/
|
||||
virtual void ScrollTo(nsPoint aScrollPosition, ScrollMode aMode,
|
||||
const nsRect* aRange = nullptr,
|
||||
ScrollSnapMode aSnap = DISABLE_SNAP) = 0;
|
||||
nsIScrollbarMediator::ScrollSnapMode aSnap
|
||||
= nsIScrollbarMediator::DISABLE_SNAP) = 0;
|
||||
/**
|
||||
* @note This method might destroy the frame, pres shell and other objects.
|
||||
* Scrolls to a particular position in integer CSS pixels.
|
||||
@ -280,7 +274,8 @@ public:
|
||||
nsIntPoint* aOverflow = nullptr,
|
||||
nsIAtom* aOrigin = nullptr,
|
||||
ScrollMomentum aMomentum = NOT_MOMENTUM,
|
||||
ScrollSnapMode aSnap = DISABLE_SNAP) = 0;
|
||||
nsIScrollbarMediator::ScrollSnapMode aSnap
|
||||
= nsIScrollbarMediator::DISABLE_SNAP) = 0;
|
||||
|
||||
/**
|
||||
* Perform scroll snapping, possibly resulting in a smooth scroll to
|
||||
|
@ -24,14 +24,25 @@ public:
|
||||
* aDirection is either -1, 0, or 1.
|
||||
*/
|
||||
|
||||
/**
|
||||
* When set to ENABLE_SNAP, additional scrolling will be performed after the
|
||||
* scroll operation to maintain the constraints set by CSS Scroll snapping.
|
||||
* The additional scrolling may include asynchronous smooth scrolls that
|
||||
* continue to animate after the initial scroll position has been set.
|
||||
*/
|
||||
enum ScrollSnapMode { DISABLE_SNAP, ENABLE_SNAP };
|
||||
|
||||
/**
|
||||
* One of the following three methods is called when the scrollbar's button is
|
||||
* clicked.
|
||||
* @note These methods might destroy the frame, pres shell, and other objects.
|
||||
*/
|
||||
virtual void ScrollByPage(nsScrollbarFrame* aScrollbar, int32_t aDirection) = 0;
|
||||
virtual void ScrollByWhole(nsScrollbarFrame* aScrollbar, int32_t aDirection) = 0;
|
||||
virtual void ScrollByLine(nsScrollbarFrame* aScrollbar, int32_t aDirection) = 0;
|
||||
virtual void ScrollByPage(nsScrollbarFrame* aScrollbar, int32_t aDirection,
|
||||
ScrollSnapMode aSnap = DISABLE_SNAP) = 0;
|
||||
virtual void ScrollByWhole(nsScrollbarFrame* aScrollbar, int32_t aDirection,
|
||||
ScrollSnapMode aSnap = DISABLE_SNAP) = 0;
|
||||
virtual void ScrollByLine(nsScrollbarFrame* aScrollbar, int32_t aDirection,
|
||||
ScrollSnapMode aSnap = DISABLE_SNAP) = 0;
|
||||
/**
|
||||
* RepeatButtonScroll is called when the scrollbar's button is held down. When the
|
||||
* button is first clicked the increment is set; RepeatButtonScroll adds this
|
||||
@ -49,6 +60,11 @@ public:
|
||||
virtual void ThumbMoved(nsScrollbarFrame* aScrollbar,
|
||||
nscoord aOldPos,
|
||||
nscoord aNewPos) = 0;
|
||||
/**
|
||||
* Called when the scroll bar thumb, slider, or any other component is
|
||||
* released.
|
||||
*/
|
||||
virtual void ScrollbarReleased(nsScrollbarFrame* aScrollbar) = 0;
|
||||
virtual void VisibilityChanged(bool aVisible) = 0;
|
||||
|
||||
/**
|
||||
|
@ -326,8 +326,10 @@ nsListBoxBodyFrame::GetPrefSize(nsBoxLayoutState& aBoxLayoutState)
|
||||
///////////// nsIScrollbarMediator ///////////////
|
||||
|
||||
void
|
||||
nsListBoxBodyFrame::ScrollByPage(nsScrollbarFrame* aScrollbar, int32_t aDirection)
|
||||
nsListBoxBodyFrame::ScrollByPage(nsScrollbarFrame* aScrollbar, int32_t aDirection,
|
||||
nsIScrollbarMediator::ScrollSnapMode aSnap)
|
||||
{
|
||||
// CSS Scroll Snapping is not enabled for XUL, aSnap is ignored
|
||||
MOZ_ASSERT(aScrollbar != nullptr);
|
||||
aScrollbar->SetIncrementToPage(aDirection);
|
||||
nsWeakFrame weakFrame(this);
|
||||
@ -339,8 +341,10 @@ nsListBoxBodyFrame::ScrollByPage(nsScrollbarFrame* aScrollbar, int32_t aDirectio
|
||||
}
|
||||
|
||||
void
|
||||
nsListBoxBodyFrame::ScrollByWhole(nsScrollbarFrame* aScrollbar, int32_t aDirection)
|
||||
nsListBoxBodyFrame::ScrollByWhole(nsScrollbarFrame* aScrollbar, int32_t aDirection,
|
||||
nsIScrollbarMediator::ScrollSnapMode aSnap)
|
||||
{
|
||||
// CSS Scroll Snapping is not enabled for XUL, aSnap is ignored
|
||||
MOZ_ASSERT(aScrollbar != nullptr);
|
||||
aScrollbar->SetIncrementToWhole(aDirection);
|
||||
nsWeakFrame weakFrame(this);
|
||||
@ -352,8 +356,10 @@ nsListBoxBodyFrame::ScrollByWhole(nsScrollbarFrame* aScrollbar, int32_t aDirecti
|
||||
}
|
||||
|
||||
void
|
||||
nsListBoxBodyFrame::ScrollByLine(nsScrollbarFrame* aScrollbar, int32_t aDirection)
|
||||
nsListBoxBodyFrame::ScrollByLine(nsScrollbarFrame* aScrollbar, int32_t aDirection,
|
||||
nsIScrollbarMediator::ScrollSnapMode aSnap)
|
||||
{
|
||||
// CSS Scroll Snapping is not enabled for XUL, aSnap is ignored
|
||||
MOZ_ASSERT(aScrollbar != nullptr);
|
||||
aScrollbar->SetIncrementToLine(aDirection);
|
||||
nsWeakFrame weakFrame(this);
|
||||
|
@ -54,13 +54,20 @@ public:
|
||||
virtual nsresult AttributeChanged(int32_t aNameSpaceID, nsIAtom* aAttribute, int32_t aModType) override;
|
||||
|
||||
// nsIScrollbarMediator
|
||||
virtual void ScrollByPage(nsScrollbarFrame* aScrollbar, int32_t aDirection) override;
|
||||
virtual void ScrollByWhole(nsScrollbarFrame* aScrollbar, int32_t aDirection) override;
|
||||
virtual void ScrollByLine(nsScrollbarFrame* aScrollbar, int32_t aDirection) override;
|
||||
virtual void ScrollByPage(nsScrollbarFrame* aScrollbar, int32_t aDirection,
|
||||
nsIScrollbarMediator::ScrollSnapMode snapMode
|
||||
= nsIScrollbarMediator::DISABLE_SNAP) override;
|
||||
virtual void ScrollByWhole(nsScrollbarFrame* aScrollbar, int32_t aDirection,
|
||||
nsIScrollbarMediator::ScrollSnapMode snapMode
|
||||
= nsIScrollbarMediator::DISABLE_SNAP) override;
|
||||
virtual void ScrollByLine(nsScrollbarFrame* aScrollbar, int32_t aDirection,
|
||||
nsIScrollbarMediator::ScrollSnapMode snapMode
|
||||
= nsIScrollbarMediator::DISABLE_SNAP) override;
|
||||
virtual void RepeatButtonScroll(nsScrollbarFrame* aScrollbar) override;
|
||||
virtual void ThumbMoved(nsScrollbarFrame* aScrollbar,
|
||||
int32_t aOldPos,
|
||||
int32_t aNewPos) override;
|
||||
virtual void ScrollbarReleased(nsScrollbarFrame* aScrollbar) override {}
|
||||
virtual void VisibilityChanged(bool aVisible) override;
|
||||
virtual nsIFrame* GetScrollbarBox(bool aVertical) override;
|
||||
virtual void ScrollbarActivityStarted() const override {}
|
||||
|
@ -141,19 +141,19 @@ nsScrollbarButtonFrame::HandleButtonPress(nsPresContext* aPresContext,
|
||||
case 0:
|
||||
sb->SetIncrementToLine(direction);
|
||||
if (m) {
|
||||
m->ScrollByLine(sb, direction);
|
||||
m->ScrollByLine(sb, direction, nsIScrollbarMediator::ENABLE_SNAP);
|
||||
}
|
||||
break;
|
||||
case 1:
|
||||
sb->SetIncrementToPage(direction);
|
||||
if (m) {
|
||||
m->ScrollByPage(sb, direction);
|
||||
m->ScrollByPage(sb, direction, nsIScrollbarMediator::ENABLE_SNAP);
|
||||
}
|
||||
break;
|
||||
case 2:
|
||||
sb->SetIncrementToWhole(direction);
|
||||
if (m) {
|
||||
m->ScrollByWhole(sb, direction);
|
||||
m->ScrollByWhole(sb, direction, nsIScrollbarMediator::ENABLE_SNAP);
|
||||
}
|
||||
break;
|
||||
case 3:
|
||||
@ -187,6 +187,15 @@ nsScrollbarButtonFrame::HandleRelease(nsPresContext* aPresContext,
|
||||
// we're not active anymore
|
||||
mContent->UnsetAttr(kNameSpaceID_None, nsGkAtoms::active, true);
|
||||
StopRepeat();
|
||||
nsIFrame* scrollbar;
|
||||
GetParentWithTag(nsGkAtoms::scrollbar, this, scrollbar);
|
||||
nsScrollbarFrame* sb = do_QueryFrame(scrollbar);
|
||||
if (sb) {
|
||||
nsIScrollbarMediator* m = sb->GetScrollbarMediator();
|
||||
if (m) {
|
||||
m->ScrollbarReleased(sb);
|
||||
}
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
@ -264,7 +264,8 @@ nsSliderFrame::AttributeChanged(int32_t aNameSpaceID,
|
||||
nsIScrollbarMediator* mediator = scrollbarFrame->GetScrollbarMediator();
|
||||
scrollbarFrame->SetIncrementToWhole(direction);
|
||||
if (mediator) {
|
||||
mediator->ScrollByWhole(scrollbarFrame, direction);
|
||||
mediator->ScrollByWhole(scrollbarFrame, direction,
|
||||
nsIScrollbarMediator::ENABLE_SNAP);
|
||||
}
|
||||
}
|
||||
// 'this' might be destroyed here
|
||||
@ -1153,6 +1154,14 @@ nsSliderFrame::HandleRelease(nsPresContext* aPresContext,
|
||||
{
|
||||
StopRepeat();
|
||||
|
||||
nsIFrame* scrollbar = GetScrollbar();
|
||||
nsScrollbarFrame* sb = do_QueryFrame(scrollbar);
|
||||
if (sb) {
|
||||
nsIScrollbarMediator* m = sb->GetScrollbarMediator();
|
||||
if (m) {
|
||||
m->ScrollbarReleased(sb);
|
||||
}
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
@ -1261,7 +1270,7 @@ nsSliderFrame::PageScroll(nscoord aChange)
|
||||
nsIScrollbarMediator* m = sb->GetScrollbarMediator();
|
||||
sb->SetIncrementToPage(aChange);
|
||||
if (m) {
|
||||
m->ScrollByPage(sb, aChange);
|
||||
m->ScrollByPage(sb, aChange, nsIScrollbarMediator::ENABLE_SNAP);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -4200,23 +4200,29 @@ nsTreeBodyFrame::ScrollHorzInternal(const ScrollParts& aParts, int32_t aPosition
|
||||
}
|
||||
|
||||
void
|
||||
nsTreeBodyFrame::ScrollByPage(nsScrollbarFrame* aScrollbar, int32_t aDirection)
|
||||
nsTreeBodyFrame::ScrollByPage(nsScrollbarFrame* aScrollbar, int32_t aDirection,
|
||||
nsIScrollbarMediator::ScrollSnapMode aSnap)
|
||||
{
|
||||
// CSS Scroll Snapping is not enabled for XUL, aSnap is ignored
|
||||
MOZ_ASSERT(aScrollbar != nullptr);
|
||||
ScrollByPages(aDirection);
|
||||
}
|
||||
|
||||
void
|
||||
nsTreeBodyFrame::ScrollByWhole(nsScrollbarFrame* aScrollbar, int32_t aDirection)
|
||||
nsTreeBodyFrame::ScrollByWhole(nsScrollbarFrame* aScrollbar, int32_t aDirection,
|
||||
nsIScrollbarMediator::ScrollSnapMode aSnap)
|
||||
{
|
||||
// CSS Scroll Snapping is not enabled for XUL, aSnap is ignored
|
||||
MOZ_ASSERT(aScrollbar != nullptr);
|
||||
int32_t newIndex = aDirection < 0 ? 0 : mTopRowIndex;
|
||||
ScrollToRow(newIndex);
|
||||
}
|
||||
|
||||
void
|
||||
nsTreeBodyFrame::ScrollByLine(nsScrollbarFrame* aScrollbar, int32_t aDirection)
|
||||
nsTreeBodyFrame::ScrollByLine(nsScrollbarFrame* aScrollbar, int32_t aDirection,
|
||||
nsIScrollbarMediator::ScrollSnapMode aSnap)
|
||||
{
|
||||
// CSS Scroll Snapping is not enabled for XUL, aSnap is ignored
|
||||
MOZ_ASSERT(aScrollbar != nullptr);
|
||||
ScrollByLines(aDirection);
|
||||
}
|
||||
|
@ -133,13 +133,20 @@ public:
|
||||
virtual bool PseudoMatches(nsCSSSelector* aSelector) override;
|
||||
|
||||
// nsIScrollbarMediator
|
||||
virtual void ScrollByPage(nsScrollbarFrame* aScrollbar, int32_t aDirection) override;
|
||||
virtual void ScrollByWhole(nsScrollbarFrame* aScrollbar, int32_t aDirection) override;
|
||||
virtual void ScrollByLine(nsScrollbarFrame* aScrollbar, int32_t aDirection) override;
|
||||
virtual void ScrollByPage(nsScrollbarFrame* aScrollbar, int32_t aDirection,
|
||||
nsIScrollbarMediator::ScrollSnapMode aSnap
|
||||
= nsIScrollbarMediator::DISABLE_SNAP) override;
|
||||
virtual void ScrollByWhole(nsScrollbarFrame* aScrollbar, int32_t aDirection,
|
||||
nsIScrollbarMediator::ScrollSnapMode aSnap
|
||||
= nsIScrollbarMediator::DISABLE_SNAP) override;
|
||||
virtual void ScrollByLine(nsScrollbarFrame* aScrollbar, int32_t aDirection,
|
||||
nsIScrollbarMediator::ScrollSnapMode aSnap
|
||||
= nsIScrollbarMediator::DISABLE_SNAP) override;
|
||||
virtual void RepeatButtonScroll(nsScrollbarFrame* aScrollbar) override;
|
||||
virtual void ThumbMoved(nsScrollbarFrame* aScrollbar,
|
||||
nscoord aOldPos,
|
||||
nscoord aNewPos) override;
|
||||
virtual void ScrollbarReleased(nsScrollbarFrame* aScrollbar) override {}
|
||||
virtual void VisibilityChanged(bool aVisible) override { Invalidate(); }
|
||||
virtual nsIFrame* GetScrollbarBox(bool aVertical) override {
|
||||
ScrollParts parts = GetScrollParts();
|
||||
|
Loading…
Reference in New Issue
Block a user