diff --git a/content/buffer.js b/content/buffer.js index 60e00902..89cb1e4f 100644 --- a/content/buffer.js +++ b/content/buffer.js @@ -92,9 +92,9 @@ function Buffer() //{{{ if (win.scrollMaxX > 0 || win.scrollMaxY > 0) return win; - for (let i = 0; i < win.frames.length; i++) - if (win.frames[i].scrollMaxX > 0 || win.frames[i].scrollMaxY > 0) - return win.frames[i]; + for (let frame in util.Array.iterator(win.frames)) + if (frame.scrollMaxX > 0 || frame.scrollMaxY > 0) + return frame; return win; } @@ -1184,6 +1184,7 @@ function Buffer() //{{{ if (!window.content.document instanceof HTMLDocument) return; + count = Math.max(count, 1); var frames = []; // find all frames - depth-first search @@ -1216,32 +1217,24 @@ function Buffer() //{{{ var next = current; if (forward) { - if (count > 1) - next = current + count; - else - next++; + next = current + count; if (next > frames.length - 1) { if (current == frames.length - 1) - liberator.beep(); // still allow the frame indicator to be activated - - next = frames.length - 1; + liberator.beep(); + next = frames.length - 1; // still allow the frame indicator to be activated } } else { - if (count > 1) - next = current - count; - else - next--; + next = current - count; if (next < 0) { if (current == 0) - liberator.beep(); // still allow the frame indicator to be activated - - next = 0; + liberator.beep(); + next = 0; // still allow the frame indicator to be activated } } @@ -1263,7 +1256,7 @@ function Buffer() //{{{ // TODO: print more useful information, just like the DOM inspector showElementInfo: function (elem) { - liberator.echo(<>Element:
+ util.objectToString(elem), commandline.FORCE_MULTILINE); + liberator.echo(<>Element:
{util.objectToString(elem, true)}, commandline.FORCE_MULTILINE); }, showPageInfo: function (verbose) diff --git a/content/events.js b/content/events.js index b7985d88..b8a7f16b 100644 --- a/content/events.js +++ b/content/events.js @@ -1064,6 +1064,9 @@ function Events() //{{{ var win = window.document.commandDispatcher.focusedWindow; var elem = window.document.commandDispatcher.focusedElement; + if (win && win.top == content && liberator.has("tabs")) + tabs.localStore.focusedFrame = win; + if (elem && elem.readOnly) return; diff --git a/content/liberator.js b/content/liberator.js index 2065b06d..4afd8c74 100644 --- a/content/liberator.js +++ b/content/liberator.js @@ -820,8 +820,8 @@ const liberator = (function () //{{{ // if clearFocusedElement, also blur a focused link focusContent: function (clearFocusedElement) { - var ww = Components.classes["@mozilla.org/embedcomp/window-watcher;1"] - .getService(Components.interfaces.nsIWindowWatcher); + let ww = Components.classes["@mozilla.org/embedcomp/window-watcher;1"] + .getService(Components.interfaces.nsIWindowWatcher); if (window == ww.activeWindow && document.commandDispatcher.focusedElement && clearFocusedElement) document.commandDispatcher.focusedElement.blur(); @@ -830,16 +830,21 @@ const liberator = (function () //{{{ { if (liberator.has("mail") && clearFocusedElement && !config.isComposeWindow) { - var i = gDBView.selection.currentIndex; + let i = gDBView.selection.currentIndex; if (i == -1 && gDBView.rowCount >= 0) i = 0; - gDBView.selection.select(i); } } catch (e) {} - var elem = config.mainWidget || window.content; + let elem = config.mainWidget || window.content; + if (this.has("tabs")) + { + let frame = tabs.localStore.focusedFrame; + if (frame && frame.top == window.content) + elem = frame; + } if (elem && (elem != document.commandDispatcher.focusedElement)) elem.focus(); }, diff --git a/content/tabs.js b/content/tabs.js index 942bdadd..57ef3d59 100644 --- a/content/tabs.js +++ b/content/tabs.js @@ -674,14 +674,20 @@ function Tabs() //{{{ get count() getBrowser().mTabs.length, - // used for :setlocal get options() { - var tab = this.getTab(); - if (!tab.liberatorOptions) - tab.liberatorOptions = {}; + let store = this.localStore; + if (!("options" in store)) + store.options = {}; + return store.options; + }, - return tab.liberatorOptions; + get localStore() + { + let tab = this.getTab(); + if (!tab.liberatorStore) + tab.liberatorStore = {}; + return tab.liberatorStore; }, get tabStrip() @@ -696,15 +702,7 @@ function Tabs() //{{{ index: function (tab) { if (tab) - { - var length = getBrowser().mTabs.length; - for (let i = 0; i < length; i++) - { - if (getBrowser().mTabs[i] == tab) - return i; - } - return -1; - } + return Array.indexOf(getBrowser().mTabs, tab); return getBrowser().mTabContainer.selectedIndex; }, @@ -737,7 +735,7 @@ function Tabs() //{{{ getTab: function (index) { - if (index) + if (index != undefined) return getBrowser().mTabs[index]; return getBrowser().mTabContainer.selectedItem;