Commit 58165d43 authored by eric@webkit.org's avatar eric@webkit.org

2009-09-11 Eric Seidel <eric@webkit.org>

        No review, rolling out r48229.
        http://trac.webkit.org/changeset/48229

        * fast/events/drag-dropeffect-expected.txt: Removed.
        * fast/events/drag-dropeffect.html: Removed.
2009-09-11  Eric Seidel  <eric@webkit.org>

        No review, rolling out r48229.
        http://trac.webkit.org/changeset/48229

        * WebCore.base.exp:
        * dom/Clipboard.cpp:
        (WebCore::Clipboard::Clipboard):
        (WebCore::Clipboard::sourceOperation):
        * page/DragController.cpp:
        (WebCore::DragController::DragController):
        (WebCore::DragController::dragExited):
        (WebCore::DragController::performDrag):
        (WebCore::DragController::dragEnteredOrUpdated):
        (WebCore::DragController::tryDHTMLDrag):
        (WebCore::DragController::startDrag):
        * page/DragController.h:
        * page/EventHandler.cpp:
        (WebCore::EventHandler::updateDragAndDrop):
        (WebCore::EventHandler::dragSourceMovedTo):
        (WebCore::EventHandler::handleDrag):
        * page/EventHandler.h:
2009-09-11  Eric Seidel  <eric@webkit.org>

        No review, rolling out r48229.
        http://trac.webkit.org/changeset/48229

        * WebView/WebFrame.mm:
        (-[WebFrame _dragSourceMovedTo:]):

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@48321 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent aa727e4b
2009-09-11 Eric Seidel <eric@webkit.org>
No review, rolling out r48229.
http://trac.webkit.org/changeset/48229
* fast/events/drag-dropeffect-expected.txt: Removed.
* fast/events/drag-dropeffect.html: Removed.
2009-09-11 Michelangelo De Simone <micdesim@gmail.com>
Reviewed by Antti Koivisto.
......
This automated layout test checks that effectAllowed and dropEffect are set properly in drag callbacks.
If you're running this in a browser, you can simulate part of it by dragging Abe onto the box.
*** Testing a successful drag...
PASS effectAllowed in dragStart = 'uninitialized'
PASS dropEffect in dragStart = 'none'
PASS effectAllowed in dragEnter = 'copyMove'
PASS dropEffect in dragEnter = 'copy'
PASS effectAllowed in drop = 'copyMove'
PASS dropEffect in drop = 'move'
PASS effectAllowed in dragEnd = 'copyMove'
PASS dropEffect in dragEnd = 'move'
PASS calls to dragStart = '1'
PASS calls to dragEnd = '1'
PASS calls to dragEnter = '1'
PASS calls to drop = '1'
*** Testing a failed drag...
PASS effectAllowed in dragStart = 'uninitialized'
PASS dropEffect in dragStart = 'none'
PASS effectAllowed in dragEnter = 'link'
PASS dropEffect in dragEnter = 'link'
PASS effectAllowed in dragLeave = 'link'
PASS dropEffect in dragLeave = 'none'
PASS effectAllowed in dragEnd = 'link'
PASS dropEffect in dragEnd = 'none'
PASS calls to dragStart = '1'
PASS calls to dragEnd = '1'
PASS calls to dragEnter = '1'
PASS calls to drop = '0'
PASS successfullyParsed is true
TEST COMPLETE
<html>
<head>
<script src="../js/resources/js-test-pre.js"></script>
</head>
<body onload="runTest()">
<image id="dragSource" src="resources/abe.png" width="76" height="103"
ondragstart="dragStart(event)" ondrag="drag(event)" ondragend="dragEnd(event)">
<div id="dragTarget" style="width: 100px; height: 100px; border: 1px solid gray;"
ondragenter="dragEnter(event)" ondragover="dragOver(event)"
ondragleave="dragLeave(event)" ondrop="drop(event)">
</div>
<p>This automated layout test checks that effectAllowed and dropEffect are set properly in drag
callbacks.<br>
If you're running this in a browser, you can simulate part of it by dragging Abe onto the box.</p>
<div id="console"></div>
<script>
function assert(result, what)
{
if (!result)
testFailed("Expected that " + what);
else
testPassed(what);
}
function assertEqual(test, expected, what, quiet)
{
if (test !== expected)
testFailed(what + " = '" + test + "' ... expected '" + expected + "'");
else if (!quiet)
testPassed(what + " = '" + test + "'");
}
var dragStartCalled = 0, dragCalled = 0, dragEndCalled = 0;
var dragEnterCalled = 0, dragOverCalled = 0, dragLeaveCalled = 0, dropCalled = 0;
var effectAllowedToSet = "copyMove";
var defaultDropEffect = "copy";
var dropEffectToSet = "move";
var expectedDropEffect = "move";
// DRAG SOURCE EVENT HANDLERS:
function dragStart(event)
{
dragStartCalled++;
assertEqual(event.dataTransfer.effectAllowed, "uninitialized", "effectAllowed in dragStart");
assertEqual(event.dataTransfer.dropEffect, "none", "dropEffect in dragStart");
event.dataTransfer.effectAllowed = effectAllowedToSet;
}
function drag(event)
{
dragCalled++;
assertEqual(event.dataTransfer.effectAllowed, effectAllowedToSet, "effectAllowed in drag", true);
assertEqual(event.dataTransfer.dropEffect,
dragLeaveCalled < dragEnterCalled ?expectedDropEffect :"none",
"dropEffect in drag",
true);
}
function dragEnd(event)
{
dragEndCalled++;
assertEqual(event.dataTransfer.effectAllowed, effectAllowedToSet, "effectAllowed in dragEnd");
assertEqual(event.dataTransfer.dropEffect,
dragLeaveCalled < dragEnterCalled ? expectedDropEffect : "none",
"dropEffect in dragEnd");
}
// DRAG DESTINATION EVENT HANDLERS:
function dragEnter(event)
{
dragEnterCalled++;
assertEqual(event.dataTransfer.effectAllowed, effectAllowedToSet, "effectAllowed in dragEnter");
assertEqual(event.dataTransfer.dropEffect, defaultDropEffect, "dropEffect in dragEnter");
event.dataTransfer.dropEffect = dropEffectToSet;
event.preventDefault();
}
function dragOver(event)
{
dragOverCalled++;
assertEqual(event.dataTransfer.effectAllowed, effectAllowedToSet, "effectAllowed in dragOver", true);
assertEqual(event.dataTransfer.dropEffect, defaultDropEffect, "dropEffect in dragOver", true);
event.dataTransfer.dropEffect = dropEffectToSet;
event.preventDefault();
}
function dragLeave(event)
{
dragLeaveCalled++;
assertEqual(event.dataTransfer.effectAllowed, effectAllowedToSet, "effectAllowed in dragLeave");
assertEqual(event.dataTransfer.dropEffect, "none", "dropEffect in dragLeave");
event.preventDefault();
}
function drop(event)
{
dropCalled++;
assertEqual(event.dataTransfer.effectAllowed, effectAllowedToSet, "effectAllowed in drop");
assertEqual(event.dataTransfer.dropEffect, expectedDropEffect, "dropEffect in drop");
event.preventDefault();
}
function performDrag(srcId, dstId)
{
function moveMouseToCenterOf(id)
{
var element = document.getElementById(id);
var x = element.offsetLeft + element.offsetWidth / 2;
var y = element.offsetTop + element.offsetHeight / 2;
eventSender.mouseMoveTo(x, y);
}
dragStartCalled = dragCalled = dragEndCalled = 0;
dragEnterCalled = dragOverCalled = dragLeaveCalled = dropCalled = 0;
moveMouseToCenterOf(srcId);
eventSender.mouseDown();
moveMouseToCenterOf(dstId);
eventSender.mouseUp();
}
function runTest()
{
if (!window.layoutTestController)
return;
try {
debug("*** Testing a successful drag...");
effectAllowedToSet = "copyMove";
defaultDropEffect = "copy";
dropEffectToSet = "move";
expectedDropEffect = "move";
performDrag('dragSource', 'dragTarget');
assertEqual(dragStartCalled, 1, "calls to dragStart");
// Whether drag is called depends on timing. In a real-life drag it will be called, but
// with the artificial mouse events generated by the test controller, it may not be.
// So I've removed the assertion that dragCalled > 0.
assertEqual(dragEndCalled, 1, "calls to dragEnd");
assertEqual(dragEnterCalled, 1, "calls to dragEnter");
// dragOver won't necessarily be called if there was only one mouse event over
// the drop target, as in performDrag.
// dragLeave isn't called because the drag never exits the drop target.
assertEqual(dropCalled, 1, "calls to drop");
debug("*** Testing a failed drag...");
effectAllowedToSet = "link";
defaultDropEffect = "link";
dropEffectToSet = "move";
expectedDropEffect = "none";
performDrag('dragSource', 'dragTarget');
assertEqual(dragStartCalled, 1, "calls to dragStart");
// As described above, drag might not be called, under test conditions, so don't check dragCalled.
assertEqual(dragEndCalled, 1, "calls to dragEnd");
assertEqual(dragEnterCalled, 1, "calls to dragEnter");
assertEqual(dropCalled, 0, "calls to drop");
// Finally run the post-test function:
isSuccessfullyParsed();
} catch (x) {
debug("FAILED by throwing " + x);
}
// OK, now DRT can quit.
layoutTestController.notifyDone();
}
// Tell DRT not to quit immediately, because the actual runTest() function won't be called
// until the onload event is sent (otherwise the fake drag stuff crashes: bug 29101.)
layoutTestController.waitUntilDone();
var successfullyParsed = true;
</script>
<script src="../js/resources/js-test-post-function.js"></script>
</body>
</html>
2009-09-11 Eric Seidel <eric@webkit.org>
No review, rolling out r48229.
http://trac.webkit.org/changeset/48229
* WebCore.base.exp:
* dom/Clipboard.cpp:
(WebCore::Clipboard::Clipboard):
(WebCore::Clipboard::sourceOperation):
* page/DragController.cpp:
(WebCore::DragController::DragController):
(WebCore::DragController::dragExited):
(WebCore::DragController::performDrag):
(WebCore::DragController::dragEnteredOrUpdated):
(WebCore::DragController::tryDHTMLDrag):
(WebCore::DragController::startDrag):
* page/DragController.h:
* page/EventHandler.cpp:
(WebCore::EventHandler::updateDragAndDrop):
(WebCore::EventHandler::dragSourceMovedTo):
(WebCore::EventHandler::handleDrag):
* page/EventHandler.h:
2009-09-11 Michelangelo De Simone <micdesim@gmail.com>
Fix the build.
......@@ -224,7 +224,7 @@ __ZN7WebCore12EventHandler14currentNSEventEv
__ZN7WebCore12EventHandler14scrollOverflowENS_15ScrollDirectionENS_17ScrollGranularityE
__ZN7WebCore12EventHandler15sendScrollEventEv
__ZN7WebCore12EventHandler17dragSourceEndedAtERKNS_18PlatformMouseEventENS_13DragOperationE
__ZN7WebCore12EventHandler17dragSourceMovedToERKNS_18PlatformMouseEventENS_13DragOperationE
__ZN7WebCore12EventHandler17dragSourceMovedToERKNS_18PlatformMouseEventE
__ZN7WebCore12EventHandler17eventMayStartDragEP7NSEvent
__ZN7WebCore12EventHandler20handleTextInputEventERKNS_6StringEPNS_5EventEbb
__ZN7WebCore12EventHandler20hitTestResultAtPointERKNS_8IntPointEbbNS_17HitTestScrollbarsE
......
......@@ -40,10 +40,6 @@ Clipboard::Clipboard(ClipboardAccessPolicy policy, bool isForDragging)
, m_forDragging(isForDragging)
, m_dragImage(0)
{
if (isForDragging) {
// per HTML5 spec, sec. 7.9.2
m_effectAllowed = "uninitialized";
}
}
void Clipboard::setAccessPolicy(ClipboardAccessPolicy policy)
......@@ -102,7 +98,7 @@ static String IEOpFromDragOp(DragOperation op)
bool Clipboard::sourceOperation(DragOperation& op) const
{
if (m_effectAllowed.isNull() || m_effectAllowed == "uninitialized")
if (m_effectAllowed.isNull())
return false;
op = dragOpFromIEOp(m_effectAllowed);
return true;
......
......@@ -83,7 +83,6 @@ DragController::DragController(Page* page, DragClient* client)
, m_didInitiateDrag(false)
, m_isHandlingDrag(false)
, m_sourceDragOperation(DragOperationNone)
, m_destinationDragOperation(DragOperationNone)
{
}
......@@ -159,7 +158,6 @@ void DragController::dragExited(DragData* dragData)
ClipboardAccessPolicy policy = (!m_documentUnderMouse || m_documentUnderMouse->securityOrigin()->isLocal()) ? ClipboardReadable : ClipboardTypesReadable;
RefPtr<Clipboard> clipboard = dragData->createClipboard(policy);
clipboard->setSourceOperation(dragData->draggingSourceOperationMask());
clipboard->setDestinationOperation(DragOperationNone); // HTML5 spec, sec. 7.9.3
mainFrame->eventHandler()->cancelDragAndDrop(createMouseEvent(dragData), clipboard.get());
clipboard->setAccessPolicy(ClipboardNumb); // invalidate clipboard here for security
}
......@@ -183,7 +181,6 @@ bool DragController::performDrag(DragData* dragData)
// Sending an event can result in the destruction of the view and part.
RefPtr<Clipboard> clipboard = dragData->createClipboard(ClipboardReadable);
clipboard->setSourceOperation(dragData->draggingSourceOperationMask());
clipboard->setDestinationOperation(m_destinationDragOperation); // HTML5 spec, sec. 7.9.3
mainFrame->eventHandler()->performDragAndDrop(createMouseEvent(dragData), clipboard.get());
clipboard->setAccessPolicy(ClipboardNumb); // invalidate clipboard here for security
}
......@@ -232,12 +229,7 @@ DragOperation DragController::dragEnteredOrUpdated(DragData* dragData)
DragOperation operation = DragOperationNone;
bool handledByDocument = tryDocumentDrag(dragData, m_dragDestinationAction, operation);
if (!handledByDocument && (m_dragDestinationAction & DragDestinationActionLoad))
operation = operationForLoad(dragData);
// Restrict the operation to what the drag source allows:
if ((operation & dragData->draggingSourceOperationMask()) != operation)
operation = DragOperationNone;
m_destinationDragOperation = operation;
return operationForLoad(dragData);
return operation;
}
......@@ -499,8 +491,6 @@ bool DragController::tryDHTMLDrag(DragData* dragData, DragOperation& operation)
RefPtr<Clipboard> clipboard = dragData->createClipboard(policy);
DragOperation srcOpMask = dragData->draggingSourceOperationMask();
clipboard->setSourceOperation(srcOpMask);
m_destinationDragOperation = defaultOperationForDrag(srcOpMask); // HTML5 spec, sec. 7.9.3
clipboard->setDestinationOperation(m_destinationDragOperation);
PlatformMouseEvent event = createMouseEvent(dragData);
if (!mainFrame->eventHandler()->updateDragAndDrop(event, clipboard.get())) {
......@@ -633,7 +623,6 @@ bool DragController::startDrag(Frame* src, Clipboard* clipboard, DragOperation s
m_draggingImageURL = KURL();
m_sourceDragOperation = srcOp;
m_destinationDragOperation = DragOperationNone;
DragImageRef dragImage = 0;
IntPoint dragLoc(0, 0);
......
......@@ -65,7 +65,6 @@ namespace WebCore {
void setIsHandlingDrag(bool handling) { m_isHandlingDrag = handling; }
bool isHandlingDrag() const { return m_isHandlingDrag; }
DragOperation sourceDragOperation() const { return m_sourceDragOperation; }
DragOperation destinationDragOperation() const { return m_destinationDragOperation; }
void setDraggingImageURL(const KURL& url) { m_draggingImageURL = url; }
const KURL& draggingImageURL() const { return m_draggingImageURL; }
void setDragInitiator(Document* initiator) { m_dragInitiator = initiator; m_didInitiateDrag = true; }
......@@ -123,7 +122,6 @@ namespace WebCore {
bool m_didInitiateDrag;
bool m_isHandlingDrag;
DragOperation m_sourceDragOperation; // Set in startDrag when a drag starts from a mouse down within WebKit
DragOperation m_destinationDragOperation; // Last operation set by event handler
IntPoint m_dragOffset;
KURL m_draggingImageURL;
};
......
......@@ -1506,14 +1506,8 @@ bool EventHandler::updateDragAndDrop(const PlatformMouseEvent& event, Clipboard*
? static_cast<HTMLFrameElementBase*>(m_dragTarget.get())->contentFrame() : 0;
if (frame)
accept = frame->eventHandler()->updateDragAndDrop(event, clipboard);
else {
// Temporarily set dropEffect to 'none' while calling dropleave handler (as per HTML5 spec)
DragOperation saveOp = DragOperationNone;
clipboard->destinationOperation(saveOp);
clipboard->setDestinationOperation(DragOperationNone);
else
dispatchDragEvent(eventNames().dragleaveEvent, m_dragTarget.get(), event, clipboard);
clipboard->setDestinationOperation(saveOp);
}
}
} else {
if (newTarget) {
......@@ -2137,13 +2131,11 @@ bool EventHandler::shouldDragAutoNode(Node* node, const IntPoint& point) const
return page && page->dragController()->mayStartDragAtEventLocation(m_frame, point);
}
void EventHandler::dragSourceMovedTo(const PlatformMouseEvent& event, DragOperation operation)
void EventHandler::dragSourceMovedTo(const PlatformMouseEvent& event)
{
if (dragState().m_dragSrc && dragState().m_dragSrcMayBeDHTML) {
dragState().m_dragClipboard->setDestinationOperation(operation);
if (dragState().m_dragSrc && dragState().m_dragSrcMayBeDHTML)
// for now we don't care if event handler cancels default behavior, since there is none
dispatchDragSrcEvent(eventNames().dragEvent, event);
}
}
void EventHandler::dragSourceEndedAt(const PlatformMouseEvent& event, DragOperation operation)
......@@ -2237,7 +2229,7 @@ bool EventHandler::handleDrag(const MouseEventWithHitTestResults& event)
// Once we're past the hysteresis point, we don't want to treat this gesture as a click
invalidateClick();
DragOperation srcOp = DragOperationEvery;
DragOperation srcOp = DragOperationNone;
freeClipboard(); // would only happen if we missed a dragEnd. Do it anyway, just
// to make sure it gets numbified
......@@ -2260,7 +2252,6 @@ bool EventHandler::handleDrag(const MouseEventWithHitTestResults& event)
}
}
dragState().m_dragClipboard->setDestinationOperation(DragOperationNone); // HTML5 spec
m_mouseDownMayStartDrag = dispatchDragSrcEvent(eventNames().dragstartEvent, m_mouseDown)
&& !m_frame->selection()->isInPasswordField();
......
......@@ -146,7 +146,7 @@ public:
bool eventMayStartDrag(const PlatformMouseEvent&) const;
void dragSourceMovedTo(const PlatformMouseEvent&, DragOperation = DragOperationNone);
void dragSourceMovedTo(const PlatformMouseEvent&);
void dragSourceEndedAt(const PlatformMouseEvent&, DragOperation);
void focusDocumentView();
......
2009-09-11 Eric Seidel <eric@webkit.org>
No review, rolling out r48229.
http://trac.webkit.org/changeset/48229
* WebView/WebFrame.mm:
(-[WebFrame _dragSourceMovedTo:]):
2009-09-10 Mark Rowe <mrowe@apple.com>
Rubber-stamped by Sam Weinig.
......
......@@ -59,7 +59,6 @@
#import <WebCore/DOMImplementation.h>
#import <WebCore/DocLoader.h>
#import <WebCore/DocumentFragment.h>
#import <WebCore/DragController.h>
#import <WebCore/EventHandler.h>
#import <WebCore/EventNames.h>
#import <WebCore/Frame.h>
......@@ -933,13 +932,7 @@ static inline WebDataSource *dataSource(DocumentLoader* loader)
// FIXME: These are fake modifier keys here, but they should be real ones instead.
PlatformMouseEvent event(IntPoint(windowLoc), globalPoint(windowLoc, [view->platformWidget() window]),
LeftButton, MouseEventMoved, 0, false, false, false, false, currentTime());
// Get the current destination drag operation, if this is an intra-page drag:
DragOperation operation = DragOperationNone;
if (Page* page = _private->coreFrame->page())
operation = page->dragController()->destinationDragOperation();
_private->coreFrame->eventHandler()->dragSourceMovedTo(event, operation);
_private->coreFrame->eventHandler()->dragSourceMovedTo(event);
}
- (void)_dragSourceEndedAt:(NSPoint)windowLoc operation:(NSDragOperation)operation
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment