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/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 #include "chrome/browser/browser_theme_provider.h" | 9 #include "chrome/browser/browser_theme_provider.h" |
10 #import "chrome/browser/cocoa/tab_controller.h" | 10 #import "chrome/browser/cocoa/tab_controller.h" |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
85 // hierarchy) first. We want to handle clicks and drags in this class and | 85 // hierarchy) first. We want to handle clicks and drags in this class and |
86 // leave the background button for display purposes only. | 86 // leave the background button for display purposes only. |
87 - (BOOL)acceptsFirstMouse:(NSEvent*)theEvent { | 87 - (BOOL)acceptsFirstMouse:(NSEvent*)theEvent { |
88 return YES; | 88 return YES; |
89 } | 89 } |
90 | 90 |
91 - (void)mouseEntered:(NSEvent*)theEvent { | 91 - (void)mouseEntered:(NSEvent*)theEvent { |
92 isMouseInside_ = YES; | 92 isMouseInside_ = YES; |
93 [self resetLastGlowUpdateTime]; | 93 [self resetLastGlowUpdateTime]; |
94 [self adjustGlowValue]; | 94 [self adjustGlowValue]; |
| 95 |
| 96 // The controller needs to update favicon/close button display state. |
| 97 [controller_ updateVisibility]; |
95 } | 98 } |
96 | 99 |
97 - (void)mouseMoved:(NSEvent*)theEvent { | 100 - (void)mouseMoved:(NSEvent*)theEvent { |
98 hoverPoint_ = [self convertPoint:[theEvent locationInWindow] | 101 hoverPoint_ = [self convertPoint:[theEvent locationInWindow] |
99 fromView:nil]; | 102 fromView:nil]; |
100 [self setNeedsDisplay:YES]; | 103 [self setNeedsDisplay:YES]; |
101 } | 104 } |
102 | 105 |
103 - (void)mouseExited:(NSEvent*)theEvent { | 106 - (void)mouseExited:(NSEvent*)theEvent { |
104 isMouseInside_ = NO; | 107 isMouseInside_ = NO; |
105 hoverHoldEndTime_ = | 108 hoverHoldEndTime_ = |
106 [NSDate timeIntervalSinceReferenceDate] + kHoverHoldDuration; | 109 [NSDate timeIntervalSinceReferenceDate] + kHoverHoldDuration; |
107 [self resetLastGlowUpdateTime]; | 110 [self resetLastGlowUpdateTime]; |
108 [self adjustGlowValue]; | 111 [self adjustGlowValue]; |
| 112 |
| 113 // The controller needs to update favicon/close button display state. |
| 114 [controller_ updateVisibility]; |
109 } | 115 } |
110 | 116 |
111 - (void)setTrackingEnabled:(BOOL)enabled { | 117 - (void)setTrackingEnabled:(BOOL)enabled { |
112 [closeButton_ setTrackingEnabled:enabled]; | 118 [closeButton_ setTrackingEnabled:enabled]; |
113 } | 119 } |
114 | 120 |
115 // Determines which view a click in our frame actually hit. It's either this | 121 // Determines which view a click in our frame actually hit. It's either this |
116 // view or our child close button. | 122 // view or our child close button. |
117 - (NSView*)hitTest:(NSPoint)aPoint { | 123 - (NSView*)hitTest:(NSPoint)aPoint { |
118 NSPoint viewPoint = [self convertPoint:aPoint fromView:[self superview]]; | 124 NSPoint viewPoint = [self convertPoint:aPoint fromView:[self superview]]; |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
202 // Handle clicks and drags in this button. We get here because we have | 208 // Handle clicks and drags in this button. We get here because we have |
203 // overridden acceptsFirstMouse: and the click is within our bounds. | 209 // overridden acceptsFirstMouse: and the click is within our bounds. |
204 - (void)mouseDown:(NSEvent*)theEvent { | 210 - (void)mouseDown:(NSEvent*)theEvent { |
205 if ([self isClosing]) | 211 if ([self isClosing]) |
206 return; | 212 return; |
207 | 213 |
208 NSPoint downLocation = [theEvent locationInWindow]; | 214 NSPoint downLocation = [theEvent locationInWindow]; |
209 | 215 |
210 // Record the state of the close button here, because selecting the tab will | 216 // Record the state of the close button here, because selecting the tab will |
211 // unhide it. | 217 // unhide it. |
212 BOOL closeButtonActive = [closeButton_ isHidden] ? NO : YES; | 218 BOOL closeButtonActive = [controller_ closeButtonActive]; |
213 | 219 |
214 // During the tab closure animation (in particular, during rapid tab closure), | 220 // During the tab closure animation (in particular, during rapid tab closure), |
215 // we may get incorrectly hit with a mouse down. If it should have gone to the | 221 // we may get incorrectly hit with a mouse down. If it should have gone to the |
216 // close button, we send it there -- it should then track the mouse, so we | 222 // close button, we send it there -- it should then track the mouse, so we |
217 // don't have to worry about mouse ups. | 223 // don't have to worry about mouse ups. |
218 if (closeButtonActive && [controller_ inRapidClosureMode]) { | 224 if (closeButtonActive && [controller_ inRapidClosureMode]) { |
219 NSPoint hitLocation = [[self superview] convertPoint:downLocation | 225 NSPoint hitLocation = [[self superview] convertPoint:downLocation |
220 fromView:nil]; | 226 fromView:nil]; |
221 if ([self hitTest:hitLocation] == closeButton_) { | 227 if ([self hitTest:hitLocation] == closeButton_) { |
222 [closeButton_ mouseDown:theEvent]; | 228 [closeButton_ mouseDown:theEvent]; |
(...skipping 574 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
797 - (void)cancelAlert { | 803 - (void)cancelAlert { |
798 if (alertState_ != tabs::kAlertNone) { | 804 if (alertState_ != tabs::kAlertNone) { |
799 alertState_ = tabs::kAlertFalling; | 805 alertState_ = tabs::kAlertFalling; |
800 alertHoldEndTime_ = | 806 alertHoldEndTime_ = |
801 [NSDate timeIntervalSinceReferenceDate] + kGlowUpdateInterval; | 807 [NSDate timeIntervalSinceReferenceDate] + kGlowUpdateInterval; |
802 [self resetLastGlowUpdateTime]; | 808 [self resetLastGlowUpdateTime]; |
803 [self adjustGlowValue]; | 809 [self adjustGlowValue]; |
804 } | 810 } |
805 } | 811 } |
806 | 812 |
| 813 - (BOOL)isMouseInside { |
| 814 return isMouseInside_; |
| 815 } |
| 816 |
807 - (BOOL)accessibilityIsIgnored { | 817 - (BOOL)accessibilityIsIgnored { |
808 return NO; | 818 return NO; |
809 } | 819 } |
810 | 820 |
811 - (NSArray*)accessibilityActionNames { | 821 - (NSArray*)accessibilityActionNames { |
812 NSArray* parentActions = [super accessibilityActionNames]; | 822 NSArray* parentActions = [super accessibilityActionNames]; |
813 | 823 |
814 return [parentActions arrayByAddingObject:NSAccessibilityPressAction]; | 824 return [parentActions arrayByAddingObject:NSAccessibilityPressAction]; |
815 } | 825 } |
816 | 826 |
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
944 } | 954 } |
945 | 955 |
946 if (nextUpdate < kNoUpdate) | 956 if (nextUpdate < kNoUpdate) |
947 [self performSelector:_cmd withObject:nil afterDelay:nextUpdate]; | 957 [self performSelector:_cmd withObject:nil afterDelay:nextUpdate]; |
948 | 958 |
949 [self resetLastGlowUpdateTime]; | 959 [self resetLastGlowUpdateTime]; |
950 [self setNeedsDisplay:YES]; | 960 [self setNeedsDisplay:YES]; |
951 } | 961 } |
952 | 962 |
953 @end // @implementation TabView(Private) | 963 @end // @implementation TabView(Private) |
OLD | NEW |