Chromium Code Reviews| 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.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 Loading... | |
| 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 (HasBoolAttribute(ui::AX_ATTR_IS_AX_TREE_HOST)) | |
|
dmazzoni
2015/06/25 22:15:38
Not due to your change, but let's change this to G
lfg
2015/06/25 22:48:24
Done. I also changed the DCHECK below to call this
| |
| 64 return 1; | |
| 65 | |
| 63 return PlatformIsLeaf() ? 0 : InternalChildCount(); | 66 return PlatformIsLeaf() ? 0 : InternalChildCount(); |
| 64 } | 67 } |
| 65 | 68 |
| 66 bool BrowserAccessibility::IsNative() const { | 69 bool BrowserAccessibility::IsNative() const { |
| 67 return false; | 70 return false; |
| 68 } | 71 } |
| 69 | 72 |
| 70 bool BrowserAccessibility::IsDescendantOf( | 73 bool BrowserAccessibility::IsDescendantOf( |
| 71 BrowserAccessibility* ancestor) { | 74 BrowserAccessibility* ancestor) { |
| 72 if (this == ancestor) { | 75 if (this == ancestor) { |
| 73 return true; | 76 return true; |
| 74 } else if (GetParent()) { | 77 } else if (GetParent()) { |
| 75 return GetParent()->IsDescendantOf(ancestor); | 78 return GetParent()->IsDescendantOf(ancestor); |
| 76 } | 79 } |
| 77 | 80 |
| 78 return false; | 81 return false; |
| 79 } | 82 } |
| 80 | 83 |
| 81 BrowserAccessibility* BrowserAccessibility::PlatformGetChild( | 84 BrowserAccessibility* BrowserAccessibility::PlatformGetChild( |
| 82 uint32 child_index) const { | 85 uint32 child_index) const { |
| 83 DCHECK(child_index < InternalChildCount()); | 86 DCHECK((child_index == 0 && HasBoolAttribute(ui::AX_ATTR_IS_AX_TREE_HOST)) || |
| 84 BrowserAccessibility* result = InternalGetChild(child_index); | 87 child_index < InternalChildCount()); |
| 88 BrowserAccessibility* result = nullptr; | |
| 85 | 89 |
| 86 if (result->HasBoolAttribute(ui::AX_ATTR_IS_AX_TREE_HOST)) { | 90 if (HasBoolAttribute(ui::AX_ATTR_IS_AX_TREE_HOST)) { |
| 87 BrowserAccessibilityManager* child_manager = | 91 BrowserAccessibilityManager* child_manager = |
| 88 manager_->delegate()->AccessibilityGetChildFrame(result->GetId()); | 92 manager_->delegate()->AccessibilityGetChildFrame(GetId()); |
| 89 if (child_manager) | 93 if (child_manager) |
| 90 result = child_manager->GetRoot(); | 94 result = child_manager->GetRoot(); |
| 95 } else { | |
| 96 result = InternalGetChild(child_index); | |
| 91 } | 97 } |
| 92 | 98 |
| 93 return result; | 99 return result; |
| 94 } | 100 } |
| 95 | 101 |
| 96 bool BrowserAccessibility::PlatformIsChildOfLeaf() const { | 102 bool BrowserAccessibility::PlatformIsChildOfLeaf() const { |
| 97 BrowserAccessibility* ancestor = GetParent(); | 103 BrowserAccessibility* ancestor = GetParent(); |
| 98 while (ancestor) { | 104 while (ancestor) { |
| 99 if (ancestor->PlatformIsLeaf()) | 105 if (ancestor->PlatformIsLeaf()) |
| 100 return true; | 106 return true; |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 143 return manager_->GetFromAXNode(parent); | 149 return manager_->GetFromAXNode(parent); |
| 144 | 150 |
| 145 if (!manager_->delegate()) | 151 if (!manager_->delegate()) |
| 146 return NULL; | 152 return NULL; |
| 147 | 153 |
| 148 BrowserAccessibility* host_node = | 154 BrowserAccessibility* host_node = |
| 149 manager_->delegate()->AccessibilityGetParentFrame(); | 155 manager_->delegate()->AccessibilityGetParentFrame(); |
| 150 if (!host_node) | 156 if (!host_node) |
| 151 return NULL; | 157 return NULL; |
| 152 | 158 |
| 153 return host_node->GetParent(); | 159 return host_node; |
| 154 } | 160 } |
| 155 | 161 |
| 156 int32 BrowserAccessibility::GetIndexInParent() const { | 162 int32 BrowserAccessibility::GetIndexInParent() const { |
| 157 return node_ ? node_->index_in_parent() : -1; | 163 return node_ ? node_->index_in_parent() : -1; |
| 158 } | 164 } |
| 159 | 165 |
| 160 int32 BrowserAccessibility::GetId() const { | 166 int32 BrowserAccessibility::GetId() const { |
| 161 return node_ ? node_->id() : -1; | 167 return node_ ? node_->id() : -1; |
| 162 } | 168 } |
| 163 | 169 |
| (...skipping 592 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 756 } | 762 } |
| 757 need_to_offset_web_area = true; | 763 need_to_offset_web_area = true; |
| 758 } | 764 } |
| 759 parent = parent->GetParentForBoundsCalculation(); | 765 parent = parent->GetParentForBoundsCalculation(); |
| 760 } | 766 } |
| 761 | 767 |
| 762 return bounds; | 768 return bounds; |
| 763 } | 769 } |
| 764 | 770 |
| 765 } // namespace content | 771 } // namespace content |
| OLD | NEW |