Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(180)

Side by Side Diff: chrome/browser/ui/views/tabs/tab_strip.cc

Issue 2702663002: [Merge to M57] cros-md: Remove the non-MD immersive mode code paths (Closed)
Patch Set: Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 575 matching lines...) Expand 10 before | Expand all | Expand 10 after
586 newtab_button_(NULL), 586 newtab_button_(NULL),
587 current_inactive_width_(Tab::GetStandardSize().width()), 587 current_inactive_width_(Tab::GetStandardSize().width()),
588 current_active_width_(Tab::GetStandardSize().width()), 588 current_active_width_(Tab::GetStandardSize().width()),
589 available_width_for_tabs_(-1), 589 available_width_for_tabs_(-1),
590 in_tab_close_(false), 590 in_tab_close_(false),
591 animation_container_(new gfx::AnimationContainer()), 591 animation_container_(new gfx::AnimationContainer()),
592 bounds_animator_(this), 592 bounds_animator_(this),
593 stacked_layout_(false), 593 stacked_layout_(false),
594 adjust_layout_(false), 594 adjust_layout_(false),
595 reset_to_shrink_on_exit_(false), 595 reset_to_shrink_on_exit_(false),
596 mouse_move_count_(0), 596 mouse_move_count_(0) {
597 immersive_style_(false) {
598 Init(); 597 Init();
599 SetEventTargeter( 598 SetEventTargeter(
600 std::unique_ptr<views::ViewTargeter>(new views::ViewTargeter(this))); 599 std::unique_ptr<views::ViewTargeter>(new views::ViewTargeter(this)));
601 } 600 }
602 601
603 TabStrip::~TabStrip() { 602 TabStrip::~TabStrip() {
604 for (TabStripObserver& observer : observers_) 603 for (TabStripObserver& observer : observers_)
605 observer.TabStripDeleted(this); 604 observer.TabStripDeleted(this);
606 605
607 // The animations may reference the tabs. Shut down the animation before we 606 // The animations may reference the tabs. Shut down the animation before we
(...skipping 403 matching lines...) Expand 10 before | Expand all | Expand 10 after
1011 // processed for them. 1010 // processed for them.
1012 return false; 1011 return false;
1013 } 1012 }
1014 1013
1015 void TabStrip::SetBackgroundOffset(const gfx::Point& offset) { 1014 void TabStrip::SetBackgroundOffset(const gfx::Point& offset) {
1016 for (int i = 0; i < tab_count(); ++i) 1015 for (int i = 0; i < tab_count(); ++i)
1017 tab_at(i)->set_background_offset(offset); 1016 tab_at(i)->set_background_offset(offset);
1018 newtab_button_->set_background_offset(offset); 1017 newtab_button_->set_background_offset(offset);
1019 } 1018 }
1020 1019
1021 void TabStrip::SetImmersiveStyle(bool enable) {
1022 if (immersive_style_ == enable)
1023 return;
1024 immersive_style_ = enable;
1025 }
1026
1027 SkAlpha TabStrip::GetInactiveAlpha(bool for_new_tab_button) const { 1020 SkAlpha TabStrip::GetInactiveAlpha(bool for_new_tab_button) const {
1028 #if defined(USE_ASH) 1021 #if defined(USE_ASH)
1029 static const SkAlpha kInactiveTabAlphaAsh = 230; 1022 static const SkAlpha kInactiveTabAlphaAsh = 230;
1030 const SkAlpha base_alpha = kInactiveTabAlphaAsh; 1023 const SkAlpha base_alpha = kInactiveTabAlphaAsh;
1031 #else 1024 #else
1032 static const SkAlpha kInactiveTabAlphaGlass = 200; 1025 static const SkAlpha kInactiveTabAlphaGlass = 200;
1033 static const SkAlpha kInactiveTabAlphaOpaque = 255; 1026 static const SkAlpha kInactiveTabAlphaOpaque = 255;
1034 const SkAlpha base_alpha = GetWidget()->ShouldWindowContentsBeTransparent() ? 1027 const SkAlpha base_alpha = GetWidget()->ShouldWindowContentsBeTransparent() ?
1035 kInactiveTabAlphaGlass : kInactiveTabAlphaOpaque; 1028 kInactiveTabAlphaGlass : kInactiveTabAlphaOpaque;
1036 #endif // USE_ASH 1029 #endif // USE_ASH
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
1158 const ui::ListSelectionModel& original_selection) { 1151 const ui::ListSelectionModel& original_selection) {
1159 // Don't accidentally start any drag operations during animations if the 1152 // Don't accidentally start any drag operations during animations if the
1160 // mouse is down... during an animation tabs are being resized automatically, 1153 // mouse is down... during an animation tabs are being resized automatically,
1161 // so the View system can misinterpret this easily if the mouse is down that 1154 // so the View system can misinterpret this easily if the mouse is down that
1162 // the user is dragging. 1155 // the user is dragging.
1163 if (IsAnimating() || tab->closing() || 1156 if (IsAnimating() || tab->closing() ||
1164 controller_->HasAvailableDragActions() == 0) { 1157 controller_->HasAvailableDragActions() == 0) {
1165 return; 1158 return;
1166 } 1159 }
1167 1160
1168 // Do not do any dragging of tabs when using the super short immersive style.
1169 if (IsImmersiveStyle())
1170 return;
1171
1172 int model_index = GetModelIndexOfTab(tab); 1161 int model_index = GetModelIndexOfTab(tab);
1173 if (!IsValidModelIndex(model_index)) { 1162 if (!IsValidModelIndex(model_index)) {
1174 CHECK(false); 1163 CHECK(false);
1175 return; 1164 return;
1176 } 1165 }
1177 Tabs tabs; 1166 Tabs tabs;
1178 int size_to_selected = 0; 1167 int size_to_selected = 0;
1179 int x = tab->GetMirroredXInView(event.x()); 1168 int x = tab->GetMirroredXInView(event.x());
1180 int y = event.y(); 1169 int y = event.y();
1181 // Build the set of selected tabs to drag and calculate the offset from the 1170 // Build the set of selected tabs to drag and calculate the offset from the
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
1301 *clip = border_callback.Run(tab_at(index - 1)->size()); 1290 *clip = border_callback.Run(tab_at(index - 1)->size());
1302 clip->offset(SkIntToScalar(previous_x - current_x), 0); 1291 clip->offset(SkIntToScalar(previous_x - current_x), 0);
1303 } 1292 }
1304 } 1293 }
1305 return true; 1294 return true;
1306 } 1295 }
1307 1296
1308 bool TabStrip::CanPaintThrobberToLayer() const { 1297 bool TabStrip::CanPaintThrobberToLayer() const {
1309 // Disable layer-painting of throbbers if dragging, if any tab animation is in 1298 // Disable layer-painting of throbbers if dragging, if any tab animation is in
1310 // progress, or if stacked tabs are enabled. Also disable in fullscreen: when 1299 // progress, or if stacked tabs are enabled. Also disable in fullscreen: when
1311 // "immersive" the tab strip could be sliding in or out while transitioning to 1300 // "immersive" the tab strip could be sliding in or out; for other modes,
1312 // or away from |immersive_style_| and, for other modes, there's no tab strip. 1301 // there's no tab strip.
1313 const bool dragging = drag_controller_ && drag_controller_->started_drag(); 1302 const bool dragging = drag_controller_ && drag_controller_->started_drag();
1314 const views::Widget* widget = GetWidget(); 1303 const views::Widget* widget = GetWidget();
1315 return widget && !touch_layout_ && !dragging && !IsAnimating() && 1304 return widget && !touch_layout_ && !dragging && !IsAnimating() &&
1316 !widget->IsFullscreen(); 1305 !widget->IsFullscreen();
1317 } 1306 }
1318 1307
1319 bool TabStrip::IsImmersiveStyle() const {
1320 return immersive_style_;
1321 }
1322
1323 SkColor TabStrip::GetToolbarTopSeparatorColor() const { 1308 SkColor TabStrip::GetToolbarTopSeparatorColor() const {
1324 return controller_->GetToolbarTopSeparatorColor(); 1309 return controller_->GetToolbarTopSeparatorColor();
1325 } 1310 }
1326 1311
1327 // Returns the accessible tab name for the tab. 1312 // Returns the accessible tab name for the tab.
1328 base::string16 TabStrip::GetAccessibleTabName(const Tab* tab) const { 1313 base::string16 TabStrip::GetAccessibleTabName(const Tab* tab) const {
1329 int model_index = GetModelIndexOfTab(tab); 1314 int model_index = GetModelIndexOfTab(tab);
1330 if (IsValidModelIndex(model_index)) 1315 if (IsValidModelIndex(model_index))
1331 return controller_->GetAccessibleTabName(tab); 1316 return controller_->GetAccessibleTabName(tab);
1332 return base::string16(); 1317 return base::string16();
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after
1508 needed_tab_width -= (tab_count() - 1) * Tab::kOverlap; 1493 needed_tab_width -= (tab_count() - 1) * Tab::kOverlap;
1509 1494
1510 // Don't let the tabstrip shrink smaller than is necessary to show one tab, 1495 // Don't let the tabstrip shrink smaller than is necessary to show one tab,
1511 // and don't force it to be larger than is necessary to show 20 tabs. 1496 // and don't force it to be larger than is necessary to show 20 tabs.
1512 const int largest_min_tab_width = 1497 const int largest_min_tab_width =
1513 min_selected_width + 19 * (min_unselected_width - Tab::kOverlap); 1498 min_selected_width + 19 * (min_unselected_width - Tab::kOverlap);
1514 needed_tab_width = std::min( 1499 needed_tab_width = std::min(
1515 std::max(needed_tab_width, min_selected_width), largest_min_tab_width); 1500 std::max(needed_tab_width, min_selected_width), largest_min_tab_width);
1516 } 1501 }
1517 return gfx::Size(needed_tab_width + GetNewTabButtonWidth(), 1502 return gfx::Size(needed_tab_width + GetNewTabButtonWidth(),
1518 immersive_style_ ? Tab::GetImmersiveHeight() 1503 Tab::GetMinimumInactiveSize().height());
1519 : Tab::GetMinimumInactiveSize().height());
1520 } 1504 }
1521 1505
1522 void TabStrip::OnDragEntered(const DropTargetEvent& event) { 1506 void TabStrip::OnDragEntered(const DropTargetEvent& event) {
1523 // Force animations to stop, otherwise it makes the index calculation tricky. 1507 // Force animations to stop, otherwise it makes the index calculation tricky.
1524 StopAnimating(true); 1508 StopAnimating(true);
1525 1509
1526 UpdateDropIndex(event); 1510 UpdateDropIndex(event);
1527 1511
1528 GURL url; 1512 GURL url;
1529 base::string16 title; 1513 base::string16 title;
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
1609 if (view) 1593 if (view)
1610 return view; 1594 return view;
1611 } 1595 }
1612 Tab* tab = FindTabForEvent(point); 1596 Tab* tab = FindTabForEvent(point);
1613 if (tab) 1597 if (tab)
1614 return ConvertPointToViewAndGetTooltipHandler(this, tab, point); 1598 return ConvertPointToViewAndGetTooltipHandler(this, tab, point);
1615 } 1599 }
1616 return this; 1600 return this;
1617 } 1601 }
1618 1602
1619 // static
1620 int TabStrip::GetImmersiveHeight() {
1621 return Tab::GetImmersiveHeight();
1622 }
1623
1624 /////////////////////////////////////////////////////////////////////////////// 1603 ///////////////////////////////////////////////////////////////////////////////
1625 // TabStrip, private: 1604 // TabStrip, private:
1626 1605
1627 void TabStrip::Init() { 1606 void TabStrip::Init() {
1628 set_id(VIEW_ID_TAB_STRIP); 1607 set_id(VIEW_ID_TAB_STRIP);
1629 // So we get enter/exit on children to switch stacked layout on and off. 1608 // So we get enter/exit on children to switch stacked layout on and off.
1630 set_notify_enter_exit_on_child(true); 1609 set_notify_enter_exit_on_child(true);
1631 1610
1632 newtab_button_bounds_.set_size(GetLayoutSize(NEW_TAB_BUTTON)); 1611 newtab_button_bounds_.set_size(GetLayoutSize(NEW_TAB_BUTTON));
1633 newtab_button_bounds_.Inset(0, 0, 0, -GetNewTabButtonTopOffset()); 1612 newtab_button_bounds_.Inset(0, 0, 0, -GetNewTabButtonTopOffset());
(...skipping 1168 matching lines...) Expand 10 before | Expand all | Expand 10 after
2802 ConvertPointToViewAndGetEventHandler(this, newtab_button_, point); 2781 ConvertPointToViewAndGetEventHandler(this, newtab_button_, point);
2803 if (view) 2782 if (view)
2804 return view; 2783 return view;
2805 } 2784 }
2806 Tab* tab = FindTabForEvent(point); 2785 Tab* tab = FindTabForEvent(point);
2807 if (tab) 2786 if (tab)
2808 return ConvertPointToViewAndGetEventHandler(this, tab, point); 2787 return ConvertPointToViewAndGetEventHandler(this, tab, point);
2809 } 2788 }
2810 return this; 2789 return this;
2811 } 2790 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/views/tabs/tab_strip.h ('k') | chrome/browser/ui/views/tabs/tab_strip_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698