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 initialTabModelAndTabIDMatchesTabModel:tabModel |
|
jif
2017/03/30 19:50:58
Can you write the code without the "!" (i.e. swap
| |
| 572 transitionContextContent.initialSelectedTabIndex != selectedTabIndex) { | 572 tabID:selectedTab.tabId]) { |
| 573 // If transitioning to a different tab than the one animated in | |
| 574 // from, a new snapshot should be generated instead of using the transition | |
| 575 // context... | |
|
jif
2017/03/30 19:50:58
no need for the "..."
| |
| 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)initialTabModelAndTabIDMatchesTabModel:(nonnull TabModel*)tabModel | |
| 723 tabID:(nonnull NSString*)tabID { | |
| 724 TabModel* initialTabModel = self.transitionContext.initialTabModel; | |
| 725 NSString* initialTabID = | |
| 726 [self transitionContextContentForTabModel:initialTabModel].initialTabID; | |
| 727 return initialTabModel == tabModel && [initialTabID isEqualToString:tabID]; | |
| 728 } | |
| 729 | |
| 719 - (void)updateLocalPanelsCells { | 730 - (void)updateLocalPanelsCells { |
| 720 auto mainTabPanel = | 731 auto mainTabPanel = |
| 721 [self panelControllerForTabModel:[_tabSwitcherModel mainTabModel]]; | 732 [self panelControllerForTabModel:[_tabSwitcherModel mainTabModel]]; |
| 722 auto otrTabPanel = | 733 auto otrTabPanel = |
| 723 [self panelControllerForTabModel:[_tabSwitcherModel otrTabModel]]; | 734 [self panelControllerForTabModel:[_tabSwitcherModel otrTabModel]]; |
| 724 [mainTabPanel reload]; | 735 [mainTabPanel reload]; |
| 725 [otrTabPanel reload]; | 736 [otrTabPanel reload]; |
| 726 } | 737 } |
| 727 | 738 |
| 728 - (NSInteger)currentPanelIndex { | 739 - (NSInteger)currentPanelIndex { |
| (...skipping 507 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1236 base::UserMetricsAction("MobileTabSwitcherCloseNonIncognitoTab")); | 1247 base::UserMetricsAction("MobileTabSwitcherCloseNonIncognitoTab")); |
| 1237 } | 1248 } |
| 1238 } | 1249 } |
| 1239 | 1250 |
| 1240 - (void)tabSwitcherPanelControllerDidUpdateOverlayViewVisibility: | 1251 - (void)tabSwitcherPanelControllerDidUpdateOverlayViewVisibility: |
| 1241 (TabSwitcherPanelController*)tabSwitcherPanelController { | 1252 (TabSwitcherPanelController*)tabSwitcherPanelController { |
| 1242 [_tabSwitcherView updateOverlayButtonState]; | 1253 [_tabSwitcherView updateOverlayButtonState]; |
| 1243 } | 1254 } |
| 1244 | 1255 |
| 1245 @end | 1256 @end |
| OLD | NEW |