From 34402636fbddd60c62fa152b8fb36c84c5e5bf0c Mon Sep 17 00:00:00 2001 From: Edwin Flores Date: Wed, 20 Jan 2016 11:00:12 +0000 Subject: [PATCH] Bug 1207958 - Fix heuristic for choosing which ICO sub-image to render - r=tn --- image/decoders/nsICODecoder.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/image/decoders/nsICODecoder.cpp b/image/decoders/nsICODecoder.cpp index b8645de911f..d123630fffb 100644 --- a/image/decoders/nsICODecoder.cpp +++ b/image/decoders/nsICODecoder.cpp @@ -235,8 +235,8 @@ nsICODecoder::ReadDirEntry(const char* aData) // choose the smallest resource that is >= the target size (i.e. we assume // it's better to downscale a larger icon than to upscale a smaller one). IntSize desiredSize = mDownscaler->TargetSize(); - int32_t delta = entrySize.width - desiredSize.width + - entrySize.height - desiredSize.height; + int32_t delta = std::min(entrySize.width - desiredSize.width, + entrySize.height - desiredSize.height); if (e.mBitCount >= mBestResourceColorDepth && ((mBestResourceDelta < 0 && delta >= mBestResourceDelta) || (delta >= 0 && delta <= mBestResourceDelta))) {