Bug 784042 - Use mozIColorAnalyzer for autocomplete search result tiles.r=mbrubeck

This commit is contained in:
Allison Naaktgeboren 2014-03-02 10:23:45 -08:00
parent 151a99c3d6
commit 1e2b39e743
2 changed files with 18 additions and 0 deletions

View File

@ -734,6 +734,21 @@
item.setAttribute("label", label);
item.setAttribute("value", value);
item.setAttribute("iconURI", iconURI);
let xpFaviconURI = Services.io.newURI(iconURI.replace("moz-anno:favicon:",""), null, null);
Task.spawn(function() {
let colorInfo = yield ColorUtils.getForegroundAndBackgroundIconColors(xpFaviconURI);
if ( !(colorInfo && colorInfo.background && colorInfo.foreground)
|| (item.getAttribute("iconURI") != iconURI) ) {
return;
}
let { background, foreground } = colorInfo;
item.style.color = foreground; //color text
item.setAttribute("customColor", background);
// when bound, use the setter to propogate the color change through the tile
if ('color' in item) {
item.color = background;
}
}).then(null, err => Components.utils.reportError(err));
}
this._results.arrangeItems();

View File

@ -40,6 +40,9 @@ XPCOMUtils.defineLazyModuleGetter(this, "NewTabUtils",
XPCOMUtils.defineLazyModuleGetter(this, "Promise",
"resource://gre/modules/commonjs/sdk/core/promise.js");
XPCOMUtils.defineLazyModuleGetter(this, "ColorUtils",
"resource:///modules/colorUtils.jsm");
#ifdef NIGHTLY_BUILD
XPCOMUtils.defineLazyModuleGetter(this, "ShumwayUtils",
"resource://shumway/ShumwayUtils.jsm");