Commit 2d2c71dc authored by Gauthier Ambard's avatar Gauthier Ambard Committed by Commit Bot

Fix Open in New Tab animation for fullscreen BCVC

This CL fixes the animation occuring when opening a new tab in
background when the flag to enable BrowserContainer fullscreen.

Bug: 836730
Cq-Include-Trybots: master.tryserver.chromium.mac:ios-simulator-cronet;master.tryserver.chromium.mac:ios-simulator-full-configs
Change-Id: Ifa1abee606888938fe3b551903e16f92c7c60698
Reviewed-on: https://chromium-review.googlesource.com/1032772Reviewed-by: default avatarJustin Cohen <justincohen@chromium.org>
Reviewed-by: default avatarRohit Rao <rohitrao@chromium.org>
Commit-Queue: Gauthier Ambard <gambard@chromium.org>
Cr-Commit-Position: refs/heads/master@{#557145}
parent ce6ace7f
......@@ -37,6 +37,7 @@ source_set("snapshots") {
"//ios/chrome/browser/browser_state",
"//ios/chrome/browser/infobars",
"//ios/chrome/browser/ui",
"//ios/chrome/browser/ui:feature_flags",
"//ios/chrome/browser/web:tab_id_tab_helper",
"//ios/chrome/browser/web_state_list",
"//ios/web/public",
......
......@@ -17,6 +17,7 @@
#import "ios/chrome/browser/snapshots/snapshot_cache_factory.h"
#import "ios/chrome/browser/snapshots/snapshot_generator_delegate.h"
#import "ios/chrome/browser/snapshots/snapshot_overlay.h"
#include "ios/chrome/browser/ui/ui_feature_flags.h"
#import "ios/chrome/browser/ui/uikit_ui_util.h"
#import "ios/web/public/web_state/web_state.h"
#import "ios/web/public/web_state/web_state_observer_bridge.h"
......@@ -201,18 +202,7 @@ BOOL ViewHierarchyContainsWKWebView(UIView* view) {
if (!snapshot)
return [[self class] defaultSnapshotImage];
UIImage* snapshotToCache = snapshot;
if (!visibleFrameOnly) {
UIEdgeInsets insets = [_delegate snapshotEdgeInsetsForWebState:_webState];
if (!UIEdgeInsetsEqualToEdgeInsets(insets, UIEdgeInsetsZero)) {
CGRect cropRect =
UIEdgeInsetsInsetRect(CGRect{CGPointZero, [snapshot size]}, insets);
snapshotToCache = CropImage(snapshot, cropRect);
}
}
[self.snapshotCache setImage:snapshotToCache
withSessionID:_snapshotSessionId];
[self.snapshotCache setImage:snapshot withSessionID:_snapshotSessionId];
return snapshot;
}
......@@ -279,10 +269,13 @@ BOOL ViewHierarchyContainsWKWebView(UIView* view) {
UIView* view = _webState->GetView();
CGRect frame = [view bounds];
UIEdgeInsets headerInsets = UIEdgeInsetsZero;
if (visibleFrameOnly) {
UIEdgeInsets insets = [_delegate snapshotEdgeInsetsForWebState:_webState];
frame = UIEdgeInsetsInsetRect(frame, insets);
headerInsets = [_delegate snapshotEdgeInsetsForWebState:_webState];
} else if (base::FeatureList::IsEnabled(kBrowserContainerFullscreen)) {
headerInsets = UIEdgeInsetsMake(StatusBarHeight(), 0, 0, 0);
}
frame = UIEdgeInsetsInsetRect(frame, headerInsets);
return frame;
}
......
......@@ -1274,7 +1274,7 @@ applicationCommandEndpoint:(id<ApplicationCommands>)applicationCommandEndpoint {
}
- (BOOL)isToolbarOnScreen {
return self.headerHeight - [self currentHeaderOffset] > 0;
return [self nonFullscreenToolbarHeight] - [self currentHeaderOffset] > 0;
}
- (void)setInNewTabAnimation:(BOOL)inNewTabAnimation {
......@@ -2598,9 +2598,11 @@ applicationCommandEndpoint:(id<ApplicationCommands>)applicationCommandEndpoint {
- (CardView*)addCardViewInFullscreen:(BOOL)fullScreen {
CGRect frame = self.contentArea.frame;
// Changing the origin here is unnecessary, it's set in page_animation_util.
if (!fullScreen) {
// Changing the origin here is unnecessary, it's set in page_animation_util.
frame.size.height -= self.headerHeight;
} else if (base::FeatureList::IsEnabled(kBrowserContainerFullscreen)) {
frame.size.height -= StatusBarHeight();
}
CGFloat shortAxis = frame.size.width;
......@@ -5184,6 +5186,10 @@ bubblePresenterForFeature:(const base::Feature&)feature
[self snapshotEdgeInsetsForWebState:topTab.webState]);
} else {
imageFrame = [topTab.webState->GetView() bounds];
if (base::FeatureList::IsEnabled(kBrowserContainerFullscreen)) {
imageFrame.origin.y += StatusBarHeight();
imageFrame.size.height -= StatusBarHeight();
}
}
// Add three layers in order on top of the contentArea for the animation:
......
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