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

Side by Side Diff: chrome/browser/ui/views/tabs/tab.cc

Issue 1543963002: Refactor layout constants in preparation for adding support for Material Hybrid. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@tab_drag_height
Patch Set: Created 5 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 (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 #include "chrome/browser/ui/views/tabs/tab.h" 5 #include "chrome/browser/ui/views/tabs/tab.h"
6 6
7 #include <limits> 7 #include <limits>
8 8
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/debug/alias.h" 10 #include "base/debug/alias.h"
(...skipping 633 matching lines...) Expand 10 before | Expand all | Expand 10 after
644 // Assume the entire region to the left of the media indicator and/or close 644 // Assume the entire region to the left of the media indicator and/or close
645 // buttons is available for click-to-select. If neither are visible, the 645 // buttons is available for click-to-select. If neither are visible, the
646 // entire tab region is available. 646 // entire tab region is available.
647 const int indicator_left = showing_media_indicator_ ? 647 const int indicator_left = showing_media_indicator_ ?
648 media_indicator_button_->x() : width(); 648 media_indicator_button_->x() : width();
649 const int close_button_left = showing_close_button_ ? 649 const int close_button_left = showing_close_button_ ?
650 close_button_->x() : width(); 650 close_button_->x() : width();
651 return std::min(indicator_left, close_button_left); 651 return std::min(indicator_left, close_button_left);
652 } 652 }
653 653
654 // static
654 gfx::Size Tab::GetMinimumInactiveSize() { 655 gfx::Size Tab::GetMinimumInactiveSize() {
655 int height; 656 return gfx::Size(GetLayoutInsets(TAB).width(), GetLayoutConstant(TAB_HEIGHT));
656 if (ui::MaterialDesignController::IsModeMaterial()) {
657 const int kTabHeight = 29;
658 height = kTabHeight;
659 } else {
660 // Since we use images, the real minimum height of the image is
661 // defined most accurately by the height of the end cap images.
662 InitTabResources();
663 height = active_images_.image_l->height();
664 }
665
666 return gfx::Size(GetLayoutInsets(TAB).width(), height);
667 } 657 }
668 658
669 // static 659 // static
670 gfx::Size Tab::GetMinimumActiveSize() { 660 gfx::Size Tab::GetMinimumActiveSize() {
671 gfx::Size minimum_size = GetMinimumInactiveSize(); 661 gfx::Size minimum_size = GetMinimumInactiveSize();
672 minimum_size.Enlarge(gfx::kFaviconSize, 0); 662 minimum_size.Enlarge(gfx::kFaviconSize, 0);
673 return minimum_size; 663 return minimum_size;
674 } 664 }
675 665
676 // static 666 // static
677 gfx::Size Tab::GetStandardSize() { 667 gfx::Size Tab::GetStandardSize() {
678 gfx::Size standard_size = GetMinimumInactiveSize(); 668 const int kNetTabWidth = 193;
679 const int title_spacing = GetLayoutConstant(TAB_FAVICON_TITLE_SPACING); 669 return gfx::Size(kNetTabWidth + GetLayoutConstant(TABSTRIP_TAB_OVERLAP),
680 const int title_width = GetLayoutConstant(TAB_MAXIMUM_TITLE_WIDTH); 670 GetMinimumInactiveSize().height());
681 standard_size.Enlarge(title_spacing + title_width, 0);
682 return standard_size;
683 } 671 }
684 672
685 // static 673 // static
686 int Tab::GetTouchWidth() { 674 int Tab::GetTouchWidth() {
687 return kTouchWidth; 675 return kTouchWidth;
688 } 676 }
689 677
690 // static 678 // static
691 int Tab::GetPinnedWidth() { 679 int Tab::GetPinnedWidth() {
692 return GetMinimumInactiveSize().width() + 680 return GetMinimumInactiveSize().width() +
(...skipping 1053 matching lines...) Expand 10 before | Expand all | Expand 10 after
1746 const gfx::ImageSkia& image) { 1734 const gfx::ImageSkia& image) {
1747 DCHECK_NE(scale_factor, ui::SCALE_FACTOR_NONE); 1735 DCHECK_NE(scale_factor, ui::SCALE_FACTOR_NONE);
1748 ImageCacheEntry entry; 1736 ImageCacheEntry entry;
1749 entry.resource_id = resource_id; 1737 entry.resource_id = resource_id;
1750 entry.scale_factor = scale_factor; 1738 entry.scale_factor = scale_factor;
1751 entry.image = image; 1739 entry.image = image;
1752 image_cache_->push_front(entry); 1740 image_cache_->push_front(entry);
1753 if (image_cache_->size() > kMaxImageCacheSize) 1741 if (image_cache_->size() > kMaxImageCacheSize)
1754 image_cache_->pop_back(); 1742 image_cache_->pop_back();
1755 } 1743 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/views/frame/opaque_browser_frame_view_layout.cc ('k') | chrome/browser/ui/views/tabs/tab_strip.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698