1
0
mirror of https://github.com/gryf/pentadactyl-pm.git synced 2026-02-16 16:15:45 +01:00

Do away with now unnecessary service variables.

This commit is contained in:
Kris Maglione
2010-12-01 22:17:19 -05:00
parent 5d51fd491a
commit 0748369c68
3 changed files with 31 additions and 36 deletions

View File

@@ -18,17 +18,13 @@ Bookmark.prototype.__defineGetter__("extra", function () [
["tags", this.tags.join(", "), "Tag"] ["tags", this.tags.join(", "), "Tag"]
].filter(function (item) item[1])); ].filter(function (item) item[1]));
const annotation = services.annotation; const name = "bookmark-cache";
const bookmarks = services.bookmarks;
const history = services.history;
const tagging = services.tagging;
const name = "bookmark-cache";
const BookmarkCache = Module("BookmarkCache", XPCOM(Ci.nsINavBookmarkObserver), { const BookmarkCache = Module("BookmarkCache", XPCOM(Ci.nsINavBookmarkObserver), {
POST: "bookmarkProperties/POSTData", POST: "bookmarkProperties/POSTData",
init: function init() { init: function init() {
bookmarks.addObserver(this, false); services.bookmarks.addObserver(this, false);
}, },
__iterator__: function () (val for ([, val] in Iterator(bookmarkcache.bookmarks))), __iterator__: function () (val for ([, val] in Iterator(bookmarkcache.bookmarks))),
@@ -38,7 +34,7 @@ const BookmarkCache = Module("BookmarkCache", XPCOM(Ci.nsINavBookmarkObserver),
get keywords() array.toObject([[b.keyword, b] for (b in this) if (b.keyword)]), get keywords() array.toObject([[b.keyword, b] for (b in this) if (b.keyword)]),
rootFolders: ["toolbarFolder", "bookmarksMenuFolder", "unfiledBookmarksFolder"] rootFolders: ["toolbarFolder", "bookmarksMenuFolder", "unfiledBookmarksFolder"]
.map(function (s) bookmarks[s]), .map(function (s) services.bookmarks[s]),
_deleteBookmark: function deleteBookmark(id) { _deleteBookmark: function deleteBookmark(id) {
let result = this.bookmarks[id] || null; let result = this.bookmarks[id] || null;
@@ -50,33 +46,31 @@ const BookmarkCache = Module("BookmarkCache", XPCOM(Ci.nsINavBookmarkObserver),
if (node.uri == null) // How does this happen? if (node.uri == null) // How does this happen?
return false; return false;
let uri = util.newURI(node.uri); let uri = util.newURI(node.uri);
let keyword = bookmarks.getKeywordForBookmark(node.itemId); let keyword = services.bookmarks.getKeywordForBookmark(node.itemId);
let tags = tagging.getTagsForURI(uri, {}) || []; let tags = services.tagging.getTagsForURI(uri, {}) || [];
let post = BookmarkCache.getAnnotation(node.itemId, this.POST); let post = BookmarkCache.getAnnotation(node.itemId, this.POST);
return Bookmark(node.uri, node.title, node.icon && node.icon.spec, post, keyword, tags, node.itemId); return Bookmark(node.uri, node.title, node.icon && node.icon.spec, post, keyword, tags, node.itemId);
}, },
get: function (url) { get: function (url) {
let ids = bookmarks.getBookmarkIdsForURI(util.newURI(url), {}); let ids = services.bookmarks.getBookmarkIdsForURI(util.newURI(url), {});
for (let id in values(ids)) for (let id in values(ids))
if (id in this.bookmarks) if (id in this.bookmarks)
return this.bookmarks[id]; return this.bookmarks[id];
return null; return null;
}, },
readBookmark: function readBookmark(id) { readBookmark: function readBookmark(id) ({
return { itemId: id,
itemId: id, uri: services.bookmarks.getBookmarkURI(id).spec,
uri: bookmarks.getBookmarkURI(id).spec, title: services.bookmarks.getItemTitle(id)
title: bookmarks.getItemTitle(id) }),
};
},
findRoot: function findRoot(id) { findRoot: function findRoot(id) {
do { do {
var root = id; var root = id;
id = bookmarks.getFolderIdForItem(id); id = services.bookmarks.getFolderIdForItem(id);
} while (id != bookmarks.placesRoot && id != root); } while (id != services.bookmarks.placesRoot && id != root);
return root; return root;
}, },
@@ -87,8 +81,8 @@ const BookmarkCache = Module("BookmarkCache", XPCOM(Ci.nsINavBookmarkObserver),
var root = id; var root = id;
if (services.livemark && services.livemark.isLivemark(id)) if (services.livemark && services.livemark.isLivemark(id))
return false; return false;
id = bookmarks.getFolderIdForItem(id); id = services.bookmarks.getFolderIdForItem(id);
} while (id != bookmarks.placesRoot && id != root); } while (id != services.bookmarks.placesRoot && id != root);
return this.rootFolders.indexOf(root) >= 0; return this.rootFolders.indexOf(root) >= 0;
}, },
@@ -97,12 +91,12 @@ const BookmarkCache = Module("BookmarkCache", XPCOM(Ci.nsINavBookmarkObserver),
let bookmarks = {}; let bookmarks = {};
let folders = this.rootFolders.slice(); let folders = this.rootFolders.slice();
let query = history.getNewQuery(); let query = services.history.getNewQuery();
let options = history.getNewQueryOptions(); let options = services.history.getNewQueryOptions();
while (folders.length > 0) { while (folders.length > 0) {
query.setFolders(folders, 1); query.setFolders(folders, 1);
folders.shift(); folders.shift();
let result = history.executeQuery(query, options); let result = services.history.executeQuery(query, options);
let folder = result.root; let folder = result.root;
folder.containerOpen = true; folder.containerOpen = true;
@@ -123,7 +117,7 @@ const BookmarkCache = Module("BookmarkCache", XPCOM(Ci.nsINavBookmarkObserver),
}, },
onItemAdded: function onItemAdded(itemId, folder, index) { onItemAdded: function onItemAdded(itemId, folder, index) {
if (bookmarks.getItemType(itemId) == bookmarks.TYPE_BOOKMARK) { if (services.bookmarks.getItemType(itemId) == services.bookmarks.TYPE_BOOKMARK) {
if (this.isBookmark(itemId)) { if (this.isBookmark(itemId)) {
let bmark = this._loadBookmark(this.readBookmark(itemId)); let bmark = this._loadBookmark(this.readBookmark(itemId));
this.bookmarks[bmark.id] = bmark; this.bookmarks[bmark.id] = bmark;
@@ -146,7 +140,7 @@ const BookmarkCache = Module("BookmarkCache", XPCOM(Ci.nsINavBookmarkObserver),
let bookmark = this.bookmarks[itemId]; let bookmark = this.bookmarks[itemId];
if (bookmark) { if (bookmark) {
if (property == "tags") if (property == "tags")
value = tagging.getTagsForURI(util.newURI(bookmark.url), {}); value = services.tagging.getTagsForURI(util.newURI(bookmark.url), {});
if (property in bookmark) { if (property in bookmark) {
bookmark[property] = value; bookmark[property] = value;
storage.fireEvent(name, "change", { __proto__: bookmark, changed: property }); storage.fireEvent(name, "change", { __proto__: bookmark, changed: property });
@@ -155,11 +149,11 @@ const BookmarkCache = Module("BookmarkCache", XPCOM(Ci.nsINavBookmarkObserver),
} }
}, { }, {
getAnnotation: function getAnnotation(item, anno) getAnnotation: function getAnnotation(item, anno)
annotation.itemHasAnnotation(item, anno) ? services.annotation.itemHasAnnotation(item, anno) ?
annotation.getItemAnnotation(item, anno) : null, services.annotation.getItemAnnotation(item, anno) : null,
getFavicon: function getFavicon(uri) { getFavicon: function getFavicon(uri) {
try { try {
return service.get("favicon").getFaviconImageForPage(util.newURI(uri)).spec; return services.favicon.getFaviconImageForPage(util.newURI(uri)).spec;
} }
catch (e) { catch (e) {
return ""; return "";

View File

@@ -11,7 +11,6 @@ defineModule("styles", {
use: ["template"] use: ["template"]
}); });
const sss = services.stylesheet;
function cssUri(css) "chrome-data:text/css," + encodeURI(css); function cssUri(css) "chrome-data:text/css," + encodeURI(css);
const namespace = "@namespace html " + XHTML.uri.quote() + ";\n" + const namespace = "@namespace html " + XHTML.uri.quote() + ";\n" +
"@namespace xul " + XUL.uri.quote() + ";\n" + "@namespace xul " + XUL.uri.quote() + ";\n" +
@@ -222,8 +221,10 @@ const Styles = Module("Styles", {
let uri = services.io.newURI(url, null, null); let uri = services.io.newURI(url, null, null);
if (reload) if (reload)
this.unregisterSheet(url, agent); this.unregisterSheet(url, agent);
if (reload || !sss.sheetRegistered(uri, agent ? sss.AGENT_SHEET : sss.USER_SHEET))
sss.loadAndRegisterSheet(uri, agent ? sss.AGENT_SHEET : sss.USER_SHEET); let type = services.stylesheet[agent ? "AGENT_SHEET" : "USER_SHEET"];
if (reload || !services.stylesheet.sheetRegistered(uri, type))
services.stylesheet.loadAndRegisterSheet(uri, type);
}, },
/** /**
@@ -234,8 +235,9 @@ const Styles = Module("Styles", {
*/ */
unregisterSheet: function unregisterSheet(url, agent) { unregisterSheet: function unregisterSheet(url, agent) {
let uri = services.io.newURI(url, null, null); let uri = services.io.newURI(url, null, null);
if (sss.sheetRegistered(uri, agent ? sss.AGENT_SHEET : sss.USER_SHEET)) let type = services.stylesheet[agent ? "AGENT_SHEET" : "USER_SHEET"];
sss.unregisterSheet(uri, agent ? sss.AGENT_SHEET : sss.USER_SHEET); if (services.stylesheet.sheetRegistered(uri, type))
services.stylesheet.unregisterSheet(uri, type);
}, },
}, { }, {
completeSite: function (context, content) { completeSite: function (context, content) {

View File

@@ -312,8 +312,7 @@ const Config = Module("config", ConfigBase, {
"boolean", true, "boolean", true,
{ {
setter: function (value) { setter: function (value) {
const ioService = services.io; if (services.io.offline == value)
if (ioService.offline == value)
BrowserOffline.toggleOfflineStatus(); BrowserOffline.toggleOfflineStatus();
return value; return value;
}, },