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

Unified Diff: Source/core/loader/ImageLoader.h

Issue 200923002: Post a microtask to load <img> elements. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: fix last test failure Created 6 years, 7 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 | « Source/core/dom/IncrementLoadEventDelayCount.cpp ('k') | Source/core/loader/ImageLoader.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/loader/ImageLoader.h
diff --git a/Source/core/loader/ImageLoader.h b/Source/core/loader/ImageLoader.h
index 2476d7952e9edee4345ff3a666d6a9bf92298bc1..894cea53d6e8f1e4ac43f5417c75de7108306a76 100644
--- a/Source/core/loader/ImageLoader.h
+++ b/Source/core/loader/ImageLoader.h
@@ -28,10 +28,13 @@
#include "core/fetch/ResourcePtr.h"
#include "platform/heap/Handle.h"
#include "wtf/HashSet.h"
+#include "wtf/WeakPtr.h"
#include "wtf/text/AtomicString.h"
namespace WebCore {
+class IncrementLoadEventDelayCount;
+
class ImageLoaderClient : public WillBeGarbageCollectedMixin {
public:
virtual void notifyImageSourceChanged() = 0;
@@ -68,14 +71,20 @@ public:
void elementDidMoveToNewDocument();
Element* element() const { return m_element; }
- bool imageComplete() const { return m_imageComplete; }
+ bool imageComplete() const
+ {
+ return m_imageComplete && !m_pendingTask;
+ }
ImageResource* image() const { return m_image.get(); }
void setImage(ImageResource*); // Cancels pending load events, and doesn't dispatch new ones.
void setLoadManually(bool loadManually) { m_loadManually = loadManually; }
- bool hasPendingActivity() const { return m_hasPendingLoadEvent || m_hasPendingErrorEvent; }
+ bool hasPendingActivity() const
+ {
+ return m_hasPendingLoadEvent || m_hasPendingErrorEvent || m_pendingTask;
+ }
void dispatchPendingEvent(ImageEventSender*);
@@ -89,6 +98,11 @@ protected:
virtual void notifyFinished(Resource*) OVERRIDE;
private:
+ class Task;
+
+ // Called from the task or from updateFromElement to initiate the load.
+ void doUpdateFromElement(bool bypassMainWorldCSP = false);
+
virtual void dispatchLoadEvent() = 0;
virtual String sourceURI(const AtomicString&) const = 0;
@@ -106,6 +120,12 @@ private:
void timerFired(Timer<ImageLoader>*);
+ KURL imageURL() const;
+
+ // Used to determine whether to immediately initiate the load
+ // or to schedule a microtask.
+ bool shouldLoadImmediately(const KURL&) const;
+
typedef WillBePersistentHeapHashSet<RawPtrWillBeWeakMember<ImageLoaderClient> > ImageLoaderClientSet;
Element* m_element;
@@ -113,6 +133,8 @@ private:
ImageLoaderClientSet m_clients;
Timer<ImageLoader> m_derefElementTimer;
AtomicString m_failedLoadURL;
+ WeakPtr<Task> m_pendingTask; // owned by Microtask
+ OwnPtr<IncrementLoadEventDelayCount> m_delayLoad;
bool m_hasPendingLoadEvent : 1;
bool m_hasPendingErrorEvent : 1;
bool m_imageComplete : 1;
« no previous file with comments | « Source/core/dom/IncrementLoadEventDelayCount.cpp ('k') | Source/core/loader/ImageLoader.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698