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

Unified 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, 2 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 | « chrome/browser/ui/cocoa/browser_window_controller_browsertest.mm ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 0396108693c7032360f5e2b965316780aa80be26..813222e77b318fd6daf8694ba4222a284140bc2a 100644
--- a/chrome/browser/ui/cocoa/browser_window_controller_private.mm
+++ b/chrome/browser/ui/cocoa/browser_window_controller_private.mm
@@ -205,26 +205,44 @@ willPositionSheet:(NSWindow*)sheet
// the sheet below the bookmark bar.
// - If the bookmark bar is currently animating, position the sheet according
// to where the bar will be when the animation ends.
+ CGFloat defaultSheetY = defaultSheetRect.origin.y;
switch ([bookmarkBarController_ currentState]) {
case BookmarkBar::SHOW: {
NSRect bookmarkBarFrame = [[bookmarkBarController_ view] frame];
- defaultSheetRect.origin.y = bookmarkBarFrame.origin.y;
+ defaultSheetY = bookmarkBarFrame.origin.y;
break;
}
case BookmarkBar::HIDDEN:
case BookmarkBar::DETACHED: {
if ([self hasToolbar]) {
NSRect toolbarFrame = [[toolbarController_ view] frame];
- defaultSheetRect.origin.y = toolbarFrame.origin.y;
+ defaultSheetY = toolbarFrame.origin.y;
} else {
// The toolbar is not shown in application mode. The sheet should be
// located at the top of the window, under the title of the window.
- defaultSheetRect.origin.y = NSHeight([[window contentView] frame]) -
- defaultSheetRect.size.height;
+ defaultSheetY = NSHeight([[window contentView] frame]) -
+ defaultSheetRect.size.height;
}
break;
}
}
+
+ // AppKit may shift the window up to fit the sheet on screen, but it will
+ // never adjust the height of the sheet, or the origin of the sheet relative
+ // to the window. Adjust the origin to prevent sheets from extending past the
+ // bottom of the screen.
+
+ // Don't allow the sheet to extend past the bottom of the window. This logic
+ // intentionally ignores the size of the screens, since the window might span
+ // multiple screens, and AppKit may reposition the window.
+ CGFloat sheetHeight = NSHeight([sheet frame]);
+ defaultSheetY = std::max(defaultSheetY, sheetHeight);
+
+ // It doesn't make sense to provide a Y higher than the height of the window.
+ CGFloat windowHeight = NSHeight([window frame]);
+ defaultSheetY = std::min(defaultSheetY, windowHeight);
+
+ defaultSheetRect.origin.y = defaultSheetY;
return defaultSheetRect;
}
« 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