Commit 0afa7573 authored by Gauthier Ambard's avatar Gauthier Ambard Committed by Commit Bot

Animate the NTP instead of a snapshot

When opening a NTP a screenshot of the NTP is animated instead of the
real NTP.
The screenshot of the NTP is taken outside of the view hierarchy.

This creates multiple problems:
- The safe area insets have to be passed to the NTP before the snapshot
  is taken so it can adapt its layout.
- The images of the elements in the NTP (Most Visited, suggestions...)
  are displayed asynchronously, so they are empty on the snapshot.

In order to reduce the complexity on iPhone X and to have the images
displayed, it is possible to display the real view instead of its
snapshot.

As side effects, the user can interact with the NTP during the animation
and it is possible that it takes more computational ressources.

Animation before this CL: https://drive.google.com/file/d/1ma2Q_fGsK3lRSCAL91MZ3mXCD_R_tYEn/view
Animation with this CL: https://drive.google.com/file/d/1xHL2ANNPwtYEY0vffqVuCvEfhrVXl_4v/view

Bug: 792918
Cq-Include-Trybots: master.tryserver.chromium.mac:ios-simulator-cronet;master.tryserver.chromium.mac:ios-simulator-full-configs
Change-Id: Ibeb74f9ca96130db49bcf082356b55e6cf8d4d9a
Reviewed-on: https://chromium-review.googlesource.com/814295Reviewed-by: default avatarJustin Cohen <justincohen@chromium.org>
Reviewed-by: default avatarMark Cogan <marq@chromium.org>
Commit-Queue: Gauthier Ambard <gambard@chromium.org>
Cr-Commit-Position: refs/heads/master@{#523067}
parent a14d026f
......@@ -751,9 +751,6 @@ NSString* const kBrowserViewControllerSnackbarCategory =
// Returns the view to use when animating a page in or out, positioning it to
// fill the content area but not actually adding it to the view hierarchy.
- (UIImageView*)pageOpenCloseAnimationView;
// Returns the view to use when animating full screen NTP paper in, filling the
// entire screen but not actually adding it to the view hierarchy.
- (UIImageView*)pageFullScreenOpenCloseAnimationView;
// Updates the toolbar display based on the current tab.
- (void)updateToolbar;
// Starts or stops broadcasting the toolbar UI and main content UI depending on
......@@ -1736,26 +1733,40 @@ applicationCommandEndpoint:(id<ApplicationCommands>)applicationCommandEndpoint {
self.inNewTabAnimation = YES;
if (!inBackground) {
UIView* animationParentView = _contentArea;
// Create the new page image, and load with the new tab page snapshot.
// Create the new page image, and load with the new tab snapshot except if
// it is the NTP.
CGFloat newPageOffset = 0;
UIImageView* newPage;
UIView* newPage;
CGFloat offset = 0;
if (tab.webState->GetLastCommittedURL() == kChromeUINewTabURL &&
!_isOffTheRecord && !IsIPadIdiom()) {
offset = 0;
animationParentView = self.view;
newPage = [self pageFullScreenOpenCloseAnimationView];
newPage = tab.view;
newPage.userInteractionEnabled = NO;
// Compute a frame for the new page by removing the status bar height from
// the bounds of |self.view|.
CGRect viewBounds, remainder;
CGRectDivide(self.view.bounds, &remainder, &viewBounds, StatusBarHeight(),
CGRectMinYEdge);
newPage.frame = viewBounds;
} else {
newPage = [self pageOpenCloseAnimationView];
UIImageView* pageScreenshot = [self pageOpenCloseAnimationView];
tab.view.frame = _contentArea.bounds;
pageScreenshot.image =
[tab updateSnapshotWithOverlay:YES visibleFrameOnly:YES];
newPage = pageScreenshot;
offset =
pageScreenshot.frame.size.height - pageScreenshot.image.size.height;
}
newPageOffset = newPage.frame.origin.y;
[tab view].frame = _contentArea.bounds;
newPage.image = [tab updateSnapshotWithOverlay:YES visibleFrameOnly:YES];
[animationParentView addSubview:newPage];
CGPoint origin = [self lastTapPoint];
page_animation_util::AnimateInPaperWithAnimationAndCompletion(
newPage, -newPageOffset,
newPage.frame.size.height - newPage.image.size.height, origin,
_isOffTheRecord, NULL, ^{
newPage, -newPageOffset, offset, origin, _isOffTheRecord, NULL, ^{
[tab view].frame = _contentArea.bounds;
newPage.userInteractionEnabled = YES;
[newPage removeFromSuperview];
self.inNewTabAnimation = NO;
// Use the model's currentTab here because it is possible that it can
......@@ -2496,13 +2507,6 @@ bubblePresenterForFeature:(const base::Feature&)feature
_expectingForegroundTab = YES;
}
- (UIImageView*)pageFullScreenOpenCloseAnimationView {
CGRect viewBounds, remainder;
CGRectDivide(self.view.bounds, &remainder, &viewBounds, StatusBarHeight(),
CGRectMinYEdge);
return [[UIImageView alloc] initWithFrame:viewBounds];
}
- (UIImageView*)pageOpenCloseAnimationView {
CGRect frame = [_contentArea bounds];
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment