Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(102)

Side by Side Diff: Source/core/css/CSSImageValue.h

Issue 164803002: Handle CSSImageValue URLs in inline styles in templates correctly (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Ready for review Created 6 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 /* 1 /*
2 * (C) 1999-2003 Lars Knoll (knoll@kde.org) 2 * (C) 1999-2003 Lars Knoll (knoll@kde.org)
3 * Copyright (C) 2004, 2005, 2006, 2008, 2012 Apple Inc. All rights reserved. 3 * Copyright (C) 2004, 2005, 2006, 2008, 2012 Apple Inc. All rights reserved.
4 * 4 *
5 * This library is free software; you can redistribute it and/or 5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Library General Public 6 * modify it under the terms of the GNU Library General Public
7 * License as published by the Free Software Foundation; either 7 * License as published by the Free Software Foundation; either
8 * version 2 of the License, or (at your option) any later version. 8 * version 2 of the License, or (at your option) any later version.
9 * 9 *
10 * This library is distributed in the hope that it will be useful, 10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Library General Public License for more details. 13 * Library General Public License for more details.
14 * 14 *
15 * You should have received a copy of the GNU Library General Public License 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 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, 17 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18 * Boston, MA 02110-1301, USA. 18 * Boston, MA 02110-1301, USA.
19 */ 19 */
20 20
21 #ifndef CSSImageValue_h 21 #ifndef CSSImageValue_h
22 #define CSSImageValue_h 22 #define CSSImageValue_h
23 23
24 #include "core/css/CSSValue.h" 24 #include "core/css/CSSValue.h"
25 #include "core/fetch/ResourceFetcher.h" 25 #include "core/fetch/ResourceFetcher.h"
26 #include "platform/weborigin/KURL.h"
26 #include "wtf/RefPtr.h" 27 #include "wtf/RefPtr.h"
27 28
28 namespace WebCore { 29 namespace WebCore {
29 30
30 class Element; 31 class Element;
31 class KURL;
32 class StyleFetchedImage; 32 class StyleFetchedImage;
33 class StyleImage; 33 class StyleImage;
34 class RenderObject; 34 class RenderObject;
35 35
36 class CSSImageValue : public CSSValue { 36 class CSSImageValue : public CSSValue {
37 public: 37 public:
38 static PassRefPtrWillBeRawPtr<CSSImageValue> create(const KURL& url) 38 static PassRefPtrWillBeRawPtr<CSSImageValue> create(const KURL& url, StyleIm age* image = 0)
39 { 39 {
40 return adoptRefCountedWillBeRefCountedGarbageCollected(new CSSImageValue (url)); 40 return adoptRefCountedWillBeRefCountedGarbageCollected(new CSSImageValue (url, url, image));
41 } 41 }
42 static PassRefPtrWillBeRawPtr<CSSImageValue> create(const KURL& url, StyleIm age* image) 42 static PassRefPtrWillBeRawPtr<CSSImageValue> create(const String& rawValue, const KURL& url, StyleImage* image = 0)
43 { 43 {
44 return adoptRefCountedWillBeRefCountedGarbageCollected(new CSSImageValue (url, image)); 44 return adoptRefCountedWillBeRefCountedGarbageCollected(new CSSImageValue (rawValue, url, image));
45 } 45 }
46 ~CSSImageValue(); 46 ~CSSImageValue();
47 47
48 StyleFetchedImage* cachedImage(ResourceFetcher*, const ResourceLoaderOptions &); 48 StyleFetchedImage* cachedImage(ResourceFetcher*, const ResourceLoaderOptions &);
49 StyleFetchedImage* cachedImage(ResourceFetcher* fetcher) { return cachedImag e(fetcher, ResourceFetcher::defaultResourceOptions()); } 49 StyleFetchedImage* cachedImage(ResourceFetcher* fetcher) { return cachedImag e(fetcher, ResourceFetcher::defaultResourceOptions()); }
50 // Returns a StyleFetchedImage if the image is cached already, otherwise a S tylePendingImage. 50 // Returns a StyleFetchedImage if the image is cached already, otherwise a S tylePendingImage.
51 StyleImage* cachedOrPendingImage(); 51 StyleImage* cachedOrPendingImage();
52 52
53 const String& url() { return m_url; } 53 const String& url() { return m_absoluteURL; }
54
55 template<typename URLResolver> // Avoids a dependency on Document
ojan 2014/02/26 03:00:30 templates scare me. Avoiding a Document dependency
adamk 2014/02/26 17:00:20 This may be overkill, given the other dependencies
56 void reResolveURL(const URLResolver& resolver) { reResolveURLInternal(resolv er.completeURL(m_relativeURL)); }
54 57
55 String customCSSText() const; 58 String customCSSText() const;
56 59
57 PassRefPtrWillBeRawPtr<CSSValue> cloneForCSSOM() const; 60 PassRefPtrWillBeRawPtr<CSSValue> cloneForCSSOM() const;
58 61
59 bool hasFailedOrCanceledSubresources() const; 62 bool hasFailedOrCanceledSubresources() const;
60 63
61 bool equals(const CSSImageValue&) const; 64 bool equals(const CSSImageValue&) const;
62 65
63 bool knownToBeOpaque(const RenderObject*) const; 66 bool knownToBeOpaque(const RenderObject*) const;
64 67
65 void setInitiator(const AtomicString& name) { m_initiatorName = name; } 68 void setInitiator(const AtomicString& name) { m_initiatorName = name; }
66 69
67 void traceAfterDispatch(Visitor*); 70 void traceAfterDispatch(Visitor*);
68 71
69 private: 72 private:
70 explicit CSSImageValue(const KURL&); 73 CSSImageValue(const String& rawValue, const KURL&, StyleImage*);
71 CSSImageValue(const KURL&, StyleImage*);
72 74
73 String m_url; 75 void reResolveURLInternal(const KURL&);
76
77 String m_relativeURL;
78 String m_absoluteURL;
74 RefPtr<StyleImage> m_image; 79 RefPtr<StyleImage> m_image;
75 bool m_accessedImage; 80 bool m_accessedImage;
76 AtomicString m_initiatorName; 81 AtomicString m_initiatorName;
77 }; 82 };
78 83
79 DEFINE_CSS_VALUE_TYPE_CASTS(CSSImageValue, isImageValue()); 84 DEFINE_CSS_VALUE_TYPE_CASTS(CSSImageValue, isImageValue());
80 85
81 } // namespace WebCore 86 } // namespace WebCore
82 87
83 #endif // CSSImageValue_h 88 #endif // CSSImageValue_h
OLDNEW
« no previous file with comments | « LayoutTests/fast/css/resolve-inline-style-url-on-adopt-expected.html ('k') | Source/core/css/CSSImageValue.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698