summaryrefslogtreecommitdiffstats
path: root/src/core/web_contents_adapter.cpp
diff options
context:
space:
mode:
authorJoerg Bornemann <joerg.bornemann@qt.io>2017-01-17 15:30:11 +0100
committerJoerg Bornemann <joerg.bornemann@qt.io>2017-01-18 09:08:57 +0000
commit8eab45ef460cc6614094ec287dda73febdf3e720 (patch)
treee270fea749a8278347254e5ffd87ac76d3d4876c /src/core/web_contents_adapter.cpp
parent42c6033724e2b5a54702d626c57806e53f163c62 (diff)
Fix conversion from blink::WebDragOperation to Qt::DropAction
blink::WebDragOperation is a bit field, even if it is not used in its blink::WebDragOperationsMask incarnation. In particular, WebDragOperationGeneric can be set in addition to other operations. This fixes situations where UpdateDragCursor is called with multiple bits set in its WebDragOperationArgument and the drag action will be spuriously ignored. Also directly pass the WebDragOperation we get from UpdateDragCursor to chromium's API without converting to QDropAction and then converting it back. Task-number: QTBUG-58037 Change-Id: I5c85699de534771f84db69abf7b98e779872a0f7 Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
Diffstat (limited to 'src/core/web_contents_adapter.cpp')
-rw-r--r--src/core/web_contents_adapter.cpp21
1 files changed, 16 insertions, 5 deletions
diff --git a/src/core/web_contents_adapter.cpp b/src/core/web_contents_adapter.cpp
index 91e457726..a0aaf8c1e 100644
--- a/src/core/web_contents_adapter.cpp
+++ b/src/core/web_contents_adapter.cpp
@@ -336,7 +336,7 @@ WebContentsAdapterPrivate::WebContentsAdapterPrivate()
, adapterClient(0)
, nextRequestId(CallbackDirectory::ReservedCallbackIdsEnd)
, lastFindRequestId(0)
- , currentDropAction(Qt::IgnoreAction)
+ , currentDropAction(blink::WebDragOperationNone)
, inDragUpdateLoop(false)
, updateDragCursorMessagePollingTimer(new QTimer)
{
@@ -1106,7 +1106,7 @@ void WebContentsAdapter::startDragging(QObject *dragSource, const content::DropD
d->currentDropData->file_contents.clear();
d->currentDropData->file_description_filename.clear();
- d->currentDropAction = Qt::IgnoreAction;
+ d->currentDropAction = blink::WebDragOperationNone;
QDrag *drag = new QDrag(dragSource); // will be deleted by Qt's DnD implementation
bool dValid = true;
QMetaObject::Connection onDestroyed = QObject::connect(dragSource, &QObject::destroyed, [&dValid](){
@@ -1183,6 +1183,17 @@ void WebContentsAdapter::enterDrag(QDragEnterEvent *e, const QPoint &screenPos)
flagsFromModifiers(e->keyboardModifiers()));
}
+Qt::DropAction toQt(blink::WebDragOperation op)
+{
+ if (op & blink::WebDragOperationCopy)
+ return Qt::CopyAction;
+ if (op & blink::WebDragOperationLink)
+ return Qt::LinkAction;
+ if (op & blink::WebDragOperationMove || op & blink::WebDragOperationDelete)
+ return Qt::MoveAction;
+ return Qt::IgnoreAction;
+}
+
Qt::DropAction WebContentsAdapter::updateDragPosition(QDragMoveEvent *e, const QPoint &screenPos)
{
Q_D(WebContentsAdapter);
@@ -1210,13 +1221,13 @@ Qt::DropAction WebContentsAdapter::updateDragPosition(QDragMoveEvent *e, const Q
loop.Run();
d->updateDragCursorMessagePollingTimer->stop();
- return d->currentDropAction;
+ return toQt(d->currentDropAction);
}
-void WebContentsAdapter::updateDragAction(Qt::DropAction action)
+void WebContentsAdapter::updateDragAction(int action)
{
Q_D(WebContentsAdapter);
- d->currentDropAction = action;
+ d->currentDropAction = static_cast<blink::WebDragOperation>(action);
finishDragUpdate();
}