Bug 596621 - findbar - need to indicate when no matches found [r=vingtetun]
authorWesley Johnston <wjohnston@mozilla.com>
Tue, 19 Oct 2010 00:20:04 +0200
changeset 2217 778ccd0db26992be61e27c45bd7a271b6968b0c1
parent 2216 03a6e97b5b21a274b0f2f301fc463bb3cb53506a
child 2218 55edc5093be0c969a054784cbc118c7392ca8844
push id1871
push uservnicolas@mozilla.com
push dateMon, 18 Oct 2010 22:20:17 +0000
reviewersvingtetun
bugs596621
Bug 596621 - findbar - need to indicate when no matches found [r=vingtetun]
chrome/content/browser-ui.js
themes/core/browser.css
--- a/chrome/content/browser-ui.js
+++ b/chrome/content/browser-ui.js
@@ -1646,16 +1646,30 @@ var BookmarkHelper = {
 var FindHelperUI = {
   type: "find",
   commands: {
     next: "cmd_findNext",
     previous: "cmd_findPrevious",
     close: "cmd_findClose"
   },
 
+  _status: null,
+
+  get status() {
+    return this._status;
+  },
+
+  set status(val) {
+    if (val != this._status) {
+      this._status = val;
+      this._textbox.setAttribute("status", val);
+      this.updateCommands(this._textbox.value);
+    }
+  },
+
   init: function findHelperInit() {
     this._textbox = document.getElementById("find-helper-textbox");
     this._container = document.getElementById("content-navigator");
 
     this._cmdPrevious = document.getElementById(this.commands.previous);
     this._cmdNext = document.getElementById(this.commands.next);
 
     // Listen for form assistant messages from content
@@ -1666,16 +1680,17 @@ var FindHelperUI = {
     document.getElementById("tabs").addEventListener("TabSelect", this, true);
     Elements.browsers.addEventListener("URLChanged", this, true);
   },
 
   receiveMessage: function findHelperReceiveMessage(aMessage) {
     let json = aMessage.json;
     switch(aMessage.name) {
       case "FindAssist:Show":
+        this.status = json.result;
         if (json.rect)
           this._zoom(Rect.fromRect(json.rect));
         break;
 
       case "FindAssist:Hide":
         if (this._container.getAttribute("type") == this.type)
           this.hide();
         break;
@@ -1708,18 +1723,19 @@ var FindHelperUI = {
   },
 
   search: function findHelperSearch(aValue) {
     this.updateCommands(aValue);
     Browser.selectedBrowser.messageManager.sendAsyncMessage("FindAssist:Find", { searchString: aValue });
   },
 
   updateCommands: function findHelperUpdateCommands(aValue) {
-    this._cmdPrevious.setAttribute("disabled", aValue == "");
-    this._cmdNext.setAttribute("disabled", aValue == "");
+    let disabled = (this._status == Ci.nsITypeAheadFind.FIND_NOTFOUND) || (aValue == "");
+    this._cmdPrevious.setAttribute("disabled", disabled);
+    this._cmdNext.setAttribute("disabled", disabled);
   },
 
   _zoom: function _findHelperZoom(aElementRect) {
     // Zoom to a specified Rect
     if (aElementRect && Browser.selectedTab.allowZoom && Services.prefs.getBoolPref("findhelper.autozoom")) {
       let zoomLevel = Browser._getZoomLevelForRect(aElementRect);
       zoomLevel = Math.min(Math.max(kBrowserFormZoomLevelMin, zoomLevel), kBrowserFormZoomLevelMax);
 
--- a/themes/core/browser.css
+++ b/themes/core/browser.css
@@ -1214,16 +1214,20 @@ pageaction:hover:active > vbox > .pageac
 
 /* navigator popup -------------------------------------------------------------- */
 #content-navigator,
 #content-navigator > #select-container > #select-spacer,
 #content-navigator > #select-container > #select-container-inner > #select-buttons {
   display: none;
 }
 
+#find-helper-textbox[status="1"] { /* Ci.nsITypeAheadFind.FIND_NOTFOUND */
+  background-color: rgb(255,200,200);
+}
+
 #content-navigator[type="find"],
 #content-navigator[type="form"] {
   display: -moz-box;
 }
 
 #content-navigator:not([type="form"]) > #form-helper-autofill {
   visibility: collapse;
 }