Commit bfa5b989 authored by Justin Cohen's avatar Justin Cohen Committed by Commit Bot

[ios] Correct content suggestions safe area on rotation.

Various safe area tweaks to correct the layout of fakebox on rotation
when presented under another view controller.

Bug: 866864, 862208
Cq-Include-Trybots: luci.chromium.try:ios-simulator-full-configs;master.tryserver.chromium.mac:ios-simulator-cronet
Change-Id: I7fda5c1ae564825c203566add4c7e738bcb38eb8
Reviewed-on: https://chromium-review.googlesource.com/1149100Reviewed-by: default avatarGauthier Ambard <gambard@chromium.org>
Commit-Queue: Justin Cohen <justincohen@chromium.org>
Cr-Commit-Position: refs/heads/master@{#577826}
parent ac4d1414
......@@ -189,7 +189,14 @@ initWithCollectionController:
- (void)updateFakeOmniboxOnNewWidth:(CGFloat)width {
if (self.shouldAnimateHeader &&
(IsUIRefreshPhase1Enabled() || !IsIPadIdiom())) {
UIEdgeInsets insets = SafeAreaInsetsForViewWithinNTP(self.collectionView);
// We check -superview here because in certain scenarios (such as when the
// VC is rotated underneath another presented VC), in a
// UICollectionViewController -viewSafeAreaInsetsDidChange the VC.view has
// updated safeAreaInsets, but VC.collectionView does not until a layer
// -viewDidLayoutSubviews. Since self.collectionView and it's superview
// should always have the same safeArea, this should be safe.
UIEdgeInsets insets =
SafeAreaInsetsForViewWithinNTP(self.collectionView.superview);
[self.headerController
updateFakeOmniboxForOffset:self.collectionView.contentOffset.y
screenWidth:width
......
......@@ -310,6 +310,7 @@ BOOL ShouldCellsBeFullWidth(UITraitCollection* collection) {
[super viewDidAppear:animated];
// Resize the collection as it might have been rotated while not being
// presented (e.g. rotation on stack view).
[self correctMissingSafeArea];
[self updateConstraints];
// Update the shadow bar.
[self.audience contentOffsetDidChange];
......@@ -354,6 +355,8 @@ BOOL ShouldCellsBeFullWidth(UITraitCollection* collection) {
- (void)viewSafeAreaInsetsDidChange {
[super viewSafeAreaInsetsDidChange];
[self correctMissingSafeArea];
[self.headerSynchronizer
updateFakeOmniboxOnNewWidth:self.collectionView.bounds.size.width];
}
#pragma mark - UICollectionViewDelegate
......
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