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

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

Issue 2655463015: Correctly set dragLeave and dragEnd coords for OOPIF drag and drop (Closed)
Patch Set: Added checks for null RWH on drag end 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
« no previous file with comments | « content/browser/web_contents/web_drag_dest_mac.mm ('k') | content/common/drag_messages.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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_source_mac.h" 5 #import "content/browser/web_contents/web_drag_source_mac.h"
6 6
7 #include <sys/param.h> 7 #include <sys/param.h>
8 8
9 #include <utility> 9 #include <utility>
10 10
11 #include "base/bind.h" 11 #include "base/bind.h"
12 #include "base/files/file.h" 12 #include "base/files/file.h"
13 #include "base/files/file_path.h" 13 #include "base/files/file_path.h"
14 #include "base/mac/foundation_util.h" 14 #include "base/mac/foundation_util.h"
15 #include "base/pickle.h" 15 #include "base/pickle.h"
16 #include "base/strings/string_util.h" 16 #include "base/strings/string_util.h"
17 #include "base/strings/sys_string_conversions.h" 17 #include "base/strings/sys_string_conversions.h"
18 #include "base/strings/utf_string_conversions.h" 18 #include "base/strings/utf_string_conversions.h"
19 #include "base/threading/thread.h" 19 #include "base/threading/thread.h"
20 #include "base/threading/thread_restrictions.h" 20 #include "base/threading/thread_restrictions.h"
21 #include "content/browser/browser_thread_impl.h" 21 #include "content/browser/browser_thread_impl.h"
22 #include "content/browser/download/drag_download_file.h" 22 #include "content/browser/download/drag_download_file.h"
23 #include "content/browser/download/drag_download_util.h" 23 #include "content/browser/download/drag_download_util.h"
24 #include "content/browser/renderer_host/render_view_host_impl.h" 24 #include "content/browser/renderer_host/render_view_host_impl.h"
25 #include "content/browser/renderer_host/render_widget_host_impl.h" 25 #include "content/browser/renderer_host/render_widget_host_impl.h"
26 #include "content/browser/renderer_host/render_widget_host_view_base.h"
26 #include "content/browser/web_contents/web_contents_impl.h" 27 #include "content/browser/web_contents/web_contents_impl.h"
27 #include "content/public/browser/content_browser_client.h" 28 #include "content/public/browser/content_browser_client.h"
28 #include "content/public/common/content_client.h" 29 #include "content/public/common/content_client.h"
29 #include "content/public/common/drop_data.h" 30 #include "content/public/common/drop_data.h"
30 #include "net/base/escape.h" 31 #include "net/base/escape.h"
31 #include "net/base/filename_util.h" 32 #include "net/base/filename_util.h"
32 #include "net/base/mime_util.h" 33 #include "net/base/mime_util.h"
33 #include "ui/base/clipboard/custom_data_helper.h" 34 #include "ui/base/clipboard/custom_data_helper.h"
34 #include "ui/base/cocoa/cocoa_base_utils.h" 35 #include "ui/base/cocoa/cocoa_base_utils.h"
35 #include "ui/base/dragdrop/cocoa_dnd_util.h" 36 #include "ui/base/dragdrop/cocoa_dnd_util.h"
(...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after
284 // Flip |screenPoint|. 285 // Flip |screenPoint|.
285 NSRect screenFrame = [[[contentsView_ window] screen] frame]; 286 NSRect screenFrame = [[[contentsView_ window] screen] frame];
286 screenPoint.y = screenFrame.size.height - screenPoint.y; 287 screenPoint.y = screenFrame.size.height - screenPoint.y;
287 288
288 // If AppKit returns a copy and move operation, mask off the move bit 289 // If AppKit returns a copy and move operation, mask off the move bit
289 // because WebCore does not understand what it means to do both, which 290 // because WebCore does not understand what it means to do both, which
290 // results in an assertion failure/renderer crash. 291 // results in an assertion failure/renderer crash.
291 if (operation == (NSDragOperationMove | NSDragOperationCopy)) 292 if (operation == (NSDragOperationMove | NSDragOperationCopy))
292 operation &= ~NSDragOperationMove; 293 operation &= ~NSDragOperationMove;
293 294
294 // TODO(paulmeyer): In the OOPIF case, should |localPoint| be converted to 295 // |localPoint| and |screenPoint| are in the root coordinate space, for
295 // the coordinates local to |dragStartRWH_|? 296 // non-root RenderWidgetHosts they need to be transformed.
297 gfx::Point transformedPoint = gfx::Point(localPoint.x, localPoint.y);
298 gfx::Point transformedScreenPoint = gfx::Point(screenPoint.x, screenPoint.y);
299 if (dragStartRWH_ && contents_->GetRenderWidgetHostView()) {
300 content::RenderWidgetHostViewBase* contentsViewBase =
301 static_cast<content::RenderWidgetHostViewBase*>(
302 contents_->GetRenderWidgetHostView());
303 content::RenderWidgetHostViewBase* dragStartViewBase =
304 static_cast<content::RenderWidgetHostViewBase*>(
305 dragStartRWH_->GetView());
306 contentsViewBase->TransformPointToCoordSpaceForView(
307 gfx::Point(localPoint.x, localPoint.y), dragStartViewBase,
308 &transformedPoint);
309 contentsViewBase->TransformPointToCoordSpaceForView(
310 gfx::Point(screenPoint.x, screenPoint.y), dragStartViewBase,
311 &transformedScreenPoint);
312 }
313
296 contents_->DragSourceEndedAt( 314 contents_->DragSourceEndedAt(
297 localPoint.x, localPoint.y, screenPoint.x, screenPoint.y, 315 transformedPoint.x(), transformedPoint.y(), transformedScreenPoint.x(),
298 static_cast<blink::WebDragOperation>(operation), 316 transformedScreenPoint.y(),
299 dragStartRWH_.get()); 317 static_cast<blink::WebDragOperation>(operation), dragStartRWH_.get());
300 318
301 // Make sure the pasteboard owner isn't us. 319 // Make sure the pasteboard owner isn't us.
302 [pasteboard_ declareTypes:[NSArray array] owner:nil]; 320 [pasteboard_ declareTypes:[NSArray array] owner:nil];
303 } 321 }
304 322
305 - (NSString*)dragPromisedFileTo:(NSString*)path { 323 - (NSString*)dragPromisedFileTo:(NSString*)path {
306 // Be extra paranoid; avoid crashing. 324 // Be extra paranoid; avoid crashing.
307 if (!dropData_) { 325 if (!dropData_) {
308 NOTREACHED() << "No drag-and-drop data available for promised file."; 326 NOTREACHED() << "No drag-and-drop data available for promised file.";
309 return nil; 327 return nil;
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after
468 - (NSImage*)dragImage { 486 - (NSImage*)dragImage {
469 if (dragImage_) 487 if (dragImage_)
470 return dragImage_; 488 return dragImage_;
471 489
472 // Default to returning a generic image. 490 // Default to returning a generic image.
473 return content::GetContentClient()->GetNativeImageNamed( 491 return content::GetContentClient()->GetNativeImageNamed(
474 IDR_DEFAULT_FAVICON).ToNSImage(); 492 IDR_DEFAULT_FAVICON).ToNSImage();
475 } 493 }
476 494
477 @end // @implementation WebDragSource (Private) 495 @end // @implementation WebDragSource (Private)
OLDNEW
« no previous file with comments | « content/browser/web_contents/web_drag_dest_mac.mm ('k') | content/common/drag_messages.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698