REGRESSION(r219045): A partially loaded image may not be repainted when its complete...
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 22 Jul 2017 12:12:33 +0000 (12:12 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 22 Jul 2017 12:12:33 +0000 (12:12 +0000)
commit6310c85a2665d751c79536a95143b87c35e76ec2
tree9054c06a472267dcae22413a6ce00fd8943c4278
parentc136ab649c04ab2fae1ca5dfb78feaf2e81b1c70
REGRESSION(r219045): A partially loaded image may not be repainted when its complete frame finishes decoding
https://bugs.webkit.org/show_bug.cgi?id=174230

Patch by Said Abou-Hallawa <sabouhallawa@apple.com> on 2017-07-22
Reviewed by Simon Fraser.

Because of r219045, we now only repaint the CachedImageClinets which tried
to draw the image but they could not because they have to wait for the image
decoding to finish. This was done by keeping a HashSet of these clients
and make CachedImage own it. This HashSet is cleared once the image frame
finishes decoding and all the waited clients are repainted.

But Multiple asynchronous image decoding requests are allowed for the same
frame if new data is added to the image source. If we tried to draw the
same image twice before it finishes decoding the first request, we will
not be to record this second request since the HashSet will not add the
same client twice. When he second request finishes decoding, CachedImage
will not repaint any client since its HashSet is empty.

To fix this problem we can do the following. When an image frame finishes
decoding, CachedImage will keep its HashSet of pending drawing clients as
long as the image frame is a partially loaded frame.

* loader/cache/CachedImage.cpp:
(WebCore::CachedImage::CachedImageObserver::imageFrameAvailable):
(WebCore::CachedImage::imageFrameAvailable):
* loader/cache/CachedImage.h:
* platform/graphics/BitmapImage.cpp:
(WebCore::BitmapImage::destroyDecodedData):
(WebCore::BitmapImage::dataChanged):
(WebCore::BitmapImage::setCurrentFrameDecodingStatusIfNecessary):
(WebCore::BitmapImage::draw):
(WebCore::BitmapImage::internalStartAnimation):
(WebCore::BitmapImage::internalAdvanceAnimation):
(WebCore::BitmapImage::imageFrameAvailableAtIndex):
* platform/graphics/BitmapImage.h:
* platform/graphics/ImageFrame.cpp:
(WebCore::ImageFrame::decodingStatus):
* platform/graphics/ImageFrame.h: Move DecodingStatus out of this class
to ImageTypes.h to avoid adding other header files to ImageObvsever.h
* platform/graphics/ImageFrameCache.cpp:
(WebCore::ImageFrameCache::setNativeImage):
(WebCore::ImageFrameCache::cacheMetadataAtIndex):
(WebCore::ImageFrameCache::cacheNativeImageAtIndex):
(WebCore::ImageFrameCache::cacheNativeImageAtIndexAsync):
(WebCore::ImageFrameCache::requestFrameAsyncDecodingAtIndex):
(WebCore::ImageFrameCache::frameDecodingStatusAtIndex):
* platform/graphics/ImageFrameCache.h:
* platform/graphics/ImageObserver.h:
* platform/graphics/ImageSource.h:
(WebCore::ImageSource::frameDecodingStatusAtIndex):
* platform/graphics/ImageTypes.h:
* platform/image-decoders/bmp/BMPImageReader.cpp:
(WebCore::BMPImageReader::decodeBMP):
* platform/image-decoders/gif/GIFImageDecoder.cpp:
(WebCore::GIFImageDecoder::frameComplete):
(WebCore::GIFImageDecoder::initFrameBuffer):
* platform/image-decoders/jpeg/JPEGImageDecoder.cpp:
(WebCore::JPEGImageDecoder::outputScanlines):
(WebCore::JPEGImageDecoder::jpegComplete):
* platform/image-decoders/png/PNGImageDecoder.cpp:
(WebCore::PNGImageDecoder::rowAvailable):
(WebCore::PNGImageDecoder::pngComplete):
(WebCore::PNGImageDecoder::frameComplete):
* platform/image-decoders/webp/WEBPImageDecoder.cpp:
(WebCore::WEBPImageDecoder::decode):
* rendering/RenderBoxModelObject.cpp:
(WebCore::RenderBoxModelObject::decodingModeForImageDraw):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@219762 268f45cc-cd09-0410-ab3c-d52691b4dbfc
18 files changed:
Source/WebCore/ChangeLog
Source/WebCore/loader/cache/CachedImage.cpp
Source/WebCore/loader/cache/CachedImage.h
Source/WebCore/platform/graphics/BitmapImage.cpp
Source/WebCore/platform/graphics/BitmapImage.h
Source/WebCore/platform/graphics/ImageFrame.cpp
Source/WebCore/platform/graphics/ImageFrame.h
Source/WebCore/platform/graphics/ImageFrameCache.cpp
Source/WebCore/platform/graphics/ImageFrameCache.h
Source/WebCore/platform/graphics/ImageObserver.h
Source/WebCore/platform/graphics/ImageSource.h
Source/WebCore/platform/graphics/ImageTypes.h
Source/WebCore/platform/image-decoders/bmp/BMPImageReader.cpp
Source/WebCore/platform/image-decoders/gif/GIFImageDecoder.cpp
Source/WebCore/platform/image-decoders/jpeg/JPEGImageDecoder.cpp
Source/WebCore/platform/image-decoders/png/PNGImageDecoder.cpp
Source/WebCore/platform/image-decoders/webp/WEBPImageDecoder.cpp
Source/WebCore/rendering/RenderBoxModelObject.cpp