| 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 "chrome/browser/ui/cocoa/bookmarks/bookmark_button.h" | 5 #import "chrome/browser/ui/cocoa/bookmarks/bookmark_button.h" |
| 6 | 6 |
| 7 #include <cmath> | 7 #include <cmath> |
| 8 | 8 |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/mac/foundation_util.h" | 10 #include "base/mac/foundation_util.h" |
| (...skipping 351 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 362 - (void)mouseMoved:(NSEvent*)theEvent { | 362 - (void)mouseMoved:(NSEvent*)theEvent { |
| 363 if ([delegate_ respondsToSelector:@selector(mouseMoved:)]) | 363 if ([delegate_ respondsToSelector:@selector(mouseMoved:)]) |
| 364 [id(delegate_) mouseMoved:theEvent]; | 364 [id(delegate_) mouseMoved:theEvent]; |
| 365 } | 365 } |
| 366 | 366 |
| 367 - (void)mouseDragged:(NSEvent*)theEvent { | 367 - (void)mouseDragged:(NSEvent*)theEvent { |
| 368 if ([delegate_ respondsToSelector:@selector(mouseDragged:)]) | 368 if ([delegate_ respondsToSelector:@selector(mouseDragged:)]) |
| 369 [id(delegate_) mouseDragged:theEvent]; | 369 [id(delegate_) mouseDragged:theEvent]; |
| 370 } | 370 } |
| 371 | 371 |
| 372 - (void)rightMouseDown:(NSEvent*)event { | 372 - (void)willOpenMenu:(NSMenu *)menu withEvent:(NSEvent *)event { |
| 373 // Ensure that right-clicking on a button while a context menu is open | 373 // Ensure that right-clicking on a button while a context menu is already open |
| 374 // highlights the new button. | 374 // highlights the new button. |
| 375 [delegate_ mouseEnteredButton:self event:event]; |
| 376 |
| 375 GradientButtonCell* cell = | 377 GradientButtonCell* cell = |
| 376 base::mac::ObjCCastStrict<GradientButtonCell>([self cell]); | 378 base::mac::ObjCCastStrict<GradientButtonCell>([self cell]); |
| 377 [delegate_ mouseEnteredButton:self event:event]; | 379 // Opt for animate:NO, otherwise the upcoming contextual menu's modal loop |
| 378 [cell setMouseInside:YES animate:YES]; | 380 // will block the animation and the button's state will visually never change |
| 381 // ( https://crbug.com/649256 ). |
| 382 [cell setMouseInside:YES animate:NO]; |
| 383 } |
| 379 | 384 |
| 380 // Keep a ref to |self|, in case -rightMouseDown: deletes this bookmark. | 385 - (void)didCloseMenu:(NSMenu *)menu withEvent:(NSEvent *)event { |
| 381 base::scoped_nsobject<BookmarkButton> keepAlive([self retain]); | 386 // Update the highlight after the contextual menu closes. |
| 382 [super rightMouseDown:event]; | 387 GradientButtonCell* cell = |
| 388 base::mac::ObjCCastStrict<GradientButtonCell>([self cell]); |
| 383 | 389 |
| 384 if (![cell isMouseReallyInside]) { | 390 if (![cell isMouseReallyInside]) { |
| 385 [cell setMouseInside:NO animate:YES]; | 391 [cell setMouseInside:NO animate:YES]; |
| 386 [delegate_ mouseExitedButton:self event:event]; | 392 [delegate_ mouseExitedButton:self event:event]; |
| 387 } | 393 } |
| 388 } | 394 } |
| 389 | 395 |
| 390 + (BookmarkButton*)draggedButton { | 396 + (BookmarkButton*)draggedButton { |
| 391 return gDraggedButton; | 397 return gDraggedButton; |
| 392 } | 398 } |
| (...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 518 [[cell clipPathForFrame:bounds inView:self] setClip]; | 524 [[cell clipPathForFrame:bounds inView:self] setClip]; |
| 519 [cell drawWithFrame:bounds inView:self]; | 525 [cell drawWithFrame:bounds inView:self]; |
| 520 | 526 |
| 521 CGContextEndTransparencyLayer(cgContext); | 527 CGContextEndTransparencyLayer(cgContext); |
| 522 [image unlockFocus]; | 528 [image unlockFocus]; |
| 523 | 529 |
| 524 return image.autorelease(); | 530 return image.autorelease(); |
| 525 } | 531 } |
| 526 | 532 |
| 527 @end | 533 @end |
| OLD | NEW |