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 "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 296 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 307 | 307 |
| 308 // Adjust the bounds by the top left corner of the containing view's bounds | 308 // Adjust the bounds by the top left corner of the containing view's bounds |
| 309 // in screen coordinates. | 309 // in screen coordinates. |
| 310 bounds.Offset(manager_->GetViewBounds().OffsetFromOrigin()); | 310 bounds.Offset(manager_->GetViewBounds().OffsetFromOrigin()); |
| 311 | 311 |
| 312 return bounds; | 312 return bounds; |
| 313 } | 313 } |
| 314 | 314 |
| 315 BrowserAccessibility* BrowserAccessibility::BrowserAccessibilityForPoint( | 315 BrowserAccessibility* BrowserAccessibility::BrowserAccessibilityForPoint( |
| 316 const gfx::Point& point) { | 316 const gfx::Point& point) { |
| 317 // Walk the children recursively looking for the BrowserAccessibility that | 317 // Walk the children recursively looking for the BrowserAccessibility that |
|
aboxhall
2014/03/27 23:28:27
Suggest moving this comment above the for loop.
dmazzoni
2014/03/28 05:34:15
Done.
| |
| 318 // most tightly encloses the specified point. | 318 // most tightly encloses the specified point. |
| 319 | |
| 320 // The best result found that's a child of this object. | |
| 321 BrowserAccessibility* child_result = NULL; | |
| 322 // The best result that's an indirect descendant like grandchild, etc. | |
| 323 BrowserAccessibility* descendant_result = NULL; | |
| 324 | |
| 319 for (int i = static_cast<int>(PlatformChildCount()) - 1; i >= 0; --i) { | 325 for (int i = static_cast<int>(PlatformChildCount()) - 1; i >= 0; --i) { |
| 320 BrowserAccessibility* child = PlatformGetChild(i); | 326 BrowserAccessibility* child = PlatformGetChild(i); |
| 321 | 327 |
| 322 // Skip table columns because cells are only contained in rows, | 328 // Skip table columns because cells are only contained in rows, |
| 323 // not columns. | 329 // not columns. |
| 324 if (child->role() == ui::AX_ROLE_COLUMN) | 330 if (child->role() == ui::AX_ROLE_COLUMN) |
| 325 continue; | 331 continue; |
| 326 | 332 |
| 327 if (child->GetGlobalBoundsRect().Contains(point)) | 333 if (child->GetGlobalBoundsRect().Contains(point)) { |
| 328 return child->BrowserAccessibilityForPoint(point); | 334 BrowserAccessibility* result = child->BrowserAccessibilityForPoint(point); |
| 335 if (result == child && !child_result) | |
| 336 child_result = result; | |
| 337 if (result != child && !descendant_result) | |
|
aboxhall
2014/03/27 23:28:27
I thought you mentioned the descendant being a con
dmazzoni
2014/03/28 05:34:15
I used that as an example, but I don't think that
aboxhall
2014/03/28 16:13:32
Ok. We should probably add a comment here explaini
| |
| 338 descendant_result = result; | |
| 339 } | |
| 329 } | 340 } |
| 341 | |
| 342 if (descendant_result) | |
| 343 return descendant_result; | |
| 344 if (child_result) | |
| 345 return child_result; | |
| 346 | |
| 330 return this; | 347 return this; |
| 331 } | 348 } |
| 332 | 349 |
| 333 void BrowserAccessibility::Destroy() { | 350 void BrowserAccessibility::Destroy() { |
| 334 for (std::vector<BrowserAccessibility*>::iterator iter = children_.begin(); | 351 for (std::vector<BrowserAccessibility*>::iterator iter = children_.begin(); |
| 335 iter != children_.end(); | 352 iter != children_.end(); |
| 336 ++iter) { | 353 ++iter) { |
| 337 (*iter)->Destroy(); | 354 (*iter)->Destroy(); |
| 338 } | 355 } |
| 339 children_.clear(); | 356 children_.clear(); |
| (...skipping 289 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 629 if (role_ == ui::AX_ROLE_STATIC_TEXT) | 646 if (role_ == ui::AX_ROLE_STATIC_TEXT) |
| 630 return static_cast<int>(GetStringAttribute(ui::AX_ATTR_VALUE).size()); | 647 return static_cast<int>(GetStringAttribute(ui::AX_ATTR_VALUE).size()); |
| 631 | 648 |
| 632 int len = 0; | 649 int len = 0; |
| 633 for (size_t i = 0; i < children_.size(); ++i) | 650 for (size_t i = 0; i < children_.size(); ++i) |
| 634 len += children_[i]->GetStaticTextLenRecursive(); | 651 len += children_[i]->GetStaticTextLenRecursive(); |
| 635 return len; | 652 return len; |
| 636 } | 653 } |
| 637 | 654 |
| 638 } // namespace content | 655 } // namespace content |
| OLD | NEW |