|
1 /* |
|
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. |
|
5 * |
|
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. |
|
10 * |
|
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. |
|
15 * |
|
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. |
|
20 * |
|
21 */ |
|
22 |
|
23 #ifndef ImageLoader_h |
|
24 #define ImageLoader_h |
|
25 |
|
26 #include "AtomicString.h" |
|
27 #include "CachedResourceClient.h" |
|
28 #include "CachedResourceHandle.h" |
|
29 |
|
30 namespace WebCore { |
|
31 |
|
32 class Element; |
|
33 class ImageLoadEventSender; |
|
34 |
|
35 class ImageLoader : public CachedResourceClient { |
|
36 public: |
|
37 ImageLoader(Element*); |
|
38 virtual ~ImageLoader(); |
|
39 |
|
40 // This function should be called when the element is attached to a document; starts |
|
41 // loading if a load hasn't already been started. |
|
42 void updateFromElement(); |
|
43 |
|
44 // This function should be called whenever the 'src' attribute is set, even if its value |
|
45 // doesn't change; starts new load unconditionally (matches Firefox and Opera behavior). |
|
46 void updateFromElementIgnoringPreviousError(); |
|
47 |
|
48 void elementWillMoveToNewOwnerDocument(); |
|
49 |
|
50 Element* element() const { return m_element; } |
|
51 bool imageComplete() const { return m_imageComplete; } |
|
52 |
|
53 CachedImage* image() const { return m_image.get(); } |
|
54 void setImage(CachedImage*); // Cancels pending beforeload and load events, and doesn't dispatch new ones. |
|
55 |
|
56 void setLoadManually(bool loadManually) { m_loadManually = loadManually; } |
|
57 |
|
58 bool haveFiredBeforeLoadEvent() const { return m_firedBeforeLoad; } |
|
59 bool haveFiredLoadEvent() const { return m_firedLoad; } |
|
60 |
|
61 static void dispatchPendingBeforeLoadEvents(); |
|
62 static void dispatchPendingLoadEvents(); |
|
63 |
|
64 protected: |
|
65 virtual void notifyFinished(CachedResource*); |
|
66 |
|
67 private: |
|
68 virtual void dispatchLoadEvent() = 0; |
|
69 virtual String sourceURI(const AtomicString&) const = 0; |
|
70 |
|
71 friend class ImageEventSender; |
|
72 void dispatchPendingBeforeLoadEvent(); |
|
73 void dispatchPendingLoadEvent(); |
|
74 |
|
75 void updateRenderer(); |
|
76 |
|
77 Element* m_element; |
|
78 CachedResourceHandle<CachedImage> m_image; |
|
79 AtomicString m_failedLoadURL; |
|
80 bool m_firedBeforeLoad : 1; |
|
81 bool m_firedLoad : 1; |
|
82 bool m_imageComplete : 1; |
|
83 bool m_loadManually : 1; |
|
84 }; |
|
85 |
|
86 } |
|
87 |
|
88 #endif |