diff options
author | Joerg Bornemann <joerg.bornemann@qt.io> | 2017-01-17 15:54:10 +0100 |
---|---|---|
committer | Joerg Bornemann <joerg.bornemann@qt.io> | 2017-01-26 11:04:47 +0000 |
commit | 1c80328cd83377a771f725b80967b5b44ba19cf7 (patch) | |
tree | 327e7823ca4a91a10afdfe47d68ab7b798a29a82 /src/core/web_contents_adapter.cpp | |
parent | 4501b9d88662e590e14dd932a43de9055cde012c (diff) |
Fix canceling drag and drop actions
RenderViewHost::DragSourceEndedAt must be called after dropping and after
canceling a drag. Otherwise scripts running on the web page do not get
properly notified.
Task-number: QTBUG-58037
Change-Id: Ia245131c59f03f3331158bea6cc2f53bce50f989
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.cpp | 38 |
1 files changed, 23 insertions, 15 deletions
diff --git a/src/core/web_contents_adapter.cpp b/src/core/web_contents_adapter.cpp index a0aaf8c1e..187169b2b 100644 --- a/src/core/web_contents_adapter.cpp +++ b/src/core/web_contents_adapter.cpp @@ -1090,6 +1090,18 @@ static QMimeData *mimeDataFromDropData(const content::DropData &dropData) return mimeData; } +static blink::WebDragOperationsMask toWeb(const Qt::DropActions action) +{ + int result = blink::WebDragOperationNone; + if (action & Qt::CopyAction) + result |= blink::WebDragOperationCopy; + if (action & Qt::LinkAction) + result |= blink::WebDragOperationLink; + if (action & Qt::MoveAction) + result |= blink::WebDragOperationMove; + return static_cast<blink::WebDragOperationsMask>(result); +} + void WebContentsAdapter::startDragging(QObject *dragSource, const content::DropData &dropData, Qt::DropActions allowedActions, const QPixmap &pixmap, const QPoint &offset) @@ -1129,25 +1141,17 @@ void WebContentsAdapter::startDragging(QObject *dragSource, const content::DropD if (dValid) { if (d->webContents) { content::RenderViewHost *rvh = d->webContents->GetRenderViewHost(); - if (rvh) + if (rvh) { + rvh->DragSourceEndedAt(d->lastDragClientPos.x(), d->lastDragClientPos.y(), + d->lastDragScreenPos.x(), d->lastDragScreenPos.y(), + d->currentDropAction); rvh->DragSourceSystemDragEnded(); + } } d->currentDropData.reset(); } } -static blink::WebDragOperationsMask toWeb(const Qt::DropActions action) -{ - int result = blink::WebDragOperationNone; - if (action & Qt::CopyAction) - result |= blink::WebDragOperationCopy; - if (action & Qt::LinkAction) - result |= blink::WebDragOperationLink; - if (action & Qt::MoveAction) - result |= blink::WebDragOperationMove; - return static_cast<blink::WebDragOperationsMask>(result); -} - static void fillDropDataFromMimeData(content::DropData *dropData, const QMimeData *mimeData) { Q_ASSERT(dropData->filenames.empty()); @@ -1198,7 +1202,9 @@ Qt::DropAction WebContentsAdapter::updateDragPosition(QDragMoveEvent *e, const Q { Q_D(WebContentsAdapter); content::RenderViewHost *rvh = d->webContents->GetRenderViewHost(); - rvh->DragTargetDragOver(toGfx(e->pos()), toGfx(screenPos), toWeb(e->possibleActions()), + d->lastDragClientPos = toGfx(e->pos()); + d->lastDragScreenPos = toGfx(screenPos); + rvh->DragTargetDragOver(d->lastDragClientPos, d->lastDragScreenPos, toWeb(e->possibleActions()), blink::WebInputEvent::LeftButtonDown); base::MessageLoop *currentMessageLoop = base::MessageLoop::current(); @@ -1246,7 +1252,9 @@ void WebContentsAdapter::endDragging(const QPoint &clientPos, const QPoint &scre finishDragUpdate(); content::RenderViewHost *rvh = d->webContents->GetRenderViewHost(); rvh->FilterDropData(d->currentDropData.get()); - rvh->DragTargetDrop(*d->currentDropData, toGfx(clientPos), toGfx(screenPos), 0); + d->lastDragClientPos = toGfx(clientPos); + d->lastDragScreenPos = toGfx(screenPos); + rvh->DragTargetDrop(*d->currentDropData, d->lastDragClientPos, d->lastDragScreenPos, 0); d->currentDropData.reset(); } |