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 "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" |
(...skipping 25 matching lines...) Expand all Loading... |
36 index_in_parent_(0), | 36 index_in_parent_(0), |
37 renderer_id_(0), | 37 renderer_id_(0), |
38 role_(0), | 38 role_(0), |
39 state_(0), | 39 state_(0), |
40 instance_active_(false) { | 40 instance_active_(false) { |
41 } | 41 } |
42 | 42 |
43 BrowserAccessibility::~BrowserAccessibility() { | 43 BrowserAccessibility::~BrowserAccessibility() { |
44 } | 44 } |
45 | 45 |
| 46 bool BrowserAccessibility::PlatformIsLeaf() const { |
| 47 return role_ == WebKit::WebAXRoleStaticText || child_count() == 0; |
| 48 } |
| 49 |
| 50 uint32 BrowserAccessibility::PlatformChildCount() const { |
| 51 return PlatformIsLeaf() ? 0 : children_.size(); |
| 52 } |
| 53 |
46 void BrowserAccessibility::DetachTree( | 54 void BrowserAccessibility::DetachTree( |
47 std::vector<BrowserAccessibility*>* nodes) { | 55 std::vector<BrowserAccessibility*>* nodes) { |
48 nodes->push_back(this); | 56 nodes->push_back(this); |
49 for (size_t i = 0; i < children_.size(); i++) | 57 for (size_t i = 0; i < children_.size(); i++) |
50 children_[i]->DetachTree(nodes); | 58 children_[i]->DetachTree(nodes); |
51 children_.clear(); | 59 children_.clear(); |
52 parent_ = NULL; | 60 parent_ = NULL; |
53 } | 61 } |
54 | 62 |
55 void BrowserAccessibility::InitializeTreeStructure( | 63 void BrowserAccessibility::InitializeTreeStructure( |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
105 BrowserAccessibility* ancestor) { | 113 BrowserAccessibility* ancestor) { |
106 if (this == ancestor) { | 114 if (this == ancestor) { |
107 return true; | 115 return true; |
108 } else if (parent_) { | 116 } else if (parent_) { |
109 return parent_->IsDescendantOf(ancestor); | 117 return parent_->IsDescendantOf(ancestor); |
110 } | 118 } |
111 | 119 |
112 return false; | 120 return false; |
113 } | 121 } |
114 | 122 |
115 BrowserAccessibility* BrowserAccessibility::GetChild(uint32 child_index) const { | 123 BrowserAccessibility* BrowserAccessibility::PlatformGetChild( |
| 124 uint32 child_index) const { |
116 DCHECK(child_index < children_.size()); | 125 DCHECK(child_index < children_.size()); |
117 return children_[child_index]; | 126 return children_[child_index]; |
118 } | 127 } |
119 | 128 |
120 BrowserAccessibility* BrowserAccessibility::GetPreviousSibling() { | 129 BrowserAccessibility* BrowserAccessibility::GetPreviousSibling() { |
121 if (parent_ && index_in_parent_ > 0) | 130 if (parent_ && index_in_parent_ > 0) |
122 return parent_->children_[index_in_parent_ - 1]; | 131 return parent_->children_[index_in_parent_ - 1]; |
123 | 132 |
124 return NULL; | 133 return NULL; |
125 } | 134 } |
(...skipping 355 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
481 return name_; | 490 return name_; |
482 } | 491 } |
483 | 492 |
484 std::string result; | 493 std::string result; |
485 for (size_t i = 0; i < children_.size(); ++i) | 494 for (size_t i = 0; i < children_.size(); ++i) |
486 result += children_[i]->GetTextRecursive(); | 495 result += children_[i]->GetTextRecursive(); |
487 return result; | 496 return result; |
488 } | 497 } |
489 | 498 |
490 } // namespace content | 499 } // namespace content |
OLD | NEW |