Skip to content

Commit

Permalink
Bug 877627 - [Contacts][Dialer] Dialer doesn't show on screen when la…
Browse files Browse the repository at this point in the history
…unching from contacts. r=fabrice,shianyow a=tef+
  • Loading branch information
airpingu committed May 31, 2013
1 parent 74e4d47 commit 7d56abd
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 10 deletions.
44 changes: 34 additions & 10 deletions dom/messages/SystemMessageInternal.js
Expand Up @@ -243,7 +243,17 @@ SystemMessageInternal.prototype = {
return -1;
},

_removeTargetFromListener: function _removeTargetFromListener(aTarget, aManifest, aRemoveListener) {
_isEmptyObject: function _isEmptyObject(aObj) {
for (let name in aObj) {
return false;
}
return true;
},

_removeTargetFromListener: function _removeTargetFromListener(aTarget,
aManifest,
aRemoveListener,
aUri) {
let targets = this._listeners[aManifest];
if (!targets) {
return false;
Expand All @@ -260,7 +270,13 @@ SystemMessageInternal.prototype = {
return true;
}

if (--targets[index].winCount === 0) {
let target = targets[index];
if (aUri && target.winCounts[aUri] !== undefined &&
--target.winCounts[aUri] === 0) {
delete target.winCounts[aUri];
}

if (this._isEmptyObject(target.winCounts)) {
if (targets.length === 1) {
// If it's the only one, get rid of this manifest entirely.
debug("remove the listener for " + aManifest);
Expand Down Expand Up @@ -297,17 +313,25 @@ SystemMessageInternal.prototype = {
case "SystemMessageManager:Register":
{
debug("Got Register from " + msg.uri + " @ " + msg.manifest);
let uri = msg.uri;
let targets, index;
if (!(targets = this._listeners[msg.manifest])) {
let winCounts = {};
winCounts[uri] = 1;
this._listeners[msg.manifest] = [{ target: aMessage.target,
uri: msg.uri,
winCount: 1 }];
winCounts: winCounts }];
} else if ((index = this._findTargetIndex(targets, aMessage.target)) === -1) {
let winCounts = {};
winCounts[uri] = 1;
targets.push({ target: aMessage.target,
uri: msg.uri,
winCount: 1 });
winCounts: winCounts });
} else {
targets[index].winCount++;
let winCounts = targets[index].winCounts;
if (winCounts[uri] === undefined) {
winCounts[uri] = 1;
} else {
winCounts[uri]++;
}
}

debug("listeners for " + msg.manifest + " innerWinID " + msg.innerWindowID);
Expand All @@ -318,7 +342,7 @@ SystemMessageInternal.prototype = {
debug("Got child-process-shutdown from " + aMessage.target);
for (let manifest in this._listeners) {
// See if any processes in this manifest have this target.
if (this._removeTargetFromListener(aMessage.target, manifest, true)) {
if (this._removeTargetFromListener(aMessage.target, manifest, true, null)) {
break;
}
}
Expand All @@ -327,7 +351,7 @@ SystemMessageInternal.prototype = {
case "SystemMessageManager:Unregister":
{
debug("Got Unregister from " + aMessage.target + "innerWinID " + msg.innerWindowID);
this._removeTargetFromListener(aMessage.target, msg.manifest, false);
this._removeTargetFromListener(aMessage.target, msg.manifest, false, msg.uri);
break;
}
case "SystemMessageManager:GetPendingMessages":
Expand Down Expand Up @@ -521,7 +545,7 @@ SystemMessageInternal.prototype = {
let target = targets[index];
// We only need to send the system message to the targets which match
// the manifest URL and page URL of the destination of system message.
if (target.uri != aPageURI) {
if (target.winCounts[aPageURI] === undefined) {
continue;
}

Expand Down
1 change: 1 addition & 0 deletions dom/messages/SystemMessageManager.js
Expand Up @@ -144,6 +144,7 @@ SystemMessageManager.prototype = {

cpmm.sendAsyncMessage("SystemMessageManager:Unregister",
{ manifest: this._manifest,
uri: this._uri,
innerWindowID: this.innerWindowID });
},

Expand Down

0 comments on commit 7d56abd

Please sign in to comment.