- Revision
- 156257
- Author
- [email protected]
- Date
- 2013-09-22 21:03:25 -0700 (Sun, 22 Sep 2013)
Log Message
iframe and scrollbar with "overflow:auto" should support autoscroll with mousedrag
https://bugs.webkit.org/show_bug.cgi?id=40981
Reviewed by Darin Adler.
Patch by Antonio Gomes <[email protected]>
Source/WebCore:
RenderBox::calculateAutoscrollDirection does not properly translate
inner frames' coordinates in order to determine its auto-scrollability.
By coincidence, if the inner frame box it placed near to page's 0, 0 position
(upper left corner), it might work.
Patch fixes it by changing ::calculateAutoscrollDirection algorithm to operate
with window coordinates, taking inner frames offset and scroll position into account.
The behavior of auto-scrollable non-frame overflow boxes, including divs, still works
as it is used to.
Test: fast/events/drag-and-drop-autoscroll-inner-frame.html
* rendering/RenderBox.cpp:
(WebCore::RenderBox::calculateAutoscrollDirection):
LayoutTests:
Test ensures that dragging an element close to the boundary of
scrollable Frames, scroll its content in that direction.
* fast/events/drag-and-drop-autoscroll-inner-frame-expected.txt: Added.
* fast/events/drag-and-drop-autoscroll-inner-frame.html: Added.
Modified Paths
Added Paths
Diff
Modified: trunk/LayoutTests/ChangeLog (156256 => 156257)
--- trunk/LayoutTests/ChangeLog 2013-09-23 03:40:47 UTC (rev 156256)
+++ trunk/LayoutTests/ChangeLog 2013-09-23 04:03:25 UTC (rev 156257)
@@ -1,3 +1,16 @@
+2013-09-22 Antonio Gomes <[email protected]>
+
+ iframe and scrollbar with "overflow:auto" should support autoscroll with mousedrag
+ https://bugs.webkit.org/show_bug.cgi?id=40981
+
+ Reviewed by Darin Adler.
+
+ Test ensures that dragging an element close to the boundary of
+ scrollable Frames, scroll its content in that direction.
+
+ * fast/events/drag-and-drop-autoscroll-inner-frame-expected.txt: Added.
+ * fast/events/drag-and-drop-autoscroll-inner-frame.html: Added.
+
2013-09-22 Arunprasad Rajkumar <[email protected]>
Hiding a focused element should unfocus it and fire a blur event
Added: trunk/LayoutTests/fast/events/drag-and-drop-autoscroll-inner-frame-expected.txt (0 => 156257)
--- trunk/LayoutTests/fast/events/drag-and-drop-autoscroll-inner-frame-expected.txt (rev 0)
+++ trunk/LayoutTests/fast/events/drag-and-drop-autoscroll-inner-frame-expected.txt 2013-09-23 04:03:25 UTC (rev 156257)
@@ -0,0 +1,12 @@
+For manual testing, drag and drop "Drop Me" downwards and then upwards.
+Check autoscroll within an inner frame by drag-and-drop
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS Autoscroll should have scrolled the iframe downwards, and did.
+PASS iframe.contentDocument.body.scrollTop < middleTermScrollOffset is true
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
Added: trunk/LayoutTests/fast/events/drag-and-drop-autoscroll-inner-frame.html (0 => 156257)
--- trunk/LayoutTests/fast/events/drag-and-drop-autoscroll-inner-frame.html (rev 0)
+++ trunk/LayoutTests/fast/events/drag-and-drop-autoscroll-inner-frame.html 2013-09-23 04:03:25 UTC (rev 156257)
@@ -0,0 +1,118 @@
+<!DOCTYPE html>
+<head>
+<style type="text/css">
+#scrollable {
+ height: 200px;
+ overflow: auto;
+ border: solid 3px #cc0000;
+ font-size: 80px;
+}
+</style>
+<script>
+
+var x, y, middleTermScrollOffset;
+var iframe, iframeDocument, draggable;
+
+function log(msg)
+{
+ document.getElementById('console').appendChild(document.createTextNode(msg + '\n'));
+}
+
+function setUpTest()
+{
+ if (!window.eventSender) {
+ log('Please run within DumpRenderTree');
+ return;
+ }
+
+ window.internals.settings.setAutoscrollForDragAndDropEnabled(true);
+ window.jsTestIsAsync = true;
+ setTimeout(testIt, 0);
+}
+
+function testIt()
+{
+ eventSender.dragMode = false;
+
+ iframe = document.getElementById('scrollable');
+ iframeDocument = iframe.contentDocument;
+ draggable = iframeDocument.getElementById('draggable');
+
+ iframeDocument.addEventListener("scroll", recordScroll);
+
+ // Grab draggable.
+ x = iframe.offsetLeft + draggable.offsetLeft + 7;
+ y = iframe.offsetTop + draggable.offsetTop + 7;
+
+ eventSender.mouseMoveTo(x, y);
+ eventSender.mouseDown();
+
+ // Move mouse to the bottom autoscroll border belt.
+ y = iframe.offsetTop + iframe.offsetHeight - 10;
+ eventSender.mouseMoveTo(x, y);
+}
+
+function recordScroll(e)
+{
+ autoscrollTestPart1();
+ iframeDocument.removeEventListener("scroll", recordScroll);
+}
+
+function recordScroll2(e)
+{
+ autoscrollTestPart2();
+ iframeDocument.removeEventListener("scroll", recordScroll);
+}
+
+function autoscrollTestPart1()
+{
+ if (iframe.contentDocument.body.scrollTop == 0) {
+ testFailed("Autoscroll should have scrolled the iframe downwards, but did not");
+ finishTest();
+ return;
+ }
+
+ testPassed("Autoscroll should have scrolled the iframe downwards, and did.");
+
+ middleTermScrollOffset = iframe.contentDocument.body.scrollTop;
+ iframeDocument.addEventListener("scroll", recordScroll2);
+
+ // Move mouse to the upper autoscroll border belt.
+ y = iframe.offsetTop + 10;
+ eventSender.mouseMoveTo(x, y);
+}
+
+function autoscrollTestPart2()
+{
+ shouldBeTrue("iframe.contentDocument.body.scrollTop < middleTermScrollOffset")
+ finishTest();
+}
+
+function finishTest()
+{
+ eventSender.mouseUp();
+ finishJSTest();
+}
+
+var successfullyParsed = true;
+</script>
+</head>
+<body>
+For manual testing, drag and drop "Drop Me" downwards and then upwards.
+<iframe id="scrollable" src=""
+<p id='draggable' draggable='true' style='cursor: hand;'>
+ <b>Drag me!</b>
+</p>
+Try to drag and drop the text above in the input element at the bottom of this iframe. It should scroll. Then, try the way back.
+<br><br>more<br>more<br>more<br>more<br>more<br>more<br>more<br>more<br>more<br>more<br>more<br>more<br><input>
+"></iframe><br>
+</div>
+<div id="console"></div>
+<script src=""
+<script>
+description('Check autoscroll within an inner frame by drag-and-drop');
+setUpTest();
+</script>
+<script src=""
+</body>
+</html>
Modified: trunk/Source/WebCore/ChangeLog (156256 => 156257)
--- trunk/Source/WebCore/ChangeLog 2013-09-23 03:40:47 UTC (rev 156256)
+++ trunk/Source/WebCore/ChangeLog 2013-09-23 04:03:25 UTC (rev 156257)
@@ -1,3 +1,25 @@
+2013-09-22 Antonio Gomes <[email protected]>
+
+ iframe and scrollbar with "overflow:auto" should support autoscroll with mousedrag
+ https://bugs.webkit.org/show_bug.cgi?id=40981
+
+ Reviewed by Darin Adler.
+
+ RenderBox::calculateAutoscrollDirection does not properly translate
+ inner frames' coordinates in order to determine its auto-scrollability.
+ By coincidence, if the inner frame box it placed near to page's 0, 0 position
+ (upper left corner), it might work.
+
+ Patch fixes it by changing ::calculateAutoscrollDirection algorithm to operate
+ with window coordinates, taking inner frames offset and scroll position into account.
+ The behavior of auto-scrollable non-frame overflow boxes, including divs, still works
+ as it is used to.
+
+ Test: fast/events/drag-and-drop-autoscroll-inner-frame.html
+
+ * rendering/RenderBox.cpp:
+ (WebCore::RenderBox::calculateAutoscrollDirection):
+
2013-09-22 Sam Weinig <[email protected]>
CTTE: Use references more in ContainerNode, ContainerNodeAlgorithms and related classes
Modified: trunk/Source/WebCore/rendering/RenderBox.cpp (156256 => 156257)
--- trunk/Source/WebCore/rendering/RenderBox.cpp 2013-09-23 03:40:47 UTC (rev 156256)
+++ trunk/Source/WebCore/rendering/RenderBox.cpp 2013-09-23 04:03:25 UTC (rev 156257)
@@ -842,20 +842,23 @@
// scrolling.
IntSize RenderBox::calculateAutoscrollDirection(const IntPoint& windowPoint) const
{
- IntSize offset;
- IntPoint point = view().frameView().windowToContents(windowPoint);
IntRect box(absoluteBoundingBoxRect());
+ box.move(view().frameView().scrollOffset());
+ IntRect windowBox = view().frameView().contentsToWindow(box);
- if (point.x() < box.x() + autoscrollBeltSize)
- point.move(-autoscrollBeltSize, 0);
- else if (point.x() > box.maxX() - autoscrollBeltSize)
- point.move(autoscrollBeltSize, 0);
+ IntPoint windowAutoscrollPoint = windowPoint;
- if (point.y() < box.y() + autoscrollBeltSize)
- point.move(0, -autoscrollBeltSize);
- else if (point.y() > box.maxY() - autoscrollBeltSize)
- point.move(0, autoscrollBeltSize);
- return view().frameView().contentsToWindow(point) - windowPoint;
+ if (windowAutoscrollPoint.x() < windowBox.x() + autoscrollBeltSize)
+ windowAutoscrollPoint.move(-autoscrollBeltSize, 0);
+ else if (windowAutoscrollPoint.x() > windowBox.maxX() - autoscrollBeltSize)
+ windowAutoscrollPoint.move(autoscrollBeltSize, 0);
+
+ if (windowAutoscrollPoint.y() < windowBox.y() + autoscrollBeltSize)
+ windowAutoscrollPoint.move(0, -autoscrollBeltSize);
+ else if (windowAutoscrollPoint.y() > windowBox.maxY() - autoscrollBeltSize)
+ windowAutoscrollPoint.move(0, autoscrollBeltSize);
+
+ return windowAutoscrollPoint - windowPoint;
}
RenderBox* RenderBox::findAutoscrollable(RenderObject* renderer)