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

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

Issue 1198203002: Fix accessibility objects with zero width and height. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@aria-owns-test
Patch Set: Clarify, don't assume child bounds are nonempty too Created 5 years, 6 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
Index: content/browser/accessibility/browser_accessibility.cc
diff --git a/content/browser/accessibility/browser_accessibility.cc b/content/browser/accessibility/browser_accessibility.cc
index b50a47662f01504097641479285641aa058f995c..9d4fe101afc599be1f15caf17a87cdfc0a74103b 100644
--- a/content/browser/accessibility/browser_accessibility.cc
+++ b/content/browser/accessibility/browser_accessibility.cc
@@ -188,6 +188,7 @@ BrowserAccessibility::GetHtmlAttributes() const {
gfx::Rect BrowserAccessibility::GetLocalBoundsRect() const {
gfx::Rect bounds = GetLocation();
+ FixEmptyBounds(&bounds);
return ElementBoundsToLocalBounds(bounds);
}
@@ -695,6 +696,32 @@ BrowserAccessibility* BrowserAccessibility::GetParentForBoundsCalculation()
return manager_->delegate()->AccessibilityGetParentFrame();
}
+void BrowserAccessibility::FixEmptyBounds(gfx::Rect* bounds) const
+{
+ if (bounds->width() > 0 && bounds->height() > 0)
+ return;
+
+ for (size_t i = 0; i < InternalChildCount(); ++i) {
+ // Compute the bounds of each child - this calls FixEmptyBounds
+ // recursively if necessary.
+ BrowserAccessibility* child = InternalGetChild(i);
+ gfx::Rect child_bounds = child->GetLocalBoundsRect();
+
+ // Ignore children that don't have valid bounds themselves.
+ if (child_bounds.width() == 0 || child_bounds.height() == 0)
+ continue;
+
+ // For the first valid child, just set the bounds to that child's bounds.
+ if (bounds->width() == 0 || bounds->height() == 0) {
+ *bounds = child_bounds;
+ continue;
+ }
+
+ // Union each additional child's bounds.
+ bounds->Union(child_bounds);
+ }
+}
+
gfx::Rect BrowserAccessibility::ElementBoundsToLocalBounds(gfx::Rect bounds)
const {
// Walk up the parent chain. Every time we encounter a Web Area, offset

Powered by Google App Engine
This is Rietveld 408576698