Bug 482921 part 9 - Support tooltips in the View Source window. r=gavin.sharp.

This commit is contained in:
Henri Sivonen 2011-11-01 13:33:11 +02:00
parent 256c728c79
commit 8fd1c9834b
2 changed files with 39 additions and 1 deletions

View File

@ -771,3 +771,39 @@ function UpdateBackForwardCommands() {
else
forwardBroadcaster.setAttribute("disabled", "true");
}
// FIXME copied and modified from browser.js.
// Deduplication is part of bug 480356.
function FillInHTMLTooltip(tipElement)
{
var retVal = false;
var titleText = null;
var direction = tipElement.ownerDocument.dir;
while (!titleText && tipElement) {
if (tipElement.nodeType == Node.ELEMENT_NODE) {
titleText = tipElement.getAttribute("title");
var defView = tipElement.ownerDocument.defaultView;
// XXX Work around bug 350679:
// "Tooltips can be fired in documents with no view".
if (!defView)
return retVal;
direction = defView.getComputedStyle(tipElement, "")
.getPropertyValue("direction");
}
tipElement = tipElement.parentNode;
}
var tipNode = document.getElementById("aHTMLTooltip");
tipNode.style.direction = direction;
if (titleText && /\S/.test(titleText)) {
// Make CRLF and CR render one line break each.
titleText = titleText.replace(/\r\n/g, '\n');
titleText = titleText.replace(/\r/g, '\n');
tipNode.setAttribute("label", titleText);
retVal = true;
}
return retVal;
}

View File

@ -141,6 +141,8 @@
#endif
</keyset>
<tooltip id="aHTMLTooltip" onpopupshowing="return FillInHTMLTooltip(document.tooltipNode);"/>
<menupopup id="viewSourceContextMenu">
<menuitem id="context-back"
@ -236,7 +238,7 @@
<vbox id="appcontent" flex="1">
<browser id="content" type="content-primary" name="content" src="about:blank" flex="1"
context="viewSourceContextMenu" showcaret="true"/>
context="viewSourceContextMenu" showcaret="true" tooltip="aHTMLTooltip"/>
<findbar id="FindToolbar" browserid="content"/>
</vbox>