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

Side by Side Diff: content/browser/accessibility/browser_accessibility.cc

Issue 799633007: Make Windows accessibility event firing aware of guest / child frames. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@webview_fixes
Patch Set: Address more feedback Created 5 years, 11 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 "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 166 matching lines...) Expand 10 before | Expand all | Expand 10 after
177 BrowserAccessibility::GetHtmlAttributes() const { 177 BrowserAccessibility::GetHtmlAttributes() const {
178 return GetData().html_attributes; 178 return GetData().html_attributes;
179 } 179 }
180 180
181 gfx::Rect BrowserAccessibility::GetLocalBoundsRect() const { 181 gfx::Rect BrowserAccessibility::GetLocalBoundsRect() const {
182 gfx::Rect bounds = GetLocation(); 182 gfx::Rect bounds = GetLocation();
183 183
184 // Walk up the parent chain. Every time we encounter a Web Area, offset 184 // Walk up the parent chain. Every time we encounter a Web Area, offset
185 // based on the scroll bars and then offset based on the origin of that 185 // based on the scroll bars and then offset based on the origin of that
186 // nested web area. 186 // nested web area.
187 BrowserAccessibility* parent = GetParent(); 187 BrowserAccessibility* parent = GetParentForBoundsCalculation();
188 bool need_to_offset_web_area = 188 bool need_to_offset_web_area =
189 (GetRole() == ui::AX_ROLE_WEB_AREA || 189 (GetRole() == ui::AX_ROLE_WEB_AREA ||
190 GetRole() == ui::AX_ROLE_ROOT_WEB_AREA); 190 GetRole() == ui::AX_ROLE_ROOT_WEB_AREA);
191 while (parent) { 191 while (parent) {
192 if (need_to_offset_web_area && 192 if (need_to_offset_web_area &&
193 parent->GetLocation().width() > 0 && 193 parent->GetLocation().width() > 0 &&
194 parent->GetLocation().height() > 0) { 194 parent->GetLocation().height() > 0) {
195 bounds.Offset(parent->GetLocation().x(), parent->GetLocation().y()); 195 bounds.Offset(parent->GetLocation().x(), parent->GetLocation().y());
196 need_to_offset_web_area = false; 196 need_to_offset_web_area = false;
197 } 197 }
198 198
199 // On some platforms, we don't want to take the root scroll offsets 199 // On some platforms, we don't want to take the root scroll offsets
200 // into account. 200 // into account.
201 if (parent->GetRole() == ui::AX_ROLE_ROOT_WEB_AREA && 201 if (parent->GetRole() == ui::AX_ROLE_ROOT_WEB_AREA &&
202 !manager()->UseRootScrollOffsetsWhenComputingBounds()) { 202 !manager()->UseRootScrollOffsetsWhenComputingBounds()) {
203 break; 203 break;
204 } 204 }
205 205
206 if (parent->GetRole() == ui::AX_ROLE_WEB_AREA || 206 if (parent->GetRole() == ui::AX_ROLE_WEB_AREA ||
207 parent->GetRole() == ui::AX_ROLE_ROOT_WEB_AREA) { 207 parent->GetRole() == ui::AX_ROLE_ROOT_WEB_AREA) {
208 int sx = 0; 208 int sx = 0;
209 int sy = 0; 209 int sy = 0;
210 if (parent->GetIntAttribute(ui::AX_ATTR_SCROLL_X, &sx) && 210 if (parent->GetIntAttribute(ui::AX_ATTR_SCROLL_X, &sx) &&
211 parent->GetIntAttribute(ui::AX_ATTR_SCROLL_Y, &sy)) { 211 parent->GetIntAttribute(ui::AX_ATTR_SCROLL_Y, &sy)) {
212 bounds.Offset(-sx, -sy); 212 bounds.Offset(-sx, -sy);
213 } 213 }
214 need_to_offset_web_area = true; 214 need_to_offset_web_area = true;
215 } 215 }
216 parent = parent->GetParent(); 216 parent = parent->GetParentForBoundsCalculation();
217 } 217 }
218 218
219 return bounds; 219 return bounds;
220 } 220 }
221 221
222 gfx::Rect BrowserAccessibility::GetGlobalBoundsRect() const { 222 gfx::Rect BrowserAccessibility::GetGlobalBoundsRect() const {
223 gfx::Rect bounds = GetLocalBoundsRect(); 223 gfx::Rect bounds = GetLocalBoundsRect();
224 224
225 // Adjust the bounds by the top left corner of the containing view's bounds 225 // Adjust the bounds by the top left corner of the containing view's bounds
226 // in screen coordinates. 226 // in screen coordinates.
(...skipping 489 matching lines...) Expand 10 before | Expand all | Expand 10 after
716 int BrowserAccessibility::GetStaticTextLenRecursive() const { 716 int BrowserAccessibility::GetStaticTextLenRecursive() const {
717 if (GetRole() == ui::AX_ROLE_STATIC_TEXT) 717 if (GetRole() == ui::AX_ROLE_STATIC_TEXT)
718 return static_cast<int>(GetStringAttribute(ui::AX_ATTR_VALUE).size()); 718 return static_cast<int>(GetStringAttribute(ui::AX_ATTR_VALUE).size());
719 719
720 int len = 0; 720 int len = 0;
721 for (size_t i = 0; i < InternalChildCount(); ++i) 721 for (size_t i = 0; i < InternalChildCount(); ++i)
722 len += InternalGetChild(i)->GetStaticTextLenRecursive(); 722 len += InternalGetChild(i)->GetStaticTextLenRecursive();
723 return len; 723 return len;
724 } 724 }
725 725
726 BrowserAccessibility* BrowserAccessibility::GetParentForBoundsCalculation()
727 const {
728 if (!node_ || !manager_)
729 return NULL;
730 ui::AXNode* parent = node_->parent();
731 if (parent)
732 return manager_->GetFromAXNode(parent);
733
734 if (!manager_->delegate())
735 return NULL;
736
737 BrowserAccessibility* host_node =
738 manager_->delegate()->AccessibilityGetParentFrame();
739 if (!host_node)
740 return NULL;
741
742 return host_node;
743 }
744
726 } // namespace content 745 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698