1
0
mirror of https://github.com/gryf/pentadactyl-pm.git synced 2026-01-21 23:24:12 +01:00

Add util.iterFrames.

This commit is contained in:
Doug Kearns
2015-07-06 23:55:51 +10:00
parent 58faec7655
commit 85eede1ee2
2 changed files with 24 additions and 19 deletions

View File

@@ -363,17 +363,13 @@ var Buffer = Module("Buffer", {
/**
* Returns a list of all frames in the given window or current buffer.
*/
allFrames: function allFrames(win, focusedFirst) {
let frames = [];
(function rec(frame) {
if (true || frame.document.body instanceof Ci.nsIDOMHTMLBodyElement)
frames.push(frame);
Array.forEach(frame.frames, rec);
})(win || this.win);
allFrames: function allFrames(win=this.win, focusedFirst) {
let frames = iter(util.iterFrames(win)).toArray();
if (focusedFirst)
return frames.filter(f => f === this.focusedFrame).concat(
frames.filter(f => f !== this.focusedFrame));
return frames;
},
@@ -2337,7 +2333,7 @@ var Buffer = Module("Buffer", {
if (count >= 1 || !elem || !events.isContentNode(elem)) {
let xpath = ["frame", "iframe", "input", "xul:textbox", "textarea[not(@disabled) and not(@readonly)]"];
let frames = buffer.allFrames(null, true);
let frames = buffer.allFrames(undefined, true);
let elements = Ary.flatten(frames.map(win => [m for (m of DOM.XPath(xpath, win.document))]))
.filter(function (elem) {