| 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/accessibility/renderer_accessibility_focus_only.h" | 5 #include "content/renderer/accessibility/renderer_accessibility_focus_only.h" |
| 6 | 6 |
| 7 #include "content/renderer/render_view_impl.h" | 7 #include "content/renderer/render_view_impl.h" |
| 8 #include "third_party/WebKit/public/web/WebDocument.h" | 8 #include "third_party/WebKit/public/web/WebDocument.h" |
| 9 #include "third_party/WebKit/public/web/WebElement.h" | 9 #include "third_party/WebKit/public/web/WebElement.h" |
| 10 #include "third_party/WebKit/public/web/WebFrame.h" | 10 #include "third_party/WebKit/public/web/WebFrame.h" |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 94 event.id = node_has_focus ? next_id_ : 1; | 94 event.id = node_has_focus ? next_id_ : 1; |
| 95 | 95 |
| 96 event.nodes.resize(2); | 96 event.nodes.resize(2); |
| 97 ui::AXNodeData& root = event.nodes[0]; | 97 ui::AXNodeData& root = event.nodes[0]; |
| 98 ui::AXNodeData& child = event.nodes[1]; | 98 ui::AXNodeData& child = event.nodes[1]; |
| 99 | 99 |
| 100 // Always include the root of the tree, the document. It always has id 1. | 100 // Always include the root of the tree, the document. It always has id 1. |
| 101 root.id = 1; | 101 root.id = 1; |
| 102 root.role = ui::AX_ROLE_ROOT_WEB_AREA; | 102 root.role = ui::AX_ROLE_ROOT_WEB_AREA; |
| 103 root.state = | 103 root.state = |
| 104 (1 << ui::AX_STATE_READONLY) | | 104 (1 << ui::AX_STATE_READ_ONLY) | |
| 105 (1 << ui::AX_STATE_FOCUSABLE); | 105 (1 << ui::AX_STATE_FOCUSABLE); |
| 106 if (!node_has_focus) | 106 if (!node_has_focus) |
| 107 root.state |= (1 << ui::AX_STATE_FOCUSED); | 107 root.state |= (1 << ui::AX_STATE_FOCUSED); |
| 108 root.location = gfx::Rect(render_view_->size()); | 108 root.location = gfx::Rect(render_view_->size()); |
| 109 root.child_ids.push_back(next_id_); | 109 root.child_ids.push_back(next_id_); |
| 110 | 110 |
| 111 child.id = next_id_; | 111 child.id = next_id_; |
| 112 child.role = ui::AX_ROLE_GROUP; | 112 child.role = ui::AX_ROLE_GROUP; |
| 113 | 113 |
| 114 if (!node.isNull() && node.isElementNode()) { | 114 if (!node.isNull() && node.isElementNode()) { |
| 115 child.location = gfx::Rect( | 115 child.location = gfx::Rect( |
| 116 const_cast<WebNode&>(node).to<WebElement>().boundsInViewportSpace()); | 116 const_cast<WebNode&>(node).to<WebElement>().boundsInViewportSpace()); |
| 117 } else if (render_view_->HasIMETextFocus()) { | 117 } else if (render_view_->HasIMETextFocus()) { |
| 118 child.location = root.location; | 118 child.location = root.location; |
| 119 } else { | 119 } else { |
| 120 child.location = gfx::Rect(); | 120 child.location = gfx::Rect(); |
| 121 } | 121 } |
| 122 | 122 |
| 123 if (node_has_focus) { | 123 if (node_has_focus) { |
| 124 child.state = | 124 child.state = |
| 125 (1 << ui::AX_STATE_FOCUSABLE) | | 125 (1 << ui::AX_STATE_FOCUSABLE) | |
| 126 (1 << ui::AX_STATE_FOCUSED); | 126 (1 << ui::AX_STATE_FOCUSED); |
| 127 if (!node_is_editable_text) | 127 if (!node_is_editable_text) |
| 128 child.state |= (1 << ui::AX_STATE_READONLY); | 128 child.state |= (1 << ui::AX_STATE_READ_ONLY); |
| 129 } | 129 } |
| 130 | 130 |
| 131 #ifndef NDEBUG | 131 #ifndef NDEBUG |
| 132 /** | 132 /** |
| 133 if (logging_) { | 133 if (logging_) { |
| 134 VLOG(0) << "Accessibility update: \n" | 134 VLOG(0) << "Accessibility update: \n" |
| 135 << "routing id=" << routing_id() | 135 << "routing id=" << routing_id() |
| 136 << " event=" | 136 << " event=" |
| 137 << AccessibilityEventToString(event.event_type) | 137 << AccessibilityEventToString(event.event_type) |
| 138 << "\n" << event.nodes[0].DebugString(true); | 138 << "\n" << event.nodes[0].DebugString(true); |
| 139 } | 139 } |
| 140 **/ | 140 **/ |
| 141 #endif | 141 #endif |
| 142 | 142 |
| 143 Send(new AccessibilityHostMsg_Events(routing_id(), events)); | 143 Send(new AccessibilityHostMsg_Events(routing_id(), events)); |
| 144 | 144 |
| 145 // Increment the id, wrap back when we get past a million. | 145 // Increment the id, wrap back when we get past a million. |
| 146 next_id_++; | 146 next_id_++; |
| 147 if (next_id_ > 1000000) | 147 if (next_id_ > 1000000) |
| 148 next_id_ = kInitialId; | 148 next_id_ = kInitialId; |
| 149 } | 149 } |
| 150 | 150 |
| 151 } // namespace content | 151 } // namespace content |
| OLD | NEW |