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/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 #include "ui/accessibility/ax_tree_serializer.h" | 10 #include "ui/accessibility/ax_tree_serializer.h" |
(...skipping 272 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
283 BrowserAccessibility* active_descendant = | 283 BrowserAccessibility* active_descendant = |
284 node->manager()->GetFromID(active_descendant_id); | 284 node->manager()->GetFromID(active_descendant_id); |
285 if (active_descendant) | 285 if (active_descendant) |
286 return active_descendant; | 286 return active_descendant; |
287 } | 287 } |
288 return node; | 288 return node; |
289 } | 289 } |
290 | 290 |
291 BrowserAccessibility* BrowserAccessibilityManager::GetFocus( | 291 BrowserAccessibility* BrowserAccessibilityManager::GetFocus( |
292 BrowserAccessibility* root) { | 292 BrowserAccessibility* root) { |
293 if (focus_ && (!root || focus_->IsDescendantOf(root->node()))) | 293 if (!focus_) |
294 return GetFromAXNode(focus_); | 294 return NULL; |
295 | 295 |
296 return NULL; | 296 if (root && !focus_->IsDescendantOf(root->node())) |
| 297 return NULL; |
| 298 |
| 299 if (!delegate()) |
| 300 return NULL; |
| 301 |
| 302 BrowserAccessibility* obj = GetFromAXNode(focus_); |
| 303 if (obj->HasBoolAttribute(ui::AX_ATTR_IS_AX_TREE_HOST)) { |
| 304 BrowserAccessibilityManager* child_manager = |
| 305 delegate()->AccessibilityGetChildFrame(obj->GetId()); |
| 306 if (child_manager) |
| 307 return child_manager->GetFocus(child_manager->GetRoot()); |
| 308 } |
| 309 |
| 310 return obj; |
297 } | 311 } |
298 | 312 |
299 void BrowserAccessibilityManager::SetFocus(ui::AXNode* node, bool notify) { | 313 void BrowserAccessibilityManager::SetFocus(ui::AXNode* node, bool notify) { |
300 if (focus_ != node) | 314 if (focus_ != node) |
301 focus_ = node; | 315 focus_ = node; |
302 | 316 |
303 if (notify && node && delegate_) | 317 if (notify && node && delegate_) |
304 delegate_->AccessibilitySetFocus(node->id()); | 318 delegate_->AccessibilitySetFocus(node->id()); |
305 } | 319 } |
306 | 320 |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
341 const BrowserAccessibility& node, | 355 const BrowserAccessibility& node, |
342 int start_offset, | 356 int start_offset, |
343 int end_offset) { | 357 int end_offset) { |
344 if (delegate_) { | 358 if (delegate_) { |
345 delegate_->AccessibilitySetTextSelection( | 359 delegate_->AccessibilitySetTextSelection( |
346 node.GetId(), start_offset, end_offset); | 360 node.GetId(), start_offset, end_offset); |
347 } | 361 } |
348 } | 362 } |
349 | 363 |
350 gfx::Rect BrowserAccessibilityManager::GetViewBounds() { | 364 gfx::Rect BrowserAccessibilityManager::GetViewBounds() { |
351 if (delegate_) | 365 BrowserAccessibilityDelegate* delegate = GetDelegateFromRootManager(); |
352 return delegate_->AccessibilityGetViewBounds(); | 366 if (delegate) |
| 367 return delegate->AccessibilityGetViewBounds(); |
353 return gfx::Rect(); | 368 return gfx::Rect(); |
354 } | 369 } |
355 | 370 |
356 BrowserAccessibility* BrowserAccessibilityManager::NextInTreeOrder( | 371 BrowserAccessibility* BrowserAccessibilityManager::NextInTreeOrder( |
357 BrowserAccessibility* node) { | 372 BrowserAccessibility* node) { |
358 if (!node) | 373 if (!node) |
359 return NULL; | 374 return NULL; |
360 | 375 |
361 if (node->PlatformChildCount() > 0) | 376 if (node->PlatformChildCount() > 0) |
362 return node->PlatformGetChild(0); | 377 return node->PlatformGetChild(0); |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
412 } | 427 } |
413 | 428 |
414 void BrowserAccessibilityManager::OnNodeCreationFinished(ui::AXNode* node) { | 429 void BrowserAccessibilityManager::OnNodeCreationFinished(ui::AXNode* node) { |
415 GetFromAXNode(node)->OnUpdateFinished(); | 430 GetFromAXNode(node)->OnUpdateFinished(); |
416 } | 431 } |
417 | 432 |
418 void BrowserAccessibilityManager::OnNodeChangeFinished(ui::AXNode* node) { | 433 void BrowserAccessibilityManager::OnNodeChangeFinished(ui::AXNode* node) { |
419 GetFromAXNode(node)->OnUpdateFinished(); | 434 GetFromAXNode(node)->OnUpdateFinished(); |
420 } | 435 } |
421 | 436 |
| 437 BrowserAccessibilityDelegate* |
| 438 BrowserAccessibilityManager::GetDelegateFromRootManager() { |
| 439 BrowserAccessibilityManager* manager = this; |
| 440 while (manager->GetRoot()->GetParent()) |
| 441 manager = manager->GetRoot()->GetParent()->manager(); |
| 442 return manager->delegate(); |
| 443 } |
| 444 |
422 ui::AXTreeUpdate BrowserAccessibilityManager::SnapshotAXTreeForTesting() { | 445 ui::AXTreeUpdate BrowserAccessibilityManager::SnapshotAXTreeForTesting() { |
423 scoped_ptr<ui::AXTreeSource<const ui::AXNode*> > tree_source( | 446 scoped_ptr<ui::AXTreeSource<const ui::AXNode*> > tree_source( |
424 tree_->CreateTreeSource()); | 447 tree_->CreateTreeSource()); |
425 ui::AXTreeSerializer<const ui::AXNode*> serializer(tree_source.get()); | 448 ui::AXTreeSerializer<const ui::AXNode*> serializer(tree_source.get()); |
426 ui::AXTreeUpdate update; | 449 ui::AXTreeUpdate update; |
427 serializer.SerializeChanges(tree_->GetRoot(), &update); | 450 serializer.SerializeChanges(tree_->GetRoot(), &update); |
428 return update; | 451 return update; |
429 } | 452 } |
430 | 453 |
431 } // namespace content | 454 } // namespace content |
OLD | NEW |