Bug 1255335 - Ensure we can and should scale image before scaling r=sebastian

We introduced the "if ((flags & FLAG_BYPASS_CACHE_WHEN_DOWNLOADING_ICONS) != 0)" check,
and direct Bitmap scaling in Bug 1238656 to avoid getting the cached icon (which results
in downscaling) for apple-touch-icons (or just any icon that we're using for homescreen shortcuts).
However we need to make sure we can actually scale the icon before performing scaling, hence
this check should have been within our pre-existing "if (image_params_are_valid)" clause.

MozReview-Commit-ID: 4RdHmEia5FR

--HG--
extra : rebase_source : 7c4b62454cb42b63ac00e98fa5476cfcf95e2ee6
extra : amend_source : 0f4c7c17c6ebabea08176969723af8cf9149bd01
This commit is contained in:
Andrzej Hunt 2016-03-10 22:50:20 -08:00
Родитель ce8ba87659
Коммит a474623c85
1 изменённых файлов: 6 добавлений и 4 удалений

Просмотреть файл

@ -549,10 +549,12 @@ public class LoadFaviconTask {
final Bitmap scaled;
// Notify listeners, scaling if required.
if ((flags & FLAG_BYPASS_CACHE_WHEN_DOWNLOADING_ICONS) != 0) {
scaled = Bitmap.createScaledBitmap(image, targetWidthAndHeight, targetWidthAndHeight, true);
} else if (targetWidthAndHeight != -1 && image != null && image.getWidth() != targetWidthAndHeight) {
scaled = Favicons.getSizedFaviconFromCache(faviconURL, targetWidthAndHeight);
if (targetWidthAndHeight != -1 && image != null && image.getWidth() != targetWidthAndHeight) {
if ((flags & FLAG_BYPASS_CACHE_WHEN_DOWNLOADING_ICONS) != 0) {
scaled = Bitmap.createScaledBitmap(image, targetWidthAndHeight, targetWidthAndHeight, true);
} else {
scaled = Favicons.getSizedFaviconFromCache(faviconURL, targetWidthAndHeight);
}
} else {
scaled = image;
}