Skip to content
Permalink
Browse files
2008-07-18 Maxime Britto <britto@apple.com>
        Reviewed by Adele.

        Fixed <rdar://problem/6049803>
        Prevent the autoscroll to trigger in WebClips when starting or hovering on an editable field.

        Test: fast/events/autoscroll-with-non-scrollable-parent.html

        * ChangeLog:
        * page/EventHandler.cpp: Edited
        (WebCore::EventHandler::handleMousePressEvent): changed the name of the funtion called to canBeProgramaticallyScrolled()
        (WebCore::EventHandler::handleMouseDraggedEvent): prevent the autoscroll to keep looking for a renderer when it's already triggered
        * rendering/RenderLayer.cpp:
        (WebCore::RenderLayer::scrollRectToVisible): verifies that the top layer can be programmatically scrolled before asking him to make the rect visible
        * rendering/RenderListBox.h:
        (WebCore::RenderListBox::canBeProgramaticallyScrolled):
        * rendering/RenderObject.cpp:
        (WebCore::RenderObject::canBeProgramaticallyScrolled): Edited : For the 3rd case we want document's renderer to have scrollbar as it's the top layer
        (WebCore::RenderObject::hasScrollableView): Verifies that the Object has a view with scrollBars
        * rendering/RenderObject.h: Renamed shouldAutosroll() for canBeProgramaticallyScrolled()
        * rendering/RenderTextControl.h:
        (WebCore::RenderTextControl::canBeProgramaticallyScrolled):

2008-07-18  Adele Peterson & Maxime Britto  <britto@apple.com>

        Reviewed by Adele.

        Test for <rdar://problem/6049803> Autoscroll triggered on no scrolling iframes

        * ChangeLog:
        * fast/events/autoscroll-with-non-scrollable-parent-expected.txt: Added.
        * fast/events/autoscroll-with-non-scrollable-parent.html: Added.
        * fast/events/resources/big-page-with-input.html: Added.



Canonical link: https://commits.webkit.org/27675@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@35244 268f45cc-cd09-0410-ab3c-d52691b4dbfc
  • Loading branch information
Maxime Britto committed Jul 19, 2008
1 parent 03b5238 commit f4143a825eec8759e2f183c8cd062e8ad682da32
Showing 11 changed files with 128 additions and 10 deletions.
@@ -1,3 +1,14 @@
2008-07-18 Adele Peterson & Maxime Britto <britto@apple.com>

Reviewed by Adele.

Test for <rdar://problem/6049803> Autoscroll triggered on no scrolling iframes

* ChangeLog:
* fast/events/autoscroll-with-non-scrollable-parent-expected.txt: Added.
* fast/events/autoscroll-with-non-scrollable-parent.html: Added.
* fast/events/resources/big-page-with-input.html: Added.

2008-07-18 Simon Fraser <simon.fraser@apple.com>

Reviewed by Dave Hyatt
@@ -0,0 +1,5 @@

rdar://problem/6049803
To do the test manually you have to try triggering the autoscroll by starting the dragging from within the text field. If the autoscroll occurs the text has FAILED since the containing iframe has scrolling=no else it has PASSED.
Though you should be able to write some long text in the input and to trigger the autoscroll within the input.
PASSED
@@ -0,0 +1,62 @@
<html>
<head>
<script>
function log(msg)
{
document.getElementById('console').appendChild(document.createTextNode(msg + '\n'));
}

function test()
{
if (window.layoutTestController) {
layoutTestController.waitUntilDone();
layoutTestController.dumpAsText();
setTimeout(autoscrollTestPart1, 0);
}
}

function autoscrollTestPart1()
{
var iframe = document.getElementById('NoScrolliFrame');
var iframeDocument = iframe.contentDocument;
var input = iframeDocument.getElementById('inp');
if (window.eventSender) {
var x = iframe.offsetLeft + input.offsetLeft + 7;
var y = iframe.offsetLeft + input.offsetTop + 7;
eventSender.dragMode = false;
eventSender.mouseMoveTo(x, y);
eventSender.mouseDown();
eventSender.mouseMoveTo(x + 20, y);
eventSender.mouseMoveTo(x + 600, y);
}
setTimeout(autoscrollTestPart2, 100);
}

function autoscrollTestPart2()
{
if (window.eventSender)
eventSender.mouseUp();

var iframe = document.getElementById('NoScrolliFrame');
var iframeDocument = iframe.contentDocument;
if (iframeDocument.body.scrollLeft != 0)
log("FAILED : " + iframeDocument.body.scrollLeft + " pixels have been scrolled");
else
log("PASSED");

if (window.layoutTestController)
layoutTestController.notifyDone();
}
</script>
</head>
<body onload="test()">
<iframe id="NoScrolliFrame" scrolling="no" style="height: 100px; width: 100px" src="resources/big-page-with-input.html"></iframe>
<div id="console">
rdar://problem/6049803 <br>
To do the test manually you have to try triggering the autoscroll by starting the dragging from within the text field. If the autoscroll occurs the text has FAILED since the containing iframe has scrolling=no else it has PASSED.<br>
Though you should be able to write some long text in the input and to trigger the autoscroll within the input.<br>
</div>

</body>
</html>

@@ -0,0 +1,8 @@
<html>
<body>
<div style="width: 400px; height: 400px; background-color: blue">
<input id="inp" size=5>
</div>
</body>
</html>

@@ -1,3 +1,27 @@
2008-07-18 Maxime Britto <britto@apple.com>

Reviewed by Adele.

Fixed <rdar://problem/6049803>
Prevent the autoscroll to trigger in WebClips when starting or hovering on an editable field.

Test: fast/events/autoscroll-with-non-scrollable-parent.html

* ChangeLog:
* page/EventHandler.cpp: Edited
(WebCore::EventHandler::handleMousePressEvent): changed the name of the funtion called to canBeProgramaticallyScrolled()
(WebCore::EventHandler::handleMouseDraggedEvent): prevent the autoscroll to keep looking for a renderer when it's already triggered
* rendering/RenderLayer.cpp:
(WebCore::RenderLayer::scrollRectToVisible): verifies that the top layer can be programmatically scrolled before asking him to make the rect visible
* rendering/RenderListBox.h:
(WebCore::RenderListBox::canBeProgramaticallyScrolled):
* rendering/RenderObject.cpp:
(WebCore::RenderObject::canBeProgramaticallyScrolled): Edited : For the 3rd case we want document's renderer to have scrollbar as it's the top layer
(WebCore::RenderObject::hasScrollableView): Verifies that the Object has a view with scrollBars
* rendering/RenderObject.h: Renamed shouldAutosroll() for canBeProgramaticallyScrolled()
* rendering/RenderTextControl.h:
(WebCore::RenderTextControl::canBeProgramaticallyScrolled):

2008-07-18 Sam Weinig <sam@webkit.org>

Reviewed by Anders Carlsson.
@@ -367,7 +367,7 @@ bool EventHandler::handleMousePressEvent(const MouseEventWithHitTestResults& eve
}

m_mouseDownMayStartAutoscroll = m_mouseDownMayStartSelect ||
(m_mousePressNode && m_mousePressNode->renderer() && m_mousePressNode->renderer()->shouldAutoscroll());
(m_mousePressNode && m_mousePressNode->renderer() && m_mousePressNode->renderer()->canBeProgramaticallyScrolled());

return swallowEvent;
}
@@ -394,12 +394,14 @@ 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->shouldAutoscroll())
while (renderer && !renderer->canBeProgramaticallyScrolled())
renderer = renderer->parent();
if (renderer) {
m_autoscrollInProgress = true;
handleAutoscroll(renderer);
}

m_mouseDownMayStartAutoscroll = false;
}

updateSelectionForMouseDrag(targetNode, event.localPoint());
@@ -941,7 +943,7 @@ bool EventHandler::handleMousePressEvent(const PlatformMouseEvent& mouseEvent)
} else if (mouseEvent.button() == MiddleButton && !mev.isOverLink()) {
RenderObject* renderer = mev.targetNode()->renderer();

while (renderer && !renderer->shouldAutoscroll())
while (renderer && !renderer->canBeProgramaticallyScrolled())
renderer = renderer->parent();

if (renderer) {
@@ -854,7 +854,7 @@ void RenderLayer::scrollRectToVisible(const IntRect &rect, const ScrollAlignment
newRect.setX(rect.x() - diffX);
newRect.setY(rect.y() - diffY);
}
} else if (!parentLayer) {
} else if (!parentLayer && renderer()->canBeProgramaticallyScrolled()) {
if (frameView) {
if (m_object->document() && m_object->document()->ownerElement() && m_object->document()->ownerElement()->renderer()) {
IntRect viewRect = enclosingIntRect(frameView->visibleContentRect());
@@ -77,7 +77,7 @@ class RenderListBox : public RenderBlock, private ScrollbarClient {
bool scrollToRevealElementAtListIndex(int index);
bool listIndexIsVisible(int index);

virtual bool shouldAutoscroll() const { return true; }
virtual bool canBeProgramaticallyScrolled() const { return true; }
virtual void autoscroll();
virtual void stopAutoscroll();

@@ -635,10 +635,15 @@ bool RenderObject::scroll(ScrollDirection direction, ScrollGranularity granulari
return b->scroll(direction, granularity, multiplier);
return false;
}

bool RenderObject::shouldAutoscroll() const

bool RenderObject::canBeProgramaticallyScrolled() const
{
return scrollsOverflow() || (node() && node()->isContentEditable()) || ((node() && node()->isDocumentNode()) && hasScrollableView());
}

bool RenderObject::hasScrollableView() const
{
return (hasOverflowClip() && (scrollsOverflow() || (node() && node()->isContentEditable()))) || (isRoot() && view() && view()->frameView()->isScrollable());
return (view() && view()->frameView()->isScrollable());
}

void RenderObject::autoscroll()
@@ -650,7 +650,8 @@ class RenderObject : public CachedResourceClient {
virtual void setScrollTop(int);

virtual bool scroll(ScrollDirection, ScrollGranularity, float multiplier = 1.0f);
virtual bool shouldAutoscroll() const;
virtual bool canBeProgramaticallyScrolled() const;
bool hasScrollableView() const;
virtual void autoscroll();
virtual void stopAutoscroll() { }

@@ -78,7 +78,7 @@ class RenderTextControl : public RenderBlock, private PopupMenuClient {
void forwardEvent(Event*);
void selectionChanged(bool userTriggered);

virtual bool shouldAutoscroll() const { return true; }
virtual bool canBeProgramaticallyScrolled() const { return true; }
virtual void autoscroll();

// Subclassed to forward to our inner div.

0 comments on commit f4143a8

Please sign in to comment.