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

Side by Side Diff: chrome/browser/ui/views/frame/browser_non_client_frame_view_ash.cc

Issue 2523783002: Top Chrome MD cleanup - get rid of most of GetLayoutInsets. (Closed)
Patch Set: Created 4 years 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 2012 The Chromium Authors. All rights reserved. 1 // Copyright 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 #include "chrome/browser/ui/views/frame/browser_non_client_frame_view_ash.h" 5 #include "chrome/browser/ui/views/frame/browser_non_client_frame_view_ash.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "ash/common/ash_layout_constants.h" 9 #include "ash/common/ash_layout_constants.h"
10 #include "ash/common/frame/caption_buttons/frame_caption_button_container_view.h " 10 #include "ash/common/frame/caption_buttons/frame_caption_button_container_view.h "
(...skipping 390 matching lines...) Expand 10 before | Expand all | Expand 10 after
401 chrome::MultiUserWindowManager::ShouldShowAvatar( 401 chrome::MultiUserWindowManager::ShouldShowAvatar(
402 browser_view()->GetNativeWindow())) { 402 browser_view()->GetNativeWindow())) {
403 UpdateProfileIndicatorIcon(); 403 UpdateProfileIndicatorIcon();
404 } 404 }
405 } 405 }
406 406
407 /////////////////////////////////////////////////////////////////////////////// 407 ///////////////////////////////////////////////////////////////////////////////
408 // BrowserNonClientFrameViewAsh, private: 408 // BrowserNonClientFrameViewAsh, private:
409 409
410 int BrowserNonClientFrameViewAsh::GetTabStripLeftInset() const { 410 int BrowserNonClientFrameViewAsh::GetTabStripLeftInset() const {
411 const gfx::Insets insets(GetLayoutInsets(AVATAR_ICON)); 411 const int pad = GetLayoutConstant(AVATAR_ICON_PADDING);
Peter Kasting 2016/11/22 22:12:08 Nit: "avoid abbreviation" ( http://google.github.i
Evan Stade 2016/11/29 03:01:45 Pad is actually a synonym of padding (and much old
Peter Kasting 2016/11/29 03:38:28 Do we use it very much elsewhere in views? I cert
Evan Stade 2016/11/30 00:39:22 I can see both sides. Padding is much more common,
412 const int avatar_right = profile_indicator_icon() 412 const int avatar_right =
413 ? (insets.left() + GetIncognitoAvatarIcon().width()) 413 profile_indicator_icon() ? (pad + GetIncognitoAvatarIcon().width()) : 0;
414 : 0; 414 return avatar_right + pad;
415 return avatar_right + insets.right();
416 } 415 }
417 416
418 int BrowserNonClientFrameViewAsh::GetTabStripRightInset() const { 417 int BrowserNonClientFrameViewAsh::GetTabStripRightInset() const {
419 return kTabstripRightSpacing + 418 return kTabstripRightSpacing +
420 caption_button_container_->GetPreferredSize().width(); 419 caption_button_container_->GetPreferredSize().width();
421 } 420 }
422 421
423 bool BrowserNonClientFrameViewAsh::UseImmersiveLightbarHeaderStyle() const { 422 bool BrowserNonClientFrameViewAsh::UseImmersiveLightbarHeaderStyle() const {
424 const ImmersiveModeController* const immersive_controller = 423 const ImmersiveModeController* const immersive_controller =
425 browser_view()->immersive_mode_controller(); 424 browser_view()->immersive_mode_controller();
(...skipping 16 matching lines...) Expand all
442 } 441 }
443 442
444 void BrowserNonClientFrameViewAsh::LayoutProfileIndicatorIcon() { 443 void BrowserNonClientFrameViewAsh::LayoutProfileIndicatorIcon() {
445 DCHECK(profile_indicator_icon()); 444 DCHECK(profile_indicator_icon());
446 #if !defined(OS_CHROMEOS) 445 #if !defined(OS_CHROMEOS)
447 // ChromeOS shows avatar on V1 app. 446 // ChromeOS shows avatar on V1 app.
448 DCHECK(browser_view()->IsTabStripVisible()); 447 DCHECK(browser_view()->IsTabStripVisible());
449 #endif 448 #endif
450 449
451 const gfx::ImageSkia incognito_icon = GetIncognitoAvatarIcon(); 450 const gfx::ImageSkia incognito_icon = GetIncognitoAvatarIcon();
452 const gfx::Insets avatar_insets = GetLayoutInsets(AVATAR_ICON); 451 const int pad = GetLayoutConstant(AVATAR_ICON_PADDING);
453 const int avatar_bottom = GetTopInset(false) + 452 const int avatar_bottom =
454 browser_view()->GetTabStripHeight() - avatar_insets.bottom(); 453 GetTopInset(false) + browser_view()->GetTabStripHeight() - pad;
455 int avatar_y = avatar_bottom - incognito_icon.height(); 454 int avatar_y = avatar_bottom - incognito_icon.height();
456 455
457 // Hide the incognito icon in immersive fullscreen when the tab light bar is 456 // Hide the incognito icon in immersive fullscreen when the tab light bar is
458 // visible because the header is too short for the icognito icon to be 457 // visible because the header is too short for the icognito icon to be
459 // recognizable. 458 // recognizable.
460 const bool avatar_visible = !UseImmersiveLightbarHeaderStyle(); 459 const bool avatar_visible = !UseImmersiveLightbarHeaderStyle();
461 const int avatar_height = avatar_visible ? (avatar_bottom - avatar_y) : 0; 460 const int avatar_height = avatar_visible ? (avatar_bottom - avatar_y) : 0;
462 profile_indicator_icon()->SetBounds(avatar_insets.left(), avatar_y, 461 profile_indicator_icon()->SetBounds(pad, avatar_y, incognito_icon.width(),
463 incognito_icon.width(), avatar_height); 462 avatar_height);
464 profile_indicator_icon()->SetVisible(avatar_visible); 463 profile_indicator_icon()->SetVisible(avatar_visible);
465 } 464 }
466 465
467 bool BrowserNonClientFrameViewAsh::ShouldPaint() const { 466 bool BrowserNonClientFrameViewAsh::ShouldPaint() const {
468 if (!frame()->IsFullscreen()) 467 if (!frame()->IsFullscreen())
469 return true; 468 return true;
470 469
471 // We need to paint when in immersive fullscreen and either: 470 // We need to paint when in immersive fullscreen and either:
472 // - The top-of-window views are revealed. 471 // - The top-of-window views are revealed.
473 // - The lightbar style tabstrip is visible. 472 // - The lightbar style tabstrip is visible.
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
509 toolbar_bounds.width(), 0); 508 toolbar_bounds.width(), 0);
510 BrowserView::Paint1pxHorizontalLine(canvas, GetToolbarTopSeparatorColor(), 509 BrowserView::Paint1pxHorizontalLine(canvas, GetToolbarTopSeparatorColor(),
511 separator_rect, true); 510 separator_rect, true);
512 511
513 // Toolbar/content separator. 512 // Toolbar/content separator.
514 toolbar_bounds.Inset(kClientEdgeThickness, 0); 513 toolbar_bounds.Inset(kClientEdgeThickness, 0);
515 BrowserView::Paint1pxHorizontalLine( 514 BrowserView::Paint1pxHorizontalLine(
516 canvas, tp->GetColor(ThemeProperties::COLOR_TOOLBAR_BOTTOM_SEPARATOR), 515 canvas, tp->GetColor(ThemeProperties::COLOR_TOOLBAR_BOTTOM_SEPARATOR),
517 toolbar_bounds, true); 516 toolbar_bounds, true);
518 } 517 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698