| Index: chrome/browser/cocoa/tab_strip_controller.mm
|
| ===================================================================
|
| --- chrome/browser/cocoa/tab_strip_controller.mm (revision 24707)
|
| +++ chrome/browser/cocoa/tab_strip_controller.mm (working copy)
|
| @@ -47,6 +47,7 @@
|
| @end
|
|
|
| @interface TabStripController(Private)
|
| +- (void)installTrackingArea;
|
| - (BOOL)useFullWidthForLayout;
|
| - (void)addSubviewToPermanentList:(NSView*)aView;
|
| - (void)regenerateSubviewList;
|
| @@ -82,6 +83,7 @@
|
| [newTabButton_ setAction:@selector(commandDispatch:)];
|
| [newTabButton_ setTag:IDC_NEW_TAB];
|
| targetFrames_.reset([[NSMutableDictionary alloc] init]);
|
| + [tabView_ setWantsLayer:YES];
|
| dragBlockingView_.reset([[TabStripControllerDragBlockingView alloc]
|
| initWithFrame:NSZeroRect]);
|
| [self addSubviewToPermanentList:dragBlockingView_];
|
| @@ -98,23 +100,13 @@
|
| selector:@selector(tabViewFrameChanged:)
|
| name:NSViewFrameDidChangeNotification
|
| object:tabView_];
|
| -
|
| - trackingArea_.reset([[NSTrackingArea alloc]
|
| - initWithRect:NSZeroRect // Ignored by NSTrackingInVisibleRect
|
| - options:NSTrackingMouseEnteredAndExited |
|
| - NSTrackingMouseMoved |
|
| - NSTrackingActiveAlways |
|
| - NSTrackingInVisibleRect
|
| - owner:self
|
| - userInfo:nil]);
|
| - [tabView_ addTrackingArea:trackingArea_.get()];
|
| }
|
| return self;
|
| }
|
|
|
| - (void)dealloc {
|
| - if (trackingArea_.get())
|
| - [tabView_ removeTrackingArea:trackingArea_.get()];
|
| + if (closeTabTrackingArea_.get())
|
| + [tabView_ removeTrackingArea:closeTabTrackingArea_.get()];
|
| [[NSNotificationCenter defaultCenter] removeObserver:self];
|
| [super dealloc];
|
| }
|
| @@ -237,9 +229,6 @@
|
| // is the TabView that is potentially going away.
|
| - (void)closeTab:(id)sender {
|
| DCHECK([sender isKindOfClass:[NSView class]]);
|
| - if ([hoveredTab_ isEqual:sender]) {
|
| - hoveredTab_ = nil;
|
| - }
|
| int index = [self indexForTabView:sender];
|
| if (tabModel_->ContainsIndex(index)) {
|
| TabContents* contents = tabModel_->GetTabContentsAt(index);
|
| @@ -251,6 +240,7 @@
|
| // TODO(pinkerton): re-visit when handling tab overflow.
|
| NSView* penultimateTab = [self viewAtIndex:[tabArray_ count] - 2];
|
| availableResizeWidth_ = NSMaxX([penultimateTab frame]);
|
| + [self installTrackingArea];
|
| tabModel_->CloseTabContentsAt(index);
|
| } else {
|
| // Use the standard window close if this is the last tab
|
| @@ -345,7 +335,7 @@
|
| for (TabController* tab in tabArray_.get()) {
|
| BOOL isPlaceholder = [[tab view] isEqual:placeholderTab_];
|
| NSRect tabFrame = [[tab view] frame];
|
| - tabFrame.size.height = [[self class] defaultTabHeight] + 1;
|
| + tabFrame.size.height = [[self class] defaultTabHeight];
|
| tabFrame.origin.y = 0;
|
| tabFrame.origin.x = offset;
|
|
|
| @@ -573,10 +563,6 @@
|
| NSView* tab = [self viewAtIndex:index];
|
| [tab removeFromSuperview];
|
|
|
| - if ([hoveredTab_ isEqual:tab]) {
|
| - hoveredTab_ = nil;
|
| - }
|
| -
|
| NSValue *identifier = [NSValue valueWithPointer:tab];
|
| [targetFrames_ removeObjectForKey:identifier];
|
|
|
| @@ -761,9 +747,9 @@
|
| tabModel_->InsertTabContentsAt(index, contents, true, false);
|
| }
|
|
|
| -- (void)applyTheme {
|
| +- (void)userChangedTheme {
|
| for (TabController* tab in tabArray_.get()) {
|
| - [tab applyTheme];
|
| + [[tab view] setNeedsDisplay:YES];
|
| }
|
| }
|
|
|
| @@ -780,38 +766,34 @@
|
| return availableResizeWidth_ == kUseFullAvailableWidth;
|
| }
|
|
|
| -- (void)mouseMoved:(NSEvent *)event {
|
| - // Use hit test to figure out what view we are hovering over.
|
| - TabView* targetView = (TabView*)[tabView_ hitTest:[event locationInWindow]];
|
| - if (![targetView isKindOfClass:[TabView class]]) {
|
| - if ([[targetView superview] isKindOfClass:[TabView class]]) {
|
| - targetView = (TabView*)[targetView superview];
|
| - } else {
|
| - targetView = nil;
|
| - }
|
| - }
|
| -
|
| - if (hoveredTab_ != targetView) {
|
| - [hoveredTab_ mouseExited:nil]; // We don't pass event because moved events
|
| - [targetView mouseEntered:nil]; // don't have valid tracking areas
|
| - hoveredTab_ = targetView;
|
| - } else {
|
| - [hoveredTab_ mouseMoved:event];
|
| - }
|
| +// Call to install a tracking area that reports mouseEnter/Exit messages so
|
| +// we can track when the mouse leaves the tab view after closing a tab with
|
| +// the mouse. Don't install another tracking rect if one is already there.
|
| +- (void)installTrackingArea {
|
| + if (closeTabTrackingArea_.get())
|
| + return;
|
| + // Note that we pass |NSTrackingInVisibleRect| so the rect is actually
|
| + // ignored.
|
| + closeTabTrackingArea_.reset([[NSTrackingArea alloc]
|
| + initWithRect:[tabView_ bounds]
|
| + options:NSTrackingMouseEnteredAndExited | NSTrackingActiveAlways |
|
| + NSTrackingInVisibleRect
|
| + owner:self
|
| + userInfo:nil]);
|
| + [tabView_ addTrackingArea:closeTabTrackingArea_.get()];
|
| }
|
|
|
| - (void)mouseEntered:(NSEvent*)event {
|
| - [self mouseMoved:event];
|
| + // Do nothing.
|
| }
|
|
|
| // Called when the tracking area is in effect which means we're tracking to
|
| // see if the user leaves the tab strip with their mouse. When they do,
|
| // reset layout to use all available width.
|
| - (void)mouseExited:(NSEvent*)event {
|
| + [tabView_ removeTrackingArea:closeTabTrackingArea_.get()];
|
| + closeTabTrackingArea_.reset(nil);
|
| availableResizeWidth_ = kUseFullAvailableWidth;
|
| -
|
| - [hoveredTab_ mouseExited:event];
|
| - hoveredTab_ = nil;
|
| [self layoutTabs];
|
| }
|
|
|
|
|