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

Unified Diff: ui/accessibility/platform/ax_platform_node_mac.mm

Issue 2210763002: MacViews a11y: Sync VoiceOver cursor with keyboard focus. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 4 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 side-by-side diff with in-line comments
Download patch
« tmp-traceclass.h ('K') | « ui/accessibility/BUILD.gn ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/accessibility/platform/ax_platform_node_mac.mm
diff --git a/ui/accessibility/platform/ax_platform_node_mac.mm b/ui/accessibility/platform/ax_platform_node_mac.mm
index 79fa94904ba8d2fbd2fcb4f57b97db3fa7f8ca29..4ef6d80dbe5af7817a163b6292de0e6642e60e61 100644
--- a/ui/accessibility/platform/ax_platform_node_mac.mm
+++ b/ui/accessibility/platform/ax_platform_node_mac.mm
@@ -7,6 +7,7 @@
#import <Cocoa/Cocoa.h>
#include <stddef.h>
+#import "base/mac/sdk_forward_declarations.h"
#include "base/macros.h"
#include "base/strings/sys_string_conversions.h"
#include "ui/accessibility/ax_node_data.h"
@@ -14,6 +15,8 @@
#include "ui/accessibility/platform/ax_platform_node_delegate.h"
#import "ui/gfx/mac/coordinate_conversion.h"
+#import "tmp-traceclass.h"
+
namespace {
struct RoleMapEntry {
@@ -197,6 +200,7 @@ RoleMap BuildSubroleMap() {
EventMap BuildEventMap() {
const EventMapEntry events[] = {
+ {ui::AX_EVENT_FOCUS, NSAccessibilityFocusedUIElementChangedNotification},
{ui::AX_EVENT_TEXT_CHANGED, NSAccessibilityTitleChangedNotification},
{ui::AX_EVENT_VALUE_CHANGED, NSAccessibilityValueChangedNotification},
{ui::AX_EVENT_TEXT_SELECTION_CHANGED,
@@ -210,7 +214,7 @@ EventMap BuildEventMap() {
return event_map;
}
-void NotifyMacEvent(NSView* target, ui::AXEvent event_type) {
+void NotifyMacEvent(id target, ui::AXEvent event_type) {
NSAccessibilityPostNotification(
target, [AXPlatformNodeCocoa nativeNotificationFromAXEvent:event_type]);
}
@@ -252,7 +256,25 @@ void NotifyMacEvent(NSView* target, ui::AXEvent event_type) {
return self;
}
+- (BOOL)isEqual:(id)object {
+ if (![object isKindOfClass:[AXPlatformNodeCocoa class]])
+ return NO;
+ return ([self hash] == [object hash]);
+}
+
+- (NSUInteger)hash {
+ // Potentially called during dealloc.
+ if (!node_)
+ return [super hash];
+ return node_->GetData().id;
+}
+
- (void)detach {
+ if (!node_)
+ return;
+ NSAccessibilityPostNotification(
+ self, NSAccessibilityUIElementDestroyedNotification);
+ NSAccessibilityUnregisterUniqueIdForUIElement(self);
node_ = nil;
}
@@ -283,6 +305,14 @@ void NotifyMacEvent(NSView* target, ui::AXEvent event_type) {
return NSAccessibilityUnignoredAncestor(self);
}
+- (BOOL)accessibilityNotifiesWhenDestroyed {
+ return YES;
+}
+
+- (BOOL)accessibilityShouldUseUniqueId {
+ return YES;
+}
+
- (NSArray*)accessibilityActionNames {
return nil;
}
@@ -515,22 +545,28 @@ gfx::NativeViewAccessible AXPlatformNodeMac::GetNativeViewAccessible() {
}
void AXPlatformNodeMac::NotifyAccessibilityEvent(ui::AXEvent event_type) {
- NSView* target = GetDelegate()->GetTargetForNativeAccessibilityEvent();
-
+ if (!native_node_)
+ GetNativeViewAccessible();
// Add mappings between ui::AXEvent and NSAccessibility notifications using
// the EventMap above. This switch contains exceptions to those mappings.
switch (event_type) {
+ case ui::AX_EVENT_FOCUS:
+ [Tracer startTracePlatformNode];
+ NSAccessibilityPostNotification(
+ native_node_, NSAccessibilityFocusedUIElementChangedNotification);
+ [Tracer platformNodeEndTrace];
+ return;
Patti Lor 2016/08/04 02:06:26 With tracing removed, this whole hunk shouldn't be
case ui::AX_EVENT_TEXT_CHANGED:
// If the view is a user-editable textfield, this should change the value.
if (GetData().role == ui::AX_ROLE_TEXT_FIELD) {
- NotifyMacEvent(target, ui::AX_EVENT_VALUE_CHANGED);
+ NotifyMacEvent(native_node_, ui::AX_EVENT_VALUE_CHANGED);
return;
}
break;
default:
break;
}
- NotifyMacEvent(target, event_type);
+ NotifyMacEvent(native_node_, event_type);
}
int AXPlatformNodeMac::GetIndexInParent() {
« tmp-traceclass.h ('K') | « ui/accessibility/BUILD.gn ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698