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

Side by Side 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 unified diff | Download patch
OLDNEW
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 <algorithm> 7 #include <algorithm>
8 8
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/strings/string_number_conversions.h" 10 #include "base/strings/string_number_conversions.h"
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after
181 return GetData().state; 181 return GetData().state;
182 } 182 }
183 183
184 const BrowserAccessibility::HtmlAttributes& 184 const BrowserAccessibility::HtmlAttributes&
185 BrowserAccessibility::GetHtmlAttributes() const { 185 BrowserAccessibility::GetHtmlAttributes() const {
186 return GetData().html_attributes; 186 return GetData().html_attributes;
187 } 187 }
188 188
189 gfx::Rect BrowserAccessibility::GetLocalBoundsRect() const { 189 gfx::Rect BrowserAccessibility::GetLocalBoundsRect() const {
190 gfx::Rect bounds = GetLocation(); 190 gfx::Rect bounds = GetLocation();
191 FixEmptyBounds(&bounds);
191 return ElementBoundsToLocalBounds(bounds); 192 return ElementBoundsToLocalBounds(bounds);
192 } 193 }
193 194
194 gfx::Rect BrowserAccessibility::GetGlobalBoundsRect() const { 195 gfx::Rect BrowserAccessibility::GetGlobalBoundsRect() const {
195 gfx::Rect bounds = GetLocalBoundsRect(); 196 gfx::Rect bounds = GetLocalBoundsRect();
196 197
197 // Adjust the bounds by the top left corner of the containing view's bounds 198 // Adjust the bounds by the top left corner of the containing view's bounds
198 // in screen coordinates. 199 // in screen coordinates.
199 bounds.Offset(manager_->GetViewBounds().OffsetFromOrigin()); 200 bounds.Offset(manager_->GetViewBounds().OffsetFromOrigin());
200 201
(...skipping 487 matching lines...) Expand 10 before | Expand all | Expand 10 after
688 ui::AXNode* parent = node_->parent(); 689 ui::AXNode* parent = node_->parent();
689 if (parent) 690 if (parent)
690 return manager_->GetFromAXNode(parent); 691 return manager_->GetFromAXNode(parent);
691 692
692 if (!manager_->delegate()) 693 if (!manager_->delegate())
693 return NULL; 694 return NULL;
694 695
695 return manager_->delegate()->AccessibilityGetParentFrame(); 696 return manager_->delegate()->AccessibilityGetParentFrame();
696 } 697 }
697 698
699 void BrowserAccessibility::FixEmptyBounds(gfx::Rect* bounds) const
700 {
701 if (bounds->width() > 0 && bounds->height() > 0)
702 return;
703
704 for (size_t i = 0; i < InternalChildCount(); ++i) {
705 // Compute the bounds of each child - this calls FixEmptyBounds
706 // recursively if necessary.
707 BrowserAccessibility* child = InternalGetChild(i);
708 gfx::Rect child_bounds = child->GetLocalBoundsRect();
709
710 // Ignore children that don't have valid bounds themselves.
711 if (child_bounds.width() == 0 || child_bounds.height() == 0)
712 continue;
713
714 // For the first valid child, just set the bounds to that child's bounds.
715 if (bounds->width() == 0 || bounds->height() == 0) {
716 *bounds = child_bounds;
717 continue;
718 }
719
720 // Union each additional child's bounds.
721 bounds->Union(child_bounds);
722 }
723 }
724
698 gfx::Rect BrowserAccessibility::ElementBoundsToLocalBounds(gfx::Rect bounds) 725 gfx::Rect BrowserAccessibility::ElementBoundsToLocalBounds(gfx::Rect bounds)
699 const { 726 const {
700 // Walk up the parent chain. Every time we encounter a Web Area, offset 727 // Walk up the parent chain. Every time we encounter a Web Area, offset
701 // based on the scroll bars and then offset based on the origin of that 728 // based on the scroll bars and then offset based on the origin of that
702 // nested web area. 729 // nested web area.
703 BrowserAccessibility* parent = GetParentForBoundsCalculation(); 730 BrowserAccessibility* parent = GetParentForBoundsCalculation();
704 bool need_to_offset_web_area = 731 bool need_to_offset_web_area =
705 (GetRole() == ui::AX_ROLE_WEB_AREA || 732 (GetRole() == ui::AX_ROLE_WEB_AREA ||
706 GetRole() == ui::AX_ROLE_ROOT_WEB_AREA); 733 GetRole() == ui::AX_ROLE_ROOT_WEB_AREA);
707 while (parent) { 734 while (parent) {
(...skipping 21 matching lines...) Expand all
729 } 756 }
730 need_to_offset_web_area = true; 757 need_to_offset_web_area = true;
731 } 758 }
732 parent = parent->GetParentForBoundsCalculation(); 759 parent = parent->GetParentForBoundsCalculation();
733 } 760 }
734 761
735 return bounds; 762 return bounds;
736 } 763 }
737 764
738 } // namespace content 765 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698