Move parseFontFaceDescriptor to CSSPropertyParser.cpp
[chromium-blink-merge.git] / third_party / WebKit / Source / core / css / CSSImageValue.h
blob003d89996e49e13e69c7cec161be4fabb0d9d492
1 /*
2 * (C) 1999-2003 Lars Knoll (knoll@kde.org)
3 * Copyright (C) 2004, 2005, 2006, 2008, 2012 Apple Inc. All rights reserved.
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.
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.
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.
21 #ifndef CSSImageValue_h
22 #define CSSImageValue_h
24 #include "core/css/CSSValue.h"
25 #include "core/fetch/ResourceFetcher.h"
26 #include "platform/weborigin/Referrer.h"
27 #include "wtf/RefPtr.h"
29 namespace blink {
31 class Document;
32 class KURL;
33 class StyleFetchedImage;
34 class StyleImage;
35 class LayoutObject;
37 class CSSImageValue : public CSSValue {
38 public:
39 static PassRefPtrWillBeRawPtr<CSSImageValue> create(const KURL& url, StyleImage* image = 0)
41 return create(url.string(), url, image);
43 static PassRefPtrWillBeRawPtr<CSSImageValue> create(const String& rawValue, const KURL& url, StyleImage* image = 0)
45 return create(AtomicString(rawValue), url, image);
47 static PassRefPtrWillBeRawPtr<CSSImageValue> create(const AtomicString& rawValue, const KURL& url, StyleImage* image = 0)
49 return adoptRefWillBeNoop(new CSSImageValue(rawValue, url, image));
51 ~CSSImageValue();
53 StyleFetchedImage* cachedImage(Document*, const ResourceLoaderOptions&);
54 StyleFetchedImage* cachedImage(Document* document) { return cachedImage(document, ResourceFetcher::defaultResourceOptions()); }
55 // Returns a StyleFetchedImage if the image is cached already, otherwise a StylePendingImage.
56 StyleImage* cachedOrPendingImage();
58 const String& url() { return m_absoluteURL; }
60 void setReferrer(const Referrer& referrer) { m_referrer = referrer; }
61 const Referrer& referrer() const { return m_referrer; }
63 void reResolveURL(const Document&);
65 String customCSSText() const;
67 bool hasFailedOrCanceledSubresources() const;
69 bool equals(const CSSImageValue&) const;
71 bool knownToBeOpaque(const LayoutObject*) const;
73 PassRefPtrWillBeRawPtr<CSSImageValue> valueWithURLMadeAbsolute()
75 return create(KURL(ParsedURLString, m_absoluteURL), m_image.get());
78 void setInitiator(const AtomicString& name) { m_initiatorName = name; }
80 DECLARE_TRACE_AFTER_DISPATCH();
81 void restoreCachedResourceIfNeeded(Document&);
83 private:
84 CSSImageValue(const AtomicString& rawValue, const KURL&, StyleImage*);
86 AtomicString m_relativeURL;
87 AtomicString m_absoluteURL;
88 Referrer m_referrer;
89 RefPtrWillBeMember<StyleImage> m_image;
90 bool m_accessedImage;
91 AtomicString m_initiatorName;
94 DEFINE_CSS_VALUE_TYPE_CASTS(CSSImageValue, isImageValue());
96 } // namespace blink
98 #endif // CSSImageValue_h