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_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 710 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 721 } | 721 } |
| 722 stacked_layout_ = stacked_layout; | 722 stacked_layout_ = stacked_layout; |
| 723 SetResetToShrinkOnExit(false); | 723 SetResetToShrinkOnExit(false); |
| 724 SwapLayoutIfNecessary(); | 724 SwapLayoutIfNecessary(); |
| 725 // When transitioning to stacked try to keep the active tab centered. | 725 // When transitioning to stacked try to keep the active tab centered. |
| 726 if (touch_layout_ && active_index != -1) { | 726 if (touch_layout_ && active_index != -1) { |
| 727 touch_layout_->SetActiveTabLocation( | 727 touch_layout_->SetActiveTabLocation( |
| 728 active_center - ideal_bounds(active_index).width() / 2); | 728 active_center - ideal_bounds(active_index).width() / 2); |
| 729 AnimateToIdealBounds(); | 729 AnimateToIdealBounds(); |
| 730 } | 730 } |
| 731 | |
| 732 for (int i = 0; i < tab_count(); ++i) | |
| 733 tab_at(i)->Layout(); | |
|
sky
2016/01/12 22:29:11
Can you elaborate as to why this is necessary (and
enne (OOO)
2016/01/12 22:36:28
Changing stacked layout can change whether or not
sky
2016/01/12 22:41:02
Yes, because the animation triggers layout.
| |
| 731 } | 734 } |
| 732 | 735 |
| 733 gfx::Rect TabStrip::GetNewTabButtonBounds() { | 736 gfx::Rect TabStrip::GetNewTabButtonBounds() { |
| 734 return newtab_button_->bounds(); | 737 return newtab_button_->bounds(); |
| 735 } | 738 } |
| 736 | 739 |
| 737 bool TabStrip::SizeTabButtonToTopOfTabStrip() { | 740 bool TabStrip::SizeTabButtonToTopOfTabStrip() { |
| 738 // Extend the button to the screen edge in maximized and immersive fullscreen. | 741 // Extend the button to the screen edge in maximized and immersive fullscreen. |
| 739 views::Widget* widget = GetWidget(); | 742 views::Widget* widget = GetWidget(); |
| 740 return browser_defaults::kSizeTabButtonToTopOfTabStrip || | 743 return browser_defaults::kSizeTabButtonToTopOfTabStrip || |
| (...skipping 395 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1136 | 1139 |
| 1137 bool TabStrip::ShouldHideCloseButtonForInactiveTabs() { | 1140 bool TabStrip::ShouldHideCloseButtonForInactiveTabs() { |
| 1138 if (!touch_layout_) | 1141 if (!touch_layout_) |
| 1139 return false; | 1142 return false; |
| 1140 | 1143 |
| 1141 return !base::CommandLine::ForCurrentProcess()->HasSwitch( | 1144 return !base::CommandLine::ForCurrentProcess()->HasSwitch( |
| 1142 switches::kDisableHideInactiveStackedTabCloseButtons); | 1145 switches::kDisableHideInactiveStackedTabCloseButtons); |
| 1143 } | 1146 } |
| 1144 | 1147 |
| 1145 void TabStrip::SelectTab(Tab* tab) { | 1148 void TabStrip::SelectTab(Tab* tab) { |
| 1149 int old_active = controller_->GetActiveIndex(); | |
|
sky
2016/01/12 22:29:11
How come TabStrip::SetSelection doesn't cover this
enne (OOO)
2016/01/12 22:36:29
SelectTab and SetSelection are both public functio
sky
2016/01/12 22:41:02
SelectTab calls to the TabStripController, which s
enne (OOO)
2016/01/12 22:54:54
It does not appear to call SetSelection from the t
sky
2016/01/13 00:41:09
Please update the caller to do that then as that i
| |
| 1150 | |
| 1146 int model_index = GetModelIndexOfTab(tab); | 1151 int model_index = GetModelIndexOfTab(tab); |
| 1147 if (IsValidModelIndex(model_index)) | 1152 if (IsValidModelIndex(model_index)) |
| 1148 controller_->SelectTab(model_index); | 1153 controller_->SelectTab(model_index); |
| 1154 | |
| 1155 int new_active = controller_->GetActiveIndex(); | |
| 1156 if (new_active != old_active) { | |
| 1157 tab_at(old_active)->ActiveStateChanged(); | |
| 1158 tab_at(new_active)->ActiveStateChanged(); | |
| 1159 } | |
| 1149 } | 1160 } |
| 1150 | 1161 |
| 1151 void TabStrip::ExtendSelectionTo(Tab* tab) { | 1162 void TabStrip::ExtendSelectionTo(Tab* tab) { |
| 1152 int model_index = GetModelIndexOfTab(tab); | 1163 int model_index = GetModelIndexOfTab(tab); |
| 1153 if (IsValidModelIndex(model_index)) | 1164 if (IsValidModelIndex(model_index)) |
| 1154 controller_->ExtendSelectionTo(model_index); | 1165 controller_->ExtendSelectionTo(model_index); |
| 1155 } | 1166 } |
| 1156 | 1167 |
| 1157 void TabStrip::ToggleSelected(Tab* tab) { | 1168 void TabStrip::ToggleSelected(Tab* tab) { |
| 1158 int model_index = GetModelIndexOfTab(tab); | 1169 int model_index = GetModelIndexOfTab(tab); |
| (...skipping 1697 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2856 ConvertPointToViewAndGetEventHandler(this, newtab_button_, point); | 2867 ConvertPointToViewAndGetEventHandler(this, newtab_button_, point); |
| 2857 if (view) | 2868 if (view) |
| 2858 return view; | 2869 return view; |
| 2859 } | 2870 } |
| 2860 Tab* tab = FindTabForEvent(point); | 2871 Tab* tab = FindTabForEvent(point); |
| 2861 if (tab) | 2872 if (tab) |
| 2862 return ConvertPointToViewAndGetEventHandler(this, tab, point); | 2873 return ConvertPointToViewAndGetEventHandler(this, tab, point); |
| 2863 } | 2874 } |
| 2864 return this; | 2875 return this; |
| 2865 } | 2876 } |
| OLD | NEW |