summaryrefslogtreecommitdiffstats
path: root/chrome/browser
diff options
context:
space:
mode:
authormark@chromium.org <mark@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-06-24 20:39:16 +0000
committermark@chromium.org <mark@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-06-24 20:39:16 +0000
commit402440030869a1f1d74119d8f7c9e2f65e0179a7 (patch)
tree7680a959cc89d75ceae641debf16f9436e773493 /chrome/browser
parentd0d8460e70cc8a125e61e1c2c6a21e37daca25ed (diff)
downloadchromium_src-402440030869a1f1d74119d8f7c9e2f65e0179a7.zip
chromium_src-402440030869a1f1d74119d8f7c9e2f65e0179a7.tar.gz
chromium_src-402440030869a1f1d74119d8f7c9e2f65e0179a7.tar.bz2
Rewrite some tab controller stuff to maybe (but probably not) improve perf.
BUG=15232 TEST=watch perf graphs Review URL: http://codereview.chromium.org/147103 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@19167 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser')
-rw-r--r--chrome/browser/cocoa/tab_controller.h22
-rw-r--r--chrome/browser/cocoa/tab_controller.mm3
-rw-r--r--chrome/browser/cocoa/tab_strip_controller.mm53
3 files changed, 39 insertions, 39 deletions
diff --git a/chrome/browser/cocoa/tab_controller.h b/chrome/browser/cocoa/tab_controller.h
index 7795ec3..fed9189 100644
--- a/chrome/browser/cocoa/tab_controller.h
+++ b/chrome/browser/cocoa/tab_controller.h
@@ -7,6 +7,17 @@
#import <Cocoa/Cocoa.h>
+// The loading/waiting state of the tab.
+// TODO(pinkerton): this really doesn't belong here, but something needs to
+// know the state and another parallel array in TabStripController doesn't seem
+// like the right place either. In a perfect world, this class shouldn't know
+// anything about states that are specific to a browser.
+enum TabLoadingState {
+ DONE,
+ LOADING,
+ WAITING,
+};
+
@class TabView;
@protocol TabControllerTarget;
@@ -26,19 +37,12 @@
IBOutlet NSButton *backgroundButton_;
IBOutlet NSView* iconView_;
BOOL selected_;
- BOOL loading_;
- BOOL waiting_;
+ TabLoadingState loadingState_;
id<TabControllerTarget> target_; // weak, where actions are sent
SEL action_; // selector sent when tab is selected by clicking
}
-// The loading/waiting state of the tab.
-// TODO(pinkerton): these really don't belong here, but something needs to
-// know the state and another parallel array in TabStripController doesn't seem
-// like the right place either. In a perfect world, this class shouldn't know
-// anything about states that are specific to a browser.
-@property(assign, nonatomic) BOOL loading;
-@property(assign, nonatomic) BOOL waiting;
+@property(assign, nonatomic) TabLoadingState loadingState;
@property(assign, nonatomic) BOOL selected;
@property(assign, nonatomic) id target;
diff --git a/chrome/browser/cocoa/tab_controller.mm b/chrome/browser/cocoa/tab_controller.mm
index 94d1ca2..f675b9c 100644
--- a/chrome/browser/cocoa/tab_controller.mm
+++ b/chrome/browser/cocoa/tab_controller.mm
@@ -8,8 +8,7 @@
@implementation TabController
-@synthesize loading = loading_;
-@synthesize waiting = waiting_;
+@synthesize loadingState = loadingState_;
@synthesize target = target_;
@synthesize action = action_;
diff --git a/chrome/browser/cocoa/tab_strip_controller.mm b/chrome/browser/cocoa/tab_strip_controller.mm
index 45741cc..6f0cd24 100644
--- a/chrome/browser/cocoa/tab_strip_controller.mm
+++ b/chrome/browser/cocoa/tab_strip_controller.mm
@@ -444,41 +444,38 @@ NSString* const kTabStripNumberOfTabsChanged = @"kTabStripNumberOfTabsChanged";
// load, so we need to make sure we're not creating the throbber view over and
// over.
if (contents) {
- static NSImage* throbberImage = [[NSImage imageNamed:@"throbber"] retain];
static NSImage* throbberWaitingImage =
[[NSImage imageNamed:@"throbber_waiting"] retain];
+ static NSImage* throbberLoadingImage =
+ [[NSImage imageNamed:@"throbber"] retain];
TabController* tabController = [tabArray_ objectAtIndex:index];
- NSImage* image = nil;
+
+ TabLoadingState oldState = [tabController loadingState];
+
+ TabLoadingState newState = DONE;
+ NSImage* throbberImage = nil;
if (contents->waiting_for_response()) {
- throbberWaitingImage = throbberWaitingImage;
-#if 0
- if (![tabController waiting]) {
- image = throbberWaitingImage;
- [tabController setWaiting:YES];
- }
-#endif
+ newState = WAITING;
+ throbberImage = throbberWaitingImage;
} else if (contents->is_loading()) {
- if (![tabController loading]) {
- image = throbberImage;
- [tabController setLoading:YES];
- }
+ newState = LOADING;
+ throbberImage = throbberLoadingImage;
}
- if (image) {
- NSRect frame = NSMakeRect(0, 0, 16, 16);
-#if 0
- ThrobberView* throbber =
- [[[ThrobberView alloc] initWithFrame:frame image:image] autorelease];
- [tabController setIconView:throbber];
-#endif
- }
- else if (!contents->is_loading()) {
- // Set everything back to normal, we're done loading.
-#if 0
- [tabController setIconView:[self favIconImageViewForContents:contents]];
-#endif
- [tabController setWaiting:NO];
- [tabController setLoading:NO];
+
+ if (oldState != newState) {
+ NSView* iconView = nil;
+ if (newState == DONE) {
+ iconView = [self favIconImageViewForContents:contents];
+ } else {
+ NSRect frame = NSMakeRect(0, 0, 16, 16);
+ iconView = [[[ThrobberView alloc] initWithFrame:frame
+ image:throbberImage]
+ autorelease];
+ }
+
+ [tabController setLoadingState:newState];
+ [tabController setIconView:iconView];
}
}