CachedImage: ensure clients overrides imageChanged instead of notifyFinished
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 29 Jan 2015 11:32:53 +0000 (11:32 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 29 Jan 2015 11:32:53 +0000 (11:32 +0000)
commit0789a59d928ea7e52109b9a36e06ba2f67fd7a61
tree700c487a78095ad5685b0502045560d0e05c70bf
parentff8834ff4745549be9b3bb5c30ff3cef00bcef5d
CachedImage: ensure clients overrides imageChanged instead of notifyFinished
https://bugs.webkit.org/show_bug.cgi?id=140722

Patch by Julien Isorce <j.isorce@samsung.com> on 2015-01-29
Reviewed by Tim Horton.

imageChanged is called whenever a frame of an image changes
because we got more data from the network.

notifyFinished was called when the image was entirely loaded.

The problem was that some clients were implementing only
imageChanged (ex: RenderBox), some only notifyFinished and
some both (ex: RenderImage) which made the situation difficult
to understand and to maintain.

For example when the image finished loading, both imageChanged
and notifyFinished were called with the difference that for the
first one isLoaded() returned false.
It could result in functions being called twice in a row,
ex: contentChanged(ImageChanged).

So this patch tries to simplify the situation by marking
CachedImageClient::notifyFinished final in order to prevent
clients from implementing it.
Indeed this patch ensure that CachedImage clients implement
and only implement imageChanged function.

Also Clients can now differentiate intermediate and end
calls by checking isLoaded() in imageChanged.

* html/HTMLImageLoader.cpp:
(WebCore::HTMLImageLoader::imageChanged): Added instead
of notifyFinished.
(WebCore::HTMLImageLoader::notifyFinished): Deleted.
* html/HTMLImageLoader.h:

* loader/ImageLoader.cpp:
(WebCore::ImageLoader::imageChanged): Added instead
of notifyFinished.
(WebCore::ImageLoader::notifyFinished): Deleted.
* loader/ImageLoader.h:

* loader/cache/CachedImage.cpp:
(WebCore::CachedImage::finishLoading): Explicilty mark image as
loaded and before notifying observers. So that it avoids to call
notifyFinished (from CachedResource::finishLoading).

* loader/cache/CachedImageClient.h:
Make CachedImageClient::notifyFinished final to make sure
sub classes implement imageChanged instead.

* rendering/RenderImage.cpp:
(WebCore::RenderImage::notifyFinished): Deleted.
ImageChanged already exists and is more clever than notifyFinished.
Indeed invalidateBackgroundObscurationStatus() will be called by
RenderReplaced::layout() upon call to setNeedsLayout() in
RenderImage::imageDimensionsChanged.
Also contentChanged(ImageChanged) is now called only when necessary.
* rendering/RenderImage.h:

* svg/SVGFEImageElement.cpp:
(WebCore::SVGFEImageElement::imageChanged): Added instead
of notifyFinished.
(WebCore::SVGFEImageElement::notifyFinished): Deleted.
* svg/SVGFEImageElement.h:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@179340 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Source/WebCore/ChangeLog
Source/WebCore/html/HTMLImageLoader.cpp
Source/WebCore/html/HTMLImageLoader.h
Source/WebCore/loader/ImageLoader.cpp
Source/WebCore/loader/ImageLoader.h
Source/WebCore/loader/cache/CachedImage.cpp
Source/WebCore/loader/cache/CachedImageClient.h
Source/WebCore/rendering/RenderImage.cpp
Source/WebCore/rendering/RenderImage.h
Source/WebCore/svg/SVGFEImageElement.cpp
Source/WebCore/svg/SVGFEImageElement.h