OLD | NEW |
---|---|
1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 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 #import "ios/chrome/browser/ui/tabs/tab_strip_controller.h" | 5 #import "ios/chrome/browser/ui/tabs/tab_strip_controller.h" |
6 #import "ios/chrome/browser/ui/tabs/tab_strip_controller_private.h" | 6 #import "ios/chrome/browser/ui/tabs/tab_strip_controller_private.h" |
7 | 7 |
8 #include <cmath> | 8 #include <cmath> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 1235 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1246 return IsCompactTablet() ? kTabOverlapForCompactLayout : kTabOverlap; | 1246 return IsCompactTablet() ? kTabOverlapForCompactLayout : kTabOverlap; |
1247 } | 1247 } |
1248 | 1248 |
1249 - (CGFloat)minTabWidth { | 1249 - (CGFloat)minTabWidth { |
1250 return IsCompactTablet() ? kMinTabWidthForCompactLayout : kMinTabWidth; | 1250 return IsCompactTablet() ? kMinTabWidthForCompactLayout : kMinTabWidth; |
1251 } | 1251 } |
1252 | 1252 |
1253 - (void)updateContentOffsetForTabIndex:(NSUInteger)tabIndex { | 1253 - (void)updateContentOffsetForTabIndex:(NSUInteger)tabIndex { |
1254 DCHECK_NE(NSNotFound, static_cast<NSInteger>(tabIndex)); | 1254 DCHECK_NE(NSNotFound, static_cast<NSInteger>(tabIndex)); |
1255 | 1255 |
1256 if (experimental_flags::IsTabStripAutoScrollNewTabsEnabled()) { | |
1257 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.
| |
1258 NSUInteger i = 0; | |
1259 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
| |
1260 if ([_closingTabs containsObject:tab]) | |
1261 ++i; | |
1262 | |
1263 if (i == tabIndex) | |
1264 break; | |
1265 | |
1266 ++numTabsToLeft; | |
1267 ++i; | |
1268 } | |
1269 | |
1270 const CGFloat tabHeight = CGRectGetHeight([_tabStripView bounds]); | |
1271 CGRect scrollRect = | |
1272 CGRectMake(_currentTabWidth * numTabsToLeft - | |
1273 ([self tabOverlap] * (numTabsToLeft - 1)), | |
1274 0, _currentTabWidth, tabHeight); | |
1275 [_tabStripView scrollRectToVisible:scrollRect animated:YES]; | |
1276 return; | |
1277 } | |
1278 | |
1256 if (IsCompactTablet()) { | 1279 if (IsCompactTablet()) { |
1257 if (tabIndex == [_tabArray count] - 1) { | 1280 if (tabIndex == [_tabArray count] - 1) { |
1258 const CGFloat tabStripAvailableSpace = | 1281 const CGFloat tabStripAvailableSpace = |
1259 _tabStripView.frame.size.width - _tabStripView.contentInset.right; | 1282 _tabStripView.frame.size.width - _tabStripView.contentInset.right; |
1260 if (_tabStripView.contentSize.width > tabStripAvailableSpace) { | 1283 if (_tabStripView.contentSize.width > tabStripAvailableSpace) { |
1261 CGFloat scrollToPoint = | 1284 CGFloat scrollToPoint = |
1262 _tabStripView.contentSize.width - tabStripAvailableSpace; | 1285 _tabStripView.contentSize.width - tabStripAvailableSpace; |
1263 [_tabStripView setContentOffset:CGPointMake(scrollToPoint, 0) | 1286 [_tabStripView setContentOffset:CGPointMake(scrollToPoint, 0) |
1264 animated:YES]; | 1287 animated:YES]; |
1265 } | 1288 } |
(...skipping 391 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1657 | 1680 |
1658 @implementation TabStripController (Testing) | 1681 @implementation TabStripController (Testing) |
1659 | 1682 |
1660 - (TabView*)existingTabViewForTab:(Tab*)tab { | 1683 - (TabView*)existingTabViewForTab:(Tab*)tab { |
1661 NSUInteger tabIndex = [_tabModel indexOfTab:tab]; | 1684 NSUInteger tabIndex = [_tabModel indexOfTab:tab]; |
1662 NSUInteger tabViewIndex = [self indexForModelIndex:tabIndex]; | 1685 NSUInteger tabViewIndex = [self indexForModelIndex:tabIndex]; |
1663 return [_tabArray objectAtIndex:tabViewIndex]; | 1686 return [_tabArray objectAtIndex:tabViewIndex]; |
1664 } | 1687 } |
1665 | 1688 |
1666 @end | 1689 @end |
OLD | NEW |