Commit fc2fe9d2 authored by Gauthier Ambard's avatar Gauthier Ambard Committed by Commit Bot

Add accessibility for PopupMenu

This CL adds the accessibility labels and ordering for the popup menus.

Bug: 833425, 842032, 831587
Cq-Include-Trybots: master.tryserver.chromium.mac:ios-simulator-cronet;master.tryserver.chromium.mac:ios-simulator-full-configs
Change-Id: I06bd6821144aee96c47374fd44e4a811831fc704
Reviewed-on: https://chromium-review.googlesource.com/1057307
Commit-Queue: Gauthier Ambard <gambard@chromium.org>
Reviewed-by: default avatarOlivier Robin <olivierrobin@chromium.org>
Cr-Commit-Position: refs/heads/master@{#558325}
parent 07d22792
......@@ -1568,6 +1568,9 @@ Your data was encrypted with your sync passphrase on <ph name="TIME">$2<ex>Sept
<message name="IDS_IOS_TOOLBAR_CLOSE_MENU" desc="The accessibility label for the toolbar close settings menu button [iOS only].">
Close Menu
</message>
<message name="IDS_IOS_TOOLBAR_SEARCH" desc="Label of the button allowing the user to focus the address bar when tapped. As usual, when the address bar is focused, the user can type a URL or a text to be searched on the internet. Read by Text-to-Speech." meaning="Search the internet. Read by Text-to-Speech.">
Search
</message>
<message name="IDS_IOS_TOOLBAR_SETTINGS" desc="The accessibility label for the toolbar open settings menu button [iOS only].">
Menu
</message>
......
......@@ -7,6 +7,8 @@
#import "ios/chrome/browser/ui/commands/browser_commands.h"
#import "ios/chrome/browser/ui/image_util/image_util.h"
#import "ios/chrome/browser/ui/util/constraints_ui_util.h"
#include "ios/chrome/grit/ios_strings.h"
#include "ui/base/l10n/l10n_util.h"
#if !defined(__has_feature) || !__has_feature(objc_arc)
#error "This file requires ARC support."
......@@ -19,7 +21,7 @@ const CGFloat kBackgroundGreyScale = 0.98;
const CGFloat kBackgroundAlpha = 0.65;
} // namespace
@interface PopupMenuViewController ()<UIGestureRecognizerDelegate>
@interface PopupMenuViewController ()
// Redefined as readwrite.
@property(nonatomic, strong, readwrite) UIView* contentContainer;
@end
......@@ -34,12 +36,20 @@ const CGFloat kBackgroundAlpha = 0.65;
- (instancetype)init {
self = [super initWithNibName:nil bundle:nil];
if (self) {
UIButton* closeButton = [UIButton buttonWithType:UIButtonTypeCustom];
[closeButton addTarget:self
action:@selector(dismissPopup)
forControlEvents:UIControlEventTouchUpInside];
closeButton.accessibilityLabel =
l10n_util::GetNSString(IDS_IOS_TOOLBAR_CLOSE_MENU);
closeButton.translatesAutoresizingMaskIntoConstraints = NO;
[self.view addSubview:closeButton];
AddSameConstraints(self.view, closeButton);
[self setUpContentContainer];
UITapGestureRecognizer* gestureRecognizer = [[UITapGestureRecognizer alloc]
initWithTarget:self
action:@selector(touchOnScrim:)];
gestureRecognizer.delegate = self;
[self.view addGestureRecognizer:gestureRecognizer];
self.view.accessibilityViewIsModal = YES;
UIAccessibilityPostNotification(UIAccessibilityLayoutChangedNotification,
closeButton);
}
return self;
}
......@@ -91,18 +101,8 @@ const CGFloat kBackgroundAlpha = 0.65;
}
// Handler receiving the touch event on the background scrim.
- (void)touchOnScrim:(UITapGestureRecognizer*)recognizer {
if (recognizer.state == UIGestureRecognizerStateEnded) {
[self.commandHandler dismissPopupMenuAnimated:YES];
}
}
#pragma mark - UIGestureRecognizerDelegate
- (BOOL)gestureRecognizer:(UIGestureRecognizer*)gestureRecognizer
shouldReceiveTouch:(UITouch*)touch {
// Only get the touch on the scrim.
return touch.view == self.view;
- (void)dismissPopup {
[self.commandHandler dismissPopupMenuAnimated:YES];
}
@end
......@@ -419,6 +419,8 @@ const CGFloat kOmniboxButtonBackgroundAlphaFactor = 0.5;
[omniboxButton addTarget:self.dispatcher
action:@selector(focusOmniboxFromSearchButton)
forControlEvents:UIControlEventTouchUpInside];
omniboxButton.accessibilityLabel =
l10n_util::GetNSString(IDS_IOS_TOOLBAR_SEARCH);
omniboxButton.accessibilityIdentifier = kToolbarOmniboxButtonIdentifier;
UIView* background = [[UIView alloc] init];
......
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