Bug 1113096 - Low quality favicons in new search preferences. r=florian, a=sledru
authorabdelrhman <codo.abdo@gmail.com>
Sun, 21 Dec 2014 01:11:58 +0100
changeset 242570 ceb5206306539ea37262bdcf710ad21fb6ec9b98
parent 242569 0be8fa650e1ca9d6dc4616d15764df6b8c3c012c
child 242571 b0105aa80d959f6eb9685278a642aacc8cfcaeb5
push id4311
push userraliiev@mozilla.com
push dateMon, 12 Jan 2015 19:37:41 +0000
treeherdermozilla-beta@150c9fed433b [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersflorian, sledru
bugs1113096
milestone36.0a2
Bug 1113096 - Low quality favicons in new search preferences. r=florian, a=sledru
browser/components/preferences/in-content/search.js
browser/components/preferences/search.js
--- a/browser/components/preferences/in-content/search.js
+++ b/browser/components/preferences/in-content/search.js
@@ -1,13 +1,14 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 Components.utils.import("resource://gre/modules/XPCOMUtils.jsm");
+Components.utils.import("resource://gre/modules/PlacesUtils.jsm");
 
 const ENGINE_FLAVOR = "text/x-moz-search-engine";
 
 var gEngineView = null;
 
 var gSearchPane = {
 
   init: function ()
@@ -47,18 +48,20 @@ var gSearchPane = {
     if (!engines.some(e => e.name == currentEngine))
       currentEngine = engines[0].name;
 
     // Now clean-up and rebuild the list.
     list.removeAllItems();
     gEngineView._engineStore._engines.forEach(e => {
       let item = list.appendItem(e.name);
       item.setAttribute("class", "menuitem-iconic searchengine-menuitem menuitem-with-favicon");
-      if (e.iconURI)
-        item.setAttribute("image", e.iconURI.spec);
+      if (e.iconURI) {
+        let uri = PlacesUtils.getImageURLForResolution(window, e.iconURI.spec);
+        item.setAttribute("image", uri);
+      }
       item.engine = e;
       if (e.name == currentEngine)
         list.selectedItem = item;
     });
   },
 
   observe: function(aEngine, aTopic, aVerb) {
     if (aTopic == "browser-search-engine-modified") {
@@ -357,18 +360,20 @@ EngineView.prototype = {
   },
 
   // nsITreeView
   get rowCount() {
     return this._engineStore.engines.length;
   },
 
   getImageSrc: function(index, column) {
-    if (column.id == "engineName" && this._engineStore.engines[index].iconURI)
-      return this._engineStore.engines[index].iconURI.spec;
+    if (column.id == "engineName" && this._engineStore.engines[index].iconURI) {
+      let uri = this._engineStore.engines[index].iconURI.spec;
+      return PlacesUtils.getImageURLForResolution(window, uri);
+    }
     return "";
   },
 
   getCellText: function(index, column) {
     if (column.id == "engineName")
       return this._engineStore.engines[index].name;
     else if (column.id == "engineKeyword")
       return this._engineStore.engines[index].alias;
--- a/browser/components/preferences/search.js
+++ b/browser/components/preferences/search.js
@@ -1,13 +1,14 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 Components.utils.import("resource://gre/modules/XPCOMUtils.jsm");
+Components.utils.import("resource://gre/modules/PlacesUtils.jsm");
 
 const ENGINE_FLAVOR = "text/x-moz-search-engine";
 
 var gEngineView = null;
 
 var gSearchPane = {
 
   init: function ()
@@ -40,18 +41,20 @@ var gSearchPane = {
     if (!engines.some(e => e.name == currentEngine))
       currentEngine = engines[0].name;
 
     // Now clean-up and rebuild the list.
     list.removeAllItems();
     gEngineView._engineStore._engines.forEach(e => {
       let item = list.appendItem(e.name);
       item.setAttribute("class", "menuitem-iconic searchengine-menuitem menuitem-with-favicon");
-      if (e.iconURI)
-        item.setAttribute("image", e.iconURI.spec);
+      if (e.iconURI) {
+        let uri = PlacesUtils.getImageURLForResolution(window, e.iconURI.spec);
+        item.setAttribute("image", uri);
+      }
       item.engine = e;
       if (e.name == currentEngine)
         list.selectedItem = item;
     });
   },
 
   observe: function(aEngine, aTopic, aVerb) {
     if (aTopic == "browser-search-engine-modified") {
@@ -428,18 +431,20 @@ EngineView.prototype = {
   },
 
   // nsITreeView
   get rowCount() {
     return this._engineStore.engines.length;
   },
 
   getImageSrc: function(index, column) {
-    if (column.id == "engineName" && this._engineStore.engines[index].iconURI)
-      return this._engineStore.engines[index].iconURI.spec;
+    if (column.id == "engineName" && this._engineStore.engines[index].iconURI) {
+      let uri = this._engineStore.engines[index].iconURI.spec;
+      return PlacesUtils.getImageURLForResolution(window, uri);
+    }
     return "";
   },
 
   getCellText: function(index, column) {
     if (column.id == "engineName")
       return this._engineStore.engines[index].name;
     else if (column.id == "engineKeyword")
       return this._engineStore.engines[index].alias;