Permalink
Show file tree
Hide file tree
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Dragging over an element with scrollbars should scroll the element wh…
…en dragging near edges https://bugs.webkit.org/show_bug.cgi?id=39725 Reviewed by Hajime Morita. Source/WebCore: This patch introduces auto scrolling functionality during drag-and-drop when drop source is near edge of scrollable element. When drop source is inside 20px of scrollable element more than 200ms, scrollable element is automatically scrolled every 50ms toward drop source position, e.g. vertically scroll up when drop source is in top edge. Test: fast/events/drag-and-drop-autoscroll.html * page/AutoscrollController.cpp: (WebCore::AutoscrollController::AutoscrollController): Changed to initialize m_dragAndDropAutoscrollStartTime. (WebCore::AutoscrollController::updateDragAndDrop): Added for start/stop autoscroll during drag-and-drop. (WebCore::AutoscrollController::autoscrollTimerFired): Changed to add autoscroll for drag-and-drop, and to pass last know position to RenderBox::autoscroll(). * page/AutoscrollController.h: (AutoscrollController): Changed to add updateDragAndDrop() and m_dragAndDropAutoscrollReferencePosition and m_dragAndDropAutoscrollStartTime. * page/EventHandler.cpp: (WebCore::EventHandler::updateDragAndDrop): Changed to call AutoscrollController::updateDragAndDrop(). * rendering/RenderBox.cpp: (WebCore::RenderBox::autoscroll): Changed for new parameter position. (WebCore::RenderBox::calculateAutoscrollDirection): Added for autoscroll. * rendering/RenderBox.h: (RenderBox): * rendering/RenderLayer.cpp: (WebCore::RenderLayer::autoscroll): Changed for new parameter position and move updateSelectionForMouseDrag() to AutoscrollController. * rendering/RenderLayer.h: (RenderLayer): * rendering/RenderListBox.cpp: (WebCore::RenderListBox::autoscroll): Changed for new parameter position. * rendering/RenderListBox.h: (RenderListBox): * rendering/RenderTextControlSingleLine.cpp: (WebCore::RenderTextControlSingleLine::autoscroll): Changed for new parameter position. * rendering/RenderTextControlSingleLine.h: (RenderTextControlSingleLine): Source/WebKit/chromium: This patch removes DragScrollTimer used for automatic scrolling of main frame drag-and-drop which is now implemented in EventHandler. Another patch will remove DragScrollTimer.{cpp,h} and update GYP files to make patch size small. No tests. Existing test covers this change. * src/WebViewImpl.cpp: (WebKit::WebViewImpl::WebViewImpl): Changed to remove m_dragScrollTimer. (WebKit::WebViewImpl::dragSourceEndedAt): ditto (WebKit::WebViewImpl::dragSourceMovedTo): ditto (WebKit::WebViewImpl::dragTargetDrop): ditto (WebKit::WebViewImpl::dragTargetDragEnterOrOver): ditto * src/WebViewImpl.h: (WebKit): Chagned to remove DragScrollTimer. LayoutTests: This patch adds new test for autoscroll during drag-and-drop. * fast/events/drag-and-drop-autoscroll-expected.txt: Added. * fast/events/drag-and-drop-autoscroll.html: Added. Canonical link: https://commits.webkit.org/124503@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@139044 268f45cc-cd09-0410-ab3c-d52691b4dbfc
- Loading branch information
Showing
18 changed files
with
286 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@@ -0,0 +1,8 @@ | ||
Check autoscroll by drag-and-drop | ||
|
||
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE". | ||
|
||
|
||
PASS scrollable.scrollTop > 0 | ||
For manual testing, drag and drop "Drop Me" to "Scrollable" area. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@@ -0,0 +1,101 @@ | ||
<html> | ||
<head> | ||
<style type="text/css"> | ||
#draggable { | ||
padding: 5pt; | ||
border: 3px solid #00cc00; | ||
background: #00cccc; | ||
width: 80px; | ||
cursor: hand; | ||
} | ||
|
||
#scrollable { | ||
height: 200px; | ||
overflow: auto; | ||
border: solid 3px #cc0000; | ||
} | ||
</style> | ||
<script> | ||
function $(id) { return document.getElementById(id); } | ||
|
||
function finishTest() { | ||
eventSender.mouseUp(); | ||
$('container').innerHTML = ''; | ||
window.testRunner.notifyDone(); | ||
} | ||
|
||
function testIt() { | ||
var draggable = $('draggable'); | ||
var scrollable = $('scrollable'); | ||
|
||
if (!window.eventSender) | ||
return; | ||
|
||
eventSender.dragMode = false; | ||
|
||
// Grab draggable | ||
eventSender.mouseMoveTo(draggable.offsetLeft + 5, draggable.offsetTop + 5); | ||
eventSender.mouseDown(); | ||
|
||
// Move mouse to autoscroll border belt. | ||
eventSender.mouseMoveTo(scrollable.offsetLeft + 5, scrollable.offsetTop + scrollable.offsetHeight - 10); | ||
|
||
var retryCount = 0; | ||
|
||
function checkScrolled() | ||
{ | ||
if (scrollable.scrollTop > 0) { | ||
testPassed('scrollable.scrollTop > 0'); | ||
finishTest(); | ||
return; | ||
} | ||
|
||
++retryCount; | ||
if (retryCount > 10) { | ||
testFailed('No autoscroll'); | ||
finishTest(); | ||
return; | ||
} | ||
|
||
// Autoscroll is occurred evey 0.05 sec. | ||
window.setTimeout(checkScrolled, 50); | ||
} | ||
|
||
checkScrolled(); | ||
} | ||
|
||
function setUpTest() | ||
{ | ||
var scrollable = $('scrollable'); | ||
for (var i = 0; i < 100; ++i) { | ||
var line = document.createElement('div'); | ||
line.innerHTML = "line " + i; | ||
scrollable.appendChild(line); | ||
} | ||
|
||
if (!window.eventSender) { | ||
console.log('Please run within DumpRenderTree'); | ||
return; | ||
} | ||
|
||
window.jsTestIsAsync = true; | ||
window.setTimeout(testIt, 0); | ||
} | ||
</script> | ||
</head> | ||
<body> | ||
For manual testing, drag and drop "Drop Me" to "Scrollable" area. | ||
<div id="container"> | ||
<div id="draggable" draggable="true">Drop Me</div> | ||
Scrollable | ||
<div id="scrollable"> | ||
</div> | ||
</div> | ||
<script src="../js/resources/js-test-pre.js"></script> | ||
<script> | ||
description('Check autoscroll by drag-and-drop'); | ||
setUpTest(); | ||
</script> | ||
<script src="../js/resources/js-test-post.js"></script> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.