| Index: third_party/WebKit/Source/core/fetch/ImageResource.cpp
|
| diff --git a/third_party/WebKit/Source/core/fetch/ImageResource.cpp b/third_party/WebKit/Source/core/fetch/ImageResource.cpp
|
| index 4eb3f1c85c45a88f78e625be046a968ddedee7cb..1108410d4517ce9ee989e701901f845080584bdd 100644
|
| --- a/third_party/WebKit/Source/core/fetch/ImageResource.cpp
|
| +++ b/third_party/WebKit/Source/core/fetch/ImageResource.cpp
|
| @@ -147,27 +147,14 @@ DEFINE_TRACE(ImageResource) {
|
| }
|
|
|
| void ImageResource::checkNotify() {
|
| - // Don't notify observers and clients of completion if this ImageResource is
|
| + // Don't notify clients of completion if this ImageResource is
|
| // about to be reloaded.
|
| if (m_isSchedulingReload || shouldReloadBrokenPlaceholder())
|
| return;
|
|
|
| - notifyObserversInternal();
|
| Resource::checkNotify();
|
| }
|
|
|
| -void ImageResource::notifyObserversInternal() {
|
| - if (isLoading())
|
| - return;
|
| -
|
| - for (auto* observer : m_observers.asVector()) {
|
| - if (m_observers.contains(observer)) {
|
| - markObserverFinished(observer);
|
| - observer->imageNotifyFinished(this);
|
| - }
|
| - }
|
| -}
|
| -
|
| void ImageResource::markObserverFinished(ImageResourceObserver* observer) {
|
| if (m_observers.contains(observer)) {
|
| m_finishedObservers.add(observer);
|
| @@ -208,7 +195,8 @@ void ImageResource::addObserver(ImageResourceObserver* observer) {
|
| observer->imageChanged(this);
|
| }
|
|
|
| - if (isLoaded() && !m_isSchedulingReload && !shouldReloadBrokenPlaceholder()) {
|
| + if (isLoaded() && m_observers.contains(observer) && !m_isSchedulingReload &&
|
| + !shouldReloadBrokenPlaceholder()) {
|
| markObserverFinished(observer);
|
| observer->imageNotifyFinished(this);
|
| }
|
| @@ -423,14 +411,21 @@ LayoutSize ImageResource::imageSize(
|
| return size;
|
| }
|
|
|
| -void ImageResource::notifyObservers(const IntRect* changeRect) {
|
| +void ImageResource::notifyObservers(bool isNotifyingFinish,
|
| + const IntRect* changeRect) {
|
| for (auto* observer : m_finishedObservers.asVector()) {
|
| if (m_finishedObservers.contains(observer))
|
| observer->imageChanged(this, changeRect);
|
| }
|
| for (auto* observer : m_observers.asVector()) {
|
| - if (m_observers.contains(observer))
|
| + if (m_observers.contains(observer)) {
|
| observer->imageChanged(this, changeRect);
|
| + if (isNotifyingFinish && m_observers.contains(observer) &&
|
| + !m_isSchedulingReload && !shouldReloadBrokenPlaceholder()) {
|
| + markObserverFinished(observer);
|
| + observer->imageNotifyFinished(this);
|
| + }
|
| + }
|
| }
|
| }
|
|
|
| @@ -514,7 +509,7 @@ void ImageResource::updateImage(bool allDataReceived) {
|
|
|
| // It would be nice to only redraw the decoded band of the image, but with the
|
| // current design (decoding delayed until painting) that seems hard.
|
| - notifyObservers();
|
| + notifyObservers(allDataReceived);
|
| }
|
|
|
| void ImageResource::updateImageAndClearBuffer() {
|
| @@ -545,7 +540,7 @@ void ImageResource::error(const ResourceError& error) {
|
| m_multipartParser->cancel();
|
| clear();
|
| Resource::error(error);
|
| - notifyObservers();
|
| + notifyObservers(true);
|
| }
|
|
|
| void ImageResource::responseReceived(
|
| @@ -600,7 +595,7 @@ bool ImageResource::shouldPauseAnimation(const blink::Image* image) {
|
| void ImageResource::animationAdvanced(const blink::Image* image) {
|
| if (!image || image != m_image)
|
| return;
|
| - notifyObservers();
|
| + notifyObservers(false);
|
| }
|
|
|
| void ImageResource::updateImageAnimationPolicy() {
|
| @@ -663,7 +658,7 @@ void ImageResource::reloadIfLoFiOrPlaceholder(
|
| // here.
|
| } else {
|
| clear();
|
| - notifyObservers();
|
| + notifyObservers(false);
|
| }
|
|
|
| setStatus(NotStarted);
|
| @@ -678,7 +673,7 @@ void ImageResource::changedInRect(const blink::Image* image,
|
| const IntRect& rect) {
|
| if (!image || image != m_image)
|
| return;
|
| - notifyObservers(&rect);
|
| + notifyObservers(false, &rect);
|
| }
|
|
|
| void ImageResource::onePartInMultipartReceived(
|
|
|