1 /*
2  * (C) 1999-2003 Lars Knoll (knoll@kde.org)
3  * Copyright (C) 2004, 2005, 2006, 2008 Apple Inc. All rights reserved.
4  *
5  * This library is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU Library General Public
7  * License as published by the Free Software Foundation; either
8  * version 2 of the License, or (at your option) any later version.
9  *
10  * This library is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13  * Library General Public License for more details.
14  *
15  * You should have received a copy of the GNU Library General Public License
16  * along with this library; see the file COPYING.LIB.  If not, write to
17  * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18  * Boston, MA 02110-1301, USA.
19  */
20 
21 #ifndef CSSImageValue_h
22 #define CSSImageValue_h
23 
24 #include "CSSPrimitiveValue.h"
25 #include "CachedResourceClient.h"
26 #include <wtf/RefPtr.h>
27 
28 namespace WebCore {
29 
30 class CachedResourceLoader;
31 class StyleCachedImage;
32 class StyleImage;
33 
34 class CSSImageValue : public CSSPrimitiveValue, private CachedResourceClient {
35     WTF_MAKE_FAST_ALLOCATED;
36 public:
create()37     static PassRefPtr<CSSImageValue> create() { return adoptRef(new CSSImageValue); }
create(const String & url)38     static PassRefPtr<CSSImageValue> create(const String& url) { return adoptRef(new CSSImageValue(url)); }
39     virtual ~CSSImageValue();
40 
41     virtual StyleCachedImage* cachedImage(CachedResourceLoader*);
42     // Returns a StyleCachedImage if the image is cached already, otherwise a StylePendingImage.
43     StyleImage* cachedOrPendingImage();
44 
45 protected:
46     CSSImageValue(const String& url);
47 
48     StyleCachedImage* cachedImage(CachedResourceLoader*, const String& url);
49     String cachedImageURL();
50     void clearCachedImage();
51 
52 private:
53     CSSImageValue();
isImageValue()54     virtual bool isImageValue() const { return true; }
55 
56     RefPtr<StyleImage> m_image;
57     bool m_accessedImage;
58 };
59 
60 } // namespace WebCore
61 
62 #endif // CSSImageValue_h
63