diff options
author | rohitrao@chromium.org <rohitrao@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-06-29 17:58:47 +0000 |
---|---|---|
committer | rohitrao@chromium.org <rohitrao@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-06-29 17:58:47 +0000 |
commit | af2fd777dae98b84279707490382002276dfc006 (patch) | |
tree | 74e7b41b42f7c92a540f9a108ea176fcbf6817c3 /chrome/browser | |
parent | dce5df54b85ca90d4bd2d2a04c9f78d3a149072c (diff) | |
download | chromium_src-af2fd777dae98b84279707490382002276dfc006.zip chromium_src-af2fd777dae98b84279707490382002276dfc006.tar.gz chromium_src-af2fd777dae98b84279707490382002276dfc006.tar.bz2 |
Removes our homespun grow box and replaces it with the
standard widget. This may also fix some of our resizing
issues.
BUG=http://crbug.com/14663
TEST=The resizer widget should still work as expected.
Review URL: http://codereview.chromium.org/149094
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@19501 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser')
-rw-r--r-- | chrome/browser/cocoa/browser_window_controller.mm | 42 | ||||
-rw-r--r-- | chrome/browser/cocoa/tab_contents_controller.h | 7 | ||||
-rw-r--r-- | chrome/browser/cocoa/tab_contents_controller.mm | 25 | ||||
-rw-r--r-- | chrome/browser/cocoa/tab_strip_controller.h | 6 | ||||
-rw-r--r-- | chrome/browser/cocoa/tab_strip_controller.mm | 17 | ||||
-rw-r--r-- | chrome/browser/cocoa/tab_strip_controller_unittest.mm | 7 |
6 files changed, 32 insertions, 72 deletions
diff --git a/chrome/browser/cocoa/browser_window_controller.mm b/chrome/browser/cocoa/browser_window_controller.mm index 91a356f..6a58402 100644 --- a/chrome/browser/cocoa/browser_window_controller.mm +++ b/chrome/browser/cocoa/browser_window_controller.mm @@ -36,6 +36,20 @@ const int kWindowGradientHeight = 24; } +@interface NSWindow (NSPrivateApis) +// Note: These functions are private, use -[NSObject respondsToSelector:] +// before calling them. + +- (void)setAutorecalculatesContentBorderThickness:(BOOL)b + forEdge:(NSRectEdge)e; +- (void)setContentBorderThickness:(CGFloat)b forEdge:(NSRectEdge)e; + +- (void)setBottomCornerRounded:(BOOL)rounded; + +- (NSRect)_growBoxRect; +@end + + @interface BrowserWindowController(Private) - (void)positionToolbar; @@ -95,6 +109,11 @@ willPositionSheet:(NSWindow *)sheet // Retain it per the comment in the header. window_.reset([[self window] retain]); + // Sets the window to not have rounded corners, which prevents + // the resize control from being inset slightly and looking ugly. + if ([window_ respondsToSelector:@selector(setBottomCornerRounded:)]) + [window_ setBottomCornerRounded:NO]; + // Since we don't have a standard resize control, Cocoa won't enable the // zoom (green) button on the titlebar for us. Grab it and enable it // manually. Note that when launched from XCode, the doesn't work for the @@ -384,7 +403,17 @@ willPositionSheet:(NSWindow *)sheet // in the coordinate system of the content area of the currently selected tab. // |windowGrowBox| needs to be in the window's coordinate system. - (NSRect)selectedTabGrowBoxRect { - return [tabStripController_ selectedTabGrowBoxRect]; + if (![window_ respondsToSelector:@selector(_growBoxRect)]) + return NSZeroRect; + + // Before we return a rect, we need to convert it from window coordinates + // to tab content area coordinates and flip the coordinate system. + NSRect growBoxRect = + [[self tabContentArea] convertRect:[window_ _growBoxRect] fromView:nil]; + growBoxRect.origin.y = + [[self tabContentArea] frame].size.height - growBoxRect.size.height - + growBoxRect.origin.y; + return growBoxRect; } // Accept tabs from a BrowserWindowController with the same Profile. @@ -630,17 +659,6 @@ willPositionSheet:(NSWindow *)sheet @end - -@interface NSWindow (NSPrivateApis) -// Note: These functions are private, use -[NSObject respondsToSelector:] -// before calling them. - -- (void)setAutorecalculatesContentBorderThickness:(BOOL)b - forEdge:(NSRectEdge)e; -- (void)setContentBorderThickness:(CGFloat)b forEdge:(NSRectEdge)e; -@end - - @implementation BrowserWindowController (Private) // Position |toolbarView_| below the tab strip, but not as a sibling. The diff --git a/chrome/browser/cocoa/tab_contents_controller.h b/chrome/browser/cocoa/tab_contents_controller.h index 123594b..0cd2e2c 100644 --- a/chrome/browser/cocoa/tab_contents_controller.h +++ b/chrome/browser/cocoa/tab_contents_controller.h @@ -7,8 +7,6 @@ #include <Cocoa/Cocoa.h> -@class GrowBoxView; - class TabContents; class TabContentsCommandObserver; class TabStripModel; @@ -22,7 +20,6 @@ class TabStripModel; TabContents* contents_; // weak IBOutlet NSBox* contentsBox_; - IBOutlet GrowBoxView* growBox_; } // Create the contents of a tab represented by |contents| and loaded from the @@ -43,10 +40,6 @@ class TabStripModel; // an entirely new tab contents object. - (void)tabDidChange:(TabContents*)updatedContents; -// Return the rect, in WebKit coordinates (flipped), of the window's grow box -// in the coordinate system of the content area of this tab. -- (NSRect)growBoxRect; - @end #endif // CHROME_BROWSER_COCOA_TAB_CONTENTS_CONTROLLER_H_ diff --git a/chrome/browser/cocoa/tab_contents_controller.mm b/chrome/browser/cocoa/tab_contents_controller.mm index 8898a87..a51796d 100644 --- a/chrome/browser/cocoa/tab_contents_controller.mm +++ b/chrome/browser/cocoa/tab_contents_controller.mm @@ -58,29 +58,4 @@ } } -// Return the rect, in WebKit coordinates (flipped), of the window's grow box -// in the coordinate system of the content area of this tab. -- (NSRect)growBoxRect { - NSRect localGrowBox = NSMakeRect(0, 0, 0, 0); - NSView* contentView = contents_->GetNativeView(); - if (contentView) { - // For the rect, we start with the grow box view which is a sibling of - // the content view's containing box. It's in the coordinate system of - // the controller view. - localGrowBox = [growBox_ frame]; - // The scrollbar assumes that the resizer goes all the way down to the - // bottom corner, so we ignore any y offset to the rect itself and use the - // entire bottom corner. - localGrowBox.origin.y = 0; - // Convert to the content view's coordinates. - localGrowBox = [contentView convertRect:localGrowBox - fromView:[self view]]; - // Flip the rect in view coordinates - localGrowBox.origin.y = - [contentView frame].size.height - localGrowBox.origin.y - - localGrowBox.size.height; - } - return localGrowBox; -} - @end diff --git a/chrome/browser/cocoa/tab_strip_controller.h b/chrome/browser/cocoa/tab_strip_controller.h index 6004768..dea418d 100644 --- a/chrome/browser/cocoa/tab_strip_controller.h +++ b/chrome/browser/cocoa/tab_strip_controller.h @@ -54,7 +54,7 @@ class ToolbarModel; CGFloat placeholderStretchiness_; // Vertical force shown by streching tab. // Frame targets for all the current views. // target frames are used because repeated requests to [NSView animator]. - // aren't coalesced, so we store frames to avoid redundant calls. + // aren't coalesced, so we store frames to avoid redundant calls. scoped_nsobject<NSMutableDictionary> targetFrames_; NSRect newTabTargetFrame_; } @@ -68,10 +68,6 @@ class ToolbarModel; switchView:(NSView*)switchView model:(TabStripModel*)model; -// Return the rect, in WebKit coordinates (flipped), of the window's grow box -// in the coordinate system of the content area of the currently selected tab. -- (NSRect)selectedTabGrowBoxRect; - // Return the view for the currently selected tab. - (NSView *)selectedTabView; diff --git a/chrome/browser/cocoa/tab_strip_controller.mm b/chrome/browser/cocoa/tab_strip_controller.mm index eae1bbb..0bf6a59 100644 --- a/chrome/browser/cocoa/tab_strip_controller.mm +++ b/chrome/browser/cocoa/tab_strip_controller.mm @@ -579,21 +579,4 @@ NSString* const kTabStripNumberOfTabsChanged = @"kTabStripNumberOfTabsChanged"; tabModel_->InsertTabContentsAt(index, contents, true, false); } -// Return the rect, in WebKit coordinates (flipped), of the window's grow box -// in the coordinate system of the content area of the currently selected tab. -- (NSRect)selectedTabGrowBoxRect { - int selectedIndex = tabModel_->selected_index(); - if (selectedIndex == TabStripModel::kNoTab) { - // When the window is initially being constructed, there may be no currently - // selected tab, so pick the first one. If there aren't any, just bail with - // an empty rect. - selectedIndex = 0; - } - TabContentsController* selectedController = - [tabContentsArray_ objectAtIndex:selectedIndex]; - if (!selectedController) - return NSZeroRect; - return [selectedController growBoxRect]; -} - @end diff --git a/chrome/browser/cocoa/tab_strip_controller_unittest.mm b/chrome/browser/cocoa/tab_strip_controller_unittest.mm index 7470bb9..71eeba5 100644 --- a/chrome/browser/cocoa/tab_strip_controller_unittest.mm +++ b/chrome/browser/cocoa/tab_strip_controller_unittest.mm @@ -96,11 +96,6 @@ class TabStripControllerTest : public testing::Test { scoped_nsobject<NSView> tab_strip_; }; -TEST_F(TabStripControllerTest, GrowBox) { - // TODO(pinkerton): Creating a TabContents crashes an unrelated test, even - // if you don't do anything with it. http://crbug.com/10899 -} - // Test adding and removing tabs and making sure that views get added to // the tab strip. TEST_F(TabStripControllerTest, AddRemoveTabs) { @@ -127,7 +122,7 @@ TEST_F(TabStripControllerTest, RearrangeTabs) { // if you don't do anything with it. http://crbug.com/10899 } -// Test that changing the number of tabs broadcasts a +// Test that changing the number of tabs broadcasts a // kTabStripNumberOfTabsChanged notifiction. TEST_F(TabStripControllerTest, Notifications) { // TODO(pinkerton): Creating a TabContents crashes an unrelated test, even |