зеркало из https://github.com/mozilla/gecko-dev.git
Bug 722428: Sprinkle weakref pixie dust on SpecialPowers to avoid leaks until shutdown. r=ctalbert
This commit is contained in:
Родитель
11d39393ec
Коммит
fe8c4a07f7
|
@ -39,7 +39,7 @@
|
|||
*/
|
||||
|
||||
function SpecialPowers(window) {
|
||||
this.window = window;
|
||||
this.window = Components.utils.getWeakReference(window);
|
||||
this._encounteredCrashDumpFiles = [];
|
||||
this._unexpectedCrashDumpFiles = { };
|
||||
this._crashDumpDir = null;
|
||||
|
|
|
@ -63,6 +63,7 @@ function bindDOMWindowUtils(aWindow) {
|
|||
|
||||
var util = aWindow.QueryInterface(Components.interfaces.nsIInterfaceRequestor)
|
||||
.getInterface(Components.interfaces.nsIDOMWindowUtils);
|
||||
var weakUtil = Components.utils.getWeakReference(util);
|
||||
// This bit of magic brought to you by the letters
|
||||
// B Z, and E, S and the number 5.
|
||||
//
|
||||
|
@ -77,7 +78,10 @@ function bindDOMWindowUtils(aWindow) {
|
|||
if (prop in desc && typeof(desc[prop]) == "function") {
|
||||
var oldval = desc[prop];
|
||||
try {
|
||||
desc[prop] = function() { return oldval.apply(util, arguments); };
|
||||
desc[prop] = function() {
|
||||
utils = weakUtil.get();
|
||||
return oldval.apply(utils, arguments);
|
||||
};
|
||||
} catch (ex) {
|
||||
dump("WARNING: Special Powers failed to rebind function: " + desc + "::" + prop + "\n");
|
||||
}
|
||||
|
@ -426,7 +430,7 @@ SpecialPowersAPI.prototype = {
|
|||
},
|
||||
|
||||
getDOMWindowUtils: function(aWindow) {
|
||||
if (aWindow == this.window && this.DOMWindowUtils != null)
|
||||
if (aWindow == this.window.get() && this.DOMWindowUtils != null)
|
||||
return this.DOMWindowUtils;
|
||||
|
||||
return bindDOMWindowUtils(aWindow);
|
||||
|
@ -814,7 +818,7 @@ SpecialPowersAPI.prototype = {
|
|||
},
|
||||
|
||||
snapshotWindow: function (win, withCaret) {
|
||||
var el = this.window.document.createElementNS("http://www.w3.org/1999/xhtml", "canvas");
|
||||
var el = this.window.get().document.createElementNS("http://www.w3.org/1999/xhtml", "canvas");
|
||||
el.width = win.innerWidth;
|
||||
el.height = win.innerHeight;
|
||||
var ctx = el.getContext("2d");
|
||||
|
@ -1029,7 +1033,7 @@ SpecialPowersAPI.prototype = {
|
|||
},
|
||||
|
||||
snapshotWindow: function (win, withCaret) {
|
||||
var el = this.window.document.createElementNS("http://www.w3.org/1999/xhtml", "canvas");
|
||||
var el = this.window.get().document.createElementNS("http://www.w3.org/1999/xhtml", "canvas");
|
||||
el.width = win.innerWidth;
|
||||
el.height = win.innerHeight;
|
||||
var ctx = el.getContext("2d");
|
||||
|
|
Загрузка…
Ссылка в новой задаче