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

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

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

Powered by Google App Engine
This is Rietveld 408576698