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

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

Issue 2430473003: Revert of Create AXAction and AXActionData as a way to simplify accessibility actions (Closed)
Patch Set: Created 4 years, 2 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
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 <stddef.h> 7 #include <stddef.h>
8 8
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "build/build_config.h" 10 #include "build/build_config.h"
(...skipping 441 matching lines...) Expand 10 before | Expand all | Expand 10 after
452 BrowserAccessibility* obj = GetFromID(hit_obj_id); 452 BrowserAccessibility* obj = GetFromID(hit_obj_id);
453 if (!obj || !obj->HasIntAttribute(ui::AX_ATTR_CHILD_TREE_ID)) 453 if (!obj || !obj->HasIntAttribute(ui::AX_ATTR_CHILD_TREE_ID))
454 return; 454 return;
455 455
456 BrowserAccessibilityManager* child_manager = 456 BrowserAccessibilityManager* child_manager =
457 BrowserAccessibilityManager::FromID( 457 BrowserAccessibilityManager::FromID(
458 obj->GetIntAttribute(ui::AX_ATTR_CHILD_TREE_ID)); 458 obj->GetIntAttribute(ui::AX_ATTR_CHILD_TREE_ID));
459 if (!child_manager || !child_manager->delegate()) 459 if (!child_manager || !child_manager->delegate())
460 return; 460 return;
461 461
462 ui::AXActionData action_data; 462 return child_manager->delegate()->AccessibilityHitTest(point);
463 action_data.target_point = point;
464 action_data.action = ui::AX_ACTION_HIT_TEST;
465 return child_manager->delegate()->AccessibilityPerformAction(action_data);
466 } 463 }
467 464
468 void BrowserAccessibilityManager::ActivateFindInPageResult( 465 void BrowserAccessibilityManager::ActivateFindInPageResult(
469 int request_id) { 466 int request_id) {
470 find_in_page_info_.active_request_id = request_id; 467 find_in_page_info_.active_request_id = request_id;
471 if (find_in_page_info_.request_id != request_id) 468 if (find_in_page_info_.request_id != request_id)
472 return; 469 return;
473 470
474 BrowserAccessibility* node = GetFromID(find_in_page_info_.start_id); 471 BrowserAccessibility* node = GetFromID(find_in_page_info_.start_id);
475 if (!node) 472 if (!node)
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
553 BrowserAccessibilityManager::FromID( 550 BrowserAccessibilityManager::FromID(
554 obj->GetIntAttribute(ui::AX_ATTR_CHILD_TREE_ID)); 551 obj->GetIntAttribute(ui::AX_ATTR_CHILD_TREE_ID));
555 if (child_manager) 552 if (child_manager)
556 return child_manager->GetFocusFromThisOrDescendantFrame(); 553 return child_manager->GetFocusFromThisOrDescendantFrame();
557 } 554 }
558 555
559 return obj; 556 return obj;
560 } 557 }
561 558
562 void BrowserAccessibilityManager::SetFocus(const BrowserAccessibility& node) { 559 void BrowserAccessibilityManager::SetFocus(const BrowserAccessibility& node) {
563 if (!delegate_) 560 if (delegate_)
564 return; 561 delegate_->AccessibilitySetFocus(node.GetId());
565
566 ui::AXActionData action_data;
567 action_data.action = ui::AX_ACTION_SET_FOCUS;
568 action_data.target_node_id = node.GetId();
569 delegate_->AccessibilityPerformAction(action_data);
570 } 562 }
571 563
572 void BrowserAccessibilityManager::SetFocusLocallyForTesting( 564 void BrowserAccessibilityManager::SetFocusLocallyForTesting(
573 BrowserAccessibility* node) { 565 BrowserAccessibility* node) {
574 ui::AXTreeData data = GetTreeData(); 566 ui::AXTreeData data = GetTreeData();
575 data.focus_id = node->GetId(); 567 data.focus_id = node->GetId();
576 tree_->UpdateData(data); 568 tree_->UpdateData(data);
577 } 569 }
578 570
579 // static 571 // static
580 void BrowserAccessibilityManager::SetFocusChangeCallbackForTesting( 572 void BrowserAccessibilityManager::SetFocusChangeCallbackForTesting(
581 const base::Closure& callback) { 573 const base::Closure& callback) {
582 g_focus_change_callback_for_testing.Get() = callback; 574 g_focus_change_callback_for_testing.Get() = callback;
583 } 575 }
584 576
585 void BrowserAccessibilityManager::DoDefaultAction( 577 void BrowserAccessibilityManager::DoDefaultAction(
586 const BrowserAccessibility& node) { 578 const BrowserAccessibility& node) {
587 if (!delegate_) 579 if (delegate_)
588 return; 580 delegate_->AccessibilityDoDefaultAction(node.GetId());
589
590 ui::AXActionData action_data;
591 action_data.action = ui::AX_ACTION_DO_DEFAULT;
592 action_data.target_node_id = node.GetId();
593 delegate_->AccessibilityPerformAction(action_data);
594 }
595
596 void BrowserAccessibilityManager::ShowContextMenu(
597 const BrowserAccessibility& node) {
598 if (!delegate_)
599 return;
600
601 ui::AXActionData action_data;
602 action_data.action = ui::AX_ACTION_SHOW_CONTEXT_MENU;
603 action_data.target_node_id = node.GetId();
604 delegate_->AccessibilityPerformAction(action_data);
605 } 581 }
606 582
607 void BrowserAccessibilityManager::ScrollToMakeVisible( 583 void BrowserAccessibilityManager::ScrollToMakeVisible(
608 const BrowserAccessibility& node, gfx::Rect subfocus) { 584 const BrowserAccessibility& node, gfx::Rect subfocus) {
609 if (!delegate_) 585 if (delegate_) {
610 return; 586 delegate_->AccessibilityScrollToMakeVisible(node.GetId(), subfocus);
611 587 }
612 ui::AXActionData action_data;
613 action_data.target_node_id = node.GetId();
614 action_data.action = ui::AX_ACTION_SCROLL_TO_MAKE_VISIBLE;
615 action_data.target_rect = subfocus;
616 delegate_->AccessibilityPerformAction(action_data);
617 } 588 }
618 589
619 void BrowserAccessibilityManager::ScrollToPoint( 590 void BrowserAccessibilityManager::ScrollToPoint(
620 const BrowserAccessibility& node, gfx::Point point) { 591 const BrowserAccessibility& node, gfx::Point point) {
621 if (!delegate_) 592 if (delegate_) {
622 return; 593 delegate_->AccessibilityScrollToPoint(node.GetId(), point);
623 594 }
624 ui::AXActionData action_data;
625 action_data.target_node_id = node.GetId();
626 action_data.action = ui::AX_ACTION_SCROLL_TO_POINT;
627 action_data.target_point = point;
628 delegate_->AccessibilityPerformAction(action_data);
629 } 595 }
630 596
631 void BrowserAccessibilityManager::SetScrollOffset( 597 void BrowserAccessibilityManager::SetScrollOffset(
632 const BrowserAccessibility& node, gfx::Point offset) { 598 const BrowserAccessibility& node, gfx::Point offset) {
633 if (!delegate_) 599 if (delegate_) {
634 return; 600 delegate_->AccessibilitySetScrollOffset(node.GetId(), offset);
635 601 }
636 ui::AXActionData action_data;
637 action_data.target_node_id = node.GetId();
638 action_data.action = ui::AX_ACTION_SET_SCROLL_OFFSET;
639 action_data.target_point = offset;
640 delegate_->AccessibilityPerformAction(action_data);
641 } 602 }
642 603
643 void BrowserAccessibilityManager::SetValue( 604 void BrowserAccessibilityManager::SetValue(
644 const BrowserAccessibility& node, 605 const BrowserAccessibility& node,
645 const base::string16& value) { 606 const base::string16& value) {
646 if (!delegate_) 607 if (delegate_)
647 return; 608 delegate_->AccessibilitySetValue(node.GetId(), value);
648
649 ui::AXActionData action_data;
650 action_data.target_node_id = node.GetId();
651 action_data.action = ui::AX_ACTION_SET_VALUE;
652 action_data.value = value;
653 delegate_->AccessibilityPerformAction(action_data);
654 } 609 }
655 610
656 void BrowserAccessibilityManager::SetTextSelection( 611 void BrowserAccessibilityManager::SetTextSelection(
657 const BrowserAccessibility& node, 612 const BrowserAccessibility& node,
658 int start_offset, 613 int start_offset,
659 int end_offset) { 614 int end_offset) {
660 if (!delegate_) 615 if (delegate_) {
661 return; 616 delegate_->AccessibilitySetSelection(node.GetId(), start_offset,
662 617 node.GetId(), end_offset);
663 ui::AXActionData action_data; 618 }
664 action_data.anchor_node_id = node.GetId();
665 action_data.anchor_offset = start_offset;
666 action_data.focus_node_id = node.GetId();
667 action_data.focus_offset = end_offset;
668 action_data.action = ui::AX_ACTION_SET_SELECTION;
669 delegate_->AccessibilityPerformAction(action_data);
670 }
671
672 void BrowserAccessibilityManager::SetAccessibilityFocus(
673 const BrowserAccessibility& node) {
674 if (!delegate_)
675 return;
676
677 ui::AXActionData action_data;
678 action_data.action = ui::AX_ACTION_SET_ACCESSIBILITY_FOCUS;
679 action_data.target_node_id = node.GetId();
680 delegate_->AccessibilityPerformAction(action_data);
681 }
682
683 void BrowserAccessibilityManager::HitTest(const gfx::Point& point) {
684 if (!delegate_)
685 return;
686
687 ui::AXActionData action_data;
688 action_data.action = ui::AX_ACTION_HIT_TEST;
689 action_data.target_point = point;
690 delegate_->AccessibilityPerformAction(action_data);
691 } 619 }
692 620
693 gfx::Rect BrowserAccessibilityManager::GetViewBounds() { 621 gfx::Rect BrowserAccessibilityManager::GetViewBounds() {
694 BrowserAccessibilityDelegate* delegate = GetDelegateFromRootManager(); 622 BrowserAccessibilityDelegate* delegate = GetDelegateFromRootManager();
695 if (delegate) 623 if (delegate)
696 return delegate->AccessibilityGetViewBounds(); 624 return delegate->AccessibilityGetViewBounds();
697 return gfx::Rect(); 625 return gfx::Rect();
698 } 626 }
699 627
700 // static 628 // static
(...skipping 466 matching lines...) Expand 10 before | Expand all | Expand 10 after
1167 1095
1168 BrowserAccessibility* BrowserAccessibilityManager::CachingAsyncHitTest( 1096 BrowserAccessibility* BrowserAccessibilityManager::CachingAsyncHitTest(
1169 const gfx::Point& screen_point) { 1097 const gfx::Point& screen_point) {
1170 BrowserAccessibilityManager* root_manager = GetRootManager(); 1098 BrowserAccessibilityManager* root_manager = GetRootManager();
1171 if (root_manager && root_manager != this) 1099 if (root_manager && root_manager != this)
1172 return root_manager->CachingAsyncHitTest(screen_point); 1100 return root_manager->CachingAsyncHitTest(screen_point);
1173 1101
1174 if (delegate()) { 1102 if (delegate()) {
1175 // This triggers an asynchronous request to compute the true object that's 1103 // This triggers an asynchronous request to compute the true object that's
1176 // under |screen_point|. 1104 // under |screen_point|.
1177 HitTest(screen_point - GetViewBounds().OffsetFromOrigin()); 1105 gfx::Point local_point = screen_point - GetViewBounds().OffsetFromOrigin();
1106 delegate()->AccessibilityHitTest(local_point);
1178 1107
1179 // Unfortunately we still have to return an answer synchronously because 1108 // Unfortunately we still have to return an answer synchronously because
1180 // the APIs were designed that way. The best case scenario is that the 1109 // the APIs were designed that way. The best case scenario is that the
1181 // screen point is within the bounds of the last result we got from a 1110 // screen point is within the bounds of the last result we got from a
1182 // call to AccessibilityHitTest - in that case, we can return that object! 1111 // call to AccessibilityHitTest - in that case, we can return that object!
1183 if (last_hover_bounds_.Contains(screen_point)) { 1112 if (last_hover_bounds_.Contains(screen_point)) {
1184 BrowserAccessibilityManager* manager = 1113 BrowserAccessibilityManager* manager =
1185 BrowserAccessibilityManager::FromID(last_hover_ax_tree_id_); 1114 BrowserAccessibilityManager::FromID(last_hover_ax_tree_id_);
1186 if (manager) { 1115 if (manager) {
1187 BrowserAccessibility* node = manager->GetFromID(last_hover_node_id_); 1116 BrowserAccessibility* node = manager->GetFromID(last_hover_node_id_);
(...skipping 22 matching lines...) Expand all
1210 hit_test_result = parent; 1139 hit_test_result = parent;
1211 parent = parent->GetParent(); 1140 parent = parent->GetParent();
1212 } 1141 }
1213 1142
1214 last_hover_ax_tree_id_ = hit_test_result->manager()->ax_tree_id(); 1143 last_hover_ax_tree_id_ = hit_test_result->manager()->ax_tree_id();
1215 last_hover_node_id_ = hit_test_result->GetId(); 1144 last_hover_node_id_ = hit_test_result->GetId();
1216 last_hover_bounds_ = hit_test_result->GetScreenBoundsRect(); 1145 last_hover_bounds_ = hit_test_result->GetScreenBoundsRect();
1217 } 1146 }
1218 1147
1219 } // namespace content 1148 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698