Commit 880787a5 authored by Stepan Khapugin's avatar Stepan Khapugin Committed by Commit Bot

Implement accessibility in the omnibox shortcuts.

1. Makes the NTP tiles have a11y type of Button
2. Matches the a11y behavior of the NTP tiles for shortcuts.

Change-Id: I295f4b23776c0ede8209b86d02c4becbc6d3dd23
Reviewed-on: https://chromium-review.googlesource.com/c/1335597
Commit-Queue: Stepan Khapugin <stkhapugin@chromium.org>
Reviewed-by: default avatarGauthier Ambard <gambard@chromium.org>
Cr-Commit-Position: refs/heads/master@{#608761}
parent 47dad54c
...@@ -653,6 +653,9 @@ initWithContentService:(ntp_snippets::ContentSuggestionsService*)contentService ...@@ -653,6 +653,9 @@ initWithContentService:(ntp_snippets::ContentSuggestionsService*)contentService
BookmarkActionItem(), self.readingListItem, RecentTabsActionItem(), BookmarkActionItem(), self.readingListItem, RecentTabsActionItem(),
HistoryActionItem() HistoryActionItem()
]; ];
for (ContentSuggestionsMostVisitedActionItem* item in _actionButtonItems) {
item.accessibilityTraits = UIAccessibilityTraitButton;
}
} }
return _actionButtonItems; return _actionButtonItems;
} }
......
...@@ -142,6 +142,7 @@ ContentSuggestionsMostVisitedItem* ConvertNTPTile( ...@@ -142,6 +142,7 @@ ContentSuggestionsMostVisitedItem* ConvertNTPTile(
suggestion.URL = tile.url; suggestion.URL = tile.url;
suggestion.source = tile.source; suggestion.source = tile.source;
suggestion.titleSource = tile.title_source; suggestion.titleSource = tile.title_source;
suggestion.accessibilityTraits = UIAccessibilityTraitButton;
suggestion.suggestionIdentifier = [[ContentSuggestionIdentifier alloc] init]; suggestion.suggestionIdentifier = [[ContentSuggestionIdentifier alloc] init];
suggestion.suggestionIdentifier.IDInSection = tile.url.spec(); suggestion.suggestionIdentifier.IDInSection = tile.url.spec();
......
...@@ -20,6 +20,7 @@ ...@@ -20,6 +20,7 @@
_tile.translatesAutoresizingMaskIntoConstraints = NO; _tile.translatesAutoresizingMaskIntoConstraints = NO;
[self.contentView addSubview:_tile]; [self.contentView addSubview:_tile];
AddSameConstraints(self.contentView, _tile); AddSameConstraints(self.contentView, _tile);
self.isAccessibilityElement = YES;
} }
return self; return self;
} }
......
...@@ -20,6 +20,7 @@ ...@@ -20,6 +20,7 @@
_tile.translatesAutoresizingMaskIntoConstraints = NO; _tile.translatesAutoresizingMaskIntoConstraints = NO;
[self.contentView addSubview:_tile]; [self.contentView addSubview:_tile];
AddSameConstraints(self.contentView, _tile); AddSameConstraints(self.contentView, _tile);
self.isAccessibilityElement = YES;
} }
return self; return self;
} }
......
...@@ -173,6 +173,7 @@ const NSInteger kCollectionShortcutSection = 1; ...@@ -173,6 +173,7 @@ const NSInteger kCollectionShortcutSection = 1;
ShortcutsMostVisitedItem* item = ShortcutsMostVisitedItem* item =
self.displayedMostVisitedItems[indexPath.item]; self.displayedMostVisitedItems[indexPath.item];
[self configureMostVisitedCell:cell withItem:item]; [self configureMostVisitedCell:cell withItem:item];
cell.accessibilityTraits = UIAccessibilityTraitButton;
return cell; return cell;
} }
...@@ -185,6 +186,7 @@ const NSInteger kCollectionShortcutSection = 1; ...@@ -185,6 +186,7 @@ const NSInteger kCollectionShortcutSection = 1;
"NTPCollectionShortcutType are supported"; "NTPCollectionShortcutType are supported";
NTPCollectionShortcutType type = (NTPCollectionShortcutType)indexPath.item; NTPCollectionShortcutType type = (NTPCollectionShortcutType)indexPath.item;
[self configureCollectionShortcutCell:cell withCollection:type]; [self configureCollectionShortcutCell:cell withCollection:type];
cell.accessibilityTraits = UIAccessibilityTraitButton;
return cell; return cell;
} }
...@@ -195,16 +197,21 @@ const NSInteger kCollectionShortcutSection = 1; ...@@ -195,16 +197,21 @@ const NSInteger kCollectionShortcutSection = 1;
withItem:(ShortcutsMostVisitedItem*)item { withItem:(ShortcutsMostVisitedItem*)item {
[cell.tile.faviconView configureWithAttributes:item.attributes]; [cell.tile.faviconView configureWithAttributes:item.attributes];
cell.tile.titleLabel.text = item.title; cell.tile.titleLabel.text = item.title;
cell.accessibilityLabel = cell.tile.titleLabel.text;
} }
- (void)configureCollectionShortcutCell:(CollectionShortcutCell*)cell - (void)configureCollectionShortcutCell:(CollectionShortcutCell*)cell
withCollection:(NTPCollectionShortcutType)type { withCollection:(NTPCollectionShortcutType)type {
cell.tile.titleLabel.text = TitleForCollectionShortcutType(type); cell.tile.titleLabel.text = TitleForCollectionShortcutType(type);
cell.tile.iconView.image = ImageForCollectionShortcutType(type); cell.tile.iconView.image = ImageForCollectionShortcutType(type);
cell.accessibilityLabel = cell.tile.titleLabel.text;
if (type == NTPCollectionShortcutTypeReadingList) { if (type == NTPCollectionShortcutTypeReadingList) {
if (self.readingListBadgeValue > 0) { if (self.readingListBadgeValue > 0) {
cell.tile.countLabel.text = [@(self.readingListBadgeValue) stringValue]; cell.tile.countLabel.text = [@(self.readingListBadgeValue) stringValue];
cell.tile.countContainer.hidden = NO; cell.tile.countContainer.hidden = NO;
cell.accessibilityLabel = AccessibilityLabelForReadingListCellWithCount(
self.readingListBadgeValue);
} else { } else {
cell.tile.countLabel.text = nil; cell.tile.countLabel.text = nil;
} }
......
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