Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(225)

Side by Side Diff: ui/accessibility/platform/ax_platform_node_mac.mm

Issue 2010493005: a11y/Mac: Add screenreader support for SubtleNotificationView announcements. Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase. Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #import "ui/accessibility/platform/ax_platform_node_mac.h" 5 #import "ui/accessibility/platform/ax_platform_node_mac.h"
6 6
7 #import <Cocoa/Cocoa.h> 7 #import <Cocoa/Cocoa.h>
8 #include <stddef.h> 8 #include <stddef.h>
9 9
10 #include "base/macros.h" 10 #include "base/macros.h"
11 #import "base/mac/sdk_forward_declarations.h"
11 #include "base/strings/sys_string_conversions.h" 12 #include "base/strings/sys_string_conversions.h"
12 #include "ui/accessibility/ax_node_data.h" 13 #include "ui/accessibility/ax_node_data.h"
13 #include "ui/accessibility/ax_view_state.h" 14 #include "ui/accessibility/ax_view_state.h"
14 #include "ui/accessibility/platform/ax_platform_node_delegate.h" 15 #include "ui/accessibility/platform/ax_platform_node_delegate.h"
15 #import "ui/gfx/mac/coordinate_conversion.h" 16 #import "ui/gfx/mac/coordinate_conversion.h"
16 17
17 namespace { 18 namespace {
18 19
19 struct RoleMapEntry { 20 struct RoleMapEntry {
20 ui::AXRole value; 21 ui::AXRole value;
(...skipping 480 matching lines...) Expand 10 before | Expand all | Expand 10 after
501 native_node_.reset([[AXPlatformNodeCocoa alloc] initWithNode:this]); 502 native_node_.reset([[AXPlatformNodeCocoa alloc] initWithNode:this]);
502 return native_node_.get(); 503 return native_node_.get();
503 } 504 }
504 505
505 void AXPlatformNodeMac::NotifyAccessibilityEvent(ui::AXEvent event_type) { 506 void AXPlatformNodeMac::NotifyAccessibilityEvent(ui::AXEvent event_type) {
506 NSView* target = GetDelegate()->GetTargetForNativeAccessibilityEvent(); 507 NSView* target = GetDelegate()->GetTargetForNativeAccessibilityEvent();
507 508
508 // Add mappings between ui::AXEvent and NSAccessibility notifications using 509 // Add mappings between ui::AXEvent and NSAccessibility notifications using
509 // the EventMap above. This switch contains exceptions to those mappings. 510 // the EventMap above. This switch contains exceptions to those mappings.
510 switch (event_type) { 511 switch (event_type) {
512 case ui::AX_EVENT_ALERT: {
513 NSString* announcement = base::SysUTF8ToNSString(
514 GetData().GetStringAttribute(ui::AX_ATTR_NAME));
515 NSDictionary* notification_info = @{
516 NSAccessibilityAnnouncementKey : announcement,
517 NSAccessibilityPriorityKey : @(NSAccessibilityPriorityHigh)
518 };
519 NSAccessibilityPostNotificationWithUserInfo(
520 [NSApp mainWindow], NSAccessibilityAnnouncementRequestedNotification,
521 notification_info);
522 return;
523 } break;
tapted 2016/07/11 03:46:47 nit: no need for break
Patti Lor 2016/07/12 00:04:36 Done.
511 case ui::AX_EVENT_TEXT_CHANGED: 524 case ui::AX_EVENT_TEXT_CHANGED:
512 // If the view is a user-editable textfield, this should change the value. 525 // If the view is a user-editable textfield, this should change the value.
513 if (GetData().role == ui::AX_ROLE_TEXT_FIELD) { 526 if (GetData().role == ui::AX_ROLE_TEXT_FIELD) {
514 NotifyMacEvent(target, ui::AX_EVENT_VALUE_CHANGED); 527 NotifyMacEvent(target, ui::AX_EVENT_VALUE_CHANGED);
515 return; 528 return;
516 } 529 }
517 break; 530 break;
518 default: 531 default:
519 break; 532 break;
520 } 533 }
521 NotifyMacEvent(target, event_type); 534 NotifyMacEvent(target, event_type);
522 } 535 }
523 536
524 int AXPlatformNodeMac::GetIndexInParent() { 537 int AXPlatformNodeMac::GetIndexInParent() {
525 // TODO(dmazzoni): implement this. http://crbug.com/396137 538 // TODO(dmazzoni): implement this. http://crbug.com/396137
526 return -1; 539 return -1;
527 } 540 }
528 541
529 } // namespace ui 542 } // namespace ui
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698