diff options
author | aruslan@chromium.org <aruslan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-02-04 21:03:36 +0000 |
---|---|---|
committer | aruslan@chromium.org <aruslan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-02-04 21:03:36 +0000 |
commit | 3e594582a1310e383f4bed00c5633d89e2d33415 (patch) | |
tree | fa03bc55d1fc101992e4b3bcd77951dbeb57ad5b /chrome/browser/resources/ntp_android/ntp_android.js | |
parent | d84ab4b5cb3921338e5b80711a9de37060521a72 (diff) | |
download | chromium_src-3e594582a1310e383f4bed00c5633d89e2d33415.zip chromium_src-3e594582a1310e383f4bed00c5633d89e2d33415.tar.gz chromium_src-3e594582a1310e383f4bed00c5633d89e2d33415.tar.bz2 |
Fix blurry favicons fetches on Android
This change depends on https://codereview.chromium.org/12041064/
Introduces a new scale factor for Nexus 7: SCALE_FACTOR_133P.
Uses max available density on Android instead of SCALE_FACTOR_100P.
BUG=172048
NOTRY=true
Review URL: https://chromiumcodereview.appspot.com/12084003
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@180518 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/resources/ntp_android/ntp_android.js')
-rw-r--r-- | chrome/browser/resources/ntp_android/ntp_android.js | 35 |
1 files changed, 23 insertions, 12 deletions
diff --git a/chrome/browser/resources/ntp_android/ntp_android.js b/chrome/browser/resources/ntp_android/ntp_android.js index 963dcb3..ff99293 100644 --- a/chrome/browser/resources/ntp_android/ntp_android.js +++ b/chrome/browser/resources/ntp_android/ntp_android.js @@ -582,7 +582,11 @@ cr.define('ntp', function() { cell.setAttribute(CONTEXT_MENU_URL_KEY, item.url); - var iconUrl = item.icon || 'chrome://touch-icon/size/16@1x/' + item.url; + var iconUrl = item.icon; + if (!iconUrl) { + iconUrl = 'chrome://touch-icon/size/16@' + window.devicePixelRatio + + 'x/' + item.url; + } var icon = createDiv('icon', iconUrl); trackImageLoad(iconUrl); cell.appendChild(icon); @@ -676,7 +680,7 @@ cr.define('ntp', function() { if (item.folder) { faviconBox.classList.add('folder'); } else { - var iconUrl = item.icon || 'chrome://touch-icon/' + item.url; + var iconUrl = item.icon || 'chrome://touch-icon/largest/' + item.url; var faviconIcon = createDiv('favicon-icon'); faviconIcon.style.backgroundImage = 'url(' + iconUrl + ')'; trackImageLoad(iconUrl); @@ -686,8 +690,10 @@ cr.define('ntp', function() { image.onload = function() { var w = image.width; var h = image.height; - if (w <= 16 || h <= 16) { - // it's a standard favicon (or at least it's small) + var wDip = w / window.devicePixelRatio; + var hDip = h / window.devicePixelRatio; + if (Math.floor(wDip) <= 16 || Math.floor(hDip) <= 16) { + // it's a standard favicon (or at least it's small). faviconBox.classList.add('document'); faviconBox.appendChild( @@ -704,21 +710,26 @@ cr.define('ntp', function() { foldContainer.appendChild(foldDiv); faviconBox.appendChild(foldContainer); + // FaviconWebUIHandler::HandleGetFaviconDominantColor expects + // an URL that starts with chrome://favicon/size/. + // The handler always loads 16x16 1x favicon and assumes that + // the dominant color for all scale factors is the same. chrome.send('getFaviconDominantColor', [('chrome://favicon/size/16@1x/' + item.url), '' + faviconIndex]); faviconIndex++; } else if ((w == 57 && h == 57) || (w == 114 && h == 114)) { - // it's a touch icon + // it's a touch icon for 1x or 2x. faviconIcon.classList.add('touch-icon'); } else { - // it's an html5 icon (or at least it's larger) - var max = 64; - if (w > max || h > max) { - var scale = (w > h) ? (max / w) : (max / h); - w *= scale; - h *= scale; + // It's an html5 icon (or at least it's larger). + // Rescale it to be no bigger than 64x64 dip. + var maxDip = 64; // DIP + if (wDip > maxDip || hDip > maxDip) { + var scale = (wDip > hDip) ? (maxDip / wDip) : (maxDip / hDip); + wDip *= scale; + hDip *= scale; } - faviconIcon.style.backgroundSize = w + 'px ' + h + 'px'; + faviconIcon.style.backgroundSize = wDip + 'px ' + hDip + 'px'; } }; faviconBox.appendChild(faviconIcon); |