Bug 842762: Uplift Add-on SDK changeset 4e44dd094e8636216e8c9ca5664866a5cf7d0cdd

a16bbd5772...4e44dd094e
This commit is contained in:
Dave Townsend
2013-02-19 14:14:54 -08:00
parent b21d195aac
commit 1be39049f5
74 changed files with 1338 additions and 496 deletions

View File

@@ -20,7 +20,7 @@ const { Ci, Cc } = require("chrome"),
{ when: unload } = require("./system/unload"),
{ getTabs, getTabContentWindow, getTabForContentWindow,
getAllTabContentWindows } = require('./tabs/utils'),
{ getInnerId, getMostRecentBrowserWindow,
{ getMostRecentBrowserWindow,
windows, getFocusedWindow, getFocusedElement } = require("./window/utils"),
events = require("./system/events");
@@ -321,17 +321,6 @@ 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);
}
});
};
/**
@@ -382,7 +371,7 @@ getAllTabContentWindows().forEach(addSelectionListener);
//
// See bug 665386 for further details.
events.on("document-shown", function (event) {
function onShown(event) {
let window = event.subject.defaultView;
// We are not interested in documents without valid defaultView.
@@ -408,17 +397,21 @@ events.on("document-shown", function (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);
});