Commit 5eb47312 authored by erikchen's avatar erikchen Committed by Commit bot

Mac: Fix tab strip relayout bug.

A CL was recently introduced that prevented unnecessary tab-strip relayouts.
(https://codereview.chromium.org/593223002/). That CL had a minor error where
it failed to relayout the tab strip when the left and right indentations
changed. This CL corrects that oversight.

This CL also refactors the browser_window_controller tab strip layout logic
into browser_window_layout. There is no intended behavioral change. The tab
strip layout logic now has test coverage.

BUG=415093

Review URL: https://codereview.chromium.org/603243002

Cr-Commit-Position: refs/heads/master@{#296852}
parent c3e11767
......@@ -191,6 +191,7 @@ willPositionSheet:(NSWindow*)sheet
CGFloat tabStripHeight = NSHeight([tabStripView frame]);
maxY -= tabStripHeight;
NSRect tabStripFrame = NSMakeRect(0, maxY, width, tabStripHeight);
BOOL requiresRelayout = !NSEqualRects(tabStripFrame, [tabStripView frame]);
// In Yosemite fullscreen, manually add the fullscreen controls to the tab
// strip.
......@@ -201,7 +202,10 @@ willPositionSheet:(NSWindow*)sheet
CGFloat leftIndent = 0;
if (!fullscreen || addControlsInFullscreen)
leftIndent = [[tabStripController_ class] defaultLeftIndentForControls];
[tabStripController_ setLeftIndentForControls:leftIndent];
if (leftIndent != [tabStripController_ leftIndentForControls]) {
[tabStripController_ setLeftIndentForControls:leftIndent];
requiresRelayout = YES;
}
if (addControlsInFullscreen)
[tabStripController_ addWindowControls];
......@@ -258,14 +262,18 @@ willPositionSheet:(NSWindow*)sheet
} else if ([self shouldShowAvatar]) {
rightIndent += NSWidth([avatarButton frame]) + kAvatarRightOffset;
}
[tabStripController_ setRightIndentForControls:rightIndent];
if (rightIndent != [tabStripController_ rightIndentForControls]) {
[tabStripController_ setRightIndentForControls:rightIndent];
requiresRelayout = YES;
}
// It is undesirable to force tabs relayout when the tap strip's frame did
// not change, because it will interrupt tab animations in progress.
// In addition, there appears to be an AppKit bug on <10.9 where interrupting
// a tab animation resulted in the tab frame being the animator's target
// frame instead of the interrupting setFrame. (See http://crbug.com/415093)
if (!NSEqualRects(tabStripFrame, [tabStripView frame])){
if (requiresRelayout) {
[tabStripView setFrame:tabStripFrame];
[tabStripController_ layoutTabsWithoutAnimation];
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment