Bug 955081 - [a11y] Tooltips are missing in log viewer and message theme preview, r=florian.

This commit is contained in:
aleth 2013-04-11 00:22:25 +02:00
Родитель f79cce50d0
Коммит 3ee5cdae24
7 изменённых файлов: 58 добавлений и 45 удалений

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

@ -628,6 +628,50 @@
</body>
</method>
<method name="FillInHTMLTooltip">
<parameter name="tipElement"/>
<body>
<![CDATA[
// Inspired from the same function in mozilla/browser/base/content/browser.js
if (tipElement.namespaceURI == "http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul")
return false;
var defView = tipElement.ownerDocument && tipElement.ownerDocument.defaultView;
// XXX Work around bug 350679:
// "Tooltips can be fired in documents with no view".
if (!defView)
return false;
while (tipElement) {
if (tipElement.nodeType == Node.ELEMENT_NODE) {
let titleText = tipElement.getAttribute("title");
if (titleText && /\S/.test(titleText)) {
let direction = defView.getComputedStyle(tipElement, "")
.getPropertyValue("direction");
let tipNode = document.getElementById("aHTMLTooltip");
tipNode.style.direction = direction;
// Per HTML 4.01 6.2 (CDATA section), literal CRs and tabs should be
// replaced with spaces, and LFs should be removed entirely.
// XXX Bug 322270: We don't preserve the result of entities like &#13;,
// which should result in a line break in the tooltip, because we can't
// distinguish that from a literal character in the source by this point.
titleText = titleText.replace(/[\r\t]/g, ' ').replace(/\n/g, '');
tipNode.setAttribute("label", titleText);
return true;
}
// When hovering a link, displaying a tooltip for a parent
// element is confusing, so we prevent it here.
if (tipElement.hasAttribute("href"))
return false;
}
tipElement = tipElement.parentNode;
}
return false;
]]>
</body>
</method>
<!-- nsIObserver implementation -->
<method name="observe">
<parameter name="aSubject"/>

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

@ -60,46 +60,6 @@ function getBrowser()
return document.getElementById("conversations");
}
// Inspired from the same function in mozilla/browser/base/content/browser.js
function FillInHTMLTooltip(tipElement)
{
if (tipElement.namespaceURI == "http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul")
return false;
var defView = tipElement.ownerDocument && tipElement.ownerDocument.defaultView;
// XXX Work around bug 350679:
// "Tooltips can be fired in documents with no view".
if (!defView)
return false;
while (tipElement) {
if (tipElement.nodeType == Node.ELEMENT_NODE) {
let titleText = tipElement.getAttribute("title");
if (titleText && /\S/.test(titleText)) {
let direction = defView.getComputedStyle(tipElement, "")
.getPropertyValue("direction");
let tipNode = document.getElementById("aHTMLTooltip");
tipNode.style.direction = direction;
// Per HTML 4.01 6.2 (CDATA section), literal CRs and tabs should be
// replaced with spaces, and LFs should be removed entirely.
// XXX Bug 322270: We don't preserve the result of entities like &#13;,
// which should result in a line break in the tooltip, because we can't
// distinguish that from a literal character in the source by this point.
titleText = titleText.replace(/[\r\t]/g, ' ').replace(/\n/g, '');
tipNode.setAttribute("label", titleText);
return true;
}
// When hovering a link, displaying a tooltip for a parent
// element is confusing, so we prevent it here.
if (tipElement.hasAttribute("href"))
return false;
}
tipElement = tipElement.parentNode;
}
return false;
}
// Copied from mozilla/browser/base/content/browser.js (and simplified)
var XULBrowserWindow = {
// Stored Status

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

@ -112,7 +112,8 @@
</stringbundleset>
<popupset id="mainPopupSet">
<tooltip id="aHTMLTooltip" onpopupshowing="return FillInHTMLTooltip(document.tooltipNode);"/>
<tooltip id="aHTMLTooltip"
onpopupshowing="return getBrowser().selectedBrowser.FillInHTMLTooltip(document.tooltipNode);"/>
<tooltip id="buddyTooltip" type="buddy"/>
<menupopup id="contentAreaContextMenu"

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

@ -20,6 +20,9 @@ Conversation.prototype = {
statusInfo: Services.core.globalUserStatus}
};
// Message style tooltips use this.
function getBrowser() document.getElementById("previewbrowser");
var previewObserver = {
_loaded: false,
load: function() {

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

@ -70,6 +70,8 @@
</hbox>
<separator class="thin"/>
<label value="&messageStylePreview.label;"/>
<tooltip id="aHTMLTooltip"
onpopupshowing="return getBrowser().FillInHTMLTooltip(document.tooltipNode);"/>
<deck flex="1" id="previewDeck" selectedIndex="1">
<vbox flex="1" id="noPreviewScreen" align="center" pack="center">
<hbox id="noPreviewBox" align="top">
@ -80,7 +82,7 @@
</vbox>
</hbox>
</vbox>
<browser flex="1" id="previewbrowser" type="content-conversation"/>
<browser flex="1" id="previewbrowser" type="content-conversation" tooltip="aHTMLTooltip"/>
</deck>
<hbox align="baseline">
<label value="&messageStyleVariant.label;" control="themevariant"

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

@ -6,7 +6,7 @@ const Cu = Components.utils;
Cu.import("resource://gre/modules/Services.jsm");
// viewZoomOverlay.js uses this
// viewZoomOverlay.js, macgestures.js and tooltips use this.
function getBrowser() {
let deck = document.getElementById("browserDeck");
let id = (parseInt(deck.selectedIndex, 10) ? "conv" : "text") + "-browser";

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

@ -86,6 +86,8 @@
</stringbundleset>
<popupset id="mainPopupSet">
<tooltip id="aHTMLTooltip"
onpopupshowing="return getBrowser().FillInHTMLTooltip(document.tooltipNode);"/>
<menupopup id="contentAreaContextMenu">
<menuitem id="context-copy"
label="&copyCmd.label;"
@ -111,11 +113,12 @@
<splitter/>
<vbox flex="1">
<deck flex="1" id="browserDeck" selectedIndex="0">
<browser id="text-browser" type="content" context="contentAreaContextMenu"
<browser id="text-browser" type="content"
context="contentAreaContextMenu" tooltip="aHTMLTooltip"
disablehistory="true" src="about:blank" flex="1"/>
<vbox flex="1">
<browser id="conv-browser" type="content-conversation" flex="1"
context="contentAreaContextMenu"/>
context="contentAreaContextMenu" tooltip="aHTMLTooltip"/>
<progressmeter id="browserProgress" hidden="true"/>
</vbox>
<vbox flex="1" id="corruptLogScreen" align="center" pack="center">