Chromium Code Reviews| 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 = |