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[] = "•";
#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
@synthesize faviconView = _faviconView;
@synthesize faviconContainerView = _faviconContainerView;
......@@ -144,6 +152,8 @@ const char kDefaultSupplementalURLTextDelimiter[] = "•";
@synthesize titleLabel = _titleLabel;
@synthesize URLLabel = _URLLabel;
@synthesize cellUniqueIdentifier = _cellUniqueIdentifier;
@synthesize shouldGenerateAccessibilityLabel =
_shouldGenerateAccessibilityLabel;
- (instancetype)initWithStyle:(UITableViewCellStyle)style
reuseIdentifier:(NSString*)reuseIdentifier {
......@@ -252,18 +262,27 @@ const char kDefaultSupplementalURLTextDelimiter[] = "•";
self.faviconBadgeView.image = nil;
}
- (void)setAccessibilityLabel:(NSString*)accessibilityLabel {
self.shouldGenerateAccessibilityLabel = !accessibilityLabel.length;
[super setAccessibilityLabel:accessibilityLabel];
}
- (NSString*)accessibilityLabel {
NSString* accessibilityLabel = self.titleLabel.text;
if (self.URLLabel.text.length > 0) {
accessibilityLabel = [NSString
stringWithFormat:@"%@, %@", accessibilityLabel, self.URLLabel.text];
}
if (self.metadataLabel.text.length > 0) {
accessibilityLabel =
[NSString stringWithFormat:@"%@, %@", accessibilityLabel,
self.metadataLabel.text];
if (self.shouldGenerateAccessibilityLabel) {
NSString* accessibilityLabel = self.titleLabel.text;
if (self.URLLabel.text.length > 0) {
accessibilityLabel = [NSString
stringWithFormat:@"%@, %@", accessibilityLabel, self.URLLabel.text];
}
if (self.metadataLabel.text.length > 0) {
accessibilityLabel =
[NSString stringWithFormat:@"%@, %@", accessibilityLabel,
self.metadataLabel.text];
}
return accessibilityLabel;
} else {
return [super accessibilityLabel];
}
return accessibilityLabel;
}
- (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