From e81012e370b100240c1b57b4e591c330d1035cf9 Mon Sep 17 00:00:00 2001 From: "sgehani%netscape.com" Date: Thu, 15 Nov 2001 02:01:10 +0000 Subject: [PATCH] Don't build search results when search panel isn't open and auto open search panel isn't set. b=91168; r=morse,jruderman; sr=alecf --- xpfe/browser/resources/content/navigator.js | 27 ++++++++++++++----- .../sidebar/resources/sidebarOverlay.js | 6 +++++ 2 files changed, 26 insertions(+), 7 deletions(-) diff --git a/xpfe/browser/resources/content/navigator.js b/xpfe/browser/resources/content/navigator.js index 4cd1c85487f..69b0535d522 100644 --- a/xpfe/browser/resources/content/navigator.js +++ b/xpfe/browser/resources/content/navigator.js @@ -129,16 +129,21 @@ function UpdateInternetSearchResults(event) var url = _content.location.href; if (url) { try { - var search = Components.classes["@mozilla.org/rdf/datasource;1?name=internetsearch"] - .getService(Components.interfaces.nsIInternetSearchService); + var autoOpenSearchPanel = + pref.getBoolPref("browser.search.opensidebarsearchpanel"); - var searchInProgressFlag = search.FindInternetSearchResults(url); + if (autoOpenSearchPanel || isSearchPanelOpen()) + { + var search = Components. + classes["@mozilla.org/rdf/datasource;1?name=internetsearch"]. + getService(Components.interfaces.nsIInternetSearchService); - if (searchInProgressFlag) { - var autoOpenSearchPanel = pref.getBoolPref("browser.search.opensidebarsearchpanel"); + var searchInProgressFlag = search.FindInternetSearchResults(url); - if (autoOpenSearchPanel) - RevealSearchPanel(); + if (searchInProgressFlag) { + if (autoOpenSearchPanel) + RevealSearchPanel(); + } } } catch (ex) { } @@ -797,6 +802,14 @@ function RevealSearchPanel() SidebarSelectPanel(searchPanel, true, true); // lives in sidebarOverlay.js } +function isSearchPanelOpen() +{ + return ( !sidebar_is_hidden() && + !sidebar_is_collapsed() && + SidebarGetLastSelectedPanel() == "urn:sidebar:panel:search" + ); +} + //Note: BrowserNewEditorWindow() was moved to globalOverlay.xul and renamed to NewEditorWindow() function BrowserOpenWindow() diff --git a/xpfe/components/sidebar/resources/sidebarOverlay.js b/xpfe/components/sidebar/resources/sidebarOverlay.js index 8bae3dce58b..3808cd18aa5 100644 --- a/xpfe/components/sidebar/resources/sidebarOverlay.js +++ b/xpfe/components/sidebar/resources/sidebarOverlay.js @@ -760,6 +760,12 @@ function SidebarSelectPanel(header, should_popopen, should_unhide) { return true; } +function SidebarGetLastSelectedPanel() +{ + return (sidebarObj.panels && + sidebarObj.panels.node.getAttribute('last-selected-panel')); +} + function SidebarStopPanelLoad(header) { var panel = sidebarObj.panels.get_panel_from_header_node(header); panel.stop_load();