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

Side by Side Diff: third_party/WebKit/Source/core/css/CSSImageValue.cpp

Issue 2352193004: Document* -> Document& for loadSubimages and friends. (Closed)
Patch Set: Added constness Created 4 years, 2 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
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 Apple Inc. All rights reserved. 3 * Copyright (C) 2004, 2005, 2006, 2008 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,
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
47 : CSSValue(ImageClass) 47 : CSSValue(ImageClass)
48 , m_relativeURL(absoluteURL) 48 , m_relativeURL(absoluteURL)
49 , m_absoluteURL(absoluteURL) 49 , m_absoluteURL(absoluteURL)
50 { 50 {
51 } 51 }
52 52
53 CSSImageValue::~CSSImageValue() 53 CSSImageValue::~CSSImageValue()
54 { 54 {
55 } 55 }
56 56
57 StyleImage* CSSImageValue::cacheImage(Document* document, CrossOriginAttributeVa lue crossOrigin) 57 StyleImage* CSSImageValue::cacheImage(const Document& document, CrossOriginAttri buteValue crossOrigin)
58 { 58 {
59 ASSERT(document);
60
61 if (!m_cachedImage) { 59 if (!m_cachedImage) {
62 FetchRequest request(ResourceRequest(m_absoluteURL), m_initiatorName.isE mpty() ? FetchInitiatorTypeNames::css : m_initiatorName); 60 FetchRequest request(ResourceRequest(m_absoluteURL), m_initiatorName.isE mpty() ? FetchInitiatorTypeNames::css : m_initiatorName);
63 request.mutableResourceRequest().setHTTPReferrer(SecurityPolicy::generat eReferrer(m_referrer.referrerPolicy, request.url(), m_referrer.referrer)); 61 request.mutableResourceRequest().setHTTPReferrer(SecurityPolicy::generat eReferrer(m_referrer.referrerPolicy, request.url(), m_referrer.referrer));
64 62
65 if (crossOrigin != CrossOriginAttributeNotSet) 63 if (crossOrigin != CrossOriginAttributeNotSet)
66 request.setCrossOriginAccessControl(document->getSecurityOrigin(), c rossOrigin); 64 request.setCrossOriginAccessControl(document.getSecurityOrigin(), cr ossOrigin);
67 65
68 if (ImageResource* cachedImage = ImageResource::fetch(request, document- >fetcher())) 66 if (ImageResource* cachedImage = ImageResource::fetch(request, document. fetcher()))
69 m_cachedImage = StyleFetchedImage::create(cachedImage, document, req uest.url()); 67 m_cachedImage = StyleFetchedImage::create(cachedImage, document, req uest.url());
70 else 68 else
71 m_cachedImage = StyleInvalidImage::create(url()); 69 m_cachedImage = StyleInvalidImage::create(url());
72 } 70 }
73 71
74 return m_cachedImage.get(); 72 return m_cachedImage.get();
75 } 73 }
76 74
77 void CSSImageValue::restoreCachedResourceIfNeeded(Document& document) const 75 void CSSImageValue::restoreCachedResourceIfNeeded(const Document& document) cons t
78 { 76 {
79 if (!m_cachedImage || !document.fetcher() || m_absoluteURL.isNull()) 77 if (!m_cachedImage || !document.fetcher() || m_absoluteURL.isNull())
80 return; 78 return;
81 if (document.fetcher()->cachedResource(KURL(ParsedURLString, m_absoluteURL)) ) 79 if (document.fetcher()->cachedResource(KURL(ParsedURLString, m_absoluteURL)) )
82 return; 80 return;
83 81
84 ImageResource* resource = m_cachedImage->cachedImage(); 82 ImageResource* resource = m_cachedImage->cachedImage();
85 if (!resource) 83 if (!resource)
86 return; 84 return;
87 85
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
126 { 124 {
127 KURL url = document.completeURL(m_relativeURL); 125 KURL url = document.completeURL(m_relativeURL);
128 AtomicString urlString(url.getString()); 126 AtomicString urlString(url.getString());
129 if (urlString == m_absoluteURL) 127 if (urlString == m_absoluteURL)
130 return; 128 return;
131 m_absoluteURL = urlString; 129 m_absoluteURL = urlString;
132 m_cachedImage.clear(); 130 m_cachedImage.clear();
133 } 131 }
134 132
135 } // namespace blink 133 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/css/CSSImageValue.h ('k') | third_party/WebKit/Source/core/css/CSSPaintValue.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698