| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 "chrome/browser/cocoa/location_bar/autocomplete_text_field_cell.h" | 5 #import "chrome/browser/cocoa/location_bar/autocomplete_text_field_cell.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #import "chrome/browser/cocoa/image_utils.h" | 8 #import "chrome/browser/cocoa/image_utils.h" |
| 9 #import "chrome/browser/cocoa/location_bar/location_bar_decoration.h" | 9 #import "chrome/browser/cocoa/location_bar/location_bar_decoration.h" |
| 10 | 10 |
| (...skipping 631 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 642 (decoration && decoration->IsDraggable())) { | 642 (decoration && decoration->IsDraggable())) { |
| 643 DCHECK(icon || decoration); | 643 DCHECK(icon || decoration); |
| 644 NSDate* timeout = | 644 NSDate* timeout = |
| 645 [NSDate dateWithTimeIntervalSinceNow:kLocationIconDragTimeout]; | 645 [NSDate dateWithTimeIntervalSinceNow:kLocationIconDragTimeout]; |
| 646 NSEvent* event = [NSApp nextEventMatchingMask:(NSLeftMouseDraggedMask | | 646 NSEvent* event = [NSApp nextEventMatchingMask:(NSLeftMouseDraggedMask | |
| 647 NSLeftMouseUpMask) | 647 NSLeftMouseUpMask) |
| 648 untilDate:timeout | 648 untilDate:timeout |
| 649 inMode:NSEventTrackingRunLoopMode | 649 inMode:NSEventTrackingRunLoopMode |
| 650 dequeue:YES]; | 650 dequeue:YES]; |
| 651 if (!event || [event type] == NSLeftMouseDragged) { | 651 if (!event || [event type] == NSLeftMouseDragged) { |
| 652 NSPasteboard* pboard; | 652 NSPasteboard* pboard = nil; |
| 653 if (icon) pboard = [icon view]->GetDragPasteboard(); | 653 if (icon) pboard = [icon view]->GetDragPasteboard(); |
| 654 if (decoration) pboard = decoration->GetDragPasteboard(); | 654 if (decoration) pboard = decoration->GetDragPasteboard(); |
| 655 DCHECK(pboard); | 655 DCHECK(pboard); |
| 656 | 656 |
| 657 // TODO(shess): My understanding is that the -isFlipped | 657 // TODO(shess): My understanding is that the -isFlipped |
| 658 // adjustment should not be necessary. But without it, the | 658 // adjustment should not be necessary. But without it, the |
| 659 // image is nowhere near the cursor. Perhaps the icon's rect is | 659 // image is nowhere near the cursor. Perhaps the icon's rect is |
| 660 // incorrectly calculated? | 660 // incorrectly calculated? |
| 661 // http://crbug.com/40711 | 661 // http://crbug.com/40711 |
| 662 NSPoint dragPoint = decorationRect.origin; | 662 NSPoint dragPoint = decorationRect.origin; |
| 663 if ([controlView isFlipped]) | 663 if ([controlView isFlipped]) |
| 664 dragPoint.y += NSHeight(decorationRect); | 664 dragPoint.y += NSHeight(decorationRect); |
| 665 | 665 |
| 666 NSImage* image; | 666 NSImage* image = nil; |
| 667 if (icon) image = [icon view]->GetImage(); | 667 if (icon) image = [icon view]->GetImage(); |
| 668 if (decoration) image = decoration->GetDragImage(); | 668 if (decoration) image = decoration->GetDragImage(); |
| 669 [controlView dragImage:image | 669 [controlView dragImage:image |
| 670 at:dragPoint | 670 at:dragPoint |
| 671 offset:NSZeroSize | 671 offset:NSZeroSize |
| 672 event:event ? event : theEvent | 672 event:event ? event : theEvent |
| 673 pasteboard:pboard | 673 pasteboard:pboard |
| 674 source:self | 674 source:self |
| 675 slideBack:YES]; | 675 slideBack:YES]; |
| 676 return YES; | 676 return YES; |
| (...skipping 11 matching lines...) Expand all Loading... |
| 688 } | 688 } |
| 689 | 689 |
| 690 return YES; | 690 return YES; |
| 691 } | 691 } |
| 692 | 692 |
| 693 - (NSDragOperation)draggingSourceOperationMaskForLocal:(BOOL)isLocal { | 693 - (NSDragOperation)draggingSourceOperationMaskForLocal:(BOOL)isLocal { |
| 694 return NSDragOperationCopy; | 694 return NSDragOperationCopy; |
| 695 } | 695 } |
| 696 | 696 |
| 697 @end | 697 @end |
| OLD | NEW |