Commit 41b1f381 authored by Justin Cohen's avatar Justin Cohen Committed by Commit Bot

[ios] More safe area fixes for iPhone X layout.

Bug: 789151, 789633, 791040
Cq-Include-Trybots: master.tryserver.chromium.mac:ios-simulator-cronet;master.tryserver.chromium.mac:ios-simulator-full-configs
Change-Id: Ic0db7db4255f01d5875e0072707886746e58274a
Reviewed-on: https://chromium-review.googlesource.com/803079Reviewed-by: default avatarStepan Khapugin <stkhapugin@chromium.org>
Reviewed-by: default avatarRohit Rao <rohitrao@chromium.org>
Reviewed-by: default avatarGauthier Ambard <gambard@chromium.org>
Commit-Queue: Justin Cohen <justincohen@chromium.org>
Cr-Commit-Position: refs/heads/master@{#521341}
parent 3b60901c
......@@ -1224,6 +1224,9 @@ applicationCommandEndpoint:(id<ApplicationCommands>)applicationCommandEndpoint {
self.contentArea.autoresizingMask = initialViewAutoresizing;
self.typingShield = [[UIButton alloc] initWithFrame:initialViewsRect];
self.typingShield.autoresizingMask = initialViewAutoresizing;
self.typingShield.accessibilityIdentifier = @"Typing Shield";
self.typingShield.accessibilityLabel = l10n_util::GetNSString(IDS_CANCEL);
[self.typingShield addTarget:self
action:@selector(shieldWasTapped:)
forControlEvents:UIControlEventTouchUpInside];
......@@ -2044,11 +2047,10 @@ applicationCommandEndpoint:(id<ApplicationCommands>)applicationCommandEndpoint {
// Attach the typing shield to the content area but have it hidden.
[_typingShield setFrame:[_contentArea frame]];
if (initialLayout)
if (initialLayout) {
[[self view] insertSubview:_typingShield aboveSubview:_contentArea];
[_typingShield setHidden:YES];
_typingShield.accessibilityIdentifier = @"Typing Shield";
_typingShield.accessibilityLabel = l10n_util::GetNSString(IDS_CANCEL);
[_typingShield setHidden:YES];
}
}
- (void)displayTab:(Tab*)tab isNewSelection:(BOOL)newSelection {
......
......@@ -700,6 +700,12 @@ using ios::material::TimingFunction;
clippingFrame.origin.y =
[_webToolbar frame].size.height - clippingFrame.size.height;
[_clippingView setFrame:clippingFrame];
// Omnibox background height also must be manually resized.
if ([_locationBarView.textField isFirstResponder]) {
CGRect omniboxFrame = CGRectInset([_clippingView bounds], -2, -2);
[_omniboxBackground setFrame:omniboxFrame];
}
}
- (void)setUpButton:(UIButton*)button
......@@ -1189,6 +1195,14 @@ using ios::material::TimingFunction;
[_webToolbar setAutoresizesSubviews:NO];
CGRect expandedFrame =
RectShiftedDownAndResizedForStatusBar(self.contentView.bounds);
// Using -RectShiftedDownAndResizedForStatusBar can sometimes be wrong in
// an autolayout world, such as if the view is rotated with the app
// backgrounded. It's safer to use -SafeAreaInsetsForView.
if (IsSafeAreaCompatibleToolbarEnabled()) {
UIEdgeInsets safeAreaInsets = SafeAreaInsetsForView(self.contentView);
expandedFrame =
UIEdgeInsetsInsetRect(self.contentView.bounds, safeAreaInsets);
}
[_webToolbar
setFrame:growOmnibox ? expandedFrame : [self specificControlsArea]];
[_webToolbar setAutoresizesSubviews:YES];
......@@ -2048,6 +2062,15 @@ using ios::material::TimingFunction;
- (void)layoutCancelButton {
CGFloat height = CGRectGetHeight([self specificControlsArea]) -
kCancelButtonTopMargin - kCancelButtonBottomMargin;
// Using -specificControlsArea can sometimes be wrong in
// an autolayout world, such as if the view is rotated with the app
// backgrounded. It's safer to use -SafeAreaInsetsForView.
if (IsSafeAreaCompatibleToolbarEnabled()) {
UIEdgeInsets safeAreaInsets = SafeAreaInsetsForView(self.contentView);
height = CGRectGetHeight(UIEdgeInsetsInsetRect(self.contentView.bounds,
safeAreaInsets)) -
kCancelButtonTopMargin - kCancelButtonBottomMargin;
}
LayoutRect cancelButtonLayout;
cancelButtonLayout.position.leading =
CGRectGetWidth([_webToolbar bounds]) - height;
......
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