Chromium Code Reviews| 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..dae9a3d7f636c0717a7ed491d08de9bcd6c8cf90 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,11 +272,10 @@ void PromiseWriterHelper(const DropData& drop_data, |
| operation:(NSDragOperation)operation { |
| if (!contents_ || !contentsView_) |
| return; |
| - contents_->SystemDragEnded(); |
| - RenderViewHostImpl* rvh = static_cast<RenderViewHostImpl*>( |
| - contents_->GetRenderViewHost()); |
| - if (rvh) { |
| + if (dragStartRWH_) { |
|
dcheng
2016/11/17 19:59:02
Let's centralize the null checking in WebCOntents.
paulmeyer
2016/11/17 20:46:43
Done.
|
| + contents_->SystemDragEnded(dragStartRWH_.get()); |
| + |
| // Convert |screenPoint| to view coordinates and flip it. |
| NSPoint localPoint = NSZeroPoint; |
| if ([contentsView_ window]) |
| @@ -290,8 +292,12 @@ void PromiseWriterHelper(const DropData& drop_data, |
| if (operation == (NSDragOperationMove | NSDragOperationCopy)) |
| operation &= ~NSDragOperationMove; |
| - contents_->DragSourceEndedAt(localPoint.x, localPoint.y, screenPoint.x, |
| - screenPoint.y, static_cast<blink::WebDragOperation>(operation)); |
| + // 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. |