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://cebug.com/670645). | |
|
Avi (use Gerrit)
2016/12/02 23:07:24
typo in the link
EhsanK
2016/12/02 23:09:51
Done.
| |
| 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; | |
| 206 // Create the appropriate mouse locations for WebCore. The draggingLocation | 214 // Create the appropriate mouse locations for WebCore. The draggingLocation |
| 207 // is in window coordinates. Both need to be flipped. | 215 // is in window coordinates. Both need to be flipped. |
| 208 NSPoint windowPoint = [info draggingLocation]; | 216 NSPoint windowPoint = [info draggingLocation]; |
| 209 NSPoint viewPoint = [self flipWindowPointToView:windowPoint view:view]; | 217 NSPoint viewPoint = [self flipWindowPointToView:windowPoint view:view]; |
| 210 NSPoint screenPoint = [self flipWindowPointToScreen:windowPoint view:view]; | 218 NSPoint screenPoint = [self flipWindowPointToScreen:windowPoint view:view]; |
| 211 gfx::Point transformedPt; | 219 gfx::Point transformedPt; |
| 212 content::RenderWidgetHostImpl* targetRWH = | 220 content::RenderWidgetHostImpl* targetRWH = |
| 213 [self GetRenderWidgetHostAtPoint:viewPoint transformedPt:&transformedPt]; | 221 [self GetRenderWidgetHostAtPoint:viewPoint transformedPt:&transformedPt]; |
| 214 | 222 |
| 215 // TODO(paulmeyer): The dragging delegates may now by invoked multiple times | 223 // 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. | 362 // Get custom MIME data. |
| 355 if ([types containsObject:ui::kWebCustomDataPboardType]) { | 363 if ([types containsObject:ui::kWebCustomDataPboardType]) { |
| 356 NSData* customData = [pboard dataForType:ui::kWebCustomDataPboardType]; | 364 NSData* customData = [pboard dataForType:ui::kWebCustomDataPboardType]; |
| 357 ui::ReadCustomDataIntoMap([customData bytes], | 365 ui::ReadCustomDataIntoMap([customData bytes], |
| 358 [customData length], | 366 [customData length], |
| 359 &data->custom_data); | 367 &data->custom_data); |
| 360 } | 368 } |
| 361 } | 369 } |
| 362 | 370 |
| 363 @end | 371 @end |
| OLD | NEW |