From cace9f737c3591513516d50f3cbdaf70a26336c1 Mon Sep 17 00:00:00 2001 From: Kris Maglione Date: Thu, 23 Dec 2010 20:27:34 -0500 Subject: [PATCH 1/3] Closes issue #204. --- common/content/tabs.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/common/content/tabs.js b/common/content/tabs.js index db906ff0..9500fdb0 100644 --- a/common/content/tabs.js +++ b/common/content/tabs.js @@ -955,7 +955,7 @@ const Tabs = Module("tabs", { "See 'showtabline' option."); tabs.tabStyle.enabled = false; } - if (value != 1) + if (value != 1 || !dactyl.has("Gecko2")) config.tabStrip.collapsed = false; return value; }, From a8d2678ad13cd2fd5b81ea7426142fc044ea1114 Mon Sep 17 00:00:00 2001 From: Kris Maglione Date: Fri, 24 Dec 2010 05:31:14 -0500 Subject: [PATCH 2/3] Use document rather than window for localStore and dactylFocusAllowed. --- common/content/buffer.js | 22 +++++++++++++--------- common/content/events.js | 2 +- 2 files changed, 14 insertions(+), 10 deletions(-) diff --git a/common/content/buffer.js b/common/content/buffer.js index 3089256f..54ff0ac2 100644 --- a/common/content/buffer.js +++ b/common/content/buffer.js @@ -161,6 +161,9 @@ const Buffer = Module("buffer", { }, _triggerLoadAutocmd: function _triggerLoadAutocmd(name, doc, uri) { + if (!(uri || doc.location)) + return; + uri = uri || util.newURI(doc.location.href); let args = { url: { toString: function () uri.spec, valueOf: function () uri }, @@ -292,8 +295,8 @@ const Buffer = Module("buffer", { onLocationChange.superapply(this, arguments); statusline.updateUrl(); statusline.updateProgress(webProgress.DOMWindow || content); - for (let frame in values(buffer.allFrames())) - frame.dactylFocusAllowed = false; + for (let frame in values(buffer.allFrames(webProgress.DOMWindow || content))) + frame.document.dactylFocusAllowed = false; // Workaround for bugs 591425 and 606877, dactyl bug #81 let collapse = uri && uri.scheme === "dactyl" && webProgress.isLoadingDocument; @@ -372,9 +375,9 @@ const Buffer = Module("buffer", { * tab. */ get localStore() { - if (!content.dactylStore) - content.dactylStore = {}; - return content.dactylStore; + if (!content.document.dactylStore) + content.document.dactylStore = {}; + return content.document.dactylStore; }, /** @@ -524,8 +527,8 @@ const Buffer = Module("buffer", { focusAllowed: function (elem) { if (elem instanceof Window && !Editor.getEditor(window)) return true; - let win = elem.ownerDocument && elem.ownerDocument.defaultView || elem; - return !options["strictfocus"] || win.dactylFocusAllowed; + let doc = elem.ownerDocument || elem.document || elem; + return !options["strictfocus"] || doc.dactylFocusAllowed; }, /** @@ -537,11 +540,12 @@ const Buffer = Module("buffer", { */ focusElement: function (elem) { let win = elem.ownerDocument && elem.ownerDocument.defaultView || elem; - win.dactylFocusAllowed = true; + win.document.dactylFocusAllowed = true; if (isinstance(elem, [HTMLFrameElement, HTMLIFrameElement])) elem = elem.contentWindow; - elem.dactylFocusAllowed = true; + if (elem.document) + elem.document.dactylFocusAllowed = true; if (elem instanceof HTMLInputElement && elem.type == "file") { Buffer.openUploadPrompt(elem); diff --git a/common/content/events.js b/common/content/events.js index 05d095a0..d1166e2b 100644 --- a/common/content/events.js +++ b/common/content/events.js @@ -947,7 +947,7 @@ const Events = Module("events", { let elem = event.target; let win = elem.ownerDocument && elem.ownerDocument.defaultView || elem; for (; win; win = win != win.parent && win.parent) - win.dactylFocusAllowed = true; + win.document.dactylFocusAllowed = true; }, onPopupShown: function onPopupShown(event) { From 045d63819a2280b8173e450d581e9d2851d692c5 Mon Sep 17 00:00:00 2001 From: Kris Maglione Date: Fri, 24 Dec 2010 05:53:27 -0500 Subject: [PATCH 3/3] Another crack at revision c24f695526a9. --- common/content/buffer.js | 7 ++----- common/content/dactyl.js | 11 +++++++---- common/content/modes.js | 1 + 3 files changed, 10 insertions(+), 9 deletions(-) diff --git a/common/content/buffer.js b/common/content/buffer.js index 54ff0ac2..456062e8 100644 --- a/common/content/buffer.js +++ b/common/content/buffer.js @@ -251,12 +251,9 @@ const Buffer = Module("buffer", { buffer._triggerLoadAutocmd("PageLoadPre", webProgress.DOMWindow.document); - // don't reset mode if a frame of the frameset gets reloaded which - // is not the focused frame - if (document.commandDispatcher.focusedWindow == webProgress.DOMWindow && this.loadCount++) { + if (document.commandDispatcher.focusedWindow == webProgress.DOMWindow && this.loadCount++) util.timeout(function () { modes.reset(false); }, - dactyl.mode == modes.HINTS ? 500 : 0); - } + dactyl.mode == modes.HINTS ? 500 : 0); } else if (flags & Ci.nsIWebProgressListener.STATE_STOP) { // Workaround for bugs 591425 and 606877, dactyl bug #81 diff --git a/common/content/dactyl.js b/common/content/dactyl.js index dbebe862..51c8617e 100644 --- a/common/content/dactyl.js +++ b/common/content/dactyl.js @@ -370,13 +370,14 @@ const Dactyl = Module("dactyl", { return res; }, - focus: function (elem, flags) { + focus: function focus(elem, flags) { flags = flags || services.focus.FLAG_BYMOUSE; + util.dumpStack(); try { if (elem instanceof Document) elem = elem.defaultView; if (elem instanceof Window) - services.focus.clearFocus(elem); + services.focus.focusedWindow = elem; else services.focus.setFocus(elem, flags); } catch (e) { @@ -391,7 +392,7 @@ const Dactyl = Module("dactyl", { * @param {boolean} clearFocusedElement Remove focus from any focused * element. */ - focusContent: function (clearFocusedElement) { + focusContent: function focusContent(clearFocusedElement) { if (window != services.windowWatcher.activeWindow) return; @@ -414,7 +415,8 @@ const Dactyl = Module("dactyl", { catch (e) {} if (clearFocusedElement) { - services.focus.clearFocus(window); + if (dactyl.focusedElement) + dactyl.focusedElement.blur(); if (win && Editor.getEditor(win)) { win.blur(); if (win.frameElement) @@ -431,6 +433,7 @@ const Dactyl = Module("dactyl", { /** @property {Element} The currently focused element. */ get focusedElement() services.focus.getFocusedElementForWindow(window, true, {}), + set focusedElement(elem) dactyl.focus(elem), /** * Returns whether this Dactyl extension supports *feature*. diff --git a/common/content/modes.js b/common/content/modes.js index c59e85b6..715d4b0e 100644 --- a/common/content/modes.js +++ b/common/content/modes.js @@ -286,6 +286,7 @@ const Modes = Module("modes", { }, push: function push(mainMode, extendedMode, params) { + util.dumpStack(); this.set(mainMode, extendedMode, params, { push: this.topOfStack }); },