1
0
mirror of https://github.com/gryf/pentadactyl-pm.git synced 2025-12-21 08:37:58 +01:00

Re-enable Text Edit mode in non-Google editable windows.

This commit is contained in:
Kris Maglione
2011-08-06 15:56:16 -04:00
parent ff0c5af5db
commit 85dfd5becd
3 changed files with 35 additions and 27 deletions

View File

@@ -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);
});

View File

@@ -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;

View File

@@ -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)) {