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

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

Issue 268543008: Cross-process iframe accessibility. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Address feedback Created 6 years, 3 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.h" 5 #include "content/browser/accessibility/browser_accessibility.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "base/strings/string_number_conversions.h" 8 #include "base/strings/string_number_conversions.h"
9 #include "base/strings/string_util.h" 9 #include "base/strings/string_util.h"
10 #include "base/strings/utf_string_conversions.h" 10 #include "base/strings/utf_string_conversions.h"
11 #include "content/browser/accessibility/browser_accessibility_manager.h" 11 #include "content/browser/accessibility/browser_accessibility_manager.h"
12 #include "content/common/accessibility_messages.h" 12 #include "content/common/accessibility_messages.h"
13 13
14 namespace content { 14 namespace content {
15 15
16 #if !defined(OS_MACOSX) && \ 16 #if !defined(OS_MACOSX) && \
17 !defined(OS_WIN) && \ 17 !defined(OS_WIN) && \
18 !defined(OS_ANDROID) 18 !defined(OS_ANDROID)
19 // We have subclassess of BrowserAccessibility on Mac and Win. For any other 19 // We have subclassess of BrowserAccessibility on Mac and Win. For any other
20 // platform, instantiate the base class. 20 // platform, instantiate the base class.
21 // static 21 // static
22 BrowserAccessibility* BrowserAccessibility::Create() { 22 BrowserAccessibility* BrowserAccessibility::Create() {
23 return new BrowserAccessibility(); 23 return new BrowserAccessibility();
24 } 24 }
25 #endif 25 #endif
26 26
27 BrowserAccessibility::BrowserAccessibility() 27 BrowserAccessibility::BrowserAccessibility()
28 : manager_(NULL), 28 : manager_(NULL),
29 node_(NULL) { 29 node_(NULL),
30 child_frame_tree_node_id_(0) {
30 } 31 }
31 32
32 BrowserAccessibility::~BrowserAccessibility() { 33 BrowserAccessibility::~BrowserAccessibility() {
33 } 34 }
34 35
35 void BrowserAccessibility::Init(BrowserAccessibilityManager* manager, 36 void BrowserAccessibility::Init(BrowserAccessibilityManager* manager,
36 ui::AXNode* node) { 37 ui::AXNode* node) {
37 manager_ = manager; 38 manager_ = manager;
38 node_ = node; 39 node_ = node;
39 } 40 }
(...skipping 16 matching lines...) Expand all
56 case ui::AX_ROLE_STATIC_TEXT: 57 case ui::AX_ROLE_STATIC_TEXT:
57 case ui::AX_ROLE_TEXT_AREA: 58 case ui::AX_ROLE_TEXT_AREA:
58 case ui::AX_ROLE_TEXT_FIELD: 59 case ui::AX_ROLE_TEXT_FIELD:
59 return true; 60 return true;
60 default: 61 default:
61 return false; 62 return false;
62 } 63 }
63 } 64 }
64 65
65 uint32 BrowserAccessibility::PlatformChildCount() const { 66 uint32 BrowserAccessibility::PlatformChildCount() const {
66 return PlatformIsLeaf() ? 0 : InternalChildCount(); 67 if (child_frame_tree_node_id_ == 0 ||
68 !manager_ || !manager_->delegate()) {
69 return PlatformIsLeaf() ? 0 : InternalChildCount();
70 }
71 BrowserAccessibilityManager* child_manager =
72 manager_->delegate()->AccessibilityGetChildFrame(
73 child_frame_tree_node_id_);
74 return child_manager ? 1 : 0;
67 } 75 }
68 76
69 bool BrowserAccessibility::IsNative() const { 77 bool BrowserAccessibility::IsNative() const {
70 return false; 78 return false;
71 } 79 }
72 80
73 bool BrowserAccessibility::IsDescendantOf( 81 bool BrowserAccessibility::IsDescendantOf(
74 BrowserAccessibility* ancestor) { 82 BrowserAccessibility* ancestor) {
75 if (this == ancestor) { 83 if (this == ancestor) {
76 return true; 84 return true;
77 } else if (GetParent()) { 85 } else if (GetParent()) {
78 return GetParent()->IsDescendantOf(ancestor); 86 return GetParent()->IsDescendantOf(ancestor);
79 } 87 }
80 88
81 return false; 89 return false;
82 } 90 }
83 91
84 BrowserAccessibility* BrowserAccessibility::PlatformGetChild( 92 BrowserAccessibility* BrowserAccessibility::PlatformGetChild(
85 uint32 child_index) const { 93 uint32 child_index) const {
94 if (child_index == 0 && child_frame_tree_node_id_ &&
95 manager_ &&
96 manager_->delegate()) {
97 BrowserAccessibilityManager* child_manager =
98 manager_->delegate()->AccessibilityGetChildFrame(
99 child_frame_tree_node_id_);
100 if (!child_manager)
101 return NULL;
102
103 return child_manager->GetRoot();
104 }
105
86 DCHECK(child_index < InternalChildCount()); 106 DCHECK(child_index < InternalChildCount());
87 return InternalGetChild(child_index); 107 return InternalGetChild(child_index);
88 } 108 }
89 109
90 BrowserAccessibility* BrowserAccessibility::GetPreviousSibling() { 110 BrowserAccessibility* BrowserAccessibility::GetPreviousSibling() {
91 if (GetParent() && GetIndexInParent() > 0) 111 if (GetParent() && GetIndexInParent() > 0)
92 return GetParent()->InternalGetChild(GetIndexInParent() - 1); 112 return GetParent()->InternalGetChild(GetIndexInParent() - 1);
93 113
94 return NULL; 114 return NULL;
95 } 115 }
(...skipping 19 matching lines...) Expand all
115 uint32 child_index) const { 135 uint32 child_index) const {
116 if (!node_ || !manager_) 136 if (!node_ || !manager_)
117 return NULL; 137 return NULL;
118 return manager_->GetFromAXNode(node_->children()[child_index]); 138 return manager_->GetFromAXNode(node_->children()[child_index]);
119 } 139 }
120 140
121 BrowserAccessibility* BrowserAccessibility::GetParent() const { 141 BrowserAccessibility* BrowserAccessibility::GetParent() const {
122 if (!node_ || !manager_) 142 if (!node_ || !manager_)
123 return NULL; 143 return NULL;
124 ui::AXNode* parent = node_->parent(); 144 ui::AXNode* parent = node_->parent();
125 return parent ? manager_->GetFromAXNode(parent) : NULL; 145 if (parent)
146 return manager_->GetFromAXNode(parent);
147 return manager_->GetCrossFrameParent();
126 } 148 }
127 149
128 int32 BrowserAccessibility::GetIndexInParent() const { 150 int32 BrowserAccessibility::GetIndexInParent() const {
129 return node_ ? node_->index_in_parent() : -1; 151 return node_ ? node_->index_in_parent() : -1;
130 } 152 }
131 153
132 int32 BrowserAccessibility::GetId() const { 154 int32 BrowserAccessibility::GetId() const {
133 return node_ ? node_->id() : -1; 155 return node_ ? node_->id() : -1;
134 } 156 }
135 157
(...skipping 537 matching lines...) Expand 10 before | Expand all | Expand 10 after
673 int BrowserAccessibility::GetStaticTextLenRecursive() const { 695 int BrowserAccessibility::GetStaticTextLenRecursive() const {
674 if (GetRole() == ui::AX_ROLE_STATIC_TEXT) 696 if (GetRole() == ui::AX_ROLE_STATIC_TEXT)
675 return static_cast<int>(GetStringAttribute(ui::AX_ATTR_VALUE).size()); 697 return static_cast<int>(GetStringAttribute(ui::AX_ATTR_VALUE).size());
676 698
677 int len = 0; 699 int len = 0;
678 for (size_t i = 0; i < InternalChildCount(); ++i) 700 for (size_t i = 0; i < InternalChildCount(); ++i)
679 len += InternalGetChild(i)->GetStaticTextLenRecursive(); 701 len += InternalGetChild(i)->GetStaticTextLenRecursive();
680 return len; 702 return len;
681 } 703 }
682 704
705 void BrowserAccessibility::SetChildFrameTreeNodeId(
706 int64 child_frame_tree_node_id) {
707 child_frame_tree_node_id_ = child_frame_tree_node_id;
708 manager_->NotifyAccessibilityEvent(ui::AX_EVENT_CHILDREN_CHANGED, this);
709 }
710
683 } // namespace content 711 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698