зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1107695 - make one-off buttons accessible, r=florian,f=MarcoZ
This commit is contained in:
Родитель
6f45959a73
Коммит
87e7d21fbc
|
@ -1010,6 +1010,7 @@
|
||||||
</xul:hbox>
|
</xul:hbox>
|
||||||
</xul:deck>
|
</xul:deck>
|
||||||
<xul:description anonid="search-panel-one-offs"
|
<xul:description anonid="search-panel-one-offs"
|
||||||
|
role="group"
|
||||||
class="search-panel-one-offs"/>
|
class="search-panel-one-offs"/>
|
||||||
<xul:vbox anonid="add-engines"/>
|
<xul:vbox anonid="add-engines"/>
|
||||||
<xul:button anonid="search-settings"
|
<xul:button anonid="search-settings"
|
||||||
|
@ -1023,6 +1024,18 @@
|
||||||
false after the mousedown event has been triggered to detect what
|
false after the mousedown event has been triggered to detect what
|
||||||
caused rollup. -->
|
caused rollup. -->
|
||||||
<field name="_isHiding">false</field>
|
<field name="_isHiding">false</field>
|
||||||
|
<field name="_bundle">null</field>
|
||||||
|
<property name="bundle" readonly="true">
|
||||||
|
<getter>
|
||||||
|
<![CDATA[
|
||||||
|
if (!this._bundle) {
|
||||||
|
const kBundleURI = "chrome://browser/locale/search.properties";
|
||||||
|
this._bundle = Services.strings.createBundle(kBundleURI);
|
||||||
|
}
|
||||||
|
return this._bundle;
|
||||||
|
]]>
|
||||||
|
</getter>
|
||||||
|
</property>
|
||||||
|
|
||||||
<method name="updateHeader">
|
<method name="updateHeader">
|
||||||
<body><![CDATA[
|
<body><![CDATA[
|
||||||
|
@ -1038,10 +1051,8 @@
|
||||||
this.removeAttribute("src");
|
this.removeAttribute("src");
|
||||||
}
|
}
|
||||||
|
|
||||||
const kBundleURI = "chrome://browser/locale/search.properties";
|
let headerText = this.bundle.formatStringFromName("searchHeader",
|
||||||
let bundle = Services.strings.createBundle(kBundleURI);
|
[currentEngine.name], 1);
|
||||||
let headerText = bundle.formatStringFromName("searchHeader",
|
|
||||||
[currentEngine.name], 1);
|
|
||||||
document.getAnonymousElementByAttribute(this, "anonid", "searchbar-engine-name")
|
document.getAnonymousElementByAttribute(this, "anonid", "searchbar-engine-name")
|
||||||
.setAttribute("value", headerText);
|
.setAttribute("value", headerText);
|
||||||
document.getAnonymousElementByAttribute(this, "anonid", "searchbar-engine")
|
document.getAnonymousElementByAttribute(this, "anonid", "searchbar-engine")
|
||||||
|
@ -1086,17 +1097,28 @@
|
||||||
let headerPanel =
|
let headerPanel =
|
||||||
document.getAnonymousElementByAttribute(this, "anonid",
|
document.getAnonymousElementByAttribute(this, "anonid",
|
||||||
"search-panel-one-offs-header");
|
"search-panel-one-offs-header");
|
||||||
|
let list = document.getAnonymousElementByAttribute(this, "anonid",
|
||||||
|
"search-panel-one-offs");
|
||||||
let textbox = searchbar.textbox;
|
let textbox = searchbar.textbox;
|
||||||
let self = this;
|
let self = this;
|
||||||
let inputHandler = function() {
|
let inputHandler = function() {
|
||||||
headerSearchText.setAttribute("value", textbox.value);
|
headerSearchText.setAttribute("value", textbox.value);
|
||||||
|
let groupText;
|
||||||
if (textbox.value) {
|
if (textbox.value) {
|
||||||
self.removeAttribute("showonlysettings");
|
self.removeAttribute("showonlysettings");
|
||||||
|
groupText = headerSearchText.previousSibling.value +
|
||||||
|
'"' + headerSearchText.value + '"' +
|
||||||
|
headerSearchText.nextSibling.value;
|
||||||
headerPanel.selectedIndex = 1;
|
headerPanel.selectedIndex = 1;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
let noSearchHeader =
|
||||||
|
document.getAnonymousElementByAttribute(this, "anonid",
|
||||||
|
"searchbar-oneoffheader-search");
|
||||||
|
groupText = noSearchHeader.value;
|
||||||
headerPanel.selectedIndex = 0;
|
headerPanel.selectedIndex = 0;
|
||||||
}
|
}
|
||||||
|
list.setAttribute("aria-label", groupText);
|
||||||
};
|
};
|
||||||
textbox.addEventListener("input", inputHandler);
|
textbox.addEventListener("input", inputHandler);
|
||||||
this.addEventListener("popuphiding", function hiding() {
|
this.addEventListener("popuphiding", function hiding() {
|
||||||
|
@ -1118,12 +1140,11 @@
|
||||||
|
|
||||||
let addEngines = gBrowser.selectedBrowser.engines;
|
let addEngines = gBrowser.selectedBrowser.engines;
|
||||||
if (addEngines && addEngines.length > 0) {
|
if (addEngines && addEngines.length > 0) {
|
||||||
const kBundleURI = "chrome://browser/locale/search.properties";
|
|
||||||
let bundle = Services.strings.createBundle(kBundleURI);
|
|
||||||
for (let engine of addEngines) {
|
for (let engine of addEngines) {
|
||||||
let button = document.createElementNS(kXULNS, "button");
|
let button = document.createElementNS(kXULNS, "button");
|
||||||
let label = bundle.formatStringFromName("cmd_addFoundEngine",
|
let label = this.bundle.formatStringFromName("cmd_addFoundEngine",
|
||||||
[engine.title], 1);
|
[engine.title], 1);
|
||||||
|
button.id = "searchbar-add-engine-" + engine.title.replace(/ /g, '-');
|
||||||
button.setAttribute("class", "addengine-item");
|
button.setAttribute("class", "addengine-item");
|
||||||
button.setAttribute("label", label);
|
button.setAttribute("label", label);
|
||||||
button.setAttribute("pack", "start");
|
button.setAttribute("pack", "start");
|
||||||
|
@ -1141,8 +1162,6 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
// Finally, build the list of one-off buttons.
|
// Finally, build the list of one-off buttons.
|
||||||
let list = document.getAnonymousElementByAttribute(this, "anonid",
|
|
||||||
"search-panel-one-offs")
|
|
||||||
while (list.firstChild)
|
while (list.firstChild)
|
||||||
list.firstChild.remove();
|
list.firstChild.remove();
|
||||||
|
|
||||||
|
@ -1201,11 +1220,15 @@
|
||||||
let height = rowCount * 33; // 32px per row, 1px border.
|
let height = rowCount * 33; // 32px per row, 1px border.
|
||||||
list.setAttribute("height", height + "px");
|
list.setAttribute("height", height + "px");
|
||||||
|
|
||||||
|
// Ensure we can refer to the settings button by ID:
|
||||||
|
let settingsEl = document.getAnonymousElementByAttribute(this, "anonid", "search-settings");
|
||||||
|
settingsEl.id = this.id + "-anon-search-settings";
|
||||||
|
|
||||||
let dummyItems = enginesPerRow - (engines.length % enginesPerRow || enginesPerRow);
|
let dummyItems = enginesPerRow - (engines.length % enginesPerRow || enginesPerRow);
|
||||||
for (let i = 0; i < engines.length; ++i) {
|
for (let i = 0; i < engines.length; ++i) {
|
||||||
let engine = engines[i];
|
let engine = engines[i];
|
||||||
let button = document.createElementNS(kXULNS, "button");
|
let button = document.createElementNS(kXULNS, "button");
|
||||||
button.setAttribute("label", engine.name);
|
button.id = "searchbar-engine-one-off-item-" + engine.name.replace(/ /g, '-');
|
||||||
let uri = "chrome://browser/skin/search-engine-placeholder.png";
|
let uri = "chrome://browser/skin/search-engine-placeholder.png";
|
||||||
if (engine.iconURI) {
|
if (engine.iconURI) {
|
||||||
uri = PlacesUtils.getImageURLForResolution(window, engine.iconURI.spec);
|
uri = PlacesUtils.getImageURLForResolution(window, engine.iconURI.spec);
|
||||||
|
|
|
@ -826,6 +826,8 @@
|
||||||
element = document.createElementNS(kXULNS, "menuseparator");
|
element = document.createElementNS(kXULNS, "menuseparator");
|
||||||
cxmenu.appendChild(element);
|
cxmenu.appendChild(element);
|
||||||
|
|
||||||
|
this.setAttribute("aria-owns", this.popup.id);
|
||||||
|
|
||||||
var insertLocation = cxmenu.firstChild;
|
var insertLocation = cxmenu.firstChild;
|
||||||
while (insertLocation.nextSibling &&
|
while (insertLocation.nextSibling &&
|
||||||
insertLocation.getAttribute("cmd") != "cmd_paste")
|
insertLocation.getAttribute("cmd") != "cmd_paste")
|
||||||
|
@ -1019,9 +1021,11 @@
|
||||||
if (val && !val.classList.contains("dummy")) {
|
if (val && !val.classList.contains("dummy")) {
|
||||||
val.setAttribute("selected", "true");
|
val.setAttribute("selected", "true");
|
||||||
this._selectedButton = val;
|
this._selectedButton = val;
|
||||||
|
this.setAttribute("aria-activedescendant", val.id);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this.removeAttribute("aria-activedescendant");
|
||||||
this._selectedButton = null;
|
this._selectedButton = null;
|
||||||
]]></setter>
|
]]></setter>
|
||||||
</property>
|
</property>
|
||||||
|
|
Загрузка…
Ссылка в новой задаче