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 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
50 { | 50 { |
51 if (m_imageSet && m_imageSet->isImageResourceSet()) | 51 if (m_imageSet && m_imageSet->isImageResourceSet()) |
52 toStyleFetchedImageSet(m_imageSet)->clearImageSetValue(); | 52 toStyleFetchedImageSet(m_imageSet)->clearImageSetValue(); |
53 } | 53 } |
54 | 54 |
55 void CSSImageSetValue::fillImageSet() | 55 void CSSImageSetValue::fillImageSet() |
56 { | 56 { |
57 size_t length = this->length(); | 57 size_t length = this->length(); |
58 size_t i = 0; | 58 size_t i = 0; |
59 while (i < length) { | 59 while (i < length) { |
60 CSSImageValue* imageValue = toCSSImageValue(item(i)); | 60 CSSValue* imageValue = item(i); |
61 String imageURL = imageValue->url(); | 61 String imageURL = toCSSImageValue(imageValue)->url(); |
62 | 62 |
63 ++i; | 63 ++i; |
64 ASSERT_WITH_SECURITY_IMPLICATION(i < length); | 64 ASSERT_WITH_SECURITY_IMPLICATION(i < length); |
65 CSSValue* scaleFactorValue = item(i); | 65 CSSValue* scaleFactorValue = item(i); |
66 float scaleFactor = toCSSPrimitiveValue(scaleFactorValue)->getFloatValue
(); | 66 float scaleFactor = toCSSPrimitiveValue(scaleFactorValue)->getFloatValue
(); |
67 | 67 |
68 ImageWithScale image; | 68 ImageWithScale image; |
69 image.imageURL = imageURL; | 69 image.imageURL = imageURL; |
70 image.referrer = imageValue->referrer(); | |
71 image.scaleFactor = scaleFactor; | 70 image.scaleFactor = scaleFactor; |
72 m_imagesInSet.append(image); | 71 m_imagesInSet.append(image); |
73 ++i; | 72 ++i; |
74 } | 73 } |
75 | 74 |
76 // Sort the images so that they are stored in order from lowest resolution t
o highest. | 75 // Sort the images so that they are stored in order from lowest resolution t
o highest. |
77 std::sort(m_imagesInSet.begin(), m_imagesInSet.end(), CSSImageSetValue::comp
areByScaleFactor); | 76 std::sort(m_imagesInSet.begin(), m_imagesInSet.end(), CSSImageSetValue::comp
areByScaleFactor); |
78 } | 77 } |
79 | 78 |
80 CSSImageSetValue::ImageWithScale CSSImageSetValue::bestImageForScaleFactor() | 79 CSSImageSetValue::ImageWithScale CSSImageSetValue::bestImageForScaleFactor() |
(...skipping 17 matching lines...) Expand all Loading... |
98 if (!m_imagesInSet.size()) | 97 if (!m_imagesInSet.size()) |
99 fillImageSet(); | 98 fillImageSet(); |
100 | 99 |
101 if (!m_accessedBestFitImage) { | 100 if (!m_accessedBestFitImage) { |
102 // 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. |
103 // All forms of scale should be included: Page::pageScaleFactor(), Local
Frame::pageZoomFactor(), | 102 // All forms of scale should be included: Page::pageScaleFactor(), Local
Frame::pageZoomFactor(), |
104 // 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 |
105 ImageWithScale image = bestImageForScaleFactor(); | 104 ImageWithScale image = bestImageForScaleFactor(); |
106 if (Document* document = loader->document()) { | 105 if (Document* document = loader->document()) { |
107 FetchRequest request(ResourceRequest(document->completeURL(image.ima
geURL)), FetchInitiatorTypeNames::css, options); | 106 FetchRequest request(ResourceRequest(document->completeURL(image.ima
geURL)), FetchInitiatorTypeNames::css, options); |
108 if (!image.referrer.isEmpty()) | |
109 request.mutableResourceRequest().setHTTPReferrer(Referrer(image.
referrer, ReferrerPolicyDefault)); | |
110 | 107 |
111 if (options.corsEnabled == IsCORSEnabled) | 108 if (options.corsEnabled == IsCORSEnabled) |
112 request.setCrossOriginAccessControl(loader->document()->security
Origin(), options.allowCredentials, options.credentialsRequested); | 109 request.setCrossOriginAccessControl(loader->document()->security
Origin(), options.allowCredentials, options.credentialsRequested); |
113 | 110 |
114 if (ResourcePtr<ImageResource> cachedImage = loader->fetchImage(requ
est)) { | 111 if (ResourcePtr<ImageResource> cachedImage = loader->fetchImage(requ
est)) { |
115 m_imageSet = StyleFetchedImageSet::create(cachedImage.get(), ima
ge.scaleFactor, this); | 112 m_imageSet = StyleFetchedImageSet::create(cachedImage.get(), ima
ge.scaleFactor, this); |
116 m_accessedBestFitImage = true; | 113 m_accessedBestFitImage = true; |
117 } | 114 } |
118 } | 115 } |
119 } | 116 } |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
187 { | 184 { |
188 // 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. |
189 } | 186 } |
190 | 187 |
191 PassRefPtrWillBeRawPtr<CSSImageSetValue> CSSImageSetValue::cloneForCSSOM() const | 188 PassRefPtrWillBeRawPtr<CSSImageSetValue> CSSImageSetValue::cloneForCSSOM() const |
192 { | 189 { |
193 return adoptRefWillBeRefCountedGarbageCollected(new CSSImageSetValue(*this))
; | 190 return adoptRefWillBeRefCountedGarbageCollected(new CSSImageSetValue(*this))
; |
194 } | 191 } |
195 | 192 |
196 } // namespace WebCore | 193 } // namespace WebCore |
OLD | NEW |