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

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

Issue 1155993003: Fix accessibility with out-of-process iframes. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fixing unittests Created 5 years, 5 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.h" 5 #include "content/browser/accessibility/browser_accessibility.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/strings/string_number_conversions.h" 10 #include "base/strings/string_number_conversions.h"
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
53 case ui::AX_ROLE_SLIDER: 53 case ui::AX_ROLE_SLIDER:
54 case ui::AX_ROLE_STATIC_TEXT: 54 case ui::AX_ROLE_STATIC_TEXT:
55 case ui::AX_ROLE_TEXT_FIELD: 55 case ui::AX_ROLE_TEXT_FIELD:
56 return true; 56 return true;
57 default: 57 default:
58 return false; 58 return false;
59 } 59 }
60 } 60 }
61 61
62 uint32 BrowserAccessibility::PlatformChildCount() const { 62 uint32 BrowserAccessibility::PlatformChildCount() const {
63 if (GetBoolAttribute(ui::AX_ATTR_IS_AX_TREE_HOST)) {
64 // Check if the child frame currently exists.
65 if (manager_->delegate()->AccessibilityGetChildFrame(GetId()))
66 return 1;
67
68 return 0;
69 }
70
63 return PlatformIsLeaf() ? 0 : InternalChildCount(); 71 return PlatformIsLeaf() ? 0 : InternalChildCount();
64 } 72 }
65 73
66 bool BrowserAccessibility::IsNative() const { 74 bool BrowserAccessibility::IsNative() const {
67 return false; 75 return false;
68 } 76 }
69 77
70 bool BrowserAccessibility::IsDescendantOf( 78 bool BrowserAccessibility::IsDescendantOf(
71 BrowserAccessibility* ancestor) { 79 BrowserAccessibility* ancestor) {
72 if (this == ancestor) { 80 if (this == ancestor) {
73 return true; 81 return true;
74 } else if (GetParent()) { 82 } else if (GetParent()) {
75 return GetParent()->IsDescendantOf(ancestor); 83 return GetParent()->IsDescendantOf(ancestor);
76 } 84 }
77 85
78 return false; 86 return false;
79 } 87 }
80 88
81 BrowserAccessibility* BrowserAccessibility::PlatformGetChild( 89 BrowserAccessibility* BrowserAccessibility::PlatformGetChild(
82 uint32 child_index) const { 90 uint32 child_index) const {
83 DCHECK(child_index < InternalChildCount()); 91 DCHECK(child_index < PlatformChildCount());
84 BrowserAccessibility* result = InternalGetChild(child_index); 92 BrowserAccessibility* result = nullptr;
85 93
86 if (result->HasBoolAttribute(ui::AX_ATTR_IS_AX_TREE_HOST)) { 94 if (GetBoolAttribute(ui::AX_ATTR_IS_AX_TREE_HOST)) {
87 BrowserAccessibilityManager* child_manager = 95 BrowserAccessibilityManager* child_manager =
88 manager_->delegate()->AccessibilityGetChildFrame(result->GetId()); 96 manager_->delegate()->AccessibilityGetChildFrame(GetId());
89 if (child_manager) 97 if (child_manager)
90 result = child_manager->GetRoot(); 98 result = child_manager->GetRoot();
99 } else {
100 result = InternalGetChild(child_index);
91 } 101 }
92 102
93 return result; 103 return result;
94 } 104 }
95 105
96 bool BrowserAccessibility::PlatformIsChildOfLeaf() const { 106 bool BrowserAccessibility::PlatformIsChildOfLeaf() const {
97 BrowserAccessibility* ancestor = GetParent(); 107 BrowserAccessibility* ancestor = GetParent();
98 while (ancestor) { 108 while (ancestor) {
99 if (ancestor->PlatformIsLeaf()) 109 if (ancestor->PlatformIsLeaf())
100 return true; 110 return true;
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
143 return manager_->GetFromAXNode(parent); 153 return manager_->GetFromAXNode(parent);
144 154
145 if (!manager_->delegate()) 155 if (!manager_->delegate())
146 return NULL; 156 return NULL;
147 157
148 BrowserAccessibility* host_node = 158 BrowserAccessibility* host_node =
149 manager_->delegate()->AccessibilityGetParentFrame(); 159 manager_->delegate()->AccessibilityGetParentFrame();
150 if (!host_node) 160 if (!host_node)
151 return NULL; 161 return NULL;
152 162
153 return host_node->GetParent(); 163 return host_node;
154 } 164 }
155 165
156 int32 BrowserAccessibility::GetIndexInParent() const { 166 int32 BrowserAccessibility::GetIndexInParent() const {
157 return node_ ? node_->index_in_parent() : -1; 167 return node_ ? node_->index_in_parent() : -1;
158 } 168 }
159 169
160 int32 BrowserAccessibility::GetId() const { 170 int32 BrowserAccessibility::GetId() const {
161 return node_ ? node_->id() : -1; 171 return node_ ? node_->id() : -1;
162 } 172 }
163 173
(...skipping 592 matching lines...) Expand 10 before | Expand all | Expand 10 after
756 } 766 }
757 need_to_offset_web_area = true; 767 need_to_offset_web_area = true;
758 } 768 }
759 parent = parent->GetParentForBoundsCalculation(); 769 parent = parent->GetParentForBoundsCalculation();
760 } 770 }
761 771
762 return bounds; 772 return bounds;
763 } 773 }
764 774
765 } // namespace content 775 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698