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

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

Issue 603243002: Mac: Fix tab strip relayout bug. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Formatting. 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 unified diff | Download patch
« no previous file with comments | « no previous file | 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/mac_util.h" 10 #include "base/mac/mac_util.h"
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after
180 [toolbarController_ setDividerOpacity:[self toolbarDividerOpacity]]; 180 [toolbarController_ setDividerOpacity:[self toolbarDividerOpacity]];
181 } 181 }
182 182
183 - (CGFloat)layoutTabStripAtMaxY:(CGFloat)maxY 183 - (CGFloat)layoutTabStripAtMaxY:(CGFloat)maxY
184 width:(CGFloat)width 184 width:(CGFloat)width
185 fullscreen:(BOOL)fullscreen { 185 fullscreen:(BOOL)fullscreen {
186 // Nothing to do if no tab strip. 186 // Nothing to do if no tab strip.
187 if (![self hasTabStrip]) 187 if (![self hasTabStrip])
188 return maxY; 188 return maxY;
189 189
190 BOOL requiresRelayout = NO;
191
190 NSView* tabStripView = [self tabStripView]; 192 NSView* tabStripView = [self tabStripView];
191 CGFloat tabStripHeight = NSHeight([tabStripView frame]); 193 CGFloat tabStripHeight = NSHeight([tabStripView frame]);
192 maxY -= tabStripHeight; 194 maxY -= tabStripHeight;
193 NSRect tabStripFrame = NSMakeRect(0, maxY, width, tabStripHeight); 195 NSRect tabStripFrame = NSMakeRect(0, maxY, width, tabStripHeight);
196 if (!NSEqualRects(tabStripFrame, [tabStripView frame]))
197 requiresRelayout = YES;
Robert Sesek 2014/09/25 19:44:10 BOOL requiresRelayout = !NSEqualRects(tabStripFram
erikchen 2014/09/25 20:03:32 Done.
194 198
195 // In Yosemite fullscreen, manually add the fullscreen controls to the tab 199 // In Yosemite fullscreen, manually add the fullscreen controls to the tab
196 // strip. 200 // strip.
197 BOOL addControlsInFullscreen = 201 BOOL addControlsInFullscreen =
198 [self isInAppKitFullscreen] && base::mac::IsOSYosemiteOrLater(); 202 [self isInAppKitFullscreen] && base::mac::IsOSYosemiteOrLater();
199 203
200 // Set left indentation based on fullscreen mode status. 204 // Set left indentation based on fullscreen mode status.
201 CGFloat leftIndent = 0; 205 CGFloat leftIndent = 0;
202 if (!fullscreen || addControlsInFullscreen) 206 if (!fullscreen || addControlsInFullscreen)
203 leftIndent = [[tabStripController_ class] defaultLeftIndentForControls]; 207 leftIndent = [[tabStripController_ class] defaultLeftIndentForControls];
204 [tabStripController_ setLeftIndentForControls:leftIndent]; 208 if (leftIndent != [tabStripController_ leftIndentForControls]) {
209 [tabStripController_ setLeftIndentForControls:leftIndent];
210 requiresRelayout = YES;
211 }
205 212
206 if (addControlsInFullscreen) 213 if (addControlsInFullscreen)
207 [tabStripController_ addWindowControls]; 214 [tabStripController_ addWindowControls];
208 else 215 else
209 [tabStripController_ removeWindowControls]; 216 [tabStripController_ removeWindowControls];
210 217
211 // fullScreenButton is non-nil when isInAnyFullscreenMode is NO, and OS 218 // fullScreenButton is non-nil when isInAnyFullscreenMode is NO, and OS
212 // version is in the range 10.7 <= version <= 10.9. Starting with 10.10, the 219 // version is in the range 10.7 <= version <= 10.9. Starting with 10.10, the
213 // zoom/maximize button acts as the fullscreen button. 220 // zoom/maximize button acts as the fullscreen button.
214 NSButton* fullScreenButton = 221 NSButton* fullScreenButton =
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
251 rightIndent = width - NSMinX([fullScreenButton frame]); 258 rightIndent = width - NSMinX([fullScreenButton frame]);
252 259
253 if ([self shouldUseNewAvatarButton]) { 260 if ([self shouldUseNewAvatarButton]) {
254 // The new avatar button is to the left of the fullscreen button. 261 // The new avatar button is to the left of the fullscreen button.
255 // (The old avatar button is to the right). 262 // (The old avatar button is to the right).
256 rightIndent += NSWidth([avatarButton frame]) + kAvatarRightOffset; 263 rightIndent += NSWidth([avatarButton frame]) + kAvatarRightOffset;
257 } 264 }
258 } else if ([self shouldShowAvatar]) { 265 } else if ([self shouldShowAvatar]) {
259 rightIndent += NSWidth([avatarButton frame]) + kAvatarRightOffset; 266 rightIndent += NSWidth([avatarButton frame]) + kAvatarRightOffset;
260 } 267 }
261 [tabStripController_ setRightIndentForControls:rightIndent]; 268
269 if (rightIndent != [tabStripController_ rightIndentForControls]) {
270 [tabStripController_ setRightIndentForControls:rightIndent];
271 requiresRelayout = YES;
272 }
262 273
263 // It is undesirable to force tabs relayout when the tap strip's frame did 274 // It is undesirable to force tabs relayout when the tap strip's frame did
264 // not change, because it will interrupt tab animations in progress. 275 // not change, because it will interrupt tab animations in progress.
265 // In addition, there appears to be an AppKit bug on <10.9 where interrupting 276 // In addition, there appears to be an AppKit bug on <10.9 where interrupting
266 // a tab animation resulted in the tab frame being the animator's target 277 // a tab animation resulted in the tab frame being the animator's target
267 // frame instead of the interrupting setFrame. (See http://crbug.com/415093) 278 // frame instead of the interrupting setFrame. (See http://crbug.com/415093)
268 if (!NSEqualRects(tabStripFrame, [tabStripView frame])){ 279 if (requiresRelayout) {
269 [tabStripView setFrame:tabStripFrame]; 280 [tabStripView setFrame:tabStripFrame];
270 [tabStripController_ layoutTabsWithoutAnimation]; 281 [tabStripController_ layoutTabsWithoutAnimation];
271 } 282 }
272 283
273 return maxY; 284 return maxY;
274 } 285 }
275 286
276 - (BOOL)placeBookmarkBarBelowInfoBar { 287 - (BOOL)placeBookmarkBarBelowInfoBar {
277 // If we are currently displaying the NTP detached bookmark bar or animating 288 // If we are currently displaying the NTP detached bookmark bar or animating
278 // to/from it (from/to anything else), we display the bookmark bar below the 289 // to/from it (from/to anything else), we display the bookmark bar below the
(...skipping 746 matching lines...) Expand 10 before | Expand all | Expand 10 after
1025 1036
1026 [CATransaction commit]; 1037 [CATransaction commit];
1027 hasAdjustedTabStripWhileEnteringAppKitFullscreen_ = YES; 1038 hasAdjustedTabStripWhileEnteringAppKitFullscreen_ = YES;
1028 } 1039 }
1029 } else { 1040 } else {
1030 hasAdjustedTabStripWhileEnteringAppKitFullscreen_ = NO; 1041 hasAdjustedTabStripWhileEnteringAppKitFullscreen_ = NO;
1031 } 1042 }
1032 } 1043 }
1033 1044
1034 @end // @implementation BrowserWindowController(Private) 1045 @end // @implementation BrowserWindowController(Private)
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698