Commit 2533dfa0 authored by Justin Cohen's avatar Justin Cohen Committed by Commit Bot

[ios] More fixes for making NTP fullscreen.

Bug: 819460, 832593

Cq-Include-Trybots: master.tryserver.chromium.mac:ios-simulator-cronet;master.tryserver.chromium.mac:ios-simulator-full-configs
Change-Id: I6ba2bfc9e22758203b5dc44698e40db5295c79ce
Reviewed-on: https://chromium-review.googlesource.com/1005912Reviewed-by: default avatarGauthier Ambard <gambard@chromium.org>
Reviewed-by: default avatarRohit Rao <rohitrao@chromium.org>
Commit-Queue: Justin Cohen <justincohen@chromium.org>
Cr-Commit-Position: refs/heads/master@{#551386}
parent b7a8a1b6
...@@ -1816,6 +1816,12 @@ applicationCommandEndpoint:(id<ApplicationCommands>)applicationCommandEndpoint { ...@@ -1816,6 +1816,12 @@ applicationCommandEndpoint:(id<ApplicationCommands>)applicationCommandEndpoint {
// Update the toolbar visibility. // Update the toolbar visibility.
[self updateToolbar]; [self updateToolbar];
// Normally this happens in -viewSafeAreaInsetsDidChange, but added here to
// support iOS10.
if (IsUIRefreshPhase1Enabled() && !base::ios::IsRunningOnIOS11OrLater()) {
[self setUpViewLayout:NO];
}
} }
- (void)viewWillTransitionToSize:(CGSize)size - (void)viewWillTransitionToSize:(CGSize)size
......
...@@ -153,7 +153,7 @@ CGFloat doodleTopMargin(BOOL toolbarPresent) { ...@@ -153,7 +153,7 @@ CGFloat doodleTopMargin(BOOL toolbarPresent) {
if (IsUIRefreshPhase1Enabled()) { if (IsUIRefreshPhase1Enabled()) {
if (!IsCompactWidth() && !IsCompactHeight()) if (!IsCompactWidth() && !IsCompactHeight())
return kDoodleTopMarginRegularXRegular; return kDoodleTopMarginRegularXRegular;
return kDoodleTopMarginOther; return StatusBarHeight() + kDoodleTopMarginOther;
} }
if (IsIPadIdiom()) if (IsIPadIdiom())
return kDoodleTopMarginIPadLegacy; return kDoodleTopMarginIPadLegacy;
......
...@@ -290,7 +290,14 @@ ...@@ -290,7 +290,14 @@
} }
- (CGFloat)overscrollHeaderHeight { - (CGFloat)overscrollHeaderHeight {
return [self.headerController toolBarView].bounds.size.height; CGFloat height = [self.headerController toolBarView].bounds.size.height;
CGFloat topInset = 0.0;
if (@available(iOS 11, *)) {
topInset = self.suggestionsViewController.view.safeAreaInsets.top;
} else {
topInset = self.suggestionsViewController.topLayoutGuide.length;
}
return height + topInset;
} }
#pragma mark - NewTabPagePanelProtocol #pragma mark - NewTabPagePanelProtocol
......
...@@ -4,6 +4,8 @@ ...@@ -4,6 +4,8 @@
#import "ios/chrome/browser/ui/content_suggestions/content_suggestions_header_synchronizer.h" #import "ios/chrome/browser/ui/content_suggestions/content_suggestions_header_synchronizer.h"
#include "base/ios/ios_util.h"
#import "base/mac/foundation_util.h"
#import "ios/chrome/browser/ui/content_suggestions/cells/content_suggestions_cell.h" #import "ios/chrome/browser/ui/content_suggestions/cells/content_suggestions_cell.h"
#import "ios/chrome/browser/ui/content_suggestions/cells/content_suggestions_most_visited_cell.h" #import "ios/chrome/browser/ui/content_suggestions/cells/content_suggestions_most_visited_cell.h"
#import "ios/chrome/browser/ui/content_suggestions/content_suggestions_collection_controlling.h" #import "ios/chrome/browser/ui/content_suggestions/content_suggestions_collection_controlling.h"
...@@ -160,10 +162,18 @@ initWithCollectionController: ...@@ -160,10 +162,18 @@ initWithCollectionController:
} }
if (self.shouldAnimateHeader) { if (self.shouldAnimateHeader) {
UIEdgeInsets insets = SafeAreaInsetsForView(self.collectionView);
if (IsUIRefreshPhase1Enabled() && !base::ios::IsRunningOnIOS11OrLater()) {
UIViewController* collectionController =
base::mac::ObjCCastStrict<UIViewController>(
self.collectionController);
insets =
UIEdgeInsetsMake(collectionController.topLayoutGuide.length, 0, 0, 0);
}
[self.headerController [self.headerController
updateFakeOmniboxForOffset:self.collectionView.contentOffset.y updateFakeOmniboxForOffset:self.collectionView.contentOffset.y
screenWidth:self.collectionView.frame.size.width screenWidth:self.collectionView.frame.size.width
safeAreaInsets:SafeAreaInsetsForView(self.collectionView)]; safeAreaInsets:insets];
} }
} }
......
...@@ -81,9 +81,10 @@ const CGFloat kSearchIconLeftMargin = 9; ...@@ -81,9 +81,10 @@ const CGFloat kSearchIconLeftMargin = 9;
kTabSwitcherGuide, kTabSwitcherGuide,
]; ];
AddNamedGuidesToView(guideNames, self); AddNamedGuidesToView(guideNames, self);
id<LayoutGuideProvider> layoutGuide = SafeAreaLayoutGuideForView(self);
[NSLayoutConstraint activateConstraints:@[ [NSLayoutConstraint activateConstraints:@[
[self.toolBarView.leadingAnchor constraintEqualToAnchor:self.leadingAnchor], [self.toolBarView.leadingAnchor constraintEqualToAnchor:self.leadingAnchor],
[self.toolBarView.topAnchor constraintEqualToAnchor:self.topAnchor], [self.toolBarView.topAnchor constraintEqualToAnchor:layoutGuide.topAnchor],
[self.toolBarView.trailingAnchor [self.toolBarView.trailingAnchor
constraintEqualToAnchor:self.trailingAnchor], constraintEqualToAnchor:self.trailingAnchor],
]]; ]];
......
...@@ -202,10 +202,18 @@ const UIEdgeInsets kSearchBoxStretchInsets = {3, 3, 3, 3}; ...@@ -202,10 +202,18 @@ const UIEdgeInsets kSearchBoxStretchInsets = {3, 3, 3, 3};
- (CGFloat)pinnedOffsetY { - (CGFloat)pinnedOffsetY {
CGFloat headerHeight = content_suggestions::heightForLogoHeader( CGFloat headerHeight = content_suggestions::heightForLogoHeader(
self.logoIsShowing, self.promoCanShow, YES); self.logoIsShowing, self.promoCanShow, YES);
CGFloat offsetY = CGFloat offsetY =
headerHeight - ntp_header::kScrolledToTopOmniboxBottomMargin; headerHeight - ntp_header::kScrolledToTopOmniboxBottomMargin;
if (!content_suggestions::IsRegularXRegularSizeClass(self.view)) if (!content_suggestions::IsRegularXRegularSizeClass(self.view)) {
offsetY -= ntp_header::ToolbarHeight(); CGFloat top = 0;
if (@available(iOS 11, *)) {
top = self.parentViewController.view.safeAreaInsets.top;
} else {
top = self.parentViewController.topLayoutGuide.length;
}
offsetY -= ntp_header::ToolbarHeight() + top;
}
return offsetY; return offsetY;
} }
......
...@@ -24,8 +24,16 @@ ...@@ -24,8 +24,16 @@
// top of the screen. // top of the screen.
CGFloat minimumHeight = collectionViewHeight + headerHeight - CGFloat minimumHeight = collectionViewHeight + headerHeight -
ntp_header::kScrolledToTopOmniboxBottomMargin; ntp_header::kScrolledToTopOmniboxBottomMargin;
CGFloat topSafeArea = 0;
if (IsUIRefreshPhase1Enabled()) {
if (@available(iOS 11, *)) {
topSafeArea = self.collectionView.safeAreaInsets.top;
} else {
topSafeArea = StatusBarHeight();
}
}
if (!content_suggestions::IsRegularXRegularSizeClass(self.collectionView)) if (!content_suggestions::IsRegularXRegularSizeClass(self.collectionView))
minimumHeight -= ntp_header::ToolbarHeight(); minimumHeight -= ntp_header::ToolbarHeight() + topSafeArea;
CGSize contentSize = [super collectionViewContentSize]; CGSize contentSize = [super collectionViewContentSize];
if (contentSize.height < minimumHeight) { if (contentSize.height < minimumHeight) {
......
...@@ -216,11 +216,12 @@ BOOL ShouldCellsBeFullWidth(UITraitCollection* collection) { ...@@ -216,11 +216,12 @@ BOOL ShouldCellsBeFullWidth(UITraitCollection* collection) {
self.collectionView.prefetchingEnabled = NO; self.collectionView.prefetchingEnabled = NO;
if (@available(iOS 11, *)) { if (@available(iOS 11, *)) {
// Use automatic behavior as each element takes the safe area into account // Overscroll action does not work well with content offset, so set this
// separately and the overscroll action does not work well with content // to never and internally offset the UI to account for safe area insets.
// offset.
self.collectionView.contentInsetAdjustmentBehavior = self.collectionView.contentInsetAdjustmentBehavior =
UIScrollViewContentInsetAdjustmentAutomatic; IsUIRefreshPhase1Enabled()
? UIScrollViewContentInsetAdjustmentNever
: UIScrollViewContentInsetAdjustmentAutomatic;
} }
self.collectionView.accessibilityIdentifier = self.collectionView.accessibilityIdentifier =
[[self class] collectionAccessibilityIdentifier]; [[self class] collectionAccessibilityIdentifier];
......
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