Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(40)

Unified Diff: chrome/browser/resources/ntp_android/ntp_android.js

Issue 17257004: [Android] Fix NTP bookmark image unit for low resolution device. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 7 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/resources/ntp_android/ntp_android.js
diff --git a/chrome/browser/resources/ntp_android/ntp_android.js b/chrome/browser/resources/ntp_android/ntp_android.js
index 4e61603ccfa5c751f5d1af18c30905f7049d28b6..517deadce3789e94f2b182e423fb40924626917e 100644
--- a/chrome/browser/resources/ntp_android/ntp_android.js
+++ b/chrome/browser/resources/ntp_android/ntp_android.js
@@ -707,9 +707,7 @@ cr.define('ntp', function() {
image.onload = function() {
var w = image.width;
var h = image.height;
- var wDip = w / window.devicePixelRatio;
- var hDip = h / window.devicePixelRatio;
- if (Math.floor(wDip) <= 16 || Math.floor(hDip) <= 16) {
+ if (Math.floor(w) <= 16 || Math.floor(h) <= 16) {
// it's a standard favicon (or at least it's small).
faviconBox.classList.add('document');
@@ -740,13 +738,13 @@ cr.define('ntp', function() {
} else {
// 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;
+ var max = 64;
+ if (w > max || h > max) {
+ var scale = (w > h) ? (max / w) : (max / h);
+ w *= scale;
+ h *= scale;
}
- faviconIcon.style.backgroundSize = wDip + 'px ' + hDip + 'px';
+ faviconIcon.style.backgroundSize = w + 'px ' + h + 'px';
}
};
faviconBox.appendChild(faviconIcon);
@@ -2214,9 +2212,6 @@ cr.define('ntp', function() {
var itemMarginRight = 20;
var listHeight = 0;
- // set it to the unscaled size so centerGrid works correctly
- modifyCssRule('body[device="phone"] .thumbnail-cell',
- 'width', thumbWidth + 'px');
var screenHeight =
document.documentElement.offsetHeight -
@@ -2224,8 +2219,8 @@ cr.define('ntp', function() {
if (isPortrait()) {
mostVisitedList.setAttribute(GRID_COLUMNS, '2');
- listHeight = screenHeight * .85;
- listHeight = listHeight >= 420 ? 420 : listHeight;
+ listHeight = screenHeight;
+ listHeight = listHeight >= 400 ? 400 : listHeight;
// Size for 3 rows (4 gutters)
itemMarginTop = (listHeight - (itemHeight * 3)) / 4;
} else {
@@ -2241,8 +2236,8 @@ cr.define('ntp', function() {
var scale = (screenHeight - 2 * labelHeight -
targetRemainder) / (2 * thumbHeight);
// update values based on scale
- thumbWidth *= scale;
- thumbHeight *= scale;
+ thumbWidth = Math.round(thumbWidth * scale);
+ thumbHeight = Math.round(thumbHeight * scale);
labelWidth = thumbWidth + 20;
itemHeight = thumbHeight + labelHeight;
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698