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
2011-05-13 Daniel Cheng <dcheng@chromium.org>
Reviewed by Tony Chang. Improve drag start logic https://bugs.webkit.org/show_bug.cgi?id=59409 Add a new test to test drag start edge cases on Mac (because of a non-zero text drag delay) as well as rebase an existing test. * fast/css/user-drag-none.html: Text nodes are no longer draggable. * platform/mac/editing/pasteboard/drag-selections-to-contenteditable-expected.txt: Added. * platform/mac/editing/pasteboard/drag-selections-to-contenteditable.html: Added. 2011-05-13 Daniel Cheng <dcheng@chromium.org> Reviewed by Tony Chang. Improve drag start logic https://bugs.webkit.org/show_bug.cgi?id=59409 Rewrite and simplify the dragging logic to better match IE, Firefox, and the behavior defined in the spec. Among other things: - draggableNode() no longer returns text nodes when dragging anchors. - When starting a drag over an image in a selection, prefer to drag the selection. - Several redundant hit tests have been removed. - Minor refactoring to make the logic easier to follow. Test: platform/mac/editing/pasteboard/drag-selections-to-contenteditable.html * WebCore.xcodeproj/project.pbxproj: * page/DragController.cpp: (WebCore::DragController::draggableNode): (WebCore::DragController::startDrag): * page/DragController.h: * page/DragState.h: (WebCore::DragState::shouldDispatchEvents): * page/EventHandler.cpp: (WebCore::EventHandler::EventHandler): (WebCore::EventHandler::eventMayStartDrag): (WebCore::EventHandler::updateDragSourceActionsAllowed): (WebCore::EventHandler::updateDragAndDrop): (WebCore::EventHandler::cancelDragAndDrop): (WebCore::EventHandler::dragHysteresisExceeded): (WebCore::EventHandler::dragSourceEndedAt): (WebCore::ExactlyOneBitSet): (WebCore::EventHandler::handleDrag): * page/EventHandler.h: Canonical link: https://commits.webkit.org/76126@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@86472 268f45cc-cd09-0410-ab3c-d52691b4dbfc
- Loading branch information
1 parent
585be5a
commit 68b05bd8437399d76bbdc9d030e8f53a0c80af6e
Showing
11 changed files
with
316 additions
and
167 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
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,16 @@ | ||
  Link Random text. | ||
Link Random text. | ||
This test checks selection drag edge cases on Mac. To run the test manually: | ||
|
||
Select everything above, start the drag over the image, and with no delay, drag it to the content editable area. Only the image should be dragged. | ||
Select everything above, start the drag over the link, and with no delay, drag it to the content editable area. The entire selection should be dragged. | ||
Select everything above, start the drag over the text, and with no delay, drag it to the content editable area. Nothing should be dragged, but a bunch of text should be selected instead. | ||
Dumping info about contenteditable div: | ||
Number of children: 4 | ||
Contents: | ||
IMG | ||
IMG | ||
A | ||
SPAN | ||
Number of selected ranges: 1 | ||
|
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,81 @@ | ||
<html> | ||
<head> | ||
<script> | ||
function log(message) { | ||
var console = document.getElementById("console"); | ||
var div = document.createElement("div"); | ||
var text = document.createTextNode(message); | ||
|
||
console.appendChild(div); | ||
div.appendChild(text); | ||
} | ||
|
||
function runTest() { | ||
if (window.layoutTestController) { | ||
layoutTestController.dumpAsText(); | ||
layoutTestController.waitUntilDone(); | ||
} else | ||
return; | ||
|
||
selectSelection(); | ||
dragElementToContentEditable(document.getElementById("dragimage")); | ||
|
||
selectSelection(); | ||
dragElementToContentEditable(document.getElementById("draglink")); | ||
|
||
selectSelection(); | ||
dragElementToContentEditable(document.getElementById("dragtext")); | ||
|
||
var target = document.getElementById("target"); | ||
log("Dumping info about contenteditable div:"); | ||
log("Number of children: " + target.children.length); | ||
log("Contents:"); | ||
log(target.children[0].tagName); | ||
log(target.children[1].tagName); | ||
log(target.children[2].tagName); | ||
log(target.children[3].tagName); | ||
|
||
log("Number of selected ranges: " + window.getSelection().rangeCount); | ||
|
||
layoutTestController.notifyDone(); | ||
} | ||
|
||
function selectSelection() { | ||
window.getSelection().selectAllChildren(document.getElementById("selection")); | ||
} | ||
|
||
function dragElementToContentEditable(dragSource) | ||
{ | ||
x = dragSource.offsetLeft + dragSource.offsetWidth / 2; | ||
y = dragSource.offsetTop + dragSource.offsetHeight / 2; | ||
|
||
eventSender.mouseMoveTo(x, y); | ||
eventSender.mouseDown(); | ||
|
||
var dropTarget = document.getElementById("target"); | ||
x = dropTarget.offsetLeft + dropTarget.offsetWidth / 2; | ||
y = dropTarget.offsetTop + dropTarget.offsetHeight / 2; | ||
|
||
eventSender.mouseMoveTo(x, y); | ||
eventSender.mouseUp(); | ||
} | ||
</script> | ||
</head> | ||
|
||
<body style="padding:0; margin:0" onload="runTest();"> | ||
|
||
<div id="target" style="border: 1px solid black; width: 300px; height: 200px;" contenteditable="true"></div> | ||
<div id="selection"> | ||
<img id="dragimage" src="../../../../editing/resources/abe.png"> | ||
<a href="#" id="draglink">Link</a> | ||
<span id="dragtext">Random text.</span></div> | ||
|
||
<p>This test checks selection drag edge cases on Mac. To run the test manually: | ||
<ol> | ||
<li>Select everything above, start the drag over the image, and with no delay, drag it to the content editable area. Only the image should be dragged. | ||
<li>Select everything above, start the drag over the link, and with no delay, drag it to the content editable area. The entire selection should be dragged. | ||
<li>Select everything above, start the drag over the text, and with no delay, drag it to the content editable area. Nothing should be dragged, but a bunch of text should be selected instead. | ||
</ol> | ||
</p> | ||
<div id="console"></ul> | ||
</body> |
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.