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

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

Issue 2718273002: Resolve background image's url if absolute url is empty (Closed)
Patch Set: Resolve background image url before use Created 3 years, 9 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
« no previous file with comments | « third_party/WebKit/LayoutTests/fast/backgrounds/background-image-relative-url-in-iframe-expected.html ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
46 CSSImageValue::CSSImageValue(const AtomicString& absoluteURL) 46 CSSImageValue::CSSImageValue(const AtomicString& absoluteURL)
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 CSSImageValue::~CSSImageValue() {} 51 CSSImageValue::~CSSImageValue() {}
52 52
53 StyleImage* CSSImageValue::cacheImage(const Document& document, 53 StyleImage* CSSImageValue::cacheImage(const Document& document,
54 CrossOriginAttributeValue crossOrigin) { 54 CrossOriginAttributeValue crossOrigin) {
55 if (!m_cachedImage) { 55 if (!m_cachedImage) {
56 if (m_absoluteURL.isEmpty())
57 reResolveURL(document);
56 FetchRequest request(ResourceRequest(m_absoluteURL), 58 FetchRequest request(ResourceRequest(m_absoluteURL),
57 m_initiatorName.isEmpty() 59 m_initiatorName.isEmpty()
58 ? FetchInitiatorTypeNames::css 60 ? FetchInitiatorTypeNames::css
59 : m_initiatorName); 61 : m_initiatorName);
60 request.mutableResourceRequest().setHTTPReferrer( 62 request.mutableResourceRequest().setHTTPReferrer(
61 SecurityPolicy::generateReferrer(m_referrer.referrerPolicy, 63 SecurityPolicy::generateReferrer(m_referrer.referrerPolicy,
62 request.url(), m_referrer.referrer)); 64 request.url(), m_referrer.referrer));
63 65
64 if (crossOrigin != CrossOriginAttributeNotSet) 66 if (crossOrigin != CrossOriginAttributeNotSet)
65 request.setCrossOriginAccessControl(document.getSecurityOrigin(), 67 request.setCrossOriginAccessControl(document.getSecurityOrigin(),
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
123 void CSSImageValue::reResolveURL(const Document& document) const { 125 void CSSImageValue::reResolveURL(const Document& document) const {
124 KURL url = document.completeURL(m_relativeURL); 126 KURL url = document.completeURL(m_relativeURL);
125 AtomicString urlString(url.getString()); 127 AtomicString urlString(url.getString());
126 if (urlString == m_absoluteURL) 128 if (urlString == m_absoluteURL)
127 return; 129 return;
128 m_absoluteURL = urlString; 130 m_absoluteURL = urlString;
129 m_cachedImage.clear(); 131 m_cachedImage.clear();
130 } 132 }
131 133
132 } // namespace blink 134 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/LayoutTests/fast/backgrounds/background-image-relative-url-in-iframe-expected.html ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698