diff --git a/common/content/buffer.js b/common/content/buffer.js index c90aa6e3..ced09968 100644 --- a/common/content/buffer.js +++ b/common/content/buffer.js @@ -344,8 +344,6 @@ const Buffer = Module("buffer", { return content.dactylStore; }, - - /** * @property {Node} The last focused input field in the buffer. Used * by the "gi" key binding. @@ -439,6 +437,14 @@ const Buffer = Module("buffer", { return frames; }, + /** + * @property {Window} Returns the currently focused frame. + */ + get focusedFrame() + (dactyl.has("tabs") ? tabs.localStore : this.localStore).focusedFrame, + set focusedFrame(frame) + (dactyl.has("tabs") ? tabs.localStore : this.localStore).focusedFrame = frame, + /** * Returns the currently selected word. If the selection is * null, it tries to guess the word that the caret is @@ -451,7 +457,7 @@ const Buffer = Module("buffer", { // FIXME: getSelection() doesn't always preserve line endings, see: // https://www.mozdev.org/bugs/show_bug.cgi?id=19303 getCurrentWord: function () { - let win = tabs.localStore.focusedFrame || content; + let win = buffer.focusedFrame || content; let selection = win.getSelection(); if (selection.rangeCount == 0) return ""; @@ -932,7 +938,7 @@ const Buffer = Module("buffer", { * @param {boolean} useExternalEditor View the source in the external editor. */ viewSource: function (url, useExternalEditor) { - let doc = tabs.localStore.focusedFrame.document; + let doc = buffer.focusedFrame.document; if (useExternalEditor) this.viewSourceExternally(url || doc); @@ -1219,7 +1225,7 @@ const Buffer = Module("buffer", { commands.add(["frameo[nly]"], "Show only the current frame's page", function (args) { - dactyl.open(tabs.localStore.focusedFrame.document.documentURI); + dactyl.open(buffer.focusedFrame.document.documentURI); }, { argCount: "0" }); diff --git a/common/content/dactyl.js b/common/content/dactyl.js index d929a660..dbbecff3 100644 --- a/common/content/dactyl.js +++ b/common/content/dactyl.js @@ -388,7 +388,7 @@ const Dactyl = Module("dactyl", { gDBView.selection.select(i); } else if (this.has("tabs")) { - let frame = tabs.localStore.focusedFrame; + let frame = buffer.focusedFrame; if (frame && frame.top == window.content) elem = frame; } diff --git a/common/content/editor.js b/common/content/editor.js index 07ba0a1e..63ec1e89 100644 --- a/common/content/editor.js +++ b/common/content/editor.js @@ -427,7 +427,7 @@ const Editor = Module("editor", { let sel = controller.getSelection(controller.SELECTION_NORMAL); if (!sel.rangeCount) // Hack. sel.addRange(RangeFind.endpoint( - RangeFind.nodeRange(tabs.localStore.focusedFrame.document.documentElement), + RangeFind.nodeRange(buffer.focusedFrame.document.documentElement), true)); while (count--) controller[caretModeMethod](caretModeArg, false); diff --git a/common/content/events.js b/common/content/events.js index 42dbb5ae..211f7c93 100644 --- a/common/content/events.js +++ b/common/content/events.js @@ -732,7 +732,7 @@ const Events = Module("events", { let elem = window.document.commandDispatcher.focusedElement; if (win && win.top == content && dactyl.has("tabs")) - tabs.localStore.focusedFrame = win; + buffer.focusedFrame = win; try { if (elem && elem.readOnly) diff --git a/common/content/finder.js b/common/content/finder.js index ef6a94bd..dc75a1d4 100644 --- a/common/content/finder.js +++ b/common/content/finder.js @@ -302,7 +302,7 @@ const RangeFind = Class("RangeFind", { get searchString() this.lastString, get selectedRange() { - let selection = (tabs.localStore.focusedFrame || content).getSelection(); + let selection = (buffer.focusedFrame || content).getSelection(); return (selection.rangeCount ? selection.getRangeAt(0) : this.ranges[0].range).cloneRange(); }, set selectedRange(range) {