mirror of
https://github.com/gryf/pentadactyl-pm.git
synced 2025-12-20 21:28:00 +01:00
Make buffer.UR[LI] nsIURI objects. Fix bug in chrome-data:.
This commit is contained in:
@@ -93,8 +93,14 @@ ChromeData.prototype = {
|
||||
|
||||
newChannel: function (uri) {
|
||||
try {
|
||||
if (uri.scheme == this.scheme)
|
||||
return makeChannel(uri.spec.replace(/^.*?:\/*(.*)(?:#.*)?/, "data:$1"), uri);
|
||||
if (uri.scheme == this.scheme) {
|
||||
let channel = ioService.newChannel(uri.spec.replace(/^.*?:\/*(.*)(?:#.*)?/, "data:$1"),
|
||||
null, null);
|
||||
channel.contentCharset = "UTF-8";
|
||||
channel.owner = systemPrincipal;
|
||||
channel.originalURI = uri;
|
||||
return channel;
|
||||
}
|
||||
}
|
||||
catch (e) {}
|
||||
return fakeChannel(uri);
|
||||
|
||||
@@ -207,7 +207,7 @@ var AutoCommands = Module("autocommands", {
|
||||
return void dactyl.echomsg("No matching autocommands");
|
||||
|
||||
let [event, url] = args;
|
||||
let defaultURL = url || buffer.URL;
|
||||
let defaultURL = url || buffer.URL.spec;
|
||||
let validEvents = Object.keys(config.autocommands);
|
||||
|
||||
// TODO: add command validators
|
||||
@@ -224,7 +224,7 @@ var AutoCommands = Module("autocommands", {
|
||||
for (let i = 0; i < tabs.count; i++) {
|
||||
tabs.select(i);
|
||||
// if no url arg is specified use the current buffer's URL
|
||||
autocommands.trigger(event, { url: url || buffer.URL });
|
||||
autocommands.trigger(event, { url: url || buffer.URL.spec });
|
||||
}
|
||||
|
||||
tabs.select(current);
|
||||
|
||||
@@ -62,7 +62,7 @@ var Bookmarks = Module("bookmarks", {
|
||||
|
||||
try {
|
||||
let uri = util.createURI(url);
|
||||
if (!force && this.isBookmarked(uri.spec))
|
||||
if (!force && this.isBookmarked(uri))
|
||||
for (var bmark in bookmarkcache)
|
||||
if (bmark.url == uri.spec) {
|
||||
if (title)
|
||||
@@ -130,7 +130,7 @@ var Bookmarks = Module("bookmarks", {
|
||||
if (count > 0)
|
||||
dactyl.echomsg({ domains: [util.getHost(url)], message: "Removed bookmark: " + url });
|
||||
else {
|
||||
let title = buffer.URL == url && buffer.title || url;
|
||||
let title = buffer.URL.spec == url && buffer.title || url;
|
||||
let extra = "";
|
||||
if (title != url)
|
||||
extra = " (" + title + ")";
|
||||
@@ -145,10 +145,12 @@ var Bookmarks = Module("bookmarks", {
|
||||
*
|
||||
* @param {string} url The URL of which to check the bookmarked state.
|
||||
*/
|
||||
isBookmarked: function isBookmarked(url) {
|
||||
isBookmarked: function isBookmarked(uri) {
|
||||
if (isString(uri))
|
||||
uri = util.newURI(uri);
|
||||
try {
|
||||
return services.bookmarks
|
||||
.getBookmarkIdsForURI(makeURI(url), {})
|
||||
.getBookmarkIdsForURI(uri, {})
|
||||
.some(bookmarkcache.closure.isRegularBookmark);
|
||||
}
|
||||
catch (e) {
|
||||
@@ -442,7 +444,7 @@ var Bookmarks = Module("bookmarks", {
|
||||
post: args["-post"],
|
||||
tags: args["-tags"] || [],
|
||||
title: args["-title"] || (args.length === 0 ? buffer.title : null),
|
||||
url: args.length === 0 ? buffer.URL : args[0]
|
||||
url: args.length === 0 ? buffer.URL.spec : args[0]
|
||||
};
|
||||
|
||||
if (bookmarks.add(opts)) {
|
||||
@@ -504,7 +506,7 @@ var Bookmarks = Module("bookmarks", {
|
||||
});
|
||||
else {
|
||||
if (!(args.length || args["-tags"] || args["-keyword"] || args["-title"]))
|
||||
var deletedCount = bookmarks.remove(buffer.URL);
|
||||
var deletedCount = bookmarks.remove(buffer.URL.spec);
|
||||
else {
|
||||
let context = CompletionContext(args.join(" "));
|
||||
context.fork("bookmark", 0, completion, "bookmark",
|
||||
@@ -536,7 +538,8 @@ var Bookmarks = Module("bookmarks", {
|
||||
function () {
|
||||
let options = {};
|
||||
|
||||
let bmarks = bookmarks.get(buffer.URL).filter(function (bmark) bmark.url == buffer.URL);
|
||||
let url = buffer.URL.spec;
|
||||
let bmarks = bookmarks.get(url).filter(function (bmark) bmark.url == url);
|
||||
|
||||
if (bmarks.length == 1) {
|
||||
let bmark = bmarks[0];
|
||||
@@ -548,18 +551,18 @@ var Bookmarks = Module("bookmarks", {
|
||||
options["-tags"] = bmark.tags.join(", ");
|
||||
}
|
||||
else {
|
||||
if (buffer.title != buffer.URL)
|
||||
if (buffer.title != buffer.URL.spec)
|
||||
options["-title"] = buffer.title;
|
||||
}
|
||||
|
||||
commandline.open(":",
|
||||
commands.commandToString({ command: "bmark", options: options, arguments: [buffer.URL] }),
|
||||
commands.commandToString({ command: "bmark", options: options, arguments: [buffer.URL.spec] }),
|
||||
modes.EX);
|
||||
});
|
||||
|
||||
mappings.add(myModes, ["A"],
|
||||
"Toggle bookmarked state of current URL",
|
||||
function () { bookmarks.toggle(buffer.URL); });
|
||||
function () { bookmarks.toggle(buffer.URL.spec); });
|
||||
},
|
||||
options: function () {
|
||||
options.add(["defsearch", "ds"],
|
||||
|
||||
@@ -14,18 +14,18 @@
|
||||
var Browser = Module("browser", {
|
||||
}, {
|
||||
climbUrlPath: function (count) {
|
||||
let url = util.newURI(buffer.URL);
|
||||
let url = buffer.URI;
|
||||
dactyl.assert(url instanceof Ci.nsIURL);
|
||||
|
||||
while (count-- && url.path != "/")
|
||||
url.path = url.path.replace(/[^\/]+\/*$/, "");
|
||||
|
||||
dactyl.assert(url.spec != buffer.URL);
|
||||
dactyl.assert(!url.equals(buffer.URI));
|
||||
dactyl.open(url.spec);
|
||||
},
|
||||
|
||||
incrementURL: function (count) {
|
||||
let matches = buffer.URL.match(/(.*?)(\d+)(\D*)$/);
|
||||
let matches = buffer.URL.spec.match(/(.*?)(\d+)(\D*)$/);
|
||||
dactyl.assert(matches);
|
||||
let oldNum = matches[2];
|
||||
|
||||
@@ -66,7 +66,7 @@ var Browser = Module("browser", {
|
||||
mappings: function () {
|
||||
mappings.add([modes.NORMAL],
|
||||
["y"], "Yank current location to the clipboard",
|
||||
function () { dactyl.clipboardWrite(buffer.URL, true); });
|
||||
function () { dactyl.clipboardWrite(buffer.URL.spec, true); });
|
||||
|
||||
// opening websites
|
||||
mappings.add([modes.NORMAL],
|
||||
@@ -75,7 +75,7 @@ var Browser = Module("browser", {
|
||||
|
||||
mappings.add([modes.NORMAL], ["O"],
|
||||
"Open one or more URLs, based on current location",
|
||||
function () { commandline.open(":", "open " + buffer.URL, modes.EX); });
|
||||
function () { commandline.open(":", "open " + buffer.URL.spec, modes.EX); });
|
||||
|
||||
mappings.add([modes.NORMAL], ["t"],
|
||||
"Open one or more URLs in a new tab",
|
||||
@@ -83,7 +83,7 @@ var Browser = Module("browser", {
|
||||
|
||||
mappings.add([modes.NORMAL], ["T"],
|
||||
"Open one or more URLs in a new tab, based on current location",
|
||||
function () { commandline.open(":", "tabopen " + buffer.URL, modes.EX); });
|
||||
function () { commandline.open(":", "tabopen " + buffer.URL.spec, modes.EX); });
|
||||
|
||||
mappings.add([modes.NORMAL], ["w"],
|
||||
"Open one or more URLs in a new window",
|
||||
@@ -91,7 +91,7 @@ var Browser = Module("browser", {
|
||||
|
||||
mappings.add([modes.NORMAL], ["W"],
|
||||
"Open one or more URLs in a new window, based on current location",
|
||||
function () { commandline.open(":", "winopen " + buffer.URL, modes.EX); });
|
||||
function () { commandline.open(":", "winopen " + buffer.URL.spec, modes.EX); });
|
||||
|
||||
mappings.add([modes.NORMAL],
|
||||
["<C-a>"], "Increment last number in URL",
|
||||
|
||||
@@ -383,13 +383,13 @@ var Buffer = Module("buffer", {
|
||||
/**
|
||||
* @property {string} The current top-level document's URL.
|
||||
*/
|
||||
get URL() content.location.href,
|
||||
get URL() util.newURI(content.location.href),
|
||||
|
||||
/**
|
||||
* @property {string} The current top-level document's URL, sans any
|
||||
* fragment identifier.
|
||||
*/
|
||||
get URI() content.document.documentURI,
|
||||
get URI() let (doc = content.document) doc.documentURIObject || util.newURI(doc.documentURI),
|
||||
|
||||
/**
|
||||
* @property {number} The buffer's height in pixels.
|
||||
|
||||
@@ -2146,7 +2146,7 @@ var Dactyl = Module("dactyl", XPCOM(Ci.nsISupportsWeakReference, ModuleBase), {
|
||||
let rcFile = io.getRCFile("~");
|
||||
|
||||
if (dactyl.userEval('typeof document') === "undefined")
|
||||
jsmodules.__proto__ = (window.XPCSafeJSObjectWrapper || XPCNativeWrapper)(window);
|
||||
jsmodules.__proto__ = XPCSafeJSObjectWrapper(window);
|
||||
|
||||
try {
|
||||
if (dactyl.commandLineOptions.rcFile) {
|
||||
|
||||
@@ -1267,7 +1267,7 @@ var Events = Module("events", {
|
||||
"Pass certain keys through directly for the given URLs",
|
||||
"regexpmap", "", {
|
||||
has: function (key) {
|
||||
let url = buffer.URI;
|
||||
let url = buffer.URI.spec;
|
||||
for (let re in values(this.value))
|
||||
if (re.test(url) && re.result.some(function (k) k === key))
|
||||
return true;
|
||||
|
||||
@@ -145,7 +145,7 @@ var QuickMarks = Module("quickmarks", {
|
||||
if (!/^[a-zA-Z0-9]$/.test(args[0]))
|
||||
dactyl.echoerr("E488: Trailing characters");
|
||||
else if (!args[1])
|
||||
quickmarks.add(args[0], buffer.URL);
|
||||
quickmarks.add(args[0], buffer.URL.spec);
|
||||
else
|
||||
quickmarks.add(args[0], args[1]);
|
||||
},
|
||||
@@ -204,7 +204,7 @@ var QuickMarks = Module("quickmarks", {
|
||||
["M"], "Add new QuickMark for current URL",
|
||||
function ({ arg }) {
|
||||
dactyl.assert(/^[a-zA-Z0-9]$/.test(arg));
|
||||
quickmarks.add(arg, buffer.URL);
|
||||
quickmarks.add(arg, buffer.URL.spec);
|
||||
},
|
||||
{ arg: true });
|
||||
}
|
||||
|
||||
@@ -143,7 +143,7 @@ var StatusLine = Module("statusline", {
|
||||
|
||||
// TODO: this probably needs a more general solution.
|
||||
if (url == null)
|
||||
url = buffer.URL;
|
||||
url = buffer.URL.spec;
|
||||
|
||||
// when session information is available, add [+] when we can go
|
||||
// backwards, [-] when we can go forwards
|
||||
|
||||
@@ -21,7 +21,7 @@ if (!JSMLoader)
|
||||
if (!(prop in this.builtin) &&
|
||||
[this, set].indexOf(Object.getOwnPropertyDescriptor(global, prop).value) < 0 &&
|
||||
!global.__lookupGetter__(prop))
|
||||
global[prop] = null;
|
||||
global[prop] = undefined;
|
||||
}
|
||||
catch (e) {
|
||||
dump("Deleting property " + prop + " on " + url + ":\n " + e + "\n");
|
||||
@@ -73,6 +73,9 @@ catch (e) {}
|
||||
let objproto = Object.prototype;
|
||||
let hasOwnProperty = objproto.hasOwnProperty;
|
||||
|
||||
if (typeof XPCSafeJSObjectWrapper === "undefined")
|
||||
var XPCSafeJSObjectWrapper = XPCNativeWrapper;
|
||||
|
||||
if (!XPCNativeWrapper.unwrap)
|
||||
XPCNativeWrapper.unwrap = function (obj) {
|
||||
if (hasOwnProperty.call(obj, "wrappedJSObject"))
|
||||
@@ -235,12 +238,11 @@ defineModule("base", {
|
||||
// sed -n 's/^(const|function) ([a-zA-Z0-9_]+).*/ "\2",/p' base.jsm | sort | fmt
|
||||
exports: [
|
||||
"ErrorBase", "Cc", "Ci", "Class", "Cr", "Cu", "Module", "JSMLoader", "Object", "Runnable",
|
||||
"Struct", "StructBase", "Timer", "UTF8", "XPCOM", "XPCOMUtils", "array",
|
||||
"call", "callable", "ctypes", "curry", "debuggerProperties", "defineModule",
|
||||
"deprecated", "endModule", "forEach", "isArray", "isGenerator",
|
||||
"isinstance", "isObject", "isString", "isSubclass", "iter", "iterAll",
|
||||
"keys", "memoize", "octal", "properties", "require", "set", "update",
|
||||
"values", "withCallerGlobal"
|
||||
"Struct", "StructBase", "Timer", "UTF8", "XPCOM", "XPCOMUtils", "XPCSafeJSObjectWrapper",
|
||||
"array", "call", "callable", "ctypes", "curry", "debuggerProperties", "defineModule",
|
||||
"deprecated", "endModule", "forEach", "isArray", "isGenerator", "isinstance", "isObject",
|
||||
"isString", "isSubclass", "iter", "iterAll", "keys", "memoize", "octal", "properties",
|
||||
"require", "set", "update", "values", "withCallerGlobal"
|
||||
],
|
||||
use: ["config", "services", "util"]
|
||||
});
|
||||
|
||||
@@ -4,9 +4,6 @@
|
||||
// given in the LICENSE.txt file included with this file.
|
||||
"use strict";
|
||||
|
||||
if (this.XPCSafeJSObjectWrapper == null)
|
||||
this.XPCSafeJSObjectWrapper = XPCNativeWrapper;
|
||||
|
||||
var myObject = Object;
|
||||
Components.utils.import("resource://dactyl/base.jsm");
|
||||
defineModule("storage", {
|
||||
|
||||
Reference in New Issue
Block a user