Commit 63261b2b authored by Gauthier Ambard's avatar Gauthier Ambard Committed by Commit Bot

[iOS] Resize the NTP instead of adjusting ContentInset

This CL resizes the frame of the NTP instead of adjusting its content
inset. It allows the content of the NTP to not be displayed below the
toolbar, avoid issues with VoiceOver reading the item behind it.
It also allows to fix the content insets for the safe area.

Fixed: 1034509, 1030422
Change-Id: I306ecf5b771fa3a7b0b88fb6d99425154695c6c7
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1969580Reviewed-by: default avatarOlivier Robin <olivierrobin@chromium.org>
Commit-Queue: Gauthier Ambard <gambard@chromium.org>
Cr-Commit-Position: refs/heads/master@{#727978}
parent 99951907
......@@ -2514,12 +2514,12 @@ NSString* const kBrowserViewControllerSnackbarCategory =
- (CGRect)ntpFrameForWebState:(web::WebState*)webState {
NewTabPageTabHelper* NTPHelper = NewTabPageTabHelper::FromWebState(webState);
DCHECK(NTPHelper && NTPHelper->IsActive());
if (!IsRegularXRegularSizeClass())
return self.contentArea.bounds;
// NTP expects to be laid out behind the bottom toolbar. It uses
// |contentInset| to push content above the toolbar.
// NTP expects to be laid out behind the bottom toolbar.
UIEdgeInsets viewportInsets = [self viewportInsetsForView:self.contentArea];
viewportInsets.bottom = 0.0;
if (IsRegularXRegularSizeClass())
viewportInsets.bottom = 0.0;
if (IsSplitToolbarMode(self))
viewportInsets.top = 0;
return UIEdgeInsetsInsetRect(self.contentArea.bounds, viewportInsets);
}
......@@ -3750,14 +3750,6 @@ NSString* const kBrowserViewControllerSnackbarCategory =
// toolbar.
[self.infobarContainerCoordinator updateInfobarContainer];
// Resize the NTP's contentInset.bottom to be above the secondary toolbar.
if (self.isNTPActiveForCurrentWebState) {
NewTabPageCoordinator* coordinator =
_ntpCoordinatorsForWebStates[self.currentWebState];
UIEdgeInsets contentInset = coordinator.contentInset;
contentInset.bottom = height;
coordinator.contentInset = contentInset;
}
}
// Updates the browser container view such that its viewport is the space
......
......@@ -315,6 +315,12 @@ NSString* const kContentSuggestionsMostVisitedAccessibilityIdentifierPrefix =
- (void)viewSafeAreaInsetsDidChange {
[super viewSafeAreaInsetsDidChange];
// Only get the bottom safe area inset.
UIEdgeInsets insets = UIEdgeInsetsZero;
insets.bottom = self.view.safeAreaInsets.bottom;
self.collectionView.contentInset = insets;
[self.headerSynchronizer
updateFakeOmniboxOnNewWidth:self.collectionView.bounds.size.width];
[self.headerSynchronizer updateConstraints];
......
......@@ -326,9 +326,6 @@ id<GREYMatcher> OmniboxWidthBetween(CGFloat width, CGFloat margin) {
[ContentSuggestionsAppInterface collectionView].bounds.size.width;
GREYAssertNotEqual(collectionWidth, collectionWidthAfterRotation,
@"The collection width has not changed.");
[[EarlGrey selectElementWithMatcher:chrome_test_util::FakeOmnibox()]
assertWithMatcher:grey_not(grey_sufficientlyVisible())];
}
// Tests that the app doesn't crash when opening multiple tabs.
......
......@@ -59,7 +59,7 @@ class WebState;
// Exposes content inset of contentSuggestions collectionView to ensure all of
// content is visible under the bottom toolbar.
@property(nonatomic) UIEdgeInsets contentInset;
@property(nonatomic, readonly) UIEdgeInsets contentInset;
// Animates the NTP fakebox to the focused position and focuses the real
// omnibox.
......
......@@ -106,18 +106,6 @@
[self.contentSuggestionsCoordinator willUpdateSnapshot];
}
- (void)setContentInset:(UIEdgeInsets)contentInset {
// UIKit will adjust the contentOffset sometimes when changing the
// contentInset.bottom. We don't want the NTP to scroll, so store and re-set
// the contentOffset after setting the contentInset.
CGPoint contentOffset = self.contentSuggestionsCoordinator.viewController
.collectionView.contentOffset;
self.contentSuggestionsCoordinator.viewController.collectionView
.contentInset = contentInset;
self.contentSuggestionsCoordinator.viewController.collectionView
.contentOffset = contentOffset;
}
- (void)focusFakebox {
[self.contentSuggestionsCoordinator.headerController focusFakebox];
}
......
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