BitmapImage::drawPattern() may not draw a complete frame even after all the data...
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 31 Jan 2018 23:23:35 +0000 (23:23 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 31 Jan 2018 23:23:35 +0000 (23:23 +0000)
commit867cbf0f5396808f9c72771595ee4bcc5af204c1
tree7a00ab444e55c521cf6a0762d3b81ba732d0eb61
parent0008300d311876903ca7c8c0169f96a73ed50042
BitmapImage::drawPattern() may not draw a complete frame even after all the data is received
https://bugs.webkit.org/show_bug.cgi?id=182277

Patch by Said Abou-Hallawa <sabouhallawa@apple.com> on 2018-01-31
Reviewed by Simon Fraser.

Source/WebCore:

BitmapImage::drawPattern() needs to destroy the incomplete decoded frame
before trying to draw it as a pattern.

Test: http/tests/images/draw-pattern-slow-load-large-image.html

* loader/cache/CachedImage.cpp:
(WebCore::CachedImage::updateBufferInternal): We need to disable CachedImage
data buffering for testing. This simulates slow network where intervals
between data chunks can last for seconds.
* loader/cache/CachedImage.h:
* platform/graphics/BitmapImage.cpp:
(WebCore::BitmapImage::drawPattern): Destroy the incomplete decoded frame
before drawing this frame as a pattern. We do not destroy incomplete decoded
frame once new data is received because it may be drawn by async image
drawing while waiting for the newer frame to finish decoding.
* testing/Internals.cpp:
(WebCore::Internals::setForceUpdateImageDataEnabledForTesting):
* testing/Internals.h:
* testing/Internals.idl:

LayoutTests:

* http/tests/images/draw-pattern-slow-load-large-image-expected.html: Added.
* http/tests/images/draw-pattern-slow-load-large-image.html: Added.
* http/tests/resources/load-and-stall.php: Add a new argument to allow
repeating the stall till the end of the file. This simulates real slow
network where sending data and stalling happens constantly and not only
a single time.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@227936 268f45cc-cd09-0410-ab3c-d52691b4dbfc
LayoutTests/ChangeLog
LayoutTests/http/tests/images/draw-pattern-slow-load-large-image-expected.html [new file with mode: 0644]
LayoutTests/http/tests/images/draw-pattern-slow-load-large-image.html [new file with mode: 0644]
LayoutTests/http/tests/resources/load-and-stall.php
Source/WebCore/ChangeLog
Source/WebCore/loader/cache/CachedImage.cpp
Source/WebCore/loader/cache/CachedImage.h
Source/WebCore/platform/graphics/BitmapImage.cpp
Source/WebCore/testing/Internals.cpp
Source/WebCore/testing/Internals.h
Source/WebCore/testing/Internals.idl