Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 /* | 1 /* |
| 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) | 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) |
| 3 * (C) 1999 Antti Koivisto (koivisto@kde.org) | 3 * (C) 1999 Antti Koivisto (koivisto@kde.org) |
| 4 * Copyright (C) 2004, 2009 Apple Inc. All rights reserved. | 4 * Copyright (C) 2004, 2009 Apple Inc. All rights reserved. |
| 5 * | 5 * |
| 6 * This library is free software; you can redistribute it and/or | 6 * This library is free software; you can redistribute it and/or |
| 7 * modify it under the terms of the GNU Library General Public | 7 * modify it under the terms of the GNU Library General Public |
| 8 * License as published by the Free Software Foundation; either | 8 * License as published by the Free Software Foundation; either |
| 9 * version 2 of the License, or (at your option) any later version. | 9 * version 2 of the License, or (at your option) any later version. |
| 10 * | 10 * |
| 11 * This library is distributed in the hope that it will be useful, | 11 * This library is distributed in the hope that it will be useful, |
| 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 14 * Library General Public License for more details. | 14 * Library General Public License for more details. |
| 15 * | 15 * |
| 16 * You should have received a copy of the GNU Library General Public License | 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 | 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, | 18 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
| 19 * Boston, MA 02110-1301, USA. | 19 * Boston, MA 02110-1301, USA. |
| 20 * | 20 * |
| 21 */ | 21 */ |
| 22 | 22 |
| 23 #ifndef ImageLoader_h | 23 #ifndef ImageLoader_h |
| 24 #define ImageLoader_h | 24 #define ImageLoader_h |
| 25 | 25 |
| 26 #include "core/loader/cache/CachedImage.h" | 26 #include "core/loader/cache/CachedImage.h" |
| 27 #include "core/loader/cache/CachedImageClient.h" | 27 #include "core/loader/cache/CachedImageClient.h" |
| 28 #include "core/loader/cache/CachedResourceHandle.h" | 28 #include "core/loader/cache/CachedResourceHandle.h" |
| 29 #include "wtf/HashSet.h" | |
| 29 #include "wtf/text/AtomicString.h" | 30 #include "wtf/text/AtomicString.h" |
| 30 | 31 |
| 31 namespace WebCore { | 32 namespace WebCore { |
| 32 | 33 |
| 34 class ImageLoaderClient { | |
| 35 public: | |
| 36 virtual void notifyImageSourceChanged() { } | |
| 37 | |
| 38 protected: | |
| 39 ImageLoaderClient() { } | |
| 40 }; | |
| 41 | |
| 33 class Element; | 42 class Element; |
| 34 class ImageLoader; | 43 class ImageLoader; |
| 35 class RenderImageResource; | 44 class RenderImageResource; |
| 36 | 45 |
| 37 template<typename T> class EventSender; | 46 template<typename T> class EventSender; |
| 38 typedef EventSender<ImageLoader> ImageEventSender; | 47 typedef EventSender<ImageLoader> ImageEventSender; |
| 39 | 48 |
| 40 class ImageLoader : public CachedImageClient { | 49 class ImageLoader : public CachedImageClient { |
| 41 public: | 50 public: |
| 42 explicit ImageLoader(Element*); | 51 explicit ImageLoader(Element*); |
| (...skipping 19 matching lines...) Expand all Loading... | |
| 62 | 71 |
| 63 bool hasPendingBeforeLoadEvent() const { return m_hasPendingBeforeLoadEvent; } | 72 bool hasPendingBeforeLoadEvent() const { return m_hasPendingBeforeLoadEvent; } |
| 64 bool hasPendingActivity() const { return m_hasPendingLoadEvent || m_hasPendi ngErrorEvent; } | 73 bool hasPendingActivity() const { return m_hasPendingLoadEvent || m_hasPendi ngErrorEvent; } |
| 65 | 74 |
| 66 void dispatchPendingEvent(ImageEventSender*); | 75 void dispatchPendingEvent(ImageEventSender*); |
| 67 | 76 |
| 68 static void dispatchPendingBeforeLoadEvents(); | 77 static void dispatchPendingBeforeLoadEvents(); |
| 69 static void dispatchPendingLoadEvents(); | 78 static void dispatchPendingLoadEvents(); |
| 70 static void dispatchPendingErrorEvents(); | 79 static void dispatchPendingErrorEvents(); |
| 71 | 80 |
| 81 void addClient(ImageLoaderClient* client) { m_clients.add(client); } | |
|
Stephen White
2013/07/25 18:01:07
I'm not sure if the ImageLoader is really the righ
| |
| 82 void removeClient(ImageLoaderClient* client) { m_clients.remove(client); } | |
| 83 | |
| 72 protected: | 84 protected: |
| 73 virtual void notifyFinished(CachedResource*); | 85 virtual void notifyFinished(CachedResource*); |
| 74 | 86 |
| 75 private: | 87 private: |
| 76 virtual void dispatchLoadEvent() = 0; | 88 virtual void dispatchLoadEvent() = 0; |
| 77 virtual String sourceURI(const AtomicString&) const = 0; | 89 virtual String sourceURI(const AtomicString&) const = 0; |
| 78 | 90 |
| 79 void updatedHasPendingEvent(); | 91 void updatedHasPendingEvent(); |
| 80 | 92 |
| 81 void dispatchPendingBeforeLoadEvent(); | 93 void dispatchPendingBeforeLoadEvent(); |
| 82 void dispatchPendingLoadEvent(); | 94 void dispatchPendingLoadEvent(); |
| 83 void dispatchPendingErrorEvent(); | 95 void dispatchPendingErrorEvent(); |
| 84 | 96 |
| 85 RenderImageResource* renderImageResource(); | 97 RenderImageResource* renderImageResource(); |
| 86 void updateRenderer(); | 98 void updateRenderer(); |
| 87 | 99 |
| 88 void setImageWithoutConsideringPendingLoadEvent(CachedImage*); | 100 void setImageWithoutConsideringPendingLoadEvent(CachedImage*); |
| 101 void sourceImageChanged(); | |
| 89 void clearFailedLoadURL(); | 102 void clearFailedLoadURL(); |
| 90 | 103 |
| 91 void timerFired(Timer<ImageLoader>*); | 104 void timerFired(Timer<ImageLoader>*); |
| 92 | 105 |
| 93 Element* m_element; | 106 Element* m_element; |
| 94 CachedResourceHandle<CachedImage> m_image; | 107 CachedResourceHandle<CachedImage> m_image; |
| 108 HashSet<ImageLoaderClient*> m_clients; | |
| 95 Timer<ImageLoader> m_derefElementTimer; | 109 Timer<ImageLoader> m_derefElementTimer; |
| 96 AtomicString m_failedLoadURL; | 110 AtomicString m_failedLoadURL; |
| 97 bool m_hasPendingBeforeLoadEvent : 1; | 111 bool m_hasPendingBeforeLoadEvent : 1; |
| 98 bool m_hasPendingLoadEvent : 1; | 112 bool m_hasPendingLoadEvent : 1; |
| 99 bool m_hasPendingErrorEvent : 1; | 113 bool m_hasPendingErrorEvent : 1; |
| 100 bool m_imageComplete : 1; | 114 bool m_imageComplete : 1; |
| 101 bool m_loadManually : 1; | 115 bool m_loadManually : 1; |
| 102 bool m_elementIsProtected : 1; | 116 bool m_elementIsProtected : 1; |
| 103 }; | 117 }; |
| 104 | 118 |
| 105 } | 119 } |
| 106 | 120 |
| 107 #endif | 121 #endif |
| OLD | NEW |