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

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

Issue 2523783002: Top Chrome MD cleanup - get rid of most of GetLayoutInsets. (Closed)
Patch Set: fix typo 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 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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_mus.h" 5 #include "chrome/browser/ui/views/frame/browser_non_client_frame_view_mus.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "chrome/browser/profiles/profiles_state.h" 9 #include "chrome/browser/profiles/profiles_state.h"
10 #include "chrome/browser/themes/theme_properties.h" 10 #include "chrome/browser/themes/theme_properties.h"
(...skipping 353 matching lines...) Expand 10 before | Expand all | Expand 10 after
364 void BrowserNonClientFrameViewMus::TabStripMaxXChanged(TabStrip* tab_strip) { 364 void BrowserNonClientFrameViewMus::TabStripMaxXChanged(TabStrip* tab_strip) {
365 UpdateClientArea(); 365 UpdateClientArea();
366 } 366 }
367 367
368 void BrowserNonClientFrameViewMus::TabStripDeleted(TabStrip* tab_strip) { 368 void BrowserNonClientFrameViewMus::TabStripDeleted(TabStrip* tab_strip) {
369 tab_strip_->RemoveObserver(this); 369 tab_strip_->RemoveObserver(this);
370 tab_strip_ = nullptr; 370 tab_strip_ = nullptr;
371 } 371 }
372 372
373 int BrowserNonClientFrameViewMus::GetTabStripLeftInset() const { 373 int BrowserNonClientFrameViewMus::GetTabStripLeftInset() const {
374 const gfx::Insets insets(GetLayoutInsets(AVATAR_ICON)); 374 const int pad = GetLayoutConstant(AVATAR_ICON_PADDING);
375 const int avatar_right = profile_indicator_icon() 375 const int avatar_right = profile_indicator_icon()
376 ? (insets.left() + GetIncognitoAvatarIcon().width()) 376 ? (pad + GetIncognitoAvatarIcon().width())
377 : 0; 377 : 0;
378 return avatar_right + insets.right() + frame_values().normal_insets.left(); 378 return avatar_right + pad + frame_values().normal_insets.left();
379 } 379 }
380 380
381 int BrowserNonClientFrameViewMus::GetTabStripRightInset() const { 381 int BrowserNonClientFrameViewMus::GetTabStripRightInset() const {
382 const int frame_right_insets = frame_values().normal_insets.right() + 382 const int frame_right_insets = frame_values().normal_insets.right() +
383 frame_values().max_title_bar_button_width; 383 frame_values().max_title_bar_button_width;
384 int right_inset = kTabstripRightSpacing + frame_right_insets; 384 int right_inset = kTabstripRightSpacing + frame_right_insets;
385 385
386 #if defined(FRAME_AVATAR_BUTTON) 386 #if defined(FRAME_AVATAR_BUTTON)
387 if (profile_switcher_.view()) { 387 if (profile_switcher_.view()) {
388 right_inset += kAvatarButtonOffset + 388 right_inset += kAvatarButtonOffset +
(...skipping 28 matching lines...) Expand all
417 Browser::FEATURE_WEBAPPFRAME); 417 Browser::FEATURE_WEBAPPFRAME);
418 } 418 }
419 419
420 void BrowserNonClientFrameViewMus::LayoutIncognitoButton() { 420 void BrowserNonClientFrameViewMus::LayoutIncognitoButton() {
421 DCHECK(profile_indicator_icon()); 421 DCHECK(profile_indicator_icon());
422 #if !defined(OS_CHROMEOS) 422 #if !defined(OS_CHROMEOS)
423 // ChromeOS shows avatar on V1 app. 423 // ChromeOS shows avatar on V1 app.
424 DCHECK(browser_view()->IsTabStripVisible()); 424 DCHECK(browser_view()->IsTabStripVisible());
425 #endif 425 #endif
426 gfx::ImageSkia incognito_icon = GetIncognitoAvatarIcon(); 426 gfx::ImageSkia incognito_icon = GetIncognitoAvatarIcon();
427 gfx::Insets avatar_insets = GetLayoutInsets(AVATAR_ICON); 427 const int pad = GetLayoutConstant(AVATAR_ICON_PADDING);
428 int avatar_bottom = GetTopInset(false) + browser_view()->GetTabStripHeight() - 428 int avatar_bottom =
429 avatar_insets.bottom(); 429 GetTopInset(false) + browser_view()->GetTabStripHeight() - pad;
430 int avatar_y = avatar_bottom - incognito_icon.height(); 430 int avatar_y = avatar_bottom - incognito_icon.height();
431 431
432 // Hide the incognito icon in immersive fullscreen when the tab light bar is 432 // Hide the incognito icon in immersive fullscreen when the tab light bar is
433 // visible because the header is too short for the icognito icon to be 433 // visible because the header is too short for the icognito icon to be
434 // recognizable. 434 // recognizable.
435 bool avatar_visible = !UseImmersiveLightbarHeaderStyle(); 435 bool avatar_visible = !UseImmersiveLightbarHeaderStyle();
436 int avatar_height = avatar_visible ? incognito_icon.height() : 0; 436 int avatar_height = avatar_visible ? incognito_icon.height() : 0;
437 437
438 gfx::Rect avatar_bounds(avatar_insets.left(), avatar_y, 438 gfx::Rect avatar_bounds(pad, avatar_y, incognito_icon.width(), avatar_height);
439 incognito_icon.width(), avatar_height);
440 profile_indicator_icon()->SetBoundsRect(avatar_bounds); 439 profile_indicator_icon()->SetBoundsRect(avatar_bounds);
441 profile_indicator_icon()->SetVisible(avatar_visible); 440 profile_indicator_icon()->SetVisible(avatar_visible);
442 } 441 }
443 442
444 void BrowserNonClientFrameViewMus::LayoutProfileSwitcher() { 443 void BrowserNonClientFrameViewMus::LayoutProfileSwitcher() {
445 #if defined(FRAME_AVATAR_BUTTON) 444 #if defined(FRAME_AVATAR_BUTTON)
446 gfx::Size button_size = profile_switcher_.view()->GetPreferredSize(); 445 gfx::Size button_size = profile_switcher_.view()->GetPreferredSize();
447 int button_x = width() - GetTabStripRightInset() + kAvatarButtonOffset; 446 int button_x = width() - GetTabStripRightInset() + kAvatarButtonOffset;
448 profile_switcher_.view()->SetBounds(button_x, 0, button_size.width(), 447 profile_switcher_.view()->SetBounds(button_x, 0, button_size.width(),
449 button_size.height()); 448 button_size.height());
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
508 } 507 }
509 508
510 void BrowserNonClientFrameViewMus::PaintContentEdge(gfx::Canvas* canvas) { 509 void BrowserNonClientFrameViewMus::PaintContentEdge(gfx::Canvas* canvas) {
511 DCHECK(!UsePackagedAppHeaderStyle() && !UseWebAppHeaderStyle()); 510 DCHECK(!UsePackagedAppHeaderStyle() && !UseWebAppHeaderStyle());
512 const int bottom = frame_values().normal_insets.bottom(); 511 const int bottom = frame_values().normal_insets.bottom();
513 canvas->FillRect( 512 canvas->FillRect(
514 gfx::Rect(0, bottom, width(), kClientEdgeThickness), 513 gfx::Rect(0, bottom, width(), kClientEdgeThickness),
515 GetThemeProvider()->GetColor( 514 GetThemeProvider()->GetColor(
516 ThemeProperties::COLOR_TOOLBAR_BOTTOM_SEPARATOR)); 515 ThemeProperties::COLOR_TOOLBAR_BOTTOM_SEPARATOR));
517 } 516 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698