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

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: 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_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 static_cast<content::RenderWidgetHostViewBase*>(
300 contents_->GetRenderWidgetHostView())
301 ->TransformPointToCoordSpaceForView(
302 gfx::Point(localPoint.x, localPoint.y),
303 static_cast<content::RenderWidgetHostViewBase*>(
304 dragStartRWH_->GetView()),
305 &transformedPoint);
306 static_cast<content::RenderWidgetHostViewBase*>(
307 contents_->GetRenderWidgetHostView())
308 ->TransformPointToCoordSpaceForView(
309 gfx::Point(screenPoint.x, screenPoint.y),
310 static_cast<content::RenderWidgetHostViewBase*>(
311 dragStartRWH_->GetView()),
312 &transformedScreenPoint);
dcheng 2017/02/01 20:45:31 Is it possible to have more of these utility funct
kenrb 2017/02/02 21:21:03 I have made changes to make the point transformati
296 contents_->DragSourceEndedAt( 313 contents_->DragSourceEndedAt(
297 localPoint.x, localPoint.y, screenPoint.x, screenPoint.y, 314 transformedPoint.x(), transformedPoint.y(), transformedScreenPoint.x(),
298 static_cast<blink::WebDragOperation>(operation), 315 transformedScreenPoint.y(),
299 dragStartRWH_.get()); 316 static_cast<blink::WebDragOperation>(operation), dragStartRWH_.get());
300 317
301 // Make sure the pasteboard owner isn't us. 318 // Make sure the pasteboard owner isn't us.
302 [pasteboard_ declareTypes:[NSArray array] owner:nil]; 319 [pasteboard_ declareTypes:[NSArray array] owner:nil];
303 } 320 }
304 321
305 - (NSString*)dragPromisedFileTo:(NSString*)path { 322 - (NSString*)dragPromisedFileTo:(NSString*)path {
306 // Be extra paranoid; avoid crashing. 323 // Be extra paranoid; avoid crashing.
307 if (!dropData_) { 324 if (!dropData_) {
308 NOTREACHED() << "No drag-and-drop data available for promised file."; 325 NOTREACHED() << "No drag-and-drop data available for promised file.";
309 return nil; 326 return nil;
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after
468 - (NSImage*)dragImage { 485 - (NSImage*)dragImage {
469 if (dragImage_) 486 if (dragImage_)
470 return dragImage_; 487 return dragImage_;
471 488
472 // Default to returning a generic image. 489 // Default to returning a generic image.
473 return content::GetContentClient()->GetNativeImageNamed( 490 return content::GetContentClient()->GetNativeImageNamed(
474 IDR_DEFAULT_FAVICON).ToNSImage(); 491 IDR_DEFAULT_FAVICON).ToNSImage();
475 } 492 }
476 493
477 @end // @implementation WebDragSource (Private) 494 @end // @implementation WebDragSource (Private)
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698