From aa1398614206a6a6ce08a0c6b36fa180db16e291 Mon Sep 17 00:00:00 2001 From: Martin Stubenschrott Date: Thu, 20 Nov 2008 21:55:41 +0000 Subject: [PATCH] fixed favicons in :hs and :bmarks output (:bmarks filter still broken) --- content/bookmarks.js | 8 ++++++-- content/ui.js | 23 +++++++++++++---------- 2 files changed, 19 insertions(+), 12 deletions(-) diff --git a/content/bookmarks.js b/content/bookmarks.js index e1f753d9..247c8609 100644 --- a/content/bookmarks.js +++ b/content/bookmarks.js @@ -26,6 +26,9 @@ the provisions above, a recipient may use your version of this file under the terms of any one of the MPL, the GPL or the LGPL. }}} ***** END LICENSE BLOCK *****/ +// TODO: with the new subscript loader, is there really no way to keep variable in per-file scope? +const DEFAULT_FAVICON = "chrome://mozapps/skin/places/defaultFavicon.png"; + // also includes methods for dealing with keywords and search engines function Bookmarks() //{{{ { @@ -74,7 +77,7 @@ function Bookmarks() //{{{ let keyword = bookmarksService.getKeywordForBookmark(node.itemId); let tags = taggingService.getTagsForURI(uri, {}) || []; //return bookmarks.push(new Bookmark(node.uri, node.title, null, keyword, tags, node.itemId)); - return bookmarks.push({url: node.uri, title: node.title, icon: null, keyword: keyword, tags: tags, id: node.itemId}); + return bookmarks.push({ url: node.uri, title: node.title, get icon() getFavicon(node.uri), keyword: keyword, tags: tags, id: node.itemId}); } function readBookmark(id) @@ -715,7 +718,7 @@ function History() //{{{ { let node = root.getChild(i); if (node.type == node.RESULT_TYPE_URI) // just make sure it's a bookmark - items.push({ url: node.uri, title: node.title, get icon() function() bookmarks.getFavicon(node.uri) }); + items.push({ url: node.uri, title: node.title, icon: node.icon ? node.icon.spec : DEFAULT_FAVICON }); } root.containerOpen = false; // close a container after using it! @@ -942,6 +945,7 @@ function QuickMarks() //{{{ } let items = ({ title: String(mark), url: qmarks.get(mark) } for each (mark in marks)); + // TODO: template.bookmarks is not the best for quickmarks let list = template.bookmarks("QuickMark", items); commandline.echo(list, commandline.HL_NORMAL, commandline.FORCE_MULTILINE); } diff --git a/content/ui.js b/content/ui.js index c755865a..e345f232 100644 --- a/content/ui.js +++ b/content/ui.js @@ -1324,31 +1324,34 @@ function ItemList(id) //{{{ } // TODO: move to completions? - function createDefaultRow([b, c, a], dom) + function createDefaultRow(item, dom) { + if (item instanceof Array) + item = { text: item[0], description: item[1], icon: item[2] }; + /* Kludge until we have completion contexts. */ let map = completion.filterMap; if (map) { - b = map[0] ? map[0](b) : b; - c = map[1] ? map[1](c) : c; + item.text = map[0] ? map[0](item.text) : item.text; + item.description = map[1] ? map[1](item.description) : item.description; } /* Obviously, ItemList shouldn't know or care about this. */ let filter = completion.filterString; if (filter) { - b = template.highlightFilter(b, filter); - c = template.highlightFilter(c, filter); + item.text = template.highlightFilter(item.text, filter); + item.description = template.highlightFilter(item.description, filter); } - if (typeof a == "function") - a = a(); + if (typeof item.icon == "function") + item.icon = item.icon(); let row = ; if (dom)