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

Unified Diff: chrome/browser/ui/cocoa/tabs/tab_strip_controller.mm

Issue 1946993004: [Mac][Material Design] Fix TabStripController test that fails under MD. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix variable name. Created 4 years, 7 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
Index: chrome/browser/ui/cocoa/tabs/tab_strip_controller.mm
diff --git a/chrome/browser/ui/cocoa/tabs/tab_strip_controller.mm b/chrome/browser/ui/cocoa/tabs/tab_strip_controller.mm
index 8b75753a5e6a9f903185f9613587cba16f541642..e9f2df3f20a10c1c3091e413d6a88e9881303348 100644
--- a/chrome/browser/ui/cocoa/tabs/tab_strip_controller.mm
+++ b/chrome/browser/ui/cocoa/tabs/tab_strip_controller.mm
@@ -84,14 +84,6 @@ namespace {
// view.
const CGFloat kUseFullAvailableWidth = -1.0;
-// The amount by which tabs overlap.
-// Needs to be <= the x position of the favicon within a tab. Else, every time
-// the throbber is painted, the throbber's invalidation will also invalidate
-// parts of the tab to the left, and two tabs's backgrounds need to be painted
-// on each throbber frame instead of one.
-const CGFloat kTabOverlap = 18.0;
-const CGFloat kTabOverlapNonMD = 19.0;
-
// The amount by which pinned tabs are separated from normal tabs.
const CGFloat kLastPinnedTabSpacing = 2.0;
@@ -559,6 +551,20 @@ private:
return 70.0;
}
++ (CGFloat)tabOverlap {
+ // The overlap value needs to be <= the x position of the favicon within a
+ // tab. Else, every time the throbber is painted, the throbber's invalidation
+ // will also invalidate parts of the tab to the left, and two tabs's
+ // backgrounds need to be painted on each throbber frame instead of one.
+ const CGFloat kTabOverlap = 18.0;
+ const CGFloat kTabOverlapNonMD = 19.0;
+
+ if (!ui::MaterialDesignController::IsModeMaterial()) {
+ return kTabOverlapNonMD;
+ }
+ return kTabOverlap;
+}
+
// Finds the TabContentsController associated with the given index into the tab
// model and swaps out the sole child of the contentArea to display its
// contents.
@@ -912,6 +918,7 @@ private:
const CGFloat kMinTabWidth = [TabController minTabWidth];
const CGFloat kMinActiveTabWidth = [TabController minActiveTabWidth];
const CGFloat kPinnedTabWidth = [TabController pinnedTabWidth];
+ const CGFloat kTabOverlap = [TabStripController tabOverlap];
NSRect enclosingRect = NSZeroRect;
ScopedNSAnimationContextGroup mainAnimationGroup(animate);
@@ -935,7 +942,7 @@ private:
if (!ui::MaterialDesignController::IsModeMaterial()) {
availableSpace -=
NSWidth([newTabButton_ frame]) + kNewTabButtonOffsetNonMD -
- kTabOverlapNonMD;
+ kTabOverlap;
} else {
availableSpace -=
NSWidth([newTabButton_ frame]) + kNewTabButtonOffset - kTabOverlap;
@@ -966,8 +973,8 @@ private:
CGFloat nonPinnedTabWidthFraction = 0;
NSInteger numberOfNonPinnedTabs = MIN(
[self numberOfOpenNonPinnedTabs],
- (availableSpaceForNonPinned - kTabOverlap) / (kMinTabWidth -
- kTabOverlap));
+ (availableSpaceForNonPinned - kTabOverlap) /
+ (kMinTabWidth - kTabOverlap));
if (numberOfNonPinnedTabs) {
// Find the width of a non-pinned tab. This only applies to horizontal
@@ -990,14 +997,12 @@ private:
// of 10.
if (numberOfNonPinnedTabs > 1 && nonPinnedTabWidth < kMinActiveTabWidth) {
nonPinnedTabWidth = (availableSpaceForNonPinned - kMinActiveTabWidth) /
- (numberOfNonPinnedTabs - 1) +
- kTabOverlap;
+ (numberOfNonPinnedTabs - 1) + kTabOverlap;
if (nonPinnedTabWidth < kMinTabWidth) {
// The above adjustment caused the tabs to not fit, show 1 less tab.
--numberOfNonPinnedTabs;
nonPinnedTabWidth = ((availableSpaceForNonPinned - kTabOverlap) /
- numberOfNonPinnedTabs) +
- kTabOverlap;
+ numberOfNonPinnedTabs) + kTabOverlap;
}
}
@@ -1979,6 +1984,7 @@ private:
// to drop on that tab).
const double kMiddleProportion = 0.5;
const double kLRProportion = (1.0 - kMiddleProportion) / 2.0;
+ const CGFloat kTabOverlap = [TabStripController tabOverlap];
DCHECK(index && disposition);
NSInteger i = 0;
@@ -2100,6 +2106,7 @@ private:
// The minimum y-coordinate at which one should consider place the arrow.
const CGFloat arrowBaseY = 25;
+ const CGFloat kTabOverlap = [TabStripController tabOverlap];
NSInteger index;
WindowOpenDisposition disposition;
« no previous file with comments | « chrome/browser/ui/cocoa/tabs/tab_strip_controller.h ('k') | chrome/browser/ui/cocoa/tabs/tab_strip_controller_unittest.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698