2010-04-21 Avi Drissman <avi@chromium.org>
authoreric@webkit.org <eric@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 21 Apr 2010 12:22:57 +0000 (12:22 +0000)
committereric@webkit.org <eric@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 21 Apr 2010 12:22:57 +0000 (12:22 +0000)
        Reviewed by Simon Fraser.

        JPG images fail to print in Chromium
        https://bugs.webkit.org/show_bug.cgi?id=37796

        Image sources of JPG data with final=false fail to draw into PDF contexts even if later updated (<rdar://problem/7874035>). Therefore, destroy and re-create the image source when the final data arrives.

        * platform/graphics/cg/ImageSourceCG.cpp:
        (WebCore::ImageSource::setData):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@57969 268f45cc-cd09-0410-ab3c-d52691b4dbfc

WebCore/ChangeLog
WebCore/platform/graphics/cg/ImageSourceCG.cpp

index 7fe9aad..9869ac1 100644 (file)
@@ -1,3 +1,15 @@
+2010-04-21  Avi Drissman  <avi@chromium.org>
+
+        Reviewed by Simon Fraser.
+
+        JPG images fail to print in Chromium
+        https://bugs.webkit.org/show_bug.cgi?id=37796
+
+        Image sources of JPG data with final=false fail to draw into PDF contexts even if later updated (<rdar://problem/7874035>). Therefore, destroy and re-create the image source when the final data arrives.
+
+        * platform/graphics/cg/ImageSourceCG.cpp:
+        (WebCore::ImageSource::setData):
+
 2010-04-21  Marcus Bulach  <bulach@chromium.org>
 
         Reviewed by Nate Chapin.
index a9179bc..b4e1ca9 100644 (file)
@@ -119,14 +119,22 @@ bool ImageSource::initialized() const
 
 void ImageSource::setData(SharedBuffer* data, bool allDataReceived)
 {
-    if (!m_decoder)
-        m_decoder = CGImageSourceCreateIncremental(NULL);
 #if PLATFORM(MAC)
+    if (!m_decoder)
+        m_decoder = CGImageSourceCreateIncremental(0);
     // On Mac the NSData inside the SharedBuffer can be secretly appended to without the SharedBuffer's knowledge.  We use SharedBuffer's ability
     // to wrap itself inside CFData to get around this, ensuring that ImageIO is really looking at the SharedBuffer.
     RetainPtr<CFDataRef> cfData(AdoptCF, data->createCFData());
     CGImageSourceUpdateData(m_decoder, cfData.get(), allDataReceived);
 #else
+    if (!m_decoder) {
+        m_decoder = CGImageSourceCreateIncremental(0);
+    } else if (allDataReceived) {
+        // 10.6 bug workaround: image sources with final=false fail to draw into PDF contexts, so re-create image source
+        // when data is complete. <rdar://problem/7874035> (<http://openradar.appspot.com/7874035>)
+        CFRelease(m_decoder);
+        m_decoder = CGImageSourceCreateIncremental(0);
+    }
     // Create a CGDataProvider to wrap the SharedBuffer.
     data->ref();
     // We use the GetBytesAtPosition callback rather than the GetBytePointer one because SharedBuffer