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

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

Issue 3050021: Rework somewhat how the folder menu window and main view sizes and positions ... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 10 years, 5 months 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
« no previous file with comments | « no previous file | chrome/browser/cocoa/bookmark_bar_folder_controller_unittest.mm » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/cocoa/bookmark_bar_folder_controller.mm
===================================================================
--- chrome/browser/cocoa/bookmark_bar_folder_controller.mm (revision 54167)
+++ chrome/browser/cocoa/bookmark_bar_folder_controller.mm (working copy)
@@ -377,22 +377,22 @@
[self adjustButtonWidths] + (2 * bookmarks::kBookmarkVerticalPadding) +
bookmarks::kScrollViewContentWidthMargin;
NSPoint newWindowTopLeft = [self windowTopLeftForWidth:windowWidth];
- NSSize windowSize = [scrollView_ convertSize:NSMakeSize(windowWidth,
- windowHeight)
- toView:nil];
- newWindowTopLeft.y -= windowSize.height;
+ NSSize windowSize = NSMakeSize(windowWidth, windowHeight);
+ windowSize = [scrollView_ convertSize:windowSize toView:nil];
+ NSWindow* window = [self window];
+ // If the window is already visible then make sure its top remains stable.
+ BOOL windowAlreadyShowing = [window isVisible];
+ CGFloat deltaY = windowHeight - NSHeight([mainView_ frame]);
+ if (windowAlreadyShowing) {
+ NSRect oldFrame = [window frame];
+ newWindowTopLeft.y = oldFrame.origin.y + NSHeight(oldFrame);
+ }
NSRect windowFrame = NSMakeRect(newWindowTopLeft.x,
- newWindowTopLeft.y,
- windowSize.width,
- windowSize.height);
-
+ newWindowTopLeft.y - windowHeight, windowSize.width, windowHeight);
// Make the scrolled content be the right size (full size).
- NSRect mainViewFrame = NSMakeRect(0, 0,
- windowWidth -
- bookmarks::kScrollViewContentWidthMargin,
- windowHeight);
+ NSRect mainViewFrame = NSMakeRect(0, 0, NSWidth(windowFrame) -
+ bookmarks::kScrollViewContentWidthMargin, NSHeight(windowFrame));
[mainView_ setFrame:mainViewFrame];
-
// Make sure the window fits on the screen. If not, constrain.
// We'll scroll to allow the user to see all the content.
NSRect screenFrame = [[[self window] screen] frame];
@@ -404,17 +404,33 @@
} else {
scrollable_ = NO;
}
- NSWindow* window = [self window];
- [window setFrame:windowFrame display:YES];
- // If scrollable then offset the view and show the arrows.
+ [window setFrame:windowFrame display:NO];
if (wasScrollable != scrollable_) {
- NSSize windowLocalSize = [scrollView_ convertSize:windowFrame.size
- fromView:nil];
- [mainView_ scrollPoint:NSMakePoint(0, (NSHeight(mainViewFrame) -
- windowLocalSize.height))];
+ // If scrollability changed then rework visibility of the scroll arrows
+ // and the scroll offset of the menu view.
+ NSSize windowLocalSize =
+ [scrollView_ convertSize:windowFrame.size fromView:nil];
+ CGFloat scrollPointY = NSHeight(mainViewFrame) - windowLocalSize.height +
+ bookmarks::kBookmarkVerticalPadding;
+ [mainView_ scrollPoint:NSMakePoint(0, scrollPointY)];
[self showOrHideScrollArrows];
[self addOrUpdateScrollTracking];
+ } else if (scrollable_ && windowAlreadyShowing) {
+ // If the window was already showing and is still scrollable then make
+ // sure the main view moves upward, not downward so that the content
+ // at the bottom of the menu, not the top, appears to move.
+ // The edge case is when the menu is scrolled all the way to top (hence
+ // the test of scrollDownArrowShown_) - don't scroll then.
+ NSView* superView = [mainView_ superview];
+ DCHECK([superView isKindOfClass:[NSClipView class]]);
+ NSClipView* clipView = static_cast<NSClipView*>(superView);
+ CGFloat scrollPointY = [clipView bounds].origin.y +
+ bookmarks::kBookmarkVerticalPadding;
+ if (scrollDownArrowShown_ || deltaY > 0.0)
+ scrollPointY += deltaY;
+ [mainView_ scrollPoint:NSMakePoint(0, scrollPointY)];
}
+ [window display];
}
// Determine window size and position.
@@ -429,7 +445,8 @@
int buttons = std::max(node->GetChildCount() - startingIndex, 1);
// Prelim height of the window. We'll trim later as needed.
- int height = buttons * bookmarks::kBookmarkButtonHeight;
+ int height = buttons * bookmarks::kBookmarkButtonHeight +
+ bookmarks::kBookmarkVerticalPadding;
// We'll need this soon...
[self window];
@@ -1237,7 +1254,8 @@
[self closeBookmarkFolder:self];
// Prelim height of the window. We'll trim later as needed.
- int height = [buttons_ count] * bookmarks::kBookmarkButtonHeight;
+ int height = [buttons_ count] * bookmarks::kBookmarkButtonHeight +
+ bookmarks::kBookmarkVerticalPadding;
[self adjustWindowForHeight:height];
}
@@ -1370,7 +1388,8 @@
}
// Propose a height for the window. We'll trim later as needed.
- int height = buttonCount * bookmarks::kBookmarkButtonHeight;
+ int height = buttonCount * bookmarks::kBookmarkButtonHeight +
+ bookmarks::kBookmarkVerticalPadding;
[self adjustWindowForHeight:height];
}
« no previous file with comments | « no previous file | chrome/browser/cocoa/bookmark_bar_folder_controller_unittest.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698