mirror of
https://github.com/gryf/pentadactyl-pm.git
synced 2026-02-12 10:05:45 +01:00
Use temp files rather than URL arguments for :viewsource!. Also update the statusline on :redraw and add an XPCOM shim class for pseudo-XPCOM objects.
This commit is contained in:
@@ -139,12 +139,11 @@ defineModule("base", {
|
||||
// sed -n 's/^(const|function) ([a-zA-Z0-9_]+).*/ "\2",/p' base.jsm | sort | fmt
|
||||
exports: [
|
||||
"Cc", "Ci", "Class", "Cr", "Cu", "Module", "Object", "Runnable",
|
||||
"Struct", "StructBase", "Timer", "UTF8", "XPCOMUtils", "array",
|
||||
"Struct", "StructBase", "Timer", "UTF8", "XPCOM", "XPCOMUtils", "array",
|
||||
"call", "callable", "curry", "debuggerProperties", "defineModule",
|
||||
"endModule", "forEach", "isArray", "isGenerator", "isinstance",
|
||||
"isObject", "isString", "isSubclass", "iter", "iterAll", "keys",
|
||||
"memoize", "properties", "requiresMainThread", "set", "update",
|
||||
"values"
|
||||
"memoize", "properties", "requiresMainThread", "set", "update", "values"
|
||||
],
|
||||
use: ["services"]
|
||||
});
|
||||
@@ -700,6 +699,25 @@ Class.extend = function extend(subclass, superclass, overrides) {
|
||||
superclass.prototype.constructor = superclass;
|
||||
}
|
||||
|
||||
/**
|
||||
* A base class generator for classes which impliment XPCOM interfaces.
|
||||
*
|
||||
* @param {nsIIID|[nsIJSIID]} interfaces The interfaces which the class
|
||||
* implements.
|
||||
* @param {Class} superClass A super class. @optional
|
||||
* @returns {Class}
|
||||
*/
|
||||
function XPCOM(interfaces, superClass) {
|
||||
interfaces = Array.concat(interfaces);
|
||||
let shim = interfaces.reduce(function (shim, iface) shim.QueryInterface(iface),
|
||||
Cc["@dactyl.googlecode.com/base/xpc-interface-shim"].createInstance());
|
||||
let res = Class("XPCOM(" + interfaces + ")", superClass || Class, update(
|
||||
array([k, v === undefined || callable(v) ? function stub() null : v] for ([k, v] in Iterator(shim))).toObject(),
|
||||
{ QueryInterface: XPCOMUtils.generateQI(interfaces) }));
|
||||
shim = interfaces = null;
|
||||
return res;
|
||||
}
|
||||
|
||||
/**
|
||||
* Memoizes the value of a class property to the falue returned by
|
||||
* the passed function the first time the property is accessed.
|
||||
|
||||
@@ -24,7 +24,7 @@ const history = services.get("history");
|
||||
const tagging = services.get("tagging");
|
||||
const name = "bookmark-cache";
|
||||
|
||||
const BookmarkCache = Module("BookmarkCache", {
|
||||
const BookmarkCache = Module("BookmarkCache", XPCOM(Ci.nsINavBookmarkObserver), {
|
||||
init: function init() {
|
||||
bookmarks.addObserver(this, false);
|
||||
},
|
||||
@@ -116,11 +116,6 @@ const BookmarkCache = Module("BookmarkCache", {
|
||||
return bookmarks;
|
||||
},
|
||||
|
||||
onBeforeItemRemoved: function () {},
|
||||
onBeginUpdateBatch: function () {},
|
||||
onEndUpdateBatch: function () {},
|
||||
onItemVisited: function () {},
|
||||
onItemMoved: function () {},
|
||||
onItemAdded: function onItemAdded(itemId, folder, index) {
|
||||
if (bookmarks.getItemType(itemId) == bookmarks.TYPE_BOOKMARK) {
|
||||
if (this.isBookmark(itemId)) {
|
||||
@@ -147,8 +142,7 @@ const BookmarkCache = Module("BookmarkCache", {
|
||||
storage.fireEvent(name, "change", { __proto__: bookmark, changed: property });
|
||||
}
|
||||
}
|
||||
},
|
||||
QueryInterface: XPCOMUtils.generateQI([Ci.nsINavBookmarkObserver])
|
||||
}
|
||||
}, {
|
||||
getFavicon: function getFavicon(uri) {
|
||||
try {
|
||||
|
||||
@@ -29,7 +29,7 @@ Range.prototype.contains = function (date)
|
||||
Range.prototype.__defineGetter__("isEternity", function () this.max == null && this.min == null);
|
||||
Range.prototype.__defineGetter__("isSession", function () this.max == null && this.min == sanitizer.sessionStart);
|
||||
|
||||
const Sanitizer = Module("sanitizer", tmp.Sanitizer, {
|
||||
const Sanitizer = Module("sanitizer", XPCOM([Ci.nsIObserver, Ci.nsISupportsWeakReference], tmp.Sanitizer), {
|
||||
sessionStart: Date.now() * 1000,
|
||||
|
||||
init: function () {
|
||||
@@ -90,8 +90,6 @@ const Sanitizer = Module("sanitizer", tmp.Sanitizer, {
|
||||
util.addObserver(this);
|
||||
},
|
||||
|
||||
QueryInterface: XPCOMUtils.generateQI([Ci.nsIObserver, Ci.nsISupportsWeakReference]),
|
||||
|
||||
addItem: function addItem(name, params) {
|
||||
if (params.description)
|
||||
this.itemDescriptions[name] = params.description;
|
||||
|
||||
Reference in New Issue
Block a user