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

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

Issue 2217363002: Use relative bounding boxes throughout Chrome accessibility (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address feedback from aboxhall Created 4 years, 4 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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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_android.h" 5 #include "content/browser/accessibility/browser_accessibility_android.h"
6 6
7 #include "base/i18n/break_iterator.h" 7 #include "base/i18n/break_iterator.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/stringprintf.h" 10 #include "base/strings/stringprintf.h"
(...skipping 954 matching lines...) Expand 10 before | Expand all | Expand 10 after
965 if (GetRole() == ui::AX_ROLE_ROOT_WEB_AREA && !GetParent()) { 965 if (GetRole() == ui::AX_ROLE_ROOT_WEB_AREA && !GetParent()) {
966 // If this is the root web area, use the bounds of the view to determine 966 // If this is the root web area, use the bounds of the view to determine
967 // how big one page is. 967 // how big one page is.
968 if (!manager()->delegate()) 968 if (!manager()->delegate())
969 return false; 969 return false;
970 bounds = manager()->delegate()->AccessibilityGetViewBounds(); 970 bounds = manager()->delegate()->AccessibilityGetViewBounds();
971 } else if (GetRole() == ui::AX_ROLE_ROOT_WEB_AREA && GetParent()) { 971 } else if (GetRole() == ui::AX_ROLE_ROOT_WEB_AREA && GetParent()) {
972 // If this is a web area inside of an iframe, try to use the bounds of 972 // If this is a web area inside of an iframe, try to use the bounds of
973 // the containing element. 973 // the containing element.
974 BrowserAccessibility* parent = GetParent(); 974 BrowserAccessibility* parent = GetParent();
975 while (parent && (parent->GetLocation().width() == 0 || 975 while (parent && (parent->GetPageBoundsRect().width() == 0 ||
976 parent->GetLocation().height() == 0)) { 976 parent->GetPageBoundsRect().height() == 0)) {
977 parent = parent->GetParent(); 977 parent = parent->GetParent();
978 } 978 }
979 if (parent) 979 if (parent)
980 bounds = parent->GetLocation(); 980 bounds = parent->GetPageBoundsRect();
981 else 981 else
982 bounds = GetLocation(); 982 bounds = GetPageBoundsRect();
983 } else { 983 } else {
984 // Otherwise this is something like a scrollable div, just use the 984 // Otherwise this is something like a scrollable div, just use the
985 // bounds of this object itself. 985 // bounds of this object itself.
986 bounds = GetLocation(); 986 bounds = GetPageBoundsRect();
987 } 987 }
988 988
989 // Scroll by 80% of one page. 989 // Scroll by 80% of one page.
990 int page_x = std::max(bounds.width() * 4 / 5, 1); 990 int page_x = std::max(bounds.width() * 4 / 5, 1);
991 int page_y = std::max(bounds.height() * 4 / 5, 1); 991 int page_y = std::max(bounds.height() * 4 / 5, 1);
992 992
993 if (direction == FORWARD) 993 if (direction == FORWARD)
994 direction = y_max > y_min ? DOWN : RIGHT; 994 direction = y_max > y_min ? DOWN : RIGHT;
995 if (direction == BACKWARD) 995 if (direction == BACKWARD)
996 direction = y_max > y_min ? UP : LEFT; 996 direction = y_max > y_min ? UP : LEFT;
(...skipping 245 matching lines...) Expand 10 before | Expand all | Expand 10 after
1242 // If this is a static text node, get the line boundaries from the 1242 // If this is a static text node, get the line boundaries from the
1243 // inline text boxes if possible. 1243 // inline text boxes if possible.
1244 if (GetRole() == ui::AX_ROLE_STATIC_TEXT) { 1244 if (GetRole() == ui::AX_ROLE_STATIC_TEXT) {
1245 int last_y = 0; 1245 int last_y = 0;
1246 for (uint32_t i = 0; i < InternalChildCount(); i++) { 1246 for (uint32_t i = 0; i < InternalChildCount(); i++) {
1247 BrowserAccessibilityAndroid* child = 1247 BrowserAccessibilityAndroid* child =
1248 static_cast<BrowserAccessibilityAndroid*>(InternalGetChild(i)); 1248 static_cast<BrowserAccessibilityAndroid*>(InternalGetChild(i));
1249 CHECK_EQ(ui::AX_ROLE_INLINE_TEXT_BOX, child->GetRole()); 1249 CHECK_EQ(ui::AX_ROLE_INLINE_TEXT_BOX, child->GetRole());
1250 // TODO(dmazzoni): replace this with a proper API to determine 1250 // TODO(dmazzoni): replace this with a proper API to determine
1251 // if two inline text boxes are on the same line. http://crbug.com/421771 1251 // if two inline text boxes are on the same line. http://crbug.com/421771
1252 int y = child->GetLocation().y(); 1252 int y = child->GetPageBoundsRect().y();
1253 if (i == 0) { 1253 if (i == 0) {
1254 line_starts->push_back(offset); 1254 line_starts->push_back(offset);
1255 } else if (y != last_y) { 1255 } else if (y != last_y) {
1256 line_ends->push_back(offset); 1256 line_ends->push_back(offset);
1257 line_starts->push_back(offset); 1257 line_starts->push_back(offset);
1258 } 1258 }
1259 offset += child->GetText().size(); 1259 offset += child->GetText().size();
1260 last_y = y; 1260 last_y = y;
1261 } 1261 }
1262 line_ends->push_back(offset); 1262 line_ends->push_back(offset);
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after
1412 int BrowserAccessibilityAndroid::CountChildrenWithRole(ui::AXRole role) const { 1412 int BrowserAccessibilityAndroid::CountChildrenWithRole(ui::AXRole role) const {
1413 int count = 0; 1413 int count = 0;
1414 for (uint32_t i = 0; i < PlatformChildCount(); i++) { 1414 for (uint32_t i = 0; i < PlatformChildCount(); i++) {
1415 if (PlatformGetChild(i)->GetRole() == role) 1415 if (PlatformGetChild(i)->GetRole() == role)
1416 count++; 1416 count++;
1417 } 1417 }
1418 return count; 1418 return count;
1419 } 1419 }
1420 1420
1421 } // namespace content 1421 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698