author | Carsten "Tomcat" Book <cbook@mozilla.com> |
Wed, 20 Jul 2016 16:50:13 +0200 | |
changeset 305844 | ee1973d27f13e5adc7d41a8917c097266ec907b7 |
parent 305812 | ed8e23b5e0c7b739e61173bb180cf3410a306679 |
child 305850 | 03269dd72a7259f582977714559f0f4ef19988aa |
push id | 79681 |
push user | cbook@mozilla.com |
push date | Wed, 20 Jul 2016 14:56:17 +0000 |
treeherder | mozilla-inbound@f90a9f8af37c [default view] [failures only] |
perfherder | [talos] [build metrics] [platform microbench] (compared to previous push) |
bugs | 1286389 |
milestone | 50.0a1 |
backs out | 3696a22ff7a09bcc27296c0a5648e2e9afd32f67 |
first release with | nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
|
last release without | nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
|
--- 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>