Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(953)

Unified Diff: chrome/browser/cocoa/tab_strip_controller.mm

Issue 386021: Add support for observing tracking areas so that when tabs are moved undernea... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 11 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | chrome/browser/cocoa/tab_view.mm » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/cocoa/tab_strip_controller.mm
===================================================================
--- chrome/browser/cocoa/tab_strip_controller.mm (revision 31786)
+++ chrome/browser/cocoa/tab_strip_controller.mm (working copy)
@@ -107,6 +107,7 @@
- (void)animationDidStopForController:(TabController*)controller
finished:(BOOL)finished;
- (NSInteger)indexFromModelIndex:(NSInteger)index;
+- (void)mouseMoved:(NSEvent*)event;
@end
// A simple view class that prevents the Window Server from dragging the area
@@ -892,8 +893,15 @@
// tell us what to swap in in its absence.
[tabContentsArray_ removeObjectAtIndex:index];
+ NSView* tab = [controller view];
+
+ // Stop observing the tab's tracking areas.
+ NSNotificationCenter* defaultCenter = [NSNotificationCenter defaultCenter];
+ [defaultCenter removeObserver:self
+ name:NSViewDidUpdateTrackingAreasNotification
+ object:tab];
+
// Remove the view from the tab strip.
- NSView* tab = [controller view];
[tab removeFromSuperview];
// Clear the tab controller's target.
@@ -1183,6 +1191,27 @@
[self layoutTabsWithAnimation:NO regenerateSubviews:NO];
}
+// Called when the tracking areas for any given tab are updated. This allows
+// the individual tabs to update their hover states correctly.
+// Only generates the event if the cursor is in the tab strip.
+- (void)tabUpdateTracking:(NSNotification*)notification {
+ DCHECK([[notification object] isKindOfClass:[TabView class]]);
+ NSWindow* window = [tabView_ window];
+ NSPoint location = [window mouseLocationOutsideOfEventStream];
+ if (NSPointInRect(location, [tabView_ frame])) {
+ NSEvent* mouseEvent = [NSEvent mouseEventWithType:NSMouseMoved
+ location:location
+ modifierFlags:0
+ timestamp:0
+ windowNumber:[window windowNumber]
+ context:nil
+ eventNumber:0
+ clickCount:0
+ pressure:0];
+ [self mouseMoved:mouseEvent];
+ }
+}
+
- (BOOL)inRapidClosureMode {
return availableResizeWidth_ != kUseFullAvailableWidth;
}
@@ -1252,6 +1281,15 @@
// should call |-addSubviewToPermanentList:| (or better yet, call that and then
// |-regenerateSubviewList| to actually add it).
- (void)regenerateSubviewList {
+ // Remove self as an observer from all the old tabs before a new set of
+ // potentially different tabs is put in place.
+ NSNotificationCenter* defaultCenter = [NSNotificationCenter defaultCenter];
+ for (NSView* view in [tabView_ subviews]) {
+ [defaultCenter removeObserver:self
+ name:NSViewDidUpdateTrackingAreasNotification
+ object:view];
+ }
+
// Subviews to put in (in bottom-to-top order), beginning with the permanent
// ones.
NSMutableArray* subviews = [NSMutableArray arrayWithArray:permanentSubviews_];
@@ -1259,11 +1297,19 @@
NSView* selectedTabView = nil;
// Go through tabs in reverse order, since |subviews| is bottom-to-top.
for (TabController* tab in [tabArray_.get() reverseObjectEnumerator]) {
+ NSView* tabView = [tab view];
+
+ // Set self up to observe tabs so hover states will be correct as tabs move.
+ [defaultCenter addObserver:self
+ selector:@selector(tabUpdateTracking:)
+ name:NSViewDidUpdateTrackingAreasNotification
+ object:tabView];
+
if ([tab selected]) {
DCHECK(!selectedTabView);
- selectedTabView = [tab view];
+ selectedTabView = tabView;
} else {
- [subviews addObject:[tab view]];
+ [subviews addObject:tabView];
}
}
if (selectedTabView)
« no previous file with comments | « no previous file | chrome/browser/cocoa/tab_view.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698