Commit 4eeada3f authored by Justin Cohen's avatar Justin Cohen Committed by Commit Bot

Fix disappearing omnibox on iPhone X.

The old-school layout logic in BVC was also re-inserting views on each
update, which is unnecessary, and in some cases causes views to show up
in the wrong z-order.  Insert only needs to happen on initial layout,
so gating this in a flag should fix the issues.

Bug: 782373
Change-Id: I326f3b9199717c0ad014267fa0239581574a826d
Reviewed-on: https://chromium-review.googlesource.com/763711Reviewed-by: default avatarStepan Khapugin <stkhapugin@chromium.org>
Reviewed-by: default avatarMark Cogan <marq@chromium.org>
Commit-Queue: Justin Cohen <justincohen@chromium.org>
Cr-Commit-Position: refs/heads/master@{#515987}
parent 140b9e68
...@@ -686,8 +686,9 @@ NSString* const kBrowserViewControllerSnackbarCategory = ...@@ -686,8 +686,9 @@ NSString* const kBrowserViewControllerSnackbarCategory =
// Updates view-related functionality with the given tab model and browser // Updates view-related functionality with the given tab model and browser
// state. The view must have been loaded. Uses |_browserState| and |_model|. // state. The view must have been loaded. Uses |_browserState| and |_model|.
- (void)addUIFunctionalityForModelAndBrowserState; - (void)addUIFunctionalityForModelAndBrowserState;
// Sets the correct frame and hierarchy for subviews and helper views. // Sets the correct frame and hierarchy for subviews and helper views. Only
- (void)setUpViewLayout; // insert views on |initialLayout|.
- (void)setUpViewLayout:(BOOL)initialLayout;
// Makes |tab| the currently visible tab, displaying its view. Calls // Makes |tab| the currently visible tab, displaying its view. Calls
// -selectedTabChanged on the toolbar only if |newSelection| is YES. // -selectedTabChanged on the toolbar only if |newSelection| is YES.
- (void)displayTab:(Tab*)tab isNewSelection:(BOOL)newSelection; - (void)displayTab:(Tab*)tab isNewSelection:(BOOL)newSelection;
...@@ -1308,7 +1309,7 @@ applicationCommandEndpoint:(id<ApplicationCommands>)applicationCommandEndpoint { ...@@ -1308,7 +1309,7 @@ applicationCommandEndpoint:(id<ApplicationCommands>)applicationCommandEndpoint {
// Install fake status bar for iPad iOS7 // Install fake status bar for iPad iOS7
[self installFakeStatusBar]; [self installFakeStatusBar];
[self buildToolbarAndTabStrip]; [self buildToolbarAndTabStrip];
[self setUpViewLayout]; [self setUpViewLayout:YES];
if (IsSafeAreaCompatibleToolbarEnabled()) { if (IsSafeAreaCompatibleToolbarEnabled()) {
[self addConstraintsToToolbar]; [self addConstraintsToToolbar];
} }
...@@ -1331,7 +1332,7 @@ applicationCommandEndpoint:(id<ApplicationCommands>)applicationCommandEndpoint { ...@@ -1331,7 +1332,7 @@ applicationCommandEndpoint:(id<ApplicationCommands>)applicationCommandEndpoint {
// Gate this behind iPhone X, since it's currently the only device that // Gate this behind iPhone X, since it's currently the only device that
// needs layout updates here after startup. // needs layout updates here after startup.
if (IsIPhoneX()) { if (IsIPhoneX()) {
[self setUpViewLayout]; [self setUpViewLayout:NO];
} }
if (IsSafeAreaCompatibleToolbarEnabled()) { if (IsSafeAreaCompatibleToolbarEnabled()) {
// TODO(crbug.com/778236): Check if this call can be removed once the // TODO(crbug.com/778236): Check if this call can be removed once the
...@@ -2042,7 +2043,7 @@ applicationCommandEndpoint:(id<ApplicationCommands>)applicationCommandEndpoint { ...@@ -2042,7 +2043,7 @@ applicationCommandEndpoint:(id<ApplicationCommands>)applicationCommandEndpoint {
} }
// Set the frame for the various views. View must be loaded. // Set the frame for the various views. View must be loaded.
- (void)setUpViewLayout { - (void)setUpViewLayout:(BOOL)initialLayout {
DCHECK([self isViewLoaded]); DCHECK([self isViewLoaded]);
CGFloat widthOfView = CGRectGetWidth([self view].bounds); CGFloat widthOfView = CGRectGetWidth([self view].bounds);
CGFloat minY = [self headerOffset]; CGFloat minY = [self headerOffset];
...@@ -2058,7 +2059,8 @@ applicationCommandEndpoint:(id<ApplicationCommands>)applicationCommandEndpoint { ...@@ -2058,7 +2059,8 @@ applicationCommandEndpoint:(id<ApplicationCommands>)applicationCommandEndpoint {
// Position the toolbar next, either at the top of the browser view or // Position the toolbar next, either at the top of the browser view or
// directly under the tabstrip. // directly under the tabstrip.
[self addChildViewController:_toolbarCoordinator.toolbarViewController]; if (initialLayout)
[self addChildViewController:_toolbarCoordinator.toolbarViewController];
CGRect toolbarFrame = _toolbarCoordinator.toolbarViewController.view.frame; CGRect toolbarFrame = _toolbarCoordinator.toolbarViewController.view.frame;
toolbarFrame.origin = CGPointMake(0, minY); toolbarFrame.origin = CGPointMake(0, minY);
toolbarFrame.size.width = widthOfView; toolbarFrame.size.width = widthOfView;
...@@ -2068,14 +2070,17 @@ applicationCommandEndpoint:(id<ApplicationCommands>)applicationCommandEndpoint { ...@@ -2068,14 +2070,17 @@ applicationCommandEndpoint:(id<ApplicationCommands>)applicationCommandEndpoint {
// Place the infobar container above the content area. // Place the infobar container above the content area.
InfoBarContainerView* infoBarContainerView = _infoBarContainer->view(); InfoBarContainerView* infoBarContainerView = _infoBarContainer->view();
[self.view insertSubview:infoBarContainerView aboveSubview:_contentArea]; if (initialLayout)
[self.view insertSubview:infoBarContainerView aboveSubview:_contentArea];
// Place the toolbar controller above the infobar container. // Place the toolbar controller above the infobar container.
[[self view] insertSubview:_toolbarCoordinator.toolbarViewController.view if (initialLayout)
aboveSubview:infoBarContainerView]; [[self view] insertSubview:_toolbarCoordinator.toolbarViewController.view
aboveSubview:infoBarContainerView];
minY += CGRectGetHeight(toolbarFrame); minY += CGRectGetHeight(toolbarFrame);
[_toolbarCoordinator.toolbarViewController if (initialLayout)
didMoveToParentViewController:self]; [_toolbarCoordinator.toolbarViewController
didMoveToParentViewController:self];
// Account for the toolbar's drop shadow. The toolbar overlaps with the web // Account for the toolbar's drop shadow. The toolbar overlaps with the web
// content slightly. // content slightly.
...@@ -2098,7 +2103,8 @@ applicationCommandEndpoint:(id<ApplicationCommands>)applicationCommandEndpoint { ...@@ -2098,7 +2103,8 @@ applicationCommandEndpoint:(id<ApplicationCommands>)applicationCommandEndpoint {
// Attach the typing shield to the content area but have it hidden. // Attach the typing shield to the content area but have it hidden.
[_typingShield setFrame:[_contentArea frame]]; [_typingShield setFrame:[_contentArea frame]];
[[self view] insertSubview:_typingShield aboveSubview:_contentArea]; if (initialLayout)
[[self view] insertSubview:_typingShield aboveSubview:_contentArea];
[_typingShield setHidden:YES]; [_typingShield setHidden:YES];
_typingShield.accessibilityIdentifier = @"Typing Shield"; _typingShield.accessibilityIdentifier = @"Typing Shield";
_typingShield.accessibilityLabel = l10n_util::GetNSString(IDS_CANCEL); _typingShield.accessibilityLabel = l10n_util::GetNSString(IDS_CANCEL);
......
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