Bug 705452 BrowserSearch.loadSearch() uses the current search engine if the search sidebar is selected even if the sidebar itself is hidden r=Neil a=Callek. BETA_9_END
authorPhilip Chee <philip.chee@gmail.com>
Tue, 20 Dec 2011 17:12:36 +0800
changeset 9419 2c0b8d3bac143dc81c3d464678527fbb77c7508a
parent 9418 7f569c0b46bef0b687202c3d690b5f4690eee84b
child 9420 4cb7e5e4cc734aef91a131293b4700de9709eb04
push id280
push userphilip.chee@gmail.com
push dateTue, 20 Dec 2011 14:57:08 +0000
treeherdercomm-beta@2c0b8d3bac14 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersNeil, Callek
bugs705452
Bug 705452 BrowserSearch.loadSearch() uses the current search engine if the search sidebar is selected even if the sidebar itself is hidden r=Neil a=Callek.
suite/browser/navigator.js
suite/common/nsContextMenu.js
--- a/suite/browser/navigator.js
+++ b/suite/browser/navigator.js
@@ -1137,17 +1137,17 @@ const BrowserSearch = {
         }
         return;
       }
     }
 
     if (isElementVisible(this.searchBar)) {
       this.searchBar.select();
       this.searchBar.focus();
-    } else if (isElementVisible(this.searchSidebar)) {
+    } else if (this.searchSidebar) {
       this.searchSidebar.focus();
     } else {
       loadURI(Services.search.defaultEngine.searchForm);
       window.content.focus();
     }
   },
 
   /**
@@ -1166,17 +1166,17 @@ const BrowserSearch = {
    *        The event object passed from the caller.
    */
   loadSearch: function BrowserSearch_search(aSearchText, aNewWindowOrTab, aEvent) {
     var engine;
 
     // If the search bar is visible, use the current engine, otherwise, fall
     // back to the default engine.
     if (isElementVisible(this.searchBar) ||
-        isElementVisible(this.searchSidebar))
+        this.searchSidebar)
       engine = Services.search.currentEngine;
     else
       engine = Services.search.defaultEngine;
 
     var submission = engine.getSubmission(aSearchText); // HTML response
 
     // getSubmission can return null if the engine doesn't have a URL
     // with a text/html response type.  This is unlikely (since
@@ -1206,22 +1206,24 @@ const BrowserSearch = {
   /**
    * Returns the search bar element if it is present in the toolbar, null otherwise.
    */
   get searchBar() {
     return document.getElementById("searchbar");
   },
 
   /**
-   * Returns the search sidebar element if it is present in the toolbar, null otherwise.
+   * Returns the search sidebar textbox if the search sidebar is present in
+   * the sidebar and selected, null otherwise.
    */
   get searchSidebar() {
     var panel = sidebarObj.panels.get_panel_from_id("urn:sidebar:panel:search");
-    return panel &&
-       panel.get_iframe().contentDocument.getElementById("sidebar-search-text");
+    return panel && isElementVisible(panel.get_iframe()) &&
+           panel.get_iframe()
+                .contentDocument.getElementById("sidebar-search-text");
   },
 
   loadAddEngines: function BrowserSearch_loadAddEngines() {
     loadAddSearchEngines(); // for compatibility
   },
 
   /**
    * Reveal the search sidebar panel.
--- a/suite/common/nsContextMenu.js
+++ b/suite/common/nsContextMenu.js
@@ -1227,17 +1227,19 @@ nsContextMenu.prototype = {
       return false;
 
     if (searchSelectText.length > 15)
       searchSelectText = searchSelectText.substr(0, 15) + this.ellipsis;
 
     // Use the current engine if it's a browser window and the search bar is
     // visible, the default engine otherwise.
     var engineName = "";
-    if (window.BrowserSearch && isElementVisible(BrowserSearch.searchBar))
+    if (window.BrowserSearch &&
+        (isElementVisible(BrowserSearch.searchBar) ||
+         BrowserSearch.searchSidebar))
       engineName = Services.search.currentEngine.name;
     else
       engineName = Services.search.defaultEngine.name;
 
     // format "Search <engine> for <selection>" string to show in menu
     const bundle = document.getElementById("contentAreaCommandsBundle");
     var menuLabel = bundle.getFormattedString("contextMenuSearchText",
                                               [engineName, searchSelectText]);