diff --git a/common/content/bookmarks.js b/common/content/bookmarks.js
index a5ca998b..a11ce6ba 100644
--- a/common/content/bookmarks.js
+++ b/common/content/bookmarks.js
@@ -60,7 +60,7 @@ function Bookmarks() //{{{
const historyService = PlacesUtils.history;
const bookmarksService = PlacesUtils.bookmarks;
const taggingService = PlacesUtils.tagging;
- const faviconService = Cc["@mozilla.org/browser/favicon-service;1"].getService(Ci.nsIFaviconService);
+ const faviconService = services.get("favicon");
// XXX for strange Firefox bug :(
// Error: [Exception... "Component returned failure code: 0x8000ffff (NS_ERROR_UNEXPECTED) [nsIObserverService.addObserver]"
@@ -863,7 +863,7 @@ function History() //{{{
context.anchored = false;
context.completions = sh.slice(0, sh.index).reverse();
- context.keys = { text: function (item) (sh.index - item.index) + ": " + item.URI.spec, description: "title" };
+ context.keys = { text: function (item) (sh.index - item.index) + ": " + item.URI.spec, description: "title", icon: "icon" };
context.compare = CompletionContext.Sort.unsorted;
context.filters = [CompletionContext.Filter.textDescription];
},
@@ -905,7 +905,7 @@ function History() //{{{
context.anchored = false;
context.completions = sh.slice(sh.index + 1);
- context.keys = { text: function (item) (item.index - sh.index) + ": " + item.URI.spec, description: "title" };
+ context.keys = { text: function (item) (item.index - sh.index) + ": " + item.URI.spec, description: "title", icon: "icon" };
context.compare = CompletionContext.Sort.unsorted;
context.filters = [CompletionContext.Filter.textDescription];
},
@@ -988,7 +988,11 @@ function History() //{{{
obj.index = sh.index;
obj.__iterator__ = function() util.Array.iteritems(this)
for (let i in util.range(0, sh.count))
+ {
obj[i] = { index: i, __proto__: sh.getEntryAtIndex(i, false) };
+ util.memoize(obj[i], "icon",
+ function (obj) services.get("favicon").getFaviconImageForPage(obj.URI).spec);
+ }
return obj;
},
diff --git a/common/content/completion.js b/common/content/completion.js
index a4e9c4f7..1f7d7ffd 100644
--- a/common/content/completion.js
+++ b/common/content/completion.js
@@ -1232,7 +1232,7 @@ function Completion() //{{{
{
let arg = str.substring(prev + 1, idx);
prev = idx;
- args.__defineGetter__(i, function () self.eval(arg));
+ util.memoize(args, i, function () self.eval(arg));
}
let key = getKey();
args.push(key + string);
diff --git a/common/content/services.js b/common/content/services.js
index e27a6a63..b9c7edc3 100644
--- a/common/content/services.js
+++ b/common/content/services.js
@@ -94,6 +94,7 @@ function Services()
self.add("directory", "@mozilla.org/file/directory_service;1", Ci.nsIProperties);
self.add("environment", "@mozilla.org/process/environment;1", Ci.nsIEnvironment);
self.add("extensionManager", "@mozilla.org/extensions/manager;1", Ci.nsIExtensionManager);
+ self.add("favicon", "@mozilla.org/browser/favicon-service;1", Ci.nsIFaviconService);
self.add("json", "@mozilla.org/dom/json;1", Ci.nsIJSON, "createInstance");
self.add("observer", "@mozilla.org/observer-service;1", Ci.nsIObserverService);
self.add("io", "@mozilla.org/network/io-service;1", Ci.nsIIOService);
diff --git a/common/content/util.js b/common/content/util.js
index 475c83aa..b014da49 100644
--- a/common/content/util.js
+++ b/common/content/util.js
@@ -178,6 +178,25 @@ const util = { //{{{
return dest;
},
+ /**
+ * Memoize the lookup of a property in an object.
+ *
+ * @param {object} obj The object to alter.
+ * @param {string} key The name of the property to memoize.
+ * @param {function} getter A function of zero to two arguments which
+ * will return the property's value. obj is
+ * passed as the first argument, key as the
+ * second.
+ */
+ memoize: function memoize(obj, key, getter)
+ {
+ obj.__defineGetter__(key, function() {
+ delete obj[key]
+ obj[key] = getter(obj, key);
+ return obj[key];
+ });
+ },
+
/**
* Split a string on literal occurrences of a marker.
*