| 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 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 97 { | 97 { |
| 98 return m_isCachePending || deviceScaleFactor != m_cachedScaleFactor; | 98 return m_isCachePending || deviceScaleFactor != m_cachedScaleFactor; |
| 99 } | 99 } |
| 100 | 100 |
| 101 StyleFetchedImageSet* CSSImageSetValue::cachedImageSet(float deviceScaleFactor)
const | 101 StyleFetchedImageSet* CSSImageSetValue::cachedImageSet(float deviceScaleFactor)
const |
| 102 { | 102 { |
| 103 ASSERT(!isCachePending(deviceScaleFactor)); | 103 ASSERT(!isCachePending(deviceScaleFactor)); |
| 104 return m_cachedImageSet.get(); | 104 return m_cachedImageSet.get(); |
| 105 } | 105 } |
| 106 | 106 |
| 107 StyleFetchedImageSet* CSSImageSetValue::cacheImageSet(Document* document, float
deviceScaleFactor, const ResourceLoaderOptions& options) | 107 StyleFetchedImageSet* CSSImageSetValue::cacheImageSet(Document* document, float
deviceScaleFactor, CrossOriginAttributeValue crossOrigin) |
| 108 { | 108 { |
| 109 ASSERT(document); | 109 ASSERT(document); |
| 110 | 110 |
| 111 if (!m_imagesInSet.size()) | 111 if (!m_imagesInSet.size()) |
| 112 fillImageSet(); | 112 fillImageSet(); |
| 113 | 113 |
| 114 if (m_isCachePending || deviceScaleFactor != m_cachedScaleFactor) { | 114 if (m_isCachePending || deviceScaleFactor != m_cachedScaleFactor) { |
| 115 // FIXME: In the future, we want to take much more than deviceScaleFacto
r into acount here. | 115 // FIXME: In the future, we want to take much more than deviceScaleFacto
r into acount here. |
| 116 // All forms of scale should be included: Page::pageScaleFactor(), Local
Frame::pageZoomFactor(), | 116 // All forms of scale should be included: Page::pageScaleFactor(), Local
Frame::pageZoomFactor(), |
| 117 // and any CSS transforms. https://bugs.webkit.org/show_bug.cgi?id=81698 | 117 // and any CSS transforms. https://bugs.webkit.org/show_bug.cgi?id=81698 |
| 118 ImageWithScale image = bestImageForScaleFactor(deviceScaleFactor); | 118 ImageWithScale image = bestImageForScaleFactor(deviceScaleFactor); |
| 119 FetchRequest request(ResourceRequest(document->completeURL(image.imageUR
L)), FetchInitiatorTypeNames::css, options); | 119 FetchRequest request(ResourceRequest(document->completeURL(image.imageUR
L)), FetchInitiatorTypeNames::css); |
| 120 request.mutableResourceRequest().setHTTPReferrer(image.referrer); | 120 request.mutableResourceRequest().setHTTPReferrer(image.referrer); |
| 121 | 121 |
| 122 if (options.corsEnabled == IsCORSEnabled) | 122 if (crossOrigin != CrossOriginAttributeNotSet) |
| 123 request.setCrossOriginAccessControl(document->securityOrigin(), opti
ons.allowCredentials, options.credentialsRequested); | 123 request.setCrossOriginAccessControl(document->securityOrigin(), cros
sOrigin); |
| 124 | 124 |
| 125 if (ResourcePtr<ImageResource> cachedImage = ImageResource::fetch(reques
t, document->fetcher())) { | 125 if (ResourcePtr<ImageResource> cachedImage = ImageResource::fetch(reques
t, document->fetcher())) { |
| 126 m_cachedImageSet = StyleFetchedImageSet::create(cachedImage.get(), i
mage.scaleFactor, this, request.url()); | 126 m_cachedImageSet = StyleFetchedImageSet::create(cachedImage.get(), i
mage.scaleFactor, this, request.url()); |
| 127 m_cachedScaleFactor = deviceScaleFactor; | 127 m_cachedScaleFactor = deviceScaleFactor; |
| 128 m_isCachePending = false; | 128 m_isCachePending = false; |
| 129 } | 129 } |
| 130 } | 130 } |
| 131 | 131 |
| 132 return m_cachedImageSet.get(); | 132 return m_cachedImageSet.get(); |
| 133 } | 133 } |
| 134 | 134 |
| 135 StyleFetchedImageSet* CSSImageSetValue::cacheImageSet(Document* document, float
deviceScaleFactor) | |
| 136 { | |
| 137 return cacheImageSet(document, deviceScaleFactor, ResourceFetcher::defaultRe
sourceOptions()); | |
| 138 } | |
| 139 | |
| 140 String CSSImageSetValue::customCSSText() const | 135 String CSSImageSetValue::customCSSText() const |
| 141 { | 136 { |
| 142 StringBuilder result; | 137 StringBuilder result; |
| 143 result.append("-webkit-image-set("); | 138 result.append("-webkit-image-set("); |
| 144 | 139 |
| 145 size_t length = this->length(); | 140 size_t length = this->length(); |
| 146 size_t i = 0; | 141 size_t i = 0; |
| 147 while (i < length) { | 142 while (i < length) { |
| 148 if (i > 0) | 143 if (i > 0) |
| 149 result.appendLiteral(", "); | 144 result.appendLiteral(", "); |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 185 PassRefPtrWillBeRawPtr<CSSImageSetValue> CSSImageSetValue::valueWithURLsMadeAbso
lute() | 180 PassRefPtrWillBeRawPtr<CSSImageSetValue> CSSImageSetValue::valueWithURLsMadeAbso
lute() |
| 186 { | 181 { |
| 187 RefPtrWillBeRawPtr<CSSImageSetValue> value = CSSImageSetValue::create(); | 182 RefPtrWillBeRawPtr<CSSImageSetValue> value = CSSImageSetValue::create(); |
| 188 for (auto& item : *this) | 183 for (auto& item : *this) |
| 189 item->isImageValue() ? value->append(toCSSImageValue(*item).valueWithURL
MadeAbsolute()) : value->append(item); | 184 item->isImageValue() ? value->append(toCSSImageValue(*item).valueWithURL
MadeAbsolute()) : value->append(item); |
| 190 return value.release(); | 185 return value.release(); |
| 191 } | 186 } |
| 192 | 187 |
| 193 | 188 |
| 194 } // namespace blink | 189 } // namespace blink |
| OLD | NEW |