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

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

Issue 2833843005: Handling of different types of empty alt (Closed)
Patch Set: Temporary test fix until we figure out why returning null for name does not work Created 3 years, 7 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 464 matching lines...) Expand 10 before | Expand all | Expand 10 after
475 // This is called from PlatformIsLeaf, so don't call PlatformChildCount 475 // This is called from PlatformIsLeaf, so don't call PlatformChildCount
476 // from within this! 476 // from within this!
477 if (text.empty() && (HasOnlyTextChildren() || 477 if (text.empty() && (HasOnlyTextChildren() ||
478 (IsFocusable() && HasOnlyTextAndImageChildren()))) { 478 (IsFocusable() && HasOnlyTextAndImageChildren()))) {
479 for (uint32_t i = 0; i < InternalChildCount(); i++) { 479 for (uint32_t i = 0; i < InternalChildCount(); i++) {
480 BrowserAccessibility* child = InternalGetChild(i); 480 BrowserAccessibility* child = InternalGetChild(i);
481 text += static_cast<BrowserAccessibilityAndroid*>(child)->GetText(); 481 text += static_cast<BrowserAccessibilityAndroid*>(child)->GetText();
482 } 482 }
483 } 483 }
484 484
485 if (text.empty() && (IsLink() || GetRole() == ui::AX_ROLE_IMAGE)) { 485 if (text.empty() && (IsLink() || GetRole() == ui::AX_ROLE_IMAGE) &&
486 !HasExplicitlyEmptyName()) {
486 base::string16 url = GetString16Attribute(ui::AX_ATTR_URL); 487 base::string16 url = GetString16Attribute(ui::AX_ATTR_URL);
487 // Given a url like http://foo.com/bar/baz.png, just return the 488 // Given a url like http://foo.com/bar/baz.png, just return the
488 // base text, e.g., "baz". 489 // base text, e.g., "baz".
489 int trailing_slashes = 0; 490 int trailing_slashes = 0;
490 while (url.size() - trailing_slashes > 0 && 491 while (url.size() - trailing_slashes > 0 &&
491 url[url.size() - trailing_slashes - 1] == '/') { 492 url[url.size() - trailing_slashes - 1] == '/') {
492 trailing_slashes++; 493 trailing_slashes++;
493 } 494 }
494 if (trailing_slashes) 495 if (trailing_slashes)
495 url = url.substr(0, url.size() - trailing_slashes); 496 url = url.substr(0, url.size() - trailing_slashes);
(...skipping 1008 matching lines...) Expand 10 before | Expand all | Expand 10 after
1504 int BrowserAccessibilityAndroid::CountChildrenWithRole(ui::AXRole role) const { 1505 int BrowserAccessibilityAndroid::CountChildrenWithRole(ui::AXRole role) const {
1505 int count = 0; 1506 int count = 0;
1506 for (uint32_t i = 0; i < PlatformChildCount(); i++) { 1507 for (uint32_t i = 0; i < PlatformChildCount(); i++) {
1507 if (PlatformGetChild(i)->GetRole() == role) 1508 if (PlatformGetChild(i)->GetRole() == role)
1508 count++; 1509 count++;
1509 } 1510 }
1510 return count; 1511 return count;
1511 } 1512 }
1512 1513
1513 } // namespace content 1514 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698