Bug 1393272 - Use original width and height if either the scaled width or height is 0. draft
authorKilik Kuo <kikuo@mozilla.com>
Thu, 12 Oct 2017 16:40:50 +0800
changeset 679006 a2f75311e1eb0ed1a92b6e8011cbe7db8a91c320
parent 678298 c50fc96b4921b52ea2bf02b348917287d7b2a15b
child 735502 a30da49bd71658f1e05ad6d775ca67deab65ef78
push id84111
push userkikuo@mozilla.com
push dateThu, 12 Oct 2017 08:41:22 +0000
bugs1393272
milestone57.0a1
Bug 1393272 - Use original width and height if either the scaled width or height is 0. MozReview-Commit-ID: 3y4c5zJZD0a
dom/media/MediaInfo.h
--- a/dom/media/MediaInfo.h
+++ b/dom/media/MediaInfo.h
@@ -284,21 +284,28 @@ public:
   // container.
   gfx::IntRect ScaledImageRect(int64_t aWidth, int64_t aHeight) const
   {
     if ((aWidth == mImage.width && aHeight == mImage.height) ||
         !mImage.width ||
         !mImage.height) {
       return ImageRect();
     }
+
     gfx::IntRect imageRect = ImageRect();
+    int64_t w = (aWidth * imageRect.Width()) / mImage.width;
+    int64_t h = (aHeight * imageRect.Height()) / mImage.height;
+    if (!w || !h) {
+      return imageRect;
+    }
+
     imageRect.x = (imageRect.x * aWidth) / mImage.width;
     imageRect.y = (imageRect.y * aHeight) / mImage.height;
-    imageRect.SetWidth((aWidth * imageRect.Width()) / mImage.width);
-    imageRect.SetHeight((aHeight * imageRect.Height()) / mImage.height);
+    imageRect.SetWidth(w);
+    imageRect.SetHeight(h);
     return imageRect;
   }
 
   Rotation ToSupportedRotation(int32_t aDegree)
   {
     switch (aDegree) {
       case 90:
         return kDegree_90;