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

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

Issue 2628533002: Fix tabs are not rendered properly when restore tabs after crash on iPad (Closed)
Patch Set: 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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()) {
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698