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

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: 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 BrowserAccessibility* child = InternalGetChild(i);
706 gfx::Rect child_bounds = child->GetLocalBoundsRect();
707 if (bounds->width() > 0 && bounds->height() > 0)
708 bounds->Union(child_bounds);
709 else
David Tseng 2015/06/22 21:29:36 I'm confused why you have this branch at all?
dmazzoni 2015/06/23 05:36:42 If the width and height are already nonzero the fu
David Tseng 2015/06/23 18:27:53 So, you're assuming child's height and width are n
dmazzoni 2015/06/23 23:37:11 OK, I made this more explicit and added a comment.
710 *bounds = child_bounds;
711 }
712 }
713
698 gfx::Rect BrowserAccessibility::ElementBoundsToLocalBounds(gfx::Rect bounds) 714 gfx::Rect BrowserAccessibility::ElementBoundsToLocalBounds(gfx::Rect bounds)
699 const { 715 const {
700 // Walk up the parent chain. Every time we encounter a Web Area, offset 716 // 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 717 // based on the scroll bars and then offset based on the origin of that
702 // nested web area. 718 // nested web area.
703 BrowserAccessibility* parent = GetParentForBoundsCalculation(); 719 BrowserAccessibility* parent = GetParentForBoundsCalculation();
704 bool need_to_offset_web_area = 720 bool need_to_offset_web_area =
705 (GetRole() == ui::AX_ROLE_WEB_AREA || 721 (GetRole() == ui::AX_ROLE_WEB_AREA ||
706 GetRole() == ui::AX_ROLE_ROOT_WEB_AREA); 722 GetRole() == ui::AX_ROLE_ROOT_WEB_AREA);
707 while (parent) { 723 while (parent) {
(...skipping 21 matching lines...) Expand all
729 } 745 }
730 need_to_offset_web_area = true; 746 need_to_offset_web_area = true;
731 } 747 }
732 parent = parent->GetParentForBoundsCalculation(); 748 parent = parent->GetParentForBoundsCalculation();
733 } 749 }
734 750
735 return bounds; 751 return bounds;
736 } 752 }
737 753
738 } // namespace content 754 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698