Bug 1068881 - Inflate the dest rect to at least one device pixel when computing the optimal image size for drawing. r=roc
☠☠ backed out by ad2032c2de8c ☠ ☠
authorSeth Fowler <seth@mozilla.com>
Thu, 26 Mar 2015 15:39:37 -0700
changeset 266357 c035d63ade9d23b29b357656a6c6d6e3785315ec
parent 266356 8ab8a64af8ecf546a9be2f7c4528896796d4abfa
child 266358 1cf1e2b49d90e16a631751d24e10563096de588d
push id830
push userraliiev@mozilla.com
push dateFri, 19 Jun 2015 19:24:37 +0000
treeherdermozilla-release@932614382a68 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersroc
bugs1068881
milestone39.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1068881 - Inflate the dest rect to at least one device pixel when computing the optimal image size for drawing. r=roc
layout/base/nsLayoutUtils.cpp
--- a/layout/base/nsLayoutUtils.cpp
+++ b/layout/base/nsLayoutUtils.cpp
@@ -5872,28 +5872,35 @@ ComputeSnappedImageDrawingParameters(gfx
     if (fill.IsEmpty()) {
       return SnappedImageDrawingParameters();
     }
   } else {
     didSnap = false;
     fill = devPixelFill;
   }
 
+  // Apply the context's scale to the dest rect.
   gfxSize destScale = didSnap ? gfxSize(currentMatrix._11, currentMatrix._22)
                               : currentMatrix.ScaleFactors(true);
   gfxSize appUnitScaledDest(dest.width * destScale.width,
                             dest.height * destScale.height);
   gfxSize scaledDest = appUnitScaledDest / aAppUnitsPerDevPixel;
+  if (scaledDest.IsEmpty()) {
+    return SnappedImageDrawingParameters();
+  }
+
+  // Compute a snapped version of the scaled dest rect, which we'll use to
+  // determine the optimal image size to draw with. We need to be sure that
+  // this rect is at least one pixel in width and height, or we'll end up
+  // drawing nothing even if we have a nonempty fill.
   gfxSize snappedScaledDest =
     gfxSize(NSAppUnitsToIntPixels(appUnitScaledDest.width, aAppUnitsPerDevPixel),
             NSAppUnitsToIntPixels(appUnitScaledDest.height, aAppUnitsPerDevPixel));
-
-  if (scaledDest.IsEmpty() || snappedScaledDest.IsEmpty()) {
-    return SnappedImageDrawingParameters();
-  }
+  snappedScaledDest.width = std::max(snappedScaledDest.width, 1.0);
+  snappedScaledDest.height = std::max(snappedScaledDest.height, 1.0);
 
   nsIntSize intImageSize =
     aImage->OptimalImageSizeForDest(snappedScaledDest,
                                     imgIContainer::FRAME_CURRENT,
                                     aGraphicsFilter, aImageFlags);
   gfxSize imageSize(intImageSize.width, intImageSize.height);
 
   nsIntSize svgViewportSize = currentMatrix.IsIdentity()