Bug 1068881 - Inflate the dest rect to at least one device pixel when computing the optimal image size for drawing. r=roc
authorSeth Fowler <seth@mozilla.com>
Fri, 27 Mar 2015 20:07:31 -0700
changeset 266663 3a8dca82b1bcdaad0f48f3ec40f66d0bd14bd56c
parent 266662 641902d237af738ebb4123fe9714a4fdb039c364
child 266664 5f12a294cf856da45df778073221029064776e4b
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()