Fix some nits.

This commit is contained in:
Brendan Dahl 2012-02-07 17:54:40 -08:00
parent b867aa9922
commit fb31dc3f86

View File

@ -22,18 +22,24 @@ function log(aMsg) {
Services.console.logStringMessage(msg); Services.console.logStringMessage(msg);
dump(msg + '\n'); dump(msg + '\n');
} }
function getWindow(top, id) top.QueryInterface(Ci.nsIInterfaceRequestor) function getWindow(top, id) {
.getInterface(Ci.nsIDOMWindowUtils) return top.QueryInterface(Ci.nsIInterfaceRequestor)
.getOuterWindowWithId(id); .getInterface(Ci.nsIDOMWindowUtils)
function windowID(win) win.QueryInterface(Ci.nsIInterfaceRequestor) .getOuterWindowWithId(id);
.getInterface(Ci.nsIDOMWindowUtils) }
.outerWindowID; function windowID(win) {
function topWindow(win) win.QueryInterface(Ci.nsIInterfaceRequestor) return win.QueryInterface(Ci.nsIInterfaceRequestor)
.getInterface(Ci.nsIWebNavigation) .getInterface(Ci.nsIDOMWindowUtils)
.QueryInterface(Ci.nsIDocShellTreeItem) .outerWindowID;
.rootTreeItem }
.QueryInterface(Ci.nsIInterfaceRequestor) function topWindow(win) {
.getInterface(Ci.nsIDOMWindow); return win.QueryInterface(Ci.nsIInterfaceRequestor)
.getInterface(Ci.nsIWebNavigation)
.QueryInterface(Ci.nsIDocShellTreeItem)
.rootTreeItem
.QueryInterface(Ci.nsIInterfaceRequestor)
.getInterface(Ci.nsIDOMWindow);
}
let application = Cc['@mozilla.org/fuel/application;1'] let application = Cc['@mozilla.org/fuel/application;1']
.getService(Ci.fuelIApplication); .getService(Ci.fuelIApplication);
let privateBrowsing = Cc['@mozilla.org/privatebrowsing;1'] let privateBrowsing = Cc['@mozilla.org/privatebrowsing;1']
@ -150,8 +156,8 @@ PdfStreamConverter.prototype = {
// an event listener on that window for the pdf.js events that require // an event listener on that window for the pdf.js events that require
// chrome priviledges. Code snippet from John Galt. // chrome priviledges. Code snippet from John Galt.
let window = aRequest.loadGroup.groupObserver let window = aRequest.loadGroup.groupObserver
.QueryInterface(Ci.nsIWebProgress) .QueryInterface(Ci.nsIWebProgress)
.DOMWindow; .DOMWindow;
let top = topWindow(window); let top = topWindow(window);
let id = windowID(window); let id = windowID(window);
window = null; window = null;
@ -161,14 +167,14 @@ PdfStreamConverter.prototype = {
let win = doc.defaultView; let win = doc.defaultView;
if (id == windowID(win)) { if (id == windowID(win)) {
top.removeEventListener('DOMWindowCreated', onDOMWinCreated, true); top.removeEventListener('DOMWindowCreated', onDOMWinCreated, true);
if (!doc.documentURIObject.equals(aRequest.URI)) if (!doc.documentURIObject.equals(aRequest.URI))
return; return;
let requestListener = new RequestListener(new ChromeActions); let requestListener = new RequestListener(new ChromeActions);
win.addEventListener(PDFJS_EVENT_ID, function(event) { win.addEventListener(PDFJS_EVENT_ID, function(event) {
requestListener.receive(event); requestListener.receive(event);
}, false, true); }, false, true);
} else if (!getWindow(top, id)) { } else if (!getWindow(top, id)) {
top.removeEventListener('DOMWindowCreated', onDOMWinCreated, true); top.removeEventListener('DOMWindowCreated', onDOMWinCreated, true);
} }