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

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

Issue 1989633002: Revert "[Material][Mac] Reduced the area above tabs by 2 pts" (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 7 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
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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_layout.h" 5 #import "chrome/browser/ui/cocoa/browser_window_layout.h"
6 6
7 #include <math.h> 7 #include <math.h>
8 #include <string.h> 8 #include <string.h>
9 9
10 #include "base/logging.h" 10 #include "base/logging.h"
11 #include "base/mac/mac_util.h" 11 #include "base/mac/mac_util.h"
12 #import "chrome/browser/ui/cocoa/tabs/tab_strip_controller.h" 12 #import "chrome/browser/ui/cocoa/tabs/tab_strip_controller.h"
13 #include "ui/base/material_design/material_design_controller.h"
14 13
15 namespace chrome { 14 namespace chrome {
16 15
17 // The height of the tab strip. 16 // The height of the tab strip.
18 const CGFloat kTabStripHeight = 37; 17 const CGFloat kTabStripHeight = 37;
19 const CGFloat kMaterialTabStripHeight = 35;
20
21 CGFloat TabStripHeight() {
22 if (ui::MaterialDesignController::IsModeMaterial())
23 return kMaterialTabStripHeight;
24
25 return kTabStripHeight;
26 }
27 18
28 } // namespace chrome 19 } // namespace chrome
29 20
30 namespace { 21 namespace {
31 22
32 // Insets for the location bar, used when the full toolbar is hidden. 23 // Insets for the location bar, used when the full toolbar is hidden.
33 // TODO(viettrungluu): We can argue about the "correct" insetting; I like the 24 // TODO(viettrungluu): We can argue about the "correct" insetting; I like the
34 // following best, though arguably 0 inset is better/more correct. 25 // following best, though arguably 0 inset is better/more correct.
35 const CGFloat kLocBarLeftRightInset = 1; 26 const CGFloat kLocBarLeftRightInset = 1;
36 const CGFloat kLocBarTopInset = 0; 27 const CGFloat kLocBarTopInset = 0;
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after
197 maxY_ = parameters_.contentViewSize.height + fullscreenYOffset_; 188 maxY_ = parameters_.contentViewSize.height + fullscreenYOffset_;
198 return; 189 return;
199 } 190 }
200 191
201 // Temporary variable to hold the output. 192 // Temporary variable to hold the output.
202 chrome::TabStripLayout layout = {}; 193 chrome::TabStripLayout layout = {};
203 194
204 // Lay out the tab strip. 195 // Lay out the tab strip.
205 maxY_ = parameters_.windowSize.height + fullscreenYOffset_; 196 maxY_ = parameters_.windowSize.height + fullscreenYOffset_;
206 CGFloat width = parameters_.contentViewSize.width; 197 CGFloat width = parameters_.contentViewSize.width;
207 layout.frame = NSMakeRect(0, maxY_ - chrome::TabStripHeight(), width, 198 layout.frame = NSMakeRect(
208 chrome::TabStripHeight()); 199 0, maxY_ - chrome::kTabStripHeight, width, chrome::kTabStripHeight);
209 maxY_ = NSMinY(layout.frame); 200 maxY_ = NSMinY(layout.frame);
210 201
211 // In Yosemite, there is no longer an exit fullscreen button in the top-right 202 // In Yosemite, there is no longer an exit fullscreen button in the top-right
212 // corner of the OSX Menu Bar. Instead, a Cocoa application's toolbar is 203 // corner of the OSX Menu Bar. Instead, a Cocoa application's toolbar is
213 // expected to have traffic lights. Chrome doesn't use an NSToolbar, so it 204 // expected to have traffic lights. Chrome doesn't use an NSToolbar, so it
214 // needs to manually add the traffic lights to the tab strip. 205 // needs to manually add the traffic lights to the tab strip.
215 layout.addCustomWindowControls = 206 layout.addCustomWindowControls =
216 parameters_.inAnyFullscreen && parameters_.isOSYosemiteOrLater; 207 parameters_.inAnyFullscreen && parameters_.isOSYosemiteOrLater;
217 208
218 // Set left indentation based on fullscreen mode status. 209 // Set left indentation based on fullscreen mode status.
219 if (!parameters_.inAnyFullscreen || layout.addCustomWindowControls) 210 if (!parameters_.inAnyFullscreen || layout.addCustomWindowControls)
220 layout.leftIndent = [TabStripController defaultLeftIndentForControls]; 211 layout.leftIndent = [TabStripController defaultLeftIndentForControls];
221 212
222 // Lay out the icognito/avatar badge because calculating the indentation on 213 // Lay out the icognito/avatar badge because calculating the indentation on
223 // the right depends on it. 214 // the right depends on it.
224 if (parameters_.shouldShowAvatar) { 215 if (parameters_.shouldShowAvatar) {
225 CGFloat badgeXOffset = -kAvatarRightOffset; 216 CGFloat badgeXOffset = -kAvatarRightOffset;
226 CGFloat badgeYOffset = 0; 217 CGFloat badgeYOffset = 0;
227 CGFloat buttonHeight = parameters_.avatarSize.height; 218 CGFloat buttonHeight = parameters_.avatarSize.height;
228 219
229 if (parameters_.shouldUseNewAvatar) { 220 if (parameters_.shouldUseNewAvatar) {
230 // The fullscreen icon (if present) is displayed to the right of the 221 // The fullscreen icon (if present) is displayed to the right of the
231 // new style profile button. 222 // new style profile button.
232 if (!NSIsEmptyRect(parameters_.fullscreenButtonFrame)) 223 if (!NSIsEmptyRect(parameters_.fullscreenButtonFrame))
233 badgeXOffset = -kLocationBarRightOffset; 224 badgeXOffset = -kLocationBarRightOffset;
234 225
235 // Center the button, but make sure that it's pixel aligned on non-retina 226 // Center the button, but make sure that it's pixel aligned on non-retina
236 // displays. Use trunc() instead of round() to mimic the behavior of 227 // displays. Use trunc() instead of round() to mimic the behavior of
237 // autoresizesSubviews. 228 // autoresizesSubviews.
238 badgeYOffset = trunc((chrome::TabStripHeight() - buttonHeight) / 2); 229 badgeYOffset = trunc((chrome::kTabStripHeight - buttonHeight) / 2);
239 } else { 230 } else {
240 // Actually place the badge *above* |maxY|, by +2 to miss the divider. 231 // Actually place the badge *above* |maxY|, by +2 to miss the divider.
241 badgeYOffset = 2 * parameters_.avatarLineWidth; 232 badgeYOffset = 2 * parameters_.avatarLineWidth;
242 } 233 }
243 234
244 NSSize size = NSMakeSize(parameters_.avatarSize.width, 235 NSSize size = NSMakeSize(parameters_.avatarSize.width,
245 std::min(buttonHeight, chrome::TabStripHeight())); 236 std::min(buttonHeight, chrome::kTabStripHeight));
246 NSPoint origin = 237 NSPoint origin =
247 NSMakePoint(width - parameters_.avatarSize.width + badgeXOffset, 238 NSMakePoint(width - parameters_.avatarSize.width + badgeXOffset,
248 maxY_ + badgeYOffset); 239 maxY_ + badgeYOffset);
249 layout.avatarFrame = 240 layout.avatarFrame =
250 NSMakeRect(origin.x, origin.y, size.width, size.height); 241 NSMakeRect(origin.x, origin.y, size.width, size.height);
251 } 242 }
252 243
253 // Calculate the right indentation. 244 // Calculate the right indentation.
254 // On 10.7 Lion to 10.9 Mavericks, there will be a fullscreen button when not 245 // On 10.7 Lion to 10.9 Mavericks, there will be a fullscreen button when not
255 // in fullscreen mode. 246 // in fullscreen mode.
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
379 // All the remaining space becomes the frame of the content area. 370 // All the remaining space becomes the frame of the content area.
380 output_.contentAreaFrame = NSMakeRect(0, minY, width, maxY - minY); 371 output_.contentAreaFrame = NSMakeRect(0, minY, width, maxY - minY);
381 } 372 }
382 373
383 - (CGFloat)fullscreenBackingBarHeight { 374 - (CGFloat)fullscreenBackingBarHeight {
384 if (!parameters_.inAnyFullscreen) 375 if (!parameters_.inAnyFullscreen)
385 return 0; 376 return 0;
386 377
387 CGFloat totalHeight = 0; 378 CGFloat totalHeight = 0;
388 if (parameters_.hasTabStrip) 379 if (parameters_.hasTabStrip)
389 totalHeight += chrome::TabStripHeight(); 380 totalHeight += chrome::kTabStripHeight;
390 381
391 if (parameters_.hasToolbar) { 382 if (parameters_.hasToolbar) {
392 totalHeight += parameters_.toolbarHeight; 383 totalHeight += parameters_.toolbarHeight;
393 } else if (parameters_.hasLocationBar) { 384 } else if (parameters_.hasLocationBar) {
394 totalHeight += 385 totalHeight +=
395 parameters_.toolbarHeight + kLocBarTopInset + kLocBarBottomInset; 386 parameters_.toolbarHeight + kLocBarTopInset + kLocBarBottomInset;
396 } 387 }
397 388
398 if (!parameters_.bookmarkBarHidden && 389 if (!parameters_.bookmarkBarHidden &&
399 !parameters_.placeBookmarkBarBelowInfoBar) 390 !parameters_.placeBookmarkBarBelowInfoBar)
400 totalHeight += parameters_.bookmarkBarHeight; 391 totalHeight += parameters_.bookmarkBarHeight;
401 392
402 return totalHeight; 393 return totalHeight;
403 } 394 }
404 395
405 @end 396 @end
406 397
407 @implementation BrowserWindowLayout (ExposedForTesting) 398 @implementation BrowserWindowLayout (ExposedForTesting)
408 399
409 - (void)setOSYosemiteOrLater:(BOOL)osYosemiteOrLater { 400 - (void)setOSYosemiteOrLater:(BOOL)osYosemiteOrLater {
410 parameters_.isOSYosemiteOrLater = osYosemiteOrLater; 401 parameters_.isOSYosemiteOrLater = osYosemiteOrLater;
411 } 402 }
412 403
413 @end 404 @end
OLDNEW
« no previous file with comments | « chrome/browser/ui/cocoa/browser_window_layout.h ('k') | chrome/browser/ui/cocoa/browser_window_layout_unittest.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698