2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org)
3 * (C) 1999 Antti Koivisto (koivisto@kde.org)
4 * Copyright (C) 2004, 2009 Apple Inc. All rights reserved.
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Library General Public
8 * License as published by the Free Software Foundation; either
9 * version 2 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Library General Public License for more details.
16 * You should have received a copy of the GNU Library General Public License
17 * along with this library; see the file COPYING.LIB. If not, write to
18 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
19 * Boston, MA 02110-1301, USA.
26 #include "CachedResourceClient.h"
27 #include "CachedResourceHandle.h"
28 #include <wtf/text/AtomicString.h>
33 class ImageLoadEventSender;
34 class RenderImageResource;
36 class ImageLoader : public CachedResourceClient {
38 ImageLoader(Element*);
39 virtual ~ImageLoader();
41 // This function should be called when the element is attached to a document; starts
42 // loading if a load hasn't already been started.
43 void updateFromElement();
45 // This function should be called whenever the 'src' attribute is set, even if its value
46 // doesn't change; starts new load unconditionally (matches Firefox and Opera behavior).
47 void updateFromElementIgnoringPreviousError();
49 void elementWillMoveToNewOwnerDocument();
51 Element* element() const { return m_element; }
52 bool imageComplete() const { return m_imageComplete; }
54 CachedImage* image() const { return m_image.get(); }
55 void setImage(CachedImage*); // Cancels pending beforeload and load events, and doesn't dispatch new ones.
57 void setLoadManually(bool loadManually) { m_loadManually = loadManually; }
59 bool haveFiredBeforeLoadEvent() const { return m_firedBeforeLoad; }
60 bool haveFiredLoadEvent() const { return m_firedLoad; }
62 static void dispatchPendingBeforeLoadEvents();
63 static void dispatchPendingLoadEvents();
66 virtual void notifyFinished(CachedResource*);
69 virtual void dispatchLoadEvent() = 0;
70 virtual String sourceURI(const AtomicString&) const = 0;
72 friend class ImageEventSender;
73 void dispatchPendingBeforeLoadEvent();
74 void dispatchPendingLoadEvent();
76 RenderImageResource* renderImageResource();
77 void updateRenderer();
80 CachedResourceHandle<CachedImage> m_image;
81 AtomicString m_failedLoadURL;
82 bool m_firedBeforeLoad : 1;
84 bool m_imageComplete : 1;
85 bool m_loadManually : 1;