Skip to content
Permalink
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
zetafunction committed May 13, 2011
1 parent 585be5a commit 68b05bd8437399d76bbdc9d030e8f53a0c80af6e
Showing 11 changed files with 316 additions and 167 deletions.
@@ -1,3 +1,17 @@
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 Anders Carlsson <andersca@apple.com>

Reviewed by Sam Weinig.
@@ -19,35 +19,35 @@
<img class="drag-none" src="resources/greenbox.png">
</div>

<div class="box" expect="IMG text text A nil">
<div class="box" expect="IMG A A A nil">
<a href="#"><img src="resources/greenbox.png">x<br><span>y</span></a>
</div>

<div class="box" expect="IMG text text A nil">
<div class="box" expect="IMG A A A nil">
<a href="#" class="drag-element"><img src="resources/greenbox.png">x<br><span>y</span></a>
</div>

<div class="box" expect="IMG nil nil nil nil">
<a href="#" class="drag-none"><img src="resources/greenbox.png">x<br><span>y</span></a>
</div>

<div class="box" expect="A text text A nil">
<div class="box" expect="A A A A nil">
<a href="#"><img class="drag-none" src="resources/greenbox.png">x<br><span>y</span></a>
</div>

<div class="box" expect="A text text A nil">
<div class="box" expect="A A A A nil">
<a href="#" class="drag-element"><img class="drag-none" src="resources/greenbox.png">x<br><span>y</span></a>
</div>

<div class="box drag-element" expect="IMG DIV DIV DIV DIV">
<a href="#" class="drag-none"><img src="resources/greenbox.png">x<br><span>y</span></a>
</div>

<div class="box drag-element" expect="A text text A DIV">
<div class="box drag-element" expect="A A A A DIV">
<a href="#"><img class="drag-none" src="resources/greenbox.png">x<br><span>y</span></a>
</div>

<div class="box drag-element" expect="A text text A DIV">
<div class="box drag-element" expect="A A A A DIV">
<a href="#" class="drag-element"><img class="drag-none" src="resources/greenbox.png">x<br><span>y</span></a>
</div>
</div>
@@ -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

@@ -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>
@@ -1,3 +1,38 @@
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:

2011-05-13 Oliver Hunt <oliver@apple.com>

Reviewed by Geoffrey Garen.
@@ -1675,7 +1675,7 @@
81BE209911F4AB8D00915DFA /* IDBCursorBackendInterface.h in Headers */ = {isa = PBXBuildFile; fileRef = 81BE209411F4AB8D00915DFA /* IDBCursorBackendInterface.h */; };
81BE20D211F4BC3200915DFA /* JSIDBCursor.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 81BE20A711F4B66F00915DFA /* JSIDBCursor.cpp */; };
81BE20D311F4BC3200915DFA /* JSIDBCursor.h in Headers */ = {isa = PBXBuildFile; fileRef = 81BE20A811F4B66F00915DFA /* JSIDBCursor.h */; };
81F65FF613788FAA00FF6F2D /* DragState.h in Headers */ = {isa = PBXBuildFile; fileRef = 81F65FF513788FAA00FF6F2D /* DragState.h */; };
81F65FF613788FAA00FF6F2D /* DragState.h in Headers */ = {isa = PBXBuildFile; fileRef = 81F65FF513788FAA00FF6F2D /* DragState.h */; settings = {ATTRIBUTES = (Private, ); }; };
82AB1743124B99EC00C5069D /* InspectorCSSAgent.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 82AB1741124B99EC00C5069D /* InspectorCSSAgent.cpp */; };
82AB1744124B99EC00C5069D /* InspectorCSSAgent.h in Headers */ = {isa = PBXBuildFile; fileRef = 82AB1742124B99EC00C5069D /* InspectorCSSAgent.h */; };
82AB1773125C826700C5069D /* InspectorStyleSheet.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 82AB176F125C826700C5069D /* InspectorStyleSheet.cpp */; };

0 comments on commit 68b05bd

Please sign in to comment.