Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(446)

Unified Diff: content/browser/web_contents/web_drag_source_mac.mm

Issue 2509933002: Drag-and-drop: Target drag messages (the sequel). (Closed)
Patch Set: Addressed additional comments by avi@, dcheng@. Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: content/browser/web_contents/web_drag_source_mac.mm
diff --git a/content/browser/web_contents/web_drag_source_mac.mm b/content/browser/web_contents/web_drag_source_mac.mm
index 14321f4787920969514adcfabf8c2cead77202ee..fdd46497ad47345bd0149631a2155878443973fc 100644
--- a/content/browser/web_contents/web_drag_source_mac.mm
+++ b/content/browser/web_contents/web_drag_source_mac.mm
@@ -22,6 +22,7 @@
#include "content/browser/download/drag_download_file.h"
#include "content/browser/download/drag_download_util.h"
#include "content/browser/renderer_host/render_view_host_impl.h"
+#include "content/browser/renderer_host/render_widget_host_impl.h"
#include "content/browser/web_contents/web_contents_impl.h"
#include "content/public/browser/content_browser_client.h"
#include "content/public/common/content_client.h"
@@ -109,6 +110,7 @@ void PromiseWriterHelper(const DropData& drop_data,
- (id)initWithContents:(content::WebContentsImpl*)contents
view:(NSView*)contentsView
dropData:(const DropData*)dropData
+ sourceRWH:(content::RenderWidgetHostImpl*)sourceRWH
image:(NSImage*)image
offset:(NSPoint)offset
pasteboard:(NSPasteboard*)pboard
@@ -123,6 +125,7 @@ void PromiseWriterHelper(const DropData& drop_data,
dropData_.reset(new DropData(*dropData));
DCHECK(dropData_.get());
+ dragStartRWH_ = sourceRWH->GetWeakPtr();
dragImage_.reset([image retain]);
imageOffset_ = offset;
@@ -269,30 +272,31 @@ void PromiseWriterHelper(const DropData& drop_data,
operation:(NSDragOperation)operation {
if (!contents_ || !contentsView_)
return;
- contents_->SystemDragEnded();
-
- RenderViewHostImpl* rvh = static_cast<RenderViewHostImpl*>(
- contents_->GetRenderViewHost());
- if (rvh) {
- // Convert |screenPoint| to view coordinates and flip it.
- NSPoint localPoint = NSZeroPoint;
- if ([contentsView_ window])
- localPoint = [self convertScreenPoint:screenPoint];
- NSRect viewFrame = [contentsView_ frame];
- localPoint.y = viewFrame.size.height - localPoint.y;
- // Flip |screenPoint|.
- NSRect screenFrame = [[[contentsView_ window] screen] frame];
- screenPoint.y = screenFrame.size.height - screenPoint.y;
-
- // If AppKit returns a copy and move operation, mask off the move bit
- // because WebCore does not understand what it means to do both, which
- // results in an assertion failure/renderer crash.
- if (operation == (NSDragOperationMove | NSDragOperationCopy))
- operation &= ~NSDragOperationMove;
-
- contents_->DragSourceEndedAt(localPoint.x, localPoint.y, screenPoint.x,
- screenPoint.y, static_cast<blink::WebDragOperation>(operation));
- }
+
+ contents_->SystemDragEnded(dragStartRWH_.get());
+
+ // Convert |screenPoint| to view coordinates and flip it.
+ NSPoint localPoint = NSZeroPoint;
+ if ([contentsView_ window])
+ localPoint = [self convertScreenPoint:screenPoint];
+ NSRect viewFrame = [contentsView_ frame];
+ localPoint.y = viewFrame.size.height - localPoint.y;
+ // Flip |screenPoint|.
+ NSRect screenFrame = [[[contentsView_ window] screen] frame];
+ screenPoint.y = screenFrame.size.height - screenPoint.y;
+
+ // If AppKit returns a copy and move operation, mask off the move bit
+ // because WebCore does not understand what it means to do both, which
+ // results in an assertion failure/renderer crash.
+ if (operation == (NSDragOperationMove | NSDragOperationCopy))
+ operation &= ~NSDragOperationMove;
+
+ // TODO(paulmeyer): In the OOPIF case, should |localPoint| be converted to
+ // the coordinates local to |dragStartRWH_|?
+ contents_->DragSourceEndedAt(
+ localPoint.x, localPoint.y, screenPoint.x, screenPoint.y,
+ static_cast<blink::WebDragOperation>(operation),
+ dragStartRWH_.get());
// Make sure the pasteboard owner isn't us.
[pasteboard_ declareTypes:[NSArray array] owner:nil];
« no previous file with comments | « content/browser/web_contents/web_drag_source_mac.h ('k') | content/browser/web_contents/web_drag_source_mac_unittest.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698