Bug 629661 - Find in Page does not reset after it is closed [r=mfinkle]
authorVivien Nicolas <21@vingtetun.org>
Mon, 07 Feb 2011 13:49:37 +0100
changeset 2739 e8490e7e78192462579fbab4f5f0f4928b29f004
parent 2738 ca6ea793ee18e05c93b96cb675a940f23850a3de
child 2740 aa4eaa1f39166cfe28127ffa18d944044bfd1ea6
push id2301
push uservnicolas@mozilla.com
push dateMon, 07 Feb 2011 13:02:25 +0000
reviewersmfinkle
bugs629661
Bug 629661 - Find in Page does not reset after it is closed [r=mfinkle]
chrome/content/common-ui.js
--- a/chrome/content/common-ui.js
+++ b/chrome/content/common-ui.js
@@ -455,32 +455,40 @@ var FindHelperUI = {
 
   get status() {
     return this._status;
   },
 
   set status(val) {
     if (val != this._status) {
       this._status = val;
-      this._textbox.setAttribute("status", val);
+      if (!val)
+        this._textbox.removeAttribute("status");
+      else
+        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
     messageManager.addMessageListener("FindAssist:Show", this);
     messageManager.addMessageListener("FindAssist:Hide", this);
 
+    // Listen for composition update, some VKB that does suggestions does not
+    // update directly the content of the field but in this case we want to
+    // search as soon as something is entered in the field
+    this._textbox.addEventListener("text", this, false);
+
     // Listen for events where form assistant should be closed
     document.getElementById("tabs").addEventListener("TabSelect", this, true);
     Elements.browsers.addEventListener("URLChanged", this, true);
   },
 
   receiveMessage: function findHelperReceiveMessage(aMessage) {
     let json = aMessage.json;
     switch(aMessage.name) {
@@ -502,16 +510,25 @@ var FindHelperUI = {
       case "TabSelect":
         this.hide();
         break;
 
       case "URLChanged":
         if (aEvent.detail && aEvent.target == getBrowser())
           this.hide();
         break;
+
+      case "text":
+        if (!this._open)
+          return;
+
+        let evt = document.createEvent("Event");
+        evt.initEvent("input", true, false);
+        this._textbox.dispatchEvent(evt);
+        break;
     }
   },
 
   show: function findHelperShow() {
     this._container.show(this);
     this.search(this._textbox.value);
     this._textbox.select();
     this._textbox.focus();