Commit 4ef6981e authored by bweinstein@apple.com's avatar bweinstein@apple.com

2009-08-12 Brian Weinstein <bweinstein@apple.com>

        Reviewed by Eric Seidel.

        Fixes two bugs about Pan Scrolling - Scrolling with middle mouse button doesn't
        work in Expanded view on reader.google.com, and Can enter auto scroll from a non-scrollable area.
        https://bugs.webkit.org/show_bug.cgi?id=28023
        https://bugs.webkit.org/show_bug.cgi?id=24794

        Added a new method to RenderBox seeing if the Box can be scrolled and actually has something to
        scroll, and use that for pan scrolling.

        Test: platform/win/fast/events/panScroll-nested-divs.html

        * page/EventHandler.cpp:
        (WebCore::EventHandler::handleMouseDraggedEvent):
        (WebCore::EventHandler::updateAutoscrollRenderer):
        (WebCore::EventHandler::handleMousePressEvent):
        * rendering/RenderBox.cpp:
        (WebCore::RenderBox::canBeScrolledAndHasScrollableArea):
        * rendering/RenderBox.h:
        * rendering/RenderLayer.cpp:
        (WebCore::RenderLayer::scrollByRecursively):

2009-08-12  Brian Weinstein  <bweinstein@apple.com>

        Reviewed by Eric Seidel.

        Added a Windows test for https://bugs.webkit.org/show_bug.cgi?id=28023.

        * platform/win/fast/events/panScroll-nested-divs-expected.txt: Added.
        * platform/win/fast/events/panScroll-nested-divs.html: Added.

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@47163 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent c44211d7
2009-08-12 Brian Weinstein <bweinstein@apple.com>
Reviewed by Eric Seidel.
Added a Windows test for https://bugs.webkit.org/show_bug.cgi?id=28023.
* platform/win/fast/events/panScroll-nested-divs-expected.txt: Added.
* platform/win/fast/events/panScroll-nested-divs.html: Added.
2009-08-12 Michelangelo De Simone <micdesim@gmail.com>
Reviewed by Darin Adler.
......
Panscrolling starting in the blue box should scroll the outer div.
Panscrolling outside the blue boxes should scroll the outer div.
Panscrolling starting in the blue box should scroll the outer div.
Test for bug 28023 This tests that pan scrolling propogates correctly up the DOM tree. On success, our scroll offset should be non-zero.
Success! Div with overflow was scrolled
<html>
<head>
<title>Pan Scrolling Test</title>
</head>
<body>
<script>
if (layoutTestController) {
layoutTestController.dumpAsText();
layoutTestController.waitUntilDone();
}
</script>
<div id="overflow" style="width:500px; height:300px; overflow:auto; border:2px solid red; padding:10px">
<div style="height:200px; position:relative;">
<div style="height:150px; border:1px blue solid; overflow:auto;">
Panscrolling starting in the blue box should scroll the outer div.
</div>
Panscrolling outside the blue boxes should scroll the outer div.
</div>
<div style="height:200px; position:relative;">
<div style="height:150px; border:1px blue solid; overflow:auto;">
Panscrolling starting in the blue box should scroll the outer div.
</div>
</div>
</div>
<p>Test for <a href="https://bugs.webkit.org/show_bug.cgi?id=28023">bug 28023</a> This tests that pan scrolling
propogates correctly up the DOM tree. On success, our scroll offset should be non-zero.</p>
<div id="console"></div>
<script>
if (eventSender)
{
eventSender.mouseMoveTo(50, 50);
eventSender.mouseDown(1);
eventSender.mouseUp(1);
eventSender.mouseMoveTo(50, 200);
setTimeout(finished, 500);
}
function finished()
{
if (document.getElementById('overflow').scrollTop)
document.getElementById('console').innerHTML = "Success! Div with overflow was scrolled";
else
document.getElementById('console').innerHTML = "Fail! Div with overflow was not scrolled";
window.layoutTestController.notifyDone();
}
</script>
</body>
</html>
2009-08-12 Brian Weinstein <bweinstein@apple.com>
Reviewed by Eric Seidel.
Fixes two bugs about Pan Scrolling - Scrolling with middle mouse button doesn't
work in Expanded view on reader.google.com, and Can enter auto scroll from a non-scrollable area.
https://bugs.webkit.org/show_bug.cgi?id=28023
https://bugs.webkit.org/show_bug.cgi?id=24794
Added a new method to RenderBox seeing if the Box can be scrolled and actually has something to
scroll, and use that for pan scrolling.
Test: platform/win/fast/events/panScroll-nested-divs.html
* page/EventHandler.cpp:
(WebCore::EventHandler::handleMouseDraggedEvent):
(WebCore::EventHandler::updateAutoscrollRenderer):
(WebCore::EventHandler::handleMousePressEvent):
* rendering/RenderBox.cpp:
(WebCore::RenderBox::canBeScrolledAndHasScrollableArea):
* rendering/RenderBox.h:
* rendering/RenderLayer.cpp:
(WebCore::RenderLayer::scrollByRecursively):
2009-08-12 Brian Weinstein <bweinstein@apple.com>
Reviewed by Adam Roben.
......@@ -430,7 +430,7 @@ bool EventHandler::handleMouseDraggedEvent(const MouseEventWithHitTestResults& e
// If the selection is contained in a layer that can scroll, that layer should handle the autoscroll
// Otherwise, let the bridge handle it so the view can scroll itself.
RenderObject* renderer = targetNode->renderer();
while (renderer && (!renderer->isBox() || !toRenderBox(renderer)->canBeProgramaticallyScrolled(false))) {
while (renderer && (!renderer->isBox() || !toRenderBox(renderer)->canBeScrolledAndHasScrollableArea())) {
if (!renderer->parent() && renderer->node() == renderer->document() && renderer->document()->ownerElement())
renderer = renderer->document()->ownerElement()->renderer();
else
......@@ -720,7 +720,7 @@ void EventHandler::updateAutoscrollRenderer()
if (Node* nodeAtPoint = hitTest.innerNode())
m_autoscrollRenderer = nodeAtPoint->renderer();
while (m_autoscrollRenderer && (!m_autoscrollRenderer->isBox() || !toRenderBox(m_autoscrollRenderer)->canBeProgramaticallyScrolled(false)))
while (m_autoscrollRenderer && (!m_autoscrollRenderer->isBox() || !toRenderBox(m_autoscrollRenderer)->canBeScrolledAndHasScrollableArea()))
m_autoscrollRenderer = m_autoscrollRenderer->parent();
}
......@@ -1160,7 +1160,7 @@ bool EventHandler::handleMousePressEvent(const PlatformMouseEvent& mouseEvent)
if (mouseEvent.button() == MiddleButton && !mev.isOverLink()) {
RenderObject* renderer = mev.targetNode()->renderer();
while (renderer && (!renderer->isBox() || !toRenderBox(renderer)->canBeProgramaticallyScrolled(false))) {
while (renderer && (!renderer->isBox() || !toRenderBox(renderer)->canBeScrolledAndHasScrollableArea())) {
if (!renderer->parent() && renderer->node() == renderer->document() && renderer->document()->ownerElement())
renderer = renderer->document()->ownerElement()->renderer();
else
......
......@@ -410,6 +410,11 @@ bool RenderBox::scroll(ScrollDirection direction, ScrollGranularity granularity,
return b->scroll(direction, granularity, multiplier);
return false;
}
bool RenderBox::canBeScrolledAndHasScrollableArea() const
{
return canBeProgramaticallyScrolled(false) && (scrollHeight() != clientHeight() || scrollWidth() != clientWidth());
}
bool RenderBox::canBeProgramaticallyScrolled(bool) const
{
......
......@@ -230,6 +230,7 @@ public:
virtual int verticalScrollbarWidth() const;
int horizontalScrollbarHeight() const;
virtual bool scroll(ScrollDirection, ScrollGranularity, float multiplier = 1.0f);
bool canBeScrolledAndHasScrollableArea() const;
virtual bool canBeProgramaticallyScrolled(bool) const;
virtual void autoscroll();
virtual void stopAutoscroll() { }
......
......@@ -997,6 +997,9 @@ void RenderLayer::panScrollFromPoint(const IntPoint& sourcePoint)
void RenderLayer::scrollByRecursively(int xDelta, int yDelta)
{
if (!xDelta && !yDelta)
return;
bool restrictedByLineClamp = false;
if (renderer()->parent())
restrictedByLineClamp = renderer()->parent()->style()->lineClamp() >= 0;
......@@ -1006,17 +1009,30 @@ void RenderLayer::scrollByRecursively(int xDelta, int yDelta)
int newOffsetY = scrollYOffset() + yDelta;
scrollToOffset(newOffsetX, newOffsetY);
// If this layer can't do the scroll we ask its parent
// If this layer can't do the scroll we ask the next layer up that can scroll to try
int leftToScrollX = newOffsetX - scrollXOffset();
int leftToScrollY = newOffsetY - scrollYOffset();
if ((leftToScrollX || leftToScrollY) && renderer()->parent()) {
renderer()->parent()->enclosingLayer()->scrollByRecursively(leftToScrollX, leftToScrollY);
RenderObject* nextRenderer = renderer()->parent();
while (nextRenderer) {
if (nextRenderer->isBox() && toRenderBox(nextRenderer)->canBeScrolledAndHasScrollableArea()) {
nextRenderer->enclosingLayer()->scrollByRecursively(leftToScrollX, leftToScrollY);
break;
}
nextRenderer = nextRenderer->parent();
}
Frame* frame = renderer()->document()->frame();
if (frame)
frame->eventHandler()->updateAutoscrollRenderer();
}
} else if (renderer()->view()->frameView())
} else if (renderer()->view()->frameView()) {
// If we are here, we were called on a renderer that can be programatically scrolled, but doesn't
// have an overflow clip. Which means that it is a document node that can be scrolled.
renderer()->view()->frameView()->scrollBy(IntSize(xDelta, yDelta));
// FIXME: If we didn't scroll the whole way, do we want to try looking at the frames ownerElement?
// https://bugs.webkit.org/show_bug.cgi?id=28237
}
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment