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
--- a/mobile/android/base/java/org/mozilla/gecko/favicons/LoadFaviconTask.java
+++ b/mobile/android/base/java/org/mozilla/gecko/favicons/LoadFaviconTask.java
@@ -544,20 +544,22 @@ public class LoadFaviconTask {
}
}
private void processResult(Bitmap image) {
Favicons.removeLoadTask(id);
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;
}
Favicons.dispatchResult(pageUrl, faviconURL, scaled, listener);
}
void onCancelled() {