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

Issue 2742813003: [Mac] Lay out the browser window when adding the download shelf. (Closed)

Created:
3 years, 9 months ago by Sidney San Martín
Modified:
3 years, 9 months ago
Reviewers:
tapted
CC:
chromium-reviews, mac-reviews_chromium.org
Target Ref:
refs/pending/heads/master
Project:
chromium
Visibility:
Public.

Description

[Mac] Lay out the browser window when adding the download shelf. ## Summary This fixes a regression when a browser window uses Auto Layout: if the download shelf is added to the window without ever being shown (e.g. when installing an extension), then the window can't be made as narrow as usual. ## Explanation Before this CL, BrowserWindowController doesn't lay out the window after adding the download shelf. When the download shelf is shown, -layoutSubviews is called via -resizeView:newHeight:, but in some cases, like a quick extension install, it's added and left hidden. In that case, the shelf will be positioned like this (but you can't see it, since it's hidden and has zero height): /---------------------------------------\ |---------------------------------------| | | | | | | | | | | | | | | |--------------------------- | | x| | \---------------------------------------/ The shelf's autoresizing mask has a flexible width but fixed margins. If the window is wider than the shelf when it's added, then it will have a right margin. As the user makes the window narrower, the download shelf is made narrower and eventually reaches a minimum size. If the user makes the window even smaller, one of two things will happen depending on whether Auto Layout is handling the window: - No Auto Layout: the layout breaks (but the user never sees it happen, because -layoutSubviews fixes it up if the download shelf is shown). - Auto Layout: The layout engine treats the fixed margin as a constraint and prevents the window from becoming any narrower. The next time -[BrowserWindowController layoutSubviews] runs, the download shelf is made the same width as the window, and the problem goes away because it no longer has a margin. ## Future work Only add the download shelf to the view hierarchy when it's visible. BUG=667698, 695577 Review-Url: https://codereview.chromium.org/2742813003 Cr-Commit-Position: refs/heads/master@{#457055} Committed: https://chromium.googlesource.com/chromium/src/+/d06b1c5641ca1022fd4165ea46d8295fb5a215b4

Patch Set 1 #

Total comments: 8

Patch Set 2 : [Not for commit] Show that the new test fails with Auto Layout. #

Patch Set 3 : Expose min size in browser_window_controller.h, simplify setup, add explicit -layoutIfNeeded for newer SDKs. #

Patch Set 4 : Test name and whitespace tweaks. #

Total comments: 8

Patch Set 5 : Nits. #

Patch Set 6 : Un-change this whitespace. #

Patch Set 7 : Rewrite the test with the knowledge that the test class comes with a free BrowserWindowController. #

Patch Set 8 : Put a stray word away. #

Unified diffs Side-by-side diffs Delta from patch set Stats (+42 lines, -10 lines) Patch
M chrome/browser/ui/cocoa/browser_window_controller.h View 1 2 3 4 5 1 chunk +3 lines, -0 lines 0 comments Download
M chrome/browser/ui/cocoa/browser_window_controller.mm View 1 2 3 4 2 chunks +5 lines, -4 lines 0 comments Download
M chrome/browser/ui/cocoa/browser_window_controller_unittest.mm View 1 2 3 4 5 6 7 1 chunk +34 lines, -6 lines 0 comments Download

Messages

Total messages: 53 (41 generated)
Sidney San Martín
Auto Layout bugfix! PTAL.
3 years, 9 months ago (2017-03-10 05:20:50 UTC) #7
tapted
lgtm https://codereview.chromium.org/2742813003/diff/1/chrome/browser/ui/cocoa/browser_window_controller_unittest.mm File chrome/browser/ui/cocoa/browser_window_controller_unittest.mm (right): https://codereview.chromium.org/2742813003/diff/1/chrome/browser/ui/cocoa/browser_window_controller_unittest.mm#newcode176 chrome/browser/ui/cocoa/browser_window_controller_unittest.mm:176: NSWindow* cocoaWindow = browser_window->GetNativeWindow(); nit: cocoa_window (I realise ...
3 years, 9 months ago (2017-03-10 07:22:28 UTC) #10
tapted
3 years, 9 months ago (2017-03-10 07:22:40 UTC) #11
tapted
and uhh.. not lgtm yet. for some awful reason the "Publish+Mail Comments" URL now performs ...
3 years, 9 months ago (2017-03-10 07:26:01 UTC) #12
Sidney San Martín
PTAL https://codereview.chromium.org/2742813003/diff/1/chrome/browser/ui/cocoa/browser_window_controller_unittest.mm File chrome/browser/ui/cocoa/browser_window_controller_unittest.mm (right): https://codereview.chromium.org/2742813003/diff/1/chrome/browser/ui/cocoa/browser_window_controller_unittest.mm#newcode176 chrome/browser/ui/cocoa/browser_window_controller_unittest.mm:176: NSWindow* cocoaWindow = browser_window->GetNativeWindow(); On 2017/03/10 07:22:28, tapted ...
3 years, 9 months ago (2017-03-10 22:23:42 UTC) #25
tapted
https://codereview.chromium.org/2742813003/diff/80001/chrome/browser/ui/cocoa/browser_window_controller.h File chrome/browser/ui/cocoa/browser_window_controller.h (right): https://codereview.chromium.org/2742813003/diff/80001/chrome/browser/ui/cocoa/browser_window_controller.h#newcode68 chrome/browser/ui/cocoa/browser_window_controller.h:68: inline NSSize MinWindowSizeForBrowserType(Browser::Type type) { See later comment for ...
3 years, 9 months ago (2017-03-13 00:25:36 UTC) #30
Sidney San Martín
https://codereview.chromium.org/2742813003/diff/80001/chrome/browser/ui/cocoa/browser_window_controller.h File chrome/browser/ui/cocoa/browser_window_controller.h (right): https://codereview.chromium.org/2742813003/diff/80001/chrome/browser/ui/cocoa/browser_window_controller.h#newcode68 chrome/browser/ui/cocoa/browser_window_controller.h:68: inline NSSize MinWindowSizeForBrowserType(Browser::Type type) { On 2017/03/13 00:25:36, tapted ...
3 years, 9 months ago (2017-03-14 23:28:39 UTC) #33
tapted
lgtm - thanks! https://codereview.chromium.org/2742813003/diff/80001/chrome/browser/ui/cocoa/browser_window_controller_unittest.mm File chrome/browser/ui/cocoa/browser_window_controller_unittest.mm (right): https://codereview.chromium.org/2742813003/diff/80001/chrome/browser/ui/cocoa/browser_window_controller_unittest.mm#newcode178 chrome/browser/ui/cocoa/browser_window_controller_unittest.mm:178: EXPECT_TRUE(browser_window->GetDownloadShelf()); On 2017/03/14 23:28:39, sdy wrote: ...
3 years, 9 months ago (2017-03-15 00:49:51 UTC) #39
Sidney San Martín
One last thing… https://codereview.chromium.org/2742813003/diff/80001/chrome/browser/ui/cocoa/browser_window_controller_unittest.mm File chrome/browser/ui/cocoa/browser_window_controller_unittest.mm (right): https://codereview.chromium.org/2742813003/diff/80001/chrome/browser/ui/cocoa/browser_window_controller_unittest.mm#newcode178 chrome/browser/ui/cocoa/browser_window_controller_unittest.mm:178: EXPECT_TRUE(browser_window->GetDownloadShelf()); On 2017/03/15 00:49:51, tapted wrote: ...
3 years, 9 months ago (2017-03-15 03:13:38 UTC) #45
tapted
neato - lgtm
3 years, 9 months ago (2017-03-15 04:31:46 UTC) #48
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.org/2742813003/160001
3 years, 9 months ago (2017-03-15 11:28:32 UTC) #50
commit-bot: I haz the power
3 years, 9 months ago (2017-03-15 11:33:25 UTC) #53
Message was sent while issue was closed.
Committed patchset #8 (id:160001) as
https://chromium.googlesource.com/chromium/src/+/d06b1c5641ca1022fd4165ea46d8...

Powered by Google App Engine
This is Rietveld 408576698