1
0
mirror of https://github.com/gryf/pentadactyl-pm.git synced 2026-01-08 00:24:11 +01:00

Fixes, mostly, most of which should really be in the default branch.

--HG--
branch : groups
This commit is contained in:
Kris Maglione
2011-02-09 07:21:10 -05:00
parent 8acf2c4ff0
commit 7aed800d29
8 changed files with 55 additions and 29 deletions

View File

@@ -14,7 +14,7 @@
* files.
* @instance buffer
*/
var Buffer = Module("buffer", {
var Buffer = Module("buffer", XPCOM(Ci.nsISupportsWeakReference, ModuleBase), {
init: function () {
this.evaluateXPath = util.evaluateXPath;
this.pageInfo = {};
@@ -153,10 +153,12 @@ var Buffer = Module("buffer", {
for (let tab in values(tabs.allTabs))
if (tab.linkedBrowser.contentDocument.readyState === "complete")
dactyl.initDocument(tab.linkedBrowser.contentDocument);
util.addObserver(this);
},
cleanup: function () {
this.cleanupProgressListener();
this.observe.unregister();
},
getDefaultNames: function getDefaultNames(node) {
@@ -199,7 +201,7 @@ var Buffer = Module("buffer", {
if (!(uri || doc.location))
return;
uri = uri || util.newURI(doc.location.href);
uri = isObject(uri) ? uri : util.newURI(uri || doc.location.href);
let args = {
url: { toString: function () uri.spec, valueOf: function () uri },
title: doc.title
@@ -222,6 +224,18 @@ var Buffer = Module("buffer", {
commandline.clear();
},
observers: {
"chrome-document-global-created": function (win, uri) { this.observe(win, "content-document-global-created", null); },
"content-document-global-created": function (win, uri) {
let top = win.QueryInterface(Ci.nsIInterfaceRequestor).getInterface(Ci.nsIWebNavigation)
.QueryInterface(Ci.nsIDocShellTreeItem).rootTreeItem
.QueryInterface(Ci.nsIInterfaceRequestor).getInterface(Ci.nsIDOMWindow);
if (top == window)
this._triggerLoadAutocmd("PageLoadPre", win.document, win.location.href != "null" ? window.location.href : uri);
}
},
onDOMContentLoaded: function onDOMContentLoaded(event) {
let doc = event.originalTarget;
if (doc instanceof HTMLDocument)
@@ -269,8 +283,6 @@ var Buffer = Module("buffer", {
// only thrown for the current tab, not when another tab changes
if (flags & Ci.nsIWebProgressListener.STATE_START) {
statusline.progress = 0;
buffer._triggerLoadAutocmd("PageLoadPre", webProgress.DOMWindow.document);
}
else if (flags & Ci.nsIWebProgressListener.STATE_STOP) {
// Workaround for bugs 591425 and 606877, dactyl bug #81
@@ -528,11 +540,8 @@ var Buffer = Module("buffer", {
let range = selection.getRangeAt(0).cloneRange();
if (range.collapsed) {
let re = options.get("iskeyword").regexp;
util.dump(String.quote(range));
Editor.extendRange(range, true, re, true);
util.dump(String.quote(range));
Editor.extendRange(range, false, re, true);
util.dump(String.quote(range) + "\n\n\n");
}
return util.domToString(range);
},

View File

@@ -1832,8 +1832,8 @@ var Dactyl = Module("dactyl", XPCOM(Ci.nsISupportsWeakReference, ModuleBase), {
function () { dactyl.restart(); });
function findToolbar(name) util.evaluateXPath(
"./*[@toolbarname=" + util.escapeString(name, "'") + "]",
toolbox).snapshotItem(0);
"//*[@toolbarname=" + util.escapeString(name, "'") + "]",
document).snapshotItem(0);
var toolbox = document.getElementById("navigator-toolbox");
if (toolbox) {
@@ -2017,7 +2017,7 @@ var Dactyl = Module("dactyl", XPCOM(Ci.nsISupportsWeakReference, ModuleBase), {
completion.toolbar = function toolbar(context) {
context.title = ["Toolbar"];
context.keys = { text: function (item) item.getAttribute("toolbarname"), description: function () "" };
context.completions = util.evaluateXPath("./*[@toolbarname]", toolbox);
context.completions = util.evaluateXPath("//*[@toolbarname]", document);
};
completion.window = function window(context) {

View File

@@ -1160,21 +1160,23 @@ var Hints = Module("hints", {
},
options: function () {
const DEFAULT_HINTTAGS =
util.makeXPath(["input[not(@type='hidden')]", "a", "area", "iframe", "textarea", "button", "select",
"*[@onclick or @onmouseover or @onmousedown or @onmouseup or @oncommand or @tabindex or @role='link' or @role='button']"]);
function xpath(arg) Option.quote(util.makeXPath(arg));
function xpath(arg) util.makeXPath(arg);
options.add(["extendedhinttags", "eht"],
"XPath strings of hintable elements for extended hint modes",
"regexpmap", "[iI]:" + xpath(["img"]) +
",[asOTivVWy]:" + xpath(["{a,area}[@href]", "{img,iframe}[@src]"]) +
",[F]:" + xpath(["body", "code", "div", "html", "p", "pre", "span"]) +
",[S]:" + xpath(["input[not(@type='hidden')]", "textarea", "button", "select"]),
"regexpmap", {
"[iI]": xpath(["img"]),
"[asOTivVWy]": xpath(["{a,area}[@href]", "{img,iframe}[@src]"]),
"[F]": xpath(["body", "code", "div", "html", "p", "pre", "span"]),
"[S]": xpath(["input[not(@type='hidden')]", "textarea", "button", "select"])
},
{ validator: Option.validateXPath });
options.add(["hinttags", "ht"],
"XPath string of hintable elements activated by 'f' and 'F'",
"string", DEFAULT_HINTTAGS,
"string", xpath(["input[not(@type='hidden')]", "a", "area", "iframe", "textarea", "button", "select",
"*[@onclick or @onmouseover or @onmousedown or @onmouseup or @oncommand or " +
"@tabindex or @role='link' or @role='button']"]),
{ validator: Option.validateXPath });
options.add(["hintkeys", "hk"],

View File

@@ -62,6 +62,13 @@ var Option = Class("Option", {
if (arguments.length > 3) {
if (this.type == "string")
defaultValue = Commands.quote(defaultValue);
if (isObject(defaultValue))
defaultValue = iter(defaultValue).map(function (val) val.map(Option.quote).join(":")).join(",");
if (isArray(defaultValue))
defaultValue = defaultValue.map(Option.quote).join(",");
this.defaultValue = this.parse(defaultValue);
}