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

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

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