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

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

Issue 2210033002: Proper rendering of stacked tabs for MD. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Resync Created 4 years, 4 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
« no previous file with comments | « chrome/browser/ui/views/tabs/tab_strip.h ('k') | chrome/browser/ui/views/tabs/tab_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
102 102
103 // See UpdateLayoutTypeFromMouseEvent() for a description of these. 103 // See UpdateLayoutTypeFromMouseEvent() for a description of these.
104 #if !defined(USE_ASH) 104 #if !defined(USE_ASH)
105 const int kMouseMoveTimeMS = 200; 105 const int kMouseMoveTimeMS = 200;
106 const int kMouseMoveCountBeforeConsiderReal = 3; 106 const int kMouseMoveCountBeforeConsiderReal = 3;
107 #endif 107 #endif
108 108
109 // Amount of time we delay before resizing after a close from a touch. 109 // Amount of time we delay before resizing after a close from a touch.
110 const int kTouchResizeLayoutTimeMS = 2000; 110 const int kTouchResizeLayoutTimeMS = 2000;
111 111
112 // Amount to adjust the clip by when the tab is stacked before the active index.
113 const int kStackedTabLeftClip = 20;
114
115 // Amount to adjust the clip by when the tab is stacked after the active index.
116 const int kStackedTabRightClip = 20;
117
118 #if defined(OS_MACOSX) 112 #if defined(OS_MACOSX)
119 const int kPinnedToNonPinnedOffset = 2; 113 const int kPinnedToNonPinnedOffset = 2;
120 #else 114 #else
121 const int kPinnedToNonPinnedOffset = 3; 115 const int kPinnedToNonPinnedOffset = 3;
122 #endif 116 #endif
123 117
124 // Returns the offset from the top of the tabstrip at which the new tab button's 118 // Returns the offset from the top of the tabstrip at which the new tab button's
125 // visible region begins. 119 // visible region begins.
126 int GetNewTabButtonTopOffset() { 120 int GetNewTabButtonTopOffset() {
127 // The vertical distance between the bottom of the new tab button and the 121 // The vertical distance between the bottom of the new tab button and the
(...skipping 1030 matching lines...) Expand 10 before | Expand all | Expand 10 after
1158 } 1152 }
1159 1153
1160 bool TabStrip::ShouldHideCloseButtonForInactiveTabs() { 1154 bool TabStrip::ShouldHideCloseButtonForInactiveTabs() {
1161 if (!touch_layout_) 1155 if (!touch_layout_)
1162 return false; 1156 return false;
1163 1157
1164 return !base::CommandLine::ForCurrentProcess()->HasSwitch( 1158 return !base::CommandLine::ForCurrentProcess()->HasSwitch(
1165 switches::kDisableHideInactiveStackedTabCloseButtons); 1159 switches::kDisableHideInactiveStackedTabCloseButtons);
1166 } 1160 }
1167 1161
1162 bool TabStrip::MaySetClip() {
1163 // Only touch layout needs to restrict the clip.
1164 return touch_layout_ || IsStackingDraggedTabs();
1165 }
1166
1168 void TabStrip::SelectTab(Tab* tab) { 1167 void TabStrip::SelectTab(Tab* tab) {
1169 int model_index = GetModelIndexOfTab(tab); 1168 int model_index = GetModelIndexOfTab(tab);
1170 if (IsValidModelIndex(model_index)) 1169 if (IsValidModelIndex(model_index))
1171 controller_->SelectTab(model_index); 1170 controller_->SelectTab(model_index);
1172 } 1171 }
1173 1172
1174 void TabStrip::ExtendSelectionTo(Tab* tab) { 1173 void TabStrip::ExtendSelectionTo(Tab* tab) {
1175 int model_index = GetModelIndexOfTab(tab); 1174 int model_index = GetModelIndexOfTab(tab);
1176 if (IsValidModelIndex(model_index)) 1175 if (IsValidModelIndex(model_index))
1177 controller_->ExtendSelectionTo(model_index); 1176 controller_->ExtendSelectionTo(model_index);
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after
1339 view = view->parent(); 1338 view = view->parent();
1340 1339
1341 return view && view->id() == VIEW_ID_TAB ? static_cast<Tab*>(view) : NULL; 1340 return view && view->id() == VIEW_ID_TAB ? static_cast<Tab*>(view) : NULL;
1342 } 1341 }
1343 1342
1344 void TabStrip::OnMouseEventInTab(views::View* source, 1343 void TabStrip::OnMouseEventInTab(views::View* source,
1345 const ui::MouseEvent& event) { 1344 const ui::MouseEvent& event) {
1346 UpdateStackedLayoutFromMouseEvent(source, event); 1345 UpdateStackedLayoutFromMouseEvent(source, event);
1347 } 1346 }
1348 1347
1349 bool TabStrip::ShouldPaintTab(const Tab* tab, gfx::Rect* clip) { 1348 bool TabStrip::ShouldPaintTab(
1350 // Only touch layout needs to restrict the clip. 1349 const Tab* tab,
1351 if (!touch_layout_ && !IsStackingDraggedTabs()) 1350 const base::Callback<gfx::Path(const gfx::Size&)>& border_callback,
1351 gfx::Path* clip) {
1352 if (!MaySetClip())
1352 return true; 1353 return true;
1353 1354
1354 int index = GetModelIndexOfTab(tab); 1355 int index = GetModelIndexOfTab(tab);
1355 if (index == -1) 1356 if (index == -1)
1356 return true; // Tab is closing, paint it all. 1357 return true; // Tab is closing, paint it all.
1357 1358
1358 int active_index = IsStackingDraggedTabs() ? 1359 int active_index = IsStackingDraggedTabs() ?
1359 controller_->GetActiveIndex() : touch_layout_->active_index(); 1360 controller_->GetActiveIndex() : touch_layout_->active_index();
1360 if (active_index == tab_count()) 1361 if (active_index == tab_count())
1361 active_index--; 1362 active_index--;
1362 1363
1363 const int current_x = tab_at(index)->x(); 1364 const int current_x = tab_at(index)->x();
1364 if (index < active_index) { 1365 if (index < active_index) {
1365 const int next_x = tab_at(index + 1)->x(); 1366 const int next_x = tab_at(index + 1)->x();
1366 if (current_x == next_x) 1367 if (current_x == next_x)
1367 return false; 1368 return false;
1368 1369
1369 if (current_x > next_x) 1370 if (current_x > next_x)
1370 return true; // Can happen during dragging. 1371 return true; // Can happen during dragging.
1371 1372
1372 clip->SetRect( 1373 *clip = border_callback.Run(tab_at(index + 1)->size());
1373 0, 0, next_x - current_x + kStackedTabLeftClip, 1374 clip->offset(SkIntToScalar(next_x - current_x), 0);
1374 tab_at(index)->height());
1375 } else if (index > active_index && index > 0) { 1375 } else if (index > active_index && index > 0) {
1376 const gfx::Rect& previous_bounds(tab_at(index - 1)->bounds()); 1376 const gfx::Rect& previous_bounds(tab_at(index - 1)->bounds());
1377 const int previous_x = previous_bounds.x(); 1377 const int previous_x = previous_bounds.x();
1378 if (current_x == previous_x) 1378 if (current_x == previous_x)
1379 return false; 1379 return false;
1380 1380
1381 if (current_x < previous_x) 1381 if (current_x < previous_x)
1382 return true; // Can happen during dragging. 1382 return true; // Can happen during dragging.
1383 1383
1384 if (previous_bounds.right() - GetLayoutConstant(TABSTRIP_TAB_OVERLAP) != 1384 if (previous_bounds.right() - GetLayoutConstant(TABSTRIP_TAB_OVERLAP) !=
1385 current_x) { 1385 current_x) {
1386 int x = previous_bounds.right() - current_x - kStackedTabRightClip; 1386 *clip = border_callback.Run(tab_at(index - 1)->size());
1387 const gfx::Rect& tab_bounds(tab_at(index)->bounds()); 1387 clip->offset(SkIntToScalar(previous_x - current_x), 0);
1388 clip->SetRect(x, 0, tab_bounds.width() - x, tab_bounds.height());
1389 } 1388 }
1390 } 1389 }
1391 return true; 1390 return true;
1392 } 1391 }
1393 1392
1394 bool TabStrip::CanPaintThrobberToLayer() const { 1393 bool TabStrip::CanPaintThrobberToLayer() const {
1395 // Disable layer-painting of throbbers if dragging, if any tab animation is in 1394 // Disable layer-painting of throbbers if dragging, if any tab animation is in
1396 // progress, or if stacked tabs are enabled. Also disable in fullscreen: when 1395 // progress, or if stacked tabs are enabled. Also disable in fullscreen: when
1397 // "immersive" the tab strip could be sliding in or out while transitioning to 1396 // "immersive" the tab strip could be sliding in or out while transitioning to
1398 // or away from |immersive_style_| and, for other modes, there's no tab strip. 1397 // or away from |immersive_style_| and, for other modes, there's no tab strip.
(...skipping 1488 matching lines...) Expand 10 before | Expand all | Expand 10 after
2887 ConvertPointToViewAndGetEventHandler(this, newtab_button_, point); 2886 ConvertPointToViewAndGetEventHandler(this, newtab_button_, point);
2888 if (view) 2887 if (view)
2889 return view; 2888 return view;
2890 } 2889 }
2891 Tab* tab = FindTabForEvent(point); 2890 Tab* tab = FindTabForEvent(point);
2892 if (tab) 2891 if (tab)
2893 return ConvertPointToViewAndGetEventHandler(this, tab, point); 2892 return ConvertPointToViewAndGetEventHandler(this, tab, point);
2894 } 2893 }
2895 return this; 2894 return this;
2896 } 2895 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/views/tabs/tab_strip.h ('k') | chrome/browser/ui/views/tabs/tab_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698