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

Unified Diff: content/browser/accessibility/browser_accessibility.cc

Issue 215633003: Improve accessible hit testing heuristic. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 9 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/browser/accessibility/browser_accessibility.cc
diff --git a/content/browser/accessibility/browser_accessibility.cc b/content/browser/accessibility/browser_accessibility.cc
index ff57121c89d66d7f00d43e9b0edb3f5b23bad9e9..6c4d9afdb686f0868ca575b9864bf1554bdd2822 100644
--- a/content/browser/accessibility/browser_accessibility.cc
+++ b/content/browser/accessibility/browser_accessibility.cc
@@ -316,6 +316,12 @@ BrowserAccessibility* BrowserAccessibility::BrowserAccessibilityForPoint(
const gfx::Point& point) {
// 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.
// most tightly encloses the specified point.
+
+ // The best result found that's a child of this object.
+ BrowserAccessibility* child_result = NULL;
+ // The best result that's an indirect descendant like grandchild, etc.
+ BrowserAccessibility* descendant_result = NULL;
+
for (int i = static_cast<int>(PlatformChildCount()) - 1; i >= 0; --i) {
BrowserAccessibility* child = PlatformGetChild(i);
@@ -324,9 +330,20 @@ BrowserAccessibility* BrowserAccessibility::BrowserAccessibilityForPoint(
if (child->role() == ui::AX_ROLE_COLUMN)
continue;
- if (child->GetGlobalBoundsRect().Contains(point))
- return child->BrowserAccessibilityForPoint(point);
+ if (child->GetGlobalBoundsRect().Contains(point)) {
+ BrowserAccessibility* result = child->BrowserAccessibilityForPoint(point);
+ if (result == child && !child_result)
+ child_result = result;
+ 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
+ descendant_result = result;
+ }
}
+
+ if (descendant_result)
+ return descendant_result;
+ if (child_result)
+ return child_result;
+
return this;
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698