mirror of
https://github.com/gryf/pentadactyl-pm.git
synced 2026-02-28 11:55:46 +01:00
Use a better document iterator for applying overlays so that we can overlay documents in tabs as well.
This commit is contained in:
@@ -860,6 +860,23 @@ var Util = Module("Util", XPCOM([Ci.nsIObserver, Ci.nsISupportsWeakReference]),
|
|||||||
return style.visibility == "visible" && style.display != "none";
|
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
|
* Returns an XPath union expression constructed from the specified node
|
||||||
* tests. An expression is built with node tests for both the null and
|
* 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.overlays[url].push(fn);
|
||||||
}, this);
|
}, this);
|
||||||
|
|
||||||
for (let win in iter(services.windowMediator.getEnumerator(null)))
|
for (let doc in util.iterDocuments())
|
||||||
if (["interactive", "complete"].indexOf(win.document.readyState) >= 0)
|
if (["interactive", "complete"].indexOf(doc.readyState) >= 0)
|
||||||
this._loadOverlays(win);
|
this._loadOverlays(doc.defaultView);
|
||||||
else
|
else
|
||||||
this.observe(win, "toplevel-window-ready");
|
this.observe(doc.defaultView, "toplevel-window-ready");
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|||||||
@@ -52,13 +52,15 @@ function checkDocument(doc, disable, force) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function chromeDocuments() {
|
function chromeDocuments() {
|
||||||
let windows = Services.ww.getXULWindowEnumerator(null);
|
let windows = services.windowMediator.getXULWindowEnumerator(null);
|
||||||
while (windows.hasMoreElements()) {
|
while (windows.hasMoreElements()) {
|
||||||
let window = windows.getNext().QueryInterface(Ci.nsIXULWindow);
|
let window = windows.getNext().QueryInterface(Ci.nsIXULWindow);
|
||||||
let docShells = window.docShell.getDocShellEnumerator(Ci.nsIDocShell.typeChrome,
|
for each (let type in ["typeChrome", "typeContent"]) {
|
||||||
Ci.nsIDocShell.ENUMERATE_FORWARDS);
|
let docShells = window.docShell.getDocShellEnumerator(Ci.nsIDocShellTreeItem[type],
|
||||||
while (docShells.hasMoreElements())
|
Ci.nsIDocShell.ENUMERATE_FORWARDS);
|
||||||
yield docShells.getNext().containedDocShells.DOMDocument;
|
while (docShells.hasMoreElements())
|
||||||
|
yield docShells.getNext().QueryInterface(Ci.nsIDocShell).contentViewer.DOMDocument;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user