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

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

Issue 10823073: Improve accessible name calculation on Windows. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Remove unintentionally modified file Created 8 years, 5 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_win.cc
diff --git a/content/browser/accessibility/browser_accessibility_win.cc b/content/browser/accessibility/browser_accessibility_win.cc
index f1896ec576d18b6bc7edacad6ed6c64c83308af0..5c8a6b7ddff8dd269f81e154a7c0a884b8a5d9c1 100644
--- a/content/browser/accessibility/browser_accessibility_win.cc
+++ b/content/browser/accessibility/browser_accessibility_win.cc
@@ -2726,6 +2726,47 @@ void BrowserAccessibilityWin::PreInitialize() {
}
}
+ // WebKit computes accessible name, description and help strings from the
+ // html source, but on Windows, the help should become the description if
+ // there's no description, and then the description should become the name
+ // if there's no name.
+ string16 description, help;
+ int title_elem_id = 0;
+ GetIntAttribute(AccessibilityNodeData::ATTR_TITLE_UI_ELEMENT, &title_elem_id);
+ GetStringAttribute(AccessibilityNodeData::ATTR_DESCRIPTION, &description);
+ GetStringAttribute(AccessibilityNodeData::ATTR_HELP, &help);
+ if (!description.empty()) {
+ name_ = description;
aboxhall 2012/08/06 01:55:49 I'm confused by this line. Is name_ always empty a
+ description = L"";
+ string_attributes_[AccessibilityNodeData::ATTR_DESCRIPTION] = description;
+ }
+ if (!help.empty() && description.empty()) {
+ description = help;
+ string_attributes_[AccessibilityNodeData::ATTR_DESCRIPTION] = help;
+ string_attributes_[AccessibilityNodeData::ATTR_HELP] = L"";
+ }
+ if (!description.empty() && name_.empty() && !title_elem_id) {
+ name_ = description;
+ description = L"";
+ string_attributes_[AccessibilityNodeData::ATTR_DESCRIPTION] = L"";
+ }
+
+ // If it's a text field, also consider the placeholder.
+ string16 placeholder;
+ if (role_ == AccessibilityNodeData::ROLE_TEXT_FIELD &&
+ HasState(AccessibilityNodeData::STATE_FOCUSABLE) &&
+ GetHtmlAttribute("placeholder", &placeholder)) {
+ if (name_.empty() && !title_elem_id) {
+ name_ = placeholder;
+ } else if (description.empty()) {
+ description = placeholder;
+ string_attributes_[AccessibilityNodeData::ATTR_DESCRIPTION] = description;
+ } else {
+ description = description + L" " + placeholder;
aboxhall 2012/08/06 01:55:49 As I said elsewhere, I'm not sure this is the best
+ string_attributes_[AccessibilityNodeData::ATTR_DESCRIPTION] = description;
+ }
+ }
+
if (name_.empty() &&
(role_ == AccessibilityNodeData::ROLE_LISTBOX_OPTION ||
role_ == AccessibilityNodeData::ROLE_STATIC_TEXT ||
@@ -2733,12 +2774,6 @@ void BrowserAccessibilityWin::PreInitialize() {
name_.swap(value_);
}
- // If this object doesn't have a name but it does have a description,
- // use the description as its name - because some screen readers only
- // announce the name.
- if (name_.empty())
- GetStringAttribute(AccessibilityNodeData::ATTR_DESCRIPTION, &name_);
-
// If this doesn't have a value and is linked then set its value to the url
// attribute. This allows screen readers to read an empty link's destination.
string16 url;
@@ -2751,9 +2786,7 @@ void BrowserAccessibilityWin::PreInitialize() {
relations_.clear();
// Handle title UI element.
- int title_elem_id;
- if (GetIntAttribute(AccessibilityNodeData::ATTR_TITLE_UI_ELEMENT,
- &title_elem_id)) {
+ if (title_elem_id) {
// Add a labelled by relationship.
CComObject<BrowserAccessibilityRelation>* relation;
HRESULT hr = CComObject<BrowserAccessibilityRelation>::CreateInstance(

Powered by Google App Engine
This is Rietveld 408576698