| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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/tab_view.h" | 5 #import "chrome/browser/cocoa/tab_view.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "base/nsimage_cache_mac.h" | 8 #include "base/nsimage_cache_mac.h" |
| 9 #import "chrome/browser/cocoa/tab_controller.h" | 9 #import "chrome/browser/cocoa/tab_controller.h" |
| 10 #import "chrome/browser/cocoa/tab_window_controller.h" | 10 #import "chrome/browser/cocoa/tab_window_controller.h" |
| (...skipping 534 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 545 } | 545 } |
| 546 [sourceController_ removePlaceholder]; | 546 [sourceController_ removePlaceholder]; |
| 547 chromeIsVisible_ = YES; | 547 chromeIsVisible_ = YES; |
| 548 | 548 |
| 549 [self resetDragControllers]; | 549 [self resetDragControllers]; |
| 550 } | 550 } |
| 551 | 551 |
| 552 - (void)otherMouseUp:(NSEvent*)theEvent { | 552 - (void)otherMouseUp:(NSEvent*)theEvent { |
| 553 // Support middle-click-to-close. | 553 // Support middle-click-to-close. |
| 554 if ([theEvent buttonNumber] == 2) { | 554 if ([theEvent buttonNumber] == 2) { |
| 555 [controller_ closeTab:self]; | 555 // |-hitTest:| takes a location in the superview's coordinates. |
| 556 NSPoint upLocation = |
| 557 [[self superview] convertPoint:[theEvent locationInWindow] |
| 558 fromView:nil]; |
| 559 // If the mouse up occurred in our view or over the close button, then |
| 560 // close. |
| 561 if ([self hitTest:upLocation]) |
| 562 [controller_ closeTab:self]; |
| 556 } | 563 } |
| 557 } | 564 } |
| 558 | 565 |
| 559 - (void)drawRect:(NSRect)rect { | 566 - (void)drawRect:(NSRect)rect { |
| 560 NSGraphicsContext* context = [NSGraphicsContext currentContext]; | 567 NSGraphicsContext* context = [NSGraphicsContext currentContext]; |
| 561 [context saveGraphicsState]; | 568 [context saveGraphicsState]; |
| 562 rect = [self bounds]; | 569 rect = [self bounds]; |
| 563 BOOL active = [[self window] isKeyWindow] || [[self window] isMainWindow]; | 570 BOOL active = [[self window] isKeyWindow] || [[self window] isMainWindow]; |
| 564 BOOL selected = [(NSButton*)self state]; | 571 BOOL selected = [(NSButton*)self state]; |
| 565 | 572 |
| (...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 715 } | 722 } |
| 716 | 723 |
| 717 - (void)viewDidMoveToWindow { | 724 - (void)viewDidMoveToWindow { |
| 718 [super viewDidMoveToWindow]; | 725 [super viewDidMoveToWindow]; |
| 719 if ([self window]) { | 726 if ([self window]) { |
| 720 [controller_ updateTitleColor]; | 727 [controller_ updateTitleColor]; |
| 721 } | 728 } |
| 722 } | 729 } |
| 723 | 730 |
| 724 @end | 731 @end |
| OLD | NEW |