Backed out 2 changesets (bug 969250) on the other theory that it broke lots of tests, forcing a prolonged CLOSED TREE

Backed out changeset 3c1005c81e52 (bug 969250)
Backed out changeset 3ed9d5170d13 (bug 969250)
This commit is contained in:
Wes Kocher 2015-03-25 14:46:47 -07:00
parent 4957e87be7
commit cad55266a2
13 changed files with 69 additions and 511 deletions

View File

@ -2431,7 +2431,7 @@ EventStateManager::DoScrollText(nsIScrollableFrame* aScrollableFrame,
actualDevPixelScrollAmount.y = 0;
}
nsIScrollbarMediator::ScrollSnapMode snapMode = nsIScrollbarMediator::DISABLE_SNAP;
nsIScrollableFrame::ScrollSnapMode snapMode = nsIScrollableFrame::DISABLE_SNAP;
nsIAtom* origin = nullptr;
switch (aEvent->deltaMode) {
case nsIDOMWheelEvent::DOM_DELTA_LINE:

View File

@ -180,8 +180,6 @@ skip-if = buildapp == 'mulet' || buildapp == 'b2g' || toolkit == 'android' || e1
[test_scroll_event_ordering.html]
[test_scroll_snapping.html]
skip-if = buildapp == 'android' # bug 1041833
[test_scroll_snapping_scrollbars.html]
skip-if = buildapp == 'android' || buildapp == 'b2g' || buildapp == 'b2g-debug' # android(Bug 1041833) b2g(B2G does not have clickable toolbars) b2g-debug(B2G does not have clickable toolbars)
[test_bug583889.html]
support-files = bug583889_inner1.html bug583889_inner2.html
[test_bug582771.html]

View File

@ -1,331 +0,0 @@
<!DOCTYPE HTML>
<html>
<head>
<title>Test for scroll snapping</title>
<script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
<script type="text/javascript" src="/tests/SimpleTest/EventUtils.js"></script>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
</head>
<body>
<p id="display"></p>
<div id="sc" style="margin: 0px; padding: 0px; overflow: scroll; width:250px; height: 250px;">
<div id="sd" style="margin: 0px; padding: 0px; width: 1250px; height: 1250px;"></div>
</div>
<pre id="test">
<script class="testbody" type="text/javascript">
var runtime = SpecialPowers.Cc["@mozilla.org/xre/app-info;1"]
.getService(SpecialPowers.Ci.nsIXULRuntime);
var isMac = navigator.platform.indexOf("Mac") != -1;
var isGtk = runtime.widgetToolkit.indexOf("gtk") != -1;
var isWin = navigator.platform.indexOf("Win") != -1;
var isSN = /mac os x 10\.6/.test(navigator.userAgent.toLowerCase());
// Half of the scrollbar control width, in CSS pixels
var scrollbarOffset = isWin ? 8 : 5;
// OSX 10.6 scroll bar thumbs are off-center due to the bundling of buttons on one end
// of the scroll bar frame.
var scrollbarCenter = isSN ? 100 : 125;
var testCases = [
{
"description" : "Drag scrollbar left, expect scroll snapping.",
"snapCoord" : "500px 500px",
"startScroll" : { "x" : 500, "y" : 500 },
"endScroll" : { "x" : 500, "y" : 500 },
"mousePosition" : { "x" : scrollbarCenter, "y" : 250 - scrollbarOffset },
"mouseOffset" : { "x" : -10, "y" : 0 },
"duration" : "0",
"runMac" : true,
"runGtk" : true,
"runWin" : true
},
{
"description" : "Drag scrollbar right, expect scroll snapping.",
"snapCoord" : "500px 500px",
"startScroll" : { "x" : 500, "y" : 500 },
"endScroll" : { "x" : 500, "y" : 500 },
"mousePosition" : { "x" : scrollbarCenter, "y" : 250 - scrollbarOffset },
"mouseOffset" : { "x" : 10, "y" : 0 },
"duration" : "0",
"runMac" : true,
"runGtk" : true,
"runWin" : true
},
{
"description" : "Drag scrollbar up, expect scroll snapping.",
"snapCoord" : "500px 500px",
"startScroll" : { "x" : 500, "y" : 500 },
"endScroll" : { "x" : 500, "y" : 500 },
"mousePosition" : { "x" : 250 - scrollbarOffset, "y" : scrollbarCenter },
"mouseOffset" : { "x" : 0, "y" : -10 },
"duration" : "0",
"runMac" : true,
"runGtk" : true,
"runWin" : true
},
{
"description" : "Drag scrollbar down, expect scroll snapping.",
"snapCoord" : "500px 500px",
"startScroll" : { "x" : 500, "y" : 500 },
"endScroll" : { "x" : 500, "y" : 500 },
"mousePosition" : { "x" : 250 - scrollbarOffset, "y" : scrollbarCenter },
"mouseOffset" : { "x" : 0, "y" : 10 },
"duration" : "0",
"runMac" : true,
"runGtk" : true,
"runWin" : true
},
{
"description" : "Page scrollbar left, expect scroll snapping.",
"snapCoord" : "500px 500px, 1000px 500px",
"startScroll" : { "x" : 1000, "y" : 500 },
"endScroll" : { "x" : 500, "y" : 500 },
"mousePosition" : { "x" : 50, "y" : 250 - scrollbarOffset },
"mouseOffset" : { "x" : 0, "y" : 0 },
"duration" : "0",
"runMac" : true,
"runGtk" : true,
"runWin" : true
},
{
"description" : "Page scrollbar right, expect scroll snapping.",
"snapCoord" : "500px 500px, 0px 500px",
"startScroll" : { "x" : 0, "y" : 500 },
"endScroll" : { "x" : 500, "y" : 500 },
"mousePosition" : { "x" : 200, "y" : 250 - scrollbarOffset },
"mouseOffset" : { "x" : 0, "y" : 0 },
"duration" : "0",
"runMac" : true,
"runGtk" : true,
"runWin" : true
},
{
"description" : "Page scrollbar up, expect scroll snapping.",
"snapCoord" : "500px 500px, 500px 1000px",
"startScroll" : { "x" : 500, "y" : 1000 },
"endScroll" : { "x" : 500, "y" : 500 },
"mousePosition" : { "x" : 250 - scrollbarOffset, "y" : 50 },
"mouseOffset" : { "x" : 0, "y" : 0 },
"duration" : "0",
"runMac" : true,
"runGtk" : true,
"runWin" : true
},
{
"description" : "Page scrollbar down, expect scroll snapping.",
"snapCoord" : "500px 500px, 500px 0px",
"startScroll" : { "x" : 500, "y" : 0 },
"endScroll" : { "x" : 500, "y" : 500 },
"mousePosition" : { "x" : 250 - scrollbarOffset, "y" : 200 },
"mouseOffset" : { "x" : 0, "y" : 0 },
"duration" : "0",
"runMac" : true,
"runGtk" : true,
"runWin" : true
},
{
"description" : "Click scrollbar left button, expect scroll snapping.",
"snapCoord" : "50px 500px, 250px 500px, 500px 500px, 750px 500px, 950px 500px",
"startScroll" : { "x" : 500, "y" : 500 },
"endScroll" : { "x" : 250, "y" : 500 },
"mousePosition" : { "x" : scrollbarOffset, "y" : 250 - scrollbarOffset },
"mouseOffset" : { "x" : 0, "y" : 0 },
"duration" : "0",
"runMac" : false, // OSX does not have have line-scroll buttons
"runGtk" : true,
"runWin" : true
},
{
"description" : "Hold scrollbar left button until repeating, expect scroll snapping.",
"snapCoord" : "50px 500px, 500px 500px, 950px 500px",
"startScroll" : { "x" : 500, "y" : 500 },
"endScroll" : { "x" : 50, "y" : 500 },
"mousePosition" : { "x" : scrollbarOffset, "y" : 250 - scrollbarOffset },
"mouseOffset" : { "x" : 0, "y" : 0 },
"duration" : "500",
"runMac" : false, // OSX does not have have line-scroll buttons
"runGtk" : true,
"runWin" : true
},
{
"description" : "Click scrollbar right button, expect scroll snapping.",
"snapCoord" : "50px 500px, 250px 500px, 500px 500px, 750px 500px, 950px 500px",
"startScroll" : { "x" : 500, "y" : 500 },
"endScroll" : { "x" : 750, "y" : 500 },
"mousePosition" : { "x" : 250 - scrollbarOffset * 3, "y" : 250 - scrollbarOffset },
"mouseOffset" : { "x" : 0, "y" : 0 },
"duration" : "0",
"runMac" : false, // OSX does not have have line-scroll buttons
"runGtk" : true,
"runWin" : true
},
{
"description" : "Hold scrollbar right button until repeating, expect scroll snapping.",
"snapCoord" : "50px 500px, 500px 500px, 950px 500px",
"startScroll" : { "x" : 500, "y" : 500 },
"endScroll" : { "x" : 950, "y" : 500 },
"mousePosition" : { "x" : 250 - scrollbarOffset * 3, "y" : 250 - scrollbarOffset },
"mouseOffset" : { "x" : 0, "y" : 0 },
"duration" : "500",
"runMac" : false, // OSX does not have have line-scroll buttons
"runGtk" : true,
"runWin" : true
},
{
"description" : "Click scrollbar up button, expect scroll snapping.",
"snapCoord" : "500px 50px, 500px 250px, 500px 500px, 500px 750px, 500px 950px",
"startScroll" : { "x" : 500, "y" : 500 },
"endScroll" : { "x" : 500, "y" : 250 },
"mousePosition" : { "x" : 250 - scrollbarOffset, "y" : scrollbarOffset },
"mouseOffset" : { "x" : 0, "y" : 0 },
"duration" : "0",
"runMac" : false, // OSX does not have have line-scroll buttons
"runGtk" : true,
"runWin" : true
},
{
"description" : "Hold scrollbar up button until repeating, expect scroll snapping.",
"snapCoord" : "500px 50px, 500px 500px, 500px 950px",
"startScroll" : { "x" : 500, "y" : 500 },
"endScroll" : { "x" : 500, "y" : 50 },
"mousePosition" : { "x" : 250 - scrollbarOffset, "y" : scrollbarOffset },
"mouseOffset" : { "x" : 0, "y" : 0 },
"duration" : "500",
"runMac" : false, // OSX does not have have line-scroll buttons
"runGtk" : true,
"runWin" : true
},
{
"description" : "Click scrollbar down button, expect scroll snapping.",
"snapCoord" : "500px 50px, 500px 250px, 500px 500px, 500px 750px, 500px 950px",
"startScroll" : { "x" : 500, "y" : 500 },
"endScroll" : { "x" : 500, "y" : 750 },
"mousePosition" : { "x" : 250 - scrollbarOffset, "y" : 250 - scrollbarOffset * 3},
"mouseOffset" : { "x" : 0, "y" : 0 },
"duration" : "0",
"runMac" : false, // OSX does not have have line-scroll buttons
"runGtk" : true,
"runWin" : true
},
{
"description" : "Hold scrollbar down button until repeating, expect scroll snapping.",
"snapCoord" : "500px 50px, 500px 500px, 500px 950px",
"startScroll" : { "x" : 500, "y" : 500 },
"endScroll" : { "x" : 500, "y" : 950 },
"mousePosition" : { "x" : 250 - scrollbarOffset, "y" : 250 - scrollbarOffset * 3},
"mouseOffset" : { "x" : 0, "y" : 0 },
"duration" : "500",
"runMac" : false, // OSX does not have have line-scroll buttons
"runGtk" : true,
"runWin" : true
},
];
var step = 0;
var sc; // Scroll Container
var sd; // Scrolled Div
var lastScrollTop;
var lastScrollLeft;
var stopFrameCount;
function doTest() {
var testCase = testCases[step];
stopFrameCount = 0;
lastScrollTop = sc.scrollTop;
lastScrollLeft = sc.scrollLeft;
sc.scrollTo(testCase.startScroll.x, testCase.startScroll.y);
sc.style.scrollSnapType = "mandatory";
sd.style.scrollSnapCoordinate = testCase.snapCoord;
synthesizeMouse(sc,
testCase.mousePosition.x,
testCase.mousePosition.y,
{ type: "mousedown" });
synthesizeMouse(sc,
testCase.mousePosition.x + testCase.mouseOffset.x,
testCase.mousePosition.y + testCase.mouseOffset.y,
{ type: "mousemove" });
window.requestAnimationFrame(function() {
isnot("(" + sc.scrollLeft + "," + sc.scrollTop + ")",
"(" + testCase.startScroll.x +"," + testCase.startScroll.y + ")",
"Step " + step + ": Synthesized mouse events move scroll position. ("
+ testCase.description + ")");
window.setTimeout(function() {
synthesizeMouse(sc,
testCase.mousePosition.x + testCase.mouseOffset.x,
testCase.mousePosition.y + testCase.mouseOffset.y,
{ type: "mouseup" });
window.requestAnimationFrame(waitForScrollStop);
}, testCase.duration);
});
}
function waitForScrollStop() {
if (stopFrameCount > 30) {
// We have the same position for 30 consecutive frames -- we are stopped
verifyTest();
} else {
// Still moving
if (lastScrollTop == sc.scrollTop && lastScrollLeft == sc.scrollLeft) {
stopFrameCount++;
} else {
stopFrameCount = 0;
lastScrollTop = sc.scrollTop;
lastScrollLeft = sc.scrollLeft;
}
window.requestAnimationFrame(waitForScrollStop);
}
}
function verifyTest() {
// Test ended, check if scroll position matches expected position
var testCase = testCases[step];
is("(" + sc.scrollLeft + "," + sc.scrollTop + ")",
"(" + testCase.endScroll.x +"," + testCase.endScroll.y + ")",
"Step " + step + ": " + testCase.description);
// Find next test to run
while (true) {
if (++step == testCases.length) {
SimpleTest.finish();
break;
} else {
testCase = testCases[step];
if ((testCase.runGtk && isGtk)
|| (testCase.runMac && isMac)
|| (testCase.runWin && isWin)) {
doTest();
break;
}
}
}
}
SimpleTest.waitForExplicitFinish();
SimpleTest.requestFlakyTimeout("Delays added to allow synthesized mouse " +
"events to trigger scrollbar repeating scrolls.");
addLoadEvent(function() {
sc = document.getElementById("sc");
sd = document.getElementById("sd");
SpecialPowers.pushPrefEnv({
"set": [["layout.css.scroll-snap.enabled", true],
["layout.css.scroll-snap.proximity-threshold", 100]]},
doTest);
});
</script>
</pre>
</body>
</html>

View File

@ -1126,24 +1126,21 @@ GetOnePixelRangeAroundPoint(nsPoint aPoint, bool aIsHorizontal)
}
void
ScrollFrameHelper::ScrollByPage(nsScrollbarFrame* aScrollbar, int32_t aDirection,
nsIScrollbarMediator::ScrollSnapMode aSnap)
ScrollFrameHelper::ScrollByPage(nsScrollbarFrame* aScrollbar, int32_t aDirection)
{
ScrollByUnit(aScrollbar, nsIScrollableFrame::SMOOTH, aDirection,
nsIScrollableFrame::PAGES, aSnap);
nsIScrollableFrame::PAGES);
}
void
ScrollFrameHelper::ScrollByWhole(nsScrollbarFrame* aScrollbar, int32_t aDirection,
nsIScrollbarMediator::ScrollSnapMode aSnap)
ScrollFrameHelper::ScrollByWhole(nsScrollbarFrame* aScrollbar, int32_t aDirection)
{
ScrollByUnit(aScrollbar, nsIScrollableFrame::INSTANT, aDirection,
nsIScrollableFrame::WHOLE, aSnap);
nsIScrollableFrame::WHOLE);
}
void
ScrollFrameHelper::ScrollByLine(nsScrollbarFrame* aScrollbar, int32_t aDirection,
nsIScrollbarMediator::ScrollSnapMode aSnap)
ScrollFrameHelper::ScrollByLine(nsScrollbarFrame* aScrollbar, int32_t aDirection)
{
bool isHorizontal = aScrollbar->IsHorizontal();
nsIntPoint delta;
@ -1175,8 +1172,7 @@ ScrollFrameHelper::ScrollByLine(nsScrollbarFrame* aScrollbar, int32_t aDirection
nsIntPoint overflow;
ScrollBy(delta, nsIScrollableFrame::LINES, nsIScrollableFrame::SMOOTH,
&overflow, nsGkAtoms::other, nsIScrollableFrame::NOT_MOMENTUM,
aSnap);
&overflow, nsGkAtoms::other);
}
void
@ -1211,24 +1207,11 @@ 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,
nsIScrollbarMediator::ScrollSnapMode aSnap)
nsIScrollableFrame::ScrollUnit aUnit)
{
MOZ_ASSERT(aScrollbar != nullptr);
bool isHorizontal = aScrollbar->IsHorizontal();
@ -1239,8 +1222,7 @@ ScrollFrameHelper::ScrollByUnit(nsScrollbarFrame* aScrollbar,
delta.y = aDirection;
}
nsIntPoint overflow;
ScrollBy(delta, aUnit, aMode, &overflow, nsGkAtoms::other,
nsIScrollableFrame::NOT_MOMENTUM, aSnap);
ScrollBy(delta, aUnit, aMode, &overflow, nsGkAtoms::other);
}
nsresult
@ -2112,7 +2094,7 @@ ScrollFrameHelper::ScrollToWithOrigin(nsPoint aScrollPosition,
nsIScrollableFrame::ScrollMode aMode,
nsIAtom *aOrigin,
const nsRect* aRange,
nsIScrollbarMediator::ScrollSnapMode aSnap)
nsIScrollableFrame::ScrollSnapMode aSnap)
{
if (aSnap == nsIScrollableFrame::ENABLE_SNAP) {
@ -3386,7 +3368,7 @@ ScrollFrameHelper::ScrollBy(nsIntPoint aDelta,
nsIntPoint* aOverflow,
nsIAtom *aOrigin,
nsIScrollableFrame::ScrollMomentum aMomentum,
nsIScrollbarMediator::ScrollSnapMode aSnap)
nsIScrollableFrame::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
@ -3518,7 +3500,7 @@ ScrollFrameHelper::ScrollBy(nsIntPoint aDelta,
}
void
ScrollFrameHelper::ScrollSnap(nsIScrollableFrame::ScrollMode aMode)
ScrollFrameHelper::ScrollSnap()
{
float flingSensitivity = gfxPrefs::ScrollSnapPredictionSensitivity();
int maxVelocity = gfxPrefs::ScrollSnapPredictionMaxVelocity();
@ -3531,7 +3513,7 @@ ScrollFrameHelper::ScrollSnap(nsIScrollableFrame::ScrollMode aMode)
predictedOffset.Clamp(maxOffset);
nsPoint pos = GetScrollPosition();
nsPoint destinationPos = pos + predictedOffset;
ScrollSnap(destinationPos, aMode);
ScrollSnap(destinationPos);
}
void
@ -3541,8 +3523,7 @@ ScrollFrameHelper::FlingSnap(const mozilla::CSSPoint& aDestination)
}
void
ScrollFrameHelper::ScrollSnap(const nsPoint &aDestination,
nsIScrollableFrame::ScrollMode aMode)
ScrollFrameHelper::ScrollSnap(const nsPoint &aDestination)
{
nsRect scrollRange = GetScrollRangeForClamping();
nsPoint pos = GetScrollPosition();
@ -3550,7 +3531,7 @@ ScrollFrameHelper::ScrollSnap(const nsPoint &aDestination,
if (GetSnapPointForDestination(nsIScrollableFrame::DEVICE_PIXELS,
pos,
snapDestination)) {
ScrollTo(snapDestination, aMode);
ScrollTo(snapDestination, nsIScrollableFrame::SMOOTH_MSD);
}
}

View File

@ -181,9 +181,8 @@ public:
void SetResolution(float aResolution);
void SetResolutionAndScaleTo(float aResolution);
void FlingSnap(const mozilla::CSSPoint& aDestination);
void ScrollSnap(nsIScrollableFrame::ScrollMode aMode = nsIScrollableFrame::SMOOTH_MSD);
void ScrollSnap(const nsPoint &aDestination,
nsIScrollableFrame::ScrollMode aMode = nsIScrollableFrame::SMOOTH_MSD);
void ScrollSnap();
void ScrollSnap(const nsPoint &aDestination);
protected:
nsRect GetScrollRangeForClamping() const;
@ -201,8 +200,7 @@ public:
*/
void ScrollTo(nsPoint aScrollPosition, nsIScrollableFrame::ScrollMode aMode,
const nsRect* aRange = nullptr,
nsIScrollbarMediator::ScrollSnapMode aSnap
= nsIScrollbarMediator::DISABLE_SNAP) {
nsIScrollableFrame::ScrollSnapMode aSnap = nsIScrollableFrame::DISABLE_SNAP) {
ScrollToWithOrigin(aScrollPosition, aMode, nsGkAtoms::other, aRange,
aSnap);
}
@ -231,8 +229,7 @@ public:
nsIScrollableFrame::ScrollMode aMode, nsIntPoint* aOverflow,
nsIAtom* aOrigin = nullptr,
nsIScrollableFrame::ScrollMomentum aMomentum = nsIScrollableFrame::NOT_MOMENTUM,
nsIScrollbarMediator::ScrollSnapMode aSnap
= nsIScrollbarMediator::DISABLE_SNAP);
nsIScrollableFrame::ScrollSnapMode aSnap = nsIScrollableFrame::DISABLE_SNAP);
/**
* @note This method might destroy the frame, pres shell and other objects.
*/
@ -383,26 +380,17 @@ public:
nsTArray<FrameMetrics>* aOutput) const;
// nsIScrollbarMediator
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 ScrollByPage(nsScrollbarFrame* aScrollbar, int32_t aDirection);
void ScrollByWhole(nsScrollbarFrame* aScrollbar, int32_t aDirection);
void ScrollByLine(nsScrollbarFrame* aScrollbar, int32_t aDirection);
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,
nsIScrollbarMediator::ScrollSnapMode aSnap
= nsIScrollbarMediator::DISABLE_SNAP);
nsIScrollableFrame::ScrollUnit aUnit);
// owning references to the nsIAnonymousContentCreator-built content
nsCOMPtr<nsIContent> mHScrollbarContent;
@ -532,8 +520,7 @@ protected:
nsIScrollableFrame::ScrollMode aMode,
nsIAtom *aOrigin, // nullptr indicates "other" origin
const nsRect* aRange,
nsIScrollbarMediator::ScrollSnapMode aSnap
= nsIScrollbarMediator::DISABLE_SNAP);
nsIScrollableFrame::ScrollSnapMode aSnap = nsIScrollableFrame::DISABLE_SNAP);
void CompleteAsyncScroll(const nsRect &aRange, nsIAtom* aOrigin = nullptr);
@ -722,8 +709,7 @@ public:
*/
virtual void ScrollTo(nsPoint aScrollPosition, ScrollMode aMode,
const nsRect* aRange = nullptr,
nsIScrollbarMediator::ScrollSnapMode aSnap
= nsIScrollbarMediator::DISABLE_SNAP)
nsIScrollableFrame::ScrollSnapMode aSnap = nsIScrollableFrame::DISABLE_SNAP)
override {
mHelper.ScrollTo(aScrollPosition, aMode, aRange, aSnap);
}
@ -751,8 +737,7 @@ public:
virtual void ScrollBy(nsIntPoint aDelta, ScrollUnit aUnit, ScrollMode aMode,
nsIntPoint* aOverflow, nsIAtom* aOrigin = nullptr,
nsIScrollableFrame::ScrollMomentum aMomentum = nsIScrollableFrame::NOT_MOMENTUM,
nsIScrollbarMediator::ScrollSnapMode aSnap
= nsIScrollbarMediator::DISABLE_SNAP)
nsIScrollableFrame::ScrollSnapMode aSnap = nsIScrollableFrame::DISABLE_SNAP)
override {
mHelper.ScrollBy(aDelta, aUnit, aMode, aOverflow, aOrigin, aMomentum, aSnap);
}
@ -860,20 +845,14 @@ public:
virtual nsIAtom* GetType() const override;
// nsIScrollbarMediator
virtual void ScrollByPage(nsScrollbarFrame* aScrollbar, int32_t aDirection,
nsIScrollbarMediator::ScrollSnapMode aSnap
= nsIScrollbarMediator::DISABLE_SNAP) override {
mHelper.ScrollByPage(aScrollbar, aDirection, aSnap);
virtual void ScrollByPage(nsScrollbarFrame* aScrollbar, int32_t aDirection) override {
mHelper.ScrollByPage(aScrollbar, aDirection);
}
virtual void ScrollByWhole(nsScrollbarFrame* aScrollbar, int32_t aDirection,
nsIScrollbarMediator::ScrollSnapMode aSnap
= nsIScrollbarMediator::DISABLE_SNAP) override {
mHelper.ScrollByWhole(aScrollbar, aDirection, aSnap);
virtual void ScrollByWhole(nsScrollbarFrame* aScrollbar, int32_t aDirection) override {
mHelper.ScrollByWhole(aScrollbar, aDirection);
}
virtual void ScrollByLine(nsScrollbarFrame* aScrollbar, int32_t aDirection,
nsIScrollbarMediator::ScrollSnapMode aSnap
= nsIScrollbarMediator::DISABLE_SNAP) override {
mHelper.ScrollByLine(aScrollbar, aDirection, aSnap);
virtual void ScrollByLine(nsScrollbarFrame* aScrollbar, int32_t aDirection) override {
mHelper.ScrollByLine(aScrollbar, aDirection);
}
virtual void RepeatButtonScroll(nsScrollbarFrame* aScrollbar) override {
mHelper.RepeatButtonScroll(aScrollbar);
@ -883,9 +862,6 @@ 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);
@ -1114,8 +1090,7 @@ public:
*/
virtual void ScrollTo(nsPoint aScrollPosition, ScrollMode aMode,
const nsRect* aRange = nullptr,
ScrollSnapMode aSnap = nsIScrollbarMediator::DISABLE_SNAP)
override {
ScrollSnapMode aSnap = nsIScrollableFrame::DISABLE_SNAP) override {
mHelper.ScrollTo(aScrollPosition, aMode, aRange, aSnap);
}
/**
@ -1139,8 +1114,7 @@ public:
virtual void ScrollBy(nsIntPoint aDelta, ScrollUnit aUnit, ScrollMode aMode,
nsIntPoint* aOverflow, nsIAtom* aOrigin = nullptr,
nsIScrollableFrame::ScrollMomentum aMomentum = nsIScrollableFrame::NOT_MOMENTUM,
nsIScrollbarMediator::ScrollSnapMode aSnap
= nsIScrollbarMediator::DISABLE_SNAP)
nsIScrollableFrame::ScrollSnapMode aSnap = nsIScrollableFrame::DISABLE_SNAP)
override {
mHelper.ScrollBy(aDelta, aUnit, aMode, aOverflow, aOrigin, aMomentum, aSnap);
}
@ -1255,20 +1229,14 @@ public:
return nsBoxFrame::IsFrameOfType(aFlags);
}
virtual void ScrollByPage(nsScrollbarFrame* aScrollbar, int32_t aDirection,
nsIScrollbarMediator::ScrollSnapMode aSnap
= nsIScrollbarMediator::DISABLE_SNAP) override {
mHelper.ScrollByPage(aScrollbar, aDirection, aSnap);
virtual void ScrollByPage(nsScrollbarFrame* aScrollbar, int32_t aDirection) override {
mHelper.ScrollByPage(aScrollbar, aDirection);
}
virtual void ScrollByWhole(nsScrollbarFrame* aScrollbar, int32_t aDirection,
nsIScrollbarMediator::ScrollSnapMode aSnap
= nsIScrollbarMediator::DISABLE_SNAP) override {
mHelper.ScrollByWhole(aScrollbar, aDirection, aSnap);
virtual void ScrollByWhole(nsScrollbarFrame* aScrollbar, int32_t aDirection) override {
mHelper.ScrollByWhole(aScrollbar, aDirection);
}
virtual void ScrollByLine(nsScrollbarFrame* aScrollbar, int32_t aDirection,
nsIScrollbarMediator::ScrollSnapMode aSnap
= nsIScrollbarMediator::DISABLE_SNAP) override {
mHelper.ScrollByLine(aScrollbar, aDirection, aSnap);
virtual void ScrollByLine(nsScrollbarFrame* aScrollbar, int32_t aDirection) override {
mHelper.ScrollByLine(aScrollbar, aDirection);
}
virtual void RepeatButtonScroll(nsScrollbarFrame* aScrollbar) override {
mHelper.RepeatButtonScroll(aScrollbar);
@ -1278,9 +1246,6 @@ 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);

View File

@ -207,6 +207,13 @@ 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
@ -218,8 +225,7 @@ public:
*/
virtual void ScrollTo(nsPoint aScrollPosition, ScrollMode aMode,
const nsRect* aRange = nullptr,
nsIScrollbarMediator::ScrollSnapMode aSnap
= nsIScrollbarMediator::DISABLE_SNAP) = 0;
ScrollSnapMode aSnap = DISABLE_SNAP) = 0;
/**
* @note This method might destroy the frame, pres shell and other objects.
* Scrolls to a particular position in integer CSS pixels.
@ -274,8 +280,7 @@ public:
nsIntPoint* aOverflow = nullptr,
nsIAtom* aOrigin = nullptr,
ScrollMomentum aMomentum = NOT_MOMENTUM,
nsIScrollbarMediator::ScrollSnapMode aSnap
= nsIScrollbarMediator::DISABLE_SNAP) = 0;
ScrollSnapMode aSnap = DISABLE_SNAP) = 0;
/**
* Perform scroll snapping, possibly resulting in a smooth scroll to

View File

@ -24,25 +24,14 @@ 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,
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;
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;
/**
* RepeatButtonScroll is called when the scrollbar's button is held down. When the
* button is first clicked the increment is set; RepeatButtonScroll adds this
@ -60,11 +49,6 @@ 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;
/**

View File

@ -326,10 +326,8 @@ nsListBoxBodyFrame::GetPrefSize(nsBoxLayoutState& aBoxLayoutState)
///////////// nsIScrollbarMediator ///////////////
void
nsListBoxBodyFrame::ScrollByPage(nsScrollbarFrame* aScrollbar, int32_t aDirection,
nsIScrollbarMediator::ScrollSnapMode aSnap)
nsListBoxBodyFrame::ScrollByPage(nsScrollbarFrame* aScrollbar, int32_t aDirection)
{
// CSS Scroll Snapping is not enabled for XUL, aSnap is ignored
MOZ_ASSERT(aScrollbar != nullptr);
aScrollbar->SetIncrementToPage(aDirection);
nsWeakFrame weakFrame(this);
@ -341,10 +339,8 @@ nsListBoxBodyFrame::ScrollByPage(nsScrollbarFrame* aScrollbar, int32_t aDirectio
}
void
nsListBoxBodyFrame::ScrollByWhole(nsScrollbarFrame* aScrollbar, int32_t aDirection,
nsIScrollbarMediator::ScrollSnapMode aSnap)
nsListBoxBodyFrame::ScrollByWhole(nsScrollbarFrame* aScrollbar, int32_t aDirection)
{
// CSS Scroll Snapping is not enabled for XUL, aSnap is ignored
MOZ_ASSERT(aScrollbar != nullptr);
aScrollbar->SetIncrementToWhole(aDirection);
nsWeakFrame weakFrame(this);
@ -356,10 +352,8 @@ nsListBoxBodyFrame::ScrollByWhole(nsScrollbarFrame* aScrollbar, int32_t aDirecti
}
void
nsListBoxBodyFrame::ScrollByLine(nsScrollbarFrame* aScrollbar, int32_t aDirection,
nsIScrollbarMediator::ScrollSnapMode aSnap)
nsListBoxBodyFrame::ScrollByLine(nsScrollbarFrame* aScrollbar, int32_t aDirection)
{
// CSS Scroll Snapping is not enabled for XUL, aSnap is ignored
MOZ_ASSERT(aScrollbar != nullptr);
aScrollbar->SetIncrementToLine(aDirection);
nsWeakFrame weakFrame(this);

View File

@ -54,20 +54,13 @@ public:
virtual nsresult AttributeChanged(int32_t aNameSpaceID, nsIAtom* aAttribute, int32_t aModType) override;
// nsIScrollbarMediator
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 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 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 {}

View File

@ -141,19 +141,19 @@ nsScrollbarButtonFrame::HandleButtonPress(nsPresContext* aPresContext,
case 0:
sb->SetIncrementToLine(direction);
if (m) {
m->ScrollByLine(sb, direction, nsIScrollbarMediator::ENABLE_SNAP);
m->ScrollByLine(sb, direction);
}
break;
case 1:
sb->SetIncrementToPage(direction);
if (m) {
m->ScrollByPage(sb, direction, nsIScrollbarMediator::ENABLE_SNAP);
m->ScrollByPage(sb, direction);
}
break;
case 2:
sb->SetIncrementToWhole(direction);
if (m) {
m->ScrollByWhole(sb, direction, nsIScrollbarMediator::ENABLE_SNAP);
m->ScrollByWhole(sb, direction);
}
break;
case 3:
@ -187,15 +187,6 @@ 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;
}

View File

@ -264,8 +264,7 @@ nsSliderFrame::AttributeChanged(int32_t aNameSpaceID,
nsIScrollbarMediator* mediator = scrollbarFrame->GetScrollbarMediator();
scrollbarFrame->SetIncrementToWhole(direction);
if (mediator) {
mediator->ScrollByWhole(scrollbarFrame, direction,
nsIScrollbarMediator::ENABLE_SNAP);
mediator->ScrollByWhole(scrollbarFrame, direction);
}
}
// 'this' might be destroyed here
@ -1154,14 +1153,6 @@ 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;
}
@ -1270,7 +1261,7 @@ nsSliderFrame::PageScroll(nscoord aChange)
nsIScrollbarMediator* m = sb->GetScrollbarMediator();
sb->SetIncrementToPage(aChange);
if (m) {
m->ScrollByPage(sb, aChange, nsIScrollbarMediator::ENABLE_SNAP);
m->ScrollByPage(sb, aChange);
return;
}
}

View File

@ -4200,29 +4200,23 @@ nsTreeBodyFrame::ScrollHorzInternal(const ScrollParts& aParts, int32_t aPosition
}
void
nsTreeBodyFrame::ScrollByPage(nsScrollbarFrame* aScrollbar, int32_t aDirection,
nsIScrollbarMediator::ScrollSnapMode aSnap)
nsTreeBodyFrame::ScrollByPage(nsScrollbarFrame* aScrollbar, int32_t aDirection)
{
// 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,
nsIScrollbarMediator::ScrollSnapMode aSnap)
nsTreeBodyFrame::ScrollByWhole(nsScrollbarFrame* aScrollbar, int32_t aDirection)
{
// 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,
nsIScrollbarMediator::ScrollSnapMode aSnap)
nsTreeBodyFrame::ScrollByLine(nsScrollbarFrame* aScrollbar, int32_t aDirection)
{
// CSS Scroll Snapping is not enabled for XUL, aSnap is ignored
MOZ_ASSERT(aScrollbar != nullptr);
ScrollByLines(aDirection);
}

View File

@ -133,20 +133,13 @@ public:
virtual bool PseudoMatches(nsCSSSelector* aSelector) override;
// nsIScrollbarMediator
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 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 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();