Bug 1453580 - Remove promiseFaviconLinkUrl and fix its consumers. r=Gijs

MozReview-Commit-ID: GrY8s3l71Mp

--HG--
extra : rebase_source : e8a1adb7c1004eaefddc42d12048d445eecd6530
This commit is contained in:
Marco Bonardo 2018-04-16 18:24:06 +02:00
Родитель 70287b8bfb
Коммит b00d20562d
5 изменённых файлов: 24 добавлений и 63 удалений

Просмотреть файл

@ -22,16 +22,21 @@ var ReaderParent = {
switch (message.name) {
case "Reader:FaviconRequest": {
if (message.target.messageManager) {
let faviconUrl = PlacesUtils.promiseFaviconLinkUrl(message.data.url);
faviconUrl.then(function onResolution(favicon) {
message.target.messageManager.sendAsyncMessage("Reader:FaviconReturn", {
url: message.data.url,
faviconUrl: favicon.pathQueryRef.replace(/^favicon:/, "")
});
},
function onRejection(reason) {
Cu.reportError("Error requesting favicon URL for about:reader content: " + reason);
}).catch(Cu.reportError);
try {
let preferredWidth = message.data.preferredWidth || 0;
let uri = Services.io.newURI(message.data.url);
PlacesUtils.favicons.getFaviconURLForPage(uri, iconUri => {
if (iconUri) {
iconUri = PlacesUtils.favicons.getFaviconLinkForIcon(iconUri);
message.target.messageManager.sendAsyncMessage("Reader:FaviconReturn", {
url: message.data.url,
faviconUrl: iconUri.pathQueryRef.replace(/^favicon:/, "")
});
}
}, preferredWidth);
} catch (ex) {
Cu.reportError("Error requesting favicon URL for about:reader content: " + ex);
}
}
break;
}

Просмотреть файл

@ -53,12 +53,10 @@ let SyncedTabsInternal = {
icon = tab.icon;
}
if (!icon) {
try {
icon = (await PlacesUtils.promiseFaviconLinkUrl(url)).spec;
} catch (ex) { /* no favicon avaiable */ }
}
if (!icon) {
icon = "";
// By not specifying a size the favicon service will pick the default,
// that is usually set through setDefaultIconURIPreferredSize by the
// first browser window. Commonly it's 16px at current dpi.
icon = "page-icon:" + url;
}
return {
type: "tab",

Просмотреть файл

@ -118,14 +118,7 @@ function setFilter(aFilterString) {
}
let signonsTreeView = {
// Keep track of which favicons we've fetched or started fetching.
// Maps a login origin to a favicon URL.
_faviconMap: new Map(),
_filterSet: [],
// Coalesce invalidations to avoid repeated flickering.
_invalidateTask: new DeferredTask(() => {
signonsTree.treeBoxObject.invalidateColumn(signonsTree.columns.siteCol);
}, 10, 0),
_lastSelectedRanges: [],
selection: null,
@ -138,22 +131,7 @@ let signonsTreeView = {
const signon = GetVisibleLogins()[row];
// We already have the favicon URL or we started to fetch (value is null).
if (this._faviconMap.has(signon.hostname)) {
return this._faviconMap.get(signon.hostname);
}
// Record the fact that we already starting fetching a favicon for this
// origin in order to avoid multiple requests for the same origin.
this._faviconMap.set(signon.hostname, null);
PlacesUtils.promiseFaviconLinkUrl(signon.hostname)
.then(faviconURI => {
this._faviconMap.set(signon.hostname, faviconURI.spec);
this._invalidateTask.arm();
}).catch(Cu.reportError);
return "";
return PlacesUtils.urlWithSizeRef(window, "page-icon:" + signon.hostname, 16);
},
getCellValue(row, column) {},
getCellText(row, column) {

Просмотреть файл

@ -1528,29 +1528,6 @@ var PlacesUtils = {
});
},
/**
* Gets the favicon link url (moz-anno:) for a given page url.
*
* @param aPageURL url of the page to lookup the favicon for.
* @resolves to the nsIURL of the favicon link
* @rejects if the given url has no associated favicon.
*/
promiseFaviconLinkUrl(aPageUrl) {
return new Promise((resolve, reject) => {
if (!(aPageUrl instanceof Ci.nsIURI))
aPageUrl = NetUtil.newURI(aPageUrl);
PlacesUtils.favicons.getFaviconURLForPage(aPageUrl, uri => {
if (uri) {
uri = PlacesUtils.favicons.getFaviconLinkForIcon(uri);
resolve(uri);
} else {
reject("favicon not found for uri");
}
});
});
},
/**
* Returns the passed URL with a #size ref for the specified size and
* devicePixelRatio.

Просмотреть файл

@ -703,7 +703,10 @@ AboutReader.prototype = {
};
this._mm.addMessageListener("Reader:FaviconReturn", handleFaviconReturn);
this._mm.sendAsyncMessage("Reader:FaviconRequest", { url: this._article.url });
this._mm.sendAsyncMessage("Reader:FaviconRequest", {
url: this._article.url,
preferredWidth: 16 * this._win.devicePixelRatio
});
},
_loadFavicon(url, faviconUrl) {