Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 49 #include "ui/views/widget/widget.h" | 49 #include "ui/views/widget/widget.h" |
| 50 #include "ui/views/window/non_client_view.h" | 50 #include "ui/views/window/non_client_view.h" |
| 51 | 51 |
| 52 #if defined(USE_ASH) | 52 #if defined(USE_ASH) |
| 53 #include "ui/aura/env.h" | 53 #include "ui/aura/env.h" |
| 54 #endif | 54 #endif |
| 55 | 55 |
| 56 namespace { | 56 namespace { |
| 57 | 57 |
| 58 // Padding around the "content" of a tab, occupied by the tab border graphics. | 58 // Padding around the "content" of a tab, occupied by the tab border graphics. |
| 59 | 59 const int kLeftPadding = 22; |
| 60 int left_padding() { | 60 const int kTopPadding = 7; |
| 61 static int value = -1; | 61 const int kRightPadding = 17; |
| 62 if (value == -1) { | 62 const int kBottomPadding = 5; |
| 63 switch (ui::GetDisplayLayout()) { | |
| 64 case ui::LAYOUT_DESKTOP: | |
| 65 value = 22; | |
| 66 break; | |
| 67 case ui::LAYOUT_TOUCH: | |
| 68 value = 30; | |
| 69 break; | |
| 70 default: | |
| 71 NOTREACHED(); | |
| 72 } | |
| 73 } | |
| 74 return value; | |
| 75 } | |
| 76 | |
| 77 int top_padding() { | |
| 78 static int value = -1; | |
| 79 if (value == -1) { | |
| 80 switch (ui::GetDisplayLayout()) { | |
| 81 case ui::LAYOUT_DESKTOP: | |
| 82 value = 7; | |
| 83 break; | |
| 84 case ui::LAYOUT_TOUCH: | |
| 85 value = 10; | |
| 86 break; | |
| 87 default: | |
| 88 NOTREACHED(); | |
| 89 } | |
| 90 } | |
| 91 return value; | |
| 92 } | |
| 93 | |
| 94 int right_padding() { | |
| 95 static int value = -1; | |
| 96 if (value == -1) { | |
| 97 switch (ui::GetDisplayLayout()) { | |
| 98 case ui::LAYOUT_DESKTOP: | |
| 99 value = 17; | |
| 100 break; | |
| 101 case ui::LAYOUT_TOUCH: | |
| 102 value = 21; | |
| 103 break; | |
| 104 default: | |
| 105 NOTREACHED(); | |
| 106 } | |
| 107 } | |
| 108 return value; | |
| 109 } | |
| 110 | |
| 111 int bottom_padding() { | |
| 112 static int value = -1; | |
| 113 if (value == -1) { | |
| 114 switch (ui::GetDisplayLayout()) { | |
| 115 case ui::LAYOUT_DESKTOP: | |
| 116 value = 5; | |
| 117 break; | |
| 118 case ui::LAYOUT_TOUCH: | |
| 119 value = 7; | |
| 120 break; | |
| 121 default: | |
| 122 NOTREACHED(); | |
| 123 } | |
| 124 } | |
| 125 return value; | |
| 126 } | |
| 127 | 63 |
| 128 // Height of the shadow at the top of the tab image assets. | 64 // Height of the shadow at the top of the tab image assets. |
| 129 int drop_shadow_height() { | 65 const int kDropShadowHeight = 4; |
| 130 static int value = -1; | |
| 131 if (value == -1) { | |
| 132 switch (ui::GetDisplayLayout()) { | |
| 133 case ui::LAYOUT_DESKTOP: | |
| 134 value = 4; | |
| 135 break; | |
| 136 case ui::LAYOUT_TOUCH: | |
| 137 value = 5; | |
| 138 break; | |
| 139 default: | |
| 140 NOTREACHED(); | |
| 141 } | |
| 142 } | |
| 143 return value; | |
| 144 } | |
| 145 | 66 |
| 146 // Size of icon used for throbber and favicon next to tab title. | 67 // Size of icon used for throbber and favicon next to tab title. |
| 147 int tab_icon_size() { | 68 const int kTabIconSize = gfx::kFaviconSize; |
| 148 static int value = -1; | |
| 149 if (value == -1) { | |
| 150 switch (ui::GetDisplayLayout()) { | |
| 151 case ui::LAYOUT_DESKTOP: | |
| 152 value = gfx::kFaviconSize; | |
| 153 break; | |
| 154 case ui::LAYOUT_TOUCH: | |
| 155 value = 20; | |
| 156 break; | |
| 157 default: | |
| 158 NOTREACHED(); | |
| 159 } | |
| 160 } | |
| 161 return value; | |
| 162 } | |
| 163 | 69 |
| 164 // How long the pulse throb takes. | 70 // How long the pulse throb takes. |
| 165 const int kPulseDurationMs = 200; | 71 const int kPulseDurationMs = 200; |
| 166 | 72 |
| 167 // Width of touch tabs. | 73 // Width of touch tabs. |
| 168 static const int kTouchWidth = 120; | 74 static const int kTouchWidth = 120; |
| 169 | 75 |
| 170 static const int kToolbarOverlap = 1; | 76 static const int kToolbarOverlap = 1; |
| 171 static const int kFaviconTitleSpacing = 4; | 77 static const int kFaviconTitleSpacing = 4; |
| 172 // Additional vertical offset for title text relative to top of tab. | 78 // Additional vertical offset for title text relative to top of tab. |
| (...skipping 480 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 653 return; | 559 return; |
| 654 tab_animation_->Stop(); | 560 tab_animation_->Stop(); |
| 655 tab_animation_.reset(NULL); | 561 tab_animation_.reset(NULL); |
| 656 } | 562 } |
| 657 | 563 |
| 658 // static | 564 // static |
| 659 gfx::Size Tab::GetBasicMinimumUnselectedSize() { | 565 gfx::Size Tab::GetBasicMinimumUnselectedSize() { |
| 660 InitTabResources(); | 566 InitTabResources(); |
| 661 | 567 |
| 662 gfx::Size minimum_size; | 568 gfx::Size minimum_size; |
| 663 minimum_size.set_width(left_padding() + right_padding()); | 569 minimum_size.set_width(kLeftPadding + kRightPadding); |
| 664 // Since we use image images, the real minimum height of the image is | 570 // Since we use image images, the real minimum height of the image is |
| 665 // defined most accurately by the height of the end cap images. | 571 // defined most accurately by the height of the end cap images. |
| 666 minimum_size.set_height(tab_active_.image_l->height()); | 572 minimum_size.set_height(tab_active_.image_l->height()); |
| 667 return minimum_size; | 573 return minimum_size; |
| 668 } | 574 } |
| 669 | 575 |
| 670 gfx::Size Tab::GetMinimumUnselectedSize() { | 576 gfx::Size Tab::GetMinimumUnselectedSize() { |
| 671 return GetBasicMinimumUnselectedSize(); | 577 return GetBasicMinimumUnselectedSize(); |
| 672 } | 578 } |
| 673 | 579 |
| 674 // static | 580 // static |
| 675 gfx::Size Tab::GetMinimumSelectedSize() { | 581 gfx::Size Tab::GetMinimumSelectedSize() { |
| 676 gfx::Size minimum_size = GetBasicMinimumUnselectedSize(); | 582 gfx::Size minimum_size = GetBasicMinimumUnselectedSize(); |
| 677 minimum_size.set_width( | 583 minimum_size.set_width( |
| 678 left_padding() + gfx::kFaviconSize + right_padding()); | 584 kLeftPadding + gfx::kFaviconSize + kRightPadding); |
| 679 return minimum_size; | 585 return minimum_size; |
| 680 } | 586 } |
| 681 | 587 |
| 682 // static | 588 // static |
| 683 gfx::Size Tab::GetStandardSize() { | 589 gfx::Size Tab::GetStandardSize() { |
| 684 gfx::Size standard_size = GetBasicMinimumUnselectedSize(); | 590 gfx::Size standard_size = GetBasicMinimumUnselectedSize(); |
| 685 standard_size.set_width( | 591 standard_size.set_width( |
| 686 standard_size.width() + kFaviconTitleSpacing + kStandardTitleWidth); | 592 standard_size.width() + kFaviconTitleSpacing + kStandardTitleWidth); |
| 687 return standard_size; | 593 return standard_size; |
| 688 } | 594 } |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 773 | 679 |
| 774 if (!clip.IsEmpty()) | 680 if (!clip.IsEmpty()) |
| 775 canvas->Restore(); | 681 canvas->Restore(); |
| 776 } | 682 } |
| 777 | 683 |
| 778 void Tab::Layout() { | 684 void Tab::Layout() { |
| 779 gfx::Rect lb = GetContentsBounds(); | 685 gfx::Rect lb = GetContentsBounds(); |
| 780 if (lb.IsEmpty()) | 686 if (lb.IsEmpty()) |
| 781 return; | 687 return; |
| 782 lb.Inset( | 688 lb.Inset( |
| 783 left_padding(), top_padding(), right_padding(), bottom_padding()); | 689 kLeftPadding, kTopPadding, kRightPadding, kBottomPadding); |
|
sky
2014/04/24 03:29:02
nit: I think you can fit this all on one line now.
oshima
2014/04/25 14:16:26
Done.
| |
| 784 | 690 |
| 785 // The height of the content of the Tab is the largest of the favicon, | 691 // The height of the content of the Tab is the largest of the favicon, |
| 786 // the title text and the close button graphic. | 692 // the title text and the close button graphic. |
| 787 int content_height = std::max(tab_icon_size(), font_height_); | 693 int content_height = std::max(kTabIconSize, font_height_); |
| 788 close_button_->SetBorder(views::Border::NullBorder()); | 694 close_button_->SetBorder(views::Border::NullBorder()); |
| 789 gfx::Size close_button_size(close_button_->GetPreferredSize()); | 695 gfx::Size close_button_size(close_button_->GetPreferredSize()); |
| 790 content_height = std::max(content_height, close_button_size.height()); | 696 content_height = std::max(content_height, close_button_size.height()); |
| 791 | 697 |
| 792 // Size the Favicon. | 698 // Size the Favicon. |
| 793 showing_icon_ = ShouldShowIcon(); | 699 showing_icon_ = ShouldShowIcon(); |
| 794 if (showing_icon_) { | 700 if (showing_icon_) { |
| 795 // Use the size of the favicon as apps use a bigger favicon size. | 701 // Use the size of the favicon as apps use a bigger favicon size. |
| 796 int favicon_top = top_padding() + content_height / 2 - tab_icon_size() / 2; | 702 int favicon_top = kTopPadding + content_height / 2 - kTabIconSize / 2; |
| 797 int favicon_left = lb.x(); | 703 int favicon_left = lb.x(); |
| 798 favicon_bounds_.SetRect(favicon_left, favicon_top, | 704 favicon_bounds_.SetRect(favicon_left, favicon_top, |
| 799 tab_icon_size(), tab_icon_size()); | 705 kTabIconSize, kTabIconSize); |
| 800 MaybeAdjustLeftForMiniTab(&favicon_bounds_); | 706 MaybeAdjustLeftForMiniTab(&favicon_bounds_); |
| 801 } else { | 707 } else { |
| 802 favicon_bounds_.SetRect(lb.x(), lb.y(), 0, 0); | 708 favicon_bounds_.SetRect(lb.x(), lb.y(), 0, 0); |
| 803 } | 709 } |
| 804 | 710 |
| 805 // Size the Close button. | 711 // Size the Close button. |
| 806 showing_close_button_ = ShouldShowCloseBox(); | 712 showing_close_button_ = ShouldShowCloseBox(); |
| 807 const bool is_host_desktop_type_ash = | 713 const bool is_host_desktop_type_ash = |
| 808 GetHostDesktopType(this) == chrome::HOST_DESKTOP_TYPE_ASH; | 714 GetHostDesktopType(this) == chrome::HOST_DESKTOP_TYPE_ASH; |
| 809 if (showing_close_button_) { | 715 if (showing_close_button_) { |
| 810 const int close_button_vert_fuzz = is_host_desktop_type_ash ? | 716 const int close_button_vert_fuzz = is_host_desktop_type_ash ? |
| 811 kCloseButtonVertFuzzAsh : kCloseButtonVertFuzz; | 717 kCloseButtonVertFuzzAsh : kCloseButtonVertFuzz; |
| 812 int close_button_top = top_padding() + close_button_vert_fuzz + | 718 int close_button_top = kTopPadding + close_button_vert_fuzz + |
| 813 (content_height - close_button_size.height()) / 2; | 719 (content_height - close_button_size.height()) / 2; |
| 814 // If the ratio of the close button size to tab width exceeds the maximum. | 720 // If the ratio of the close button size to tab width exceeds the maximum. |
| 815 // The close button should be as large as possible so that there is a larger | 721 // The close button should be as large as possible so that there is a larger |
| 816 // hit-target for touch events. So the close button bounds extends to the | 722 // hit-target for touch events. So the close button bounds extends to the |
| 817 // edges of the tab. However, the larger hit-target should be active only | 723 // edges of the tab. However, the larger hit-target should be active only |
| 818 // for mouse events, and the close-image should show up in the right place. | 724 // for mouse events, and the close-image should show up in the right place. |
| 819 // So a border is added to the button with necessary padding. The close | 725 // So a border is added to the button with necessary padding. The close |
| 820 // button (BaseTab::TabCloseButton) makes sure the padding is a hit-target | 726 // button (BaseTab::TabCloseButton) makes sure the padding is a hit-target |
| 821 // only for touch events. | 727 // only for touch events. |
| 822 int top_border = close_button_top; | 728 int top_border = close_button_top; |
| (...skipping 11 matching lines...) Expand all Loading... | |
| 834 close_button_->SetVisible(false); | 740 close_button_->SetVisible(false); |
| 835 } | 741 } |
| 836 | 742 |
| 837 showing_media_indicator_ = ShouldShowMediaIndicator(); | 743 showing_media_indicator_ = ShouldShowMediaIndicator(); |
| 838 if (showing_media_indicator_) { | 744 if (showing_media_indicator_) { |
| 839 const gfx::Image& media_indicator_image = | 745 const gfx::Image& media_indicator_image = |
| 840 chrome::GetTabMediaIndicatorImage(animating_media_state_); | 746 chrome::GetTabMediaIndicatorImage(animating_media_state_); |
| 841 media_indicator_bounds_.set_width(media_indicator_image.Width()); | 747 media_indicator_bounds_.set_width(media_indicator_image.Width()); |
| 842 media_indicator_bounds_.set_height(media_indicator_image.Height()); | 748 media_indicator_bounds_.set_height(media_indicator_image.Height()); |
| 843 media_indicator_bounds_.set_y( | 749 media_indicator_bounds_.set_y( |
| 844 top_padding() + | 750 kTopPadding + |
| 845 (content_height - media_indicator_bounds_.height()) / 2); | 751 (content_height - media_indicator_bounds_.height()) / 2); |
| 846 const int right = showing_close_button_ ? | 752 const int right = showing_close_button_ ? |
| 847 close_button_->x() + close_button_->GetInsets().left() : lb.right(); | 753 close_button_->x() + close_button_->GetInsets().left() : lb.right(); |
| 848 media_indicator_bounds_.set_x( | 754 media_indicator_bounds_.set_x( |
| 849 std::max(lb.x(), right - media_indicator_bounds_.width())); | 755 std::max(lb.x(), right - media_indicator_bounds_.width())); |
| 850 MaybeAdjustLeftForMiniTab(&media_indicator_bounds_); | 756 MaybeAdjustLeftForMiniTab(&media_indicator_bounds_); |
| 851 } else { | 757 } else { |
| 852 media_indicator_bounds_.SetRect(lb.x(), lb.y(), 0, 0); | 758 media_indicator_bounds_.SetRect(lb.x(), lb.y(), 0, 0); |
| 853 } | 759 } |
| 854 | 760 |
| 855 const int title_text_offset = is_host_desktop_type_ash ? | 761 const int title_text_offset = is_host_desktop_type_ash ? |
| 856 kTitleTextOffsetYAsh : kTitleTextOffsetY; | 762 kTitleTextOffsetYAsh : kTitleTextOffsetY; |
| 857 int title_left = favicon_bounds_.right() + kFaviconTitleSpacing; | 763 int title_left = favicon_bounds_.right() + kFaviconTitleSpacing; |
| 858 int title_top = top_padding() + title_text_offset + | 764 int title_top = kTopPadding + title_text_offset + |
| 859 (content_height - font_height_) / 2; | 765 (content_height - font_height_) / 2; |
| 860 // Size the Title text to fill the remaining space. | 766 // Size the Title text to fill the remaining space. |
| 861 if (!data().mini || width() >= kMiniTabRendererAsNormalTabWidth) { | 767 if (!data().mini || width() >= kMiniTabRendererAsNormalTabWidth) { |
| 862 // If the user has big fonts, the title will appear rendered too far down | 768 // If the user has big fonts, the title will appear rendered too far down |
| 863 // on the y-axis if we use the regular top padding, so we need to adjust it | 769 // on the y-axis if we use the regular top padding, so we need to adjust it |
| 864 // so that the text appears centered. | 770 // so that the text appears centered. |
| 865 gfx::Size minimum_size = GetMinimumUnselectedSize(); | 771 gfx::Size minimum_size = GetMinimumUnselectedSize(); |
| 866 int text_height = title_top + font_height_ + bottom_padding(); | 772 int text_height = title_top + font_height_ + kBottomPadding; |
| 867 if (text_height > minimum_size.height()) | 773 if (text_height > minimum_size.height()) |
| 868 title_top -= (text_height - minimum_size.height()) / 2; | 774 title_top -= (text_height - minimum_size.height()) / 2; |
| 869 | 775 |
| 870 int title_width; | 776 int title_width; |
| 871 if (showing_media_indicator_) { | 777 if (showing_media_indicator_) { |
| 872 title_width = media_indicator_bounds_.x() - kTitleCloseButtonSpacing - | 778 title_width = media_indicator_bounds_.x() - kTitleCloseButtonSpacing - |
| 873 title_left; | 779 title_left; |
| 874 } else if (close_button_->visible()) { | 780 } else if (close_button_->visible()) { |
| 875 // The close button has an empty border with some padding (see details | 781 // The close button has an empty border with some padding (see details |
| 876 // above where the close-button's bounds is set). Allow the title to | 782 // above where the close-button's bounds is set). Allow the title to |
| (...skipping 478 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1355 background_canvas.DrawImageInt(theme_r, | 1261 background_canvas.DrawImageInt(theme_r, |
| 1356 0, 0, theme_r.width(), theme_r.height() - kToolbarOverlap, | 1262 0, 0, theme_r.width(), theme_r.height() - kToolbarOverlap, |
| 1357 width() - theme_r.width(), 0, theme_r.width(), | 1263 width() - theme_r.width(), 0, theme_r.width(), |
| 1358 theme_r.height() - kToolbarOverlap, false); | 1264 theme_r.height() - kToolbarOverlap, false); |
| 1359 | 1265 |
| 1360 // Draw center. Instead of masking out the top portion we simply skip over | 1266 // Draw center. Instead of masking out the top portion we simply skip over |
| 1361 // it by incrementing by GetDropShadowHeight(), since it's a simple | 1267 // it by incrementing by GetDropShadowHeight(), since it's a simple |
| 1362 // rectangle. And again, don't draw over the toolbar. | 1268 // rectangle. And again, don't draw over the toolbar. |
| 1363 background_canvas.TileImageInt(*tab_bg, | 1269 background_canvas.TileImageInt(*tab_bg, |
| 1364 offset + tab_image->l_width, | 1270 offset + tab_image->l_width, |
| 1365 bg_offset_y + drop_shadow_height(), | 1271 bg_offset_y + kDropShadowHeight, |
| 1366 tab_image->l_width, | 1272 tab_image->l_width, |
| 1367 drop_shadow_height(), | 1273 kDropShadowHeight, |
| 1368 width() - tab_image->l_width - tab_image->r_width, | 1274 width() - tab_image->l_width - tab_image->r_width, |
| 1369 height() - drop_shadow_height() - kToolbarOverlap); | 1275 height() - kDropShadowHeight - kToolbarOverlap); |
| 1370 | 1276 |
| 1371 canvas->DrawImageInt( | 1277 canvas->DrawImageInt( |
| 1372 gfx::ImageSkia(background_canvas.ExtractImageRep()), 0, 0); | 1278 gfx::ImageSkia(background_canvas.ExtractImageRep()), 0, 0); |
| 1373 | 1279 |
| 1374 if (!GetThemeProvider()->HasCustomImage(tab_id) && | 1280 if (!GetThemeProvider()->HasCustomImage(tab_id) && |
| 1375 hover_controller_.ShouldDraw()) { | 1281 hover_controller_.ShouldDraw()) { |
| 1376 hover_controller_.Draw(canvas, gfx::ImageSkia( | 1282 hover_controller_.Draw(canvas, gfx::ImageSkia( |
| 1377 background_canvas.ExtractImageRep())); | 1283 background_canvas.ExtractImageRep())); |
| 1378 } | 1284 } |
| 1379 | 1285 |
| (...skipping 28 matching lines...) Expand all Loading... | |
| 1408 *tab_background, | 1314 *tab_background, |
| 1409 offset + width() - tab_image->r_width, 0, tab_image->r_width, height()); | 1315 offset + width() - tab_image->r_width, 0, tab_image->r_width, height()); |
| 1410 gfx::ImageSkia theme_r = | 1316 gfx::ImageSkia theme_r = |
| 1411 gfx::ImageSkiaOperations::CreateMaskedImage(tab_r, *alpha->image_r); | 1317 gfx::ImageSkiaOperations::CreateMaskedImage(tab_r, *alpha->image_r); |
| 1412 canvas->DrawImageInt(theme_r, width() - tab_image->r_width, 0); | 1318 canvas->DrawImageInt(theme_r, width() - tab_image->r_width, 0); |
| 1413 | 1319 |
| 1414 // Draw center. Instead of masking out the top portion we simply skip over it | 1320 // Draw center. Instead of masking out the top portion we simply skip over it |
| 1415 // by incrementing by GetDropShadowHeight(), since it's a simple rectangle. | 1321 // by incrementing by GetDropShadowHeight(), since it's a simple rectangle. |
| 1416 canvas->TileImageInt(*tab_background, | 1322 canvas->TileImageInt(*tab_background, |
| 1417 offset + tab_image->l_width, | 1323 offset + tab_image->l_width, |
| 1418 drop_shadow_height(), | 1324 kDropShadowHeight, |
| 1419 tab_image->l_width, | 1325 tab_image->l_width, |
| 1420 drop_shadow_height(), | 1326 kDropShadowHeight, |
| 1421 width() - tab_image->l_width - tab_image->r_width, | 1327 width() - tab_image->l_width - tab_image->r_width, |
| 1422 height() - drop_shadow_height()); | 1328 height() - kDropShadowHeight); |
| 1423 | 1329 |
| 1424 // Now draw the highlights/shadows around the tab edge. | 1330 // Now draw the highlights/shadows around the tab edge. |
| 1425 canvas->DrawImageInt(*tab_image->image_l, 0, 0); | 1331 canvas->DrawImageInt(*tab_image->image_l, 0, 0); |
| 1426 canvas->TileImageInt(*tab_image->image_c, tab_image->l_width, 0, | 1332 canvas->TileImageInt(*tab_image->image_c, tab_image->l_width, 0, |
| 1427 width() - tab_image->l_width - tab_image->r_width, height()); | 1333 width() - tab_image->l_width - tab_image->r_width, height()); |
| 1428 canvas->DrawImageInt(*tab_image->image_r, width() - tab_image->r_width, 0); | 1334 canvas->DrawImageInt(*tab_image->image_r, width() - tab_image->r_width, 0); |
| 1429 } | 1335 } |
| 1430 | 1336 |
| 1431 void Tab::PaintIcon(gfx::Canvas* canvas) { | 1337 void Tab::PaintIcon(gfx::Canvas* canvas) { |
| 1432 gfx::Rect bounds = GetIconBounds(); | 1338 gfx::Rect bounds = GetIconBounds(); |
| (...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1558 if (controller_->IsImmersiveStyle()) | 1464 if (controller_->IsImmersiveStyle()) |
| 1559 SchedulePaintInRect(GetImmersiveBarRect()); | 1465 SchedulePaintInRect(GetImmersiveBarRect()); |
| 1560 else | 1466 else |
| 1561 ScheduleIconPaint(); | 1467 ScheduleIconPaint(); |
| 1562 } | 1468 } |
| 1563 | 1469 |
| 1564 int Tab::IconCapacity() const { | 1470 int Tab::IconCapacity() const { |
| 1565 if (height() < GetMinimumUnselectedSize().height()) | 1471 if (height() < GetMinimumUnselectedSize().height()) |
| 1566 return 0; | 1472 return 0; |
| 1567 const int available_width = | 1473 const int available_width = |
| 1568 std::max(0, width() - left_padding() - right_padding()); | 1474 std::max(0, width() - kLeftPadding - kRightPadding); |
| 1569 const int width_per_icon = tab_icon_size(); | 1475 const int width_per_icon = kTabIconSize; |
| 1570 const int kPaddingBetweenIcons = 2; | 1476 const int kPaddingBetweenIcons = 2; |
| 1571 if (available_width >= width_per_icon && | 1477 if (available_width >= width_per_icon && |
| 1572 available_width < (width_per_icon + kPaddingBetweenIcons)) { | 1478 available_width < (width_per_icon + kPaddingBetweenIcons)) { |
| 1573 return 1; | 1479 return 1; |
| 1574 } | 1480 } |
| 1575 return available_width / (width_per_icon + kPaddingBetweenIcons); | 1481 return available_width / (width_per_icon + kPaddingBetweenIcons); |
| 1576 } | 1482 } |
| 1577 | 1483 |
| 1578 bool Tab::ShouldShowIcon() const { | 1484 bool Tab::ShouldShowIcon() const { |
| 1579 return chrome::ShouldTabShowFavicon( | 1485 return chrome::ShouldTabShowFavicon( |
| (...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1745 const gfx::ImageSkia& image) { | 1651 const gfx::ImageSkia& image) { |
| 1746 DCHECK_NE(scale_factor, ui::SCALE_FACTOR_NONE); | 1652 DCHECK_NE(scale_factor, ui::SCALE_FACTOR_NONE); |
| 1747 ImageCacheEntry entry; | 1653 ImageCacheEntry entry; |
| 1748 entry.resource_id = resource_id; | 1654 entry.resource_id = resource_id; |
| 1749 entry.scale_factor = scale_factor; | 1655 entry.scale_factor = scale_factor; |
| 1750 entry.image = image; | 1656 entry.image = image; |
| 1751 image_cache_->push_front(entry); | 1657 image_cache_->push_front(entry); |
| 1752 if (image_cache_->size() > kMaxImageCacheSize) | 1658 if (image_cache_->size() > kMaxImageCacheSize) |
| 1753 image_cache_->pop_back(); | 1659 image_cache_->pop_back(); |
| 1754 } | 1660 } |
| OLD | NEW |