REGRESSION (r161580): Some PDFs render outside their <img>

https://bugs.webkit.org/show_bug.cgi?id=127381
<rdar://problem/15872168>

Reviewed by Simon Fraser.

* platform/graphics/cg/PDFDocumentImage.cpp:
(WebCore::transformContextForPainting):
Only try to make the scale uniform if it isn't already, and use the minimum
of the two original scales when doing so, so that it is absolutely certain
to fit inside space allocated for the image during layout.


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@162486 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 34692e93
2014-01-21 Tim Horton <timothy_horton@apple.com>
REGRESSION (r161580): Some PDFs render outside their <img>
https://bugs.webkit.org/show_bug.cgi?id=127381
<rdar://problem/15872168>
Reviewed by Simon Fraser.
* platform/graphics/cg/PDFDocumentImage.cpp:
(WebCore::transformContextForPainting):
Only try to make the scale uniform if it isn't already, and use the minimum
of the two original scales when doing so, so that it is absolutely certain
to fit inside space allocated for the image during layout.
2014-01-21 Roger Fong <roger_fong@apple.com>
Unreviewed. WebGLLoadPolicy::WebGLAsk is an unnecessary value.
......@@ -123,14 +123,17 @@ static void transformContextForPainting(GraphicsContext* context, const FloatRec
float hScale = dstRect.width() / srcRect.width();
float vScale = dstRect.height() / srcRect.height();
float minimumScale = std::max((dstRect.width() - 0.5) / srcRect.width(), (dstRect.height() - 0.5) / srcRect.height());
float maximumScale = std::min((dstRect.width() + 0.5) / srcRect.width(), (dstRect.height() + 0.5) / srcRect.height());
// If the difference between the two scales is due to integer rounding of image sizes,
// use the average scale for both axes.
if (minimumScale <= maximumScale) {
hScale = (maximumScale + minimumScale) / 2;
vScale = hScale;
if (hScale != vScale) {
float minimumScale = std::max((dstRect.width() - 0.5) / srcRect.width(), (dstRect.height() - 0.5) / srcRect.height());
float maximumScale = std::min((dstRect.width() + 0.5) / srcRect.width(), (dstRect.height() + 0.5) / srcRect.height());
// If the difference between the two scales is due to integer rounding of image sizes,
// use the smaller of the two original scales to ensure that the image fits inside the
// space originally allocated for it.
if (minimumScale <= maximumScale) {
hScale = std::min(hScale, vScale);
vScale = hScale;
}
}
context->translate(srcRect.x() * hScale, srcRect.y() * vScale);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment