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

Unified Diff: content/browser/accessibility/browser_accessibility_android.cc

Issue 639773012: On Android, unlabeled link containing image should use image url as name. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@link_visible_text
Patch Set: Rebase Created 6 years, 2 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 side-by-side diff with in-line comments
Download patch
Index: content/browser/accessibility/browser_accessibility_android.cc
diff --git a/content/browser/accessibility/browser_accessibility_android.cc b/content/browser/accessibility/browser_accessibility_android.cc
index 61ecb22bf6cc0bbd9128c9b55672473a7912e133..caea3beab892e101df3d221e8a682f66c6652e58 100644
--- a/content/browser/accessibility/browser_accessibility_android.cc
+++ b/content/browser/accessibility/browser_accessibility_android.cc
@@ -327,14 +327,16 @@ base::string16 BrowserAccessibilityAndroid::GetText() const {
// This is called from PlatformIsLeaf, so don't call PlatformChildCount
// from within this!
- if (text.empty() && HasOnlyStaticTextChildren()) {
+ if (text.empty() &&
+ (HasOnlyStaticTextChildren() ||
+ (IsFocusable() && HasOnlyTextAndImageChildren()))) {
for (uint32 i = 0; i < InternalChildCount(); i++) {
BrowserAccessibility* child = InternalGetChild(i);
text += static_cast<BrowserAccessibilityAndroid*>(child)->GetText();
}
}
- if (text.empty() && IsLink()) {
+ if (text.empty() && (IsLink() || GetRole() == ui::AX_ROLE_IMAGE)) {
base::string16 url = GetString16Attribute(ui::AX_ATTR_URL);
// Given a url like http://foo.com/bar/baz.png, just return the
// base name, e.g., "baz".
@@ -621,6 +623,19 @@ bool BrowserAccessibilityAndroid::HasOnlyStaticTextChildren() const {
return true;
}
+bool BrowserAccessibilityAndroid::HasOnlyTextAndImageChildren() const {
+ // This is called from PlatformIsLeaf, so don't call PlatformChildCount
+ // from within this!
+ for (uint32 i = 0; i < InternalChildCount(); i++) {
+ BrowserAccessibility* child = InternalGetChild(i);
+ if (child->GetRole() != ui::AX_ROLE_STATIC_TEXT &&
+ child->GetRole() != ui::AX_ROLE_IMAGE) {
+ return false;
+ }
+ }
+ return true;
+}
+
bool BrowserAccessibilityAndroid::IsIframe() const {
base::string16 html_tag = GetString16Attribute(
ui::AX_ATTR_HTML_TAG);
« no previous file with comments | « content/browser/accessibility/browser_accessibility_android.h ('k') | content/test/data/accessibility/a-no-text.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698