Commit 1a3cceb3 authored by Kurt Horimoto's avatar Kurt Horimoto Committed by Commit Bot

[iOS] Don't generate TableViewURLCell's a11y label if one is provided.

Previously, TableViewURLCell always returned a lazily created a11y
label created using the values of the UILabel subviews, which was
squashing the custom a11y label provided by TableViewItems.

Bug: 862306
Cq-Include-Trybots: luci.chromium.try:ios-simulator-full-configs;master.tryserver.chromium.mac:ios-simulator-cronet
Change-Id: I7210e683f4dfdcdbf0f2c60ecec3eb2a0683eeec
Reviewed-on: https://chromium-review.googlesource.com/1136902Reviewed-by: default avatarSergio Collazos <sczs@chromium.org>
Commit-Queue: Kurt Horimoto <kkhorimoto@chromium.org>
Cr-Commit-Position: refs/heads/master@{#575890}
parent 67c45902
...@@ -136,6 +136,14 @@ const char kDefaultSupplementalURLTextDelimiter[] = "•"; ...@@ -136,6 +136,14 @@ const char kDefaultSupplementalURLTextDelimiter[] = "•";
#pragma mark - TableViewURLCell #pragma mark - TableViewURLCell
@interface TableViewURLCell ()
// If the cell's accessibility label has not been manually set via
// |-setAccessibilityLabel:|, this property will be YES, and
// |-accessibilityLabel| will return a lazily created label based on the
// text values of the UILabel subviews.
@property(nonatomic, assign) BOOL shouldGenerateAccessibilityLabel;
@end
@implementation TableViewURLCell @implementation TableViewURLCell
@synthesize faviconView = _faviconView; @synthesize faviconView = _faviconView;
@synthesize faviconContainerView = _faviconContainerView; @synthesize faviconContainerView = _faviconContainerView;
...@@ -144,6 +152,8 @@ const char kDefaultSupplementalURLTextDelimiter[] = "•"; ...@@ -144,6 +152,8 @@ const char kDefaultSupplementalURLTextDelimiter[] = "•";
@synthesize titleLabel = _titleLabel; @synthesize titleLabel = _titleLabel;
@synthesize URLLabel = _URLLabel; @synthesize URLLabel = _URLLabel;
@synthesize cellUniqueIdentifier = _cellUniqueIdentifier; @synthesize cellUniqueIdentifier = _cellUniqueIdentifier;
@synthesize shouldGenerateAccessibilityLabel =
_shouldGenerateAccessibilityLabel;
- (instancetype)initWithStyle:(UITableViewCellStyle)style - (instancetype)initWithStyle:(UITableViewCellStyle)style
reuseIdentifier:(NSString*)reuseIdentifier { reuseIdentifier:(NSString*)reuseIdentifier {
...@@ -252,18 +262,27 @@ const char kDefaultSupplementalURLTextDelimiter[] = "•"; ...@@ -252,18 +262,27 @@ const char kDefaultSupplementalURLTextDelimiter[] = "•";
self.faviconBadgeView.image = nil; self.faviconBadgeView.image = nil;
} }
- (void)setAccessibilityLabel:(NSString*)accessibilityLabel {
self.shouldGenerateAccessibilityLabel = !accessibilityLabel.length;
[super setAccessibilityLabel:accessibilityLabel];
}
- (NSString*)accessibilityLabel { - (NSString*)accessibilityLabel {
NSString* accessibilityLabel = self.titleLabel.text; if (self.shouldGenerateAccessibilityLabel) {
if (self.URLLabel.text.length > 0) { NSString* accessibilityLabel = self.titleLabel.text;
accessibilityLabel = [NSString if (self.URLLabel.text.length > 0) {
stringWithFormat:@"%@, %@", accessibilityLabel, self.URLLabel.text]; accessibilityLabel = [NSString
} stringWithFormat:@"%@, %@", accessibilityLabel, self.URLLabel.text];
if (self.metadataLabel.text.length > 0) { }
accessibilityLabel = if (self.metadataLabel.text.length > 0) {
[NSString stringWithFormat:@"%@, %@", accessibilityLabel, accessibilityLabel =
self.metadataLabel.text]; [NSString stringWithFormat:@"%@, %@", accessibilityLabel,
self.metadataLabel.text];
}
return accessibilityLabel;
} else {
return [super accessibilityLabel];
} }
return accessibilityLabel;
} }
- (NSString*)accessibilityIdentifier { - (NSString*)accessibilityIdentifier {
......
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