#ifndef ImageLoader_h
#define ImageLoader_h
#include "CachedImage.h"
#include "CachedResourceHandle.h"
#include <wtf/text/AtomicString.h>
namespace WebCore {
class Element;
class ImageLoader;
class RenderImageResource;
template<typename T> class EventSender;
typedef EventSender<ImageLoader> ImageEventSender;
class ImageLoader : public CachedImageClient {
public:
ImageLoader(Element*);
virtual ~ImageLoader();
void updateFromElement();
void updateFromElementIgnoringPreviousError();
void elementDidMoveToNewDocument();
Element* element() const { return m_element; }
bool imageComplete() const { return m_imageComplete; }
CachedImage* image() const { return m_image.get(); }
void setImage(CachedImage*);
void setLoadManually(bool loadManually) { m_loadManually = loadManually; }
bool hasPendingBeforeLoadEvent() const { return m_hasPendingBeforeLoadEvent; }
bool hasPendingLoadEvent() const { return m_hasPendingLoadEvent; }
void dispatchPendingEvent(ImageEventSender*);
static void dispatchPendingBeforeLoadEvents();
static void dispatchPendingLoadEvents();
static void dispatchPendingErrorEvents();
protected:
virtual void notifyFinished(CachedResource*);
private:
virtual void dispatchLoadEvent() = 0;
virtual String sourceURI(const AtomicString&) const = 0;
void dispatchPendingBeforeLoadEvent();
void dispatchPendingLoadEvent();
void dispatchPendingErrorEvent();
RenderImageResource* renderImageResource();
void updateRenderer();
Element* m_element;
CachedResourceHandle<CachedImage> m_image;
AtomicString m_failedLoadURL;
bool m_hasPendingBeforeLoadEvent : 1;
bool m_hasPendingLoadEvent : 1;
bool m_hasPendingErrorEvent : 1;
bool m_imageComplete : 1;
bool m_loadManually : 1;
};
}
#endif