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

Unified Diff: chrome/browser/ui/cocoa/browser_window_controller_private.mm

Issue 11876036: Alternate NTP: Don't hide bookmark bar on instant (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: a Created 7 years, 11 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
Index: chrome/browser/ui/cocoa/browser_window_controller_private.mm
diff --git a/chrome/browser/ui/cocoa/browser_window_controller_private.mm b/chrome/browser/ui/cocoa/browser_window_controller_private.mm
index 7d31c4ee7905395621c605fa6f9f26f1d3cd08d1..d2df87ea91889323a153086e1de91145047d95b1 100644
--- a/chrome/browser/ui/cocoa/browser_window_controller_private.mm
+++ b/chrome/browser/ui/cocoa/browser_window_controller_private.mm
@@ -32,6 +32,7 @@
#import "chrome/browser/ui/cocoa/tabs/tab_strip_view.h"
#import "chrome/browser/ui/cocoa/toolbar/toolbar_controller.h"
#include "chrome/browser/ui/fullscreen/fullscreen_controller.h"
+#include "chrome/browser/ui/search/search_model.h"
#include "chrome/browser/ui/search/search_ui.h"
#include "chrome/common/chrome_switches.h"
#include "chrome/common/pref_names.h"
@@ -176,6 +177,9 @@ willPositionSheet:(NSWindow*)sheet
if ([window respondsToSelector:@selector(setShouldHideTitle:)])
[(id)window setShouldHideTitle:![self hasTitleBar]];
+ // Update z-order. The code below depends on this.
+ [self updateSubviewZOrder];
+
BOOL inPresentationMode = [self inPresentationMode];
CGFloat floatingBarHeight = [self floatingBarHeight];
// In presentation mode, |yOffset| accounts for the sliding position of the
@@ -201,6 +205,7 @@ willPositionSheet:(NSWindow*)sheet
// Place the toolbar at the top of the reserved area.
maxY = [self layoutToolbarAtMinX:minX maxY:maxY width:width];
+ CGFloat toolbarBottomY = maxY;
// If we're not displaying the bookmark bar below the infobar, then it goes
// immediately below the toolbar.
@@ -242,14 +247,25 @@ willPositionSheet:(NSWindow*)sheet
}
}
- // Finally, the content area takes up all of the remaining space.
- NSRect contentAreaRect = NSMakeRect(minX, minY, width, maxY - minY);
+ // In presentation mode the content area takes up all the remaining space
+ // (from the bottom of the infobar down). In normal mode the content area
+ // takes up the space between the bottom of the toolbar down.
+ CGFloat contentAreaTop = 0;
+ if (inPresentationMode) {
+ toolbarToWebContentsOffset_ = 0;
+ contentAreaTop = maxY;
+ } else {
+ toolbarToWebContentsOffset_ = toolbarBottomY - maxY;
+ contentAreaTop = toolbarBottomY;
+ }
+ [self updateContentOffsets];
+
+ NSRect contentAreaRect = NSMakeRect(minX, minY, width, contentAreaTop - minY);
[self layoutTabContentArea:contentAreaRect];
// Normally, we don't need to tell the toolbar whether or not to show the
// divider, but things break down during animation.
- [toolbarController_
- setDividerOpacity:[bookmarkBarController_ toolbarDividerOpacity]];
+ [toolbarController_ setDividerOpacity:[self toolbarDividerOpacity]];
}
- (CGFloat)floatingBarHeight {
@@ -425,22 +441,6 @@ willPositionSheet:(NSWindow*)sheet
// window), there's no actual overlay. (Displaying one would result in an
// overly sliding in only under the menu, which gives an ugly effect.)
if (floatingBarBackingView_.get()) {
- BOOL aboveBookmarkBar = [self placeBookmarkBarBelowInfoBar];
-
- // Insert it into the view hierarchy if necessary.
- if (![floatingBarBackingView_ superview] ||
- aboveBookmarkBar != floatingBarAboveBookmarkBar_) {
- NSView* contentView = [[self window] contentView];
- // z-order gets messed up unless we explicitly remove the floatingbar
- // view and re-add it.
- [floatingBarBackingView_ removeFromSuperview];
- [contentView addSubview:floatingBarBackingView_
- positioned:(aboveBookmarkBar ?
- NSWindowAbove : NSWindowBelow)
- relativeTo:[bookmarkBarController_ view]];
- floatingBarAboveBookmarkBar_ = aboveBookmarkBar;
- }
-
// Set its frame.
[floatingBarBackingView_ setFrame:frame];
}
@@ -728,15 +728,9 @@ willPositionSheet:(NSWindow*)sheet
NSViewMinYMargin)];
}
- // Adjust the infobar container. In fullscreen, it needs to be below all
- // top chrome elements so it only sits atop the web contents. When in normal
- // mode, it needs to draw over the bookmark bar and part of the toolbar.
- [[infoBarContainerController_ view] removeFromSuperview];
- NSView* infoBarDest = [[self window] contentView];
- [infoBarDest addSubview:[infoBarContainerController_ view]
- positioned:fullscreen ? NSWindowBelow : NSWindowAbove
- relativeTo:fullscreen ? nil
- : [toolbarController_ view]];
+ // Force the bookmark bar zorder to update.
+ [[bookmarkBarController_ view] removeFromSuperview];
+ [self updateSubviewZOrder];
}
- (void)showFullscreenExitBubbleIfNecessary {
@@ -873,4 +867,116 @@ willPositionSheet:(NSWindow*)sheet
[presentationModeController_ cancelAnimationAndTimers];
}
+- (CGFloat)toolbarDividerOpacity {
+ if ([self isShowingInstantResults])
+ return 1;
+ return [bookmarkBarController_ toolbarDividerOpacity];
+}
+
+- (BOOL)isShowingInstantResults {
+ if (!browser_->search_model()->mode().is_search_suggestions())
+ return NO;
+
+ // If the search suggestions are already being displayed in the preview
+ // contents then return YES.
+ if ([previewableContentsController_ isShowingPreview])
+ return YES;
+
+ // Search suggestions might be shown directly in the web contents in some
+ // cases.
+ return browser_->search_model()->mode().origin ==
+ chrome::search::Mode::ORIGIN_SEARCH;
+}
+
+- (void)updateContentOffsets {
+ // Normally the preview contents is used to show instant results which must
+ // obscure the bookmark bar. This is achived by setting the offset to 0
kuan 2013/01/17 18:25:51 nit: s/achived/achieved/
sail 2013/01/17 18:54:55 Done.
+ // so that it overlaps the bookmark bar. The only exception is when the
+ // preview contents is showing the NTP which must sit below the bookmark bar.
+ CGFloat previewOffset = 0;
+ if (browser_->search_model()->mode().is_ntp())
+ previewOffset = toolbarToWebContentsOffset_;
+ [previewableContentsController_ setPreviewOffset:previewOffset];
+
+ // Normally the tab contents sits below the bookmark bar. This is achived by
kuan 2013/01/17 18:25:51 nit: s/sits/sit/, s/achived/achieved/
sail 2013/01/17 18:54:55 Done.
+ // setting the offset to the height of the bookmark bar. The only exception
+ // is on the search results page where the instant results are shown inside
+ // the page and not in the preview contents are usual.
kuan 2013/01/17 18:25:51 nit: s/are/as/
sail 2013/01/17 18:54:55 Done.
+ CGFloat tabContentsOffset = toolbarToWebContentsOffset_;
+ if (browser_->search_model()->mode().is_search_suggestions() &&
+ browser_->search_model()->mode().origin ==
+ chrome::search::Mode::ORIGIN_SEARCH) {
+ tabContentsOffset = 0;
+ }
+ [previewableContentsController_ setActiveContainerOffset:tabContentsOffset];
+
+ // Prevent the fast resize view from drawing white over the bookmark bar.
+ [[self tabContentArea] setContentOffset:toolbarToWebContentsOffset_];
+}
+
+- (void)updateSubviewZOrder {
+ NSView* contentView = [[self window] contentView];
+ NSView* toolbarView = [toolbarController_ view];
+
+ if ([self inPresentationMode]) {
+ // Toolbar is above tab contents so that it can slide down from top of
+ // screen.
+ [contentView cr_ensureSubview:toolbarView
+ isPositioned:NSWindowAbove
+ relativeTo:[self tabContentArea]];
+ } else {
+ // Toolbar is below tab contents so that the infobar arrow can appear above
+ // it. Unlike other views the toolbar never
dhollowa 2013/01/17 17:47:58 nit: looks like comment got cut off before finishi
sail 2013/01/17 18:17:12 Done.
+ [contentView cr_ensureSubview:toolbarView
+ isPositioned:NSWindowBelow
+ relativeTo:[self tabContentArea]];
+ }
+
+ // The bookmark bar is always below the toolbar. In normal mode this means
+ // that it is below tab contents. This allows instant results to be above
+ // the bookmark bar.
+ [contentView cr_ensureSubview:[bookmarkBarController_ view]
+ isPositioned:NSWindowBelow
+ relativeTo:toolbarView];
+
+ if ([self inPresentationMode]) {
+ // In presentation mode the infobar is below all other views.
+ [contentView cr_ensureSubview:[infoBarContainerController_ view]
+ isPositioned:NSWindowBelow
+ relativeTo:[self tabContentArea]];
+ } else {
+ // Above the toolbar but still below tab contents. Similar to the bookmark
+ // bar, this allows instnat results to be above the info bar.
kuan 2013/01/17 18:25:51 nit: s/instnat/instant/
sail 2013/01/17 18:54:55 Done.
+ [contentView cr_ensureSubview:[infoBarContainerController_ view]
+ isPositioned:NSWindowAbove
+ relativeTo:toolbarView];
+ }
+
+ // The find bar is above everything except instant search results.
+ if (findBarCocoaController_) {
+ NSView* relativeView = nil;
+ if ([self inPresentationMode])
+ relativeView = toolbarView;
+ else if ([self isShowingInstantResults])
+ relativeView = [infoBarContainerController_ view];
+ else
+ relativeView = [self tabContentArea];
+ [contentView cr_ensureSubview:[findBarCocoaController_ view]
+ isPositioned:NSWindowAbove
+ relativeTo:relativeView];
+ }
+
+ if (floatingBarBackingView_) {
+ if ([self placeBookmarkBarBelowInfoBar]) {
+ [contentView cr_ensureSubview:floatingBarBackingView_
+ isPositioned:NSWindowAbove
+ relativeTo:[bookmarkBarController_ view]];
+ } else {
+ [contentView cr_ensureSubview:floatingBarBackingView_
+ isPositioned:NSWindowBelow
+ relativeTo:[bookmarkBarController_ view]];
+ }
+ }
+}
+
@end // @implementation BrowserWindowController(Private)

Powered by Google App Engine
This is Rietveld 408576698