summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authordmaclach@chromium.org <dmaclach@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-11-12 23:43:02 +0000
committerdmaclach@chromium.org <dmaclach@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-11-12 23:43:02 +0000
commite40c87f893cbe182dcd83ee2e01c341ba2a7e680 (patch)
tree6384ae6321f7343141f3e158ff8315990c851632
parent8dffd310eab54621971df075b029aed569309bde (diff)
downloadchromium_src-e40c87f893cbe182dcd83ee2e01c341ba2a7e680.zip
chromium_src-e40c87f893cbe182dcd83ee2e01c341ba2a7e680.tar.gz
chromium_src-e40c87f893cbe182dcd83ee2e01c341ba2a7e680.tar.bz2
Revert 31814 - Testing to see if it caused performance problems.
Add support for observing tracking areas so that when tabs are moved underneath our cursor, we highlight them correctly. BUG=27458, 13208, 21448 TEST=Create a pile of tabs. Select a middle one. Put your cursor in some other tab. Hit cmdw a couple of times Watch to make sure highlights occur correctly in both the tabs and the close buttons. Review URL: http://codereview.chromium.org/386021 TBR=dmaclach@chromium.org Review URL: http://codereview.chromium.org/384100 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@31856 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/browser/cocoa/tab_strip_controller.mm52
-rw-r--r--chrome/browser/cocoa/tab_view.mm22
2 files changed, 3 insertions, 71 deletions
diff --git a/chrome/browser/cocoa/tab_strip_controller.mm b/chrome/browser/cocoa/tab_strip_controller.mm
index 48a7747..dfc70a7 100644
--- a/chrome/browser/cocoa/tab_strip_controller.mm
+++ b/chrome/browser/cocoa/tab_strip_controller.mm
@@ -107,7 +107,6 @@ private:
- (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
@@ -893,15 +892,8 @@ private:
// 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.
@@ -1191,27 +1183,6 @@ private:
[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;
}
@@ -1281,15 +1252,6 @@ private:
// 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_];
@@ -1297,19 +1259,11 @@ private:
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 = tabView;
+ selectedTabView = [tab view];
} else {
- [subviews addObject:tabView];
+ [subviews addObject:[tab view]];
}
}
if (selectedTabView)
diff --git a/chrome/browser/cocoa/tab_view.mm b/chrome/browser/cocoa/tab_view.mm
index 3106dd1..6ad5a05 100644
--- a/chrome/browser/cocoa/tab_view.mm
+++ b/chrome/browser/cocoa/tab_view.mm
@@ -116,28 +116,6 @@ static const NSTimeInterval kAnimationHideDuration = 0.4;
}
}
-// The tracking areas have been moved. Make sure that the close button is
-// highlighting correctly with respect to the cursor position with the new
-// tracking area locations.
-- (void)updateTrackingAreas {
- [super updateTrackingAreas];
-
- // Update the close buttons if the tab has moved.
- NSPoint mouseLoc = [[self window] mouseLocationOutsideOfEventStream];
- mouseLoc = [self convertPointFromBase:mouseLoc];
- NSString* name = nil;
- if (NSPointInRect(mouseLoc, [closeButton_ frame])) {
- name = @"close_bar_h.pdf";
- } else {
- name = @"close_bar.pdf";
- }
- NSImage* newImage = nsimage_cache::ImageNamed(name);
- NSImage* buttonImage = [closeButton_ image];
- if (![buttonImage isEqual:newImage]) {
- [closeButton_ setImage:newImage];
- }
-}
-
// Determines which view a click in our frame actually hit. It's either this
// view or our child close button.
- (NSView*)hitTest:(NSPoint)aPoint {