Commit 9445030a authored by Robbie Gibson's avatar Robbie Gibson Committed by Commit Bot

[iOS] Fix bug where omnibox popup row selection color was incorrect

This bug only occurs on iOS 12. The root cause is that, on iOS 13 we
use the dark mode apis to color things in incognito. This means all
colors can be set once and incognito can be changed afterwards and the
colors will update. For iOS 12, the colors are static, so they must be
set after the incognito status is known.

Bug: 1017138
Change-Id: I8084646b07d2bcbf8b48d91b0d7d341a8fb9bece
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1886684Reviewed-by: default avatarStepan Khapugin <stkhapugin@chromium.org>
Commit-Queue: Robbie Gibson <rkgibson@google.com>
Cr-Commit-Position: refs/heads/master@{#710399}
parent 9c368114
......@@ -53,6 +53,8 @@ const CGFloat kLeadingPaddingIpadCompact = 71;
self = [super initWithStyle:UITableViewCellStyleDefault
reuseIdentifier:@"OmniboxPopupRow"];
if (self) {
_incognito = incognito;
self.isAccessibilityElement = YES;
self.backgroundColor = UIColor.clearColor;
self.selectedBackgroundView = [[UIView alloc] initWithFrame:CGRectZero];
......@@ -60,8 +62,6 @@ const CGFloat kLeadingPaddingIpadCompact = 71;
[UIColor colorNamed:kTableViewRowHighlightColor], _incognito,
[UIColor colorNamed:kTableViewRowHighlightDarkColor]);
_incognito = incognito;
_textTruncatingLabel =
[[OmniboxPopupTruncatingLabel alloc] initWithFrame:CGRectZero];
_textTruncatingLabel.userInteractionEnabled = NO;
......
......@@ -66,6 +66,8 @@ NSString* const kOmniboxPopupRowSwitchTabAccessibilityIdentifier =
reuseIdentifier:(NSString*)reuseIdentifier {
self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
if (self) {
_incognito = NO;
self.selectedBackgroundView = [[UIView alloc] initWithFrame:CGRectZero];
self.selectedBackgroundView.backgroundColor = color::DarkModeDynamicColor(
[UIColor colorNamed:kTableViewRowHighlightColor], _incognito,
......@@ -109,8 +111,6 @@ NSString* const kOmniboxPopupRowSwitchTabAccessibilityIdentifier =
_separator.translatesAutoresizingMaskIntoConstraints = NO;
_separator.hidden = YES;
_incognito = NO;
self.backgroundColor = UIColor.clearColor;
}
return self;
......@@ -308,6 +308,17 @@ NSString* const kOmniboxPopupRowSwitchTabAccessibilityIdentifier =
self.suggestion = suggestion;
self.incognito = incognito;
// While iOS 12 is still supported, the background color needs to be reset
// when the incognito mode changes. Once iOS 12 is no longer supported,
// the color should only have to be set once.
if (@available(iOS 13, *)) {
// Empty because condition should be if (!@available(iOS 13, *)).
} else {
self.selectedBackgroundView.backgroundColor = color::DarkModeDynamicColor(
[UIColor colorNamed:kTableViewRowHighlightColor], self.incognito,
[UIColor colorNamed:kTableViewRowHighlightDarkColor]);
}
self.separator.backgroundColor =
self.incognito ? [UIColor.whiteColor colorWithAlphaComponent:0.12]
: [UIColor.blackColor colorWithAlphaComponent:0.12];
......
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