OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/string_number_conversions.h" | 8 #include "base/string_number_conversions.h" |
9 #include "base/string_util.h" | 9 #include "base/string_util.h" |
10 #include "content/browser/accessibility/browser_accessibility_manager.h" | 10 #include "content/browser/accessibility/browser_accessibility_manager.h" |
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
119 BrowserAccessibility* BrowserAccessibility::GetNextSibling() { | 119 BrowserAccessibility* BrowserAccessibility::GetNextSibling() { |
120 if (parent_ && | 120 if (parent_ && |
121 index_in_parent_ >= 0 && | 121 index_in_parent_ >= 0 && |
122 index_in_parent_ < static_cast<int>(parent_->children_.size() - 1)) { | 122 index_in_parent_ < static_cast<int>(parent_->children_.size() - 1)) { |
123 return parent_->children_[index_in_parent_ + 1]; | 123 return parent_->children_[index_in_parent_ + 1]; |
124 } | 124 } |
125 | 125 |
126 return NULL; | 126 return NULL; |
127 } | 127 } |
128 | 128 |
129 gfx::Rect BrowserAccessibility::GetBoundsRect() { | 129 gfx::Rect BrowserAccessibility::GetLocalBoundsRect() { |
130 gfx::Rect bounds = location_; | 130 gfx::Rect bounds = location_; |
131 | 131 |
132 // Adjust the bounds by the top left corner of the containing view's bounds | |
133 // in screen coordinates. | |
134 gfx::Point top_left = manager_->GetViewBounds().origin(); | |
135 bounds.Offset(top_left); | |
136 | |
137 // Adjust top left position by the root document's scroll offset. | 132 // Adjust top left position by the root document's scroll offset. |
138 BrowserAccessibility* root = manager_->GetRoot(); | 133 BrowserAccessibility* root = manager_->GetRoot(); |
139 int scroll_x = 0; | 134 int scroll_x = 0; |
140 int scroll_y = 0; | 135 int scroll_y = 0; |
141 root->GetIntAttribute(WebAccessibility::ATTR_DOC_SCROLLX, &scroll_x); | 136 root->GetIntAttribute(WebAccessibility::ATTR_DOC_SCROLLX, &scroll_x); |
142 root->GetIntAttribute(WebAccessibility::ATTR_DOC_SCROLLY, &scroll_y); | 137 root->GetIntAttribute(WebAccessibility::ATTR_DOC_SCROLLY, &scroll_y); |
143 bounds.Offset(-scroll_x, -scroll_y); | 138 bounds.Offset(-scroll_x, -scroll_y); |
144 | 139 |
145 return bounds; | 140 return bounds; |
146 } | 141 } |
147 | 142 |
| 143 gfx::Rect BrowserAccessibility::GetGlobalBoundsRect() { |
| 144 gfx::Rect bounds = GetLocalBoundsRect(); |
| 145 |
| 146 // Adjust the bounds by the top left corner of the containing view's bounds |
| 147 // in screen coordinates. |
| 148 gfx::Point top_left = manager_->GetViewBounds().origin(); |
| 149 bounds.Offset(top_left); |
| 150 |
| 151 return bounds; |
| 152 } |
| 153 |
148 BrowserAccessibility* BrowserAccessibility::BrowserAccessibilityForPoint( | 154 BrowserAccessibility* BrowserAccessibility::BrowserAccessibilityForPoint( |
149 const gfx::Point& point) { | 155 const gfx::Point& point) { |
150 // Walk the children recursively looking for the BrowserAccessibility that | 156 // Walk the children recursively looking for the BrowserAccessibility that |
151 // most tightly encloses the specified point. | 157 // most tightly encloses the specified point. |
152 for (int i = children_.size() - 1; i >= 0; --i) { | 158 for (int i = children_.size() - 1; i >= 0; --i) { |
153 BrowserAccessibility* child = children_[i]; | 159 BrowserAccessibility* child = children_[i]; |
154 if (child->GetBoundsRect().Contains(point)) | 160 if (child->GetGlobalBoundsRect().Contains(point)) |
155 return child->BrowserAccessibilityForPoint(point); | 161 return child->BrowserAccessibilityForPoint(point); |
156 } | 162 } |
157 return this; | 163 return this; |
158 } | 164 } |
159 | 165 |
160 void BrowserAccessibility::InternalAddReference() { | 166 void BrowserAccessibility::InternalAddReference() { |
161 ref_count_++; | 167 ref_count_++; |
162 } | 168 } |
163 | 169 |
164 void BrowserAccessibility::InternalReleaseReference(bool recursive) { | 170 void BrowserAccessibility::InternalReleaseReference(bool recursive) { |
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
260 if (!name_.empty()) { | 266 if (!name_.empty()) { |
261 return name_; | 267 return name_; |
262 } | 268 } |
263 | 269 |
264 string16 result; | 270 string16 result; |
265 for (size_t i = 0; i < children_.size(); ++i) | 271 for (size_t i = 0; i < children_.size(); ++i) |
266 result += children_[i]->GetTextRecursive(); | 272 result += children_[i]->GetTextRecursive(); |
267 return result; | 273 return result; |
268 } | 274 } |
269 | 275 |
OLD | NEW |