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

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

Issue 665333004: Support the placeholder attribute on Android (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 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 unified diff | Download patch
« no previous file with comments | « no previous file | content/test/data/accessibility/input-text-name-calc-expected-android.txt » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/strings/utf_string_conversions.h" 7 #include "base/strings/utf_string_conversions.h"
8 #include "content/browser/accessibility/browser_accessibility_manager_android.h" 8 #include "content/browser/accessibility/browser_accessibility_manager_android.h"
9 #include "content/common/accessibility_messages.h" 9 #include "content/common/accessibility_messages.h"
10 10
(...skipping 289 matching lines...) Expand 10 before | Expand all | Expand 10 after
300 300
301 // If there's no text value, the basic rule is: prefer description 301 // If there's no text value, the basic rule is: prefer description
302 // (aria-labelledby or aria-label), then help (title), then name 302 // (aria-labelledby or aria-label), then help (title), then name
303 // (inner text), then value (control value). However, if 303 // (inner text), then value (control value). However, if
304 // title_elem_id is set, that means there's a label element 304 // title_elem_id is set, that means there's a label element
305 // supplying the name and then name takes precedence over help. 305 // supplying the name and then name takes precedence over help.
306 // TODO(dmazzoni): clean this up by providing more granular labels in 306 // TODO(dmazzoni): clean this up by providing more granular labels in
307 // Blink, making the platform-specific mapping to accessible text simpler. 307 // Blink, making the platform-specific mapping to accessible text simpler.
308 base::string16 description = GetString16Attribute(ui::AX_ATTR_DESCRIPTION); 308 base::string16 description = GetString16Attribute(ui::AX_ATTR_DESCRIPTION);
309 base::string16 help = GetString16Attribute(ui::AX_ATTR_HELP); 309 base::string16 help = GetString16Attribute(ui::AX_ATTR_HELP);
310 base::string16 placeholder;
311 GetHtmlAttribute("placeholder", &placeholder);
310 int title_elem_id = GetIntAttribute( 312 int title_elem_id = GetIntAttribute(
311 ui::AX_ATTR_TITLE_UI_ELEMENT); 313 ui::AX_ATTR_TITLE_UI_ELEMENT);
312 base::string16 text; 314 base::string16 text;
313 if (!description.empty()) 315 if (!description.empty())
314 text = description; 316 text = description;
315 else if (title_elem_id && !name().empty()) 317 else if (title_elem_id && !name().empty())
316 text = base::UTF8ToUTF16(name()); 318 text = base::UTF8ToUTF16(name());
317 else if (!help.empty()) 319 else if (!help.empty())
318 text = help; 320 text = help;
319 else if (!name().empty()) 321 else if (!name().empty())
320 text = base::UTF8ToUTF16(name()); 322 text = base::UTF8ToUTF16(name());
323 else if (GetRole() == ui::AX_ROLE_TEXT_FIELD && !placeholder.empty())
324 text = placeholder;
321 else if (!value().empty()) 325 else if (!value().empty())
322 text = base::UTF8ToUTF16(value()); 326 text = base::UTF8ToUTF16(value());
323 327
324 // This is called from PlatformIsLeaf, so don't call PlatformChildCount 328 // This is called from PlatformIsLeaf, so don't call PlatformChildCount
325 // from within this! 329 // from within this!
326 if (text.empty() && HasOnlyStaticTextChildren()) { 330 if (text.empty() && HasOnlyStaticTextChildren()) {
327 for (uint32 i = 0; i < InternalChildCount(); i++) { 331 for (uint32 i = 0; i < InternalChildCount(); i++) {
328 BrowserAccessibility* child = InternalGetChild(i); 332 BrowserAccessibility* child = InternalGetChild(i);
329 text += static_cast<BrowserAccessibilityAndroid*>(child)->GetText(); 333 text += static_cast<BrowserAccessibilityAndroid*>(child)->GetText();
330 } 334 }
(...skipping 333 matching lines...) Expand 10 before | Expand all | Expand 10 after
664 int BrowserAccessibilityAndroid::CountChildrenWithRole(ui::AXRole role) const { 668 int BrowserAccessibilityAndroid::CountChildrenWithRole(ui::AXRole role) const {
665 int count = 0; 669 int count = 0;
666 for (uint32 i = 0; i < PlatformChildCount(); i++) { 670 for (uint32 i = 0; i < PlatformChildCount(); i++) {
667 if (PlatformGetChild(i)->GetRole() == role) 671 if (PlatformGetChild(i)->GetRole() == role)
668 count++; 672 count++;
669 } 673 }
670 return count; 674 return count;
671 } 675 }
672 676
673 } // namespace content 677 } // namespace content
OLDNEW
« no previous file with comments | « no previous file | content/test/data/accessibility/input-text-name-calc-expected-android.txt » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698