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_win.h" | 5 #include "content/browser/accessibility/browser_accessibility_manager_win.h" |
6 | 6 |
7 #include <atlbase.h> | 7 #include <atlbase.h> |
8 #include <atlapp.h> | 8 #include <atlapp.h> |
9 #include <atlcom.h> | 9 #include <atlcom.h> |
10 #include <atlcrack.h> | 10 #include <atlcrack.h> |
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
116 if (tracked_scroll_object_) { | 116 if (tracked_scroll_object_) { |
117 tracked_scroll_object_->Release(); | 117 tracked_scroll_object_->Release(); |
118 tracked_scroll_object_ = NULL; | 118 tracked_scroll_object_ = NULL; |
119 } | 119 } |
120 } | 120 } |
121 | 121 |
122 // static | 122 // static |
123 AccessibilityNodeData BrowserAccessibilityManagerWin::GetEmptyDocument() { | 123 AccessibilityNodeData BrowserAccessibilityManagerWin::GetEmptyDocument() { |
124 AccessibilityNodeData empty_document; | 124 AccessibilityNodeData empty_document; |
125 empty_document.id = 0; | 125 empty_document.id = 0; |
126 empty_document.role = WebKit::WebAXRoleRootWebArea; | 126 empty_document.role = blink::WebAXRoleRootWebArea; |
127 empty_document.state = | 127 empty_document.state = |
128 (1 << WebKit::WebAXStateEnabled) | | 128 (1 << blink::WebAXStateEnabled) | |
129 (1 << WebKit::WebAXStateReadonly) | | 129 (1 << blink::WebAXStateReadonly) | |
130 (1 << WebKit::WebAXStateBusy); | 130 (1 << blink::WebAXStateBusy); |
131 return empty_document; | 131 return empty_document; |
132 } | 132 } |
133 | 133 |
134 void BrowserAccessibilityManagerWin::MaybeCallNotifyWinEvent(DWORD event, | 134 void BrowserAccessibilityManagerWin::MaybeCallNotifyWinEvent(DWORD event, |
135 LONG child_id) { | 135 LONG child_id) { |
136 // Don't fire events if this view isn't hooked up to its parent. | 136 // Don't fire events if this view isn't hooked up to its parent. |
137 if (!parent_iaccessible()) | 137 if (!parent_iaccessible()) |
138 return; | 138 return; |
139 | 139 |
140 #if defined(USE_AURA) | 140 #if defined(USE_AURA) |
(...skipping 23 matching lines...) Expand all Loading... |
164 unique_id_to_renderer_id_map_.erase( | 164 unique_id_to_renderer_id_map_.erase( |
165 node->ToBrowserAccessibilityWin()->unique_id_win()); | 165 node->ToBrowserAccessibilityWin()->unique_id_win()); |
166 BrowserAccessibilityManager::RemoveNode(node); | 166 BrowserAccessibilityManager::RemoveNode(node); |
167 if (node == tracked_scroll_object_) { | 167 if (node == tracked_scroll_object_) { |
168 tracked_scroll_object_->Release(); | 168 tracked_scroll_object_->Release(); |
169 tracked_scroll_object_ = NULL; | 169 tracked_scroll_object_ = NULL; |
170 } | 170 } |
171 } | 171 } |
172 | 172 |
173 void BrowserAccessibilityManagerWin::NotifyAccessibilityEvent( | 173 void BrowserAccessibilityManagerWin::NotifyAccessibilityEvent( |
174 WebKit::WebAXEvent event_type, | 174 blink::WebAXEvent event_type, |
175 BrowserAccessibility* node) { | 175 BrowserAccessibility* node) { |
176 LONG event_id = EVENT_MIN; | 176 LONG event_id = EVENT_MIN; |
177 switch (event_type) { | 177 switch (event_type) { |
178 case WebKit::WebAXEventActiveDescendantChanged: | 178 case blink::WebAXEventActiveDescendantChanged: |
179 event_id = IA2_EVENT_ACTIVE_DESCENDANT_CHANGED; | 179 event_id = IA2_EVENT_ACTIVE_DESCENDANT_CHANGED; |
180 break; | 180 break; |
181 case WebKit::WebAXEventAlert: | 181 case blink::WebAXEventAlert: |
182 event_id = EVENT_SYSTEM_ALERT; | 182 event_id = EVENT_SYSTEM_ALERT; |
183 break; | 183 break; |
184 case WebKit::WebAXEventAriaAttributeChanged: | 184 case blink::WebAXEventAriaAttributeChanged: |
185 event_id = IA2_EVENT_OBJECT_ATTRIBUTE_CHANGED; | 185 event_id = IA2_EVENT_OBJECT_ATTRIBUTE_CHANGED; |
186 break; | 186 break; |
187 case WebKit::WebAXEventAutocorrectionOccured: | 187 case blink::WebAXEventAutocorrectionOccured: |
188 event_id = IA2_EVENT_OBJECT_ATTRIBUTE_CHANGED; | 188 event_id = IA2_EVENT_OBJECT_ATTRIBUTE_CHANGED; |
189 break; | 189 break; |
190 case WebKit::WebAXEventBlur: | 190 case blink::WebAXEventBlur: |
191 // Equivalent to focus on the root. | 191 // Equivalent to focus on the root. |
192 event_id = EVENT_OBJECT_FOCUS; | 192 event_id = EVENT_OBJECT_FOCUS; |
193 node = GetRoot(); | 193 node = GetRoot(); |
194 break; | 194 break; |
195 case WebKit::WebAXEventCheckedStateChanged: | 195 case blink::WebAXEventCheckedStateChanged: |
196 event_id = EVENT_OBJECT_STATECHANGE; | 196 event_id = EVENT_OBJECT_STATECHANGE; |
197 break; | 197 break; |
198 case WebKit::WebAXEventChildrenChanged: | 198 case blink::WebAXEventChildrenChanged: |
199 event_id = EVENT_OBJECT_REORDER; | 199 event_id = EVENT_OBJECT_REORDER; |
200 break; | 200 break; |
201 case WebKit::WebAXEventFocus: | 201 case blink::WebAXEventFocus: |
202 event_id = EVENT_OBJECT_FOCUS; | 202 event_id = EVENT_OBJECT_FOCUS; |
203 break; | 203 break; |
204 case WebKit::WebAXEventInvalidStatusChanged: | 204 case blink::WebAXEventInvalidStatusChanged: |
205 event_id = EVENT_OBJECT_STATECHANGE; | 205 event_id = EVENT_OBJECT_STATECHANGE; |
206 break; | 206 break; |
207 case WebKit::WebAXEventLiveRegionChanged: | 207 case blink::WebAXEventLiveRegionChanged: |
208 // TODO: try not firing a native notification at all, since | 208 // TODO: try not firing a native notification at all, since |
209 // on Windows, each individual item in a live region that changes | 209 // on Windows, each individual item in a live region that changes |
210 // already gets its own notification. | 210 // already gets its own notification. |
211 event_id = EVENT_OBJECT_REORDER; | 211 event_id = EVENT_OBJECT_REORDER; |
212 break; | 212 break; |
213 case WebKit::WebAXEventLoadComplete: | 213 case blink::WebAXEventLoadComplete: |
214 event_id = IA2_EVENT_DOCUMENT_LOAD_COMPLETE; | 214 event_id = IA2_EVENT_DOCUMENT_LOAD_COMPLETE; |
215 break; | 215 break; |
216 case WebKit::WebAXEventMenuListItemSelected: | 216 case blink::WebAXEventMenuListItemSelected: |
217 event_id = EVENT_OBJECT_FOCUS; | 217 event_id = EVENT_OBJECT_FOCUS; |
218 break; | 218 break; |
219 case WebKit::WebAXEventMenuListValueChanged: | 219 case blink::WebAXEventMenuListValueChanged: |
220 event_id = EVENT_OBJECT_VALUECHANGE; | 220 event_id = EVENT_OBJECT_VALUECHANGE; |
221 break; | 221 break; |
222 case WebKit::WebAXEventHide: | 222 case blink::WebAXEventHide: |
223 event_id = EVENT_OBJECT_HIDE; | 223 event_id = EVENT_OBJECT_HIDE; |
224 break; | 224 break; |
225 case WebKit::WebAXEventShow: | 225 case blink::WebAXEventShow: |
226 event_id = EVENT_OBJECT_SHOW; | 226 event_id = EVENT_OBJECT_SHOW; |
227 break; | 227 break; |
228 case WebKit::WebAXEventScrolledToAnchor: | 228 case blink::WebAXEventScrolledToAnchor: |
229 event_id = EVENT_SYSTEM_SCROLLINGSTART; | 229 event_id = EVENT_SYSTEM_SCROLLINGSTART; |
230 break; | 230 break; |
231 case WebKit::WebAXEventSelectedChildrenChanged: | 231 case blink::WebAXEventSelectedChildrenChanged: |
232 event_id = EVENT_OBJECT_SELECTIONWITHIN; | 232 event_id = EVENT_OBJECT_SELECTIONWITHIN; |
233 break; | 233 break; |
234 case WebKit::WebAXEventSelectedTextChanged: | 234 case blink::WebAXEventSelectedTextChanged: |
235 event_id = IA2_EVENT_TEXT_CARET_MOVED; | 235 event_id = IA2_EVENT_TEXT_CARET_MOVED; |
236 break; | 236 break; |
237 case WebKit::WebAXEventTextChanged: | 237 case blink::WebAXEventTextChanged: |
238 event_id = EVENT_OBJECT_NAMECHANGE; | 238 event_id = EVENT_OBJECT_NAMECHANGE; |
239 break; | 239 break; |
240 case WebKit::WebAXEventTextInserted: | 240 case blink::WebAXEventTextInserted: |
241 event_id = IA2_EVENT_TEXT_INSERTED; | 241 event_id = IA2_EVENT_TEXT_INSERTED; |
242 break; | 242 break; |
243 case WebKit::WebAXEventTextRemoved: | 243 case blink::WebAXEventTextRemoved: |
244 event_id = IA2_EVENT_TEXT_REMOVED; | 244 event_id = IA2_EVENT_TEXT_REMOVED; |
245 break; | 245 break; |
246 case WebKit::WebAXEventValueChanged: | 246 case blink::WebAXEventValueChanged: |
247 event_id = EVENT_OBJECT_VALUECHANGE; | 247 event_id = EVENT_OBJECT_VALUECHANGE; |
248 break; | 248 break; |
249 default: | 249 default: |
250 // Not all WebKit accessibility events result in a Windows | 250 // Not all WebKit accessibility events result in a Windows |
251 // accessibility notification. | 251 // accessibility notification. |
252 break; | 252 break; |
253 } | 253 } |
254 | 254 |
255 if (event_id != EVENT_MIN) { | 255 if (event_id != EVENT_MIN) { |
256 // Pass the node's unique id in the |child_id| argument to NotifyWinEvent; | 256 // Pass the node's unique id in the |child_id| argument to NotifyWinEvent; |
257 // the AT client will then call get_accChild on the HWND's accessibility | 257 // the AT client will then call get_accChild on the HWND's accessibility |
258 // object and pass it that same id, which we can use to retrieve the | 258 // object and pass it that same id, which we can use to retrieve the |
259 // IAccessible for this node. | 259 // IAccessible for this node. |
260 LONG child_id = node->ToBrowserAccessibilityWin()->unique_id_win(); | 260 LONG child_id = node->ToBrowserAccessibilityWin()->unique_id_win(); |
261 MaybeCallNotifyWinEvent(event_id, child_id); | 261 MaybeCallNotifyWinEvent(event_id, child_id); |
262 } | 262 } |
263 | 263 |
264 // If this is a layout complete notification (sent when a container scrolls) | 264 // If this is a layout complete notification (sent when a container scrolls) |
265 // and there is a descendant tracked object, send a notification on it. | 265 // and there is a descendant tracked object, send a notification on it. |
266 // TODO(dmazzoni): remove once http://crbug.com/113483 is fixed. | 266 // TODO(dmazzoni): remove once http://crbug.com/113483 is fixed. |
267 if (event_type == WebKit::WebAXEventLayoutComplete && | 267 if (event_type == blink::WebAXEventLayoutComplete && |
268 tracked_scroll_object_ && | 268 tracked_scroll_object_ && |
269 tracked_scroll_object_->IsDescendantOf(node)) { | 269 tracked_scroll_object_->IsDescendantOf(node)) { |
270 MaybeCallNotifyWinEvent( | 270 MaybeCallNotifyWinEvent( |
271 IA2_EVENT_VISIBLE_DATA_CHANGED, | 271 IA2_EVENT_VISIBLE_DATA_CHANGED, |
272 tracked_scroll_object_->ToBrowserAccessibilityWin()->unique_id_win()); | 272 tracked_scroll_object_->ToBrowserAccessibilityWin()->unique_id_win()); |
273 tracked_scroll_object_->Release(); | 273 tracked_scroll_object_->Release(); |
274 tracked_scroll_object_ = NULL; | 274 tracked_scroll_object_ = NULL; |
275 } | 275 } |
276 } | 276 } |
277 | 277 |
(...skipping 11 matching lines...) Expand all Loading... |
289 unique_id_to_renderer_id_map_.find(unique_id_win); | 289 unique_id_to_renderer_id_map_.find(unique_id_win); |
290 if (iter != unique_id_to_renderer_id_map_.end()) { | 290 if (iter != unique_id_to_renderer_id_map_.end()) { |
291 BrowserAccessibility* result = GetFromRendererID(iter->second); | 291 BrowserAccessibility* result = GetFromRendererID(iter->second); |
292 if (result) | 292 if (result) |
293 return result->ToBrowserAccessibilityWin(); | 293 return result->ToBrowserAccessibilityWin(); |
294 } | 294 } |
295 return NULL; | 295 return NULL; |
296 } | 296 } |
297 | 297 |
298 } // namespace content | 298 } // namespace content |
OLD | NEW |