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

Unified Diff: chrome/browser/resources/shared/js/cr/ui/list.js

Issue 10376003: Improve accessibility of user image selection screen. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase. Manually verified with fresh Chrome OS build. Created 8 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/resources/shared/js/cr/ui/list.js
diff --git a/chrome/browser/resources/shared/js/cr/ui/list.js b/chrome/browser/resources/shared/js/cr/ui/list.js
index 7a23cb56837942d8c0faa337452becf8a6a5a98a..49facce0aa02551924e7952ba8539072c0c094b2 100644
--- a/chrome/browser/resources/shared/js/cr/ui/list.js
+++ b/chrome/browser/resources/shared/js/cr/ui/list.js
@@ -319,7 +319,7 @@ cr.define('cr.ui', function() {
this.addEventListener('focus', this.handleElementFocus_, true);
this.addEventListener('blur', this.handleElementBlur_, true);
this.addEventListener('scroll', this.handleScroll.bind(this));
- this.setAttribute('role', 'listbox');
+ this.setAttribute('role', 'list');
this.touchHandler_ = new cr.ui.TouchHandler(this);
this.addEventListener(cr.ui.TouchHandler.EventType.TOUCH_START,
@@ -332,6 +332,19 @@ cr.define('cr.ui', function() {
// Make list focusable
if (!this.hasAttribute('tabindex'))
this.tabIndex = 0;
+
+ // Try to get an unique id prefix from the id of this element or the
+ // nearest ancestor with an id.
+ var element = this;
+ while (element && !element.id)
+ element = element.parentElement;
+ if (element && element.id)
+ this.uniqueIdPrefix_ = element.id;
+ else
+ this.uniqueIdPrefix_ = 'list';
+
+ // The next id suffix to use when giving each item an unique id.
+ this.nextUniqueIdSuffix_ = 0;
},
/**
@@ -582,8 +595,11 @@ cr.define('cr.ui', function() {
handleOnChange_: function(ce) {
ce.changes.forEach(function(change) {
var listItem = this.getListItemByIndex(change.index);
- if (listItem)
+ if (listItem) {
listItem.selected = change.selected;
+ if (change.selected)
+ this.setAttribute('aria-activedescendant', listItem.id);
+ }
}, this);
cr.dispatchSimpleEvent(this, 'change');
@@ -816,6 +832,7 @@ cr.define('cr.ui', function() {
createItem: function(value) {
var item = new this.itemConstructor_(value);
item.label = value;
+ item.id = this.uniqueIdPrefix_ + '-' + this.nextUniqueIdSuffix_++;
if (typeof item.decorate == 'function')
item.decorate();
return item;
« no previous file with comments | « chrome/browser/resources/shared/js/cr/ui/grid.js ('k') | chrome/browser/ui/webui/chromeos/login/user_image_screen_handler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698