Bug 1145903 - Use CSS to shrinkToFit instead of a racy set of width/height on the image frame. r=tnikkel

MozReview-Commit-ID: GnBcPLMGKDS

--HG--
extra : rebase_source : 665ac8fd0cf60745dff19940ddd1201a6cd5145f
This commit is contained in:
Benoit Girard 2016-02-22 19:02:26 -05:00
parent 1d1fd489f5
commit 222f9bc8c4
3 changed files with 6 additions and 6 deletions

View File

@ -339,12 +339,6 @@ ImageDocument::ShrinkToFit()
return;
}
// Keep image content alive while changing the attributes.
nsCOMPtr<nsIContent> imageContent = mImageContent;
nsCOMPtr<nsIDOMHTMLImageElement> image = do_QueryInterface(mImageContent);
image->SetWidth(std::max(1, NSToCoordFloor(GetRatio() * mImageWidth)));
image->SetHeight(std::max(1, NSToCoordFloor(GetRatio() * mImageHeight)));
// The view might have been scrolled when zooming in, scroll back to the
// origin now that we're showing a shrunk-to-window version.
ScrollImageTo(0, 0, false);

View File

@ -114,6 +114,9 @@ protected:
float mVisibleWidth;
float mVisibleHeight;
// XXX: The image width/height isn't invalidated to reflect the up-to-date
// width/height of the image frame. In particular when the
// StyleVisibility orientation changes this value isn't updated.
int32_t mImageWidth;
int32_t mImageHeight;

View File

@ -15,6 +15,9 @@
.shrinkToFit {
cursor: zoom-in;
width: 100%;
height: 100%;
object-fit: contain;
}
}