From daea81cf90105dd73c1cdd9bfe1a806eb7dc8a18 Mon Sep 17 00:00:00 2001 From: Matt Woodrow Date: Thu, 7 Apr 2016 18:51:45 +1200 Subject: [PATCH] Bug 1251644 - Snap object-contain fit if we were going to reduce the size by less than one css pixel. r=seth --- layout/base/nsCSSRendering.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/layout/base/nsCSSRendering.cpp b/layout/base/nsCSSRendering.cpp index 1ee3978715ab..2642373c4d3b 100644 --- a/layout/base/nsCSSRendering.cpp +++ b/layout/base/nsCSSRendering.cpp @@ -4990,9 +4990,17 @@ nsImageRenderer::ComputeConstrainedSize(const nsSize& aConstrainingSize, size.width = aConstrainingSize.width; size.height = NSCoordSaturatingNonnegativeMultiply( aIntrinsicRatio.height, scaleX); + // If we're reducing the size by less than one css pixel, then just use the + // constraining size. + if (aFitType == CONTAIN && aConstrainingSize.height - size.height < nsPresContext::AppUnitsPerCSSPixel()) { + size.height = aConstrainingSize.height; + } } else { size.width = NSCoordSaturatingNonnegativeMultiply( aIntrinsicRatio.width, scaleY); + if (aFitType == CONTAIN && aConstrainingSize.width - size.width < nsPresContext::AppUnitsPerCSSPixel()) { + size.width = aConstrainingSize.width; + } size.height = aConstrainingSize.height; } return size;