| 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_focus_only.h" | 5 #include "content/renderer/renderer_accessibility_focus_only.h" |
| 6 | 6 |
| 7 #include "content/common/accessibility_node_data.h" |
| 7 #include "content/renderer/render_view_impl.h" | 8 #include "content/renderer/render_view_impl.h" |
| 8 #include "third_party/WebKit/Source/WebKit/chromium/public/WebDocument.h" | 9 #include "third_party/WebKit/Source/WebKit/chromium/public/WebDocument.h" |
| 9 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFrame.h" | 10 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFrame.h" |
| 10 #include "third_party/WebKit/Source/WebKit/chromium/public/WebNode.h" | 11 #include "third_party/WebKit/Source/WebKit/chromium/public/WebNode.h" |
| 11 #include "third_party/WebKit/Source/WebKit/chromium/public/WebView.h" | 12 #include "third_party/WebKit/Source/WebKit/chromium/public/WebView.h" |
| 12 #include "webkit/glue/webaccessibility.h" | |
| 13 | 13 |
| 14 using WebKit::WebDocument; | 14 using WebKit::WebDocument; |
| 15 using WebKit::WebFrame; | 15 using WebKit::WebFrame; |
| 16 using WebKit::WebNode; | 16 using WebKit::WebNode; |
| 17 using WebKit::WebView; | 17 using WebKit::WebView; |
| 18 using webkit_glue::WebAccessibility; | |
| 19 | 18 |
| 20 namespace { | 19 namespace { |
| 21 // The root node will always have id 1. Let each child node have a new | 20 // The root node will always have id 1. Let each child node have a new |
| 22 // id starting with 2. | 21 // id starting with 2. |
| 23 const int kInitialId = 2; | 22 const int kInitialId = 2; |
| 24 } | 23 } |
| 25 | 24 |
| 26 namespace content { | 25 namespace content { |
| 27 | 26 |
| 28 RendererAccessibilityFocusOnly::RendererAccessibilityFocusOnly( | 27 RendererAccessibilityFocusOnly::RendererAccessibilityFocusOnly( |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 80 // This means that the new tree we send supercedes any previous tree, | 79 // This means that the new tree we send supercedes any previous tree, |
| 81 // not just a previous node. | 80 // not just a previous node. |
| 82 notification.includes_children = true; | 81 notification.includes_children = true; |
| 83 | 82 |
| 84 // Set the id that the notification applies to: the root node if nothing | 83 // Set the id that the notification applies to: the root node if nothing |
| 85 // has focus, otherwise the focused node. | 84 // has focus, otherwise the focused node. |
| 86 notification.id = node.isNull() ? 1 : next_id_; | 85 notification.id = node.isNull() ? 1 : next_id_; |
| 87 | 86 |
| 88 // Always include the root of the tree, the document. It always has id 1. | 87 // Always include the root of the tree, the document. It always has id 1. |
| 89 notification.acc_tree.id = 1; | 88 notification.acc_tree.id = 1; |
| 90 notification.acc_tree.role = WebAccessibility::ROLE_ROOT_WEB_AREA; | 89 notification.acc_tree.role = AccessibilityNodeData::ROLE_ROOT_WEB_AREA; |
| 91 notification.acc_tree.state = | 90 notification.acc_tree.state = |
| 92 (1 << WebAccessibility::STATE_READONLY) | | 91 (1 << AccessibilityNodeData::STATE_READONLY) | |
| 93 (1 << WebAccessibility::STATE_FOCUSABLE); | 92 (1 << AccessibilityNodeData::STATE_FOCUSABLE); |
| 94 if (node.isNull()) | 93 if (node.isNull()) |
| 95 notification.acc_tree.state |= (1 << WebAccessibility::STATE_FOCUSED); | 94 notification.acc_tree.state |= (1 << AccessibilityNodeData::STATE_FOCUSED); |
| 96 notification.acc_tree.location = gfx::Rect(render_view_->size()); | 95 notification.acc_tree.location = gfx::Rect(render_view_->size()); |
| 97 | 96 |
| 98 notification.acc_tree.children.push_back(WebAccessibility()); | 97 notification.acc_tree.children.push_back(AccessibilityNodeData()); |
| 99 WebAccessibility& child = notification.acc_tree.children[0]; | 98 AccessibilityNodeData& child = notification.acc_tree.children[0]; |
| 100 child.id = next_id_; | 99 child.id = next_id_; |
| 101 child.role = WebAccessibility::ROLE_GROUP; | 100 child.role = AccessibilityNodeData::ROLE_GROUP; |
| 102 child.location = gfx::Rect(render_view_->size()); | 101 child.location = gfx::Rect(render_view_->size()); |
| 103 if (!node.isNull()) { | 102 if (!node.isNull()) { |
| 104 child.state = | 103 child.state = |
| 105 (1 << WebAccessibility::STATE_FOCUSABLE) | | 104 (1 << AccessibilityNodeData::STATE_FOCUSABLE) | |
| 106 (1 << WebAccessibility::STATE_FOCUSED); | 105 (1 << AccessibilityNodeData::STATE_FOCUSED); |
| 107 if (!render_view_->IsEditableNode(node)) | 106 if (!render_view_->IsEditableNode(node)) |
| 108 child.state |= (1 << WebAccessibility::STATE_READONLY); | 107 child.state |= (1 << AccessibilityNodeData::STATE_READONLY); |
| 109 } | 108 } |
| 110 | 109 |
| 111 #ifndef NDEBUG | 110 #ifndef NDEBUG |
| 112 if (logging_) { | 111 if (logging_) { |
| 113 LOG(INFO) << "Accessibility update: \n" | 112 LOG(INFO) << "Accessibility update: \n" |
| 114 << "routing id=" << routing_id() | 113 << "routing id=" << routing_id() |
| 115 << " notification=" | 114 << " notification=" |
| 116 << AccessibilityNotificationToString(notification.notification_type) | 115 << AccessibilityNotificationToString(notification.notification_type) |
| 117 << "\n" << notification.acc_tree.DebugString(true); | 116 << "\n" << notification.acc_tree.DebugString(true); |
| 118 } | 117 } |
| 119 #endif | 118 #endif |
| 120 | 119 |
| 121 Send(new AccessibilityHostMsg_Notifications(routing_id(), notifications)); | 120 Send(new AccessibilityHostMsg_Notifications(routing_id(), notifications)); |
| 122 | 121 |
| 123 // Increment the id, wrap back when we get past a million. | 122 // Increment the id, wrap back when we get past a million. |
| 124 next_id_++; | 123 next_id_++; |
| 125 if (next_id_ > 1000000) | 124 if (next_id_ > 1000000) |
| 126 next_id_ = kInitialId; | 125 next_id_ = kInitialId; |
| 127 } | 126 } |
| 128 | 127 |
| 129 } // namespace content | 128 } // namespace content |
| OLD | NEW |