Backed out changeset 3696a22ff7a0 (bug 1286389) for frequent dt2 linux debug failures
authorCarsten "Tomcat" Book <cbook@mozilla.com>
Wed, 20 Jul 2016 16:50:13 +0200
changeset 330864 ee1973d27f13e5adc7d41a8917c097266ec907b7
parent 330863 ed8e23b5e0c7b739e61173bb180cf3410a306679
child 330870 03269dd72a7259f582977714559f0f4ef19988aa
push id9858
push userjlund@mozilla.com
push dateMon, 01 Aug 2016 14:37:10 +0000
treeherdermozilla-aurora@203106ef6cb6 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs1286389
milestone50.0a1
backs out3696a22ff7a09bcc27296c0a5648e2e9afd32f67
Backed out changeset 3696a22ff7a0 (bug 1286389) for frequent dt2 linux debug failures
toolkit/content/widgets/popup.xml
--- a/toolkit/content/widgets/popup.xml
+++ b/toolkit/content/widgets/popup.xml
@@ -311,45 +311,37 @@
       <handler event="popuphiding"><![CDATA[
         try {
           this._currentFocus = document.commandDispatcher.focusedElement;
         } catch (e) {
           this._currentFocus = document.activeElement;
         }
       ]]></handler>
       <handler event="popuphidden"><![CDATA[
-        function doFocus() {
-          // Focus was set on an element inside this panel,
-          // so we need to move it back to where it was previously
-          try {
-            let fm = Components.classes["@mozilla.org/focus-manager;1"]
-                               .getService(Components.interfaces.nsIFocusManager);
-            fm.setFocus(prevFocus, fm.FLAG_NOSCROLL);
-          } catch(e) {
-            prevFocus.focus();
-          }
-        }
         var currentFocus = this._currentFocus;
         var prevFocus = this._prevFocus ? this._prevFocus.get() : null;
         this._currentFocus = null;
         this._prevFocus = null;
-        if (prevFocus && this.getAttribute("norestorefocus") != "true") {
+        if (prevFocus && currentFocus && this.getAttribute("norestorefocus") != "true") {
           // Try to restore focus
           try {
             if (document.commandDispatcher.focusedWindow != window)
               return; // Focus has already been set to a window outside of this panel
           } catch(ex) {}
-
-          if (!currentFocus) {
-            doFocus();
-            return;
-          }
           while (currentFocus) {
             if (currentFocus == this) {
-              doFocus();
+              // Focus was set on an element inside this panel,
+              // so we need to move it back to where it was previously
+              try {
+                let fm = Components.classes["@mozilla.org/focus-manager;1"]
+                                   .getService(Components.interfaces.nsIFocusManager);
+                fm.setFocus(prevFocus, fm.FLAG_NOSCROLL);
+              } catch(e) {
+                prevFocus.focus();
+              }
               return;
             }
             currentFocus = currentFocus.parentNode;
           }
         }
       ]]></handler>
     </handlers>
   </binding>