Commit 8b0446e6 authored by Rohit Rao's avatar Rohit Rao Committed by Commit Bot

[ios] Fixes toolbar buttons disappearing when switching BVC modes.

When switching between incognito and non-incognito BVCs, it is possible
for all of the toolbar's buttons to be temporarily hidden.  We believe
that this results in the stack view having zero width, which seems to
permanently break autolayout on iOS 10.  Adding an optional width
constraint seems to work around this issue.

BUG=851954

Cq-Include-Trybots: luci.chromium.try:ios-simulator-full-configs;master.tryserver.chromium.mac:ios-simulator-cronet
Change-Id: I6995f2b3f5fa3b0f2eafb09e3970001fd16720f6
Reviewed-on: https://chromium-review.googlesource.com/1097207Reviewed-by: default avatarStepan Khapugin <stkhapugin@chromium.org>
Commit-Queue: Stepan Khapugin <stkhapugin@chromium.org>
Cr-Commit-Position: refs/heads/master@{#566759}
parent e6761727
......@@ -564,6 +564,16 @@ std::unique_ptr<net::test_server::HttpResponse> HandleQueryTitle(
[ChromeEarlGreyUI openNewTab];
}
// Tests switching back and forth between the normal and incognito BVCs many
// times. This is a regression test for https://crbug.com/851954.
- (void)testSwappingBVCModesManyTimesWithoutEnteringSwitcher {
for (int ii = 0; ii < 10; ++ii) {
// Opening a new tab from the menu will force a change in BVC.
[ChromeEarlGreyUI openNewIncognitoTab];
[ChromeEarlGreyUI openNewTab];
}
}
// Tests rotating the device while the switcher is not active. This is a
// regression test case for https://crbug.com/789975.
- (void)testRotationsWhileSwitcherIsNotActive {
......
......@@ -4,6 +4,7 @@
#import "ios/chrome/browser/ui/toolbar/adaptive/primary_toolbar_view.h"
#import "base/ios/ios_util.h"
#include "base/logging.h"
#import "ios/chrome/browser/ui/toolbar/buttons/toolbar_button.h"
#import "ios/chrome/browser/ui/toolbar/buttons/toolbar_button_factory.h"
......@@ -286,6 +287,18 @@
constraintEqualToConstant:kAdaptiveToolbarButtonHeight],
]];
// When switching between incognito and non-incognito BVCs, it is possible for
// all of the toolbar's buttons to be temporarily hidden, which results in the
// stack view having zero width. This seems to permanently break autolayout
// on iOS 10. Adding an optional width constraint seems to work around this
// issue. See https://crbug.com/851954.
if (!base::ios::IsRunningOnIOS11OrLater()) {
NSLayoutConstraint* minWidthConstraint =
[self.leadingStackView.widthAnchor constraintEqualToConstant:1.0];
minWidthConstraint.priority = UILayoutPriorityDefaultLow;
minWidthConstraint.active = YES;
}
// LocationBar constraints.
self.locationBarHeight = [self.locationBarContainer.heightAnchor
constraintEqualToConstant:kAdaptiveToolbarHeight -
......
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