Back out bug 791616 due to test failure.

This commit is contained in:
Robert O'Callahan 2012-09-24 21:55:16 +12:00
parent dc0a7ee1ac
commit 9415165f4b
9 changed files with 20 additions and 116 deletions

View File

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

View File

@ -568,8 +568,7 @@ public:
};
typedef struct ScrollAxis {
int16_t mWhereToScroll;
WhenToScroll mWhenToScroll : 8;
bool mOnlyIfPerceivedScrollableDirection : 1;
WhenToScroll mWhenToScroll : 16;
/**
* @param aWhere: Either a percentage or a special value.
* nsIPresShell defines:
@ -600,17 +599,10 @@ public:
* is visible.
* * SCROLL_ALWAYS: Move the frame regardless of its current
* visibility.
* @param aOnlyIfPerceivedScrollableDirection:
* If the direction is not a perceived scrollable direction (i.e.
* no scrollbar showing and less than one device pixel of
* scrollable distance), don't scroll.
*/
ScrollAxis(int16_t aWhere = SCROLL_MINIMUM,
WhenToScroll aWhen = SCROLL_IF_NOT_FULLY_VISIBLE,
bool aOnlyIfPerceivedScrollableDirection = true) :
mWhereToScroll(aWhere), mWhenToScroll(aWhen),
mOnlyIfPerceivedScrollableDirection(aOnlyIfPerceivedScrollableDirection)
{}
WhenToScroll aWhen = SCROLL_IF_NOT_FULLY_VISIBLE) :
mWhereToScroll(aWhere), mWhenToScroll(aWhen) {}
} ScrollAxis;
/**
* Scrolls the view of the document so that the primary frame of the content

View File

@ -943,12 +943,18 @@ nsLayoutUtils::GetNearestScrollableFrameForDirection(nsIFrame* aFrame,
nsIScrollableFrame* scrollableFrame = do_QueryFrame(f);
if (scrollableFrame) {
nsPresContext::ScrollbarStyles ss = scrollableFrame->GetScrollbarStyles();
uint32_t directions = scrollableFrame->GetPerceivedScrollingDirections();
uint32_t scrollbarVisibility = scrollableFrame->GetScrollbarVisibility();
nsRect scrollRange = scrollableFrame->GetScrollRange();
// Require visible scrollbars or something to scroll to in
// the given direction.
nscoord oneDevPixel = f->PresContext()->DevPixelsToAppUnits(1);
if (aDirection == eVertical ?
(ss.mVertical != NS_STYLE_OVERFLOW_HIDDEN &&
(directions & nsIScrollableFrame::VERTICAL)) :
((scrollbarVisibility & nsIScrollableFrame::VERTICAL) ||
scrollRange.height >= oneDevPixel)) :
(ss.mHorizontal != NS_STYLE_OVERFLOW_HIDDEN &&
(directions & nsIScrollableFrame::HORIZONTAL)))
((scrollbarVisibility & nsIScrollableFrame::HORIZONTAL) ||
scrollRange.width >= oneDevPixel)))
return scrollableFrame;
}
}

View File

@ -3106,12 +3106,9 @@ static void ScrollToShowRect(nsIScrollableFrame* aScrollFrame,
nsPresContext::ScrollbarStyles ss = aScrollFrame->GetScrollbarStyles();
nsRect allowedRange(scrollPt, nsSize(0, 0));
bool needToScroll = false;
uint32_t directions = aScrollFrame->GetPerceivedScrollingDirections();
if (((aFlags & nsIPresShell::SCROLL_OVERFLOW_HIDDEN) ||
ss.mVertical != NS_STYLE_OVERFLOW_HIDDEN) &&
(!aVertical.mOnlyIfPerceivedScrollableDirection ||
(directions & nsIScrollableFrame::VERTICAL))) {
if ((aFlags & nsIPresShell::SCROLL_OVERFLOW_HIDDEN) ||
ss.mVertical != NS_STYLE_OVERFLOW_HIDDEN) {
if (ComputeNeedToScroll(aVertical.mWhenToScroll,
lineSize.height,
@ -3132,10 +3129,8 @@ static void ScrollToShowRect(nsIScrollableFrame* aScrollFrame,
}
}
if (((aFlags & nsIPresShell::SCROLL_OVERFLOW_HIDDEN) ||
ss.mHorizontal != NS_STYLE_OVERFLOW_HIDDEN) &&
(!aHorizontal.mOnlyIfPerceivedScrollableDirection ||
(directions & nsIScrollableFrame::HORIZONTAL))) {
if ((aFlags & nsIPresShell::SCROLL_OVERFLOW_HIDDEN) ||
ss.mHorizontal != NS_STYLE_OVERFLOW_HIDDEN) {
if (ComputeNeedToScroll(aHorizontal.mWhenToScroll,
lineSize.width,

View File

@ -4170,18 +4170,3 @@ nsGfxScrollFrameInner::FireScrolledAreaEvent()
nsEventDispatcher::Dispatch(doc, prescontext, &event, nullptr);
}
}
uint32_t
nsIScrollableFrame::GetPerceivedScrollingDirections() const
{
nscoord oneDevPixel = GetScrolledFrame()->PresContext()->AppUnitsPerDevPixel();
uint32_t directions = GetScrollbarVisibility();
nsRect scrollRange = GetScrollRange();
if (scrollRange.width >= oneDevPixel) {
directions |= HORIZONTAL;
}
if (scrollRange.height >= oneDevPixel) {
directions |= VERTICAL;
}
return directions;
}

View File

@ -51,12 +51,6 @@ public:
* assumptions about scrollbar visibility.
*/
virtual uint32_t GetScrollbarVisibility() const = 0;
/**
* Returns the directions in which scrolling is perceived to be allowed.
* A direction is perceived to be allowed if there is a visible scrollbar
* for that direction or if the scroll range is at least one device pixel.
*/
uint32_t GetPerceivedScrollingDirections() const;
/**
* Return the actual sizes of all possible scrollbars. Returns 0 for scrollbar
* positions that don't have a scrollbar or where the scrollbar is not visible.

View File

@ -5339,11 +5339,6 @@ Selection::ScrollIntoView(SelectionRegion aRegion,
if (!frame)
return NS_ERROR_FAILURE;
// Scroll vertically to get the caret into view, but only if the container
// is perceived to be scrollable in that direction (i.e. there is a visible
// vertical scrollbar or the scroll range is at least one device pixel)
aVertical.mOnlyIfPerceivedScrollableDirection = false;
presShell->ScrollFrameRectIntoView(frame, rect, aVertical, aHorizontal,
(aFlags & Selection::SCROLL_FIRST_ANCESTOR_ONLY) ?
nsIPresShell::SCROLL_FIRST_ANCESTOR_ONLY : 0);

View File

@ -103,7 +103,6 @@ MOCHITEST_FILES = \
test_bug748961.html \
test_bug784410.html \
test_bug785324.html \
test_bug791616.html \
$(NULL)
MOCHITEST_CHROME_FILES = \

View File

@ -1,63 +0,0 @@
<!DOCTYPE HTML>
<html>
<head>
<title>Test bug 791616</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" />
<style>
#t {
overflow: auto;
position: absolute;
left: 200px;
top: 100px;
font: 14px/1.1em "Consolas","Bitstream Vera Sans Mono","Courier New",Courier,monospace;
}
</style>
</head>
<body>
<p id="display"></p>
<div id="t" contenteditable>
<div>66666666666666</div>
<div id="target">777777777777777777777777777777777777777</div>
</div>
</div>
<pre id="test">
<script class="testbody">
var t = document.getElementById("t");
var target = document.getElementById("target");
var sel = window.getSelection();
var smoothScrollPref = "general.smoothScroll";
SimpleTest.waitForExplicitFinish();
SpecialPowers.setBoolPref(smoothScrollPref, false);
t.scrollTop = 0;
var targetY = target.getBoundingClientRect().top;
SimpleTest.waitForFocus(function() {
t.focus();
// Move the caret to scroll it into view
sel.collapse(target.firstChild, 2);
synthesizeKey("VK_LEFT", {});
// Delay until next repaint in case stuff is asynchronous. Also
// take a trip through the event loop.
setTimeout(function() {
window.mozRequestAnimationFrame(function() {
is(sel.anchorNode, target.firstChild, "Should have selected 'target' text node");
is(sel.anchorOffset, 1, "Selection should have moved left one character");
// We should not have needed to scroll the caret into view
is(target.getBoundingClientRect().top, targetY, "Target should not have scrolled");
SpecialPowers.clearUserPref(smoothScrollPref);
SimpleTest.finish();
});
// Make sure repainting actually happens.
target.style.background = "yellow";
});
});
</script>
</pre>
</body>
</html>