Chromium Code Reviews| Index: third_party/WebKit/Source/core/loader/ImageLoader.cpp |
| diff --git a/third_party/WebKit/Source/core/loader/ImageLoader.cpp b/third_party/WebKit/Source/core/loader/ImageLoader.cpp |
| index 549c3b20dff7749f4978214743e5594a815d055a..6e0f072a32122bef6285fa63912d364481701196 100644 |
| --- a/third_party/WebKit/Source/core/loader/ImageLoader.cpp |
| +++ b/third_party/WebKit/Source/core/loader/ImageLoader.cpp |
| @@ -182,10 +182,11 @@ void ImageLoader::dispose() { |
| DEFINE_TRACE(ImageLoader) { |
| visitor->trace(m_image); |
| + visitor->trace(m_imageResourceForImageDocument); |
| visitor->trace(m_element); |
| } |
| -void ImageLoader::setImage(ImageResource* newImage) { |
| +void ImageLoader::setImage(ImageResourceContent* newImage) { |
| setImageWithoutConsideringPendingLoadEvent(newImage); |
| // Only consider updating the protection ref-count of the Element immediately |
| @@ -195,9 +196,9 @@ void ImageLoader::setImage(ImageResource* newImage) { |
| } |
| void ImageLoader::setImageWithoutConsideringPendingLoadEvent( |
| - ImageResource* newImage) { |
| + ImageResourceContent* newImage) { |
| DCHECK(m_failedLoadURL.isEmpty()); |
| - ImageResource* oldImage = m_image.get(); |
| + ImageResourceContent* oldImage = m_image.get(); |
| if (newImage != oldImage) { |
| m_image = newImage; |
| if (m_hasPendingLoadEvent) { |
| @@ -288,7 +289,7 @@ void ImageLoader::doUpdateFromElement(BypassMainWorldBehavior bypassBehavior, |
| return; |
| AtomicString imageSourceURL = m_element->imageSourceURL(); |
| - ImageResource* newImage = nullptr; |
| + ImageResourceContent* newImage = nullptr; |
| if (!url.isNull()) { |
| // Unlike raw <img>, we block mixed content inside of <picture> or |
| // <img srcset>. |
| @@ -318,7 +319,7 @@ void ImageLoader::doUpdateFromElement(BypassMainWorldBehavior bypassBehavior, |
| request.setAllowImagePlaceholder(); |
| } |
| - newImage = ImageResource::fetch(request, document.fetcher()); |
| + newImage = ImageResourceContent::fetch(request, document.fetcher()); |
| if (!newImage && !pageIsBeingDismissed(&document)) { |
| crossSiteOrCSPViolationOccurred(imageSourceURL); |
| @@ -334,7 +335,7 @@ void ImageLoader::doUpdateFromElement(BypassMainWorldBehavior bypassBehavior, |
| noImageResourceToLoad(); |
| } |
| - ImageResource* oldImage = m_image.get(); |
| + ImageResourceContent* oldImage = m_image.get(); |
| if (updateBehavior == UpdateSizeChanged && m_element->layoutObject() && |
| m_element->layoutObject()->isImage() && newImage == oldImage) { |
| toLayoutImage(m_element->layoutObject())->intrinsicSizeChanged(); |
| @@ -397,9 +398,11 @@ void ImageLoader::updateFromElement(UpdateFromElementBehavior updateBehavior, |
| // funneling the main resource bytes into m_image, so just create an |
| // ImageResource to be populated later. |
| if (m_loadingImageDocument && updateBehavior != UpdateForcedReload) { |
| - setImage( |
| - ImageResource::create(imageSourceToKURL(m_element->imageSourceURL()))); |
| - m_image->setStatus(Resource::Pending); |
| + ImageResource* imageResource = |
| + ImageResource::create(imageSourceToKURL(m_element->imageSourceURL())); |
| + imageResource->setStatus(Resource::Pending); |
| + m_imageResourceForImageDocument = imageResource; |
| + setImage(imageResource->getRealContent()); |
| return; |
| } |
| @@ -419,7 +422,7 @@ void ImageLoader::updateFromElement(UpdateFromElementBehavior updateBehavior, |
| // Allow the idiom "img.src=''; img.src='.." to clear down the image before an |
| // asynchronous load completes. |
| if (imageSourceURL.isEmpty()) { |
| - ImageResource* image = m_image.get(); |
| + ImageResourceContent* image = m_image.get(); |
| if (image) { |
| image->removeObserver(this); |
| } |
| @@ -467,7 +470,7 @@ bool ImageLoader::shouldLoadImmediately(const KURL& url) const { |
| url.protocolIsData()); |
| } |
| -void ImageLoader::imageNotifyFinished(ImageResource* resource) { |
| +void ImageLoader::imageNotifyFinished(ImageResourceContent* resource) { |
| RESOURCE_LOADING_DVLOG(1) |
| << "ImageLoader::imageNotifyFinished " << this |
| << "; m_hasPendingLoadEvent=" << m_hasPendingLoadEvent; |
| @@ -493,11 +496,6 @@ void ImageLoader::imageNotifyFinished(ImageResource* resource) { |
| loadEventSender().cancelEvent(this); |
| m_hasPendingLoadEvent = false; |
| - if (resource->resourceError().isAccessCheck()) { |
|
hiroshige
2016/11/30 06:46:25
TODO: I'll revert this change in next major rebase
|
| - crossSiteOrCSPViolationOccurred( |
| - AtomicString(resource->resourceError().failingURL())); |
| - } |
| - |
| // The error event should not fire if the image data update is a result of |
| // environment change. |
| // https://html.spec.whatwg.org/multipage/embedded-content.html#the-img-element:the-img-element-55 |
| @@ -510,14 +508,6 @@ void ImageLoader::imageNotifyFinished(ImageResource* resource) { |
| updatedHasPendingEvent(); |
| return; |
| } |
| - if (resource->wasCanceled()) { |
|
hiroshige
2016/11/30 06:46:24
TODO: This change will be done in https://coderevi
|
| - m_hasPendingLoadEvent = false; |
| - // Only consider updating the protection ref-count of the Element |
| - // immediately before returning from this function as doing so might result |
| - // in the destruction of this ImageLoader. |
| - updatedHasPendingEvent(); |
| - return; |
| - } |
| loadEventSender().dispatchEventSoon(this); |
| } |
| @@ -551,7 +541,7 @@ void ImageLoader::updateLayoutObject() { |
| // Only update the layoutObject if it doesn't have an image or if what we have |
| // is a complete image. This prevents flickering in the case where a dynamic |
| // change is happening between two images. |
| - ImageResource* cachedImage = imageResource->cachedImage(); |
| + ImageResourceContent* cachedImage = imageResource->cachedImage(); |
| if (m_image != cachedImage && (m_imageComplete || !cachedImage)) |
| imageResource->setImageResource(m_image.get()); |
| } |