summaryrefslogtreecommitdiffstats
path: root/chrome/browser
diff options
context:
space:
mode:
authormark@chromium.org <mark@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-06-24 22:31:21 +0000
committermark@chromium.org <mark@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-06-24 22:31:21 +0000
commit6d227373602b058ec53c56656ac3ccd4ea7549c4 (patch)
treea93dd916723059a3d63215798c15803ce6a61975 /chrome/browser
parentf844783017efd73e57900335f353f496857d4ecc (diff)
downloadchromium_src-6d227373602b058ec53c56656ac3ccd4ea7549c4.zip
chromium_src-6d227373602b058ec53c56656ac3ccd4ea7549c4.tar.gz
chromium_src-6d227373602b058ec53c56656ac3ccd4ea7549c4.tar.bz2
Back out all sorts of stuff back to pre-r18933 so that we can regroup and
figure these perf regressions out. TEST=graphs BUG=15232 Review URL: http://codereview.chromium.org/147113 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@19187 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_controller_unittest.mm6
-rw-r--r--chrome/browser/cocoa/tab_strip_controller.mm46
-rw-r--r--chrome/browser/cocoa/throbber_view.mm4
5 files changed, 33 insertions, 48 deletions
diff --git a/chrome/browser/cocoa/tab_controller.h b/chrome/browser/cocoa/tab_controller.h
index fed9189..7795ec3 100644
--- a/chrome/browser/cocoa/tab_controller.h
+++ b/chrome/browser/cocoa/tab_controller.h
@@ -7,17 +7,6 @@
#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;
@@ -37,12 +26,19 @@ enum TabLoadingState {
IBOutlet NSButton *backgroundButton_;
IBOutlet NSView* iconView_;
BOOL selected_;
- TabLoadingState loadingState_;
+ BOOL loading_;
+ BOOL waiting_;
id<TabControllerTarget> target_; // weak, where actions are sent
SEL action_; // selector sent when tab is selected by clicking
}
-@property(assign, nonatomic) TabLoadingState loadingState;
+// 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) BOOL selected;
@property(assign, nonatomic) id target;
diff --git a/chrome/browser/cocoa/tab_controller.mm b/chrome/browser/cocoa/tab_controller.mm
index f675b9c..94d1ca2 100644
--- a/chrome/browser/cocoa/tab_controller.mm
+++ b/chrome/browser/cocoa/tab_controller.mm
@@ -8,7 +8,8 @@
@implementation TabController
-@synthesize loadingState = loadingState_;
+@synthesize loading = loading_;
+@synthesize waiting = waiting_;
@synthesize target = target_;
@synthesize action = action_;
diff --git a/chrome/browser/cocoa/tab_controller_unittest.mm b/chrome/browser/cocoa/tab_controller_unittest.mm
index 8f93912..c6526be 100644
--- a/chrome/browser/cocoa/tab_controller_unittest.mm
+++ b/chrome/browser/cocoa/tab_controller_unittest.mm
@@ -126,9 +126,9 @@ TEST_F(TabControllerTest, Loading) {
scoped_nsobject<TabController> controller([[TabController alloc] init]);
[[window contentView] addSubview:[controller view]];
- EXPECT_EQ(DONE, [controller loadingState]);
- [controller setLoadingState:LOADING];
- EXPECT_EQ(LOADING, [controller loadingState]);
+ EXPECT_FALSE([controller loading]);
+ [controller setLoading:YES];
+ EXPECT_TRUE([controller loading]);
[[controller view] removeFromSuperview];
}
diff --git a/chrome/browser/cocoa/tab_strip_controller.mm b/chrome/browser/cocoa/tab_strip_controller.mm
index 6f0cd24..90fced55 100644
--- a/chrome/browser/cocoa/tab_strip_controller.mm
+++ b/chrome/browser/cocoa/tab_strip_controller.mm
@@ -444,38 +444,30 @@ 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];
-
- TabLoadingState oldState = [tabController loadingState];
-
- TabLoadingState newState = DONE;
- NSImage* throbberImage = nil;
- if (contents->waiting_for_response()) {
- newState = WAITING;
- throbberImage = throbberWaitingImage;
- } else if (contents->is_loading()) {
- newState = LOADING;
- throbberImage = throbberLoadingImage;
+ NSImage* image = nil;
+ if (contents->waiting_for_response() && ![tabController waiting]) {
+ image = throbberWaitingImage;
+ [tabController setWaiting:YES];
+ } else if (contents->is_loading() && ![tabController loading]) {
+ image = throbberImage;
+ [tabController setLoading:YES];
}
-
- 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];
+ if (image) {
+ NSRect frame = NSMakeRect(0, 0, 16, 16);
+ ThrobberView* throbber =
+ [[[ThrobberView alloc] initWithFrame:frame image:image] autorelease];
+ [tabController setIconView:throbber];
+ }
+ else if (!contents->is_loading()) {
+ // Set everything back to normal, we're done loading.
+ [tabController setIconView:[self favIconImageViewForContents:contents]];
+ [tabController setWaiting:NO];
+ [tabController setLoading:NO];
}
}
diff --git a/chrome/browser/cocoa/throbber_view.mm b/chrome/browser/cocoa/throbber_view.mm
index 0763684..2f9b491 100644
--- a/chrome/browser/cocoa/throbber_view.mm
+++ b/chrome/browser/cocoa/throbber_view.mm
@@ -65,7 +65,6 @@ const float kAnimationIntervalSeconds = 0.03; // 30ms, same as windows
// Overridden to draw the appropriate frame in the image strip.
- (void)drawRect:(NSRect)rect {
-#if 0
float imageDimension = [image_ extent].size.height;
float xOffset = animationFrame_ * imageDimension;
NSRect sourceImageRect =
@@ -74,7 +73,6 @@ const float kAnimationIntervalSeconds = 0.03; // 30ms, same as windows
fromRect:sourceImageRect
operation:NSCompositeSourceOver
fraction:1.0];
-#endif
}
// Stores the internal representation of the image from |image|. We use
@@ -87,7 +85,6 @@ const float kAnimationIntervalSeconds = 0.03; // 30ms, same as windows
[timer_ invalidate];
timer_ = nil;
-#if 0
// Ensure that the height divides evenly into the width. Cache the
// number of frames in the animation for later.
NSSize imageSize = [image size];
@@ -109,7 +106,6 @@ const float kAnimationIntervalSeconds = 0.03; // 30ms, same as windows
[image unlockFocus];
}
image_.reset([[CIImage alloc] initWithBitmapImageRep:rep]);
-#endif
#if 0
// TODO(pinkerton): The invalidation of the view to trigger re-draw causes