Bug 1187634 Fix typeaheadfind bustage from bug 113981 r=Ratty a=Ian
authorNeil Rashbrook <neil@parkwaycc.co.uk>
Fri, 14 Aug 2015 08:37:01 +0100
changeset 31198 58111896d3d0c6c6b1a76fd3f3dbbb8a9a9af59a
parent 31195 7cc9cce1a1449fc379fc628ece30e3ad640b3c51
child 31211 1be679fa13d5af0274208ee8e5b4eecb71f98ec9
push id1
push userclokep@gmail.com
push dateMon, 07 May 2018 22:45:56 +0000
treeherdercomm-esr60@57eacde5ef40 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersRatty, Ian
bugs1187634, 113981
Bug 1187634 Fix typeaheadfind bustage from bug 113981 r=Ratty a=Ian a=ewong for checkin to a CLOSED TREE
suite/browser/tabbrowser.xml
suite/common/bindings/findbar.xml
--- a/suite/browser/tabbrowser.xml
+++ b/suite/browser/tabbrowser.xml
@@ -2705,17 +2705,17 @@
                 onget="return this.mCurrentBrowser.textZoom;"
                 onset="return this.mCurrentBrowser.textZoom = val;"/>
 
       <property name="isSyntheticDocument"
                 onget="return this.mCurrentBrowser.isSyntheticDocument;"
                 readonly="true"/>
 
       <property name="messageManager"
-                onget="return this.mCurrentBrowser.messageManager;"
+                onget="return window.messageManager;"
                 readonly="true"/>
 
       <method name="observe">
         <parameter name="aSubject"/>
         <parameter name="aTopic"/>
         <parameter name="aData"/>
         <body>
           <![CDATA[
--- a/suite/common/bindings/findbar.xml
+++ b/suite/common/bindings/findbar.xml
@@ -32,19 +32,19 @@
 
         prefsvc.removeObserver("accessibility.typeaheadfind",
                                this._observer);
         prefsvc.addObserver("accessibility.typeaheadfind.autostart",
                             this._suiteObserver, false);
         prefsvc.addObserver("accessibility.typeaheadfind.usefindbar",
                             this._suiteObserver, false);
 
-        this._useTypeAheadFind =
+        this._findAsYouType =
           prefsvc.getBoolPref("accessibility.typeaheadfind.autostart");
-        this._useTypeAheadFindFindbar =
+        this._useFindbar =
           prefsvc.getBoolPref("accessibility.typeaheadfind.usefindbar");
       ]]></constructor>
 
       <field name="_suiteObserver"><![CDATA[({
         _self: this,
 
         QueryInterface: function(aIID) {
           if (aIID.equals(Components.interfaces.nsIObserver) ||
@@ -59,101 +59,74 @@
           if (aTopic != "nsPref:changed")
             return;
 
           var prefsvc =
             aSubject.QueryInterface(Components.interfaces.nsIPrefBranch);
 
           switch (aPrefName) {
             case "accessibility.typeaheadfind.autostart":
-              this._self._useTypeAheadFind = prefsvc.getBoolPref(aPrefName);
+              this._self._findAsYouType = prefsvc.getBoolPref(aPrefName);
+              this._self._updateBrowserWithState();
               break;
             case "accessibility.typeaheadfind.usefindbar":
-              this._self._useTypeAheadFindFindbar = prefsvc.getBoolPref(aPrefName);
+              this._self._useFindbar = prefsvc.getBoolPref(aPrefName);
               break;
            }
         }
       })]]></field>
 
       <!-- This is necessary because the destructor isn't called when
            we are removed from a document that is not destroyed. This
            needs to be explicitly called in this case -->
       <method name="destroy">
         <body><![CDATA[
           if (this._destroyed)
             return;
           this._destroyed = true;
 
-          // It is possible that the findbar may be destroyed before any
-          // documents it is listening to (see nsIEditActionListener code below).
-          // Thus, to avoid leaking, if we are listening to any editors, unhook
-          // ourselves now, and remove our cached copies
-          if (this._editors) {
-            for (var x = this._editors.length - 1; x >= 0; --x)
-              this._unhookListenersAtIndex(x);
-          }
-
           this.browser = null;
 
           var prefsvc =
             Components.classes["@mozilla.org/preferences-service;1"]
                       .getService(Components.interfaces.nsIPrefBranch);
           prefsvc.removeObserver("accessibility.typeaheadfind.linksonly",
                                  this._observer);
           prefsvc.removeObserver("accessibility.typeaheadfind.casesensitive",
                                  this._observer);
           prefsvc.removeObserver("accessibility.typeaheadfind.usefindbar",
                                  this._suiteObserver);
           prefsvc.removeObserver("accessibility.typeaheadfind.autostart",
                                  this._suiteObserver);
         ]]></body>
       </method>
 
-      <!--
-        - Returns whether FAYT can be used for the given event in
-        - the current content state.
-        -->
-      <method name="_shouldFastFind">
-        <parameter name="aEvent"/>
+      <method name="_updateBrowserWithState">
         <body><![CDATA[
-          if (!this._useTypeAheadFindFindbar || aEvent.ctrlKey ||
-              aEvent.altKey || aEvent.metaKey || aEvent.defaultPrevented)
-            return false;
-
-          var win = document.commandDispatcher.focusedWindow;
-          if (win)
-            if (!this._mimeTypeIsTextBased(win.document.contentType))
-              return false;
-
-          var elt = document.commandDispatcher.focusedElement;
-          if (elt) {
-            if (elt instanceof HTMLInputElement && elt.mozIsTextField(false))
-              return false;
+          window.messageManager.broadcastAsyncMessage("Findbar:UpdateState", {
+            findMode: this._findMode,
+            findAsYouType: this._findAsYouType,
+          });
+        ]]></body>
+      </method>
 
-            if (elt instanceof HTMLTextAreaElement ||
-                elt instanceof HTMLSelectElement ||
-                elt instanceof HTMLObjectElement ||
-                elt instanceof HTMLEmbedElement)
-              return false;
-          }
+      <method name="receiveMessage">
+        <parameter name="aMessage"/>
+        <body><![CDATA[
+          switch (aMessage.name) {
+            case "Findbar:Mouseup":
+              if (!this.hidden && this._findMode != this.FIND_NORMAL)
+                this.close();
+              break;
 
-          if (win) {
-            try {
-              var editingSession = win.QueryInterface(Components.interfaces.nsIInterfaceRequestor)
-                                   .getInterface(Components.interfaces.nsIWebNavigation)
-                                   .QueryInterface(Components.interfaces.nsIInterfaceRequestor)
-                                   .getInterface(Components.interfaces.nsIEditingSession);
-              if (editingSession.windowIsEditable(win))
-                return false;
-            }
-            catch (e) {
-              // If someone built with composer disabled, we can't get an editing session.
-            }
+            case "Findbar:Keypress":
+              if (this._useFindbar)
+                return this._onBrowserKeypress(aMessage.data);
+              break;
           }
-
           return true;
         ]]></body>
       </method>
 
       <method name="startFastFind">
         <parameter name="aMode"/>
         <body><![CDATA[
           if (this._findMode == aMode && this._quickFindTimeout) {