summaryrefslogtreecommitdiff
path: root/common
diff options
context:
space:
mode:
authorKris Maglione <maglione.k@gmail.com>2011-08-06 15:56:16 -0400
committerKris Maglione <maglione.k@gmail.com>2011-08-06 15:56:16 -0400
commit85dfd5becd1d4c91ec64e260f19df6340331dcb4 (patch)
tree140418074ae9621826148fa57cd67b46d090c119 /common
parentff0c5af5dbf9f121051bb5c4947bfcc9ba455799 (diff)
downloadpentadactyl-85dfd5becd1d4c91ec64e260f19df6340331dcb4.tar.gz
Re-enable Text Edit mode in non-Google editable windows.
Diffstat (limited to 'common')
-rw-r--r--common/content/editor.js44
-rw-r--r--common/content/hints.js8
-rw-r--r--common/modules/sanitizer.jsm10
3 files changed, 35 insertions, 27 deletions
diff --git a/common/content/editor.js b/common/content/editor.js
index 40972970..ef030360 100644
--- a/common/content/editor.js
+++ b/common/content/editor.js
@@ -62,7 +62,7 @@ var Editor = Module("editor", {
// count is optional, defaults to 1
executeCommand: function (cmd, count) {
let editor = Editor.getEditor(null);
- let controller = Editor.getController();
+ let controller = Editor.getController(cmd);
dactyl.assert(callable(cmd) ||
controller &&
controller.supportsCommand(cmd) &&
@@ -355,12 +355,13 @@ var Editor = Module("editor", {
}
},
- getController: function () {
- let ed = dactyl.focusedElement;
+ getController: function (cmd) {
+ let win = document.commandDispatcher.focusedWindow;
+ let ed = dactyl.focusedElement || Editor.getEditor(win) && win;
if (!ed || !ed.controllers)
return null;
- return ed.controllers.getControllerForCommand("cmd_beginLine");
+ return ed.controllers.getControllerForCommand(cmd || "cmd_beginLine");
}
}, {
mappings: function () {
@@ -395,7 +396,7 @@ var Editor = Module("editor", {
true));
}
- let controller = buffer.selectionController;
+ let controller = util.selectionController(document.commandDispatcher.focusedWindow);
let sel = controller.getSelection(controller.SELECTION_NORMAL);
if (!sel.rangeCount) // Hack.
fixSelection();
@@ -410,42 +411,38 @@ var Editor = Module("editor", {
}
}
- mappings.add([modes.CARET], keys, description,
- function ({ count }) {
- if (!count)
- count = 1;
-
- while (count--)
- caretExecute(false, true);
- },
- extraInfo);
-
mappings.add([modes.VISUAL], keys, description,
function ({ count }) {
if (!count)
count = 1;
+ let caret = !dactyl.focusedElement;
let editor_ = Editor.getEditor(null);
let controller = buffer.selectionController;
while (count-- && modes.main == modes.VISUAL) {
- if (editor.isTextEdit) {
+ if (caret)
+ caretExecute(true, true);
+ else {
if (callable(visualTextEditCommand))
visualTextEditCommand(editor_);
else
editor.executeCommand(visualTextEditCommand);
}
- else
- caretExecute(true, true);
}
},
extraInfo);
- mappings.add([modes.TEXT_EDIT, modes.OPERATOR], keys, description,
+ mappings.add([modes.CARET, modes.TEXT_EDIT, modes.OPERATOR], keys, description,
function ({ count }) {
if (!count)
count = 1;
- editor.executeCommand(textEditCommand, count);
+ if (Editor.getEditor(null))
+ editor.executeCommand(textEditCommand, count);
+ else {
+ while (count--)
+ caretExecute(false, true);
+ }
},
extraInfo);
}
@@ -618,8 +615,11 @@ var Editor = Module("editor", {
bind(["<C-t>"], "Edit text field in Vi mode",
function () {
- dactyl.assert(dactyl.focusedElement);
- dactyl.assert(!editor.isTextEdit);
+ dactyl.assert(!editor.isTextEdit && Editor.getEditor(null));
+ dactyl.assert(dactyl.focusedElement ||
+ let (f = document.commandDispatcher.focusedWindow.frameElement)
+ f && Hints.isVisible(f, true));
+
modes.push(modes.TEXT_EDIT);
});
diff --git a/common/content/hints.js b/common/content/hints.js
index a7d2b611..459ac88a 100644
--- a/common/content/hints.js
+++ b/common/content/hints.js
@@ -1077,12 +1077,18 @@ var Hints = Module("hints", {
this.hintSession = HintSession(mode, opts);
}
}, {
- isVisible: function isVisible(elem) {
+ isVisible: function isVisible(elem, offScreen) {
let rect = elem.getBoundingClientRect();
if (!rect.width || !rect.height)
if (!Array.some(elem.childNodes, function (elem) elem instanceof Element && util.computedStyle(elem).float != "none" && isVisible(elem)))
return false;
+ let win = elem.ownerDocument.defaultView;
+ if (offScreen && (rect.top + win.scrollY < 0 || rect.left + win.scrollX < 0 ||
+ rect.bottom + win.scrollY > win.scrolMaxY + win.innerHeight ||
+ rect.right + win.scrollX > win.scrolMaxX + win.innerWidth))
+ return false;
+
let computedStyle = util.computedStyle(elem, null);
if (computedStyle.visibility != "visible" || computedStyle.display == "none")
return false;
diff --git a/common/modules/sanitizer.jsm b/common/modules/sanitizer.jsm
index 47c8c458..ef45cf5a 100644
--- a/common/modules/sanitizer.jsm
+++ b/common/modules/sanitizer.jsm
@@ -369,10 +369,12 @@ var Sanitizer = Module("sanitizer", XPCOM([Ci.nsIObserver, Ci.nsISupportsWeakRef
prefToArg: function (pref) pref.replace(/.*\./, "").toLowerCase(),
iterCookies: function iterCookies(host) {
- let iterator = host ? services.cookies.getCookiesFromHost(host)
- : services.cookies;
- for (let c in iter(iterator))
- yield c.QueryInterface(Ci.nsICookie2);
+ for (let c in iter(services.cookies)) {
+ c.QueryInterface(Ci.nsICookie2);
+ if (!host || util.isSubdomain(c.rawHost, host) || c.host[0] == "." && c.host.length < host.length && host.indexOf(c.host) == host.length - c.host.length)
+ yield c;
+ }
+
},
iterPermissions: function iterPermissions(host) {
for (let p in iter(services.permissions)) {