Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/tab_switcher/tab_switcher_controller.h" | 5 #import "ios/chrome/browser/ui/tab_switcher/tab_switcher_controller.h" |
| 6 | 6 |
| 7 #include "base/ios/block_types.h" | 7 #include "base/ios/block_types.h" |
| 8 #include "base/ios/weak_nsobject.h" | 8 #include "base/ios/weak_nsobject.h" |
| 9 #include "base/mac/scoped_nsobject.h" | 9 #include "base/mac/scoped_nsobject.h" |
| 10 #include "base/metrics/user_metrics.h" | 10 #include "base/metrics/user_metrics.h" |
| (...skipping 550 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 561 const CGFloat cellTopBarHeight = tabSwitcherLocalSessionCellTopBarHeight(); | 561 const CGFloat cellTopBarHeight = tabSwitcherLocalSessionCellTopBarHeight(); |
| 562 CGRect finalToolbarScreenshotFrame = | 562 CGRect finalToolbarScreenshotFrame = |
| 563 CGRectMake(0, 0, selectedCellFrame.size.width, cellTopBarHeight); | 563 CGRectMake(0, 0, selectedCellFrame.size.width, cellTopBarHeight); |
| 564 | 564 |
| 565 base::scoped_nsobject<UIImageView> tabScreenshotImageView( | 565 base::scoped_nsobject<UIImageView> tabScreenshotImageView( |
| 566 [[UIImageView alloc] initWithFrame:CGRectZero]); | 566 [[UIImageView alloc] initWithFrame:CGRectZero]); |
| 567 | 567 |
| 568 base::WeakNSObject<UIImageView> weakTabScreenshotImageView( | 568 base::WeakNSObject<UIImageView> weakTabScreenshotImageView( |
| 569 tabScreenshotImageView.get()); | 569 tabScreenshotImageView.get()); |
| 570 | 570 |
| 571 if (self.transitionContext.initialTabModel != tabModel || | 571 if ([self initialTabModelAndTabDifferFromTabModel:tabModel |
| 572 transitionContextContent.initialSelectedTabIndex != selectedTabIndex) { | 572 andTabID:selectedTab.tabId]) { |
|
marq (ping after 24h)
2017/03/30 06:17:45
Align colons.
| |
| 573 // If we're transitioning to a different tab than the one we animated in | |
|
marq (ping after 24h)
2017/03/30 06:17:45
Avoid using "we" in comments; it can be ambiguous.
| |
| 574 // from, generate a new snapshot instead of using the transition | |
| 575 // context... | |
| 573 tabScreenshotImageView.get().image = | 576 tabScreenshotImageView.get().image = |
| 574 [self updateScreenshotForCellIfNeeded:selectedCell tabModel:tabModel]; | 577 [self updateScreenshotForCellIfNeeded:selectedCell tabModel:tabModel]; |
| 575 [selectedTab retrieveSnapshot:^(UIImage* snapshot) { | 578 [selectedTab retrieveSnapshot:^(UIImage* snapshot) { |
| 576 [weakTabScreenshotImageView setImage:snapshot]; | 579 [weakTabScreenshotImageView setImage:snapshot]; |
| 577 }]; | 580 }]; |
| 578 } else { | 581 } else { |
| 579 tabScreenshotImageView.get().image = | 582 tabScreenshotImageView.get().image = |
| 580 self.transitionContext.tabSnapshotImage; | 583 self.transitionContext.tabSnapshotImage; |
| 581 } | 584 } |
| 582 | 585 |
| (...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 709 tabScreenshotImageView.get().frame = finalTabScreenshotFrame; | 712 tabScreenshotImageView.get().frame = finalTabScreenshotFrame; |
| 710 }; | 713 }; |
| 711 | 714 |
| 712 [UIView animateWithDuration:animated ? kTransitionAnimationDuration : 0 | 715 [UIView animateWithDuration:animated ? kTransitionAnimationDuration : 0 |
| 713 delay:0 | 716 delay:0 |
| 714 options:UIViewAnimationCurveEaseInOut | 717 options:UIViewAnimationCurveEaseInOut |
| 715 animations:animationBlock | 718 animations:animationBlock |
| 716 completion:completionBlock]; | 719 completion:completionBlock]; |
| 717 } | 720 } |
| 718 | 721 |
| 722 - (BOOL)initialTabModelAndTabDifferFromTabModel:(nonnull TabModel*)tabModel | |
| 723 andTabID:(nonnull NSString*)tabID { | |
|
marq (ping after 24h)
2017/03/30 06:17:45
Align colons.
Prefer not to use 'and' to join met
| |
| 724 BOOL differ = NO; | |
|
marq (ping after 24h)
2017/03/30 06:17:44
'differs' ? But see below.
| |
| 725 TabModel *initialTabModel = self.transitionContext.initialTabModel; | |
|
marq (ping after 24h)
2017/03/30 06:17:44
Chromium style is to have the pointer operator adh
| |
| 726 NSString* initialTabID = [self transitionContextContentForTabModel: | |
| 727 initialTabModel].initialTabID; | |
| 728 differ = initialTabModel != tabModel || | |
| 729 [initialTabID isEqualToString:tabID] == NO; | |
| 730 return differ; | |
|
marq (ping after 24h)
2017/03/30 06:17:45
Instead of using the intermediate variable, it's c
marq (ping after 24h)
2017/03/30 09:20:06
And, (as I should have realized), we can apply De
| |
| 731 } | |
| 732 | |
| 719 - (void)updateLocalPanelsCells { | 733 - (void)updateLocalPanelsCells { |
| 720 auto mainTabPanel = | 734 auto mainTabPanel = |
| 721 [self panelControllerForTabModel:[_tabSwitcherModel mainTabModel]]; | 735 [self panelControllerForTabModel:[_tabSwitcherModel mainTabModel]]; |
| 722 auto otrTabPanel = | 736 auto otrTabPanel = |
| 723 [self panelControllerForTabModel:[_tabSwitcherModel otrTabModel]]; | 737 [self panelControllerForTabModel:[_tabSwitcherModel otrTabModel]]; |
| 724 [mainTabPanel reload]; | 738 [mainTabPanel reload]; |
| 725 [otrTabPanel reload]; | 739 [otrTabPanel reload]; |
| 726 } | 740 } |
| 727 | 741 |
| 728 - (NSInteger)currentPanelIndex { | 742 - (NSInteger)currentPanelIndex { |
| (...skipping 507 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1236 base::UserMetricsAction("MobileTabSwitcherCloseNonIncognitoTab")); | 1250 base::UserMetricsAction("MobileTabSwitcherCloseNonIncognitoTab")); |
| 1237 } | 1251 } |
| 1238 } | 1252 } |
| 1239 | 1253 |
| 1240 - (void)tabSwitcherPanelControllerDidUpdateOverlayViewVisibility: | 1254 - (void)tabSwitcherPanelControllerDidUpdateOverlayViewVisibility: |
| 1241 (TabSwitcherPanelController*)tabSwitcherPanelController { | 1255 (TabSwitcherPanelController*)tabSwitcherPanelController { |
| 1242 [_tabSwitcherView updateOverlayButtonState]; | 1256 [_tabSwitcherView updateOverlayButtonState]; |
| 1243 } | 1257 } |
| 1244 | 1258 |
| 1245 @end | 1259 @end |
| OLD | NEW |