1
0
mirror of https://github.com/gryf/pentadactyl-pm.git synced 2025-12-20 16:17:59 +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);
}

View File

@@ -81,7 +81,7 @@ update(Highlight.prototype, {
get cssText() this.inheritedCSS + this.value,
toString: function () "Highlight(" + this.class + ")\n\t" +
[k + ": " + String.quote(v) for ([k, v] in this)] .join("\n\t")
[k + ": " + String(v).quote() for ([k, v] in this)] .join("\n\t")
});
/**

View File

@@ -512,7 +512,7 @@ var Styles = Module("Styles", {
{
names: ["-name", "-n"],
description: "The name of this stylesheet",
completer: function () [[k, v.css] for ([k, v] in Iterator(args["-group"].names))],
completer: function (context, args) [[k, v.css] for ([k, v] in Iterator(args["-group"].hive.names))],
type: modules.CommandOption.STRING
}
],

View File

@@ -6,7 +6,7 @@
Components.utils.import("resource://dactyl/bootstrap.jsm");
defineModule("template", {
exports: ["Template", "template"],
exports: ["Binding", "Template", "template"],
require: ["util"],
use: ["services"]
}, this);
@@ -14,8 +14,9 @@ defineModule("template", {
default xml namespace = XHTML;
var Binding = Class("Binding", {
init: function (node) {
init: function (node, nodes) {
this.node = node;
this.nodes = nodes;
node.dactylBinding = this;
Object.defineProperties(node, this.constructor.properties);
@@ -32,9 +33,13 @@ var Binding = Class("Binding", {
},
get collapsed() !!this.getAttribute("collapsed"),
__noSuchMethod__: function __noSuchMethod__(meth, args) {
return this.node[meth].apply(this.node, args);
}
__noSuchMethod__: Class.Property({
configurable: true,
writeable: true,
value: function __noSuchMethod__(meth, args) {
return this.node[meth].apply(this.node, args);
}
})
}, {
get bindings() {
let bindingProto = Object.getPrototypeOf(Binding.prototype);
@@ -66,10 +71,12 @@ var Binding = Class("Binding", {
for (let obj in this.bindings)
for (let prop in properties(obj)) {
let desc = Object.getOwnPropertyDescriptor(obj, prop);
for (let k in values(["get", "set", "value"]))
if (typeof desc[k] === "function")
desc[k] = this.bind(desc[k]);
res[prop] = desc;
if (desc.enumerable) {
for (let k in values(["get", "set", "value"]))
if (typeof desc[k] === "function")
desc[k] = this.bind(desc[k]);
res[prop] = desc;
}
}
return res;
})

View File

@@ -1083,6 +1083,7 @@ var Util = Module("Util", XPCOM([Ci.nsIObserver, Ci.nsISupportsWeakReference]),
this._loadOverlay(window, obj(window));
}
},
_loadOverlay: function _loadOverlay(window, obj) {
let doc = window.document;
if (!doc.dactylOverlayElements) {