OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2012 Apple Inc. All rights reserved. | 2 * Copyright (C) 2012 Apple Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
6 * are met: | 6 * are met: |
7 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
93 { | 93 { |
94 return !m_cachedImage || deviceScaleFactor != m_cachedScaleFactor; | 94 return !m_cachedImage || deviceScaleFactor != m_cachedScaleFactor; |
95 } | 95 } |
96 | 96 |
97 StyleImage* CSSImageSetValue::cachedImage(float deviceScaleFactor) const | 97 StyleImage* CSSImageSetValue::cachedImage(float deviceScaleFactor) const |
98 { | 98 { |
99 ASSERT(!isCachePending(deviceScaleFactor)); | 99 ASSERT(!isCachePending(deviceScaleFactor)); |
100 return m_cachedImage.get(); | 100 return m_cachedImage.get(); |
101 } | 101 } |
102 | 102 |
103 StyleImage* CSSImageSetValue::cacheImage(Document* document, float deviceScaleFa
ctor, CrossOriginAttributeValue crossOrigin) | 103 StyleImage* CSSImageSetValue::cacheImage(const Document& document, float deviceS
caleFactor, CrossOriginAttributeValue crossOrigin) |
104 { | 104 { |
105 ASSERT(document); | |
106 | |
107 if (!m_imagesInSet.size()) | 105 if (!m_imagesInSet.size()) |
108 fillImageSet(); | 106 fillImageSet(); |
109 | 107 |
110 if (isCachePending(deviceScaleFactor)) { | 108 if (isCachePending(deviceScaleFactor)) { |
111 // FIXME: In the future, we want to take much more than deviceScaleFacto
r into acount here. | 109 // FIXME: In the future, we want to take much more than deviceScaleFacto
r into acount here. |
112 // All forms of scale should be included: Page::pageScaleFactor(), Local
Frame::pageZoomFactor(), | 110 // All forms of scale should be included: Page::pageScaleFactor(), Local
Frame::pageZoomFactor(), |
113 // and any CSS transforms. https://bugs.webkit.org/show_bug.cgi?id=81698 | 111 // and any CSS transforms. https://bugs.webkit.org/show_bug.cgi?id=81698 |
114 ImageWithScale image = bestImageForScaleFactor(deviceScaleFactor); | 112 ImageWithScale image = bestImageForScaleFactor(deviceScaleFactor); |
115 FetchRequest request(ResourceRequest(document->completeURL(image.imageUR
L)), FetchInitiatorTypeNames::css); | 113 FetchRequest request(ResourceRequest(document.completeURL(image.imageURL
)), FetchInitiatorTypeNames::css); |
116 request.mutableResourceRequest().setHTTPReferrer(image.referrer); | 114 request.mutableResourceRequest().setHTTPReferrer(image.referrer); |
117 | 115 |
118 if (crossOrigin != CrossOriginAttributeNotSet) | 116 if (crossOrigin != CrossOriginAttributeNotSet) |
119 request.setCrossOriginAccessControl(document->getSecurityOrigin(), c
rossOrigin); | 117 request.setCrossOriginAccessControl(document.getSecurityOrigin(), cr
ossOrigin); |
120 | 118 |
121 if (ImageResource* cachedImage = ImageResource::fetch(request, document-
>fetcher())) | 119 if (ImageResource* cachedImage = ImageResource::fetch(request, document.
fetcher())) |
122 m_cachedImage = StyleFetchedImageSet::create(cachedImage, image.scal
eFactor, this, request.url()); | 120 m_cachedImage = StyleFetchedImageSet::create(cachedImage, image.scal
eFactor, this, request.url()); |
123 else | 121 else |
124 m_cachedImage = StyleInvalidImage::create(image.imageURL); | 122 m_cachedImage = StyleInvalidImage::create(image.imageURL); |
125 m_cachedScaleFactor = deviceScaleFactor; | 123 m_cachedScaleFactor = deviceScaleFactor; |
126 } | 124 } |
127 | 125 |
128 return m_cachedImage.get(); | 126 return m_cachedImage.get(); |
129 } | 127 } |
130 | 128 |
131 String CSSImageSetValue::customCSSText() const | 129 String CSSImageSetValue::customCSSText() const |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
176 CSSImageSetValue* CSSImageSetValue::valueWithURLsMadeAbsolute() | 174 CSSImageSetValue* CSSImageSetValue::valueWithURLsMadeAbsolute() |
177 { | 175 { |
178 CSSImageSetValue* value = CSSImageSetValue::create(); | 176 CSSImageSetValue* value = CSSImageSetValue::create(); |
179 for (auto& item : *this) | 177 for (auto& item : *this) |
180 item->isImageValue() ? value->append(*toCSSImageValue(*item).valueWithUR
LMadeAbsolute()) : value->append(*item); | 178 item->isImageValue() ? value->append(*toCSSImageValue(*item).valueWithUR
LMadeAbsolute()) : value->append(*item); |
181 return value; | 179 return value; |
182 } | 180 } |
183 | 181 |
184 | 182 |
185 } // namespace blink | 183 } // namespace blink |
OLD | NEW |