Bug 1064855 - Handle zero area destination rects during image snapping. r=roc, a=lmandel
authorSeth Fowler <seth@mozilla.com>
Fri, 10 Oct 2014 19:38:32 -0400
changeset 225614 1a58d8626b7780be7c45c013b644c770a5c015f5
parent 225613 d96e19abd61e60a7b23789c741ae50facaf92a97
child 225615 6ae4ca55a6d9ae4a1e32fb8693aeca6eb5dbd0b2
push id3979
push userraliiev@mozilla.com
push dateMon, 13 Oct 2014 16:35:44 +0000
treeherdermozilla-beta@30f2cc610691 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersroc, lmandel
bugs1064855
milestone34.0a2
Bug 1064855 - Handle zero area destination rects during image snapping. r=roc, a=lmandel
image/src/RasterImage.cpp
layout/base/nsLayoutUtils.cpp
--- a/image/src/RasterImage.cpp
+++ b/image/src/RasterImage.cpp
@@ -3700,17 +3700,17 @@ RasterImage::FrameNeededWorker::Run()
 nsIntSize
 RasterImage::OptimalImageSizeForDest(const gfxSize& aDest, uint32_t aWhichFrame,
                                      GraphicsFilter aFilter, uint32_t aFlags)
 {
   MOZ_ASSERT(aDest.width >= 0 || ceil(aDest.width) <= INT32_MAX ||
              aDest.height >= 0 || ceil(aDest.height) <= INT32_MAX,
              "Unexpected destination size");
 
-  if (mSize.IsEmpty()) {
+  if (mSize.IsEmpty() || aDest.IsEmpty()) {
     return nsIntSize(0, 0);
   }
 
   nsIntSize destSize(ceil(aDest.width), ceil(aDest.height));
   gfx::Size scale(double(destSize.width) / mSize.width,
                   double(destSize.height) / mSize.height);
 
   if (CanScale(aFilter, scale, aFlags)) {
--- a/layout/base/nsLayoutUtils.cpp
+++ b/layout/base/nsLayoutUtils.cpp
@@ -5050,16 +5050,20 @@ ComputeSnappedImageDrawingParameters(gfx
                               : gfxSize(1.0, 1.0);
   gfxSize appUnitScaledDest(dest.width * destScale.width,
                             dest.height * destScale.height);
   gfxSize scaledDest = appUnitScaledDest / aAppUnitsPerDevPixel;
   gfxSize snappedScaledDest =
     gfxSize(NSAppUnitsToIntPixels(appUnitScaledDest.width, aAppUnitsPerDevPixel),
             NSAppUnitsToIntPixels(appUnitScaledDest.height, aAppUnitsPerDevPixel));
 
+  if (scaledDest.IsEmpty() || snappedScaledDest.IsEmpty()) {
+    return SnappedImageDrawingParameters();
+  }
+
   nsIntSize intImageSize =
     aImage->OptimalImageSizeForDest(snappedScaledDest,
                                     imgIContainer::FRAME_CURRENT,
                                     aGraphicsFilter, aImageFlags);
   gfxSize imageSize(intImageSize.width, intImageSize.height);
 
   // Compute the set of pixels that would be sampled by an ideal rendering
   gfxPoint subimageTopLeft =