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

Unified 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 side-by-side diff with in-line comments
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 »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/ui/views/tabs/tab_strip.cc
diff --git a/chrome/browser/ui/views/tabs/tab_strip.cc b/chrome/browser/ui/views/tabs/tab_strip.cc
index 0df1f6f8db610b94a44a8bddb29d9d089c30813c..5f8c0c711a3b40095608b19f49ff8ae28ee44085 100644
--- a/chrome/browser/ui/views/tabs/tab_strip.cc
+++ b/chrome/browser/ui/views/tabs/tab_strip.cc
@@ -109,12 +109,6 @@ const int kMouseMoveCountBeforeConsiderReal = 3;
// Amount of time we delay before resizing after a close from a touch.
const int kTouchResizeLayoutTimeMS = 2000;
-// Amount to adjust the clip by when the tab is stacked before the active index.
-const int kStackedTabLeftClip = 20;
-
-// Amount to adjust the clip by when the tab is stacked after the active index.
-const int kStackedTabRightClip = 20;
-
#if defined(OS_MACOSX)
const int kPinnedToNonPinnedOffset = 2;
#else
@@ -1165,6 +1159,11 @@ bool TabStrip::ShouldHideCloseButtonForInactiveTabs() {
switches::kDisableHideInactiveStackedTabCloseButtons);
}
+bool TabStrip::MaySetClip() {
+ // Only touch layout needs to restrict the clip.
+ return touch_layout_ || IsStackingDraggedTabs();
+}
+
void TabStrip::SelectTab(Tab* tab) {
int model_index = GetModelIndexOfTab(tab);
if (IsValidModelIndex(model_index))
@@ -1346,9 +1345,11 @@ void TabStrip::OnMouseEventInTab(views::View* source,
UpdateStackedLayoutFromMouseEvent(source, event);
}
-bool TabStrip::ShouldPaintTab(const Tab* tab, gfx::Rect* clip) {
- // Only touch layout needs to restrict the clip.
- if (!touch_layout_ && !IsStackingDraggedTabs())
+bool TabStrip::ShouldPaintTab(
+ const Tab* tab,
+ const base::Callback<gfx::Path(const gfx::Size&)>& border_callback,
+ gfx::Path* clip) {
+ if (!MaySetClip())
return true;
int index = GetModelIndexOfTab(tab);
@@ -1369,9 +1370,8 @@ bool TabStrip::ShouldPaintTab(const Tab* tab, gfx::Rect* clip) {
if (current_x > next_x)
return true; // Can happen during dragging.
- clip->SetRect(
- 0, 0, next_x - current_x + kStackedTabLeftClip,
- tab_at(index)->height());
+ *clip = border_callback.Run(tab_at(index + 1)->size());
+ clip->offset(SkIntToScalar(next_x - current_x), 0);
} else if (index > active_index && index > 0) {
const gfx::Rect& previous_bounds(tab_at(index - 1)->bounds());
const int previous_x = previous_bounds.x();
@@ -1383,9 +1383,8 @@ bool TabStrip::ShouldPaintTab(const Tab* tab, gfx::Rect* clip) {
if (previous_bounds.right() - GetLayoutConstant(TABSTRIP_TAB_OVERLAP) !=
current_x) {
- int x = previous_bounds.right() - current_x - kStackedTabRightClip;
- const gfx::Rect& tab_bounds(tab_at(index)->bounds());
- clip->SetRect(x, 0, tab_bounds.width() - x, tab_bounds.height());
+ *clip = border_callback.Run(tab_at(index - 1)->size());
+ clip->offset(SkIntToScalar(previous_x - current_x), 0);
}
}
return true;
« 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