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

Side by Side Diff: Source/core/css/CSSImageSetValue.cpp

Issue 137983010: (Re)organize handling of CORS access control during resource loading. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: HTMLImportLoader no longer needs a ResourceFetcher Created 6 years, 11 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 | « Source/core/css/CSSImageSetValue.h ('k') | Source/core/css/CSSImageValue.h » ('j') | 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 * 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 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
81 ImageWithScale image; 81 ImageWithScale image;
82 size_t numberOfImages = m_imagesInSet.size(); 82 size_t numberOfImages = m_imagesInSet.size();
83 for (size_t i = 0; i < numberOfImages; ++i) { 83 for (size_t i = 0; i < numberOfImages; ++i) {
84 image = m_imagesInSet.at(i); 84 image = m_imagesInSet.at(i);
85 if (image.scaleFactor >= m_scaleFactor) 85 if (image.scaleFactor >= m_scaleFactor)
86 return image; 86 return image;
87 } 87 }
88 return image; 88 return image;
89 } 89 }
90 90
91 StyleFetchedImageSet* CSSImageSetValue::cachedImageSet(ResourceFetcher* loader, float deviceScaleFactor, const ResourceLoaderOptions& options, CORSEnabled corsE nabled) 91 StyleFetchedImageSet* CSSImageSetValue::cachedImageSet(ResourceFetcher* loader, float deviceScaleFactor, const ResourceLoaderOptions& options)
92 { 92 {
93 ASSERT(loader); 93 ASSERT(loader);
94 94
95 m_scaleFactor = deviceScaleFactor; 95 m_scaleFactor = deviceScaleFactor;
96 96
97 if (!m_imagesInSet.size()) 97 if (!m_imagesInSet.size())
98 fillImageSet(); 98 fillImageSet();
99 99
100 if (!m_accessedBestFitImage) { 100 if (!m_accessedBestFitImage) {
101 // FIXME: In the future, we want to take much more than deviceScaleFacto r into acount here. 101 // FIXME: In the future, we want to take much more than deviceScaleFacto r into acount here.
102 // All forms of scale should be included: Page::pageScaleFactor(), Frame ::pageZoomFactor(), 102 // All forms of scale should be included: Page::pageScaleFactor(), Frame ::pageZoomFactor(),
103 // and any CSS transforms. https://bugs.webkit.org/show_bug.cgi?id=81698 103 // and any CSS transforms. https://bugs.webkit.org/show_bug.cgi?id=81698
104 ImageWithScale image = bestImageForScaleFactor(); 104 ImageWithScale image = bestImageForScaleFactor();
105 if (Document* document = loader->document()) { 105 if (Document* document = loader->document()) {
106 FetchRequest request(ResourceRequest(document->completeURL(image.ima geURL)), FetchInitiatorTypeNames::css, options); 106 FetchRequest request(ResourceRequest(document->completeURL(image.ima geURL)), FetchInitiatorTypeNames::css, options);
107 107
108 if (corsEnabled == PotentiallyCORSEnabled) 108 if (options.corsEnabled == IsCORSEnabled)
109 updateRequestForAccessControl(request.mutableResourceRequest(), loader->document()->securityOrigin(), options.allowCredentials); 109 request.setCrossOriginAccessControl(loader->document()->security Origin(), options.allowCredentials);
110 110
111 if (ResourcePtr<ImageResource> cachedImage = loader->fetchImage(requ est)) { 111 if (ResourcePtr<ImageResource> cachedImage = loader->fetchImage(requ est)) {
112 m_imageSet = StyleFetchedImageSet::create(cachedImage.get(), ima ge.scaleFactor, this); 112 m_imageSet = StyleFetchedImageSet::create(cachedImage.get(), ima ge.scaleFactor, this);
113 m_accessedBestFitImage = true; 113 m_accessedBestFitImage = true;
114 } 114 }
115 } 115 }
116 } 116 }
117 117
118 return (m_imageSet && m_imageSet->isImageResourceSet()) ? toStyleFetchedImag eSet(m_imageSet) : 0; 118 return (m_imageSet && m_imageSet->isImageResourceSet()) ? toStyleFetchedImag eSet(m_imageSet) : 0;
119 } 119 }
120 120
121 StyleFetchedImageSet* CSSImageSetValue::cachedImageSet(ResourceFetcher* fetcher, float deviceScaleFactor) 121 StyleFetchedImageSet* CSSImageSetValue::cachedImageSet(ResourceFetcher* fetcher, float deviceScaleFactor)
122 { 122 {
123 return cachedImageSet(fetcher, deviceScaleFactor, ResourceFetcher::defaultRe sourceOptions(), NotCORSEnabled); 123 return cachedImageSet(fetcher, deviceScaleFactor, ResourceFetcher::defaultRe sourceOptions());
124 } 124 }
125 125
126 StyleImage* CSSImageSetValue::cachedOrPendingImageSet(float deviceScaleFactor) 126 StyleImage* CSSImageSetValue::cachedOrPendingImageSet(float deviceScaleFactor)
127 { 127 {
128 if (!m_imageSet) { 128 if (!m_imageSet) {
129 m_imageSet = StylePendingImage::create(this); 129 m_imageSet = StylePendingImage::create(this);
130 } else if (!m_imageSet->isPendingImage()) { 130 } else if (!m_imageSet->isPendingImage()) {
131 // If the deviceScaleFactor has changed, we may not have the best image loaded, so we have to re-assess. 131 // If the deviceScaleFactor has changed, we may not have the best image loaded, so we have to re-assess.
132 if (deviceScaleFactor != m_scaleFactor) { 132 if (deviceScaleFactor != m_scaleFactor) {
133 m_accessedBestFitImage = false; 133 m_accessedBestFitImage = false;
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
184 { 184 {
185 // Non-CSSValueList data is not accessible through CSS OM, no need to clone. 185 // Non-CSSValueList data is not accessible through CSS OM, no need to clone.
186 } 186 }
187 187
188 PassRefPtr<CSSImageSetValue> CSSImageSetValue::cloneForCSSOM() const 188 PassRefPtr<CSSImageSetValue> CSSImageSetValue::cloneForCSSOM() const
189 { 189 {
190 return adoptRef(new CSSImageSetValue(*this)); 190 return adoptRef(new CSSImageSetValue(*this));
191 } 191 }
192 192
193 } // namespace WebCore 193 } // namespace WebCore
OLDNEW
« no previous file with comments | « Source/core/css/CSSImageSetValue.h ('k') | Source/core/css/CSSImageValue.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698