Skip to content

Commit

Permalink
Cocoa: ensure app menu makes space from browser action overflow conta…
Browse files Browse the repository at this point in the history
…iner

https://chromium-review.googlesource.com/c/chromium/src/+/1091497 removed
an item from the app menu that never appeared on Mac. Unfortunately,
even though the item was never *displayed*, it appears to have factored
into NSMenu's calculation for what its max size should be.

When the item was removed, the max size is no longer able to account
for multiple rows in the browser action overflow container, so all
rows but the last are clipped.

This change removes and readds the extension overflow container when it's
finished sizing itself to prompt the menu to reevaluate its height.
We can't do this before we add the item to the menu because the menu's
width factors into the overflow container's size calculation. It seems
like there should be a less awkward way to do this, but I can't find it.

Bug: 862005
Change-Id: Ib17ed810855041226786b16ca94f0a60d88dc892
Reviewed-on: https://chromium-review.googlesource.com/1145133
Reviewed-by: Elly Fong-Jones <ellyjones@chromium.org>
Commit-Queue: Leonard Grey <lgrey@chromium.org>
Cr-Original-Commit-Position: refs/heads/master@{#576905}(cherry picked from commit 8634192)
Reviewed-on: https://chromium-review.googlesource.com/1146780
Reviewed-by: Leonard Grey <lgrey@chromium.org>
Cr-Commit-Position: refs/branch-heads/3497@{chromium#12}
Cr-Branched-From: 271eaf5-refs/heads/master@{#576753}
  • Loading branch information
speednoisemovement committed Jul 23, 2018
1 parent 16b2a7f commit d3524fc
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions chrome/browser/ui/cocoa/app_menu/app_menu_controller.mm
Expand Up @@ -362,6 +362,14 @@ - (void)updateBrowserActionsSubmenu {
[view setFrameOrigin:NSZeroPoint];
[[containerView superview] setFrameOrigin:NSZeroPoint];
[containerView setFrameOrigin:NSMakePoint(kLeftPadding, 0)];

if (containerView.isHidden)
return;

// Remove and re-add menu item so menu gets the correct size.
NSInteger index = [[self menu] indexOfItem:browserActionsMenuItem_];
[[self menu] removeItemAtIndex:index];
[[self menu] insertItem:browserActionsMenuItem_ atIndex:index];
}

- (void)menuWillOpen:(NSMenu*)menu {
Expand Down

0 comments on commit d3524fc

Please sign in to comment.