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

Side by Side Diff: content/renderer/renderer_accessibility_complete.cc

Issue 10544099: Refactor all accessibility code out of webkit/glue. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix Mac build Created 8 years, 6 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 274 matching lines...) Expand 10 before | Expand all | Expand 10 after
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, &notification_msg.acc_tree); 318 BuildAccessibilityTree(obj, includes_children, &notification_msg.acc_tree);
320 if (obj.axID() == root_id) { 319 if (obj.axID() == root_id) {
321 DCHECK_EQ(notification_msg.acc_tree.role, 320 DCHECK_EQ(notification_msg.acc_tree.role,
322 WebAccessibility::ROLE_WEB_AREA); 321 AccessibilityNodeData::ROLE_WEB_AREA);
323 notification_msg.acc_tree.role = WebAccessibility::ROLE_ROOT_WEB_AREA; 322 notification_msg.acc_tree.role =
323 AccessibilityNodeData::ROLE_ROOT_WEB_AREA;
324 } 324 }
325 notification_msgs.push_back(notification_msg); 325 notification_msgs.push_back(notification_msg);
326 326
327 if (includes_children) 327 if (includes_children)
328 UpdateBrowserTree(notification_msg.acc_tree); 328 UpdateBrowserTree(notification_msg.acc_tree);
329 329
330 #ifndef NDEBUG 330 #ifndef NDEBUG
331 if (logging_) { 331 if (logging_) {
332 LOG(INFO) << "Accessibility update: \n" 332 LOG(INFO) << "Accessibility update: \n"
333 << "routing id=" << routing_id() 333 << "routing id=" << routing_id()
334 << " notification=" 334 << " notification="
335 << AccessibilityNotificationToString(notification.notification_type) 335 << AccessibilityNotificationToString(notification.notification_type)
336 << "\n" << notification_msg.acc_tree.DebugString(true); 336 << "\n" << notification_msg.acc_tree.DebugString(true);
337 } 337 }
338 #endif 338 #endif
339 } 339 }
340 340
341 Send(new AccessibilityHostMsg_Notifications(routing_id(), notification_msgs)); 341 Send(new AccessibilityHostMsg_Notifications(routing_id(), notification_msgs));
342 } 342 }
343 343
344 void RendererAccessibilityComplete::UpdateBrowserTree( 344 void RendererAccessibilityComplete::UpdateBrowserTree(
345 const webkit_glue::WebAccessibility& renderer_node) { 345 const AccessibilityNodeData& renderer_node) {
346 BrowserTreeNode* browser_node = NULL; 346 BrowserTreeNode* browser_node = NULL;
347 base::hash_map<int32, BrowserTreeNode*>::iterator iter = 347 base::hash_map<int32, BrowserTreeNode*>::iterator iter =
348 browser_id_map_.find(renderer_node.id); 348 browser_id_map_.find(renderer_node.id);
349 if (iter != browser_id_map_.end()) { 349 if (iter != browser_id_map_.end()) {
350 browser_node = iter->second; 350 browser_node = iter->second;
351 ClearBrowserTreeNode(browser_node); 351 ClearBrowserTreeNode(browser_node);
352 } else { 352 } else {
353 DCHECK_EQ(renderer_node.role, WebAccessibility::ROLE_ROOT_WEB_AREA); 353 DCHECK_EQ(renderer_node.role, AccessibilityNodeData::ROLE_ROOT_WEB_AREA);
354 if (browser_root_) { 354 if (browser_root_) {
355 ClearBrowserTreeNode(browser_root_); 355 ClearBrowserTreeNode(browser_root_);
356 browser_id_map_.erase(browser_root_->id); 356 browser_id_map_.erase(browser_root_->id);
357 delete browser_root_; 357 delete browser_root_;
358 } 358 }
359 browser_root_ = new BrowserTreeNode; 359 browser_root_ = new BrowserTreeNode;
360 browser_node = browser_root_; 360 browser_node = browser_root_;
361 browser_node->id = renderer_node.id; 361 browser_node->id = renderer_node.id;
362 browser_id_map_[browser_node->id] = browser_node; 362 browser_id_map_[browser_node->id] = browser_node;
363 } 363 }
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after
526 type == AccessibilityNotificationLiveRegionChanged || 526 type == AccessibilityNotificationLiveRegionChanged ||
527 type == AccessibilityNotificationSelectedChildrenChanged) { 527 type == AccessibilityNotificationSelectedChildrenChanged) {
528 return true; 528 return true;
529 } 529 }
530 return false; 530 return false;
531 } 531 }
532 532
533 void RendererAccessibilityComplete::BuildAccessibilityTree( 533 void RendererAccessibilityComplete::BuildAccessibilityTree(
534 const WebAccessibilityObject& src, 534 const WebAccessibilityObject& src,
535 bool include_children, 535 bool include_children,
536 WebAccessibility* dst) { 536 AccessibilityNodeData* dst) {
537 dst->Init(src, 537 AccessibilityNodeSerializer::Serialize(
538 include_children ? 538 src,
539 WebAccessibility::INCLUDE_CHILDREN : 539 dst,
540 WebAccessibility::NO_CHILDREN, 540 include_children ?
541 WebAccessibility::INCLUDE_LINE_BREAKS); 541 AccessibilityNodeSerializer::INCLUDE_CHILDREN :
542 AccessibilityNodeSerializer::NO_CHILDREN,
543 AccessibilityNodeSerializer::INCLUDE_LINE_BREAKS);
542 } 544 }
543 545
544 } // namespace content 546 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698