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 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
90 | 90 |
91 BrowserAccessibilityManagerWin* manager_; | 91 BrowserAccessibilityManagerWin* manager_; |
92 base::win::ScopedComPtr<IAccessible> window_accessible_; | 92 base::win::ScopedComPtr<IAccessible> window_accessible_; |
93 | 93 |
94 DISALLOW_COPY_AND_ASSIGN(AccessibleHWND); | 94 DISALLOW_COPY_AND_ASSIGN(AccessibleHWND); |
95 }; | 95 }; |
96 | 96 |
97 | 97 |
98 // static | 98 // static |
99 BrowserAccessibilityManager* BrowserAccessibilityManager::Create( | 99 BrowserAccessibilityManager* BrowserAccessibilityManager::Create( |
100 const AccessibilityNodeData& src, | 100 const ui::AXNodeData& src, |
101 BrowserAccessibilityDelegate* delegate, | 101 BrowserAccessibilityDelegate* delegate, |
102 BrowserAccessibilityFactory* factory) { | 102 BrowserAccessibilityFactory* factory) { |
103 return new BrowserAccessibilityManagerWin( | 103 return new BrowserAccessibilityManagerWin( |
104 GetDesktopWindow(), NULL, src, delegate, factory); | 104 GetDesktopWindow(), NULL, src, delegate, factory); |
105 } | 105 } |
106 | 106 |
107 BrowserAccessibilityManagerWin* | 107 BrowserAccessibilityManagerWin* |
108 BrowserAccessibilityManager::ToBrowserAccessibilityManagerWin() { | 108 BrowserAccessibilityManager::ToBrowserAccessibilityManagerWin() { |
109 return static_cast<BrowserAccessibilityManagerWin*>(this); | 109 return static_cast<BrowserAccessibilityManagerWin*>(this); |
110 } | 110 } |
111 | 111 |
112 BrowserAccessibilityManagerWin::BrowserAccessibilityManagerWin( | 112 BrowserAccessibilityManagerWin::BrowserAccessibilityManagerWin( |
113 HWND parent_hwnd, | 113 HWND parent_hwnd, |
114 IAccessible* parent_iaccessible, | 114 IAccessible* parent_iaccessible, |
115 const AccessibilityNodeData& src, | 115 const ui::AXNodeData& src, |
116 BrowserAccessibilityDelegate* delegate, | 116 BrowserAccessibilityDelegate* delegate, |
117 BrowserAccessibilityFactory* factory) | 117 BrowserAccessibilityFactory* factory) |
118 : BrowserAccessibilityManager(src, delegate, factory), | 118 : BrowserAccessibilityManager(src, delegate, factory), |
119 parent_hwnd_(parent_hwnd), | 119 parent_hwnd_(parent_hwnd), |
120 parent_iaccessible_(parent_iaccessible), | 120 parent_iaccessible_(parent_iaccessible), |
121 tracked_scroll_object_(NULL), | 121 tracked_scroll_object_(NULL), |
122 is_chrome_frame_( | 122 is_chrome_frame_( |
123 CommandLine::ForCurrentProcess()->HasSwitch("chrome-frame")), | 123 CommandLine::ForCurrentProcess()->HasSwitch("chrome-frame")), |
124 accessible_hwnd_(NULL) { | 124 accessible_hwnd_(NULL) { |
125 } | 125 } |
126 | 126 |
127 BrowserAccessibilityManagerWin::~BrowserAccessibilityManagerWin() { | 127 BrowserAccessibilityManagerWin::~BrowserAccessibilityManagerWin() { |
128 if (tracked_scroll_object_) { | 128 if (tracked_scroll_object_) { |
129 tracked_scroll_object_->Release(); | 129 tracked_scroll_object_->Release(); |
130 tracked_scroll_object_ = NULL; | 130 tracked_scroll_object_ = NULL; |
131 } | 131 } |
132 if (accessible_hwnd_) | 132 if (accessible_hwnd_) |
133 accessible_hwnd_->OnManagerDeleted(); | 133 accessible_hwnd_->OnManagerDeleted(); |
134 } | 134 } |
135 | 135 |
136 // static | 136 // static |
137 AccessibilityNodeData BrowserAccessibilityManagerWin::GetEmptyDocument() { | 137 ui::AXNodeData BrowserAccessibilityManagerWin::GetEmptyDocument() { |
138 AccessibilityNodeData empty_document; | 138 ui::AXNodeData empty_document; |
139 empty_document.id = 0; | 139 empty_document.id = 0; |
140 empty_document.role = blink::WebAXRoleRootWebArea; | 140 empty_document.role = ui::AX_ROLE_ROOT_WEB_AREA; |
141 empty_document.state = | 141 empty_document.state = |
142 (1 << blink::WebAXStateEnabled) | | 142 (1 << blink::WebAXStateEnabled) | |
143 (1 << blink::WebAXStateReadonly) | | 143 (1 << ui::AX_STATE_READONLY) | |
144 (1 << blink::WebAXStateBusy); | 144 (1 << ui::AX_STATE_BUSY); |
145 return empty_document; | 145 return empty_document; |
146 } | 146 } |
147 | 147 |
148 void BrowserAccessibilityManagerWin::MaybeCallNotifyWinEvent(DWORD event, | 148 void BrowserAccessibilityManagerWin::MaybeCallNotifyWinEvent(DWORD event, |
149 LONG child_id) { | 149 LONG child_id) { |
150 // Don't fire events if this view isn't hooked up to its parent. | 150 // Don't fire events if this view isn't hooked up to its parent. |
151 if (!parent_iaccessible()) | 151 if (!parent_iaccessible()) |
152 return; | 152 return; |
153 | 153 |
154 #if defined(USE_AURA) | 154 #if defined(USE_AURA) |
(...skipping 22 matching lines...) Expand all Loading... |
177 unique_id_to_renderer_id_map_.erase( | 177 unique_id_to_renderer_id_map_.erase( |
178 node->ToBrowserAccessibilityWin()->unique_id_win()); | 178 node->ToBrowserAccessibilityWin()->unique_id_win()); |
179 BrowserAccessibilityManager::RemoveNode(node); | 179 BrowserAccessibilityManager::RemoveNode(node); |
180 if (node == tracked_scroll_object_) { | 180 if (node == tracked_scroll_object_) { |
181 tracked_scroll_object_->Release(); | 181 tracked_scroll_object_->Release(); |
182 tracked_scroll_object_ = NULL; | 182 tracked_scroll_object_ = NULL; |
183 } | 183 } |
184 } | 184 } |
185 | 185 |
186 void BrowserAccessibilityManagerWin::NotifyAccessibilityEvent( | 186 void BrowserAccessibilityManagerWin::NotifyAccessibilityEvent( |
187 blink::WebAXEvent event_type, | 187 ui::AXEvent event_type, |
188 BrowserAccessibility* node) { | 188 BrowserAccessibility* node) { |
189 if (node->role() == blink::WebAXRoleInlineTextBox) | 189 if (node->role() == ui::AX_ROLE_INLINE_TEXT_BOX) |
190 return; | 190 return; |
191 | 191 |
192 LONG event_id = EVENT_MIN; | 192 LONG event_id = EVENT_MIN; |
193 switch (event_type) { | 193 switch (event_type) { |
194 case blink::WebAXEventActiveDescendantChanged: | 194 case ui::AX_EVENT_ACTIVEDESCENDANTCHANGED: |
195 event_id = IA2_EVENT_ACTIVE_DESCENDANT_CHANGED; | 195 event_id = IA2_EVENT_ACTIVE_DESCENDANT_CHANGED; |
196 break; | 196 break; |
197 case blink::WebAXEventAlert: | 197 case ui::AX_EVENT_ALERT: |
198 event_id = EVENT_SYSTEM_ALERT; | 198 event_id = EVENT_SYSTEM_ALERT; |
199 break; | 199 break; |
200 case blink::WebAXEventAriaAttributeChanged: | 200 case ui::AX_EVENT_ARIA_ATTRIBUTE_CHANGED: |
201 event_id = IA2_EVENT_OBJECT_ATTRIBUTE_CHANGED; | 201 event_id = IA2_EVENT_OBJECT_ATTRIBUTE_CHANGED; |
202 break; | 202 break; |
203 case blink::WebAXEventAutocorrectionOccured: | 203 case ui::AX_EVENT_AUTOCORRECTION_OCCURED: |
204 event_id = IA2_EVENT_OBJECT_ATTRIBUTE_CHANGED; | 204 event_id = IA2_EVENT_OBJECT_ATTRIBUTE_CHANGED; |
205 break; | 205 break; |
206 case blink::WebAXEventBlur: | 206 case ui::AX_EVENT_BLUR: |
207 // Equivalent to focus on the root. | 207 // Equivalent to focus on the root. |
208 event_id = EVENT_OBJECT_FOCUS; | 208 event_id = EVENT_OBJECT_FOCUS; |
209 node = GetRoot(); | 209 node = GetRoot(); |
210 break; | 210 break; |
211 case blink::WebAXEventCheckedStateChanged: | 211 case ui::AX_EVENT_CHECKED_STATE_CHANGED: |
212 event_id = EVENT_OBJECT_STATECHANGE; | 212 event_id = EVENT_OBJECT_STATECHANGE; |
213 break; | 213 break; |
214 case blink::WebAXEventChildrenChanged: | 214 case ui::AX_EVENT_CHILDREN_CHANGED: |
215 event_id = EVENT_OBJECT_REORDER; | 215 event_id = EVENT_OBJECT_REORDER; |
216 break; | 216 break; |
217 case blink::WebAXEventFocus: | 217 case ui::AX_EVENT_FOCUS: |
218 event_id = EVENT_OBJECT_FOCUS; | 218 event_id = EVENT_OBJECT_FOCUS; |
219 break; | 219 break; |
220 case blink::WebAXEventInvalidStatusChanged: | 220 case ui::AX_EVENT_INVALID_STATUS_CHANGED: |
221 event_id = EVENT_OBJECT_STATECHANGE; | 221 event_id = EVENT_OBJECT_STATECHANGE; |
222 break; | 222 break; |
223 case blink::WebAXEventLiveRegionChanged: | 223 case ui::AX_EVENT_LIVE_REGION_CHANGED: |
224 // TODO: try not firing a native notification at all, since | 224 // TODO: try not firing a native notification at all, since |
225 // on Windows, each individual item in a live region that changes | 225 // on Windows, each individual item in a live region that changes |
226 // already gets its own notification. | 226 // already gets its own notification. |
227 event_id = EVENT_OBJECT_REORDER; | 227 event_id = EVENT_OBJECT_REORDER; |
228 break; | 228 break; |
229 case blink::WebAXEventLoadComplete: | 229 case ui::AX_EVENT_LOAD_COMPLETE: |
230 event_id = IA2_EVENT_DOCUMENT_LOAD_COMPLETE; | 230 event_id = IA2_EVENT_DOCUMENT_LOAD_COMPLETE; |
231 break; | 231 break; |
232 case blink::WebAXEventMenuListItemSelected: | 232 case ui::AX_EVENT_MENU_LIST_ITEM_SELECTED: |
233 event_id = EVENT_OBJECT_FOCUS; | 233 event_id = EVENT_OBJECT_FOCUS; |
234 break; | 234 break; |
235 case blink::WebAXEventMenuListValueChanged: | 235 case ui::AX_EVENT_MENU_LIST_VALUE_CHANGED: |
236 event_id = EVENT_OBJECT_VALUECHANGE; | 236 event_id = EVENT_OBJECT_VALUECHANGE; |
237 break; | 237 break; |
238 case blink::WebAXEventHide: | 238 case ui::AX_EVENT_HIDE: |
239 event_id = EVENT_OBJECT_HIDE; | 239 event_id = EVENT_OBJECT_HIDE; |
240 break; | 240 break; |
241 case blink::WebAXEventShow: | 241 case ui::AX_EVENT_SHOW: |
242 event_id = EVENT_OBJECT_SHOW; | 242 event_id = EVENT_OBJECT_SHOW; |
243 break; | 243 break; |
244 case blink::WebAXEventScrolledToAnchor: | 244 case ui::AX_EVENT_SCROLLED_TO_ANCHOR: |
245 event_id = EVENT_SYSTEM_SCROLLINGSTART; | 245 event_id = EVENT_SYSTEM_SCROLLINGSTART; |
246 break; | 246 break; |
247 case blink::WebAXEventSelectedChildrenChanged: | 247 case ui::AX_EVENT_SELECTED_CHILDREN_CHANGED: |
248 event_id = EVENT_OBJECT_SELECTIONWITHIN; | 248 event_id = EVENT_OBJECT_SELECTIONWITHIN; |
249 break; | 249 break; |
250 case blink::WebAXEventSelectedTextChanged: | 250 case ui::AX_EVENT_SELECTED_TEXT_CHANGED: |
251 event_id = IA2_EVENT_TEXT_CARET_MOVED; | 251 event_id = IA2_EVENT_TEXT_CARET_MOVED; |
252 break; | 252 break; |
253 case blink::WebAXEventTextChanged: | 253 case ui::AX_EVENT_TEXT_CHANGED: |
254 event_id = EVENT_OBJECT_NAMECHANGE; | 254 event_id = EVENT_OBJECT_NAMECHANGE; |
255 break; | 255 break; |
256 case blink::WebAXEventTextInserted: | 256 case ui::AX_EVENT_TEXT_INSERTED: |
257 event_id = IA2_EVENT_TEXT_INSERTED; | 257 event_id = IA2_EVENT_TEXT_INSERTED; |
258 break; | 258 break; |
259 case blink::WebAXEventTextRemoved: | 259 case ui::AX_EVENT_TEXT_REMOVED: |
260 event_id = IA2_EVENT_TEXT_REMOVED; | 260 event_id = IA2_EVENT_TEXT_REMOVED; |
261 break; | 261 break; |
262 case blink::WebAXEventValueChanged: | 262 case ui::AX_EVENT_VALUE_CHANGED: |
263 event_id = EVENT_OBJECT_VALUECHANGE; | 263 event_id = EVENT_OBJECT_VALUECHANGE; |
264 break; | 264 break; |
265 default: | 265 default: |
266 // Not all WebKit accessibility events result in a Windows | 266 // Not all WebKit accessibility events result in a Windows |
267 // accessibility notification. | 267 // accessibility notification. |
268 break; | 268 break; |
269 } | 269 } |
270 | 270 |
271 if (event_id != EVENT_MIN) { | 271 if (event_id != EVENT_MIN) { |
272 // Pass the node's unique id in the |child_id| argument to NotifyWinEvent; | 272 // Pass the node's unique id in the |child_id| argument to NotifyWinEvent; |
273 // the AT client will then call get_accChild on the HWND's accessibility | 273 // the AT client will then call get_accChild on the HWND's accessibility |
274 // object and pass it that same id, which we can use to retrieve the | 274 // object and pass it that same id, which we can use to retrieve the |
275 // IAccessible for this node. | 275 // IAccessible for this node. |
276 LONG child_id = node->ToBrowserAccessibilityWin()->unique_id_win(); | 276 LONG child_id = node->ToBrowserAccessibilityWin()->unique_id_win(); |
277 MaybeCallNotifyWinEvent(event_id, child_id); | 277 MaybeCallNotifyWinEvent(event_id, child_id); |
278 } | 278 } |
279 | 279 |
280 // If this is a layout complete notification (sent when a container scrolls) | 280 // If this is a layout complete notification (sent when a container scrolls) |
281 // and there is a descendant tracked object, send a notification on it. | 281 // and there is a descendant tracked object, send a notification on it. |
282 // TODO(dmazzoni): remove once http://crbug.com/113483 is fixed. | 282 // TODO(dmazzoni): remove once http://crbug.com/113483 is fixed. |
283 if (event_type == blink::WebAXEventLayoutComplete && | 283 if (event_type == ui::AX_EVENT_LAYOUT_COMPLETE && |
284 tracked_scroll_object_ && | 284 tracked_scroll_object_ && |
285 tracked_scroll_object_->IsDescendantOf(node)) { | 285 tracked_scroll_object_->IsDescendantOf(node)) { |
286 MaybeCallNotifyWinEvent( | 286 MaybeCallNotifyWinEvent( |
287 IA2_EVENT_VISIBLE_DATA_CHANGED, | 287 IA2_EVENT_VISIBLE_DATA_CHANGED, |
288 tracked_scroll_object_->ToBrowserAccessibilityWin()->unique_id_win()); | 288 tracked_scroll_object_->ToBrowserAccessibilityWin()->unique_id_win()); |
289 tracked_scroll_object_->Release(); | 289 tracked_scroll_object_->Release(); |
290 tracked_scroll_object_ = NULL; | 290 tracked_scroll_object_ = NULL; |
291 } | 291 } |
292 } | 292 } |
293 | 293 |
(...skipping 22 matching lines...) Expand all Loading... |
316 // |parent_iaccessible_| are no longer valid either, since they were | 316 // |parent_iaccessible_| are no longer valid either, since they were |
317 // derived from AccessibleHWND. We don't have to restore them to | 317 // derived from AccessibleHWND. We don't have to restore them to |
318 // previous values, though, because this should only happen | 318 // previous values, though, because this should only happen |
319 // during the destruct sequence for this window. | 319 // during the destruct sequence for this window. |
320 accessible_hwnd_ = NULL; | 320 accessible_hwnd_ = NULL; |
321 parent_hwnd_ = NULL; | 321 parent_hwnd_ = NULL; |
322 parent_iaccessible_ = NULL; | 322 parent_iaccessible_ = NULL; |
323 } | 323 } |
324 | 324 |
325 } // namespace content | 325 } // namespace content |
OLD | NEW |