fix for 27828, TITLE attribute shows tooltip in content area. patch from robert o'callahan, r=me.

This commit is contained in:
ben%netscape.com 2006-09-14 05:51:30 +00:00
Родитель 2c2ab11e2d
Коммит ff2c33698b
3 изменённых файлов: 85 добавлений и 9 удалений

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

@ -906,11 +906,11 @@ function RevealSearchPanel()
newWin.saveFileAndPos = true;
}
const nsIFilePicker = Components.interfaces.nsIFilePicker;
function BrowserOpenFileWindow()
{
// Get filepicker component.
try {
var nsIFilePicker = Components.interfaces.nsIFilePicker;
var fp = Components.classes["component://mozilla/filepicker"].createInstance(nsIFilePicker);
fp.init(window, bundle.GetStringFromName("openFile"), nsIFilePicker.modeOpen);
fp.appendFilters(nsIFilePicker.filterHTML | nsIFilePicker.filterText |
@ -1587,3 +1587,63 @@ function postURLToNativeWidget() {
}
}
/**
* Content area tooltip.
* XXX - this must move into XBL binding/equiv! Do not want to pollute
* navigator.js with functionality that can be encapsulated into
* browser widget. TEMPORARY!
**/
function FillInHTMLTooltip ( tipElement )
{
var HTMLNS = "http://www.w3.org/1999/xhtml";
var XULNS = "http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul";
var XLinkNS = "http://www.w3.org/1999/xlink";
var retVal = false;
var tipNode = document.getElementById("HTML_TOOLTIP_tooltipBox");
if ( tipNode ) {
try {
while ( tipNode.hasChildNodes() ) {
tipNode.removeChild( tipNode.firstChild );
}
var titleText = "";
var XLinkTitleText = "";
var summaryText = "";
while ( titleText == "" && summaryText == "" && XLinkTitleText == "" && tipElement ) {
if ( tipElement.nodeType == 1 ) {
titleText = tipElement.getAttributeNS(HTMLNS, "title");
XLinkTitleText = tipElement.getAttributeNS(XLinkNS, "title");
if ( (tipElement.namespaceURI == "" || tipElement.namespaceURI == HTMLNS)
&& tipElement.tagName.toLowerCase() == "table" ) {
summaryText = tipElement.getAttributeNS(HTMLNS, "summary");
}
}
tipElement = tipElement.parentNode;
}
var texts = [ titleText, summaryText, XLinkTitleText ];
for (var i = 0; i < texts.length; i++) {
var t = texts[i];
if ( t.search(/\S/) >= 0 ) {
if ( tipNode.hasChildNodes() ) {
var blankLineElem = tipNode.ownerDocument.createElementNS(XULNS, "text");
tipNode.appendChild(blankLineElem);
}
var tipLineElem = tipNode.ownerDocument.createElementNS(XULNS, "text");
tipLineElem.setAttribute("value", t);
tipNode.appendChild(tipLineElem);
retVal = true;
}
}
}
catch (e) { retVal = false; }
}
return retVal;
}

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

@ -61,6 +61,7 @@ Contributor(s): ______________________________________. -->
<script language="javascript" src="chrome://global/content/nsDragAndDrop.js"></script>
<script language="javascript" src="chrome://global/content/builtinURLs.js"></script>
<script language="javascript" src="chrome://global/content/strres.js"></script>
<script language="javascript" src="chrome://communicator/content/bookmarks/bookmarks.js"></script>
<script language="javascript" src="chrome://navigator/content/navigator.js"></script>
<script language="javascript" src="nsContextMenu.js"></script>
<script language="javascript" src="tooltip.js"></script>
@ -86,9 +87,14 @@ Contributor(s): ______________________________________. -->
<!-- keys are appended from the overlay -->
<keyset id="keyset"/>
<!-- This needs to go into a xul fragment, but since those don't work now, this stays here !-->
<!-- tooltips -->
<popupset id="aTooltipSet"/>
<!-- XXX-TEMP this needs to move into an XBL binding for browser!!! -->
<popupset id="aHTMLTooltipSet">
<popup id="aHTMLTooltip" class="tooltip" oncreate="return FillInHTMLTooltip(document.tooltipNode);" >
<box id="HTML_TOOLTIP_tooltipBox" orient="vertical"/>
</popup>
</popupset>
<!-- Context menu -->
<script language="javascript">
@ -225,6 +231,13 @@ Contributor(s): ______________________________________. -->
</popup>
</popupset>
<popupset>
<popup id="contextual" oncreate="return fillContextMenu('contextual', 'innermostBox');" >
<menu />
</popup>
</popupset>
<script language="javascript">
var gBookmarkPopup = null;
</script>
@ -232,7 +245,7 @@ Contributor(s): ______________________________________. -->
<toolbox class="toolbox-top">
<!-- Menu -->
<menubar id="main-menubar"/>
<toolbar id="nav-bar" class="toolbar-primary chromeclass-toolbar" persist="collapsed" grippytooltip="aTooltip" grippytooltiptext="&navigationBar.tooltip;">
<box id="nav-bar-inner" autostretch="never" flex="1" style="min-width: 0px;">
<menubutton class="menubutton-dual top toolbar" id="back-button" value="&backButton.label;"
@ -321,7 +334,7 @@ Contributor(s): ______________________________________. -->
</menubutton>
<!-- Personal toolbar items -->
<box id="innermostBox" flex="1" style="min-width: 1px;"
<box id="innermostBox" flex="1" style="min-width: 1px;" context="contextual"
datasources="rdf:bookmarks" ref="NC:PersonalToolbarFolder">
<template>
@ -391,7 +404,7 @@ Contributor(s): ______________________________________. -->
<!-- type attribute is used by frame construction to locate iframes
intended to hold (html) content -->
<browser context="context" type="content-primary" id="content"
src="about:blank" flex="1"/>
src="about:blank" flex="1" tooltip="aHTMLTooltip"/>
</box>
<statusbar id="status-bar" class="chromeclass-status"/>

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

@ -134,10 +134,13 @@ var personalToolbarObserver = {
var potentialTitle = null;
var historyDS = gRDFService.GetDataSource("rdf:history");
var historyEntry = gRDFService.GetResource(element);
var historyTitleProperty = gRDFService.GetResource(NC_RDF("URL"));
var historyTitleProperty = gRDFService.GetResource(NC_RDF("Name"));
var titleFromHistory = historyDS.GetTarget(historyEntry, historyTitleProperty, true);
if (titleFromHistory)
// titleFromHistory = titleFromHistory.QueryInterface(Components.interfaces.nsIRDFLiteral);
dump("*** titleFromHistory = " + titleFromHistory + "\n");
if (titleFromHistory) {
titleFromHistory = titleFromHistory.QueryInterface(Components.interfaces.nsIRDFLiteral);
dump("*** titleFromHistory2 = " + titleFromHistory + "\n");
}
if (titleFromHistory)
potentialTitle = titleFromHistory.Value;
linkTitle = potentialTitle ? potentialTitle : element;