Commit dbfe1c8b authored by Gauthier Ambard's avatar Gauthier Ambard Committed by Commit Bot

[iOS] Layout subviews the tab that will presented

When opening a new tab in foreground, the tab should relayout its
subviews after resetting the frame to have them correctly positioned.

Bug: 852106
Cq-Include-Trybots: luci.chromium.try:ios-simulator-full-configs;master.tryserver.chromium.mac:ios-simulator-cronet
Change-Id: I9f886f68a55a28429d1ce39a908745acd24cbc12
Reviewed-on: https://chromium-review.googlesource.com/1105769
Commit-Queue: Gauthier Ambard <gambard@chromium.org>
Reviewed-by: default avatarRohit Rao <rohitrao@chromium.org>
Reviewed-by: default avatarJustin Cohen <justincohen@chromium.org>
Reviewed-by: default avatarEugene But <eugenebut@chromium.org>
Cr-Commit-Position: refs/heads/master@{#569612}
parent cd8c165e
...@@ -5170,6 +5170,10 @@ applicationCommandEndpoint:(id<ApplicationCommands>)applicationCommandEndpoint { ...@@ -5170,6 +5170,10 @@ applicationCommandEndpoint:(id<ApplicationCommands>)applicationCommandEndpoint {
} else { } else {
UIImageView* pageScreenshot = [self pageOpenCloseAnimationView]; UIImageView* pageScreenshot = [self pageOpenCloseAnimationView];
tab.view.frame = self.contentArea.bounds; tab.view.frame = self.contentArea.bounds;
// Setting the frame here doesn't trigger a layout pass. Trigger it manually
// if needed. Not triggering it can create problem if the previous frame
// wasn't the right one, for example in https://crbug.com/852106.
[tab.view layoutIfNeeded];
pageScreenshot.image = SnapshotTabHelper::FromWebState(tab.webState) pageScreenshot.image = SnapshotTabHelper::FromWebState(tab.webState)
->UpdateSnapshot(/*with_overlays=*/true, ->UpdateSnapshot(/*with_overlays=*/true,
/*visible_frame_only=*/true); /*visible_frame_only=*/true);
......
...@@ -3823,14 +3823,19 @@ registerLoadRequestForURL:(const GURL&)requestURL ...@@ -3823,14 +3823,19 @@ registerLoadRequestForURL:(const GURL&)requestURL
// This will be resized later, but matching the final frame will minimize // This will be resized later, but matching the final frame will minimize
// re-rendering. Use the screen size because the application's key window // re-rendering. Use the screen size because the application's key window
// may still be nil. // may still be nil.
CGRect containerViewFrame = CGRectZero;
if (UIApplication.sharedApplication.keyWindow) {
containerViewFrame = UIApplication.sharedApplication.keyWindow.bounds;
} else {
containerViewFrame = UIScreen.mainScreen.bounds;
}
if (base::FeatureList::IsEnabled( if (base::FeatureList::IsEnabled(
web::features::kBrowserContainerFullscreen)) { web::features::kBrowserContainerFullscreen)) {
_containerView.frame = [UIScreen mainScreen].bounds; _containerView.frame = containerViewFrame;
} else { } else {
// TODO(crbug.com/688259): Stop subtracting status bar height. // TODO(crbug.com/688259): Stop subtracting status bar height.
CGFloat statusBarHeight = CGFloat statusBarHeight =
[[UIApplication sharedApplication] statusBarFrame].size.height; [[UIApplication sharedApplication] statusBarFrame].size.height;
CGRect containerViewFrame = [UIScreen mainScreen].bounds;
containerViewFrame.origin.y += statusBarHeight; containerViewFrame.origin.y += statusBarHeight;
containerViewFrame.size.height -= statusBarHeight; containerViewFrame.size.height -= statusBarHeight;
_containerView.frame = containerViewFrame; _containerView.frame = containerViewFrame;
......
...@@ -94,7 +94,8 @@ NSString* GetHTMLForZoomState(const PageZoomState& zoom_state, ...@@ -94,7 +94,8 @@ NSString* GetHTMLForZoomState(const PageZoomState& zoom_state,
@"<html><head><meta name='viewport' content=" @"<html><head><meta name='viewport' content="
"'width=%f,minimum-scale=%f,maximum-scale=%f,initial-scale=%f," "'width=%f,minimum-scale=%f,maximum-scale=%f,initial-scale=%f,"
"user-scalable=%@'/></head><body>Test</body></html>"; "user-scalable=%@'/></head><body>Test</body></html>";
CGFloat width = CGRectGetWidth([UIScreen mainScreen].bounds) / CGFloat width =
CGRectGetWidth(UIApplication.sharedApplication.keyWindow.bounds) /
zoom_state.minimum_zoom_scale(); zoom_state.minimum_zoom_scale();
BOOL scalability_enabled = scalability_type == PAGE_SCALABILITY_ENABLED; BOOL scalability_enabled = scalability_type == PAGE_SCALABILITY_ENABLED;
return [NSString return [NSString
...@@ -147,7 +148,8 @@ class CRWWebControllerTest : public WebTestWithWebController { ...@@ -147,7 +148,8 @@ class CRWWebControllerTest : public WebTestWithWebController {
// The value for web view OCMock objects to expect for |-setFrame:|. // The value for web view OCMock objects to expect for |-setFrame:|.
CGRect GetExpectedWebViewFrame() const { CGRect GetExpectedWebViewFrame() const {
CGSize container_view_size = [UIScreen mainScreen].bounds.size; CGSize container_view_size =
UIApplication.sharedApplication.keyWindow.bounds.size;
container_view_size.height -= container_view_size.height -=
CGRectGetHeight([UIApplication sharedApplication].statusBarFrame); CGRectGetHeight([UIApplication sharedApplication].statusBarFrame);
return {CGPointZero, container_view_size}; return {CGPointZero, container_view_size};
......
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