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

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

Issue 2611003002: Autoscroll new background tabs on iPad (Closed)
Patch Set: Addressed Jason's comments to turn on the feature by default Created 3 years, 11 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: ios/chrome/browser/ui/tabs/tab_strip_controller.mm
diff --git a/ios/chrome/browser/ui/tabs/tab_strip_controller.mm b/ios/chrome/browser/ui/tabs/tab_strip_controller.mm
index ced59b8ddf92bb3c4f5b09453dda550999c6260b..215af54a90e639e31cd087aa2b128004ee277eef 100644
--- a/ios/chrome/browser/ui/tabs/tab_strip_controller.mm
+++ b/ios/chrome/browser/ui/tabs/tab_strip_controller.mm
@@ -1253,6 +1253,29 @@ - (CGFloat)minTabWidth {
- (void)updateContentOffsetForTabIndex:(NSUInteger)tabIndex {
DCHECK_NE(NSNotFound, static_cast<NSInteger>(tabIndex));
+ if (experimental_flags::IsTabStripAutoScrollNewTabsEnabled()) {
+ NSUInteger numTabsToLeft = 0;
rohitrao (ping after 24h) 2017/01/06 15:35:21 This could use a big comment explaining the goal o
liaoyuke 2017/01/06 20:46:49 Done.
+ NSUInteger i = 0;
+ for (TabView* tab in _tabArray.get()) {
rohitrao (ping after 24h) 2017/01/06 15:35:21 What is this for loop trying to do? I think can b
liaoyuke 2017/01/06 20:46:49 To find the number of non-closing tabs to the left
+ if ([_closingTabs containsObject:tab])
+ ++i;
+
+ if (i == tabIndex)
+ break;
+
+ ++numTabsToLeft;
+ ++i;
+ }
+
+ const CGFloat tabHeight = CGRectGetHeight([_tabStripView bounds]);
+ CGRect scrollRect =
+ CGRectMake(_currentTabWidth * numTabsToLeft -
+ ([self tabOverlap] * (numTabsToLeft - 1)),
+ 0, _currentTabWidth, tabHeight);
+ [_tabStripView scrollRectToVisible:scrollRect animated:YES];
+ return;
+ }
+
if (IsCompactTablet()) {
if (tabIndex == [_tabArray count] - 1) {
const CGFloat tabStripAvailableSpace =

Powered by Google App Engine
This is Rietveld 408576698