Commit 057730b0 authored by bweinstein@apple.com's avatar bweinstein@apple.com

Drag and Drop source/destination code needs cleanup.

<https://bugs.webkit.org/show_bug.cgi?id=33691>.
        
Reviewed by Adam Roben.

WebCore: 

Cleaned up some Drag and Drop code that deals with getting
source and destination operations, and added some ASSERTS to make
sure we don't get in bad states.

* dom/Clipboard.cpp:
(WebCore::Clipboard::sourceOperation): Make this return the operation itself.
(WebCore::Clipboard::destinationOperation): Ditto.
(WebCore::Clipboard::setSourceOperation): Add an assert to make sure we're valud.
(WebCore::Clipboard::setDestinationOperation): Ditto.
* dom/Clipboard.h:
* page/DragController.cpp:
(WebCore::DragController::tryDHTMLDrag):
* page/EventHandler.cpp:
(WebCore::EventHandler::handleDrag):

WebKit/chromium: 

Update to new way of calling sourceOperation.

* src/DragClientImpl.cpp:
(WebKit::DragClientImpl::startDrag):

WebKit/qt: 

Update to new way of calling sourceOperation.

* WebCoreSupport/DragClientQt.cpp:
(WebCore::DragClientQt::startDrag):



git-svn-id: http://svn.webkit.org/repository/webkit/trunk@53296 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 6f122a12
2010-01-14 Brian Weinstein <bweinstein@apple.com>
Reviewed by Adam Roben.
Drag and Drop source/destination code needs cleanup.
<https://bugs.webkit.org/show_bug.cgi?id=33691>.
Cleaned up some Drag and Drop code that deals with getting
source and destination operations, and added some ASSERTS to make
sure we don't get in bad states.
* dom/Clipboard.cpp:
(WebCore::Clipboard::sourceOperation): Make this return the operation itself.
(WebCore::Clipboard::destinationOperation): Ditto.
(WebCore::Clipboard::setSourceOperation): Add an assert to make sure we're valud.
(WebCore::Clipboard::setDestinationOperation): Ditto.
* dom/Clipboard.h:
* page/DragController.cpp:
(WebCore::DragController::tryDHTMLDrag):
* page/EventHandler.cpp:
(WebCore::EventHandler::handleDrag):
2010-01-14 Timothy Hatcher <timothy@apple.com>
Make the Web Inspector's JavaScript debugger work with isolated worlds.
......@@ -100,27 +100,29 @@ static String IEOpFromDragOp(DragOperation op)
return "none";
}
bool Clipboard::sourceOperation(DragOperation& op) const
DragOperation Clipboard::sourceOperation() const
{
op = dragOpFromIEOp(m_effectAllowed);
DragOperation op = dragOpFromIEOp(m_effectAllowed);
ASSERT(op != DragOperationPrivate);
return true;
return op;
}
bool Clipboard::destinationOperation(DragOperation& op) const
DragOperation Clipboard::destinationOperation() const
{
op = dragOpFromIEOp(m_dropEffect);
ASSERT(op == DragOperationCopy || op == DragOperationNone || op == DragOperationLink || op == DragOperationMove);
return true;
DragOperation op = dragOpFromIEOp(m_dropEffect);
ASSERT_ARG(op, op == DragOperationCopy || op == DragOperationNone || op == DragOperationLink || op == DragOperationGeneric);
return op;
}
void Clipboard::setSourceOperation(DragOperation op)
{
ASSERT_ARG(op, op != DragOperationPrivate);
m_effectAllowed = IEOpFromDragOp(op);
}
void Clipboard::setDestinationOperation(DragOperation op)
{
ASSERT(op == DragOperationCopy || op == DragOperationNone || op == DragOperationLink || op == DragOperationMove);
m_dropEffect = IEOpFromDragOp(op);
}
......
......@@ -74,8 +74,8 @@ namespace WebCore {
void setAccessPolicy(ClipboardAccessPolicy);
bool sourceOperation(DragOperation&) const;
bool destinationOperation(DragOperation&) const;
DragOperation sourceOperation() const;
DragOperation destinationOperation() const;
void setSourceOperation(DragOperation);
void setDestinationOperation(DragOperation);
......
......@@ -482,21 +482,6 @@ bool DragController::canProcessDrag(DragData* dragData)
return true;
}
static DragOperation defaultOperationForDrag(DragOperation srcOpMask)
{
// This is designed to match IE's operation fallback for the case where
// the page calls preventDefault() in a drag event but doesn't set dropEffect.
if (srcOpMask & DragOperationCopy)
return DragOperationCopy;
if (srcOpMask & DragOperationMove || srcOpMask & DragOperationGeneric)
return DragOperationMove;
if (srcOpMask & DragOperationLink)
return DragOperationLink;
// FIXME: Does IE really return "generic" even if no operations were allowed by the source?
return DragOperationGeneric;
}
bool DragController::tryDHTMLDrag(DragData* dragData, DragOperation& operation)
{
ASSERT(dragData);
......@@ -517,10 +502,8 @@ bool DragController::tryDHTMLDrag(DragData* dragData, DragOperation& operation)
return false;
}
if (!clipboard->destinationOperation(operation)) {
// The element accepted but they didn't pick an operation, so we pick one (to match IE).
operation = defaultOperationForDrag(srcOpMask);
} else if (!(srcOpMask & operation)) {
operation = clipboard->destinationOperation();
if (!(srcOpMask & operation)) {
// The element picked an operation which is not supported by the source
operation = DragOperationNone;
}
......
......@@ -2333,7 +2333,7 @@ bool EventHandler::handleDrag(const MouseEventWithHitTestResults& event)
if (m_mouseDownMayStartDrag) {
// gather values from DHTML element, if it set any
dragState().m_dragClipboard->sourceOperation(srcOp);
srcOp = dragState().m_dragClipboard->sourceOperation();
// Yuck, a draggedImage:moveTo: message can be fired as a result of kicking off the
// drag with dragImage! Because of that dumb reentrancy, we may think we've not
......
2010-01-14 Brian Weinstein <bweinstein@apple.com>
Reviewed by Adam Roben.
Drag and Drop source/destination code needs cleanup.
<https://bugs.webkit.org/show_bug.cgi?id=33691>.
Update to new way of calling sourceOperation.
* src/DragClientImpl.cpp:
(WebKit::DragClientImpl::startDrag):
2010-01-14 Nate Chapin <japhet@chromium.org>
Reviewed by Dimitri Glazkov.
......
......@@ -79,9 +79,7 @@ void DragClientImpl::startDrag(DragImageRef dragImage,
WebDragData dragData = static_cast<ClipboardChromium*>(clipboard)->dataObject();
DragOperation dragOperationMask;
if (!clipboard->sourceOperation(dragOperationMask))
dragOperationMask = DragOperationEvery;
DragOperation dragOperationMask = clipboard->sourceOperation();
m_webView->startDragging(
eventPos, dragData, static_cast<WebDragOperationsMask>(dragOperationMask));
......
2010-01-14 Brian Weinstein <bweinstein@apple.com>
Reviewed by Adam Roben.
Drag and Drop source/destination code needs cleanup.
<https://bugs.webkit.org/show_bug.cgi?id=33691>.
Update to new way of calling sourceOperation.
* WebCoreSupport/DragClientQt.cpp:
(WebCore::DragClientQt::startDrag):
2010-01-14 Simon Hausmann <simon.hausmann@nokia.com>
Reviewed by Tor Arne Vestbø.
......
......@@ -96,8 +96,7 @@ void DragClientQt::startDrag(DragImageRef, const IntPoint&, const IntPoint&, Cli
QDrag *drag = new QDrag(view);
if (clipboardData && clipboardData->hasImage())
drag->setPixmap(qvariant_cast<QPixmap>(clipboardData->imageData()));
DragOperation dragOperationMask = DragOperationEvery;
clipboard->sourceOperation(dragOperationMask);
DragOperation dragOperationMask = clipboard->sourceOperation();
drag->setMimeData(clipboardData);
Qt::DropAction actualDropAction = drag->exec(dragOperationsToDropActions(dragOperationMask));
......
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