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

Side by Side Diff: content/browser/web_contents/web_drag_dest_mac.mm

Issue 2655463015: Correctly set dragLeave and dragEnd coords for OOPIF drag and drop (Closed)
Patch Set: Cleanup Created 3 years, 10 months 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 unified diff | Download patch
OLDNEW
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"
11 #include "content/browser/renderer_host/render_widget_host_impl.h" 11 #include "content/browser/renderer_host/render_widget_host_impl.h"
12 #include "content/browser/renderer_host/render_widget_host_input_event_router.h" 12 #include "content/browser/renderer_host/render_widget_host_input_event_router.h"
13 #include "content/browser/renderer_host/render_widget_host_view_base.h"
13 #include "content/browser/web_contents/web_contents_impl.h" 14 #include "content/browser/web_contents/web_contents_impl.h"
14 #include "content/public/browser/web_contents_delegate.h" 15 #include "content/public/browser/web_contents_delegate.h"
15 #include "content/public/browser/web_drag_dest_delegate.h" 16 #include "content/public/browser/web_drag_dest_delegate.h"
16 #include "content/public/common/child_process_host.h" 17 #include "content/public/common/child_process_host.h"
17 #include "content/public/common/drop_data.h" 18 #include "content/public/common/drop_data.h"
18 #include "third_party/WebKit/public/platform/WebInputEvent.h" 19 #include "third_party/WebKit/public/platform/WebInputEvent.h"
19 #import "third_party/mozilla/NSPasteboard+Utils.h" 20 #import "third_party/mozilla/NSPasteboard+Utils.h"
20 #include "ui/base/clipboard/custom_data_helper.h" 21 #include "ui/base/clipboard/custom_data_helper.h"
21 #include "ui/base/cocoa/cocoa_base_utils.h" 22 #include "ui/base/cocoa/cocoa_base_utils.h"
22 #import "ui/base/dragdrop/cocoa_dnd_util.h" 23 #import "ui/base/dragdrop/cocoa_dnd_util.h"
(...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after
208 if (canceled_) 209 if (canceled_)
209 return; 210 return;
210 211
211 if ([self onlyAllowsNavigation]) 212 if ([self onlyAllowsNavigation])
212 return; 213 return;
213 214
214 if (delegate_) 215 if (delegate_)
215 delegate_->OnDragLeave(); 216 delegate_->OnDragLeave();
216 217
217 if (currentRWHForDrag_) { 218 if (currentRWHForDrag_) {
218 currentRWHForDrag_->DragTargetDragLeave(); 219 currentRWHForDrag_->DragTargetDragLeave(gfx::Point(), gfx::Point());
219 currentRWHForDrag_.reset(); 220 currentRWHForDrag_.reset();
220 } 221 }
221 dropData_.reset(); 222 dropData_.reset();
222 } 223 }
223 224
224 - (NSDragOperation)draggingUpdated:(id<NSDraggingInfo>)info view:(NSView*)view { 225 - (NSDragOperation)draggingUpdated:(id<NSDraggingInfo>)info view:(NSView*)view {
225 if (canceled_) { 226 if (canceled_) {
226 // TODO(ekaramad,paulmeyer): We probably shouldn't be checking for 227 // TODO(ekaramad,paulmeyer): We probably shouldn't be checking for
227 // |canceled_| twice in this method. 228 // |canceled_| twice in this method.
228 return NSDragOperationNone; 229 return NSDragOperationNone;
229 } 230 }
230 231
231 // Create the appropriate mouse locations for WebCore. The draggingLocation 232 // Create the appropriate mouse locations for WebCore. The draggingLocation
232 // is in window coordinates. Both need to be flipped. 233 // is in window coordinates. Both need to be flipped.
233 NSPoint windowPoint = [info draggingLocation]; 234 NSPoint windowPoint = [info draggingLocation];
234 NSPoint viewPoint = [self flipWindowPointToView:windowPoint view:view]; 235 NSPoint viewPoint = [self flipWindowPointToView:windowPoint view:view];
235 NSPoint screenPoint = [self flipWindowPointToScreen:windowPoint view:view]; 236 NSPoint screenPoint = [self flipWindowPointToScreen:windowPoint view:view];
236 gfx::Point transformedPt; 237 gfx::Point transformedPt;
237 content::RenderWidgetHostImpl* targetRWH = 238 content::RenderWidgetHostImpl* targetRWH =
238 [self GetRenderWidgetHostAtPoint:viewPoint transformedPt:&transformedPt]; 239 [self GetRenderWidgetHostAtPoint:viewPoint transformedPt:&transformedPt];
239 240
240 if (![self isValidDragTarget:targetRWH]) 241 if (![self isValidDragTarget:targetRWH])
241 return NSDragOperationNone; 242 return NSDragOperationNone;
242 243
243 // TODO(paulmeyer): The dragging delegates may now by invoked multiple times 244 // TODO(paulmeyer): The dragging delegates may now by invoked multiple times
244 // per drag, even without the drag ever leaving the window. 245 // per drag, even without the drag ever leaving the window.
245 if (targetRWH != currentRWHForDrag_.get()) { 246 if (targetRWH != currentRWHForDrag_.get()) {
246 if (currentRWHForDrag_) 247 if (currentRWHForDrag_) {
247 currentRWHForDrag_->DragTargetDragLeave(); 248 gfx::Point transformedLeavePoint = gfx::Point(viewPoint.x, viewPoint.y);
249 gfx::Point transformedScreenPoint =
250 gfx::Point(screenPoint.x, screenPoint.y);
251 static_cast<content::RenderWidgetHostViewBase*>(
252 webContents_->GetRenderWidgetHostView())
253 ->TransformPointToCoordSpaceForView(
254 transformedLeavePoint,
255 static_cast<content::RenderWidgetHostViewBase*>(
256 currentRWHForDrag_->GetView()),
257 &transformedLeavePoint);
258 static_cast<content::RenderWidgetHostViewBase*>(
259 webContents_->GetRenderWidgetHostView())
260 ->TransformPointToCoordSpaceForView(
261 transformedScreenPoint,
262 static_cast<content::RenderWidgetHostViewBase*>(
263 currentRWHForDrag_->GetView()),
264 &transformedScreenPoint);
265 currentRWHForDrag_->DragTargetDragLeave(transformedLeavePoint,
266 transformedScreenPoint);
267 }
248 [self draggingEntered:info view:view]; 268 [self draggingEntered:info view:view];
249 } 269 }
250 270
251 if (canceled_) 271 if (canceled_)
252 return NSDragOperationNone; 272 return NSDragOperationNone;
253 273
254 if ([self onlyAllowsNavigation]) { 274 if ([self onlyAllowsNavigation]) {
255 if ([[info draggingPasteboard] containsURLDataConvertingTextToURL:YES]) 275 if ([[info draggingPasteboard] containsURLDataConvertingTextToURL:YES])
256 return NSDragOperationCopy; 276 return NSDragOperationCopy;
257 return NSDragOperationNone; 277 return NSDragOperationNone;
(...skipping 19 matching lines...) Expand all
277 NSPoint screenPoint = [self flipWindowPointToScreen:windowPoint view:view]; 297 NSPoint screenPoint = [self flipWindowPointToScreen:windowPoint view:view];
278 gfx::Point transformedPt; 298 gfx::Point transformedPt;
279 content::RenderWidgetHostImpl* targetRWH = 299 content::RenderWidgetHostImpl* targetRWH =
280 [self GetRenderWidgetHostAtPoint:viewPoint transformedPt:&transformedPt]; 300 [self GetRenderWidgetHostAtPoint:viewPoint transformedPt:&transformedPt];
281 301
282 if (![self isValidDragTarget:targetRWH]) 302 if (![self isValidDragTarget:targetRWH])
283 return NO; 303 return NO;
284 304
285 if (targetRWH != currentRWHForDrag_.get()) { 305 if (targetRWH != currentRWHForDrag_.get()) {
286 if (currentRWHForDrag_) 306 if (currentRWHForDrag_)
287 currentRWHForDrag_->DragTargetDragLeave(); 307 currentRWHForDrag_->DragTargetDragLeave(
308 transformedPt, gfx::Point(screenPoint.x, screenPoint.y));
288 [self draggingEntered:info view:view]; 309 [self draggingEntered:info view:view];
289 } 310 }
290 311
291 // Check if we only allow navigation and navigate to a url on the pasteboard. 312 // Check if we only allow navigation and navigate to a url on the pasteboard.
292 if ([self onlyAllowsNavigation]) { 313 if ([self onlyAllowsNavigation]) {
293 NSPasteboard* pboard = [info draggingPasteboard]; 314 NSPasteboard* pboard = [info draggingPasteboard];
294 if ([pboard containsURLDataConvertingTextToURL:YES]) { 315 if ([pboard containsURLDataConvertingTextToURL:YES]) {
295 GURL url; 316 GURL url;
296 ui::PopulateURLAndTitleFromPasteboard(&url, NULL, pboard, YES); 317 ui::PopulateURLAndTitleFromPasteboard(&url, NULL, pboard, YES);
297 webContents_->OpenURL( 318 webContents_->OpenURL(
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
396 // Get custom MIME data. 417 // Get custom MIME data.
397 if ([types containsObject:ui::kWebCustomDataPboardType]) { 418 if ([types containsObject:ui::kWebCustomDataPboardType]) {
398 NSData* customData = [pboard dataForType:ui::kWebCustomDataPboardType]; 419 NSData* customData = [pboard dataForType:ui::kWebCustomDataPboardType];
399 ui::ReadCustomDataIntoMap([customData bytes], 420 ui::ReadCustomDataIntoMap([customData bytes],
400 [customData length], 421 [customData length],
401 &data->custom_data); 422 &data->custom_data);
402 } 423 }
403 } 424 }
404 425
405 @end 426 @end
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698