mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-28 07:13:20 +00:00
Bug 1249226 - Use weak reference to keep popup's previous focus to avoid leak. r=neil
MozReview-Commit-ID: 8VUexyKMbJr
This commit is contained in:
parent
7b72d7a595
commit
92314af9cb
@ -285,12 +285,13 @@
|
||||
<handler event="popupshowing"><![CDATA[
|
||||
// Capture the previous focus before has a chance to get set inside the panel
|
||||
try {
|
||||
this._prevFocus = document.commandDispatcher.focusedElement;
|
||||
if (this._prevFocus)
|
||||
this._prevFocus = Components.utils
|
||||
.getWeakReference(document.commandDispatcher.focusedElement);
|
||||
if (this._prevFocus.get())
|
||||
return;
|
||||
} catch (ex) { }
|
||||
|
||||
this._prevFocus = document.activeElement;
|
||||
this._prevFocus = Components.utils.getWeakReference(document.activeElement);
|
||||
]]></handler>
|
||||
<handler event="popupshown"><![CDATA[
|
||||
// Fire event for accessibility APIs
|
||||
@ -307,7 +308,7 @@
|
||||
]]></handler>
|
||||
<handler event="popuphidden"><![CDATA[
|
||||
var currentFocus = this._currentFocus;
|
||||
var prevFocus = this._prevFocus;
|
||||
var prevFocus = this._prevFocus ? this._prevFocus.get() : null;
|
||||
this._currentFocus = null;
|
||||
this._prevFocus = null;
|
||||
if (prevFocus && currentFocus && this.getAttribute("norestorefocus") != "true") {
|
||||
|
Loading…
Reference in New Issue
Block a user