1
0
mirror of https://github.com/gryf/pentadactyl-pm.git synced 2025-12-20 17:47:59 +01:00

Cache bookmarkcache.keywords.

This commit is contained in:
Kris Maglione
2011-02-05 16:22:25 -05:00
parent 96bce6efdf
commit 4d47bfe002
3 changed files with 12 additions and 14 deletions

View File

@@ -192,8 +192,8 @@ var Bookmarks = Module("bookmarks", {
let aliases = {}; let aliases = {};
return iter(services.browserSearch.getVisibleEngines({})).map(function ([, engine]) { return iter(services.browserSearch.getVisibleEngines({})).map(function ([, engine]) {
let alias = engine.alias; let alias = engine.alias;
if (!alias || !/^[a-z-]+$/.test(alias)) if (!alias || !/^[a-z0-9-]+$/.test(alias))
alias = engine.name.replace(/[^a-z_-]+/gi, "-").replace(/^-|-$/, "").toLowerCase(); alias = engine.name.replace(/[^a-z0-9]+/gi, "-").replace(/^-|-$/, "").toLowerCase();
if (!alias) if (!alias)
alias = "search"; // for search engines which we can't find a suitable alias alias = "search"; // for search engines which we can't find a suitable alias
@@ -248,12 +248,6 @@ var Bookmarks = Module("bookmarks", {
return process(resp); return process(resp);
}, },
/**
* Returns an array of bookmark keyword objects.
* @deprecated
*/
getKeywords: function getKeywords() bookmarkcache.keywords,
/** /**
* Returns an array containing a search URL and POST data for the * Returns an array containing a search URL and POST data for the
* given search string. If *useDefsearch* is true, the string is * given search string. If *useDefsearch* is true, the string is
@@ -600,7 +594,7 @@ var Bookmarks = Module("bookmarks", {
completion.search = function search(context, noSuggest) { completion.search = function search(context, noSuggest) {
let [, keyword, space, args] = context.filter.match(/^\s*(\S*)(\s*)(.*)$/); let [, keyword, space, args] = context.filter.match(/^\s*(\S*)(\s*)(.*)$/);
let keywords = bookmarks.getKeywords(); let keywords = bookmarkcache.keywords;
let engines = bookmarks.searchEngines; let engines = bookmarks.searchEngines;
context.title = ["Search Keywords"]; context.title = ["Search Keywords"];

View File

@@ -324,13 +324,13 @@ var Buffer = Module("buffer", {
if (win && uri) { if (win && uri) {
statusline.progress = win.dactylProgress; statusline.progress = win.dactylProgress;
let oldURI = webProgress.document.dactylURI; let oldURI = win.document.dactylURI;
if (webProgress.document.dactylLoadIdx === webProgress.loadedTransIndex if (win.document.dactylLoadIdx === webProgress.loadedTransIndex
|| !oldURI || uri.spec.replace(/#.*/, "") !== oldURI.replace(/#.*/, "")) || !oldURI || uri.spec.replace(/#.*/, "") !== oldURI.replace(/#.*/, ""))
for (let frame in values(buffer.allFrames(win))) for (let frame in values(buffer.allFrames(win)))
frame.document.dactylFocusAllowed = false; frame.document.dactylFocusAllowed = false;
webProgress.document.dactylURI = uri.spec; win.document.dactylURI = uri.spec;
webProgress.document.dactylLoadIdx = webProgress.loadedTransIndex; win.document.dactylLoadIdx = webProgress.loadedTransIndex;
} }
// Workaround for bugs 591425 and 606877, dactyl bug #81 // Workaround for bugs 591425 and 606877, dactyl bug #81

View File

@@ -63,7 +63,7 @@ var BookmarkCache = Module("BookmarkCache", XPCOM(Ci.nsINavBookmarkObserver), {
get bookmarks() Class.replaceProperty(this, "bookmarks", this.load()), get bookmarks() Class.replaceProperty(this, "bookmarks", this.load()),
get keywords() array.toObject([[b.keyword, b] for (b in this) if (b.keyword)]), keywords: Class.memoize(function () array.toObject([[b.keyword, b] for (b in this) if (b.keyword)])),
rootFolders: ["toolbarFolder", "bookmarksMenuFolder", "unfiledBookmarksFolder"] rootFolders: ["toolbarFolder", "bookmarksMenuFolder", "unfiledBookmarksFolder"]
.map(function (s) services.bookmarks[s]), .map(function (s) services.bookmarks[s]),
@@ -185,11 +185,13 @@ var BookmarkCache = Module("BookmarkCache", XPCOM(Ci.nsINavBookmarkObserver), {
let bmark = this._loadBookmark(this.readBookmark(itemId)); let bmark = this._loadBookmark(this.readBookmark(itemId));
this.bookmarks[bmark.id] = bmark; this.bookmarks[bmark.id] = bmark;
storage.fireEvent(name, "add", bmark); storage.fireEvent(name, "add", bmark);
delete this.keywords;
} }
} }
}, },
onItemRemoved: function onItemRemoved(itemId, folder, index) { onItemRemoved: function onItemRemoved(itemId, folder, index) {
let result = this._deleteBookmark(itemId); let result = this._deleteBookmark(itemId);
delete this.keywords;
if (result) if (result)
storage.fireEvent(name, "remove", result); storage.fireEvent(name, "remove", result);
}, },
@@ -204,6 +206,8 @@ var BookmarkCache = Module("BookmarkCache", XPCOM(Ci.nsINavBookmarkObserver), {
let bookmark = this.bookmarks[itemId]; let bookmark = this.bookmarks[itemId];
if (bookmark) { if (bookmark) {
if (property == "keyword")
delete this.keywords;
if (property == "tags") if (property == "tags")
value = services.tagging.getTagsForURI(bookmark.uri, {}); value = services.tagging.getTagsForURI(bookmark.uri, {});
if (property in bookmark) { if (property in bookmark) {