fix for bug #406355: New autocomplete has a11y issues The "faabar" wasn't friendly to screer readers, and would either just say what the user typed in the url bar or nothing at all. now, screen readers will read the title, url and type ("tag" or "bookmark") for each autocomplete result. r=gavin, a=blocking-firefox3+

This commit is contained in:
sspitzer@mozilla.org 2007-12-04 22:19:38 -08:00
parent b54cc99d03
commit d1df49f1d3
3 changed files with 56 additions and 1 deletions

View File

@ -320,6 +320,12 @@
<implementation>
<field name="_maxResults">0</field>
<field name="_bundle" readonly="true">
Cc["@mozilla.org/intl/stringbundle;1"].
getService(Ci.nsIStringBundleService).
createBundle("chrome://browser/locale/places/places.properties");
</field>
<property name="maxResults" readonly="true">
<getter>
<![CDATA[
@ -375,6 +381,25 @@
]]>
</body>
</method>
<method name="createResultLabel">
<parameter name="aTitle"/>
<parameter name="aUrl"/>
<parameter name="aType"/>
<body>
<![CDATA[
var label = aTitle + " " + aUrl;
// convert aType (ex: "ac-result-type-<aType>") to text to be spoke aloud
// by screen readers. convert "tag" and "bookmark" to the localized versions,
// but don't do anything for "favicon" (the default)
if (aType != "favicon") {
label += " " + this._bundle.GetStringFromName(aType + "ResultLabel");
}
return label;
]]>
</body>
</method>
</implementation>
</binding>
</bindings>

View File

@ -106,3 +106,14 @@ recentTagsTitle=Recent Tags
OrganizerQueryHistory=History
OrganizerQueryDownloads=Downloads
OrganizerQueryAllBookmarks=All Bookmarks
# LOCALIZATION NOTE (tagResultLabel) :
# This is what we use to form the label (for screen readers)
# for url bar autocomplete results of type "tag"
# See createResultLabel() in urlbarBindings.xml
tagResultLabel=Tag
# LOCALIZATION NOTE (bookmarkResultLabel) :
# This is what we use to form the label (for screen readers)
# for url bar autocomplete results of type "bookmark"
# See createResultLabel() in urlbarBindings.xml
bookmarkResultLabel=Bookmark

View File

@ -1092,7 +1092,7 @@
</xul:hbox>
</xul:vbox>
</content>
<implementation>
<implementation implements="nsIDOMXULSelectControlItemElement">
<constructor>
<![CDATA[
this._urlOverflowEllipsis = document.getAnonymousElementByAttribute(this, "anonid", "url-overflow-ellipsis");
@ -1122,6 +1122,25 @@
]]>
</constructor>
<property name="label" readonly="true">
<getter>
<![CDATA[
var title = this.getAttribute("title");
var url = this.getAttribute("url");
var panel = this.parentNode.parentNode;
// allow consumers that have extended popups to override
// the label values for the richlistitems
if (panel.createResultLabel)
return panel.createResultLabel(title, url, this.getAttribute("type"));
// aType (ex: "ac-result-type-<aType>") is related to the class of the image,
// and is not "visible" text so don't use it for the label (for accessibility).
return title + " " + url;
]]>
</getter>
</property>
<field name="_ellipsis">null</field>
<property name="ellipsis" readonly="true">