Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(590)

Unified Diff: third_party/WebKit/Source/core/loader/ImageLoader.cpp

Issue 2278953002: Revert of Fix ImageLoader::m_hasPendingLoadEvent/m_imageComplete in ImageDocument (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « third_party/WebKit/Source/core/loader/ImageLoader.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 42fff6565f793abb14e45eb71458d878e0a6195c..86f65618292a28c53500d98bb06686c25897ba40 100644
--- a/third_party/WebKit/Source/core/loader/ImageLoader.cpp
+++ b/third_party/WebKit/Source/core/loader/ImageLoader.cpp
@@ -217,38 +217,6 @@
imageResource->resetAnimation();
}
-void ImageLoader::setImagePending(ImageResource* newImage)
-{
- ImageResource* oldImage = m_image.get();
- if (m_hasPendingLoadEvent) {
- loadEventSender().cancelEvent(this);
- m_hasPendingLoadEvent = false;
- }
-
- // Cancel error events that belong to the previous load, which is now cancelled by changing the src attribute.
- // If newImage is null and m_hasPendingErrorEvent is true, we know the error event has been just posted by
- // this load and we should not cancel the event.
- // FIXME: If both previous load and this one got blocked with an error, we can receive one error event instead of two.
- if (m_hasPendingErrorEvent && newImage) {
- errorEventSender().cancelEvent(this);
- m_hasPendingErrorEvent = false;
- }
-
- m_image = newImage;
- m_hasPendingLoadEvent = newImage;
- m_imageComplete = !newImage;
-
- updateLayoutObject();
- // If newImage exists and is cached, addObserver() will result in the load event
- // being queued to fire. Ensure this happens after beforeload is dispatched.
- if (newImage) {
- newImage->addObserver(this);
- }
- if (oldImage) {
- oldImage->removeObserver(this);
- }
-}
-
static void configureRequest(FetchRequest& request, ImageLoader::BypassMainWorldBehavior bypassBehavior, Element& element, const ClientHintsPreferences& clientHintsPreferences)
{
if (bypassBehavior == ImageLoader::BypassMainWorldCSP)
@@ -344,7 +312,33 @@
if (updateBehavior == UpdateSizeChanged && m_element->layoutObject() && m_element->layoutObject()->isImage() && newImage == oldImage) {
toLayoutImage(m_element->layoutObject())->intrinsicSizeChanged();
} else {
- setImagePending(newImage);
+ if (m_hasPendingLoadEvent) {
+ loadEventSender().cancelEvent(this);
+ m_hasPendingLoadEvent = false;
+ }
+
+ // Cancel error events that belong to the previous load, which is now cancelled by changing the src attribute.
+ // If newImage is null and m_hasPendingErrorEvent is true, we know the error event has been just posted by
+ // this load and we should not cancel the event.
+ // FIXME: If both previous load and this one got blocked with an error, we can receive one error event instead of two.
+ if (m_hasPendingErrorEvent && newImage) {
+ errorEventSender().cancelEvent(this);
+ m_hasPendingErrorEvent = false;
+ }
+
+ m_image = newImage;
+ m_hasPendingLoadEvent = newImage;
+ m_imageComplete = !newImage;
+
+ updateLayoutObject();
+ // If newImage exists and is cached, addObserver() will result in the load event
+ // being queued to fire. Ensure this happens after beforeload is dispatched.
+ if (newImage) {
+ newImage->addObserver(this);
+ }
+ if (oldImage) {
+ oldImage->removeObserver(this);
+ }
}
if (LayoutImageResource* imageResource = layoutImageResource())
@@ -372,11 +366,8 @@
// funneling the main resource bytes into m_image, so just create an ImageResource
// to be populated later.
if (m_loadingImageDocument && updateBehavior != UpdateForcedReload) {
- setImagePending(ImageResource::create(imageSourceToKURL(m_element->imageSourceURL())));
+ setImage(ImageResource::create(imageSourceToKURL(m_element->imageSourceURL())));
m_image->setStatus(Resource::Pending);
- // 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;
}
« no previous file with comments | « third_party/WebKit/Source/core/loader/ImageLoader.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698