From f72fa4f594d903128677b668e028f50225e6de87 Mon Sep 17 00:00:00 2001 From: "ben%netscape.com" Date: Thu, 14 Sep 2006 05:51:30 +0000 Subject: [PATCH] fix for 27828, TITLE attribute shows tooltip in content area. patch from robert o'callahan, r=me. --- suite/browser/navigator.js | 62 +++++++++++++++++++++++++++++++++++- suite/browser/navigator.xul | 23 ++++++++++--- suite/browser/navigatorDD.js | 9 ++++-- 3 files changed, 85 insertions(+), 9 deletions(-) diff --git a/suite/browser/navigator.js b/suite/browser/navigator.js index 52857824bbb0..39a1f807bab3 100644 --- a/suite/browser/navigator.js +++ b/suite/browser/navigator.js @@ -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; +} + diff --git a/suite/browser/navigator.xul b/suite/browser/navigator.xul index 2f1f6c9b1691..2459f0ed43ff 100644 --- a/suite/browser/navigator.xul +++ b/suite/browser/navigator.xul @@ -61,6 +61,7 @@ Contributor(s): ______________________________________. --> + @@ -86,9 +87,14 @@ Contributor(s): ______________________________________. --> - - + + + + + + + @@ -232,7 +245,7 @@ Contributor(s): ______________________________________. --> - + -