From 475da7edd91f66b9c8c23485b56fc37ac43b9efe Mon Sep 17 00:00:00 2001 From: Kris Maglione Date: Wed, 2 Feb 2011 16:21:57 -0500 Subject: [PATCH] Use a better document iterator for applying overlays so that we can overlay documents in tabs as well. --- common/modules/util.jsm | 25 +++++++++++++++++++++---- pentadactyl/content/disable-acr.jsm | 12 +++++++----- 2 files changed, 28 insertions(+), 9 deletions(-) diff --git a/common/modules/util.jsm b/common/modules/util.jsm index 6d16de46..cfb422e9 100644 --- a/common/modules/util.jsm +++ b/common/modules/util.jsm @@ -860,6 +860,23 @@ var Util = Module("Util", XPCOM([Ci.nsIObserver, Ci.nsISupportsWeakReference]), return style.visibility == "visible" && style.display != "none"; }, + /** + * Iterates over all currently open documents, including all + * top-level window and sub-frames thereof. + */ + iterDocuments: function iterDocuments() { + let windows = services.windowMediator.getXULWindowEnumerator(null); + while (windows.hasMoreElements()) { + let window = windows.getNext().QueryInterface(Ci.nsIXULWindow); + for each (let type in ["typeChrome", "typeContent"]) { + let docShells = window.docShell.getDocShellEnumerator(Ci.nsIDocShellTreeItem[type], + Ci.nsIDocShell.ENUMERATE_FORWARDS); + while (docShells.hasMoreElements()) + yield docShells.getNext().QueryInterface(Ci.nsIDocShell).contentViewer.DOMDocument; + } + } + }, + /** * Returns an XPath union expression constructed from the specified node * tests. An expression is built with node tests for both the null and @@ -1149,11 +1166,11 @@ var Util = Module("Util", XPCOM([Ci.nsIObserver, Ci.nsISupportsWeakReference]), this.overlays[url].push(fn); }, this); - for (let win in iter(services.windowMediator.getEnumerator(null))) - if (["interactive", "complete"].indexOf(win.document.readyState) >= 0) - this._loadOverlays(win); + for (let doc in util.iterDocuments()) + if (["interactive", "complete"].indexOf(doc.readyState) >= 0) + this._loadOverlays(doc.defaultView); else - this.observe(win, "toplevel-window-ready"); + this.observe(doc.defaultView, "toplevel-window-ready"); } }, diff --git a/pentadactyl/content/disable-acr.jsm b/pentadactyl/content/disable-acr.jsm index 943585f7..f5ebe74b 100644 --- a/pentadactyl/content/disable-acr.jsm +++ b/pentadactyl/content/disable-acr.jsm @@ -52,13 +52,15 @@ function checkDocument(doc, disable, force) { } function chromeDocuments() { - let windows = Services.ww.getXULWindowEnumerator(null); + let windows = services.windowMediator.getXULWindowEnumerator(null); while (windows.hasMoreElements()) { let window = windows.getNext().QueryInterface(Ci.nsIXULWindow); - let docShells = window.docShell.getDocShellEnumerator(Ci.nsIDocShell.typeChrome, - Ci.nsIDocShell.ENUMERATE_FORWARDS); - while (docShells.hasMoreElements()) - yield docShells.getNext().containedDocShells.DOMDocument; + for each (let type in ["typeChrome", "typeContent"]) { + let docShells = window.docShell.getDocShellEnumerator(Ci.nsIDocShellTreeItem[type], + Ci.nsIDocShell.ENUMERATE_FORWARDS); + while (docShells.hasMoreElements()) + yield docShells.getNext().QueryInterface(Ci.nsIDocShell).contentViewer.DOMDocument; + } } }