Chromium Code Reviews| Index: content/browser/web_contents/web_drag_dest_mac.mm |
| diff --git a/content/browser/web_contents/web_drag_dest_mac.mm b/content/browser/web_contents/web_drag_dest_mac.mm |
| index 9655f41aca8cecc0ce7c1387a1809943db6468d7..d4eb9039b28c6c92d8d617a8f56bf6041553f793 100644 |
| --- a/content/browser/web_contents/web_drag_dest_mac.mm |
| +++ b/content/browser/web_contents/web_drag_dest_mac.mm |
| @@ -8,6 +8,8 @@ |
| #include "base/strings/sys_string_conversions.h" |
| #include "content/browser/renderer_host/render_view_host_impl.h" |
| +#include "content/browser/renderer_host/render_widget_host_impl.h" |
| +#include "content/browser/renderer_host/render_widget_host_input_event_router.h" |
| #include "content/browser/web_contents/web_contents_impl.h" |
| #include "content/public/browser/web_contents_delegate.h" |
| #include "content/public/browser/web_drag_dest_delegate.h" |
| @@ -125,14 +127,25 @@ int GetModifierFlags() { |
| // we need to send a new enter message in draggingUpdated:. |
| currentRVH_ = webContents_->GetRenderViewHost(); |
| + // Create the appropriate mouse locations for WebCore. The draggingLocation |
| + // is in window coordinates. Both need to be flipped. |
| + NSPoint windowPoint = [info draggingLocation]; |
| + NSPoint viewPoint = [self flipWindowPointToView:windowPoint view:view]; |
| + NSPoint screenPoint = [self flipWindowPointToScreen:windowPoint view:view]; |
| + gfx::Point transformedPt; |
| + currentRWHForDrag_ = |
| + webContents_->GetInputEventRouter() |
| + ->GetRenderWidgetHostAtPoint( |
| + webContents_->GetRenderViewHost()->GetWidget()->GetView(), |
| + gfx::Point(viewPoint.x, viewPoint.y), &transformedPt) |
| + ->GetWeakPtr(); |
| + |
| // Fill out a DropData from pasteboard. |
| std::unique_ptr<DropData> dropData; |
| dropData.reset(new DropData()); |
| [self populateDropData:dropData.get() |
| fromPasteboard:[info draggingPasteboard]]; |
| - // TODO(paulmeyer): This will need to target the correct specific |
| - // RenderWidgetHost to work with OOPIFs. See crbug.com/647249. |
| - currentRVH_->GetWidget()->FilterDropData(dropData.get()); |
| + currentRWHForDrag_->FilterDropData(dropData.get()); |
|
dcheng
2016/11/17 17:44:19
This filters URLs from the drag, and the filtering
|
| NSDragOperation mask = [info draggingSourceOperationMask]; |
| @@ -157,19 +170,9 @@ int GetModifierFlags() { |
| dropData_.swap(dropData); |
| - // Create the appropriate mouse locations for WebCore. The draggingLocation |
| - // is in window coordinates. Both need to be flipped. |
| - NSPoint windowPoint = [info draggingLocation]; |
| - NSPoint viewPoint = [self flipWindowPointToView:windowPoint view:view]; |
| - NSPoint screenPoint = [self flipWindowPointToScreen:windowPoint view:view]; |
| - // TODO(paulmeyer): This will need to target the correct specific |
| - // RenderWidgetHost to work with OOPIFs. See crbug.com/647249. |
| - webContents_->GetRenderViewHost()->GetWidget()->DragTargetDragEnter( |
| - *dropData_, |
| - gfx::Point(viewPoint.x, viewPoint.y), |
| - gfx::Point(screenPoint.x, screenPoint.y), |
| - static_cast<WebDragOperationsMask>(mask), |
| - GetModifierFlags()); |
| + currentRWHForDrag_->DragTargetDragEnter( |
| + *dropData_, transformedPt, gfx::Point(screenPoint.x, screenPoint.y), |
| + static_cast<WebDragOperationsMask>(mask), GetModifierFlags()); |
| // We won't know the true operation (whether the drag is allowed) until we |
| // hear back from the renderer. For now, be optimistic: |
| @@ -191,17 +194,29 @@ int GetModifierFlags() { |
| if (delegate_) |
| delegate_->OnDragLeave(); |
| - // TODO(paulmeyer): This will need to target the correct specific |
| - // RenderWidgetHost to work with OOPIFs. See crbug.com/647249. |
| - webContents_->GetRenderViewHost()->GetWidget()->DragTargetDragLeave(); |
| + if (currentRWHForDrag_) { |
| + currentRWHForDrag_->DragTargetDragLeave(); |
| + currentRWHForDrag_.reset(); |
| + } |
| dropData_.reset(); |
| } |
| - (NSDragOperation)draggingUpdated:(id<NSDraggingInfo>)info |
| view:(NSView*)view { |
| - DCHECK(currentRVH_); |
| - if (currentRVH_ != webContents_->GetRenderViewHost()) |
| + NSPoint windowPoint = [info draggingLocation]; |
| + NSPoint viewPoint = [self flipWindowPointToView:windowPoint view:view]; |
| + NSPoint screenPoint = [self flipWindowPointToScreen:windowPoint view:view]; |
| + gfx::Point transformedPt; |
| + content::RenderWidgetHostImpl* targetRWH = |
| + webContents_->GetInputEventRouter()->GetRenderWidgetHostAtPoint( |
| + webContents_->GetRenderViewHost()->GetWidget()->GetView(), |
| + gfx::Point(viewPoint.x, viewPoint.y), &transformedPt); |
|
dcheng
2016/11/17 17:44:19
This block feels like it should be a helper.
If t
|
| + |
| + if (targetRWH != currentRWHForDrag_.get()) { |
| + if (currentRWHForDrag_) |
| + currentRWHForDrag_->DragTargetDragLeave(); |
| [self draggingEntered:info view:view]; |
| + } |
| if (canceled_) |
| return NSDragOperationNone; |
| @@ -214,17 +229,10 @@ int GetModifierFlags() { |
| // Create the appropriate mouse locations for WebCore. The draggingLocation |
| // is in window coordinates. |
| - NSPoint windowPoint = [info draggingLocation]; |
| - NSPoint viewPoint = [self flipWindowPointToView:windowPoint view:view]; |
| - NSPoint screenPoint = [self flipWindowPointToScreen:windowPoint view:view]; |
| NSDragOperation mask = [info draggingSourceOperationMask]; |
| - // TODO(paulmeyer): This will need to target the correct specific |
| - // RenderWidgetHost to work with OOPIFs. See crbug.com/647249. |
| - webContents_->GetRenderViewHost()->GetWidget()->DragTargetDragOver( |
| - gfx::Point(viewPoint.x, viewPoint.y), |
| - gfx::Point(screenPoint.x, screenPoint.y), |
| - static_cast<WebDragOperationsMask>(mask), |
| - GetModifierFlags()); |
| + targetRWH->DragTargetDragOver( |
| + transformedPt, gfx::Point(screenPoint.x, screenPoint.y), |
| + static_cast<WebDragOperationsMask>(mask), GetModifierFlags()); |
| if (delegate_) |
| delegate_->OnDragOver(); |
| @@ -234,8 +242,20 @@ int GetModifierFlags() { |
| - (BOOL)performDragOperation:(id<NSDraggingInfo>)info |
| view:(NSView*)view { |
| - if (currentRVH_ != webContents_->GetRenderViewHost()) |
| + NSPoint windowPoint = [info draggingLocation]; |
| + NSPoint viewPoint = [self flipWindowPointToView:windowPoint view:view]; |
| + NSPoint screenPoint = [self flipWindowPointToScreen:windowPoint view:view]; |
| + gfx::Point transformedPt; |
| + content::RenderWidgetHostImpl* targetRWH = |
| + webContents_->GetInputEventRouter()->GetRenderWidgetHostAtPoint( |
| + webContents_->GetRenderViewHost()->GetWidget()->GetView(), |
| + gfx::Point(viewPoint.x, viewPoint.y), &transformedPt); |
|
Avi (use Gerrit)
2016/11/17 02:50:28
You do this three times; can you abstract it out?
paulmeyer
2016/11/17 16:01:52
Done.
paulmeyer
2016/11/17 17:32:11
Actually, I'd like to do this abstraction in a fol
dcheng
2016/11/17 17:44:19
We should abstract it out: as-is, this logic doesn
|
| + |
| + if (targetRWH != currentRWHForDrag_.get()) { |
| + if (currentRWHForDrag_) |
| + currentRWHForDrag_->DragTargetDragLeave(); |
| [self draggingEntered:info view:view]; |
| + } |
| // Check if we only allow navigation and navigate to a url on the pasteboard. |
| if ([self onlyAllowsNavigation]) { |
| @@ -257,16 +277,9 @@ int GetModifierFlags() { |
| currentRVH_ = NULL; |
| - // Create the appropriate mouse locations for WebCore. The draggingLocation |
| - // is in window coordinates. Both need to be flipped. |
| - NSPoint windowPoint = [info draggingLocation]; |
| - NSPoint viewPoint = [self flipWindowPointToView:windowPoint view:view]; |
| - NSPoint screenPoint = [self flipWindowPointToScreen:windowPoint view:view]; |
| - // TODO(paulmeyer): This will need to target the correct specific |
| - // RenderWidgetHost to work with OOPIFs. See crbug.com/647249. |
| - webContents_->GetRenderViewHost()->GetWidget()->DragTargetDrop( |
| - *dropData_, gfx::Point(viewPoint.x, viewPoint.y), |
| - gfx::Point(screenPoint.x, screenPoint.y), GetModifierFlags()); |
| + targetRWH->DragTargetDrop(*dropData_, transformedPt, |
| + gfx::Point(screenPoint.x, screenPoint.y), |
| + GetModifierFlags()); |
| dropData_.reset(); |