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

Side by Side Diff: content/renderer/accessibility/renderer_accessibility_focus_only.cc

Issue 116293005: Refactor content/ to use ui::AXNodeData instead of blink. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Update content/DEPS instead of subdirs Created 6 years, 11 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/accessibility/renderer_accessibility_focus_only.h" 5 #include "content/renderer/accessibility/renderer_accessibility_focus_only.h"
6 6
7 #include "content/common/accessibility_node_data.h"
8 #include "content/renderer/render_view_impl.h" 7 #include "content/renderer/render_view_impl.h"
9 #include "third_party/WebKit/public/web/WebDocument.h" 8 #include "third_party/WebKit/public/web/WebDocument.h"
10 #include "third_party/WebKit/public/web/WebElement.h" 9 #include "third_party/WebKit/public/web/WebElement.h"
11 #include "third_party/WebKit/public/web/WebFrame.h" 10 #include "third_party/WebKit/public/web/WebFrame.h"
12 #include "third_party/WebKit/public/web/WebNode.h" 11 #include "third_party/WebKit/public/web/WebNode.h"
13 #include "third_party/WebKit/public/web/WebView.h" 12 #include "third_party/WebKit/public/web/WebView.h"
13 #include "ui/accessibility/ax_node_data.h"
14 14
15 using blink::WebDocument; 15 using blink::WebDocument;
16 using blink::WebElement; 16 using blink::WebElement;
17 using blink::WebFrame; 17 using blink::WebFrame;
18 using blink::WebNode; 18 using blink::WebNode;
19 using blink::WebView; 19 using blink::WebView;
20 20
21 namespace { 21 namespace {
22 // The root node will always have id 1. Let each child node have a new 22 // The root node will always have id 1. Let each child node have a new
23 // id starting with 2. 23 // id starting with 2.
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
80 } 80 }
81 81
82 std::vector<AccessibilityHostMsg_EventParams> events; 82 std::vector<AccessibilityHostMsg_EventParams> events;
83 events.push_back(AccessibilityHostMsg_EventParams()); 83 events.push_back(AccessibilityHostMsg_EventParams());
84 AccessibilityHostMsg_EventParams& event = events[0]; 84 AccessibilityHostMsg_EventParams& event = events[0];
85 85
86 // If we want to update the browser's accessibility tree but not send a 86 // If we want to update the browser's accessibility tree but not send a
87 // native focus changed event, we can send a LayoutComplete 87 // native focus changed event, we can send a LayoutComplete
88 // event, which doesn't post a native event on Windows. 88 // event, which doesn't post a native event on Windows.
89 event.event_type = 89 event.event_type =
90 send_focus_event ? 90 send_focus_event ? ui::AX_EVENT_FOCUS : ui::AX_EVENT_LAYOUT_COMPLETE;
91 blink::WebAXEventFocus :
92 blink::WebAXEventLayoutComplete;
93 91
94 // Set the id that the event applies to: the root node if nothing 92 // Set the id that the event applies to: the root node if nothing
95 // has focus, otherwise the focused node. 93 // has focus, otherwise the focused node.
96 event.id = node_has_focus ? next_id_ : 1; 94 event.id = node_has_focus ? next_id_ : 1;
97 95
98 event.nodes.resize(2); 96 event.nodes.resize(2);
99 AccessibilityNodeData& root = event.nodes[0]; 97 ui::AXNodeData& root = event.nodes[0];
100 AccessibilityNodeData& child = event.nodes[1]; 98 ui::AXNodeData& child = event.nodes[1];
101 99
102 // 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.
103 root.id = 1; 101 root.id = 1;
104 root.role = blink::WebAXRoleRootWebArea; 102 root.role = ui::AX_ROLE_ROOT_WEB_AREA;
105 root.state = 103 root.state =
106 (1 << blink::WebAXStateReadonly) | 104 (1 << ui::AX_STATE_READONLY) |
107 (1 << blink::WebAXStateFocusable); 105 (1 << ui::AX_STATE_FOCUSABLE);
108 if (!node_has_focus) 106 if (!node_has_focus)
109 root.state |= (1 << blink::WebAXStateFocused); 107 root.state |= (1 << ui::AX_STATE_FOCUSED);
110 root.location = gfx::Rect(render_view_->size()); 108 root.location = gfx::Rect(render_view_->size());
111 root.child_ids.push_back(next_id_); 109 root.child_ids.push_back(next_id_);
112 110
113 child.id = next_id_; 111 child.id = next_id_;
114 child.role = blink::WebAXRoleGroup; 112 child.role = ui::AX_ROLE_GROUP;
115 113
116 if (!node.isNull() && node.isElementNode()) { 114 if (!node.isNull() && node.isElementNode()) {
117 child.location = gfx::Rect( 115 child.location = gfx::Rect(
118 const_cast<WebNode&>(node).to<WebElement>().boundsInViewportSpace()); 116 const_cast<WebNode&>(node).to<WebElement>().boundsInViewportSpace());
119 } else if (render_view_->HasIMETextFocus()) { 117 } else if (render_view_->HasIMETextFocus()) {
120 child.location = root.location; 118 child.location = root.location;
121 } else { 119 } else {
122 child.location = gfx::Rect(); 120 child.location = gfx::Rect();
123 } 121 }
124 122
125 if (node_has_focus) { 123 if (node_has_focus) {
126 child.state = 124 child.state =
127 (1 << blink::WebAXStateFocusable) | 125 (1 << ui::AX_STATE_FOCUSABLE) |
128 (1 << blink::WebAXStateFocused); 126 (1 << ui::AX_STATE_FOCUSED);
129 if (!node_is_editable_text) 127 if (!node_is_editable_text)
130 child.state |= (1 << blink::WebAXStateReadonly); 128 child.state |= (1 << ui::AX_STATE_READONLY);
131 } 129 }
132 130
133 #ifndef NDEBUG 131 #ifndef NDEBUG
132 /**
134 if (logging_) { 133 if (logging_) {
135 VLOG(0) << "Accessibility update: \n" 134 VLOG(0) << "Accessibility update: \n"
136 << "routing id=" << routing_id() 135 << "routing id=" << routing_id()
137 << " event=" 136 << " event="
138 << AccessibilityEventToString(event.event_type) 137 << AccessibilityEventToString(event.event_type)
139 << "\n" << event.nodes[0].DebugString(true); 138 << "\n" << event.nodes[0].DebugString(true);
140 } 139 }
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
OLDNEW
« no previous file with comments | « content/renderer/accessibility/renderer_accessibility_complete.cc ('k') | content/test/accessibility_browser_test_utils.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698