Bug 1062128 - set tooltiptext for new tab button directly for a11y reasons, r=johannh

Differential Revision: https://phabricator.services.mozilla.com/D13406

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Gijs Kruitbosch 2018-12-03 18:22:05 +00:00
Родитель 90b02dc14b
Коммит 45794c41ea
2 изменённых файлов: 13 добавлений и 4 удалений

Просмотреть файл

@ -5912,8 +5912,7 @@ if (AppConstants.platform == "macosx") {
}
const gDynamicTooltipCache = new Map();
function UpdateDynamicShortcutTooltipText(aTooltip) {
let nodeId = aTooltip.triggerNode.id || aTooltip.triggerNode.getAttribute("anonid");
function GetDynamicShortcutTooltipText(nodeId) {
if (!gDynamicTooltipCache.has(nodeId) && nodeId in nodeToTooltipMap) {
let strId = nodeToTooltipMap[nodeId];
let args = [];
@ -5926,9 +5925,15 @@ function UpdateDynamicShortcutTooltipText(aTooltip) {
}
gDynamicTooltipCache.set(nodeId, gNavigatorBundle.getFormattedString(strId, args));
}
aTooltip.setAttribute("label", gDynamicTooltipCache.get(nodeId));
return gDynamicTooltipCache.get(nodeId);
}
function UpdateDynamicShortcutTooltipText(aTooltip) {
let nodeId = aTooltip.triggerNode.id || aTooltip.triggerNode.getAttribute("anonid");
aTooltip.setAttribute("label", GetDynamicShortcutTooltipText(nodeId));
}
/*
* - [ Dependencies ] ---------------------------------------------------------
* utilityOverlay.js:

Просмотреть файл

@ -93,7 +93,7 @@
anonid="tabs-newtab-button"
command="cmd_newNavigatorTab"
onclick="checkForMiddleClick(this, event);"
tooltip="dynamic-shortcut-tooltip"/>
/>
<xul:spacer class="closing-tabs-spacer" anonid="closing-tabs-spacer"
style="width: 0;"/>
</xul:arrowscrollbox>
@ -112,6 +112,10 @@
var tab = this.firstElementChild;
tab.label = this.emptyTabTitle;
let newTabButton = document.getAnonymousElementByAttribute(
this, "anonid", "tabs-newtab-button");
newTabButton.setAttribute("tooltiptext", GetDynamicShortcutTooltipText("tabs-newtab-button"));
window.addEventListener("resize", this);
Services.prefs.addObserver("privacy.userContext", this);