Bug 784042 - Use mozIColorAnalyzer for autocomplete search result tiles. r=mbrubeck
☠☠ backed out by 87cb292f3470 ☠ ☠
authorAllison Naaktgeboren <ally@mozilla.com>
Fri, 28 Feb 2014 16:59:07 -0500
changeset 171787 ebcbf7155214548727b891a432671666d02b6344
parent 171786 47ac0c7dd66ef93389e3fa548ad27c124e1c55f3
child 171788 e3ce8fb65c5fc75e27fada38427632529f42bf05
push id270
push userpvanderbeken@mozilla.com
push dateThu, 06 Mar 2014 09:24:21 +0000
reviewersmbrubeck
bugs784042
milestone30.0a1
Bug 784042 - Use mozIColorAnalyzer for autocomplete search result tiles. r=mbrubeck
browser/metro/base/content/bindings/urlbar.xml
--- a/browser/metro/base/content/bindings/urlbar.xml
+++ b/browser/metro/base/content/bindings/urlbar.xml
@@ -729,16 +729,32 @@
               let value = controller.getValueAt(i);
               let label = controller.getCommentAt(i) || value;
               let iconURI = controller.getImageAt(i);
 
               item.setAttribute("autocomplete", true);
               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() {
+                Components.utils.import("resource:///modules/colorUtils.jsm");
+                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();
           ]]>
         </body>
       </method>
 
       <!-- Updating grid content: search engines -->