зеркало из https://github.com/mozilla/gecko-dev.git
Bug 879113 part 1/2, favicon errorhandling-Start screen should handle error cases when missing favicons, thumbnails gracefully.r=mbrubeck
This commit is contained in:
Родитель
11d987731d
Коммит
64a0059353
|
@ -293,13 +293,15 @@ TopSitesView.prototype = {
|
|||
aTileNode.iconSrc = iconURLfromSiteURL.spec;
|
||||
let faviconURL = (PlacesUtils.favicons.getFaviconLinkForIcon(iconURLfromSiteURL)).spec;
|
||||
let xpFaviconURI = Util.makeURI(faviconURL.replace("moz-anno:favicon:",""));
|
||||
ColorUtils.getForegroundAndBackgroundIconColors(xpFaviconURI, function(foreground, background) {
|
||||
aTileNode.style.color = foreground; //color text
|
||||
let successAction = function(foreground, background) {
|
||||
aTileNode.style.color = foreground; //color text
|
||||
aTileNode.setAttribute("customColor", background);
|
||||
if (aTileNode.refresh) {
|
||||
aTileNode.refresh();
|
||||
}
|
||||
});
|
||||
};
|
||||
let failureAction = function() {};
|
||||
ColorUtils.getForegroundAndBackgroundIconColors(xpFaviconURI, successAction, failureAction);
|
||||
});
|
||||
|
||||
if (this._useThumbs) {
|
||||
|
|
|
@ -234,13 +234,15 @@ BookmarksView.prototype = {
|
|||
if (!aIconUri) {
|
||||
return;
|
||||
}
|
||||
ColorUtils.getForegroundAndBackgroundIconColors(aIconUri, function(foregroundColor, backgroundColor) {
|
||||
let successAction = function(foregroundColor, backgroundColor) {
|
||||
aItem.style.color = foregroundColor; //color text
|
||||
aItem.setAttribute("customColor", backgroundColor); //set background
|
||||
if (aItem.refresh) {
|
||||
aItem.refresh();
|
||||
}
|
||||
});
|
||||
};
|
||||
let failureAction = function() {};
|
||||
ColorUtils.getForegroundAndBackgroundIconColors(aIconUri, successAction, failureAction);
|
||||
},
|
||||
|
||||
_sendNeedsRefresh: function bv__sendNeedsRefresh(){
|
||||
|
|
|
@ -14,18 +14,20 @@ let ColorUtils = {
|
|||
* & background color as is desired) The first argument to the callback is
|
||||
* the foreground/contrast color, the second is the background/primary/dominant one
|
||||
*/
|
||||
getForegroundAndBackgroundIconColors: function getForegroundAndBackgroundIconColors(aIconURI, aSuccessCallback) {
|
||||
getForegroundAndBackgroundIconColors: function getForegroundAndBackgroundIconColors(aIconURI, aSuccessCallback, aErrorCallback) {
|
||||
if (!aIconURI) {
|
||||
return;
|
||||
}
|
||||
|
||||
let that = this;
|
||||
let wrappedIcon = aIconURI;
|
||||
ColorAnalyzer.findRepresentativeColor(wrappedIcon, function (success, color) {
|
||||
let foregroundColor = that.bestTextColorForContrast(color);
|
||||
let backgroundColor = that.convertDecimalToRgbColor(color);
|
||||
// let the caller do whatever it is they need through the callback
|
||||
aSuccessCallback(foregroundColor, backgroundColor);
|
||||
if (!success) {
|
||||
aErrorCallback();
|
||||
} else {
|
||||
let foregroundColor = that.bestTextColorForContrast(color);
|
||||
let backgroundColor = that.convertDecimalToRgbColor(color);
|
||||
aSuccessCallback(foregroundColor, backgroundColor);
|
||||
}
|
||||
}, this);
|
||||
},
|
||||
/** returns the best color for text readability on top of aColor
|
||||
|
|
Загрузка…
Ссылка в новой задаче