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 715b40e8287fe44be710e795880c888358ca1083..623981a7afaf6b570d18e16c8c1cf84d51a6941d 100644 |
| --- a/ios/chrome/browser/ui/tabs/tab_strip_controller.mm |
| +++ b/ios/chrome/browser/ui/tabs/tab_strip_controller.mm |
| @@ -1263,6 +1263,30 @@ - (void)updateContentOffsetForTabIndex:(NSUInteger)tabIndex |
| // long. The amount of scroll is calculated as a desired length that it is |
| // just large enough to contain all the tabs to the left of |tabIndex|, with |
| // the standard overlap. |
| + if (tabIndex == [_tabArray count] - 1) { |
|
rohitrao (ping after 24h)
2017/01/19 01:44:22
If crash restore adds 100 tabs to the tabstrip, wi
liaoyuke
2017/01/20 00:55:51
Yes, the complexity is n^2, every tab view will be
|
| + const CGFloat tabStripAvailableSpace = |
| + _tabStripView.frame.size.width - _tabStripView.contentInset.right; |
| + CGPoint oldOffset = [_tabStripView contentOffset]; |
| + if (_tabStripView.contentSize.width > tabStripAvailableSpace) { |
| + CGFloat scrollToPoint = |
| + _tabStripView.contentSize.width - tabStripAvailableSpace; |
| + [_tabStripView setContentOffset:CGPointMake(scrollToPoint, 0)]; |
| + } |
| + |
| + // To handle content offset change without making views appear to jump, |
| + // shift all of the subviews by an amount equal to the size change. This |
| + // effectively places the subviews back where they were before the change, |
| + // in terms of screen coordinates. |
| + CGFloat dx = [_tabStripView contentOffset].x - oldOffset.x; |
| + for (UIView* view in [_tabStripView subviews]) { |
|
rohitrao (ping after 24h)
2017/01/19 01:44:22
Is there any way to share this code with the other
liaoyuke
2017/01/20 00:55:51
Done.
|
| + CGRect frame = [view frame]; |
| + frame.origin.x += dx; |
| + [view setFrame:frame]; |
| + _targetFrames.AddFrame(view, frame); |
| + } |
| + return; |
|
rohitrao (ping after 24h)
2017/01/19 01:44:22
This function now has two early returns, which mak
liaoyuke
2017/01/20 00:55:51
From my point of view, I think it would be non-tri
|
| + } |
| + |
| NSUInteger numNonClosingTabsToLeft = 0; |
| NSUInteger i = 0; |
| for (TabView* tab in _tabArray.get()) { |