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

Side by Side Diff: ios/chrome/browser/ui/tab_switcher/tab_switcher_controller.mm

Issue 2776083003: Use correct snapshot for the tab transition animation on iPad (Closed)
Patch Set: Formatting changes Created 3 years, 8 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 unified diff | Download patch
« no previous file with comments | « no previous file | ios/chrome/browser/ui/tab_switcher/tab_switcher_transition_context.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
572 transitionContextContent.initialSelectedTabIndex != selectedTabIndex) { 572 tabID:selectedTab.tabId]) {
573 tabScreenshotImageView.get().image =
574 self.transitionContext.tabSnapshotImage;
575 } else {
576 // If transitioning to a different tab than the one animated in
577 // from, a new snapshot should be generated instead of using the transition
578 // context
573 tabScreenshotImageView.get().image = 579 tabScreenshotImageView.get().image =
574 [self updateScreenshotForCellIfNeeded:selectedCell tabModel:tabModel]; 580 [self updateScreenshotForCellIfNeeded:selectedCell tabModel:tabModel];
575 [selectedTab retrieveSnapshot:^(UIImage* snapshot) { 581 [selectedTab retrieveSnapshot:^(UIImage* snapshot) {
576 [weakTabScreenshotImageView setImage:snapshot]; 582 [weakTabScreenshotImageView setImage:snapshot];
577 }]; 583 }];
578 } else {
579 tabScreenshotImageView.get().image =
580 self.transitionContext.tabSnapshotImage;
581 } 584 }
582 585
583 const CGSize tabScreenshotImageSize = tabScreenshotImageView.get().image.size; 586 const CGSize tabScreenshotImageSize = tabScreenshotImageView.get().image.size;
584 587
585 CGRect initialTabScreenshotFrame = CGRectZero; 588 CGRect initialTabScreenshotFrame = CGRectZero;
586 const CGSize toolbarSize = toolbarController.view.bounds.size; 589 const CGSize toolbarSize = toolbarController.view.bounds.size;
587 CGSize initialTabTargetSize = 590 CGSize initialTabTargetSize =
588 CGSizeMake(initialTabFrame.size.width, 591 CGSizeMake(initialTabFrame.size.width,
589 initialTabFrame.size.height - toolbarSize.height); 592 initialTabFrame.size.height - toolbarSize.height);
590 CGSize revisedTargetSize = CGSizeZero; 593 CGSize revisedTargetSize = CGSizeZero;
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
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
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
OLDNEW
« no previous file with comments | « no previous file | ios/chrome/browser/ui/tab_switcher/tab_switcher_transition_context.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698