Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #import "content/browser/web_contents/web_drag_dest_mac.h" | 5 #import "content/browser/web_contents/web_drag_dest_mac.h" |
| 6 | 6 |
| 7 #import <Carbon/Carbon.h> | 7 #import <Carbon/Carbon.h> |
| 8 | 8 |
| 9 #include "base/strings/sys_string_conversions.h" | 9 #include "base/strings/sys_string_conversions.h" |
| 10 #include "content/browser/renderer_host/render_view_host_impl.h" | 10 #include "content/browser/renderer_host/render_view_host_impl.h" |
| (...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 127 // Save off the RVH so we can tell if it changes during a drag. If it does, | 127 // Save off the RVH so we can tell if it changes during a drag. If it does, |
| 128 // we need to send a new enter message in draggingUpdated:. | 128 // we need to send a new enter message in draggingUpdated:. |
| 129 currentRVH_ = webContents_->GetRenderViewHost(); | 129 currentRVH_ = webContents_->GetRenderViewHost(); |
| 130 | 130 |
| 131 // Create the appropriate mouse locations for WebCore. The draggingLocation | 131 // Create the appropriate mouse locations for WebCore. The draggingLocation |
| 132 // is in window coordinates. Both need to be flipped. | 132 // is in window coordinates. Both need to be flipped. |
| 133 NSPoint windowPoint = [info draggingLocation]; | 133 NSPoint windowPoint = [info draggingLocation]; |
| 134 NSPoint viewPoint = [self flipWindowPointToView:windowPoint view:view]; | 134 NSPoint viewPoint = [self flipWindowPointToView:windowPoint view:view]; |
| 135 NSPoint screenPoint = [self flipWindowPointToScreen:windowPoint view:view]; | 135 NSPoint screenPoint = [self flipWindowPointToScreen:windowPoint view:view]; |
| 136 gfx::Point transformedPt; | 136 gfx::Point transformedPt; |
| 137 if (!webContents_->GetRenderWidgetHostView()) { | |
| 138 // This could happen when the renderer process for the top-level RWH crashes | |
| 139 // (see https://crbug.com/670645). | |
| 140 canceled_ = true; | |
| 141 return NSDragOperationNone; | |
| 142 } | |
| 137 currentRWHForDrag_ = | 143 currentRWHForDrag_ = |
| 138 [self GetRenderWidgetHostAtPoint:viewPoint transformedPt:&transformedPt] | 144 [self GetRenderWidgetHostAtPoint:viewPoint transformedPt:&transformedPt] |
| 139 ->GetWeakPtr(); | 145 ->GetWeakPtr(); |
| 140 | 146 |
| 141 // Fill out a DropData from pasteboard. | 147 // Fill out a DropData from pasteboard. |
| 142 std::unique_ptr<DropData> dropData; | 148 std::unique_ptr<DropData> dropData; |
| 143 dropData.reset(new DropData()); | 149 dropData.reset(new DropData()); |
| 144 [self populateDropData:dropData.get() | 150 [self populateDropData:dropData.get() |
| 145 fromPasteboard:[info draggingPasteboard]]; | 151 fromPasteboard:[info draggingPasteboard]]; |
| 146 // TODO(paulmeyer): Data may be pulled from the pasteboard multiple times per | 152 // TODO(paulmeyer): Data may be pulled from the pasteboard multiple times per |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 196 | 202 |
| 197 if (currentRWHForDrag_) { | 203 if (currentRWHForDrag_) { |
| 198 currentRWHForDrag_->DragTargetDragLeave(); | 204 currentRWHForDrag_->DragTargetDragLeave(); |
| 199 currentRWHForDrag_.reset(); | 205 currentRWHForDrag_.reset(); |
| 200 } | 206 } |
| 201 dropData_.reset(); | 207 dropData_.reset(); |
| 202 } | 208 } |
| 203 | 209 |
| 204 - (NSDragOperation)draggingUpdated:(id<NSDraggingInfo>)info | 210 - (NSDragOperation)draggingUpdated:(id<NSDraggingInfo>)info |
| 205 view:(NSView*)view { | 211 view:(NSView*)view { |
| 212 if (canceled_) | |
| 213 return NSDragOperationNone; | |
|
dcheng
2016/12/03 00:33:07
Seems unusual that this condition is checked twice
EhsanK
2016/12/03 00:36:44
I think draggingEntered could also mutate |cancele
dcheng
2016/12/03 00:49:14
Right, I understand, that was there even before we
EhsanK
2016/12/03 00:59:37
I see your point. I could instead not change cance
dcheng
2016/12/03 01:02:32
Meh, I can't really think of anything better atm.
EhsanK
2016/12/03 01:13:50
I added TODOs (on behalf of paulmeyer@ as well hop
| |
| 214 | |
| 206 // Create the appropriate mouse locations for WebCore. The draggingLocation | 215 // Create the appropriate mouse locations for WebCore. The draggingLocation |
| 207 // is in window coordinates. Both need to be flipped. | 216 // is in window coordinates. Both need to be flipped. |
| 208 NSPoint windowPoint = [info draggingLocation]; | 217 NSPoint windowPoint = [info draggingLocation]; |
| 209 NSPoint viewPoint = [self flipWindowPointToView:windowPoint view:view]; | 218 NSPoint viewPoint = [self flipWindowPointToView:windowPoint view:view]; |
| 210 NSPoint screenPoint = [self flipWindowPointToScreen:windowPoint view:view]; | 219 NSPoint screenPoint = [self flipWindowPointToScreen:windowPoint view:view]; |
| 211 gfx::Point transformedPt; | 220 gfx::Point transformedPt; |
| 212 content::RenderWidgetHostImpl* targetRWH = | 221 content::RenderWidgetHostImpl* targetRWH = |
| 213 [self GetRenderWidgetHostAtPoint:viewPoint transformedPt:&transformedPt]; | 222 [self GetRenderWidgetHostAtPoint:viewPoint transformedPt:&transformedPt]; |
| 214 | 223 |
| 215 // TODO(paulmeyer): The dragging delegates may now by invoked multiple times | 224 // TODO(paulmeyer): The dragging delegates may now by invoked multiple times |
| (...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 354 // Get custom MIME data. | 363 // Get custom MIME data. |
| 355 if ([types containsObject:ui::kWebCustomDataPboardType]) { | 364 if ([types containsObject:ui::kWebCustomDataPboardType]) { |
| 356 NSData* customData = [pboard dataForType:ui::kWebCustomDataPboardType]; | 365 NSData* customData = [pboard dataForType:ui::kWebCustomDataPboardType]; |
| 357 ui::ReadCustomDataIntoMap([customData bytes], | 366 ui::ReadCustomDataIntoMap([customData bytes], |
| 358 [customData length], | 367 [customData length], |
| 359 &data->custom_data); | 368 &data->custom_data); |
| 360 } | 369 } |
| 361 } | 370 } |
| 362 | 371 |
| 363 @end | 372 @end |
| OLD | NEW |