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

Side by Side Diff: content/browser/accessibility/browser_accessibility_manager.cc

Issue 246773008: RWHI should implement BrowserAccessibilityDelegate (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix Mac tests Created 6 years, 7 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/browser/accessibility/browser_accessibility_manager.h" 5 #include "content/browser/accessibility/browser_accessibility_manager.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "content/browser/accessibility/browser_accessibility.h" 8 #include "content/browser/accessibility/browser_accessibility.h"
9 #include "content/common/accessibility_messages.h" 9 #include "content/common/accessibility_messages.h"
10 10
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
88 88
89 BrowserAccessibilityManager::~BrowserAccessibilityManager() { 89 BrowserAccessibilityManager::~BrowserAccessibilityManager() {
90 tree_.reset(NULL); 90 tree_.reset(NULL);
91 } 91 }
92 92
93 void BrowserAccessibilityManager::Initialize( 93 void BrowserAccessibilityManager::Initialize(
94 const ui::AXTreeUpdate& initial_tree) { 94 const ui::AXTreeUpdate& initial_tree) {
95 if (!tree_->Unserialize(initial_tree)) { 95 if (!tree_->Unserialize(initial_tree)) {
96 if (delegate_) { 96 if (delegate_) {
97 LOG(ERROR) << tree_->error(); 97 LOG(ERROR) << tree_->error();
98 delegate_->FatalAccessibilityTreeError(); 98 delegate_->AccessibilityFatalError();
99 } else { 99 } else {
100 LOG(FATAL) << tree_->error(); 100 LOG(FATAL) << tree_->error();
101 } 101 }
102 } 102 }
103 103
104 if (!focus_) 104 if (!focus_)
105 SetFocus(tree_->GetRoot(), false); 105 SetFocus(tree_->GetRoot(), false);
106 } 106 }
107 107
108 // static 108 // static
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
140 void BrowserAccessibilityManager::OnWindowBlurred() { 140 void BrowserAccessibilityManager::OnWindowBlurred() {
141 if (focus_) 141 if (focus_)
142 NotifyAccessibilityEvent(ui::AX_EVENT_BLUR, GetFromAXNode(focus_)); 142 NotifyAccessibilityEvent(ui::AX_EVENT_BLUR, GetFromAXNode(focus_));
143 } 143 }
144 144
145 void BrowserAccessibilityManager::GotMouseDown() { 145 void BrowserAccessibilityManager::GotMouseDown() {
146 osk_state_ = OSK_ALLOWED_WITHIN_FOCUSED_OBJECT; 146 osk_state_ = OSK_ALLOWED_WITHIN_FOCUSED_OBJECT;
147 NotifyAccessibilityEvent(ui::AX_EVENT_FOCUS, GetFromAXNode(focus_)); 147 NotifyAccessibilityEvent(ui::AX_EVENT_FOCUS, GetFromAXNode(focus_));
148 } 148 }
149 149
150 bool BrowserAccessibilityManager::IsOSKAllowed(const gfx::Rect& bounds) {
151 if (!delegate_ || !delegate_->HasFocus())
152 return false;
153
154 gfx::Point touch_point = delegate_->GetLastTouchEventLocation();
155 return bounds.Contains(touch_point);
156 }
157
158 bool BrowserAccessibilityManager::UseRootScrollOffsetsWhenComputingBounds() { 150 bool BrowserAccessibilityManager::UseRootScrollOffsetsWhenComputingBounds() {
159 return true; 151 return true;
160 } 152 }
161 153
162 void BrowserAccessibilityManager::OnAccessibilityEvents( 154 void BrowserAccessibilityManager::OnAccessibilityEvents(
163 const std::vector<AccessibilityHostMsg_EventParams>& params) { 155 const std::vector<AccessibilityHostMsg_EventParams>& params) {
164 bool should_send_initial_focus = false; 156 bool should_send_initial_focus = false;
165 157
166 // Process all changes to the accessibility tree first. 158 // Process all changes to the accessibility tree first.
167 for (uint32 index = 0; index < params.size(); index++) { 159 for (uint32 index = 0; index < params.size(); index++) {
168 const AccessibilityHostMsg_EventParams& param = params[index]; 160 const AccessibilityHostMsg_EventParams& param = params[index];
169 if (!tree_->Unserialize(param.update)) { 161 if (!tree_->Unserialize(param.update)) {
170 if (delegate_) { 162 if (delegate_) {
171 LOG(ERROR) << tree_->error(); 163 LOG(ERROR) << tree_->error();
172 delegate_->FatalAccessibilityTreeError(); 164 delegate_->AccessibilityFatalError();
173 } else { 165 } else {
174 CHECK(false) << tree_->error(); 166 CHECK(false) << tree_->error();
175 } 167 }
176 return; 168 return;
177 } 169 }
178 170
179 // Set focus to the root if it's not anywhere else. 171 // Set focus to the root if it's not anywhere else.
180 if (!focus_) { 172 if (!focus_) {
181 SetFocus(tree_->GetRoot(), false); 173 SetFocus(tree_->GetRoot(), false);
182 should_send_initial_focus = true; 174 should_send_initial_focus = true;
183 } 175 }
184 } 176 }
185 177
186 if (should_send_initial_focus && 178 if (should_send_initial_focus &&
187 (!delegate_ || delegate_->HasFocus())) { 179 (!delegate_ || delegate_->AccessibilityViewHasFocus())) {
188 NotifyAccessibilityEvent(ui::AX_EVENT_FOCUS, GetFromAXNode(focus_)); 180 NotifyAccessibilityEvent(ui::AX_EVENT_FOCUS, GetFromAXNode(focus_));
189 } 181 }
190 182
191 // Now iterate over the events again and fire the events. 183 // Now iterate over the events again and fire the events.
192 for (uint32 index = 0; index < params.size(); index++) { 184 for (uint32 index = 0; index < params.size(); index++) {
193 const AccessibilityHostMsg_EventParams& param = params[index]; 185 const AccessibilityHostMsg_EventParams& param = params[index];
194 186
195 // Find the node corresponding to the id that's the target of the 187 // Find the node corresponding to the id that's the target of the
196 // event (which may not be the root of the update tree). 188 // event (which may not be the root of the update tree).
197 ui::AXNode* node = tree_->GetFromId(param.id); 189 ui::AXNode* node = tree_->GetFromId(param.id);
198 if (!node) 190 if (!node)
199 continue; 191 continue;
200 192
201 ui::AXEvent event_type = param.event_type; 193 ui::AXEvent event_type = param.event_type;
202 if (event_type == ui::AX_EVENT_FOCUS || 194 if (event_type == ui::AX_EVENT_FOCUS ||
203 event_type == ui::AX_EVENT_BLUR) { 195 event_type == ui::AX_EVENT_BLUR) {
204 SetFocus(node, false); 196 SetFocus(node, false);
205 197
206 if (osk_state_ != OSK_DISALLOWED_BECAUSE_TAB_HIDDEN && 198 if (osk_state_ != OSK_DISALLOWED_BECAUSE_TAB_HIDDEN &&
207 osk_state_ != OSK_DISALLOWED_BECAUSE_TAB_JUST_APPEARED) 199 osk_state_ != OSK_DISALLOWED_BECAUSE_TAB_JUST_APPEARED)
208 osk_state_ = OSK_ALLOWED; 200 osk_state_ = OSK_ALLOWED;
209 201
210 // Don't send a native focus event if the window itself doesn't 202 // Don't send a native focus event if the window itself doesn't
211 // have focus. 203 // have focus.
212 if (delegate_ && !delegate_->HasFocus()) 204 if (delegate_ && !delegate_->AccessibilityViewHasFocus())
213 continue; 205 continue;
214 } 206 }
215 207
216 // Send the event event to the operating system. 208 // Send the event event to the operating system.
217 NotifyAccessibilityEvent(event_type, GetFromAXNode(node)); 209 NotifyAccessibilityEvent(event_type, GetFromAXNode(node));
218 } 210 }
219 } 211 }
220 212
221 void BrowserAccessibilityManager::OnLocationChanges( 213 void BrowserAccessibilityManager::OnLocationChanges(
222 const std::vector<AccessibilityHostMsg_LocationChangeParams>& params) { 214 const std::vector<AccessibilityHostMsg_LocationChangeParams>& params) {
(...skipping 13 matching lines...) Expand all
236 return GetFromAXNode(focus_); 228 return GetFromAXNode(focus_);
237 229
238 return NULL; 230 return NULL;
239 } 231 }
240 232
241 void BrowserAccessibilityManager::SetFocus(ui::AXNode* node, bool notify) { 233 void BrowserAccessibilityManager::SetFocus(ui::AXNode* node, bool notify) {
242 if (focus_ != node) 234 if (focus_ != node)
243 focus_ = node; 235 focus_ = node;
244 236
245 if (notify && node && delegate_) 237 if (notify && node && delegate_)
246 delegate_->SetAccessibilityFocus(node->id()); 238 delegate_->AccessibilitySetFocus(node->id());
247 } 239 }
248 240
249 void BrowserAccessibilityManager::SetFocus( 241 void BrowserAccessibilityManager::SetFocus(
250 BrowserAccessibility* obj, bool notify) { 242 BrowserAccessibility* obj, bool notify) {
251 if (obj->node()) 243 if (obj->node())
252 SetFocus(obj->node(), notify); 244 SetFocus(obj->node(), notify);
253 } 245 }
254 246
255 void BrowserAccessibilityManager::DoDefaultAction( 247 void BrowserAccessibilityManager::DoDefaultAction(
256 const BrowserAccessibility& node) { 248 const BrowserAccessibility& node) {
(...skipping 18 matching lines...) Expand all
275 void BrowserAccessibilityManager::SetTextSelection( 267 void BrowserAccessibilityManager::SetTextSelection(
276 const BrowserAccessibility& node, int start_offset, int end_offset) { 268 const BrowserAccessibility& node, int start_offset, int end_offset) {
277 if (delegate_) { 269 if (delegate_) {
278 delegate_->AccessibilitySetTextSelection( 270 delegate_->AccessibilitySetTextSelection(
279 node.GetId(), start_offset, end_offset); 271 node.GetId(), start_offset, end_offset);
280 } 272 }
281 } 273 }
282 274
283 gfx::Rect BrowserAccessibilityManager::GetViewBounds() { 275 gfx::Rect BrowserAccessibilityManager::GetViewBounds() {
284 if (delegate_) 276 if (delegate_)
285 return delegate_->GetViewBounds(); 277 return delegate_->AccessibilityGetViewBounds();
286 return gfx::Rect(); 278 return gfx::Rect();
287 } 279 }
288 280
289 BrowserAccessibility* BrowserAccessibilityManager::NextInTreeOrder( 281 BrowserAccessibility* BrowserAccessibilityManager::NextInTreeOrder(
290 BrowserAccessibility* node) { 282 BrowserAccessibility* node) {
291 if (!node) 283 if (!node)
292 return NULL; 284 return NULL;
293 285
294 if (node->PlatformChildCount() > 0) 286 if (node->PlatformChildCount() > 0)
295 return node->PlatformGetChild(0); 287 return node->PlatformGetChild(0);
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
346 338
347 void BrowserAccessibilityManager::OnNodeCreationFinished(ui::AXNode* node) { 339 void BrowserAccessibilityManager::OnNodeCreationFinished(ui::AXNode* node) {
348 GetFromAXNode(node)->OnUpdateFinished(); 340 GetFromAXNode(node)->OnUpdateFinished();
349 } 341 }
350 342
351 void BrowserAccessibilityManager::OnNodeChangeFinished(ui::AXNode* node) { 343 void BrowserAccessibilityManager::OnNodeChangeFinished(ui::AXNode* node) {
352 GetFromAXNode(node)->OnUpdateFinished(); 344 GetFromAXNode(node)->OnUpdateFinished();
353 } 345 }
354 346
355 } // namespace content 347 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698