Bug 1393272 - Use original width and height if either the scaled width or height is 0.
MozReview-Commit-ID: 3y4c5zJZD0a
--- 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;