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" |
| 11 #include "base/strings/utf_string_conversions.h" | 11 #include "base/strings/utf_string_conversions.h" |
| 12 #include "chrome/browser/defaults.h" | 12 #include "chrome/browser/defaults.h" |
| 13 #include "chrome/browser/themes/theme_properties.h" | 13 #include "chrome/browser/themes/theme_properties.h" |
| 14 #include "chrome/browser/ui/browser.h" | 14 #include "chrome/browser/ui/browser.h" |
| 15 #include "chrome/browser/ui/tab_contents/core_tab_helper.h" | 15 #include "chrome/browser/ui/tab_contents/core_tab_helper.h" |
| 16 #include "chrome/browser/ui/tabs/tab_resources.h" | 16 #include "chrome/browser/ui/tabs/tab_resources.h" |
| 17 #include "chrome/browser/ui/tabs/tab_utils.h" | 17 #include "chrome/browser/ui/tabs/tab_utils.h" |
| 18 #include "chrome/browser/ui/view_ids.h" | 18 #include "chrome/browser/ui/view_ids.h" |
| 19 #include "chrome/browser/ui/views/tabs/tab_controller.h" | 19 #include "chrome/browser/ui/views/tabs/tab_controller.h" |
| 20 #include "chrome/browser/ui/views/theme_image_mapper.h" | 20 #include "chrome/browser/ui/views/theme_image_mapper.h" |
| 21 #include "chrome/browser/ui/views/touch_uma/touch_uma.h" | 21 #include "chrome/browser/ui/views/touch_uma/touch_uma.h" |
| 22 #include "chrome/common/chrome_switches.h" | 22 #include "chrome/common/chrome_switches.h" |
| 23 #include "grit/generated_resources.h" | 23 #include "grit/generated_resources.h" |
| 24 #include "grit/theme_resources.h" | 24 #include "grit/theme_resources.h" |
| 25 #include "grit/ui_resources.h" | 25 #include "grit/ui_resources.h" |
| 26 #include "third_party/skia/include/effects/SkGradientShader.h" | 26 #include "third_party/skia/include/effects/SkGradientShader.h" |
| 27 #include "ui/accessibility/ax_view_state.h" | 27 #include "ui/accessibility/ax_view_state.h" |
| 28 #include "ui/base/l10n/l10n_util.h" | 28 #include "ui/base/l10n/l10n_util.h" |
| 29 #include "ui/base/layout.h" | |
| 30 #include "ui/base/models/list_selection_model.h" | 29 #include "ui/base/models/list_selection_model.h" |
| 31 #include "ui/base/resource/resource_bundle.h" | 30 #include "ui/base/resource/resource_bundle.h" |
| 32 #include "ui/base/theme_provider.h" | 31 #include "ui/base/theme_provider.h" |
| 33 #include "ui/gfx/animation/animation_container.h" | 32 #include "ui/gfx/animation/animation_container.h" |
| 34 #include "ui/gfx/animation/multi_animation.h" | 33 #include "ui/gfx/animation/multi_animation.h" |
| 35 #include "ui/gfx/animation/throb_animation.h" | 34 #include "ui/gfx/animation/throb_animation.h" |
| 36 #include "ui/gfx/canvas.h" | 35 #include "ui/gfx/canvas.h" |
| 37 #include "ui/gfx/color_analysis.h" | 36 #include "ui/gfx/color_analysis.h" |
| 38 #include "ui/gfx/favicon_size.h" | 37 #include "ui/gfx/favicon_size.h" |
| 39 #include "ui/gfx/font.h" | 38 #include "ui/gfx/font.h" |
| 40 #include "ui/gfx/image/image_skia_operations.h" | 39 #include "ui/gfx/image/image_skia_operations.h" |
| 41 #include "ui/gfx/path.h" | 40 #include "ui/gfx/path.h" |
| 42 #include "ui/gfx/rect_conversions.h" | 41 #include "ui/gfx/rect_conversions.h" |
| 43 #include "ui/gfx/skia_util.h" | 42 #include "ui/gfx/skia_util.h" |
| 44 #include "ui/gfx/text_elider.h" | 43 #include "ui/gfx/text_elider.h" |
| 45 #include "ui/views/border.h" | 44 #include "ui/views/border.h" |
| 46 #include "ui/views/controls/button/image_button.h" | 45 #include "ui/views/controls/button/image_button.h" |
| 47 #include "ui/views/rect_based_targeting_utils.h" | 46 #include "ui/views/rect_based_targeting_utils.h" |
| 48 #include "ui/views/widget/tooltip_manager.h" | 47 #include "ui/views/widget/tooltip_manager.h" |
| 49 #include "ui/views/widget/widget.h" | 48 #include "ui/views/widget/widget.h" |
| 50 #include "ui/views/window/non_client_view.h" | 49 #include "ui/views/window/non_client_view.h" |
| 51 | 50 |
| 52 #if defined(USE_ASH) | 51 #if defined(USE_ASH) |
| 53 #include "ui/aura/env.h" | 52 #include "ui/aura/env.h" |
| 54 #endif | 53 #endif |
| 55 | 54 |
| 56 namespace { | 55 namespace { |
| 57 | 56 |
| 58 // Padding around the "content" of a tab, occupied by the tab border graphics. | 57 // Padding around the "content" of a tab, occupied by the tab border graphics. |
| 59 | 58 const int kLeftPadding = 22; |
| 60 int left_padding() { | 59 const int kTopPadding = 7; |
| 61 static int value = -1; | 60 const int kRightPadding = 17; |
| 62 if (value == -1) { | 61 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 | 62 |
| 128 // Height of the shadow at the top of the tab image assets. | 63 // Height of the shadow at the top of the tab image assets. |
| 129 int drop_shadow_height() { | 64 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 | 65 |
| 146 // Size of icon used for throbber and favicon next to tab title. | 66 // Size of icon used for throbber and favicon next to tab title. |
| 147 int tab_icon_size() { | 67 const int kTabIconSize = gfx::kFaviconSize; |
|
Dan Beam
2014/04/26 03:43:32
^ this added a static initializer, but I have no i
oshima
2014/04/26 03:52:57
ah, I guess it's because it's value is defined in
Dan Beam
2014/04/26 03:56:09
this isn't great but it'll keep the rev landed and
| |
| 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 | 68 |
| 164 // How long the pulse throb takes. | 69 // How long the pulse throb takes. |
| 165 const int kPulseDurationMs = 200; | 70 const int kPulseDurationMs = 200; |
| 166 | 71 |
| 167 // Width of touch tabs. | 72 // Width of touch tabs. |
| 168 static const int kTouchWidth = 120; | 73 static const int kTouchWidth = 120; |
| 169 | 74 |
| 170 static const int kToolbarOverlap = 1; | 75 static const int kToolbarOverlap = 1; |
| 171 static const int kFaviconTitleSpacing = 4; | 76 static const int kFaviconTitleSpacing = 4; |
| 172 // Additional vertical offset for title text relative to top of tab. | 77 // 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; | 558 return; |
| 654 tab_animation_->Stop(); | 559 tab_animation_->Stop(); |
| 655 tab_animation_.reset(NULL); | 560 tab_animation_.reset(NULL); |
| 656 } | 561 } |
| 657 | 562 |
| 658 // static | 563 // static |
| 659 gfx::Size Tab::GetBasicMinimumUnselectedSize() { | 564 gfx::Size Tab::GetBasicMinimumUnselectedSize() { |
| 660 InitTabResources(); | 565 InitTabResources(); |
| 661 | 566 |
| 662 gfx::Size minimum_size; | 567 gfx::Size minimum_size; |
| 663 minimum_size.set_width(left_padding() + right_padding()); | 568 minimum_size.set_width(kLeftPadding + kRightPadding); |
| 664 // Since we use image images, the real minimum height of the image is | 569 // 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. | 570 // defined most accurately by the height of the end cap images. |
| 666 minimum_size.set_height(tab_active_.image_l->height()); | 571 minimum_size.set_height(tab_active_.image_l->height()); |
| 667 return minimum_size; | 572 return minimum_size; |
| 668 } | 573 } |
| 669 | 574 |
| 670 gfx::Size Tab::GetMinimumUnselectedSize() { | 575 gfx::Size Tab::GetMinimumUnselectedSize() { |
| 671 return GetBasicMinimumUnselectedSize(); | 576 return GetBasicMinimumUnselectedSize(); |
| 672 } | 577 } |
| 673 | 578 |
| 674 // static | 579 // static |
| 675 gfx::Size Tab::GetMinimumSelectedSize() { | 580 gfx::Size Tab::GetMinimumSelectedSize() { |
| 676 gfx::Size minimum_size = GetBasicMinimumUnselectedSize(); | 581 gfx::Size minimum_size = GetBasicMinimumUnselectedSize(); |
| 677 minimum_size.set_width( | 582 minimum_size.set_width( |
| 678 left_padding() + gfx::kFaviconSize + right_padding()); | 583 kLeftPadding + gfx::kFaviconSize + kRightPadding); |
| 679 return minimum_size; | 584 return minimum_size; |
| 680 } | 585 } |
| 681 | 586 |
| 682 // static | 587 // static |
| 683 gfx::Size Tab::GetStandardSize() { | 588 gfx::Size Tab::GetStandardSize() { |
| 684 gfx::Size standard_size = GetBasicMinimumUnselectedSize(); | 589 gfx::Size standard_size = GetBasicMinimumUnselectedSize(); |
| 685 standard_size.set_width( | 590 standard_size.set_width( |
| 686 standard_size.width() + kFaviconTitleSpacing + kStandardTitleWidth); | 591 standard_size.width() + kFaviconTitleSpacing + kStandardTitleWidth); |
| 687 return standard_size; | 592 return standard_size; |
| 688 } | 593 } |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 772 PaintTab(canvas); | 677 PaintTab(canvas); |
| 773 | 678 |
| 774 if (!clip.IsEmpty()) | 679 if (!clip.IsEmpty()) |
| 775 canvas->Restore(); | 680 canvas->Restore(); |
| 776 } | 681 } |
| 777 | 682 |
| 778 void Tab::Layout() { | 683 void Tab::Layout() { |
| 779 gfx::Rect lb = GetContentsBounds(); | 684 gfx::Rect lb = GetContentsBounds(); |
| 780 if (lb.IsEmpty()) | 685 if (lb.IsEmpty()) |
| 781 return; | 686 return; |
| 782 lb.Inset( | 687 lb.Inset(kLeftPadding, kTopPadding, kRightPadding, kBottomPadding); |
| 783 left_padding(), top_padding(), right_padding(), bottom_padding()); | |
| 784 | 688 |
| 785 // The height of the content of the Tab is the largest of the favicon, | 689 // The height of the content of the Tab is the largest of the favicon, |
| 786 // the title text and the close button graphic. | 690 // the title text and the close button graphic. |
| 787 int content_height = std::max(tab_icon_size(), font_height_); | 691 int content_height = std::max(kTabIconSize, font_height_); |
| 788 close_button_->SetBorder(views::Border::NullBorder()); | 692 close_button_->SetBorder(views::Border::NullBorder()); |
| 789 gfx::Size close_button_size(close_button_->GetPreferredSize()); | 693 gfx::Size close_button_size(close_button_->GetPreferredSize()); |
| 790 content_height = std::max(content_height, close_button_size.height()); | 694 content_height = std::max(content_height, close_button_size.height()); |
| 791 | 695 |
| 792 // Size the Favicon. | 696 // Size the Favicon. |
| 793 showing_icon_ = ShouldShowIcon(); | 697 showing_icon_ = ShouldShowIcon(); |
| 794 if (showing_icon_) { | 698 if (showing_icon_) { |
| 795 // Use the size of the favicon as apps use a bigger favicon size. | 699 // 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; | 700 int favicon_top = kTopPadding + content_height / 2 - kTabIconSize / 2; |
| 797 int favicon_left = lb.x(); | 701 int favicon_left = lb.x(); |
| 798 favicon_bounds_.SetRect(favicon_left, favicon_top, | 702 favicon_bounds_.SetRect(favicon_left, favicon_top, |
| 799 tab_icon_size(), tab_icon_size()); | 703 kTabIconSize, kTabIconSize); |
| 800 MaybeAdjustLeftForMiniTab(&favicon_bounds_); | 704 MaybeAdjustLeftForMiniTab(&favicon_bounds_); |
| 801 } else { | 705 } else { |
| 802 favicon_bounds_.SetRect(lb.x(), lb.y(), 0, 0); | 706 favicon_bounds_.SetRect(lb.x(), lb.y(), 0, 0); |
| 803 } | 707 } |
| 804 | 708 |
| 805 // Size the Close button. | 709 // Size the Close button. |
| 806 showing_close_button_ = ShouldShowCloseBox(); | 710 showing_close_button_ = ShouldShowCloseBox(); |
| 807 const bool is_host_desktop_type_ash = | 711 const bool is_host_desktop_type_ash = |
| 808 GetHostDesktopType(this) == chrome::HOST_DESKTOP_TYPE_ASH; | 712 GetHostDesktopType(this) == chrome::HOST_DESKTOP_TYPE_ASH; |
| 809 if (showing_close_button_) { | 713 if (showing_close_button_) { |
| 810 const int close_button_vert_fuzz = is_host_desktop_type_ash ? | 714 const int close_button_vert_fuzz = is_host_desktop_type_ash ? |
| 811 kCloseButtonVertFuzzAsh : kCloseButtonVertFuzz; | 715 kCloseButtonVertFuzzAsh : kCloseButtonVertFuzz; |
| 812 int close_button_top = top_padding() + close_button_vert_fuzz + | 716 int close_button_top = kTopPadding + close_button_vert_fuzz + |
| 813 (content_height - close_button_size.height()) / 2; | 717 (content_height - close_button_size.height()) / 2; |
| 814 // If the ratio of the close button size to tab width exceeds the maximum. | 718 // 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 | 719 // 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 | 720 // 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 | 721 // 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. | 722 // 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 | 723 // 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 | 724 // button (BaseTab::TabCloseButton) makes sure the padding is a hit-target |
| 821 // only for touch events. | 725 // only for touch events. |
| 822 int top_border = close_button_top; | 726 int top_border = close_button_top; |
| (...skipping 11 matching lines...) Expand all Loading... | |
| 834 close_button_->SetVisible(false); | 738 close_button_->SetVisible(false); |
| 835 } | 739 } |
| 836 | 740 |
| 837 showing_media_indicator_ = ShouldShowMediaIndicator(); | 741 showing_media_indicator_ = ShouldShowMediaIndicator(); |
| 838 if (showing_media_indicator_) { | 742 if (showing_media_indicator_) { |
| 839 const gfx::Image& media_indicator_image = | 743 const gfx::Image& media_indicator_image = |
| 840 chrome::GetTabMediaIndicatorImage(animating_media_state_); | 744 chrome::GetTabMediaIndicatorImage(animating_media_state_); |
| 841 media_indicator_bounds_.set_width(media_indicator_image.Width()); | 745 media_indicator_bounds_.set_width(media_indicator_image.Width()); |
| 842 media_indicator_bounds_.set_height(media_indicator_image.Height()); | 746 media_indicator_bounds_.set_height(media_indicator_image.Height()); |
| 843 media_indicator_bounds_.set_y( | 747 media_indicator_bounds_.set_y( |
| 844 top_padding() + | 748 kTopPadding + |
| 845 (content_height - media_indicator_bounds_.height()) / 2); | 749 (content_height - media_indicator_bounds_.height()) / 2); |
| 846 const int right = showing_close_button_ ? | 750 const int right = showing_close_button_ ? |
| 847 close_button_->x() + close_button_->GetInsets().left() : lb.right(); | 751 close_button_->x() + close_button_->GetInsets().left() : lb.right(); |
| 848 media_indicator_bounds_.set_x( | 752 media_indicator_bounds_.set_x( |
| 849 std::max(lb.x(), right - media_indicator_bounds_.width())); | 753 std::max(lb.x(), right - media_indicator_bounds_.width())); |
| 850 MaybeAdjustLeftForMiniTab(&media_indicator_bounds_); | 754 MaybeAdjustLeftForMiniTab(&media_indicator_bounds_); |
| 851 } else { | 755 } else { |
| 852 media_indicator_bounds_.SetRect(lb.x(), lb.y(), 0, 0); | 756 media_indicator_bounds_.SetRect(lb.x(), lb.y(), 0, 0); |
| 853 } | 757 } |
| 854 | 758 |
| 855 const int title_text_offset = is_host_desktop_type_ash ? | 759 const int title_text_offset = is_host_desktop_type_ash ? |
| 856 kTitleTextOffsetYAsh : kTitleTextOffsetY; | 760 kTitleTextOffsetYAsh : kTitleTextOffsetY; |
| 857 int title_left = favicon_bounds_.right() + kFaviconTitleSpacing; | 761 int title_left = favicon_bounds_.right() + kFaviconTitleSpacing; |
| 858 int title_top = top_padding() + title_text_offset + | 762 int title_top = kTopPadding + title_text_offset + |
| 859 (content_height - font_height_) / 2; | 763 (content_height - font_height_) / 2; |
| 860 // Size the Title text to fill the remaining space. | 764 // Size the Title text to fill the remaining space. |
| 861 if (!data().mini || width() >= kMiniTabRendererAsNormalTabWidth) { | 765 if (!data().mini || width() >= kMiniTabRendererAsNormalTabWidth) { |
| 862 // If the user has big fonts, the title will appear rendered too far down | 766 // 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 | 767 // on the y-axis if we use the regular top padding, so we need to adjust it |
| 864 // so that the text appears centered. | 768 // so that the text appears centered. |
| 865 gfx::Size minimum_size = GetMinimumUnselectedSize(); | 769 gfx::Size minimum_size = GetMinimumUnselectedSize(); |
| 866 int text_height = title_top + font_height_ + bottom_padding(); | 770 int text_height = title_top + font_height_ + kBottomPadding; |
| 867 if (text_height > minimum_size.height()) | 771 if (text_height > minimum_size.height()) |
| 868 title_top -= (text_height - minimum_size.height()) / 2; | 772 title_top -= (text_height - minimum_size.height()) / 2; |
| 869 | 773 |
| 870 int title_width; | 774 int title_width; |
| 871 if (showing_media_indicator_) { | 775 if (showing_media_indicator_) { |
| 872 title_width = media_indicator_bounds_.x() - kTitleCloseButtonSpacing - | 776 title_width = media_indicator_bounds_.x() - kTitleCloseButtonSpacing - |
| 873 title_left; | 777 title_left; |
| 874 } else if (close_button_->visible()) { | 778 } else if (close_button_->visible()) { |
| 875 // The close button has an empty border with some padding (see details | 779 // 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 | 780 // 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, | 1259 background_canvas.DrawImageInt(theme_r, |
| 1356 0, 0, theme_r.width(), theme_r.height() - kToolbarOverlap, | 1260 0, 0, theme_r.width(), theme_r.height() - kToolbarOverlap, |
| 1357 width() - theme_r.width(), 0, theme_r.width(), | 1261 width() - theme_r.width(), 0, theme_r.width(), |
| 1358 theme_r.height() - kToolbarOverlap, false); | 1262 theme_r.height() - kToolbarOverlap, false); |
| 1359 | 1263 |
| 1360 // Draw center. Instead of masking out the top portion we simply skip over | 1264 // Draw center. Instead of masking out the top portion we simply skip over |
| 1361 // it by incrementing by GetDropShadowHeight(), since it's a simple | 1265 // it by incrementing by GetDropShadowHeight(), since it's a simple |
| 1362 // rectangle. And again, don't draw over the toolbar. | 1266 // rectangle. And again, don't draw over the toolbar. |
| 1363 background_canvas.TileImageInt(*tab_bg, | 1267 background_canvas.TileImageInt(*tab_bg, |
| 1364 offset + tab_image->l_width, | 1268 offset + tab_image->l_width, |
| 1365 bg_offset_y + drop_shadow_height(), | 1269 bg_offset_y + kDropShadowHeight, |
| 1366 tab_image->l_width, | 1270 tab_image->l_width, |
| 1367 drop_shadow_height(), | 1271 kDropShadowHeight, |
| 1368 width() - tab_image->l_width - tab_image->r_width, | 1272 width() - tab_image->l_width - tab_image->r_width, |
| 1369 height() - drop_shadow_height() - kToolbarOverlap); | 1273 height() - kDropShadowHeight - kToolbarOverlap); |
| 1370 | 1274 |
| 1371 canvas->DrawImageInt( | 1275 canvas->DrawImageInt( |
| 1372 gfx::ImageSkia(background_canvas.ExtractImageRep()), 0, 0); | 1276 gfx::ImageSkia(background_canvas.ExtractImageRep()), 0, 0); |
| 1373 | 1277 |
| 1374 if (!GetThemeProvider()->HasCustomImage(tab_id) && | 1278 if (!GetThemeProvider()->HasCustomImage(tab_id) && |
| 1375 hover_controller_.ShouldDraw()) { | 1279 hover_controller_.ShouldDraw()) { |
| 1376 hover_controller_.Draw(canvas, gfx::ImageSkia( | 1280 hover_controller_.Draw(canvas, gfx::ImageSkia( |
| 1377 background_canvas.ExtractImageRep())); | 1281 background_canvas.ExtractImageRep())); |
| 1378 } | 1282 } |
| 1379 | 1283 |
| (...skipping 28 matching lines...) Expand all Loading... | |
| 1408 *tab_background, | 1312 *tab_background, |
| 1409 offset + width() - tab_image->r_width, 0, tab_image->r_width, height()); | 1313 offset + width() - tab_image->r_width, 0, tab_image->r_width, height()); |
| 1410 gfx::ImageSkia theme_r = | 1314 gfx::ImageSkia theme_r = |
| 1411 gfx::ImageSkiaOperations::CreateMaskedImage(tab_r, *alpha->image_r); | 1315 gfx::ImageSkiaOperations::CreateMaskedImage(tab_r, *alpha->image_r); |
| 1412 canvas->DrawImageInt(theme_r, width() - tab_image->r_width, 0); | 1316 canvas->DrawImageInt(theme_r, width() - tab_image->r_width, 0); |
| 1413 | 1317 |
| 1414 // Draw center. Instead of masking out the top portion we simply skip over it | 1318 // 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. | 1319 // by incrementing by GetDropShadowHeight(), since it's a simple rectangle. |
| 1416 canvas->TileImageInt(*tab_background, | 1320 canvas->TileImageInt(*tab_background, |
| 1417 offset + tab_image->l_width, | 1321 offset + tab_image->l_width, |
| 1418 drop_shadow_height(), | 1322 kDropShadowHeight, |
| 1419 tab_image->l_width, | 1323 tab_image->l_width, |
| 1420 drop_shadow_height(), | 1324 kDropShadowHeight, |
| 1421 width() - tab_image->l_width - tab_image->r_width, | 1325 width() - tab_image->l_width - tab_image->r_width, |
| 1422 height() - drop_shadow_height()); | 1326 height() - kDropShadowHeight); |
| 1423 | 1327 |
| 1424 // Now draw the highlights/shadows around the tab edge. | 1328 // Now draw the highlights/shadows around the tab edge. |
| 1425 canvas->DrawImageInt(*tab_image->image_l, 0, 0); | 1329 canvas->DrawImageInt(*tab_image->image_l, 0, 0); |
| 1426 canvas->TileImageInt(*tab_image->image_c, tab_image->l_width, 0, | 1330 canvas->TileImageInt(*tab_image->image_c, tab_image->l_width, 0, |
| 1427 width() - tab_image->l_width - tab_image->r_width, height()); | 1331 width() - tab_image->l_width - tab_image->r_width, height()); |
| 1428 canvas->DrawImageInt(*tab_image->image_r, width() - tab_image->r_width, 0); | 1332 canvas->DrawImageInt(*tab_image->image_r, width() - tab_image->r_width, 0); |
| 1429 } | 1333 } |
| 1430 | 1334 |
| 1431 void Tab::PaintIcon(gfx::Canvas* canvas) { | 1335 void Tab::PaintIcon(gfx::Canvas* canvas) { |
| 1432 gfx::Rect bounds = GetIconBounds(); | 1336 gfx::Rect bounds = GetIconBounds(); |
| (...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1558 if (controller_->IsImmersiveStyle()) | 1462 if (controller_->IsImmersiveStyle()) |
| 1559 SchedulePaintInRect(GetImmersiveBarRect()); | 1463 SchedulePaintInRect(GetImmersiveBarRect()); |
| 1560 else | 1464 else |
| 1561 ScheduleIconPaint(); | 1465 ScheduleIconPaint(); |
| 1562 } | 1466 } |
| 1563 | 1467 |
| 1564 int Tab::IconCapacity() const { | 1468 int Tab::IconCapacity() const { |
| 1565 if (height() < GetMinimumUnselectedSize().height()) | 1469 if (height() < GetMinimumUnselectedSize().height()) |
| 1566 return 0; | 1470 return 0; |
| 1567 const int available_width = | 1471 const int available_width = |
| 1568 std::max(0, width() - left_padding() - right_padding()); | 1472 std::max(0, width() - kLeftPadding - kRightPadding); |
| 1569 const int width_per_icon = tab_icon_size(); | 1473 const int width_per_icon = kTabIconSize; |
| 1570 const int kPaddingBetweenIcons = 2; | 1474 const int kPaddingBetweenIcons = 2; |
| 1571 if (available_width >= width_per_icon && | 1475 if (available_width >= width_per_icon && |
| 1572 available_width < (width_per_icon + kPaddingBetweenIcons)) { | 1476 available_width < (width_per_icon + kPaddingBetweenIcons)) { |
| 1573 return 1; | 1477 return 1; |
| 1574 } | 1478 } |
| 1575 return available_width / (width_per_icon + kPaddingBetweenIcons); | 1479 return available_width / (width_per_icon + kPaddingBetweenIcons); |
| 1576 } | 1480 } |
| 1577 | 1481 |
| 1578 bool Tab::ShouldShowIcon() const { | 1482 bool Tab::ShouldShowIcon() const { |
| 1579 return chrome::ShouldTabShowFavicon( | 1483 return chrome::ShouldTabShowFavicon( |
| (...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1745 const gfx::ImageSkia& image) { | 1649 const gfx::ImageSkia& image) { |
| 1746 DCHECK_NE(scale_factor, ui::SCALE_FACTOR_NONE); | 1650 DCHECK_NE(scale_factor, ui::SCALE_FACTOR_NONE); |
| 1747 ImageCacheEntry entry; | 1651 ImageCacheEntry entry; |
| 1748 entry.resource_id = resource_id; | 1652 entry.resource_id = resource_id; |
| 1749 entry.scale_factor = scale_factor; | 1653 entry.scale_factor = scale_factor; |
| 1750 entry.image = image; | 1654 entry.image = image; |
| 1751 image_cache_->push_front(entry); | 1655 image_cache_->push_front(entry); |
| 1752 if (image_cache_->size() > kMaxImageCacheSize) | 1656 if (image_cache_->size() > kMaxImageCacheSize) |
| 1753 image_cache_->pop_back(); | 1657 image_cache_->pop_back(); |
| 1754 } | 1658 } |
| OLD | NEW |