| 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 #if defined(OS_WIN) | 7 #if defined(OS_WIN) |
| 8 #include <windowsx.h> | 8 #include <windowsx.h> |
| 9 #endif | 9 #endif |
| 10 | 10 |
| (...skipping 586 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 597 views::Widget* widget = GetWidget(); | 597 views::Widget* widget = GetWidget(); |
| 598 return browser_defaults::kSizeTabButtonToTopOfTabStrip || | 598 return browser_defaults::kSizeTabButtonToTopOfTabStrip || |
| 599 (widget && (widget->IsMaximized() || widget->IsFullscreen())); | 599 (widget && (widget->IsMaximized() || widget->IsFullscreen())); |
| 600 } | 600 } |
| 601 | 601 |
| 602 void TabStrip::StartHighlight(int model_index) { | 602 void TabStrip::StartHighlight(int model_index) { |
| 603 tab_at(model_index)->StartPulse(); | 603 tab_at(model_index)->StartPulse(); |
| 604 } | 604 } |
| 605 | 605 |
| 606 void TabStrip::StopAllHighlighting() { | 606 void TabStrip::StopAllHighlighting() { |
| 607 for (int i = 0; i < tab_count(); ++i) | 607 for (int i = 0; i < GetTabCount(); ++i) |
| 608 tab_at(i)->StopPulse(); | 608 tab_at(i)->StopPulse(); |
| 609 } | 609 } |
| 610 | 610 |
| 611 void TabStrip::AddTabAt(int model_index, | 611 void TabStrip::AddTabAt(int model_index, |
| 612 const TabRendererData& data, | 612 const TabRendererData& data, |
| 613 bool is_active) { | 613 bool is_active) { |
| 614 // Stop dragging when a new tab is added and dragging a window. Doing | 614 // Stop dragging when a new tab is added and dragging a window. Doing |
| 615 // otherwise results in a confusing state if the user attempts to reattach. We | 615 // otherwise results in a confusing state if the user attempts to reattach. We |
| 616 // could allow this and make TabDragController update itself during the add, | 616 // could allow this and make TabDragController update itself during the add, |
| 617 // but this comes up infrequently enough that it's not work the complexity. | 617 // but this comes up infrequently enough that it's not work the complexity. |
| (...skipping 12 matching lines...) Expand all Loading... |
| 630 int add_types = 0; | 630 int add_types = 0; |
| 631 if (data.mini) | 631 if (data.mini) |
| 632 add_types |= StackedTabStripLayout::kAddTypeMini; | 632 add_types |= StackedTabStripLayout::kAddTypeMini; |
| 633 if (is_active) | 633 if (is_active) |
| 634 add_types |= StackedTabStripLayout::kAddTypeActive; | 634 add_types |= StackedTabStripLayout::kAddTypeActive; |
| 635 touch_layout_->AddTab(model_index, add_types, GetStartXForNormalTabs()); | 635 touch_layout_->AddTab(model_index, add_types, GetStartXForNormalTabs()); |
| 636 } | 636 } |
| 637 | 637 |
| 638 // Don't animate the first tab, it looks weird, and don't animate anything | 638 // Don't animate the first tab, it looks weird, and don't animate anything |
| 639 // if the containing window isn't visible yet. | 639 // if the containing window isn't visible yet. |
| 640 if (tab_count() > 1 && GetWidget() && GetWidget()->IsVisible()) | 640 if (GetTabCount() > 1 && GetWidget() && GetWidget()->IsVisible()) |
| 641 StartInsertTabAnimation(model_index); | 641 StartInsertTabAnimation(model_index); |
| 642 else | 642 else |
| 643 DoLayout(); | 643 DoLayout(); |
| 644 | 644 |
| 645 SwapLayoutIfNecessary(); | 645 SwapLayoutIfNecessary(); |
| 646 | 646 |
| 647 FOR_EACH_OBSERVER(TabStripObserver, observers_, | 647 FOR_EACH_OBSERVER(TabStripObserver, observers_, |
| 648 TabStripAddedTabAt(this, model_index)); | 648 TabStripAddedTabAt(this, model_index)); |
| 649 } | 649 } |
| 650 | 650 |
| (...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 849 tab_at(new_selection.active())->NotifyAccessibilityEvent( | 849 tab_at(new_selection.active())->NotifyAccessibilityEvent( |
| 850 ui::AX_EVENT_SELECTION, true); | 850 ui::AX_EVENT_SELECTION, true); |
| 851 } | 851 } |
| 852 | 852 |
| 853 void TabStrip::TabTitleChangedNotLoading(int model_index) { | 853 void TabStrip::TabTitleChangedNotLoading(int model_index) { |
| 854 Tab* tab = tab_at(model_index); | 854 Tab* tab = tab_at(model_index); |
| 855 if (tab->data().mini && !tab->IsActive()) | 855 if (tab->data().mini && !tab->IsActive()) |
| 856 tab->StartMiniTabTitleAnimation(); | 856 tab->StartMiniTabTitleAnimation(); |
| 857 } | 857 } |
| 858 | 858 |
| 859 int TabStrip::GetModelIndexOfTab(const Tab* tab) const { | |
| 860 return tabs_.GetIndexOfView(tab); | |
| 861 } | |
| 862 | |
| 863 int TabStrip::GetModelCount() const { | 859 int TabStrip::GetModelCount() const { |
| 864 return controller_->GetCount(); | 860 return controller_->GetCount(); |
| 865 } | 861 } |
| 866 | 862 |
| 867 bool TabStrip::IsValidModelIndex(int model_index) const { | 863 bool TabStrip::IsValidModelIndex(int model_index) const { |
| 868 return controller_->IsValidIndex(model_index); | 864 return controller_->IsValidIndex(model_index); |
| 869 } | 865 } |
| 870 | 866 |
| 871 bool TabStrip::IsDragSessionActive() const { | 867 bool TabStrip::IsDragSessionActive() const { |
| 872 return drag_controller_.get() != NULL; | 868 return drag_controller_.get() != NULL; |
| 873 } | 869 } |
| 874 | 870 |
| 875 bool TabStrip::IsActiveDropTarget() const { | 871 bool TabStrip::IsActiveDropTarget() const { |
| 876 for (int i = 0; i < tab_count(); ++i) { | 872 for (int i = 0; i < GetTabCount(); ++i) { |
| 877 Tab* tab = tab_at(i); | 873 Tab* tab = tab_at(i); |
| 878 if (tab->dragging()) | 874 if (tab->dragging()) |
| 879 return true; | 875 return true; |
| 880 } | 876 } |
| 881 return false; | 877 return false; |
| 882 } | 878 } |
| 883 | 879 |
| 884 bool TabStrip::IsTabStripEditable() const { | 880 bool TabStrip::IsTabStripEditable() const { |
| 885 return !IsDragSessionActive() && !IsActiveDropTarget(); | 881 return !IsDragSessionActive() && !IsActiveDropTarget(); |
| 886 } | 882 } |
| (...skipping 29 matching lines...) Expand all Loading... |
| 916 !newtab_button_->HitTestRect(rect_in_newtab_coords)) | 912 !newtab_button_->HitTestRect(rect_in_newtab_coords)) |
| 917 return true; | 913 return true; |
| 918 | 914 |
| 919 // All other regions, including the new Tab button, should be considered part | 915 // All other regions, including the new Tab button, should be considered part |
| 920 // of the containing Window's client area so that regular events can be | 916 // of the containing Window's client area so that regular events can be |
| 921 // processed for them. | 917 // processed for them. |
| 922 return false; | 918 return false; |
| 923 } | 919 } |
| 924 | 920 |
| 925 void TabStrip::SetBackgroundOffset(const gfx::Point& offset) { | 921 void TabStrip::SetBackgroundOffset(const gfx::Point& offset) { |
| 926 for (int i = 0; i < tab_count(); ++i) | 922 for (int i = 0; i < GetTabCount(); ++i) |
| 927 tab_at(i)->set_background_offset(offset); | 923 tab_at(i)->set_background_offset(offset); |
| 928 newtab_button_->set_background_offset(offset); | 924 newtab_button_->set_background_offset(offset); |
| 929 } | 925 } |
| 930 | 926 |
| 931 void TabStrip::SetImmersiveStyle(bool enable) { | 927 void TabStrip::SetImmersiveStyle(bool enable) { |
| 932 if (immersive_style_ == enable) | 928 if (immersive_style_ == enable) |
| 933 return; | 929 return; |
| 934 immersive_style_ = enable; | 930 immersive_style_ = enable; |
| 935 } | 931 } |
| 936 | 932 |
| (...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1049 if (!IsValidModelIndex(model_index)) { | 1045 if (!IsValidModelIndex(model_index)) { |
| 1050 CHECK(false); | 1046 CHECK(false); |
| 1051 return; | 1047 return; |
| 1052 } | 1048 } |
| 1053 Tabs tabs; | 1049 Tabs tabs; |
| 1054 int size_to_selected = 0; | 1050 int size_to_selected = 0; |
| 1055 int x = tab->GetMirroredXInView(event.x()); | 1051 int x = tab->GetMirroredXInView(event.x()); |
| 1056 int y = event.y(); | 1052 int y = event.y(); |
| 1057 // Build the set of selected tabs to drag and calculate the offset from the | 1053 // Build the set of selected tabs to drag and calculate the offset from the |
| 1058 // first selected tab. | 1054 // first selected tab. |
| 1059 for (int i = 0; i < tab_count(); ++i) { | 1055 for (int i = 0; i < GetTabCount(); ++i) { |
| 1060 Tab* other_tab = tab_at(i); | 1056 Tab* other_tab = tab_at(i); |
| 1061 if (IsTabSelected(other_tab)) { | 1057 if (IsTabSelected(other_tab)) { |
| 1062 tabs.push_back(other_tab); | 1058 tabs.push_back(other_tab); |
| 1063 if (other_tab == tab) { | 1059 if (other_tab == tab) { |
| 1064 size_to_selected = GetSizeNeededForTabs(tabs); | 1060 size_to_selected = GetSizeNeededForTabs(tabs); |
| 1065 x = size_to_selected - tab->width() + x; | 1061 x = size_to_selected - tab->width() + x; |
| 1066 } | 1062 } |
| 1067 } | 1063 } |
| 1068 } | 1064 } |
| 1069 DCHECK(!tabs.empty()); | 1065 DCHECK(!tabs.empty()); |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1141 // Only touch layout needs to restrict the clip. | 1137 // Only touch layout needs to restrict the clip. |
| 1142 if (!touch_layout_ && !IsStackingDraggedTabs()) | 1138 if (!touch_layout_ && !IsStackingDraggedTabs()) |
| 1143 return true; | 1139 return true; |
| 1144 | 1140 |
| 1145 int index = GetModelIndexOfTab(tab); | 1141 int index = GetModelIndexOfTab(tab); |
| 1146 if (index == -1) | 1142 if (index == -1) |
| 1147 return true; // Tab is closing, paint it all. | 1143 return true; // Tab is closing, paint it all. |
| 1148 | 1144 |
| 1149 int active_index = IsStackingDraggedTabs() ? | 1145 int active_index = IsStackingDraggedTabs() ? |
| 1150 controller_->GetActiveIndex() : touch_layout_->active_index(); | 1146 controller_->GetActiveIndex() : touch_layout_->active_index(); |
| 1151 if (active_index == tab_count()) | 1147 if (active_index == GetTabCount()) |
| 1152 active_index--; | 1148 active_index--; |
| 1153 | 1149 |
| 1154 if (index < active_index) { | 1150 if (index < active_index) { |
| 1155 if (tab_at(index)->x() == tab_at(index + 1)->x()) | 1151 if (tab_at(index)->x() == tab_at(index + 1)->x()) |
| 1156 return false; | 1152 return false; |
| 1157 | 1153 |
| 1158 if (tab_at(index)->x() > tab_at(index + 1)->x()) | 1154 if (tab_at(index)->x() > tab_at(index + 1)->x()) |
| 1159 return true; // Can happen during dragging. | 1155 return true; // Can happen during dragging. |
| 1160 | 1156 |
| 1161 clip->SetRect( | 1157 clip->SetRect( |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1218 | 1214 |
| 1219 const chrome::HostDesktopType host_desktop_type = | 1215 const chrome::HostDesktopType host_desktop_type = |
| 1220 chrome::GetHostDesktopTypeForNativeView(GetWidget()->GetNativeView()); | 1216 chrome::GetHostDesktopTypeForNativeView(GetWidget()->GetNativeView()); |
| 1221 const int inactive_tab_alpha = | 1217 const int inactive_tab_alpha = |
| 1222 (host_desktop_type == chrome::HOST_DESKTOP_TYPE_ASH) ? | 1218 (host_desktop_type == chrome::HOST_DESKTOP_TYPE_ASH) ? |
| 1223 kInactiveTabAndNewTabButtonAlphaAsh : kInactiveTabAndNewTabButtonAlpha; | 1219 kInactiveTabAndNewTabButtonAlphaAsh : kInactiveTabAndNewTabButtonAlpha; |
| 1224 | 1220 |
| 1225 if (inactive_tab_alpha < 255) | 1221 if (inactive_tab_alpha < 255) |
| 1226 canvas->SaveLayerAlpha(inactive_tab_alpha); | 1222 canvas->SaveLayerAlpha(inactive_tab_alpha); |
| 1227 | 1223 |
| 1228 PaintClosingTabs(canvas, tab_count(), cull_set); | 1224 PaintClosingTabs(canvas, GetTabCount(), cull_set); |
| 1229 | 1225 |
| 1230 for (int i = tab_count() - 1; i >= 0; --i) { | 1226 for (int i = GetTabCount() - 1; i >= 0; --i) { |
| 1231 Tab* tab = tab_at(i); | 1227 Tab* tab = tab_at(i); |
| 1232 if (tab->IsSelected()) | 1228 if (tab->IsSelected()) |
| 1233 selected_tab_count++; | 1229 selected_tab_count++; |
| 1234 if (tab->dragging() && !stacked_layout_) { | 1230 if (tab->dragging() && !stacked_layout_) { |
| 1235 is_dragging = true; | 1231 is_dragging = true; |
| 1236 if (tab->IsActive()) { | 1232 if (tab->IsActive()) { |
| 1237 active_tab = tab; | 1233 active_tab = tab; |
| 1238 active_tab_index = i; | 1234 active_tab_index = i; |
| 1239 } else { | 1235 } else { |
| 1240 tabs_dragging.push_back(tab); | 1236 tabs_dragging.push_back(tab); |
| (...skipping 12 matching lines...) Expand all Loading... |
| 1253 PaintClosingTabs(canvas, i, cull_set); | 1249 PaintClosingTabs(canvas, i, cull_set); |
| 1254 } | 1250 } |
| 1255 | 1251 |
| 1256 // Draw from the left and then the right if we're in touch mode. | 1252 // Draw from the left and then the right if we're in touch mode. |
| 1257 if (stacked_layout_ && active_tab_index >= 0) { | 1253 if (stacked_layout_ && active_tab_index >= 0) { |
| 1258 for (int i = 0; i < active_tab_index; ++i) { | 1254 for (int i = 0; i < active_tab_index; ++i) { |
| 1259 Tab* tab = tab_at(i); | 1255 Tab* tab = tab_at(i); |
| 1260 tab->Paint(canvas, cull_set); | 1256 tab->Paint(canvas, cull_set); |
| 1261 } | 1257 } |
| 1262 | 1258 |
| 1263 for (int i = tab_count() - 1; i > active_tab_index; --i) { | 1259 for (int i = GetTabCount() - 1; i > active_tab_index; --i) { |
| 1264 Tab* tab = tab_at(i); | 1260 Tab* tab = tab_at(i); |
| 1265 tab->Paint(canvas, cull_set); | 1261 tab->Paint(canvas, cull_set); |
| 1266 } | 1262 } |
| 1267 } | 1263 } |
| 1268 if (inactive_tab_alpha < 255) | 1264 if (inactive_tab_alpha < 255) |
| 1269 canvas->Restore(); | 1265 canvas->Restore(); |
| 1270 | 1266 |
| 1271 if (GetWidget()->ShouldWindowContentsBeTransparent()) { | 1267 if (GetWidget()->ShouldWindowContentsBeTransparent()) { |
| 1272 // Make sure non-active tabs are somewhat transparent. | 1268 // Make sure non-active tabs are somewhat transparent. |
| 1273 SkPaint paint; | 1269 SkPaint paint; |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1316 int needed_tab_width; | 1312 int needed_tab_width; |
| 1317 if (touch_layout_ || adjust_layout_) { | 1313 if (touch_layout_ || adjust_layout_) { |
| 1318 // For stacked tabs the minimum size is calculated as the size needed to | 1314 // For stacked tabs the minimum size is calculated as the size needed to |
| 1319 // handle showing any number of tabs. | 1315 // handle showing any number of tabs. |
| 1320 needed_tab_width = | 1316 needed_tab_width = |
| 1321 Tab::GetTouchWidth() + (2 * kStackedPadding * kMaxStackedCount); | 1317 Tab::GetTouchWidth() + (2 * kStackedPadding * kMaxStackedCount); |
| 1322 } else { | 1318 } else { |
| 1323 // Otherwise the minimum width is based on the actual number of tabs. | 1319 // Otherwise the minimum width is based on the actual number of tabs. |
| 1324 const int mini_tab_count = GetMiniTabCount(); | 1320 const int mini_tab_count = GetMiniTabCount(); |
| 1325 needed_tab_width = mini_tab_count * Tab::GetMiniWidth(); | 1321 needed_tab_width = mini_tab_count * Tab::GetMiniWidth(); |
| 1326 const int remaining_tab_count = tab_count() - mini_tab_count; | 1322 const int remaining_tab_count = GetTabCount() - mini_tab_count; |
| 1327 const int min_selected_width = Tab::GetMinimumSelectedSize().width(); | 1323 const int min_selected_width = Tab::GetMinimumSelectedSize().width(); |
| 1328 const int min_unselected_width = Tab::GetMinimumUnselectedSize().width(); | 1324 const int min_unselected_width = Tab::GetMinimumUnselectedSize().width(); |
| 1329 if (remaining_tab_count > 0) { | 1325 if (remaining_tab_count > 0) { |
| 1330 needed_tab_width += kMiniToNonMiniGap + min_selected_width + | 1326 needed_tab_width += kMiniToNonMiniGap + min_selected_width + |
| 1331 ((remaining_tab_count - 1) * min_unselected_width); | 1327 ((remaining_tab_count - 1) * min_unselected_width); |
| 1332 } | 1328 } |
| 1333 if (tab_count() > 1) | 1329 if (GetTabCount() > 1) |
| 1334 needed_tab_width += (tab_count() - 1) * kTabHorizontalOffset; | 1330 needed_tab_width += (GetTabCount() - 1) * kTabHorizontalOffset; |
| 1335 | 1331 |
| 1336 // Don't let the tabstrip shrink smaller than is necessary to show one tab, | 1332 // Don't let the tabstrip shrink smaller than is necessary to show one tab, |
| 1337 // and don't force it to be larger than is necessary to show 20 tabs. | 1333 // and don't force it to be larger than is necessary to show 20 tabs. |
| 1338 const int largest_min_tab_width = | 1334 const int largest_min_tab_width = |
| 1339 min_selected_width + 19 * (min_unselected_width + kTabHorizontalOffset); | 1335 min_selected_width + 19 * (min_unselected_width + kTabHorizontalOffset); |
| 1340 needed_tab_width = std::min( | 1336 needed_tab_width = std::min( |
| 1341 std::max(needed_tab_width, min_selected_width), largest_min_tab_width); | 1337 std::max(needed_tab_width, min_selected_width), largest_min_tab_width); |
| 1342 } | 1338 } |
| 1343 return gfx::Size( | 1339 return gfx::Size( |
| 1344 needed_tab_width + new_tab_button_width(), | 1340 needed_tab_width + new_tab_button_width(), |
| (...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1462 if (view) | 1458 if (view) |
| 1463 return view; | 1459 return view; |
| 1464 } | 1460 } |
| 1465 Tab* tab = FindTabForEvent(point); | 1461 Tab* tab = FindTabForEvent(point); |
| 1466 if (tab) | 1462 if (tab) |
| 1467 return ConvertPointToViewAndGetTooltipHandler(this, tab, point); | 1463 return ConvertPointToViewAndGetTooltipHandler(this, tab, point); |
| 1468 } | 1464 } |
| 1469 return this; | 1465 return this; |
| 1470 } | 1466 } |
| 1471 | 1467 |
| 1468 int TabStrip::GetModelIndexOfTab(const Tab* tab) const { |
| 1469 return tabs_.GetIndexOfView(tab); |
| 1470 } |
| 1471 |
| 1472 int TabStrip::GetTabCount() const { |
| 1473 return tabs_.view_size(); |
| 1474 } |
| 1475 |
| 1472 // static | 1476 // static |
| 1473 int TabStrip::GetImmersiveHeight() { | 1477 int TabStrip::GetImmersiveHeight() { |
| 1474 return Tab::GetImmersiveHeight(); | 1478 return Tab::GetImmersiveHeight(); |
| 1475 } | 1479 } |
| 1476 | 1480 |
| 1477 /////////////////////////////////////////////////////////////////////////////// | 1481 /////////////////////////////////////////////////////////////////////////////// |
| 1478 // TabStrip, private: | 1482 // TabStrip, private: |
| 1479 | 1483 |
| 1480 void TabStrip::Init() { | 1484 void TabStrip::Init() { |
| 1481 set_id(VIEW_ID_TAB_STRIP); | 1485 set_id(VIEW_ID_TAB_STRIP); |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1568 // Don't animate the new tab button when dragging tabs. Otherwise it looks | 1572 // Don't animate the new tab button when dragging tabs. Otherwise it looks |
| 1569 // like the new tab button magically appears from beyond the end of the tab | 1573 // like the new tab button magically appears from beyond the end of the tab |
| 1570 // strip. | 1574 // strip. |
| 1571 if (TabDragController::IsAttachedTo(this)) { | 1575 if (TabDragController::IsAttachedTo(this)) { |
| 1572 bounds_animator_.StopAnimatingView(newtab_button_); | 1576 bounds_animator_.StopAnimatingView(newtab_button_); |
| 1573 newtab_button_->SetBoundsRect(newtab_button_bounds_); | 1577 newtab_button_->SetBoundsRect(newtab_button_bounds_); |
| 1574 } | 1578 } |
| 1575 } | 1579 } |
| 1576 | 1580 |
| 1577 void TabStrip::AnimateToIdealBounds() { | 1581 void TabStrip::AnimateToIdealBounds() { |
| 1578 for (int i = 0; i < tab_count(); ++i) { | 1582 for (int i = 0; i < GetTabCount(); ++i) { |
| 1579 Tab* tab = tab_at(i); | 1583 Tab* tab = tab_at(i); |
| 1580 if (!tab->dragging()) { | 1584 if (!tab->dragging()) { |
| 1581 bounds_animator_.AnimateViewTo(tab, ideal_bounds(i)); | 1585 bounds_animator_.AnimateViewTo(tab, ideal_bounds(i)); |
| 1582 bounds_animator_.SetAnimationDelegate( | 1586 bounds_animator_.SetAnimationDelegate( |
| 1583 tab, | 1587 tab, |
| 1584 scoped_ptr<gfx::AnimationDelegate>( | 1588 scoped_ptr<gfx::AnimationDelegate>( |
| 1585 new TabAnimationDelegate(this, tab))); | 1589 new TabAnimationDelegate(this, tab))); |
| 1586 } | 1590 } |
| 1587 } | 1591 } |
| 1588 | 1592 |
| (...skipping 24 matching lines...) Expand all Loading... |
| 1613 bounds_animator_.StopAnimatingView(newtab_button_); | 1617 bounds_animator_.StopAnimatingView(newtab_button_); |
| 1614 newtab_button_->SetBoundsRect(newtab_button_bounds_); | 1618 newtab_button_->SetBoundsRect(newtab_button_bounds_); |
| 1615 } | 1619 } |
| 1616 | 1620 |
| 1617 void TabStrip::SetTabVisibility() { | 1621 void TabStrip::SetTabVisibility() { |
| 1618 // We could probably be more efficient here by making use of the fact that the | 1622 // We could probably be more efficient here by making use of the fact that the |
| 1619 // tabstrip will always have any visible tabs, and then any invisible tabs, so | 1623 // tabstrip will always have any visible tabs, and then any invisible tabs, so |
| 1620 // we could e.g. binary-search for the changeover point. But since we have to | 1624 // we could e.g. binary-search for the changeover point. But since we have to |
| 1621 // iterate through all the tabs to call SetVisible() anyway, it doesn't seem | 1625 // iterate through all the tabs to call SetVisible() anyway, it doesn't seem |
| 1622 // worth it. | 1626 // worth it. |
| 1623 for (int i = 0; i < tab_count(); ++i) { | 1627 for (int i = 0; i < GetTabCount(); ++i) { |
| 1624 Tab* tab = tab_at(i); | 1628 Tab* tab = tab_at(i); |
| 1625 tab->SetVisible(ShouldTabBeVisible(tab)); | 1629 tab->SetVisible(ShouldTabBeVisible(tab)); |
| 1626 } | 1630 } |
| 1627 for (TabsClosingMap::const_iterator i(tabs_closing_map_.begin()); | 1631 for (TabsClosingMap::const_iterator i(tabs_closing_map_.begin()); |
| 1628 i != tabs_closing_map_.end(); ++i) { | 1632 i != tabs_closing_map_.end(); ++i) { |
| 1629 for (Tabs::const_iterator j(i->second.begin()); j != i->second.end(); ++j) { | 1633 for (Tabs::const_iterator j(i->second.begin()); j != i->second.end(); ++j) { |
| 1630 Tab* tab = *j; | 1634 Tab* tab = *j; |
| 1631 tab->SetVisible(ShouldTabBeVisible(tab)); | 1635 tab->SetVisible(ShouldTabBeVisible(tab)); |
| 1632 } | 1636 } |
| 1633 } | 1637 } |
| 1634 } | 1638 } |
| 1635 | 1639 |
| 1636 void TabStrip::DragActiveTab(const std::vector<int>& initial_positions, | 1640 void TabStrip::DragActiveTab(const std::vector<int>& initial_positions, |
| 1637 int delta) { | 1641 int delta) { |
| 1638 DCHECK_EQ(tab_count(), static_cast<int>(initial_positions.size())); | 1642 DCHECK_EQ(GetTabCount(), static_cast<int>(initial_positions.size())); |
| 1639 if (!touch_layout_) { | 1643 if (!touch_layout_) { |
| 1640 StackDraggedTabs(delta); | 1644 StackDraggedTabs(delta); |
| 1641 return; | 1645 return; |
| 1642 } | 1646 } |
| 1643 SetIdealBoundsFromPositions(initial_positions); | 1647 SetIdealBoundsFromPositions(initial_positions); |
| 1644 touch_layout_->DragActiveTab(delta); | 1648 touch_layout_->DragActiveTab(delta); |
| 1645 DoLayout(); | 1649 DoLayout(); |
| 1646 } | 1650 } |
| 1647 | 1651 |
| 1648 void TabStrip::SetIdealBoundsFromPositions(const std::vector<int>& positions) { | 1652 void TabStrip::SetIdealBoundsFromPositions(const std::vector<int>& positions) { |
| 1649 if (static_cast<size_t>(tab_count()) != positions.size()) | 1653 if (static_cast<size_t>(GetTabCount()) != positions.size()) |
| 1650 return; | 1654 return; |
| 1651 | 1655 |
| 1652 for (int i = 0; i < tab_count(); ++i) { | 1656 for (int i = 0; i < GetTabCount(); ++i) { |
| 1653 gfx::Rect bounds(ideal_bounds(i)); | 1657 gfx::Rect bounds(ideal_bounds(i)); |
| 1654 bounds.set_x(positions[i]); | 1658 bounds.set_x(positions[i]); |
| 1655 tabs_.set_ideal_bounds(i, bounds); | 1659 tabs_.set_ideal_bounds(i, bounds); |
| 1656 } | 1660 } |
| 1657 } | 1661 } |
| 1658 | 1662 |
| 1659 void TabStrip::StackDraggedTabs(int delta) { | 1663 void TabStrip::StackDraggedTabs(int delta) { |
| 1660 DCHECK(!touch_layout_); | 1664 DCHECK(!touch_layout_); |
| 1661 GenerateIdealBounds(); | 1665 GenerateIdealBounds(); |
| 1662 const int active_index = controller_->GetActiveIndex(); | 1666 const int active_index = controller_->GetActiveIndex(); |
| 1663 DCHECK_NE(-1, active_index); | 1667 DCHECK_NE(-1, active_index); |
| 1664 if (delta < 0) { | 1668 if (delta < 0) { |
| 1665 // Drag the tabs to the left, stacking tabs before the active tab. | 1669 // Drag the tabs to the left, stacking tabs before the active tab. |
| 1666 const int adjusted_delta = | 1670 const int adjusted_delta = |
| 1667 std::min(ideal_bounds(active_index).x() - | 1671 std::min(ideal_bounds(active_index).x() - |
| 1668 kStackedPadding * std::min(active_index, kMaxStackedCount), | 1672 kStackedPadding * std::min(active_index, kMaxStackedCount), |
| 1669 -delta); | 1673 -delta); |
| 1670 for (int i = 0; i <= active_index; ++i) { | 1674 for (int i = 0; i <= active_index; ++i) { |
| 1671 const int min_x = std::min(i, kMaxStackedCount) * kStackedPadding; | 1675 const int min_x = std::min(i, kMaxStackedCount) * kStackedPadding; |
| 1672 gfx::Rect new_bounds(ideal_bounds(i)); | 1676 gfx::Rect new_bounds(ideal_bounds(i)); |
| 1673 new_bounds.set_x(std::max(min_x, new_bounds.x() - adjusted_delta)); | 1677 new_bounds.set_x(std::max(min_x, new_bounds.x() - adjusted_delta)); |
| 1674 tabs_.set_ideal_bounds(i, new_bounds); | 1678 tabs_.set_ideal_bounds(i, new_bounds); |
| 1675 } | 1679 } |
| 1676 const bool is_active_mini = tab_at(active_index)->data().mini; | 1680 const bool is_active_mini = tab_at(active_index)->data().mini; |
| 1677 const int active_width = ideal_bounds(active_index).width(); | 1681 const int active_width = ideal_bounds(active_index).width(); |
| 1678 for (int i = active_index + 1; i < tab_count(); ++i) { | 1682 for (int i = active_index + 1; i < GetTabCount(); ++i) { |
| 1679 const int max_x = ideal_bounds(active_index).x() + | 1683 const int max_x = ideal_bounds(active_index).x() + |
| 1680 (kStackedPadding * std::min(i - active_index, kMaxStackedCount)); | 1684 (kStackedPadding * std::min(i - active_index, kMaxStackedCount)); |
| 1681 gfx::Rect new_bounds(ideal_bounds(i)); | 1685 gfx::Rect new_bounds(ideal_bounds(i)); |
| 1682 int new_x = std::max(new_bounds.x() + delta, max_x); | 1686 int new_x = std::max(new_bounds.x() + delta, max_x); |
| 1683 if (new_x == max_x && !tab_at(i)->data().mini && !is_active_mini && | 1687 if (new_x == max_x && !tab_at(i)->data().mini && !is_active_mini && |
| 1684 new_bounds.width() != active_width) | 1688 new_bounds.width() != active_width) |
| 1685 new_x += (active_width - new_bounds.width()); | 1689 new_x += (active_width - new_bounds.width()); |
| 1686 new_bounds.set_x(new_x); | 1690 new_bounds.set_x(new_x); |
| 1687 tabs_.set_ideal_bounds(i, new_bounds); | 1691 tabs_.set_ideal_bounds(i, new_bounds); |
| 1688 } | 1692 } |
| 1689 } else { | 1693 } else { |
| 1690 // Drag the tabs to the right, stacking tabs after the active tab. | 1694 // Drag the tabs to the right, stacking tabs after the active tab. |
| 1691 const int last_tab_width = ideal_bounds(tab_count() - 1).width(); | 1695 const int last_tab_width = ideal_bounds(GetTabCount() - 1).width(); |
| 1692 const int last_tab_x = tab_area_width() - last_tab_width; | 1696 const int last_tab_x = tab_area_width() - last_tab_width; |
| 1693 if (active_index == tab_count() - 1 && | 1697 if (active_index == GetTabCount() - 1 && |
| 1694 ideal_bounds(tab_count() - 1).x() == last_tab_x) | 1698 ideal_bounds(GetTabCount() - 1).x() == last_tab_x) |
| 1695 return; | 1699 return; |
| 1696 const int adjusted_delta = | 1700 const int adjusted_delta = std::min( |
| 1697 std::min(last_tab_x - | 1701 last_tab_x - |
| 1698 kStackedPadding * std::min(tab_count() - active_index - 1, | 1702 kStackedPadding * |
| 1699 kMaxStackedCount) - | 1703 std::min(GetTabCount() - active_index - 1, kMaxStackedCount) - |
| 1700 ideal_bounds(active_index).x(), | 1704 ideal_bounds(active_index).x(), |
| 1701 delta); | 1705 delta); |
| 1702 for (int last_index = tab_count() - 1, i = last_index; i >= active_index; | 1706 for (int last_index = GetTabCount() - 1, i = last_index; i >= active_index; |
| 1703 --i) { | 1707 --i) { |
| 1704 const int max_x = last_tab_x - | 1708 const int max_x = last_tab_x - |
| 1705 std::min(tab_count() - i - 1, kMaxStackedCount) * kStackedPadding; | 1709 std::min(GetTabCount() - i - 1, kMaxStackedCount) * kStackedPadding; |
| 1706 gfx::Rect new_bounds(ideal_bounds(i)); | 1710 gfx::Rect new_bounds(ideal_bounds(i)); |
| 1707 int new_x = std::min(max_x, new_bounds.x() + adjusted_delta); | 1711 int new_x = std::min(max_x, new_bounds.x() + adjusted_delta); |
| 1708 // Because of rounding not all tabs are the same width. Adjust the | 1712 // Because of rounding not all tabs are the same width. Adjust the |
| 1709 // position to accommodate this, otherwise the stacking is off. | 1713 // position to accommodate this, otherwise the stacking is off. |
| 1710 if (new_x == max_x && !tab_at(i)->data().mini && | 1714 if (new_x == max_x && !tab_at(i)->data().mini && |
| 1711 new_bounds.width() != last_tab_width) | 1715 new_bounds.width() != last_tab_width) |
| 1712 new_x += (last_tab_width - new_bounds.width()); | 1716 new_x += (last_tab_width - new_bounds.width()); |
| 1713 new_bounds.set_x(new_x); | 1717 new_bounds.set_x(new_x); |
| 1714 tabs_.set_ideal_bounds(i, new_bounds); | 1718 tabs_.set_ideal_bounds(i, new_bounds); |
| 1715 } | 1719 } |
| 1716 for (int i = active_index - 1; i >= 0; --i) { | 1720 for (int i = active_index - 1; i >= 0; --i) { |
| 1717 const int min_x = ideal_bounds(active_index).x() - | 1721 const int min_x = ideal_bounds(active_index).x() - |
| 1718 std::min(active_index - i, kMaxStackedCount) * kStackedPadding; | 1722 std::min(active_index - i, kMaxStackedCount) * kStackedPadding; |
| 1719 gfx::Rect new_bounds(ideal_bounds(i)); | 1723 gfx::Rect new_bounds(ideal_bounds(i)); |
| 1720 new_bounds.set_x(std::min(min_x, new_bounds.x() + delta)); | 1724 new_bounds.set_x(std::min(min_x, new_bounds.x() + delta)); |
| 1721 tabs_.set_ideal_bounds(i, new_bounds); | 1725 tabs_.set_ideal_bounds(i, new_bounds); |
| 1722 } | 1726 } |
| 1723 if (ideal_bounds(tab_count() - 1).right() >= newtab_button_->x()) | 1727 if (ideal_bounds(GetTabCount() - 1).right() >= newtab_button_->x()) |
| 1724 newtab_button_->SetVisible(false); | 1728 newtab_button_->SetVisible(false); |
| 1725 } | 1729 } |
| 1726 views::ViewModelUtils::SetViewBoundsToIdealBounds(tabs_); | 1730 views::ViewModelUtils::SetViewBoundsToIdealBounds(tabs_); |
| 1727 SchedulePaint(); | 1731 SchedulePaint(); |
| 1728 } | 1732 } |
| 1729 | 1733 |
| 1730 bool TabStrip::IsStackingDraggedTabs() const { | 1734 bool TabStrip::IsStackingDraggedTabs() const { |
| 1731 return drag_controller_.get() && drag_controller_->started_drag() && | 1735 return drag_controller_.get() && drag_controller_->started_drag() && |
| 1732 (drag_controller_->move_behavior() == | 1736 (drag_controller_->move_behavior() == |
| 1733 TabDragController::MOVE_VISIBILE_TABS); | 1737 TabDragController::MOVE_VISIBILE_TABS); |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1789 if (i > 0 && tab->data().mini != tabs[i - 1]->data().mini) | 1793 if (i > 0 && tab->data().mini != tabs[i - 1]->data().mini) |
| 1790 width += kMiniToNonMiniGap; | 1794 width += kMiniToNonMiniGap; |
| 1791 } | 1795 } |
| 1792 if (tabs.size() > 0) | 1796 if (tabs.size() > 0) |
| 1793 width += kTabHorizontalOffset * static_cast<int>(tabs.size() - 1); | 1797 width += kTabHorizontalOffset * static_cast<int>(tabs.size() - 1); |
| 1794 return width; | 1798 return width; |
| 1795 } | 1799 } |
| 1796 | 1800 |
| 1797 int TabStrip::GetMiniTabCount() const { | 1801 int TabStrip::GetMiniTabCount() const { |
| 1798 int mini_count = 0; | 1802 int mini_count = 0; |
| 1799 while (mini_count < tab_count() && tab_at(mini_count)->data().mini) | 1803 while (mini_count < GetTabCount() && tab_at(mini_count)->data().mini) |
| 1800 mini_count++; | 1804 mini_count++; |
| 1801 return mini_count; | 1805 return mini_count; |
| 1802 } | 1806 } |
| 1803 | 1807 |
| 1804 const Tab* TabStrip::GetLastVisibleTab() const { | 1808 const Tab* TabStrip::GetLastVisibleTab() const { |
| 1805 for (int i = tab_count() - 1; i >= 0; --i) { | 1809 for (int i = GetTabCount() - 1; i >= 0; --i) { |
| 1806 const Tab* tab = tab_at(i); | 1810 const Tab* tab = tab_at(i); |
| 1807 if (tab->visible()) | 1811 if (tab->visible()) |
| 1808 return tab; | 1812 return tab; |
| 1809 } | 1813 } |
| 1810 // While in normal use the tabstrip should always be wide enough to have at | 1814 // While in normal use the tabstrip should always be wide enough to have at |
| 1811 // least one visible tab, it can be zero-width in tests, meaning we get here. | 1815 // least one visible tab, it can be zero-width in tests, meaning we get here. |
| 1812 return NULL; | 1816 return NULL; |
| 1813 } | 1817 } |
| 1814 | 1818 |
| 1815 void TabStrip::RemoveTabFromViewModel(int index) { | 1819 void TabStrip::RemoveTabFromViewModel(int index) { |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1856 // Let the controller know that the user started dragging tabs. | 1860 // Let the controller know that the user started dragging tabs. |
| 1857 controller()->OnStartedDraggingTabs(); | 1861 controller()->OnStartedDraggingTabs(); |
| 1858 | 1862 |
| 1859 // Hide the new tab button immediately if we didn't originate the drag. | 1863 // Hide the new tab button immediately if we didn't originate the drag. |
| 1860 if (!drag_controller_.get()) | 1864 if (!drag_controller_.get()) |
| 1861 newtab_button_->SetVisible(false); | 1865 newtab_button_->SetVisible(false); |
| 1862 | 1866 |
| 1863 PrepareForAnimation(); | 1867 PrepareForAnimation(); |
| 1864 | 1868 |
| 1865 // Reset dragging state of existing tabs. | 1869 // Reset dragging state of existing tabs. |
| 1866 for (int i = 0; i < tab_count(); ++i) | 1870 for (int i = 0; i < GetTabCount(); ++i) |
| 1867 tab_at(i)->set_dragging(false); | 1871 tab_at(i)->set_dragging(false); |
| 1868 | 1872 |
| 1869 for (size_t i = 0; i < tabs.size(); ++i) { | 1873 for (size_t i = 0; i < tabs.size(); ++i) { |
| 1870 tabs[i]->set_dragging(true); | 1874 tabs[i]->set_dragging(true); |
| 1871 bounds_animator_.StopAnimatingView(tabs[i]); | 1875 bounds_animator_.StopAnimatingView(tabs[i]); |
| 1872 } | 1876 } |
| 1873 | 1877 |
| 1874 // Move the dragged tabs to their ideal bounds. | 1878 // Move the dragged tabs to their ideal bounds. |
| 1875 GenerateIdealBounds(); | 1879 GenerateIdealBounds(); |
| 1876 | 1880 |
| (...skipping 242 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2119 available_width - total_offset - min_selected_width) / | 2123 available_width - total_offset - min_selected_width) / |
| 2120 static_cast<double>(tab_count - 1), min_unselected_width); | 2124 static_cast<double>(tab_count - 1), min_unselected_width); |
| 2121 } | 2125 } |
| 2122 } | 2126 } |
| 2123 } | 2127 } |
| 2124 | 2128 |
| 2125 void TabStrip::ResizeLayoutTabs() { | 2129 void TabStrip::ResizeLayoutTabs() { |
| 2126 // We've been called back after the TabStrip has been emptied out (probably | 2130 // We've been called back after the TabStrip has been emptied out (probably |
| 2127 // just prior to the window being destroyed). We need to do nothing here or | 2131 // just prior to the window being destroyed). We need to do nothing here or |
| 2128 // else GetTabAt below will crash. | 2132 // else GetTabAt below will crash. |
| 2129 if (tab_count() == 0) | 2133 if (GetTabCount() == 0) |
| 2130 return; | 2134 return; |
| 2131 | 2135 |
| 2132 // It is critically important that this is unhooked here, otherwise we will | 2136 // It is critically important that this is unhooked here, otherwise we will |
| 2133 // keep spying on messages forever. | 2137 // keep spying on messages forever. |
| 2134 RemoveMessageLoopObserver(); | 2138 RemoveMessageLoopObserver(); |
| 2135 | 2139 |
| 2136 in_tab_close_ = false; | 2140 in_tab_close_ = false; |
| 2137 available_width_for_tabs_ = -1; | 2141 available_width_for_tabs_ = -1; |
| 2138 int mini_tab_count = GetMiniTabCount(); | 2142 int mini_tab_count = GetMiniTabCount(); |
| 2139 if (mini_tab_count == tab_count()) { | 2143 if (mini_tab_count == GetTabCount()) { |
| 2140 // Only mini-tabs, we know the tab widths won't have changed (all | 2144 // Only mini-tabs, we know the tab widths won't have changed (all |
| 2141 // mini-tabs have the same width), so there is nothing to do. | 2145 // mini-tabs have the same width), so there is nothing to do. |
| 2142 return; | 2146 return; |
| 2143 } | 2147 } |
| 2144 // Don't try and avoid layout based on tab sizes. If tabs are small enough | 2148 // Don't try and avoid layout based on tab sizes. If tabs are small enough |
| 2145 // then the width of the active tab may not change, but other widths may | 2149 // then the width of the active tab may not change, but other widths may |
| 2146 // have. This is particularly important if we've overflowed (all tabs are at | 2150 // have. This is particularly important if we've overflowed (all tabs are at |
| 2147 // the min). | 2151 // the min). |
| 2148 StartResizeLayoutAnimation(); | 2152 StartResizeLayoutAnimation(); |
| 2149 } | 2153 } |
| 2150 | 2154 |
| 2151 void TabStrip::ResizeLayoutTabsFromTouch() { | 2155 void TabStrip::ResizeLayoutTabsFromTouch() { |
| 2152 // Don't resize if the user is interacting with the tabstrip. | 2156 // Don't resize if the user is interacting with the tabstrip. |
| 2153 if (!drag_controller_.get()) | 2157 if (!drag_controller_.get()) |
| 2154 ResizeLayoutTabs(); | 2158 ResizeLayoutTabs(); |
| 2155 else | 2159 else |
| 2156 StartResizeLayoutTabsFromTouchTimer(); | 2160 StartResizeLayoutTabsFromTouchTimer(); |
| 2157 } | 2161 } |
| 2158 | 2162 |
| 2159 void TabStrip::StartResizeLayoutTabsFromTouchTimer() { | 2163 void TabStrip::StartResizeLayoutTabsFromTouchTimer() { |
| 2160 resize_layout_timer_.Stop(); | 2164 resize_layout_timer_.Stop(); |
| 2161 resize_layout_timer_.Start( | 2165 resize_layout_timer_.Start( |
| 2162 FROM_HERE, base::TimeDelta::FromMilliseconds(kTouchResizeLayoutTimeMS), | 2166 FROM_HERE, base::TimeDelta::FromMilliseconds(kTouchResizeLayoutTimeMS), |
| 2163 this, &TabStrip::ResizeLayoutTabsFromTouch); | 2167 this, &TabStrip::ResizeLayoutTabsFromTouch); |
| 2164 } | 2168 } |
| 2165 | 2169 |
| 2166 void TabStrip::SetTabBoundsForDrag(const std::vector<gfx::Rect>& tab_bounds) { | 2170 void TabStrip::SetTabBoundsForDrag(const std::vector<gfx::Rect>& tab_bounds) { |
| 2167 StopAnimating(false); | 2171 StopAnimating(false); |
| 2168 DCHECK_EQ(tab_count(), static_cast<int>(tab_bounds.size())); | 2172 DCHECK_EQ(GetTabCount(), static_cast<int>(tab_bounds.size())); |
| 2169 for (int i = 0; i < tab_count(); ++i) | 2173 for (int i = 0; i < GetTabCount(); ++i) |
| 2170 tab_at(i)->SetBoundsRect(tab_bounds[i]); | 2174 tab_at(i)->SetBoundsRect(tab_bounds[i]); |
| 2171 // Reset the layout size as we've effectively layed out a different size. | 2175 // Reset the layout size as we've effectively layed out a different size. |
| 2172 // This ensures a layout happens after the drag is done. | 2176 // This ensures a layout happens after the drag is done. |
| 2173 last_layout_size_ = gfx::Size(); | 2177 last_layout_size_ = gfx::Size(); |
| 2174 } | 2178 } |
| 2175 | 2179 |
| 2176 void TabStrip::AddMessageLoopObserver() { | 2180 void TabStrip::AddMessageLoopObserver() { |
| 2177 if (!mouse_watcher_.get()) { | 2181 if (!mouse_watcher_.get()) { |
| 2178 mouse_watcher_.reset( | 2182 mouse_watcher_.reset( |
| 2179 new views::MouseWatcher( | 2183 new views::MouseWatcher( |
| 2180 new views::MouseWatcherViewHost( | 2184 new views::MouseWatcherViewHost( |
| 2181 this, gfx::Insets(0, 0, kTabStripAnimationVSlop, 0)), | 2185 this, gfx::Insets(0, 0, kTabStripAnimationVSlop, 0)), |
| 2182 this)); | 2186 this)); |
| 2183 } | 2187 } |
| 2184 mouse_watcher_->Start(); | 2188 mouse_watcher_->Start(); |
| 2185 } | 2189 } |
| 2186 | 2190 |
| 2187 void TabStrip::RemoveMessageLoopObserver() { | 2191 void TabStrip::RemoveMessageLoopObserver() { |
| 2188 mouse_watcher_.reset(NULL); | 2192 mouse_watcher_.reset(NULL); |
| 2189 } | 2193 } |
| 2190 | 2194 |
| 2191 gfx::Rect TabStrip::GetDropBounds(int drop_index, | 2195 gfx::Rect TabStrip::GetDropBounds(int drop_index, |
| 2192 bool drop_before, | 2196 bool drop_before, |
| 2193 bool* is_beneath) { | 2197 bool* is_beneath) { |
| 2194 DCHECK_NE(drop_index, -1); | 2198 DCHECK_NE(drop_index, -1); |
| 2195 int center_x; | 2199 int center_x; |
| 2196 if (drop_index < tab_count()) { | 2200 if (drop_index < GetTabCount()) { |
| 2197 Tab* tab = tab_at(drop_index); | 2201 Tab* tab = tab_at(drop_index); |
| 2198 if (drop_before) | 2202 if (drop_before) |
| 2199 center_x = tab->x() - (kTabHorizontalOffset / 2); | 2203 center_x = tab->x() - (kTabHorizontalOffset / 2); |
| 2200 else | 2204 else |
| 2201 center_x = tab->x() + (tab->width() / 2); | 2205 center_x = tab->x() + (tab->width() / 2); |
| 2202 } else { | 2206 } else { |
| 2203 Tab* last_tab = tab_at(drop_index - 1); | 2207 Tab* last_tab = tab_at(drop_index - 1); |
| 2204 center_x = last_tab->x() + last_tab->width() + (kTabHorizontalOffset / 2); | 2208 center_x = last_tab->x() + last_tab->width() + (kTabHorizontalOffset / 2); |
| 2205 } | 2209 } |
| 2206 | 2210 |
| (...skipping 16 matching lines...) Expand all Loading... |
| 2223 | 2227 |
| 2224 return drop_bounds; | 2228 return drop_bounds; |
| 2225 } | 2229 } |
| 2226 | 2230 |
| 2227 void TabStrip::UpdateDropIndex(const DropTargetEvent& event) { | 2231 void TabStrip::UpdateDropIndex(const DropTargetEvent& event) { |
| 2228 // If the UI layout is right-to-left, we need to mirror the mouse | 2232 // If the UI layout is right-to-left, we need to mirror the mouse |
| 2229 // coordinates since we calculate the drop index based on the | 2233 // coordinates since we calculate the drop index based on the |
| 2230 // original (and therefore non-mirrored) positions of the tabs. | 2234 // original (and therefore non-mirrored) positions of the tabs. |
| 2231 const int x = GetMirroredXInView(event.x()); | 2235 const int x = GetMirroredXInView(event.x()); |
| 2232 // We don't allow replacing the urls of mini-tabs. | 2236 // We don't allow replacing the urls of mini-tabs. |
| 2233 for (int i = GetMiniTabCount(); i < tab_count(); ++i) { | 2237 for (int i = GetMiniTabCount(); i < GetTabCount(); ++i) { |
| 2234 Tab* tab = tab_at(i); | 2238 Tab* tab = tab_at(i); |
| 2235 const int tab_max_x = tab->x() + tab->width(); | 2239 const int tab_max_x = tab->x() + tab->width(); |
| 2236 const int hot_width = tab->width() / kTabEdgeRatioInverse; | 2240 const int hot_width = tab->width() / kTabEdgeRatioInverse; |
| 2237 if (x < tab_max_x) { | 2241 if (x < tab_max_x) { |
| 2238 if (x < tab->x() + hot_width) | 2242 if (x < tab->x() + hot_width) |
| 2239 SetDropIndex(i, true); | 2243 SetDropIndex(i, true); |
| 2240 else if (x >= tab_max_x - hot_width) | 2244 else if (x >= tab_max_x - hot_width) |
| 2241 SetDropIndex(i + 1, true); | 2245 SetDropIndex(i + 1, true); |
| 2242 else | 2246 else |
| 2243 SetDropIndex(i, false); | 2247 SetDropIndex(i, false); |
| 2244 return; | 2248 return; |
| 2245 } | 2249 } |
| 2246 } | 2250 } |
| 2247 | 2251 |
| 2248 // The drop isn't over a tab, add it to the end. | 2252 // The drop isn't over a tab, add it to the end. |
| 2249 SetDropIndex(tab_count(), true); | 2253 SetDropIndex(GetTabCount(), true); |
| 2250 } | 2254 } |
| 2251 | 2255 |
| 2252 void TabStrip::SetDropIndex(int tab_data_index, bool drop_before) { | 2256 void TabStrip::SetDropIndex(int tab_data_index, bool drop_before) { |
| 2253 // Let the controller know of the index update. | 2257 // Let the controller know of the index update. |
| 2254 controller()->OnDropIndexUpdate(tab_data_index, drop_before); | 2258 controller()->OnDropIndexUpdate(tab_data_index, drop_before); |
| 2255 | 2259 |
| 2256 if (tab_data_index == -1) { | 2260 if (tab_data_index == -1) { |
| 2257 if (drop_info_.get()) | 2261 if (drop_info_.get()) |
| 2258 drop_info_.reset(NULL); | 2262 drop_info_.reset(NULL); |
| 2259 return; | 2263 return; |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2328 | 2332 |
| 2329 TabStrip::DropInfo::~DropInfo() { | 2333 TabStrip::DropInfo::~DropInfo() { |
| 2330 // Close eventually deletes the window, which deletes arrow_view too. | 2334 // Close eventually deletes the window, which deletes arrow_view too. |
| 2331 arrow_window->Close(); | 2335 arrow_window->Close(); |
| 2332 } | 2336 } |
| 2333 | 2337 |
| 2334 /////////////////////////////////////////////////////////////////////////////// | 2338 /////////////////////////////////////////////////////////////////////////////// |
| 2335 | 2339 |
| 2336 void TabStrip::PrepareForAnimation() { | 2340 void TabStrip::PrepareForAnimation() { |
| 2337 if (!IsDragSessionActive() && !TabDragController::IsAttachedTo(this)) { | 2341 if (!IsDragSessionActive() && !TabDragController::IsAttachedTo(this)) { |
| 2338 for (int i = 0; i < tab_count(); ++i) | 2342 for (int i = 0; i < GetTabCount(); ++i) |
| 2339 tab_at(i)->set_dragging(false); | 2343 tab_at(i)->set_dragging(false); |
| 2340 } | 2344 } |
| 2341 } | 2345 } |
| 2342 | 2346 |
| 2343 void TabStrip::GenerateIdealBounds() { | 2347 void TabStrip::GenerateIdealBounds() { |
| 2344 int new_tab_y = 0; | 2348 int new_tab_y = 0; |
| 2345 | 2349 |
| 2346 if (touch_layout_) { | 2350 if (touch_layout_) { |
| 2347 if (tabs_.view_size() == 0) | 2351 if (tabs_.view_size() == 0) |
| 2348 return; | 2352 return; |
| 2349 | 2353 |
| 2350 int new_tab_x = tabs_.ideal_bounds(tabs_.view_size() - 1).right() + | 2354 int new_tab_x = tabs_.ideal_bounds(tabs_.view_size() - 1).right() + |
| 2351 kNewTabButtonHorizontalOffset; | 2355 kNewTabButtonHorizontalOffset; |
| 2352 newtab_button_bounds_.set_origin(gfx::Point(new_tab_x, new_tab_y)); | 2356 newtab_button_bounds_.set_origin(gfx::Point(new_tab_x, new_tab_y)); |
| 2353 return; | 2357 return; |
| 2354 } | 2358 } |
| 2355 | 2359 |
| 2356 GetDesiredTabWidths(tab_count(), GetMiniTabCount(), | 2360 GetDesiredTabWidths(GetTabCount(), GetMiniTabCount(), |
| 2357 ¤t_unselected_width_, ¤t_selected_width_); | 2361 ¤t_unselected_width_, ¤t_selected_width_); |
| 2358 | 2362 |
| 2359 // NOTE: This currently assumes a tab's height doesn't differ based on | 2363 // NOTE: This currently assumes a tab's height doesn't differ based on |
| 2360 // selected state or the number of tabs in the strip! | 2364 // selected state or the number of tabs in the strip! |
| 2361 int tab_height = Tab::GetStandardSize().height(); | 2365 int tab_height = Tab::GetStandardSize().height(); |
| 2362 int first_non_mini_index = 0; | 2366 int first_non_mini_index = 0; |
| 2363 double tab_x = GenerateIdealBoundsForMiniTabs(&first_non_mini_index); | 2367 double tab_x = GenerateIdealBoundsForMiniTabs(&first_non_mini_index); |
| 2364 for (int i = first_non_mini_index; i < tab_count(); ++i) { | 2368 for (int i = first_non_mini_index; i < GetTabCount(); ++i) { |
| 2365 Tab* tab = tab_at(i); | 2369 Tab* tab = tab_at(i); |
| 2366 DCHECK(!tab->data().mini); | 2370 DCHECK(!tab->data().mini); |
| 2367 double tab_width = | 2371 double tab_width = |
| 2368 tab->IsActive() ? current_selected_width_ : current_unselected_width_; | 2372 tab->IsActive() ? current_selected_width_ : current_unselected_width_; |
| 2369 double end_of_tab = tab_x + tab_width; | 2373 double end_of_tab = tab_x + tab_width; |
| 2370 int rounded_tab_x = Round(tab_x); | 2374 int rounded_tab_x = Round(tab_x); |
| 2371 tabs_.set_ideal_bounds( | 2375 tabs_.set_ideal_bounds( |
| 2372 i, | 2376 i, |
| 2373 gfx::Rect(rounded_tab_x, 0, Round(end_of_tab) - rounded_tab_x, | 2377 gfx::Rect(rounded_tab_x, 0, Round(end_of_tab) - rounded_tab_x, |
| 2374 tab_height)); | 2378 tab_height)); |
| (...skipping 13 matching lines...) Expand all Loading... |
| 2388 kNewTabButtonHorizontalOffset; | 2392 kNewTabButtonHorizontalOffset; |
| 2389 } | 2393 } |
| 2390 newtab_button_bounds_.set_origin(gfx::Point(new_tab_x, new_tab_y)); | 2394 newtab_button_bounds_.set_origin(gfx::Point(new_tab_x, new_tab_y)); |
| 2391 } | 2395 } |
| 2392 | 2396 |
| 2393 int TabStrip::GenerateIdealBoundsForMiniTabs(int* first_non_mini_index) { | 2397 int TabStrip::GenerateIdealBoundsForMiniTabs(int* first_non_mini_index) { |
| 2394 int next_x = 0; | 2398 int next_x = 0; |
| 2395 int mini_width = Tab::GetMiniWidth(); | 2399 int mini_width = Tab::GetMiniWidth(); |
| 2396 int tab_height = Tab::GetStandardSize().height(); | 2400 int tab_height = Tab::GetStandardSize().height(); |
| 2397 int index = 0; | 2401 int index = 0; |
| 2398 for (; index < tab_count() && tab_at(index)->data().mini; ++index) { | 2402 for (; index < GetTabCount() && tab_at(index)->data().mini; ++index) { |
| 2399 tabs_.set_ideal_bounds(index, gfx::Rect(next_x, 0, mini_width, tab_height)); | 2403 tabs_.set_ideal_bounds(index, gfx::Rect(next_x, 0, mini_width, tab_height)); |
| 2400 next_x += mini_width + kTabHorizontalOffset; | 2404 next_x += mini_width + kTabHorizontalOffset; |
| 2401 } | 2405 } |
| 2402 if (index > 0 && index < tab_count()) | 2406 if (index > 0 && index < GetTabCount()) |
| 2403 next_x += kMiniToNonMiniGap; | 2407 next_x += kMiniToNonMiniGap; |
| 2404 if (first_non_mini_index) | 2408 if (first_non_mini_index) |
| 2405 *first_non_mini_index = index; | 2409 *first_non_mini_index = index; |
| 2406 return next_x; | 2410 return next_x; |
| 2407 } | 2411 } |
| 2408 | 2412 |
| 2409 void TabStrip::StartResizeLayoutAnimation() { | 2413 void TabStrip::StartResizeLayoutAnimation() { |
| 2410 PrepareForAnimation(); | 2414 PrepareForAnimation(); |
| 2411 GenerateIdealBounds(); | 2415 GenerateIdealBounds(); |
| 2412 AnimateToIdealBounds(); | 2416 AnimateToIdealBounds(); |
| 2413 } | 2417 } |
| 2414 | 2418 |
| 2415 void TabStrip::StartMiniTabAnimation() { | 2419 void TabStrip::StartMiniTabAnimation() { |
| 2416 in_tab_close_ = false; | 2420 in_tab_close_ = false; |
| 2417 available_width_for_tabs_ = -1; | 2421 available_width_for_tabs_ = -1; |
| 2418 | 2422 |
| 2419 PrepareForAnimation(); | 2423 PrepareForAnimation(); |
| 2420 | 2424 |
| 2421 GenerateIdealBounds(); | 2425 GenerateIdealBounds(); |
| 2422 AnimateToIdealBounds(); | 2426 AnimateToIdealBounds(); |
| 2423 } | 2427 } |
| 2424 | 2428 |
| 2425 void TabStrip::StartMouseInitiatedRemoveTabAnimation(int model_index) { | 2429 void TabStrip::StartMouseInitiatedRemoveTabAnimation(int model_index) { |
| 2426 // The user initiated the close. We want to persist the bounds of all the | 2430 // The user initiated the close. We want to persist the bounds of all the |
| 2427 // existing tabs, so we manually shift ideal_bounds then animate. | 2431 // existing tabs, so we manually shift ideal_bounds then animate. |
| 2428 Tab* tab_closing = tab_at(model_index); | 2432 Tab* tab_closing = tab_at(model_index); |
| 2429 int delta = tab_closing->width() + kTabHorizontalOffset; | 2433 int delta = tab_closing->width() + kTabHorizontalOffset; |
| 2430 // If the tab being closed is a mini-tab next to a non-mini-tab, be sure to | 2434 // If the tab being closed is a mini-tab next to a non-mini-tab, be sure to |
| 2431 // add the extra padding. | 2435 // add the extra padding. |
| 2432 DCHECK_LT(model_index, tab_count() - 1); | 2436 DCHECK_LT(model_index, GetTabCount() - 1); |
| 2433 if (tab_closing->data().mini && !tab_at(model_index + 1)->data().mini) | 2437 if (tab_closing->data().mini && !tab_at(model_index + 1)->data().mini) |
| 2434 delta += kMiniToNonMiniGap; | 2438 delta += kMiniToNonMiniGap; |
| 2435 | 2439 |
| 2436 for (int i = model_index + 1; i < tab_count(); ++i) { | 2440 for (int i = model_index + 1; i < GetTabCount(); ++i) { |
| 2437 gfx::Rect bounds = ideal_bounds(i); | 2441 gfx::Rect bounds = ideal_bounds(i); |
| 2438 bounds.set_x(bounds.x() - delta); | 2442 bounds.set_x(bounds.x() - delta); |
| 2439 tabs_.set_ideal_bounds(i, bounds); | 2443 tabs_.set_ideal_bounds(i, bounds); |
| 2440 } | 2444 } |
| 2441 | 2445 |
| 2442 // Don't just subtract |delta| from the New Tab x-coordinate, as we might have | 2446 // Don't just subtract |delta| from the New Tab x-coordinate, as we might have |
| 2443 // overflow tabs that will be able to animate into the strip, in which case | 2447 // overflow tabs that will be able to animate into the strip, in which case |
| 2444 // the new tab button should stay where it is. | 2448 // the new tab button should stay where it is. |
| 2445 newtab_button_bounds_.set_x(std::min( | 2449 newtab_button_bounds_.set_x(std::min( |
| 2446 width() - newtab_button_bounds_.width(), | 2450 width() - newtab_button_bounds_.width(), |
| 2447 ideal_bounds(tab_count() - 1).right() + kNewTabButtonHorizontalOffset)); | 2451 ideal_bounds(GetTabCount() - 1).right() + kNewTabButtonHorizontalOffset)); |
| 2448 | 2452 |
| 2449 PrepareForAnimation(); | 2453 PrepareForAnimation(); |
| 2450 | 2454 |
| 2451 tab_closing->set_closing(true); | 2455 tab_closing->set_closing(true); |
| 2452 | 2456 |
| 2453 // We still need to paint the tab until we actually remove it. Put it in | 2457 // We still need to paint the tab until we actually remove it. Put it in |
| 2454 // tabs_closing_map_ so we can find it. | 2458 // tabs_closing_map_ so we can find it. |
| 2455 RemoveTabFromViewModel(model_index); | 2459 RemoveTabFromViewModel(model_index); |
| 2456 | 2460 |
| 2457 AnimateToIdealBounds(); | 2461 AnimateToIdealBounds(); |
| (...skipping 27 matching lines...) Expand all Loading... |
| 2485 | 2489 |
| 2486 Tab* TabStrip::FindTabForEvent(const gfx::Point& point) { | 2490 Tab* TabStrip::FindTabForEvent(const gfx::Point& point) { |
| 2487 if (touch_layout_) { | 2491 if (touch_layout_) { |
| 2488 int active_tab_index = touch_layout_->active_index(); | 2492 int active_tab_index = touch_layout_->active_index(); |
| 2489 if (active_tab_index != -1) { | 2493 if (active_tab_index != -1) { |
| 2490 Tab* tab = FindTabForEventFrom(point, active_tab_index, -1); | 2494 Tab* tab = FindTabForEventFrom(point, active_tab_index, -1); |
| 2491 if (!tab) | 2495 if (!tab) |
| 2492 tab = FindTabForEventFrom(point, active_tab_index + 1, 1); | 2496 tab = FindTabForEventFrom(point, active_tab_index + 1, 1); |
| 2493 return tab; | 2497 return tab; |
| 2494 } | 2498 } |
| 2495 if (tab_count()) | 2499 if (GetTabCount()) |
| 2496 return FindTabForEventFrom(point, 0, 1); | 2500 return FindTabForEventFrom(point, 0, 1); |
| 2497 } else { | 2501 } else { |
| 2498 for (int i = 0; i < tab_count(); ++i) { | 2502 for (int i = 0; i < GetTabCount(); ++i) { |
| 2499 if (IsPointInTab(tab_at(i), point)) | 2503 if (IsPointInTab(tab_at(i), point)) |
| 2500 return tab_at(i); | 2504 return tab_at(i); |
| 2501 } | 2505 } |
| 2502 } | 2506 } |
| 2503 return NULL; | 2507 return NULL; |
| 2504 } | 2508 } |
| 2505 | 2509 |
| 2506 Tab* TabStrip::FindTabForEventFrom(const gfx::Point& point, | 2510 Tab* TabStrip::FindTabForEventFrom(const gfx::Point& point, |
| 2507 int start, | 2511 int start, |
| 2508 int delta) { | 2512 int delta) { |
| 2509 // |start| equals tab_count() when there are only pinned tabs. | 2513 // |start| equals GetTabCount() when there are only pinned tabs. |
| 2510 if (start == tab_count()) | 2514 if (start == GetTabCount()) |
| 2511 start += delta; | 2515 start += delta; |
| 2512 for (int i = start; i >= 0 && i < tab_count(); i += delta) { | 2516 for (int i = start; i >= 0 && i < GetTabCount(); i += delta) { |
| 2513 if (IsPointInTab(tab_at(i), point)) | 2517 if (IsPointInTab(tab_at(i), point)) |
| 2514 return tab_at(i); | 2518 return tab_at(i); |
| 2515 } | 2519 } |
| 2516 return NULL; | 2520 return NULL; |
| 2517 } | 2521 } |
| 2518 | 2522 |
| 2519 views::View* TabStrip::FindTabHitByPoint(const gfx::Point& point) { | 2523 views::View* TabStrip::FindTabHitByPoint(const gfx::Point& point) { |
| 2520 // The display order doesn't necessarily match the child list order, so we | 2524 // The display order doesn't necessarily match the child list order, so we |
| 2521 // walk the display list hit-testing Tabs. Since the active tab always | 2525 // walk the display list hit-testing Tabs. Since the active tab always |
| 2522 // renders on top of adjacent tabs, it needs to be hit-tested before any | 2526 // renders on top of adjacent tabs, it needs to be hit-tested before any |
| 2523 // left-adjacent Tab, so we look ahead for it as we walk. | 2527 // left-adjacent Tab, so we look ahead for it as we walk. |
| 2524 for (int i = 0; i < tab_count(); ++i) { | 2528 for (int i = 0; i < GetTabCount(); ++i) { |
| 2525 Tab* next_tab = i < (tab_count() - 1) ? tab_at(i + 1) : NULL; | 2529 Tab* next_tab = i < (GetTabCount() - 1) ? tab_at(i + 1) : NULL; |
| 2526 if (next_tab && next_tab->IsActive() && IsPointInTab(next_tab, point)) | 2530 if (next_tab && next_tab->IsActive() && IsPointInTab(next_tab, point)) |
| 2527 return next_tab; | 2531 return next_tab; |
| 2528 if (IsPointInTab(tab_at(i), point)) | 2532 if (IsPointInTab(tab_at(i), point)) |
| 2529 return tab_at(i); | 2533 return tab_at(i); |
| 2530 } | 2534 } |
| 2531 | 2535 |
| 2532 return NULL; | 2536 return NULL; |
| 2533 } | 2537 } |
| 2534 | 2538 |
| 2535 std::vector<int> TabStrip::GetTabXCoordinates() { | 2539 std::vector<int> TabStrip::GetTabXCoordinates() { |
| 2536 std::vector<int> results; | 2540 std::vector<int> results; |
| 2537 for (int i = 0; i < tab_count(); ++i) | 2541 for (int i = 0; i < GetTabCount(); ++i) |
| 2538 results.push_back(ideal_bounds(i).x()); | 2542 results.push_back(ideal_bounds(i).x()); |
| 2539 return results; | 2543 return results; |
| 2540 } | 2544 } |
| 2541 | 2545 |
| 2542 void TabStrip::SwapLayoutIfNecessary() { | 2546 void TabStrip::SwapLayoutIfNecessary() { |
| 2543 bool needs_touch = NeedsTouchLayout(); | 2547 bool needs_touch = NeedsTouchLayout(); |
| 2544 bool using_touch = touch_layout_ != NULL; | 2548 bool using_touch = touch_layout_ != NULL; |
| 2545 if (needs_touch == using_touch) | 2549 if (needs_touch == using_touch) |
| 2546 return; | 2550 return; |
| 2547 | 2551 |
| (...skipping 21 matching lines...) Expand all Loading... |
| 2569 GenerateIdealBounds(); | 2573 GenerateIdealBounds(); |
| 2570 SetTabVisibility(); | 2574 SetTabVisibility(); |
| 2571 AnimateToIdealBounds(); | 2575 AnimateToIdealBounds(); |
| 2572 } | 2576 } |
| 2573 | 2577 |
| 2574 bool TabStrip::NeedsTouchLayout() const { | 2578 bool TabStrip::NeedsTouchLayout() const { |
| 2575 if (!stacked_layout_) | 2579 if (!stacked_layout_) |
| 2576 return false; | 2580 return false; |
| 2577 | 2581 |
| 2578 int mini_tab_count = GetMiniTabCount(); | 2582 int mini_tab_count = GetMiniTabCount(); |
| 2579 int normal_count = tab_count() - mini_tab_count; | 2583 int normal_count = GetTabCount() - mini_tab_count; |
| 2580 if (normal_count <= 1 || normal_count == mini_tab_count) | 2584 if (normal_count <= 1 || normal_count == mini_tab_count) |
| 2581 return false; | 2585 return false; |
| 2582 int x = GetStartXForNormalTabs(); | 2586 int x = GetStartXForNormalTabs(); |
| 2583 int available_width = tab_area_width() - x; | 2587 int available_width = tab_area_width() - x; |
| 2584 return (Tab::GetTouchWidth() * normal_count + | 2588 return (Tab::GetTouchWidth() * normal_count + |
| 2585 kTabHorizontalOffset * (normal_count - 1)) > available_width; | 2589 kTabHorizontalOffset * (normal_count - 1)) > available_width; |
| 2586 } | 2590 } |
| 2587 | 2591 |
| 2588 void TabStrip::SetResetToShrinkOnExit(bool value) { | 2592 void TabStrip::SetResetToShrinkOnExit(bool value) { |
| 2589 if (!adjust_layout_) | 2593 if (!adjust_layout_) |
| (...skipping 29 matching lines...) Expand all Loading... |
| 2619 } | 2623 } |
| 2620 | 2624 |
| 2621 controller()->CreateNewTab(); | 2625 controller()->CreateNewTab(); |
| 2622 if (event.type() == ui::ET_GESTURE_TAP) | 2626 if (event.type() == ui::ET_GESTURE_TAP) |
| 2623 TouchUMA::RecordGestureAction(TouchUMA::GESTURE_NEWTAB_TAP); | 2627 TouchUMA::RecordGestureAction(TouchUMA::GESTURE_NEWTAB_TAP); |
| 2624 } | 2628 } |
| 2625 } | 2629 } |
| 2626 | 2630 |
| 2627 // Overridden to support automation. See automation_proxy_uitest.cc. | 2631 // Overridden to support automation. See automation_proxy_uitest.cc. |
| 2628 const views::View* TabStrip::GetViewByID(int view_id) const { | 2632 const views::View* TabStrip::GetViewByID(int view_id) const { |
| 2629 if (tab_count() > 0) { | 2633 if (GetTabCount() > 0) { |
| 2630 if (view_id == VIEW_ID_TAB_LAST) | 2634 if (view_id == VIEW_ID_TAB_LAST) |
| 2631 return tab_at(tab_count() - 1); | 2635 return tab_at(GetTabCount() - 1); |
| 2632 if ((view_id >= VIEW_ID_TAB_0) && (view_id < VIEW_ID_TAB_LAST)) { | 2636 if ((view_id >= VIEW_ID_TAB_0) && (view_id < VIEW_ID_TAB_LAST)) { |
| 2633 int index = view_id - VIEW_ID_TAB_0; | 2637 int index = view_id - VIEW_ID_TAB_0; |
| 2634 return (index >= 0 && index < tab_count()) ? tab_at(index) : NULL; | 2638 return (index >= 0 && index < GetTabCount()) ? tab_at(index) : NULL; |
| 2635 } | 2639 } |
| 2636 } | 2640 } |
| 2637 | 2641 |
| 2638 return View::GetViewByID(view_id); | 2642 return View::GetViewByID(view_id); |
| 2639 } | 2643 } |
| 2640 | 2644 |
| 2641 bool TabStrip::OnMousePressed(const ui::MouseEvent& event) { | 2645 bool TabStrip::OnMousePressed(const ui::MouseEvent& event) { |
| 2642 UpdateStackedLayoutFromMouseEvent(this, event); | 2646 UpdateStackedLayoutFromMouseEvent(this, event); |
| 2643 // We can't return true here, else clicking in an empty area won't drag the | 2647 // We can't return true here, else clicking in an empty area won't drag the |
| 2644 // window. | 2648 // window. |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2713 action = TouchUMA::GESTURE_TABSWITCH_TAP; | 2717 action = TouchUMA::GESTURE_TABSWITCH_TAP; |
| 2714 TouchUMA::RecordGestureAction(action); | 2718 TouchUMA::RecordGestureAction(action); |
| 2715 break; | 2719 break; |
| 2716 } | 2720 } |
| 2717 | 2721 |
| 2718 default: | 2722 default: |
| 2719 break; | 2723 break; |
| 2720 } | 2724 } |
| 2721 event->SetHandled(); | 2725 event->SetHandled(); |
| 2722 } | 2726 } |
| OLD | NEW |