Bug 1397448: Part 6 - Cache messageManager for MessageManagerProxy. r=mixedpuppy

MozReview-Commit-ID: 7eqSgBkrj4f

--HG--
extra : rebase_source : 4541d5af94af4e219b2435da9485ce5530f0fab1
This commit is contained in:
Kris Maglione 2017-09-08 21:36:00 -07:00
Родитель c2a6f79739
Коммит f9e2e7cfbc
1 изменённых файлов: 8 добавлений и 15 удалений

Просмотреть файл

@ -489,11 +489,7 @@ class MessageManagerProxy {
this.listeners = new DefaultMap(() => new Map());
if (target instanceof Ci.nsIMessageSender) {
Object.defineProperty(this, "messageManager", {
value: target,
configurable: true,
writable: true,
});
this.messageManager = target;
} else {
this.addListeners(target);
}
@ -511,9 +507,8 @@ class MessageManagerProxy {
if (this.eventTarget) {
this.removeListeners(this.eventTarget);
this.eventTarget = null;
} else {
this.messageManager = null;
}
this.messageManager = null;
}
/**
@ -541,9 +536,6 @@ class MessageManagerProxy {
* may change during the life of the proxy object, so should
* not be stored elsewhere.
*/
get messageManager() {
return this.eventTarget && this.eventTarget.messageManager;
}
/**
* Sends a message on the proxied message manager.
@ -622,11 +614,12 @@ class MessageManagerProxy {
addListeners(target) {
target.addEventListener("SwapDocShells", this);
for (let {message, listener, listenWhenClosed} of this.iterListeners()) {
target.addMessageListener(message, listener, listenWhenClosed);
}
this.eventTarget = target;
this.messageManager = target.messageManager;
for (let {message, listener, listenWhenClosed} of this.iterListeners()) {
this.messageManager.addMessageListener(message, listener, listenWhenClosed);
}
}
/**
@ -640,7 +633,7 @@ class MessageManagerProxy {
target.removeEventListener("SwapDocShells", this);
for (let {message, listener} of this.iterListeners()) {
target.removeMessageListener(message, listener);
this.messageManager.removeMessageListener(message, listener);
}
}