OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 #include "content/browser/accessibility/browser_accessibility_manager_mac.h" | 5 #include "content/browser/accessibility/browser_accessibility_manager_mac.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #import "base/mac/mac_util.h" | 9 #import "base/mac/mac_util.h" |
10 #import "base/mac/sdk_forward_declarations.h" | 10 #import "base/mac/sdk_forward_declarations.h" |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
99 ui::AXNodeData empty_document; | 99 ui::AXNodeData empty_document; |
100 empty_document.id = 0; | 100 empty_document.id = 0; |
101 empty_document.role = ui::AX_ROLE_ROOT_WEB_AREA; | 101 empty_document.role = ui::AX_ROLE_ROOT_WEB_AREA; |
102 empty_document.state = | 102 empty_document.state = |
103 1 << ui::AX_STATE_READ_ONLY; | 103 1 << ui::AX_STATE_READ_ONLY; |
104 ui::AXTreeUpdate update; | 104 ui::AXTreeUpdate update; |
105 update.nodes.push_back(empty_document); | 105 update.nodes.push_back(empty_document); |
106 return update; | 106 return update; |
107 } | 107 } |
108 | 108 |
109 BrowserAccessibility* BrowserAccessibilityManagerMac::GetFocus( | 109 BrowserAccessibility* BrowserAccessibilityManagerMac::GetFocus() { |
110 BrowserAccessibility* root) { | |
111 // On Mac, list boxes should always get focus on the whole list, otherwise | 110 // On Mac, list boxes should always get focus on the whole list, otherwise |
112 // information about the number of selected items will never be reported. | 111 // information about the number of selected items will never be reported. |
113 BrowserAccessibility* node = BrowserAccessibilityManager::GetFocus(root); | 112 BrowserAccessibility* node = BrowserAccessibilityManager::GetFocus(); |
114 if (node && node->GetRole() == ui::AX_ROLE_LIST_BOX) | 113 if (node && node->GetRole() == ui::AX_ROLE_LIST_BOX) |
115 return node; | 114 return node; |
116 | 115 |
117 // For other roles, follow the active descendant. | 116 // For other roles, follow the active descendant. |
118 return GetActiveDescendantFocus(root); | 117 return GetActiveDescendantFocus(node); |
119 } | 118 } |
120 | 119 |
121 void BrowserAccessibilityManagerMac::NotifyAccessibilityEvent( | 120 void BrowserAccessibilityManagerMac::NotifyAccessibilityEvent( |
122 ui::AXEvent event_type, | 121 ui::AXEvent event_type, |
123 BrowserAccessibility* node) { | 122 BrowserAccessibility* node) { |
124 if (!node->IsNative()) | 123 if (!node->IsNative()) |
125 return; | 124 return; |
126 | 125 |
127 if (event_type == ui::AX_EVENT_FOCUS) { | 126 if (event_type == ui::AX_EVENT_FOCUS) { |
128 BrowserAccessibility* active_descendant = GetActiveDescendantFocus( | 127 BrowserAccessibility* active_descendant = GetActiveDescendantFocus(node); |
129 GetRoot()); | |
130 if (active_descendant) | 128 if (active_descendant) |
131 node = active_descendant; | 129 node = active_descendant; |
132 | 130 |
133 if (node->GetRole() == ui::AX_ROLE_LIST_BOX_OPTION && | 131 if (node->GetRole() == ui::AX_ROLE_LIST_BOX_OPTION && |
134 node->HasState(ui::AX_STATE_SELECTED) && | 132 node->HasState(ui::AX_STATE_SELECTED) && |
135 node->GetParent() && | 133 node->GetParent() && |
136 node->GetParent()->GetRole() == ui::AX_ROLE_LIST_BOX) { | 134 node->GetParent()->GetRole() == ui::AX_ROLE_LIST_BOX) { |
137 node = node->GetParent(); | 135 node = node->GetParent(); |
138 SetFocus(node, false); | 136 SetFocus(*node); |
139 } | 137 } |
140 } | 138 } |
141 | 139 |
142 auto native_node = node->ToBrowserAccessibilityCocoa(); | 140 auto native_node = node->ToBrowserAccessibilityCocoa(); |
143 DCHECK(native_node); | 141 DCHECK(native_node); |
144 | 142 |
145 // Refer to |AXObjectCache::postPlatformNotification| in WebKit source code. | 143 // Refer to |AXObjectCache::postPlatformNotification| in WebKit source code. |
146 NSString* mac_notification; | 144 NSString* mac_notification; |
147 switch (event_type) { | 145 switch (event_type) { |
148 case ui::AX_EVENT_ACTIVEDESCENDANTCHANGED: | 146 case ui::AX_EVENT_ACTIVEDESCENDANTCHANGED: |
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
307 auto native_focus_object = focus_object->ToBrowserAccessibilityCocoa(); | 305 auto native_focus_object = focus_object->ToBrowserAccessibilityCocoa(); |
308 if (native_focus_object) | 306 if (native_focus_object) |
309 [user_info setObject:native_focus_object | 307 [user_info setObject:native_focus_object |
310 forKey:NSAccessibilityTextChangeElement]; | 308 forKey:NSAccessibilityTextChangeElement]; |
311 } | 309 } |
312 | 310 |
313 return user_info; | 311 return user_info; |
314 } | 312 } |
315 | 313 |
316 } // namespace content | 314 } // namespace content |
OLD | NEW |