Bug 1393272 - Use original width and height if either the scaled width or height is 0. r=jya

MozReview-Commit-ID: 3y4c5zJZD0a

--HG--
extra : rebase_source : ec0d168f544be8dea1cbf63d9b2c253ea139286c
This commit is contained in:
Kilik Kuo 2017-10-12 16:40:50 +08:00
parent 4a8b35e00c
commit 58868278cc

View File

@ -289,11 +289,18 @@ public:
!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;
}