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/renderer/renderer_accessibility_complete.h" | 5 #include "content/renderer/renderer_accessibility_complete.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/message_loop.h" | 8 #include "base/message_loop.h" |
| 9 #include "content/renderer/accessibility_node_serializer.h" |
9 #include "content/renderer/render_view_impl.h" | 10 #include "content/renderer/render_view_impl.h" |
10 #include "third_party/WebKit/Source/WebKit/chromium/public/WebAccessibilityObjec
t.h" | 11 #include "third_party/WebKit/Source/WebKit/chromium/public/WebAccessibilityObjec
t.h" |
11 #include "third_party/WebKit/Source/WebKit/chromium/public/WebDocument.h" | 12 #include "third_party/WebKit/Source/WebKit/chromium/public/WebDocument.h" |
12 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFrame.h" | 13 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFrame.h" |
13 #include "third_party/WebKit/Source/WebKit/chromium/public/WebInputElement.h" | 14 #include "third_party/WebKit/Source/WebKit/chromium/public/WebInputElement.h" |
14 #include "third_party/WebKit/Source/WebKit/chromium/public/WebNode.h" | 15 #include "third_party/WebKit/Source/WebKit/chromium/public/WebNode.h" |
15 #include "third_party/WebKit/Source/WebKit/chromium/public/WebView.h" | 16 #include "third_party/WebKit/Source/WebKit/chromium/public/WebView.h" |
16 #include "webkit/glue/webaccessibility.h" | |
17 | 17 |
18 using WebKit::WebAccessibilityNotification; | 18 using WebKit::WebAccessibilityNotification; |
19 using WebKit::WebAccessibilityObject; | 19 using WebKit::WebAccessibilityObject; |
20 using WebKit::WebDocument; | 20 using WebKit::WebDocument; |
21 using WebKit::WebFrame; | 21 using WebKit::WebFrame; |
22 using WebKit::WebNode; | 22 using WebKit::WebNode; |
23 using WebKit::WebPoint; | 23 using WebKit::WebPoint; |
24 using WebKit::WebRect; | 24 using WebKit::WebRect; |
25 using WebKit::WebSize; | 25 using WebKit::WebSize; |
26 using WebKit::WebView; | 26 using WebKit::WebView; |
27 using webkit_glue::WebAccessibility; | |
28 | 27 |
29 namespace content { | 28 namespace content { |
30 | 29 |
31 bool WebAccessibilityNotificationToAccessibilityNotification( | 30 bool WebAccessibilityNotificationToAccessibilityNotification( |
32 WebAccessibilityNotification notification, | 31 WebAccessibilityNotification notification, |
33 AccessibilityNotification* type) { | 32 AccessibilityNotification* type) { |
34 switch (notification) { | 33 switch (notification) { |
35 case WebKit::WebAccessibilityNotificationActiveDescendantChanged: | 34 case WebKit::WebAccessibilityNotificationActiveDescendantChanged: |
36 *type = AccessibilityNotificationActiveDescendantChanged; | 35 *type = AccessibilityNotificationActiveDescendantChanged; |
37 break; | 36 break; |
(...skipping 271 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
309 obj = parent; | 308 obj = parent; |
310 notification.id = obj.axID(); | 309 notification.id = obj.axID(); |
311 includes_children = true; | 310 includes_children = true; |
312 } | 311 } |
313 } | 312 } |
314 | 313 |
315 AccessibilityHostMsg_NotificationParams notification_msg; | 314 AccessibilityHostMsg_NotificationParams notification_msg; |
316 notification_msg.notification_type = notification.notification_type; | 315 notification_msg.notification_type = notification.notification_type; |
317 notification_msg.id = notification.id; | 316 notification_msg.id = notification.id; |
318 notification_msg.includes_children = includes_children; | 317 notification_msg.includes_children = includes_children; |
319 BuildAccessibilityTree(obj, includes_children, ¬ification_msg.acc_tree); | 318 SerializeAccessibilityNode(obj, |
| 319 ¬ification_msg.acc_tree, |
| 320 includes_children); |
320 if (obj.axID() == root_id) { | 321 if (obj.axID() == root_id) { |
321 DCHECK_EQ(notification_msg.acc_tree.role, | 322 DCHECK_EQ(notification_msg.acc_tree.role, |
322 WebAccessibility::ROLE_WEB_AREA); | 323 AccessibilityNodeData::ROLE_WEB_AREA); |
323 notification_msg.acc_tree.role = WebAccessibility::ROLE_ROOT_WEB_AREA; | 324 notification_msg.acc_tree.role = |
| 325 AccessibilityNodeData::ROLE_ROOT_WEB_AREA; |
324 } | 326 } |
325 notification_msgs.push_back(notification_msg); | 327 notification_msgs.push_back(notification_msg); |
326 | 328 |
327 if (includes_children) | 329 if (includes_children) |
328 UpdateBrowserTree(notification_msg.acc_tree); | 330 UpdateBrowserTree(notification_msg.acc_tree); |
329 | 331 |
330 #ifndef NDEBUG | 332 #ifndef NDEBUG |
331 if (logging_) { | 333 if (logging_) { |
332 LOG(INFO) << "Accessibility update: \n" | 334 LOG(INFO) << "Accessibility update: \n" |
333 << "routing id=" << routing_id() | 335 << "routing id=" << routing_id() |
334 << " notification=" | 336 << " notification=" |
335 << AccessibilityNotificationToString(notification.notification_type) | 337 << AccessibilityNotificationToString(notification.notification_type) |
336 << "\n" << notification_msg.acc_tree.DebugString(true); | 338 << "\n" << notification_msg.acc_tree.DebugString(true); |
337 } | 339 } |
338 #endif | 340 #endif |
339 } | 341 } |
340 | 342 |
341 Send(new AccessibilityHostMsg_Notifications(routing_id(), notification_msgs)); | 343 Send(new AccessibilityHostMsg_Notifications(routing_id(), notification_msgs)); |
342 } | 344 } |
343 | 345 |
344 void RendererAccessibilityComplete::UpdateBrowserTree( | 346 void RendererAccessibilityComplete::UpdateBrowserTree( |
345 const webkit_glue::WebAccessibility& renderer_node) { | 347 const AccessibilityNodeData& renderer_node) { |
346 BrowserTreeNode* browser_node = NULL; | 348 BrowserTreeNode* browser_node = NULL; |
347 base::hash_map<int32, BrowserTreeNode*>::iterator iter = | 349 base::hash_map<int32, BrowserTreeNode*>::iterator iter = |
348 browser_id_map_.find(renderer_node.id); | 350 browser_id_map_.find(renderer_node.id); |
349 if (iter != browser_id_map_.end()) { | 351 if (iter != browser_id_map_.end()) { |
350 browser_node = iter->second; | 352 browser_node = iter->second; |
351 ClearBrowserTreeNode(browser_node); | 353 ClearBrowserTreeNode(browser_node); |
352 } else { | 354 } else { |
353 DCHECK_EQ(renderer_node.role, WebAccessibility::ROLE_ROOT_WEB_AREA); | 355 DCHECK_EQ(renderer_node.role, AccessibilityNodeData::ROLE_ROOT_WEB_AREA); |
354 if (browser_root_) { | 356 if (browser_root_) { |
355 ClearBrowserTreeNode(browser_root_); | 357 ClearBrowserTreeNode(browser_root_); |
356 browser_id_map_.erase(browser_root_->id); | 358 browser_id_map_.erase(browser_root_->id); |
357 delete browser_root_; | 359 delete browser_root_; |
358 } | 360 } |
359 browser_root_ = new BrowserTreeNode; | 361 browser_root_ = new BrowserTreeNode; |
360 browser_node = browser_root_; | 362 browser_node = browser_root_; |
361 browser_node->id = renderer_node.id; | 363 browser_node->id = renderer_node.id; |
362 browser_id_map_[browser_node->id] = browser_node; | 364 browser_id_map_[browser_node->id] = browser_node; |
363 } | 365 } |
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
523 AccessibilityNotification type = notification.notification_type; | 525 AccessibilityNotification type = notification.notification_type; |
524 if (type == AccessibilityNotificationChildrenChanged || | 526 if (type == AccessibilityNotificationChildrenChanged || |
525 type == AccessibilityNotificationLoadComplete || | 527 type == AccessibilityNotificationLoadComplete || |
526 type == AccessibilityNotificationLiveRegionChanged || | 528 type == AccessibilityNotificationLiveRegionChanged || |
527 type == AccessibilityNotificationSelectedChildrenChanged) { | 529 type == AccessibilityNotificationSelectedChildrenChanged) { |
528 return true; | 530 return true; |
529 } | 531 } |
530 return false; | 532 return false; |
531 } | 533 } |
532 | 534 |
533 void RendererAccessibilityComplete::BuildAccessibilityTree( | |
534 const WebAccessibilityObject& src, | |
535 bool include_children, | |
536 WebAccessibility* dst) { | |
537 dst->Init(src, | |
538 include_children ? | |
539 WebAccessibility::INCLUDE_CHILDREN : | |
540 WebAccessibility::NO_CHILDREN, | |
541 WebAccessibility::INCLUDE_LINE_BREAKS); | |
542 } | |
543 | |
544 } // namespace content | 535 } // namespace content |
OLD | NEW |