Commit b482c93d authored by edchin's avatar edchin Committed by Commit Bot

[ios] Fix voiceover for NTP

Voiceover reads nothing for NTP tabs in the tab grid.
It should read 'new tab'. Recently, the titles for NTP
tabs were removed to improve the look of the tab grid.
However, this meant that voiceover had nothing to read.

This CL brings back titles for NTP, but instead hides them.
This allows voiceover to read the title, even though it
is not visible.

Bug: 868401
Cq-Include-Trybots: luci.chromium.try:ios-simulator-full-configs;master.tryserver.chromium.mac:ios-simulator-cronet
Change-Id: I37fe3782e6ee68822e59ff1de7ef18e619cece42
Reviewed-on: https://chromium-review.googlesource.com/1152239Reviewed-by: default avataredchin <edchin@chromium.org>
Reviewed-by: default avatarSergio Collazos <sczs@chromium.org>
Commit-Queue: edchin <edchin@chromium.org>
Cr-Commit-Position: refs/heads/master@{#579266}
parent e8077c54
...@@ -31,7 +31,7 @@ ...@@ -31,7 +31,7 @@
@property(nonatomic, weak) UIImage* icon; @property(nonatomic, weak) UIImage* icon;
@property(nonatomic, weak) UIImage* snapshot; @property(nonatomic, weak) UIImage* snapshot;
@property(nonatomic, copy) NSString* title; @property(nonatomic, copy) NSString* title;
@property(nonatomic, assign) BOOL titleHidden;
@end @end
// A GridCell for use in animated transitions that only shows selection state // A GridCell for use in animated transitions that only shows selection state
......
...@@ -62,6 +62,7 @@ void PositionView(UIView* view, CGPoint point) { ...@@ -62,6 +62,7 @@ void PositionView(UIView* view, CGPoint point) {
@synthesize icon = _icon; @synthesize icon = _icon;
@synthesize snapshot = _snapshot; @synthesize snapshot = _snapshot;
@synthesize title = _title; @synthesize title = _title;
@synthesize titleHidden = _titleHidden;
// Private properties. // Private properties.
@synthesize topBarHeight = _topBarHeight; @synthesize topBarHeight = _topBarHeight;
@synthesize topBar = _topBar; @synthesize topBar = _topBar;
...@@ -141,6 +142,7 @@ void PositionView(UIView* view, CGPoint point) { ...@@ -141,6 +142,7 @@ void PositionView(UIView* view, CGPoint point) {
[super prepareForReuse]; [super prepareForReuse];
self.itemIdentifier = nil; self.itemIdentifier = nil;
self.title = nil; self.title = nil;
self.titleHidden = NO;
self.icon = nil; self.icon = nil;
self.snapshot = nil; self.snapshot = nil;
self.selected = NO; self.selected = NO;
...@@ -216,6 +218,11 @@ void PositionView(UIView* view, CGPoint point) { ...@@ -216,6 +218,11 @@ void PositionView(UIView* view, CGPoint point) {
_title = title; _title = title;
} }
- (void)setTitleHidden:(BOOL)titleHidden {
self.titleLabel.hidden = titleHidden;
_titleHidden = titleHidden;
}
#pragma mark - Private #pragma mark - Private
// Sets up the top bar with icon, title, and close button. // Sets up the top bar with icon, title, and close button.
...@@ -350,6 +357,7 @@ void PositionView(UIView* view, CGPoint point) { ...@@ -350,6 +357,7 @@ void PositionView(UIView* view, CGPoint point) {
proxy.icon = cell.icon; proxy.icon = cell.icon;
proxy.snapshot = cell.snapshot; proxy.snapshot = cell.snapshot;
proxy.title = cell.title; proxy.title = cell.title;
proxy.titleHidden = cell.titleHidden;
return proxy; return proxy;
} }
#pragma mark - GridToTabTransitionView properties. #pragma mark - GridToTabTransitionView properties.
......
...@@ -18,6 +18,7 @@ ...@@ -18,6 +18,7 @@
@property(nonatomic, readonly) NSString* identifier; @property(nonatomic, readonly) NSString* identifier;
@property(nonatomic, copy) NSString* title; @property(nonatomic, copy) NSString* title;
@property(nonatomic, assign) BOOL hidesTitle;
@end @end
#endif // IOS_CHROME_BROWSER_UI_TAB_GRID_GRID_GRID_ITEM_H_ #endif // IOS_CHROME_BROWSER_UI_TAB_GRID_GRID_GRID_ITEM_H_
...@@ -13,6 +13,7 @@ ...@@ -13,6 +13,7 @@
@implementation GridItem @implementation GridItem
@synthesize identifier = _identifier; @synthesize identifier = _identifier;
@synthesize title = _title; @synthesize title = _title;
@synthesize hidesTitle = _hidesTitle;
- (instancetype)initWithIdentifier:(NSString*)identifier { - (instancetype)initWithIdentifier:(NSString*)identifier {
DCHECK(identifier); DCHECK(identifier);
......
...@@ -502,6 +502,7 @@ NSIndexPath* CreateIndexPath(NSInteger index) { ...@@ -502,6 +502,7 @@ NSIndexPath* CreateIndexPath(NSInteger index) {
cell.theme = self.theme; cell.theme = self.theme;
cell.itemIdentifier = item.identifier; cell.itemIdentifier = item.identifier;
cell.title = item.title; cell.title = item.title;
cell.titleHidden = item.hidesTitle;
cell.snapshot = nil; cell.snapshot = nil;
cell.icon = nil; cell.icon = nil;
NSString* itemIdentifier = item.identifier; NSString* itemIdentifier = item.identifier;
......
...@@ -38,9 +38,10 @@ GridItem* CreateItem(web::WebState* web_state) { ...@@ -38,9 +38,10 @@ GridItem* CreateItem(web::WebState* web_state) {
TabIdTabHelper* tab_helper = TabIdTabHelper::FromWebState(web_state); TabIdTabHelper* tab_helper = TabIdTabHelper::FromWebState(web_state);
GridItem* item = [[GridItem alloc] initWithIdentifier:tab_helper->tab_id()]; GridItem* item = [[GridItem alloc] initWithIdentifier:tab_helper->tab_id()];
// chrome://newtab (NTP) tabs have no title. // chrome://newtab (NTP) tabs have no title.
if (!IsURLNtp(web_state->GetVisibleURL())) { if (IsURLNtp(web_state->GetVisibleURL())) {
item.title = base::SysUTF16ToNSString(web_state->GetTitle()); item.hidesTitle = YES;
} }
item.title = base::SysUTF16ToNSString(web_state->GetTitle());
return item; return item;
} }
......
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