diff options
author | Kris Maglione <maglione.k@gmail.com> | 2011-01-03 22:00:53 -0500 |
---|---|---|
committer | Kris Maglione <maglione.k@gmail.com> | 2011-01-03 22:00:53 -0500 |
commit | d661d60cb6af169941b84b4b8626b56a2a35c41b (patch) | |
tree | 0b5eed3b01e6ddccea7ecc5c52307667194bf9ca /common | |
parent | ec554ac6c9388b7fb685e50cbefa41c35af5334b (diff) | |
download | pentadactyl-d661d60cb6af169941b84b4b8626b56a2a35c41b.tar.gz |
Make buffer.UR[LI] nsIURI objects. Fix bug in chrome-data:.
Diffstat (limited to 'common')
-rw-r--r-- | common/components/protocols.js | 10 | ||||
-rw-r--r-- | common/content/autocommands.js | 4 | ||||
-rw-r--r-- | common/content/bookmarks.js | 23 | ||||
-rw-r--r-- | common/content/browser.js | 14 | ||||
-rw-r--r-- | common/content/buffer.js | 4 | ||||
-rw-r--r-- | common/content/dactyl.js | 2 | ||||
-rw-r--r-- | common/content/events.js | 2 | ||||
-rw-r--r-- | common/content/quickmarks.js | 4 | ||||
-rw-r--r-- | common/content/statusline.js | 2 | ||||
-rw-r--r-- | common/modules/base.jsm | 16 | ||||
-rw-r--r-- | common/modules/storage.jsm | 3 |
11 files changed, 46 insertions, 38 deletions
diff --git a/common/components/protocols.js b/common/components/protocols.js index 3719858c..4151275e 100644 --- a/common/components/protocols.js +++ b/common/components/protocols.js @@ -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); diff --git a/common/content/autocommands.js b/common/content/autocommands.js index 5c14ae50..532bccd4 100644 --- a/common/content/autocommands.js +++ b/common/content/autocommands.js @@ -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); diff --git a/common/content/bookmarks.js b/common/content/bookmarks.js index 05314274..fb2d2bf2 100644 --- a/common/content/bookmarks.js +++ b/common/content/bookmarks.js @@ -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"], diff --git a/common/content/browser.js b/common/content/browser.js index bfe5abc8..484d654b 100644 --- a/common/content/browser.js +++ b/common/content/browser.js @@ -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", diff --git a/common/content/buffer.js b/common/content/buffer.js index 9faa6f76..1e96d417 100644 --- a/common/content/buffer.js +++ b/common/content/buffer.js @@ -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. diff --git a/common/content/dactyl.js b/common/content/dactyl.js index 7f6905b9..b8e70e7a 100644 --- a/common/content/dactyl.js +++ b/common/content/dactyl.js @@ -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) { diff --git a/common/content/events.js b/common/content/events.js index a47fb8e6..f61768b4 100644 --- a/common/content/events.js +++ b/common/content/events.js @@ -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; diff --git a/common/content/quickmarks.js b/common/content/quickmarks.js index 3d5aea40..14836ecf 100644 --- a/common/content/quickmarks.js +++ b/common/content/quickmarks.js @@ -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 }); } diff --git a/common/content/statusline.js b/common/content/statusline.js index f9ee56cf..4adab3ed 100644 --- a/common/content/statusline.js +++ b/common/content/statusline.js @@ -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 diff --git a/common/modules/base.jsm b/common/modules/base.jsm index 85835b6e..d8249c8e 100644 --- a/common/modules/base.jsm +++ b/common/modules/base.jsm @@ -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"] }); diff --git a/common/modules/storage.jsm b/common/modules/storage.jsm index e9c3cf12..73b21afc 100644 --- a/common/modules/storage.jsm +++ b/common/modules/storage.jsm @@ -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", { |