Garbage on page background while http://canberraballoons.com.au is loading
authorsimon.fraser@apple.com <simon.fraser@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 18 May 2013 19:09:07 +0000 (19:09 +0000)
committersimon.fraser@apple.com <simon.fraser@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 18 May 2013 19:09:07 +0000 (19:09 +0000)
https://bugs.webkit.org/show_bug.cgi?id=116384
<rdar://problem/13930328>

Reviewed by Dan Bernstein.

This page loads a large JPEG image as the body background.
ImageSource::frameHasAlphaAtIndex() always claims that JPEG images
are opaque, but this isn't true if the frame is only partially loaded.
However, this would cause FillLayer::hasOpaqueImage() to report that the
background image is opaque, so we'd skip painting the background color.
Unpainted content in an opaque layer results in garbage.

Fix by having ImageSource::frameHasAlphaAtIndex() always return true
for frames that are not complete. When the image load completes, we
recompute metadata and correctly determine that the frame is opaque.

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

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

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

index 3c28704..1431e94 100644 (file)
@@ -1,3 +1,25 @@
+2013-05-17  Simon Fraser  <simon.fraser@apple.com>
+
+        Garbage on page background while http://canberraballoons.com.au is loading
+        https://bugs.webkit.org/show_bug.cgi?id=116384
+        <rdar://problem/13930328>
+
+        Reviewed by Dan Bernstein.
+
+        This page loads a large JPEG image as the body background.
+        ImageSource::frameHasAlphaAtIndex() always claims that JPEG images
+        are opaque, but this isn't true if the frame is only partially loaded.
+        However, this would cause FillLayer::hasOpaqueImage() to report that the
+        background image is opaque, so we'd skip painting the background color.
+        Unpainted content in an opaque layer results in garbage.
+        
+        Fix by having ImageSource::frameHasAlphaAtIndex() always return true
+        for frames that are not complete. When the image load completes, we
+        recompute metadata and correctly determine that the frame is opaque.
+
+        * platform/graphics/cg/ImageSourceCG.cpp:
+        (WebCore::ImageSource::frameHasAlphaAtIndex):
+
 2013-05-18  Timothy Hatcher  <timothy@apple.com>
 
         Simplify EventLoop::cycle() on Mac.
index 40d616e..aaa2fdf 100644 (file)
@@ -361,10 +361,13 @@ float ImageSource::frameDurationAtIndex(size_t index)
     return duration;
 }
 
-bool ImageSource::frameHasAlphaAtIndex(size_t)
+bool ImageSource::frameHasAlphaAtIndex(size_t index)
 {
     if (!m_decoder)
-        return false;
+        return false; // FIXME: why doesn't this return true?
+
+    if (!frameIsCompleteAtIndex(index))
+        return true;
 
     CFStringRef imageType = CGImageSourceGetType(m_decoder);