Back out a104642698a0 (bug 842762) for b2g test bustage

CLOSED TREE
This commit is contained in:
Phil Ringnalda
2013-02-19 19:49:41 -08:00
parent 4e5947ff83
commit 9ce4d191b7
74 changed files with 496 additions and 1338 deletions

View File

@@ -20,7 +20,7 @@ const { Ci, Cc } = require("chrome"),
{ when: unload } = require("./system/unload"),
{ getTabs, getTabContentWindow, getTabForContentWindow,
getAllTabContentWindows } = require('./tabs/utils'),
{ getMostRecentBrowserWindow,
{ getInnerId, getMostRecentBrowserWindow,
windows, getFocusedWindow, getFocusedElement } = require("./window/utils"),
events = require("./system/events");
@@ -321,6 +321,17 @@ function addSelectionListener(window) {
window.addEventListener("select", selectionListener.onSelect, true);
selections(window).selection = selection;
let innerId = getInnerId(window);
events.on("inner-window-destroyed", function destroyed (event) {
let destroyedId = event.subject.QueryInterface(Ci.nsISupportsPRUint64).data;
if (destroyedId === innerId) {
removeSelectionListener(window);
events.off("inner-window-destroyed", destroyed);
}
});
};
/**
@@ -371,7 +382,7 @@ getAllTabContentWindows().forEach(addSelectionListener);
//
// See bug 665386 for further details.
function onShown(event) {
events.on("document-shown", function (event) {
let window = event.subject.defaultView;
// We are not interested in documents without valid defaultView.
@@ -397,21 +408,17 @@ function onShown(event) {
if (currentSelection instanceof Ci.nsISelectionPrivate &&
currentSelection !== selection) {
window.addEventListener("select", selectionListener.onSelect, true);
currentSelection.addSelectionListener(selectionListener);
selections(window).selection = currentSelection;
}
}
}
events.on("document-shown", onShown, true);
});
// Removes Selection listeners when the add-on is unloaded
unload(function(){
getAllTabContentWindows().forEach(removeSelectionListener);
events.off("document-element-inserted", onContent);
events.off("document-shown", onShown);
off(exports);
});