Commit 07cb9bd4 authored by kkimlabs@chromium.org's avatar kkimlabs@chromium.org

[Android] Fix NTP bookmark image unit for low resolution device.

makeBookmarkItem() function incorrectly converted image size to dip, but
actually it is already dip, so we don't need the conversion. This caused
16px x 16px icon to be classified as non-standard favicon(or small) on low
resolution(ldpi) devices and as a result, it didn't draw the document background.

BUG=238928

Review URL: https://chromiumcodereview.appspot.com/17257004

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@208067 0039d316-1c4b-4281-b951-d872f2087c98
parent 721c5a66
...@@ -707,9 +707,7 @@ cr.define('ntp', function() { ...@@ -707,9 +707,7 @@ cr.define('ntp', function() {
image.onload = function() { image.onload = function() {
var w = image.width; var w = image.width;
var h = image.height; var h = image.height;
var wDip = w / window.devicePixelRatio; if (Math.floor(w) <= 16 || Math.floor(h) <= 16) {
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). // it's a standard favicon (or at least it's small).
faviconBox.classList.add('document'); faviconBox.classList.add('document');
...@@ -740,13 +738,13 @@ cr.define('ntp', function() { ...@@ -740,13 +738,13 @@ cr.define('ntp', function() {
} else { } else {
// It's an html5 icon (or at least it's larger). // It's an html5 icon (or at least it's larger).
// Rescale it to be no bigger than 64x64 dip. // Rescale it to be no bigger than 64x64 dip.
var maxDip = 64; // DIP var max = 64;
if (wDip > maxDip || hDip > maxDip) { if (w > max || h > max) {
var scale = (wDip > hDip) ? (maxDip / wDip) : (maxDip / hDip); var scale = (w > h) ? (max / w) : (max / h);
wDip *= scale; w *= scale;
hDip *= scale; h *= scale;
} }
faviconIcon.style.backgroundSize = wDip + 'px ' + hDip + 'px'; faviconIcon.style.backgroundSize = w + 'px ' + h + 'px';
} }
}; };
faviconBox.appendChild(faviconIcon); faviconBox.appendChild(faviconIcon);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment