<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" /><style type="text/css"><!--
#msg dl { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; }
#msg dl a { font-weight: bold}
#msg dl a:link { color:#fc3; }
#msg dl a:active { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fc0 solid; padding: 6px; }
#msg ul, pre { overflow: auto; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<title>[20720] trunk</title>
</head>
<body>
<div id="msg">
<dl>
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/20720">20720</a></dd>
<dt>Author</dt> <dd>oliver</dd>
<dt>Date</dt> <dd>2007-04-05 03:20:22 -0700 (Thu, 05 Apr 2007)</dd>
</dl>
<h3>Log Message</h3>
<pre>2007-04-05 Oliver Hunt <oliver@apple.com>
Reviewed by Adam.
WebCore:
Fix rdar://problem/5030934 -- landscape PDFs embedded as an image are cut off
also fixes scaling of pdf images
PDFDocumentImage was not accounting for page rotation in a number of places
* platform/graphics/cg/PDFDocumentImage.cpp:
(WebCore::PDFDocumentImage::size):
we need to account for rotation of the pdf image effecting our bounds
(WebCore::PDFDocumentImage::draw):
When compensating for flipped coords we need to use the correct rect for the
coordinate space. We can't pass size() to CGContextDrawPDFDocument as it
returns the rotated bounds now -- this is also save the old
FloatSize -> IntSize -> FloatSize conversions.
LayoutTests:
Testcase for landscape pdfs as image
rdar://problem/5030934 -- landscape PDFs embedded as an image are cut off
* fast/images/pdf-as-image-landscape-expected.txt: Added.
* fast/images/pdf-as-image-landscape.html: Added.
* fast/images/resources/pdf_test_landscape.pdf: Added.</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkLayoutTestsChangeLog">trunk/LayoutTests/ChangeLog</a></li>
<li><a href="#trunkWebCoreChangeLog">trunk/WebCore/ChangeLog</a></li>
<li><a href="#trunkWebCoreplatformgraphicscgPDFDocumentImagecpp">trunk/WebCore/platform/graphics/cg/PDFDocumentImage.cpp</a></li>
</ul>
<h3>Added Paths</h3>
<ul>
<li><a href="#trunkLayoutTestsfastimagespdfasimagelandscapeexpectedtxt">trunk/LayoutTests/fast/images/pdf-as-image-landscape-expected.txt</a></li>
<li><a href="#trunkLayoutTestsfastimagespdfasimagelandscapehtml">trunk/LayoutTests/fast/images/pdf-as-image-landscape.html</a></li>
<li><a href="#trunkLayoutTestsfastimagesresourcespdf_test_landscapepdf">trunk/LayoutTests/fast/images/resources/pdf_test_landscape.pdf</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkLayoutTestsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/ChangeLog (20719 => 20720)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/ChangeLog        2007-04-05 10:08:55 UTC (rev 20719)
+++ trunk/LayoutTests/ChangeLog        2007-04-05 10:20:22 UTC (rev 20720)
</span><span class="lines">@@ -1,3 +1,15 @@
</span><ins>+2007-04-05 Oliver Hunt <oliver@apple.com>
+
+ Reviewed by Adam.
+
+ Testcase for landscape pdfs as image
+
+ rdar://problem/5030934 -- landscape PDFs embedded as an image are cut off
+
+ * fast/images/pdf-as-image-landscape-expected.txt: Added.
+ * fast/images/pdf-as-image-landscape.html: Added.
+ * fast/images/resources/pdf_test_landscape.pdf: Added.
+
</ins><span class="cx"> 2007-04-04 Alexey Proskuryakov <ap@webkit.org>
</span><span class="cx">
</span><span class="cx"> Reviewed by Darin.
</span></span></pre></div>
<a id="trunkLayoutTestsfastimagespdfasimagelandscapeexpectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/fast/images/pdf-as-image-landscape-expected.txt (0 => 20720)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/images/pdf-as-image-landscape-expected.txt         (rev 0)
+++ trunk/LayoutTests/fast/images/pdf-as-image-landscape-expected.txt        2007-04-05 10:20:22 UTC (rev 20720)
</span><span class="lines">@@ -0,0 +1,14 @@
</span><ins>+layer at (0,0) size 850x653
+ RenderView at (0,0) size 785x585
+layer at (0,0) size 850x653
+ RenderBlock {HTML} at (0,0) size 785x653
+ RenderBody {BODY} at (8,8) size 769x629
+ RenderBlock (anonymous) at (0,0) size 769x18
+ RenderText {#text} at (0,0) size 663x18
+ text run at (0,0) width 349: "This test that we correctly orient landscape pdf images. "
+ text run at (349,0) width 314: "The green rectangle should be wider than it is tall."
+ RenderBlock {P} at (0,34) size 769x595
+ RenderImage {IMG} at (0,0) size 842x595
+ RenderText {#text} at (0,0) size 0x0
+ RenderText {#text} at (0,0) size 0x0
+ RenderText {#text} at (0,0) size 0x0
</ins></span></pre></div>
<a id="trunkLayoutTestsfastimagespdfasimagelandscapehtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/fast/images/pdf-as-image-landscape.html (0 => 20720)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/images/pdf-as-image-landscape.html         (rev 0)
+++ trunk/LayoutTests/fast/images/pdf-as-image-landscape.html        2007-04-05 10:20:22 UTC (rev 20720)
</span><span class="lines">@@ -0,0 +1,8 @@
</span><ins>+<html>
+<head>
+</head>
+<body>
+This test that we correctly orient landscape pdf images. The green rectangle should be wider than it is tall.<p />
+<img src="resources/pdf_test_landscape.pdf"/>
+</body>
+</html>
</ins></span></pre></div>
<a id="trunkLayoutTestsfastimagesresourcespdf_test_landscapepdf"></a>
<div class="binary"><h4>Added: trunk/LayoutTests/fast/images/resources/pdf_test_landscape.pdf</h4>
<pre class="diff"><span>
<span class="cx">(Binary files differ)
</span></span></pre></div>
<span class="cx">Property changes on: trunk/LayoutTests/fast/images/resources/pdf_test_landscape.pdf
</span><span class="cx">___________________________________________________________________
</span><span class="cx">Name: svn:mime-type
</span><span class="cx"> + application/octet-stream
</span><a id="trunkWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/WebCore/ChangeLog (20719 => 20720)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/WebCore/ChangeLog        2007-04-05 10:08:55 UTC (rev 20719)
+++ trunk/WebCore/ChangeLog        2007-04-05 10:20:22 UTC (rev 20720)
</span><span class="lines">@@ -1,3 +1,22 @@
</span><ins>+2007-04-05 Oliver Hunt <oliver@apple.com>
+
+ Reviewed by Adam.
+
+ Fix rdar://problem/5030934 -- landscape PDFs embedded as an image are cut off
+ also fixes scaling of pdf images
+
+ PDFDocumentImage was not accounting for page rotation in a number of places
+
+ * platform/graphics/cg/PDFDocumentImage.cpp:
+ (WebCore::PDFDocumentImage::size):
+ we need to account for rotation of the pdf image effecting our bounds
+ (WebCore::PDFDocumentImage::draw):
+ When compensating for flipped coords we need to use the correct rect for the
+ coordinate space. We can't pass size() to CGContextDrawPDFDocument as it
+ returns the rotated bounds now -- this is also save the old
+ FloatSize -> IntSize -> FloatSize conversions.
+
+
</ins><span class="cx"> 2007-04-04 Alexey Proskuryakov <ap@webkit.org>
</span><span class="cx">
</span><span class="cx"> Reviewed by Darin.
</span></span></pre></div>
<a id="trunkWebCoreplatformgraphicscgPDFDocumentImagecpp"></a>
<div class="modfile"><h4>Modified: trunk/WebCore/platform/graphics/cg/PDFDocumentImage.cpp (20719 => 20720)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/WebCore/platform/graphics/cg/PDFDocumentImage.cpp        2007-04-05 10:08:55 UTC (rev 20719)
+++ trunk/WebCore/platform/graphics/cg/PDFDocumentImage.cpp        2007-04-05 10:20:22 UTC (rev 20720)
</span><span class="lines">@@ -50,7 +50,14 @@
</span><span class="cx">
</span><span class="cx"> IntSize PDFDocumentImage::size() const
</span><span class="cx"> {
</span><del>- return IntSize((int)m_mediaBox.size().width(), (int)m_mediaBox.size().height());
</del><ins>+ const float sina = sinf(-m_rotation);
+ const float cosa = cosf(-m_rotation);
+ const float width = m_mediaBox.size().width();
+ const float height = m_mediaBox.size().height();
+ const float rotWidth = width * cosa - height * sina;
+ const float rotHeight = width * sina + height * cosa;
+
+ return IntSize((int)(fabsf(rotWidth) + 0.5f), (int)(fabsf(rotHeight) + 0.5f));
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> bool PDFDocumentImage::dataChanged(bool allDataReceived)
</span><span class="lines">@@ -150,14 +157,14 @@
</span><span class="cx"> CGContextTranslateCTM(context->platformContext(), dstRect.x() - srcRect.x() * hScale, dstRect.y() - srcRect.y() * vScale);
</span><span class="cx"> CGContextScaleCTM(context->platformContext(), hScale, vScale);
</span><span class="cx"> CGContextScaleCTM(context->platformContext(), 1, -1);
</span><del>- CGContextTranslateCTM(context->platformContext(), 0, -dstRect.height());
</del><ins>+ CGContextTranslateCTM(context->platformContext(), 0, -srcRect.height());
</ins><span class="cx"> CGContextClipToRect(context->platformContext(), CGRectIntegral(srcRect));
</span><span class="cx">
</span><span class="cx"> // Rotate translate image into position according to doc properties.
</span><span class="cx"> adjustCTM(context);
</span><span class="cx">
</span><span class="cx"> // Media box may have non-zero origin which we ignore. Pass 1 for the page number.
</span><del>- CGContextDrawPDFDocument(context->platformContext(), FloatRect(FloatPoint(), size()),
</del><ins>+ CGContextDrawPDFDocument(context->platformContext(), FloatRect(FloatPoint(), m_mediaBox.size()),
</ins><span class="cx"> m_document, m_currentPage + 1);
</span><span class="cx">
</span><span class="cx"> context->restore();
</span></span></pre>
</div>
</div>
</body>
</html>