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

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

Issue 3547008: Handle resize corner layout entirely in the platform BrowserWindow*/BrowserView* code... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 10 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
Index: chrome/browser/cocoa/sidebar_controller.mm
===================================================================
--- chrome/browser/cocoa/sidebar_controller.mm (revision 65756)
+++ chrome/browser/cocoa/sidebar_controller.mm (working copy)
@@ -36,14 +36,17 @@
@implementation SidebarController
-- (id)init {
+- (id)initWithDelegate:(id<TabContentsControllerDelegate>)delegate {
if ((self = [super init])) {
splitView_.reset([[NSSplitView alloc] initWithFrame:NSZeroRect]);
[splitView_ setDividerStyle:NSSplitViewDividerStyleThin];
[splitView_ setVertical:YES];
[splitView_ setAutoresizingMask:NSViewWidthSizable|NSViewHeightSizable];
[splitView_ setDelegate:self];
- sidebarContents_ = NULL;
+
+ contentsController_.reset(
+ [[TabContentsController alloc] initWithContents:NULL
+ delegate:delegate]);
}
return self;
}
@@ -73,12 +76,11 @@
if (activeSidebar)
sidebarContents = activeSidebar->sidebar_contents();
}
- if (sidebarContents_ == sidebarContents)
+
+ TabContents* oldSidebarContents = [contentsController_ tabContents];
+ if (oldSidebarContents == sidebarContents)
return;
- TabContents* oldSidebarContents = sidebarContents_;
- sidebarContents_ = sidebarContents;
-
// Adjust sidebar view.
[self showSidebarContents:sidebarContents];
@@ -87,16 +89,22 @@
oldSidebarContents, sidebarContents);
}
+- (void)ensureContentsVisible {
+ [contentsController_ ensureContentsVisible];
+}
+
- (void)showSidebarContents:(TabContents*)sidebarContents {
+ [contentsController_ ensureContentsSizeDoesNotChange];
+
NSArray* subviews = [splitView_ subviews];
if (sidebarContents) {
DCHECK_GE([subviews count], 1u);
- // |sidebarView| is a TabContentsViewCocoa object, whose ViewID was
+ // Native view is a TabContentsViewCocoa object, whose ViewID was
// set to VIEW_ID_TAB_CONTAINER initially, so change it to
// VIEW_ID_SIDE_BAR_CONTAINER here.
- NSView* sidebarView = sidebarContents->GetNativeView();
- view_id_util::SetID(sidebarView, VIEW_ID_SIDE_BAR_CONTAINER);
+ view_id_util::SetID(
+ sidebarContents->GetNativeView(), VIEW_ID_SIDE_BAR_CONTAINER);
CGFloat sidebarWidth = 0;
if ([subviews count] == 1) {
@@ -108,12 +116,10 @@
sidebarWidth =
NSWidth([splitView_ frame]) * kDefaultSidebarWidthRatio;
}
- [splitView_ addSubview:sidebarView];
+ [splitView_ addSubview:[contentsController_ view]];
} else {
DCHECK_EQ([subviews count], 2u);
sidebarWidth = NSWidth([[subviews objectAtIndex:1] frame]);
- [splitView_ replaceSubview:[subviews objectAtIndex:1]
- with:sidebarView];
}
// Make sure |sidebarWidth| isn't too large or too small.
@@ -132,8 +138,11 @@
g_browser_process->local_state()->SetInteger(
prefs::kExtensionSidebarWidth, sidebarWidth);
[oldSidebarContentsView removeFromSuperview];
+ [splitView_ adjustSubviews];
}
}
+
+ [contentsController_ changeTabContents:sidebarContents];
}
- (void)resizeSidebarToNewWidth:(CGFloat)width {

Powered by Google App Engine
This is Rietveld 408576698