1
0
mirror of https://github.com/gryf/pentadactyl-pm.git synced 2025-12-20 04:07: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. * files.
* @instance buffer * @instance buffer
*/ */
var Buffer = Module("buffer", { var Buffer = Module("buffer", XPCOM(Ci.nsISupportsWeakReference, ModuleBase), {
init: function () { init: function () {
this.evaluateXPath = util.evaluateXPath; this.evaluateXPath = util.evaluateXPath;
this.pageInfo = {}; this.pageInfo = {};
@@ -153,10 +153,12 @@ var Buffer = Module("buffer", {
for (let tab in values(tabs.allTabs)) for (let tab in values(tabs.allTabs))
if (tab.linkedBrowser.contentDocument.readyState === "complete") if (tab.linkedBrowser.contentDocument.readyState === "complete")
dactyl.initDocument(tab.linkedBrowser.contentDocument); dactyl.initDocument(tab.linkedBrowser.contentDocument);
util.addObserver(this);
}, },
cleanup: function () { cleanup: function () {
this.cleanupProgressListener(); this.cleanupProgressListener();
this.observe.unregister();
}, },
getDefaultNames: function getDefaultNames(node) { getDefaultNames: function getDefaultNames(node) {
@@ -199,7 +201,7 @@ var Buffer = Module("buffer", {
if (!(uri || doc.location)) if (!(uri || doc.location))
return; return;
uri = uri || util.newURI(doc.location.href); uri = isObject(uri) ? uri : util.newURI(uri || doc.location.href);
let args = { let args = {
url: { toString: function () uri.spec, valueOf: function () uri }, url: { toString: function () uri.spec, valueOf: function () uri },
title: doc.title title: doc.title
@@ -222,6 +224,18 @@ var Buffer = Module("buffer", {
commandline.clear(); 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) { onDOMContentLoaded: function onDOMContentLoaded(event) {
let doc = event.originalTarget; let doc = event.originalTarget;
if (doc instanceof HTMLDocument) if (doc instanceof HTMLDocument)
@@ -269,8 +283,6 @@ var Buffer = Module("buffer", {
// only thrown for the current tab, not when another tab changes // only thrown for the current tab, not when another tab changes
if (flags & Ci.nsIWebProgressListener.STATE_START) { if (flags & Ci.nsIWebProgressListener.STATE_START) {
statusline.progress = 0; statusline.progress = 0;
buffer._triggerLoadAutocmd("PageLoadPre", webProgress.DOMWindow.document);
} }
else if (flags & Ci.nsIWebProgressListener.STATE_STOP) { else if (flags & Ci.nsIWebProgressListener.STATE_STOP) {
// Workaround for bugs 591425 and 606877, dactyl bug #81 // Workaround for bugs 591425 and 606877, dactyl bug #81
@@ -528,11 +540,8 @@ var Buffer = Module("buffer", {
let range = selection.getRangeAt(0).cloneRange(); let range = selection.getRangeAt(0).cloneRange();
if (range.collapsed) { if (range.collapsed) {
let re = options.get("iskeyword").regexp; let re = options.get("iskeyword").regexp;
util.dump(String.quote(range));
Editor.extendRange(range, true, re, true); Editor.extendRange(range, true, re, true);
util.dump(String.quote(range));
Editor.extendRange(range, false, re, true); Editor.extendRange(range, false, re, true);
util.dump(String.quote(range) + "\n\n\n");
} }
return util.domToString(range); return util.domToString(range);
}, },

View File

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

View File

@@ -1160,21 +1160,23 @@ var Hints = Module("hints", {
}, },
options: function () { options: function () {
const DEFAULT_HINTTAGS = 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"], options.add(["extendedhinttags", "eht"],
"XPath strings of hintable elements for extended hint modes", "XPath strings of hintable elements for extended hint modes",
"regexpmap", "[iI]:" + xpath(["img"]) + "regexpmap", {
",[asOTivVWy]:" + xpath(["{a,area}[@href]", "{img,iframe}[@src]"]) + "[iI]": xpath(["img"]),
",[F]:" + xpath(["body", "code", "div", "html", "p", "pre", "span"]) + "[asOTivVWy]": xpath(["{a,area}[@href]", "{img,iframe}[@src]"]),
",[S]:" + xpath(["input[not(@type='hidden')]", "textarea", "button", "select"]), "[F]": xpath(["body", "code", "div", "html", "p", "pre", "span"]),
"[S]": xpath(["input[not(@type='hidden')]", "textarea", "button", "select"])
},
{ validator: Option.validateXPath }); { validator: Option.validateXPath });
options.add(["hinttags", "ht"], options.add(["hinttags", "ht"],
"XPath string of hintable elements activated by 'f' and 'F'", "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 }); { validator: Option.validateXPath });
options.add(["hintkeys", "hk"], options.add(["hintkeys", "hk"],

View File

@@ -62,6 +62,13 @@ var Option = Class("Option", {
if (arguments.length > 3) { if (arguments.length > 3) {
if (this.type == "string") if (this.type == "string")
defaultValue = Commands.quote(defaultValue); 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); this.defaultValue = this.parse(defaultValue);
} }

View File

@@ -81,7 +81,7 @@ update(Highlight.prototype, {
get cssText() this.inheritedCSS + this.value, get cssText() this.inheritedCSS + this.value,
toString: function () "Highlight(" + this.class + ")\n\t" + 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"], names: ["-name", "-n"],
description: "The name of this stylesheet", 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 type: modules.CommandOption.STRING
} }
], ],

View File

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

View File

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