| 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/tab_contents/web_drag_source_mac.h" | 5 #import "content/browser/tab_contents/web_drag_source_mac.h" |
| 6 | 6 |
| 7 #include <sys/param.h> | 7 #include <sys/param.h> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/file_path.h" | 10 #include "base/file_path.h" |
| (...skipping 243 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 254 event:dragEvent | 254 event:dragEvent |
| 255 pasteboard:pasteboard_ | 255 pasteboard:pasteboard_ |
| 256 source:contentsView_ | 256 source:contentsView_ |
| 257 slideBack:YES]; | 257 slideBack:YES]; |
| 258 } | 258 } |
| 259 | 259 |
| 260 - (void)endDragAt:(NSPoint)screenPoint | 260 - (void)endDragAt:(NSPoint)screenPoint |
| 261 operation:(NSDragOperation)operation { | 261 operation:(NSDragOperation)operation { |
| 262 contents_->SystemDragEnded(); | 262 contents_->SystemDragEnded(); |
| 263 | 263 |
| 264 RenderViewHost* rvh = contents_->GetRenderViewHost(); | 264 RenderViewHostImpl* rvh = static_cast<RenderViewHostImpl*>( |
| 265 contents_->GetRenderViewHost()); |
| 265 if (rvh) { | 266 if (rvh) { |
| 266 // Convert |screenPoint| to view coordinates and flip it. | 267 // Convert |screenPoint| to view coordinates and flip it. |
| 267 NSPoint localPoint = NSMakePoint(0, 0); | 268 NSPoint localPoint = NSMakePoint(0, 0); |
| 268 if ([contentsView_ window]) | 269 if ([contentsView_ window]) |
| 269 localPoint = [self convertScreenPoint:screenPoint]; | 270 localPoint = [self convertScreenPoint:screenPoint]; |
| 270 NSRect viewFrame = [contentsView_ frame]; | 271 NSRect viewFrame = [contentsView_ frame]; |
| 271 localPoint.y = viewFrame.size.height - localPoint.y; | 272 localPoint.y = viewFrame.size.height - localPoint.y; |
| 272 // Flip |screenPoint|. | 273 // Flip |screenPoint|. |
| 273 NSRect screenFrame = [[[contentsView_ window] screen] frame]; | 274 NSRect screenFrame = [[[contentsView_ window] screen] frame]; |
| 274 screenPoint.y = screenFrame.size.height - screenPoint.y; | 275 screenPoint.y = screenFrame.size.height - screenPoint.y; |
| 275 | 276 |
| 276 // If AppKit returns a copy and move operation, mask off the move bit | 277 // If AppKit returns a copy and move operation, mask off the move bit |
| 277 // because WebCore does not understand what it means to do both, which | 278 // because WebCore does not understand what it means to do both, which |
| 278 // results in an assertion failure/renderer crash. | 279 // results in an assertion failure/renderer crash. |
| 279 if (operation == (NSDragOperationMove | NSDragOperationCopy)) | 280 if (operation == (NSDragOperationMove | NSDragOperationCopy)) |
| 280 operation &= ~NSDragOperationMove; | 281 operation &= ~NSDragOperationMove; |
| 281 | 282 |
| 282 rvh->DragSourceEndedAt(localPoint.x, localPoint.y, | 283 rvh->DragSourceEndedAt(localPoint.x, localPoint.y, |
| 283 screenPoint.x, screenPoint.y, | 284 screenPoint.x, screenPoint.y, |
| 284 static_cast<WebKit::WebDragOperation>(operation)); | 285 static_cast<WebKit::WebDragOperation>(operation)); |
| 285 } | 286 } |
| 286 | 287 |
| 287 // Make sure the pasteboard owner isn't us. | 288 // Make sure the pasteboard owner isn't us. |
| 288 [pasteboard_ declareTypes:[NSArray array] owner:nil]; | 289 [pasteboard_ declareTypes:[NSArray array] owner:nil]; |
| 289 } | 290 } |
| 290 | 291 |
| 291 - (void)moveDragTo:(NSPoint)screenPoint { | 292 - (void)moveDragTo:(NSPoint)screenPoint { |
| 292 RenderViewHost* rvh = contents_->GetRenderViewHost(); | 293 RenderViewHostImpl* rvh = static_cast<RenderViewHostImpl*>( |
| 294 contents_->GetRenderViewHost()); |
| 293 if (rvh) { | 295 if (rvh) { |
| 294 // Convert |screenPoint| to view coordinates and flip it. | 296 // Convert |screenPoint| to view coordinates and flip it. |
| 295 NSPoint localPoint = NSMakePoint(0, 0); | 297 NSPoint localPoint = NSMakePoint(0, 0); |
| 296 if ([contentsView_ window]) | 298 if ([contentsView_ window]) |
| 297 localPoint = [self convertScreenPoint:screenPoint]; | 299 localPoint = [self convertScreenPoint:screenPoint]; |
| 298 NSRect viewFrame = [contentsView_ frame]; | 300 NSRect viewFrame = [contentsView_ frame]; |
| 299 localPoint.y = viewFrame.size.height - localPoint.y; | 301 localPoint.y = viewFrame.size.height - localPoint.y; |
| 300 // Flip |screenPoint|. | 302 // Flip |screenPoint|. |
| 301 NSRect screenFrame = [[[contentsView_ window] screen] frame]; | 303 NSRect screenFrame = [[[contentsView_ window] screen] frame]; |
| 302 screenPoint.y = screenFrame.size.height - screenPoint.y; | 304 screenPoint.y = screenFrame.size.height - screenPoint.y; |
| (...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 441 | 443 |
| 442 - (NSImage*)dragImage { | 444 - (NSImage*)dragImage { |
| 443 if (dragImage_) | 445 if (dragImage_) |
| 444 return dragImage_; | 446 return dragImage_; |
| 445 | 447 |
| 446 // Default to returning a generic image. | 448 // Default to returning a generic image. |
| 447 return gfx::GetCachedImageWithName(@"nav.pdf"); | 449 return gfx::GetCachedImageWithName(@"nav.pdf"); |
| 448 } | 450 } |
| 449 | 451 |
| 450 @end // @implementation WebDragSource (Private) | 452 @end // @implementation WebDragSource (Private) |
| OLD | NEW |