| 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_strip.h" | 5 #include "chrome/browser/ui/views/tabs/tab_strip.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <algorithm> | 9 #include <algorithm> |
| 10 #include <iterator> | 10 #include <iterator> |
| (...skipping 738 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 749 } | 749 } |
| 750 | 750 |
| 751 void TabStrip::StopAllHighlighting() { | 751 void TabStrip::StopAllHighlighting() { |
| 752 for (int i = 0; i < tab_count(); ++i) | 752 for (int i = 0; i < tab_count(); ++i) |
| 753 tab_at(i)->StopPulse(); | 753 tab_at(i)->StopPulse(); |
| 754 } | 754 } |
| 755 | 755 |
| 756 void TabStrip::AddTabAt(int model_index, | 756 void TabStrip::AddTabAt(int model_index, |
| 757 const TabRendererData& data, | 757 const TabRendererData& data, |
| 758 bool is_active) { | 758 bool is_active) { |
| 759 Tab* tab = CreateTab(); | 759 Tab* tab = new Tab(this, animation_container_.get()); |
| 760 AddChildView(tab); | 760 AddChildView(tab); |
| 761 tab->SetData(data); | 761 tab->SetData(data); |
| 762 UpdateTabsClosingMap(model_index, 1); | 762 UpdateTabsClosingMap(model_index, 1); |
| 763 tabs_.Add(tab, model_index); | 763 tabs_.Add(tab, model_index); |
| 764 | 764 |
| 765 if (touch_layout_) { | 765 if (touch_layout_) { |
| 766 GenerateIdealBoundsForPinnedTabs(NULL); | 766 GenerateIdealBoundsForPinnedTabs(NULL); |
| 767 int add_types = 0; | 767 int add_types = 0; |
| 768 if (data.pinned) | 768 if (data.pinned) |
| 769 add_types |= StackedTabStripLayout::kAddTypePinned; | 769 add_types |= StackedTabStripLayout::kAddTypePinned; |
| (...skipping 316 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1086 newtab_button_->set_background_offset(offset); | 1086 newtab_button_->set_background_offset(offset); |
| 1087 } | 1087 } |
| 1088 | 1088 |
| 1089 void TabStrip::SetImmersiveStyle(bool enable) { | 1089 void TabStrip::SetImmersiveStyle(bool enable) { |
| 1090 if (immersive_style_ == enable) | 1090 if (immersive_style_ == enable) |
| 1091 return; | 1091 return; |
| 1092 immersive_style_ = enable; | 1092 immersive_style_ = enable; |
| 1093 } | 1093 } |
| 1094 | 1094 |
| 1095 SkAlpha TabStrip::GetInactiveAlpha(bool for_new_tab_button) const { | 1095 SkAlpha TabStrip::GetInactiveAlpha(bool for_new_tab_button) const { |
| 1096 static const SkAlpha kInactiveTabAlphaOpaque = 255; | |
| 1097 static const double kMultiSelectionMultiplier = 0.6; | |
| 1098 | |
| 1099 SkAlpha base_alpha = kInactiveTabAlphaOpaque; | |
| 1100 #if defined(USE_ASH) | 1096 #if defined(USE_ASH) |
| 1101 static const SkAlpha kInactiveTabAlphaAsh = 230; | 1097 static const SkAlpha kInactiveTabAlphaAsh = 230; |
| 1102 base_alpha = kInactiveTabAlphaAsh; | 1098 const SkAlpha base_alpha = kInactiveTabAlphaAsh; |
| 1103 #else | 1099 #else |
| 1104 static const SkAlpha kInactiveTabAlphaGlass = 200; | 1100 static const SkAlpha kInactiveTabAlphaGlass = 200; |
| 1105 if (GetWidget()->ShouldWindowContentsBeTransparent()) | 1101 static const SkAlpha kInactiveTabAlphaOpaque = 255; |
| 1106 base_alpha = kInactiveTabAlphaGlass; | 1102 const SkAlpha base_alpha = GetWidget()->ShouldWindowContentsBeTransparent() ? |
| 1103 kInactiveTabAlphaGlass : kInactiveTabAlphaOpaque; |
| 1107 #endif // USE_ASH | 1104 #endif // USE_ASH |
| 1105 static const double kMultiSelectionMultiplier = 0.6; |
| 1108 return (for_new_tab_button || (GetSelectionModel().size() <= 1)) ? | 1106 return (for_new_tab_button || (GetSelectionModel().size() <= 1)) ? |
| 1109 base_alpha : static_cast<SkAlpha>(kMultiSelectionMultiplier * base_alpha); | 1107 base_alpha : static_cast<SkAlpha>(kMultiSelectionMultiplier * base_alpha); |
| 1110 } | 1108 } |
| 1111 | 1109 |
| 1112 bool TabStrip::IsAnimating() const { | 1110 bool TabStrip::IsAnimating() const { |
| 1113 return bounds_animator_.IsAnimating(); | 1111 return bounds_animator_.IsAnimating(); |
| 1114 } | 1112 } |
| 1115 | 1113 |
| 1116 void TabStrip::StopAnimating(bool layout) { | 1114 void TabStrip::StopAnimating(bool layout) { |
| 1117 if (!IsAnimating()) | 1115 if (!IsAnimating()) |
| (...skipping 277 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1395 | 1393 |
| 1396 // If a custom theme does not provide a replacement tab background, but does | 1394 // If a custom theme does not provide a replacement tab background, but does |
| 1397 // provide a replacement frame image, HasCustomImage() on the tab background | 1395 // provide a replacement frame image, HasCustomImage() on the tab background |
| 1398 // ID will return false, but the theme provider will make a custom image from | 1396 // ID will return false, but the theme provider will make a custom image from |
| 1399 // the frame image. Furthermore, since the theme provider will create the | 1397 // the frame image. Furthermore, since the theme provider will create the |
| 1400 // incognito frame image from the normal frame image, in incognito mode we | 1398 // incognito frame image from the normal frame image, in incognito mode we |
| 1401 // need to look for a custom incognito _or_ regular frame image. | 1399 // need to look for a custom incognito _or_ regular frame image. |
| 1402 const bool incognito = controller()->IsIncognito(); | 1400 const bool incognito = controller()->IsIncognito(); |
| 1403 const int id = incognito ? | 1401 const int id = incognito ? |
| 1404 IDR_THEME_TAB_BACKGROUND_INCOGNITO : IDR_THEME_TAB_BACKGROUND; | 1402 IDR_THEME_TAB_BACKGROUND_INCOGNITO : IDR_THEME_TAB_BACKGROUND; |
| 1405 const int frame_id = incognito ? IDR_THEME_FRAME_INCOGNITO : IDR_THEME_FRAME; | 1403 *custom_image = |
| 1406 *custom_image = tp->HasCustomImage(id) || tp->HasCustomImage(frame_id) || | 1404 tp->HasCustomImage(id) || tp->HasCustomImage(IDR_THEME_FRAME) || |
| 1407 (incognito && tp->HasCustomImage(IDR_THEME_FRAME)); | 1405 (incognito && tp->HasCustomImage(IDR_THEME_FRAME_INCOGNITO)); |
| 1408 return id; | 1406 return id; |
| 1409 } | 1407 } |
| 1410 | 1408 |
| 1411 void TabStrip::UpdateTabAccessibilityState(const Tab* tab, | 1409 void TabStrip::UpdateTabAccessibilityState(const Tab* tab, |
| 1412 ui::AXViewState* state) { | 1410 ui::AXViewState* state) { |
| 1413 state->count = tab_count(); | 1411 state->count = tab_count(); |
| 1414 state->index = GetModelIndexOfTab(tab); | 1412 state->index = GetModelIndexOfTab(tab); |
| 1415 } | 1413 } |
| 1416 | 1414 |
| 1417 void TabStrip::MouseMovedOutOfHost() { | 1415 void TabStrip::MouseMovedOutOfHost() { |
| (...skipping 279 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1697 AddChildView(newtab_button_); | 1695 AddChildView(newtab_button_); |
| 1698 | 1696 |
| 1699 if (drop_indicator_width == 0) { | 1697 if (drop_indicator_width == 0) { |
| 1700 // Direction doesn't matter, both images are the same size. | 1698 // Direction doesn't matter, both images are the same size. |
| 1701 gfx::ImageSkia* drop_image = GetDropArrowImage(true); | 1699 gfx::ImageSkia* drop_image = GetDropArrowImage(true); |
| 1702 drop_indicator_width = drop_image->width(); | 1700 drop_indicator_width = drop_image->width(); |
| 1703 drop_indicator_height = drop_image->height(); | 1701 drop_indicator_height = drop_image->height(); |
| 1704 } | 1702 } |
| 1705 } | 1703 } |
| 1706 | 1704 |
| 1707 Tab* TabStrip::CreateTab() { | |
| 1708 Tab* tab = new Tab(this); | |
| 1709 tab->SetAnimationContainer(animation_container_.get()); | |
| 1710 return tab; | |
| 1711 } | |
| 1712 | |
| 1713 void TabStrip::StartInsertTabAnimation(int model_index) { | 1705 void TabStrip::StartInsertTabAnimation(int model_index) { |
| 1714 PrepareForAnimation(); | 1706 PrepareForAnimation(); |
| 1715 | 1707 |
| 1716 // The TabStrip can now use its entire width to lay out Tabs. | 1708 // The TabStrip can now use its entire width to lay out Tabs. |
| 1717 in_tab_close_ = false; | 1709 in_tab_close_ = false; |
| 1718 available_width_for_tabs_ = -1; | 1710 available_width_for_tabs_ = -1; |
| 1719 | 1711 |
| 1720 GenerateIdealBounds(); | 1712 GenerateIdealBounds(); |
| 1721 | 1713 |
| 1722 Tab* tab = tab_at(model_index); | 1714 Tab* tab = tab_at(model_index); |
| (...skipping 1148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2871 ConvertPointToViewAndGetEventHandler(this, newtab_button_, point); | 2863 ConvertPointToViewAndGetEventHandler(this, newtab_button_, point); |
| 2872 if (view) | 2864 if (view) |
| 2873 return view; | 2865 return view; |
| 2874 } | 2866 } |
| 2875 Tab* tab = FindTabForEvent(point); | 2867 Tab* tab = FindTabForEvent(point); |
| 2876 if (tab) | 2868 if (tab) |
| 2877 return ConvertPointToViewAndGetEventHandler(this, tab, point); | 2869 return ConvertPointToViewAndGetEventHandler(this, tab, point); |
| 2878 } | 2870 } |
| 2879 return this; | 2871 return this; |
| 2880 } | 2872 } |
| OLD | NEW |