Commit 44a76757 authored by Gauthier Ambard's avatar Gauthier Ambard Committed by Commit Bot

[iOS] Fix 0-sized NTP on cold start

When the app is launched after a cold start, the size of the collection
view is 0, even if the size of the wrapper view isn't 0. This CL fixes
it by setting the frame of the collectionView if it is 0.
This only seems to happen when the NTP is contained in a native view.

Bug: 896234
Change-Id: I4309bf35c0a3d82e2a5c6c78265f8293ff65a43c
Reviewed-on: https://chromium-review.googlesource.com/c/1297360Reviewed-by: default avatarJustin Cohen <justincohen@chromium.org>
Commit-Queue: Gauthier Ambard <gambard@chromium.org>
Cr-Commit-Position: refs/heads/master@{#602313}
parent 63e884a4
......@@ -115,6 +115,7 @@ source_set("content_suggestions_ui") {
"//base",
"//components/strings",
"//ios/chrome/browser/ui",
"//ios/chrome/browser/ui:feature_flags",
"//ios/chrome/browser/ui/collection_view",
"//ios/chrome/browser/ui/commands",
"//ios/chrome/browser/ui/content_suggestions/cells:cells_ui",
......
......@@ -23,6 +23,7 @@
#import "ios/chrome/browser/ui/content_suggestions/ntp_home_constant.h"
#import "ios/chrome/browser/ui/ntp/new_tab_page_header_constants.h"
#import "ios/chrome/browser/ui/overscroll_actions/overscroll_actions_controller.h"
#include "ios/chrome/browser/ui/ui_feature_flags.h"
#import "ios/chrome/browser/ui/util/uikit_ui_util.h"
#import "ios/chrome/common/ui_util/constraints_ui_util.h"
#include "ios/web/public/features.h"
......@@ -276,6 +277,14 @@ const CGFloat kCardBorderRadius = 11;
- (void)viewDidLayoutSubviews {
[super viewDidLayoutSubviews];
if (!base::FeatureList::IsEnabled(kBrowserContainerContainsNTP) &&
CGSizeEqualToSize(self.collectionView.bounds.size, CGSizeZero) &&
!CGSizeEqualToSize(self.view.bounds.size, CGSizeZero)) {
// When started after a cold start, the frame of the collection view isn't
// set to the bounds of the view. In that case, the constraints for the
// cells are broken.
self.collectionView.frame = self.view.bounds;
}
[self applyContentOffset];
}
......
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