Bug 784410. Fix mousewheel scrolling to avoid scrolling frames that can't be scrolled by at least one device pixel. r=mats

This commit is contained in:
Robert O'Callahan 2012-09-13 16:13:19 +12:00
parent a84827280d
commit f936b8b283
2 changed files with 26 additions and 12 deletions

View File

@ -383,11 +383,13 @@ CanScrollOn(nsIScrollableFrame* aScrollFrame, double aDeltaX, double aDeltaY)
nsPoint scrollPt = aScrollFrame->GetScrollPosition();
nsRect scrollRange = aScrollFrame->GetScrollRange();
nscoord oneDevPixel =
aScrollFrame->GetScrolledFrame()->PresContext()->AppUnitsPerDevPixel();
return ((aDeltaX && CanScrollInRange(scrollRange.x, scrollPt.x,
scrollRange.XMost(), aDeltaX)) ||
(aDeltaY && CanScrollInRange(scrollRange.y, scrollPt.y,
scrollRange.YMost(), aDeltaY)));
return (aDeltaX && scrollRange.width >= oneDevPixel &&
CanScrollInRange(scrollRange.x, scrollPt.x, scrollRange.XMost(), aDeltaX)) ||
(aDeltaY && scrollRange.height >= oneDevPixel &&
CanScrollInRange(scrollRange.y, scrollPt.y, scrollRange.YMost(), aDeltaY));
}
void

View File

@ -27,16 +27,28 @@ function innerScrollOffset() {
}
var innerStartScrollOffset = innerScrollOffset();
var done = false;
var step = 0;
function doneScroll() {
if (done) {
return;
++step;
switch (step) {
case 1:
is(innerScrollOffset(), innerStartScrollOffset, "Inner element should not have scrolled down");
ok(outer.scrollTop > 0, "Outer element should have scrolled down");
outer.scrollTop = 0;
break;
case 2:
synthesizeWheel(inner, 4, 4,
{ deltaMode: WheelEvent.DOM_DELTA_LINE, deltaY: 1 });
break;
case 3:
is(innerScrollOffset(), innerStartScrollOffset, "Inner element should not have scrolled down");
ok(outer.scrollTop > 0, "Outer element should have scrolled down");
SpecialPowers.clearUserPref(smoothScrollPref);
SimpleTest.finish();
break;
}
done = true;
is(innerScrollOffset(), innerStartScrollOffset, "Inner element should not have scrolled down");
ok(outer.scrollTop > 0, "Outer element should have scrolled down");
SpecialPowers.clearUserPref(smoothScrollPref);
SimpleTest.finish();
}
function test() {