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

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

Issue 2423683002: Add Blink support for showing image placeholders using range requests. (Closed)
Patch Set: Addressed comments 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,
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 #include "core/css/CSSImageValue.h" 21 #include "core/css/CSSImageValue.h"
22 22
23 #include "core/css/CSSMarkup.h" 23 #include "core/css/CSSMarkup.h"
24 #include "core/dom/Document.h" 24 #include "core/dom/Document.h"
25 #include "core/fetch/FetchInitiatorTypeNames.h" 25 #include "core/fetch/FetchInitiatorTypeNames.h"
26 #include "core/fetch/FetchRequest.h" 26 #include "core/fetch/FetchRequest.h"
27 #include "core/fetch/ImageResource.h" 27 #include "core/fetch/ImageResource.h"
28 #include "core/fetch/ResourceFetcher.h" 28 #include "core/fetch/ResourceFetcher.h"
29 #include "core/frame/Settings.h"
29 #include "core/loader/MixedContentChecker.h" 30 #include "core/loader/MixedContentChecker.h"
30 #include "core/style/StyleFetchedImage.h" 31 #include "core/style/StyleFetchedImage.h"
31 #include "core/style/StyleInvalidImage.h" 32 #include "core/style/StyleInvalidImage.h"
32 #include "platform/CrossOriginAttributeValue.h" 33 #include "platform/CrossOriginAttributeValue.h"
33 #include "platform/weborigin/KURL.h" 34 #include "platform/weborigin/KURL.h"
34 #include "platform/weborigin/SecurityPolicy.h" 35 #include "platform/weborigin/SecurityPolicy.h"
35 36
36 namespace blink { 37 namespace blink {
37 38
38 CSSImageValue::CSSImageValue(const AtomicString& rawValue, 39 CSSImageValue::CSSImageValue(const AtomicString& rawValue,
(...skipping 18 matching lines...) Expand all
57 m_initiatorName.isEmpty() 58 m_initiatorName.isEmpty()
58 ? FetchInitiatorTypeNames::css 59 ? FetchInitiatorTypeNames::css
59 : m_initiatorName); 60 : m_initiatorName);
60 request.mutableResourceRequest().setHTTPReferrer( 61 request.mutableResourceRequest().setHTTPReferrer(
61 SecurityPolicy::generateReferrer(m_referrer.referrerPolicy, 62 SecurityPolicy::generateReferrer(m_referrer.referrerPolicy,
62 request.url(), m_referrer.referrer)); 63 request.url(), m_referrer.referrer));
63 64
64 if (crossOrigin != CrossOriginAttributeNotSet) 65 if (crossOrigin != CrossOriginAttributeNotSet)
65 request.setCrossOriginAccessControl(document.getSecurityOrigin(), 66 request.setCrossOriginAccessControl(document.getSecurityOrigin(),
66 crossOrigin); 67 crossOrigin);
68 if (document.settings() && document.settings()->fetchImagePlaceholders())
69 request.setAllowImagePlaceholder();
67 70
68 if (ImageResource* cachedImage = 71 if (ImageResource* cachedImage =
69 ImageResource::fetch(request, document.fetcher())) 72 ImageResource::fetch(request, document.fetcher()))
70 m_cachedImage = 73 m_cachedImage =
71 StyleFetchedImage::create(cachedImage, document, request.url()); 74 StyleFetchedImage::create(cachedImage, document, request.url());
72 else 75 else
73 m_cachedImage = StyleInvalidImage::create(url()); 76 m_cachedImage = StyleInvalidImage::create(url());
74 } 77 }
75 78
76 return m_cachedImage.get(); 79 return m_cachedImage.get();
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
129 void CSSImageValue::reResolveURL(const Document& document) const { 132 void CSSImageValue::reResolveURL(const Document& document) const {
130 KURL url = document.completeURL(m_relativeURL); 133 KURL url = document.completeURL(m_relativeURL);
131 AtomicString urlString(url.getString()); 134 AtomicString urlString(url.getString());
132 if (urlString == m_absoluteURL) 135 if (urlString == m_absoluteURL)
133 return; 136 return;
134 m_absoluteURL = urlString; 137 m_absoluteURL = urlString;
135 m_cachedImage.clear(); 138 m_cachedImage.clear();
136 } 139 }
137 140
138 } // namespace blink 141 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698