OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #import "chrome/browser/ui/cocoa/browser_window_controller_private.h" | 5 #import "chrome/browser/ui/cocoa/browser_window_controller_private.h" |
6 | 6 |
7 #include <cmath> | 7 #include <cmath> |
8 | 8 |
9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
10 #import "base/memory/scoped_nsobject.h" | 10 #import "base/memory/scoped_nsobject.h" |
(...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
236 // presentation mode in which case it's at the top of the visual content area. | 236 // presentation mode in which case it's at the top of the visual content area. |
237 maxY = [self layoutInfoBarAtMinX:minX maxY:maxY width:width]; | 237 maxY = [self layoutInfoBarAtMinX:minX maxY:maxY width:width]; |
238 | 238 |
239 // Place the download shelf, if any, at the bottom of the view. | 239 // Place the download shelf, if any, at the bottom of the view. |
240 minY = [self layoutDownloadShelfAtMinX:minX minY:minY width:width]; | 240 minY = [self layoutDownloadShelfAtMinX:minX minY:minY width:width]; |
241 | 241 |
242 // Place the bookmark bar. | 242 // Place the bookmark bar. |
243 if (placeBookmarkBarBelowInfoBar) | 243 if (placeBookmarkBarBelowInfoBar) |
244 maxY = [self layoutBookmarkBarAtMinX:minX maxY:maxY width:width]; | 244 maxY = [self layoutBookmarkBarAtMinX:minX maxY:maxY width:width]; |
245 | 245 |
246 // In presentation mode the content area takes up all the remaining space | 246 int contentAreaTop = 0; |
247 // (from the bottom of the infobar down). In normal mode the content area | |
248 // takes up the space between the bottom of the toolbar down. | |
249 CGFloat contentAreaTop = 0; | |
250 if (inPresentationMode) { | 247 if (inPresentationMode) { |
251 toolbarToWebContentsOffset_ = 0; | 248 // The tabContentaArea starts at the bottom of the info bar (or top of the |
249 // screen if there's no infobar). | |
252 contentAreaTop = maxY; | 250 contentAreaTop = maxY; |
251 CGFloat floatingBarHeight = | |
252 NSHeight(floatingBarBackingRect) * [self floatingBarShownFraction]; | |
253 // When an instant overlay is shown this is the amount it needs to be pushed | |
254 // down by so that it doesn't get covered by the floating toolbar. | |
dhollowa
2013/03/25 16:28:18
"pushed down so"
sail
2013/03/26 00:16:43
Done.
| |
255 toolbarToWebContentsOffset_ = | |
256 floatingBarHeight - (NSMaxY(contentBounds) - maxY); | |
253 } else { | 257 } else { |
258 // The tabContentArea view starts below the omnibox. | |
254 CGFloat minToolbarHeight = [toolbarController_ | 259 CGFloat minToolbarHeight = [toolbarController_ |
255 desiredHeightForCompression:bookmarks::kBookmarkBarOverlap]; | 260 desiredHeightForCompression:bookmarks::kBookmarkBarOverlap]; |
256 contentAreaTop = toolbarTopY - minToolbarHeight; | 261 contentAreaTop = toolbarTopY - minToolbarHeight; |
262 // This is the space between the bottom of the omnibox and the bottom of the | |
263 // infobar (or bookmark bar if there's no infobar). This is used to push | |
dhollowa
2013/03/25 16:28:18
What if there's both the bookmark bar and the info
sail
2013/03/26 00:16:43
contentAreaTop is the Y coordinate of the bottom m
| |
264 // the tab web content down when no instant overlay is shown. | |
257 toolbarToWebContentsOffset_ = contentAreaTop - maxY; | 265 toolbarToWebContentsOffset_ = contentAreaTop - maxY; |
258 } | 266 } |
259 [self updateContentOffsets]; | 267 [self updateContentOffsets]; |
260 | 268 |
261 NSRect contentAreaRect = NSMakeRect(minX, minY, width, contentAreaTop - minY); | 269 NSRect contentAreaRect = NSMakeRect(minX, minY, width, contentAreaTop - minY); |
262 [self layoutTabContentArea:contentAreaRect]; | 270 [self layoutTabContentArea:contentAreaRect]; |
263 | 271 |
264 // Normally, we don't need to tell the toolbar whether or not to show the | 272 // Normally, we don't need to tell the toolbar whether or not to show the |
265 // divider, but things break down during animation. | 273 // divider, but things break down during animation. |
266 [toolbarController_ setDividerOpacity:[self toolbarDividerOpacity]]; | 274 [toolbarController_ setDividerOpacity:[self toolbarDividerOpacity]]; |
(...skipping 589 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
856 if ([overlayableContentsController_ isShowingOverlay]) | 864 if ([overlayableContentsController_ isShowingOverlay]) |
857 return browser_window_controller::kInstantUIOverlay; | 865 return browser_window_controller::kInstantUIOverlay; |
858 | 866 |
859 if (browser_->search_model()->top_bars_visible()) | 867 if (browser_->search_model()->top_bars_visible()) |
860 return browser_window_controller::kInstantUINone; | 868 return browser_window_controller::kInstantUINone; |
861 | 869 |
862 return browser_window_controller::kInstantUIFullPageResults; | 870 return browser_window_controller::kInstantUIFullPageResults; |
863 } | 871 } |
864 | 872 |
865 - (void)updateContentOffsets { | 873 - (void)updateContentOffsets { |
866 // Normally the tab contents sits below the bookmark bar. This is achieved by | 874 if ([self inPresentationMode]) { |
867 // setting the offset to the height of the bookmark bar. The only exception | 875 // In presentation mode the tabContentArea starts at the bottom of the info |
868 // is on the search results page where the Instant results are shown inside | 876 // bar (or top of the screen if there's no infobar). |
869 // the page and not in the overlay contents as usual. | 877 if ([self currentInstantUIState] != |
870 CGFloat tabContentsOffset = toolbarToWebContentsOffset_; | 878 browser_window_controller::kInstantUIFullPageResults) { |
871 if ([self currentInstantUIState] == | 879 // Normal mode, keep the tab web contents at the top (below the info bar). |
dhollowa
2013/03/25 16:28:18
nit: "infobar"
sail
2013/03/26 00:16:43
Actually, we always make this two words. Updated m
| |
872 browser_window_controller::kInstantUIFullPageResults) { | 880 [overlayableContentsController_ setActiveContainerOffset:0]; |
873 tabContentsOffset = 0; | 881 } else { |
882 // Instant suggestions are displayed in the main tab contents so push that | |
883 // down so that the floating toolbar doesn't obscure it. | |
884 [overlayableContentsController_ | |
885 setActiveContainerOffset:toolbarToWebContentsOffset_]; | |
886 } | |
887 // Floating overlay (if any) should also be below the floating toolbar. | |
888 [overlayableContentsController_ | |
889 setOverlayContentsOffset:toolbarToWebContentsOffset_]; | |
890 | |
891 [[self tabContentArea] setContentOffset:0]; | |
892 [devToolsController_ setTopContentOffset:0]; | |
893 } else { | |
894 // In normal mode the tabContentArea starts just below the omnibox and the | |
895 // bookmark bar and info bar overlap it. | |
896 if ([self currentInstantUIState] != | |
897 browser_window_controller::kInstantUIFullPageResults) { | |
898 // Normal mode, push the tab web contents down so that it doesn't obscure | |
899 // the bookmark bar and info bar. | |
900 [overlayableContentsController_ | |
901 setActiveContainerOffset:toolbarToWebContentsOffset_]; | |
902 } else { | |
903 // Instant suggestions are displayed in the main tab contents so don't | |
904 // push it down (keep it next to the omnibox). | |
905 [overlayableContentsController_ setActiveContainerOffset:0]; | |
906 } | |
907 // Floating overlay (if any) should also be at the top (next to the | |
908 // omnibox). | |
909 [overlayableContentsController_ setOverlayContentsOffset:0]; | |
910 | |
911 // Prevent the fast resize view from drawing white over the bookmark bar. | |
912 [[self tabContentArea] setContentOffset:toolbarToWebContentsOffset_]; | |
913 // Prevent the dev tools splitter from overlapping the bookmark bar. | |
914 if ([self currentInstantUIState] != | |
915 browser_window_controller::kInstantUINone) { | |
916 [devToolsController_ setTopContentOffset:0]; | |
917 } else { | |
918 [devToolsController_ setTopContentOffset:toolbarToWebContentsOffset_]; | |
919 } | |
874 } | 920 } |
875 [overlayableContentsController_ setActiveContainerOffset:tabContentsOffset]; | |
876 | |
877 // Prevent the fast resize view from drawing white over the bookmark bar. | |
878 [[self tabContentArea] setContentOffset:toolbarToWebContentsOffset_]; | |
879 | |
880 // Prevent the dev tools splitter from overlapping the bookmark bar. | |
881 if ([self currentInstantUIState] != browser_window_controller::kInstantUINone) | |
882 [devToolsController_ setTopContentOffset:0]; | |
883 else | |
884 [devToolsController_ setTopContentOffset:toolbarToWebContentsOffset_]; | |
885 } | 921 } |
886 | 922 |
887 - (void)updateSubviewZOrder:(BOOL)inPresentationMode { | 923 - (void)updateSubviewZOrder:(BOOL)inPresentationMode { |
888 NSView* contentView = [[self window] contentView]; | 924 NSView* contentView = [[self window] contentView]; |
889 NSView* toolbarView = [toolbarController_ view]; | 925 NSView* toolbarView = [toolbarController_ view]; |
890 | 926 |
891 if (inPresentationMode) { | 927 if (inPresentationMode) { |
892 // Toolbar is above tab contents so that it can slide down from top of | 928 // Toolbar is above tab contents so that it can slide down from top of |
893 // screen. | 929 // screen. |
894 [contentView cr_ensureSubview:toolbarView | 930 [contentView cr_ensureSubview:toolbarView |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
948 relativeTo:[bookmarkBarController_ view]]; | 984 relativeTo:[bookmarkBarController_ view]]; |
949 } else { | 985 } else { |
950 [contentView cr_ensureSubview:floatingBarBackingView_ | 986 [contentView cr_ensureSubview:floatingBarBackingView_ |
951 isPositioned:NSWindowBelow | 987 isPositioned:NSWindowBelow |
952 relativeTo:[bookmarkBarController_ view]]; | 988 relativeTo:[bookmarkBarController_ view]]; |
953 } | 989 } |
954 } | 990 } |
955 } | 991 } |
956 | 992 |
957 @end // @implementation BrowserWindowController(Private) | 993 @end // @implementation BrowserWindowController(Private) |
OLD | NEW |