From d3f0cb160a6f1b513cd9c7ff7ef7782798cea23b Mon Sep 17 00:00:00 2001 From: "masayuki%d-toybox.com" Date: Sat, 1 Oct 2005 03:38:34 +0000 Subject: [PATCH] Bug 307874 Either wrong url or no url is shown in the status bar for focused links during FAYT r=mconnor git-svn-id: svn://10.0.0.236/trunk@181390 18797224-902f-48f8-a5cc-f745e15eee43 --- .../typeaheadfind/content/findBar.js | 35 +++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/mozilla/toolkit/components/typeaheadfind/content/findBar.js b/mozilla/toolkit/components/typeaheadfind/content/findBar.js index 62d05937c3d..79c2d1c17a1 100755 --- a/mozilla/toolkit/components/typeaheadfind/content/findBar.js +++ b/mozilla/toolkit/components/typeaheadfind/content/findBar.js @@ -66,6 +66,7 @@ var gFlashFindBarTimeout = null; var gLastHighlightString = ""; var gTypeAheadLinksOnly = false; var gIsIMEComposing = false; +var gTextToSubURIService = null; // DOMRange used during highlighting var searchRange; @@ -112,6 +113,10 @@ function initFindBar() var findField = document.getElementById("find-field"); findField.addEventListener("dragdrop", findBarOnDrop, true); + + gTextToSubURIService = + Components.classes["@mozilla.org/intl/texttosuburi;1"] + .getService(Components.interfaces.nsITextToSubURI); } var findbarObserver = { @@ -366,6 +371,29 @@ function fireKeypressEvent(target, evt) target.dispatchEvent(event); } +function updateStatusBar() +{ + var xulBrowserWindow = window.XULBrowserWindow; + if (!xulBrowserWindow) + return false; + + if (!gFoundLink || !gFoundLink.href || gFoundLink.href == "") { + xulBrowserWindow.setOverLink(""); + return true; + } + + var docCharset = ""; + var ownerDoc = gFoundLink.ownerDocument; + if (ownerDoc) + docCharset = ownerDoc.characterSet; + + var url = + gTextToSubURIService.unEscapeURIForUI(docCharset, gFoundLink.href); + xulBrowserWindow.setOverLink(url); + + return true; +} + function setFoundLink(foundLink) { if (gFoundLink == foundLink) @@ -389,6 +417,13 @@ function setFoundLink(foundLink) } gFoundLink = foundLink; + + // We should update status bar. But we need delay. If the mouse cursor is + // on the document, the status bar text is changed by mouse event that is + // fired by scroll event. So, we need to change the status bar text after + // mouse event. + if (gFindMode != FIND_NORMAL) + setTimeout(updateStatusBar, 0); } function finishFAYT(aKeypressEvent)