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

Side by Side Diff: chrome/browser/ui/cocoa/browser_window_controller_private.mm

Issue 665933005: mac: Fix bug where finder window extends past bottom of screen. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase against top of tree. Comments from rsesek. Created 6 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 unified diff | Download patch
« no previous file with comments | « chrome/browser/ui/cocoa/browser_window_controller_browsertest.mm ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 #include "base/mac/bind_objc_block.h" 10 #include "base/mac/bind_objc_block.h"
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after
198 willPositionSheet:(NSWindow*)sheet 198 willPositionSheet:(NSWindow*)sheet
199 usingRect:(NSRect)defaultSheetRect { 199 usingRect:(NSRect)defaultSheetRect {
200 // Position the sheet as follows: 200 // Position the sheet as follows:
201 // - If the bookmark bar is hidden or shown as a bubble (on the NTP when the 201 // - If the bookmark bar is hidden or shown as a bubble (on the NTP when the
202 // bookmark bar is disabled), position the sheet immediately below the 202 // bookmark bar is disabled), position the sheet immediately below the
203 // normal toolbar. 203 // normal toolbar.
204 // - If the bookmark bar is shown (attached to the normal toolbar), position 204 // - If the bookmark bar is shown (attached to the normal toolbar), position
205 // the sheet below the bookmark bar. 205 // the sheet below the bookmark bar.
206 // - If the bookmark bar is currently animating, position the sheet according 206 // - If the bookmark bar is currently animating, position the sheet according
207 // to where the bar will be when the animation ends. 207 // to where the bar will be when the animation ends.
208 CGFloat defaultSheetY = defaultSheetRect.origin.y;
208 switch ([bookmarkBarController_ currentState]) { 209 switch ([bookmarkBarController_ currentState]) {
209 case BookmarkBar::SHOW: { 210 case BookmarkBar::SHOW: {
210 NSRect bookmarkBarFrame = [[bookmarkBarController_ view] frame]; 211 NSRect bookmarkBarFrame = [[bookmarkBarController_ view] frame];
211 defaultSheetRect.origin.y = bookmarkBarFrame.origin.y; 212 defaultSheetY = bookmarkBarFrame.origin.y;
212 break; 213 break;
213 } 214 }
214 case BookmarkBar::HIDDEN: 215 case BookmarkBar::HIDDEN:
215 case BookmarkBar::DETACHED: { 216 case BookmarkBar::DETACHED: {
216 if ([self hasToolbar]) { 217 if ([self hasToolbar]) {
217 NSRect toolbarFrame = [[toolbarController_ view] frame]; 218 NSRect toolbarFrame = [[toolbarController_ view] frame];
218 defaultSheetRect.origin.y = toolbarFrame.origin.y; 219 defaultSheetY = toolbarFrame.origin.y;
219 } else { 220 } else {
220 // The toolbar is not shown in application mode. The sheet should be 221 // The toolbar is not shown in application mode. The sheet should be
221 // located at the top of the window, under the title of the window. 222 // located at the top of the window, under the title of the window.
222 defaultSheetRect.origin.y = NSHeight([[window contentView] frame]) - 223 defaultSheetY = NSHeight([[window contentView] frame]) -
223 defaultSheetRect.size.height; 224 defaultSheetRect.size.height;
224 } 225 }
225 break; 226 break;
226 } 227 }
227 } 228 }
229
230 // AppKit may shift the window up to fit the sheet on screen, but it will
231 // never adjust the height of the sheet, or the origin of the sheet relative
232 // to the window. Adjust the origin to prevent sheets from extending past the
233 // bottom of the screen.
234
235 // Don't allow the sheet to extend past the bottom of the window. This logic
236 // intentionally ignores the size of the screens, since the window might span
237 // multiple screens, and AppKit may reposition the window.
238 CGFloat sheetHeight = NSHeight([sheet frame]);
239 defaultSheetY = std::max(defaultSheetY, sheetHeight);
240
241 // It doesn't make sense to provide a Y higher than the height of the window.
242 CGFloat windowHeight = NSHeight([window frame]);
243 defaultSheetY = std::min(defaultSheetY, windowHeight);
244
245 defaultSheetRect.origin.y = defaultSheetY;
228 return defaultSheetRect; 246 return defaultSheetRect;
229 } 247 }
230 248
231 - (void)layoutSubviews { 249 - (void)layoutSubviews {
232 // Suppress title drawing if necessary. 250 // Suppress title drawing if necessary.
233 if ([self.window respondsToSelector:@selector(setShouldHideTitle:)]) 251 if ([self.window respondsToSelector:@selector(setShouldHideTitle:)])
234 [(id)self.window setShouldHideTitle:![self hasTitleBar]]; 252 [(id)self.window setShouldHideTitle:![self hasTitleBar]];
235 253
236 [bookmarkBarController_ updateHiddenState]; 254 [bookmarkBarController_ updateHiddenState];
237 [self updateSubviewZOrder]; 255 [self updateSubviewZOrder];
(...skipping 849 matching lines...) Expand 10 before | Expand all | Expand 10 after
1087 } 1105 }
1088 if (!enteringAppKitFullscreen_) 1106 if (!enteringAppKitFullscreen_)
1089 return NO; 1107 return NO;
1090 if (enteringAppKitFullscreenOnPrimaryScreen_) 1108 if (enteringAppKitFullscreenOnPrimaryScreen_)
1091 return NO; 1109 return NO;
1092 1110
1093 return YES; 1111 return YES;
1094 } 1112 }
1095 1113
1096 @end // @implementation BrowserWindowController(Private) 1114 @end // @implementation BrowserWindowController(Private)
OLDNEW
« no previous file with comments | « chrome/browser/ui/cocoa/browser_window_controller_browsertest.mm ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698