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 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
53 { | 53 { |
54 if (m_imageSet && m_imageSet->isImageResourceSet()) | 54 if (m_imageSet && m_imageSet->isImageResourceSet()) |
55 toStyleFetchedImageSet(m_imageSet)->clearImageSetValue(); | 55 toStyleFetchedImageSet(m_imageSet)->clearImageSetValue(); |
56 } | 56 } |
57 | 57 |
58 void CSSImageSetValue::fillImageSet() | 58 void CSSImageSetValue::fillImageSet() |
59 { | 59 { |
60 size_t length = this->length(); | 60 size_t length = this->length(); |
61 size_t i = 0; | 61 size_t i = 0; |
62 while (i < length) { | 62 while (i < length) { |
63 CSSImageValue* imageValue = toCSSImageValue(item(i)); | 63 CSSImageValue& imageValue = toCSSImageValue(item(i)); |
64 String imageURL = imageValue->url(); | 64 String imageURL = imageValue.url(); |
65 | 65 |
66 ++i; | 66 ++i; |
67 ASSERT_WITH_SECURITY_IMPLICATION(i < length); | 67 ASSERT_WITH_SECURITY_IMPLICATION(i < length); |
68 CSSValue* scaleFactorValue = item(i); | 68 CSSValue scaleFactorValue = item(i); |
69 float scaleFactor = toCSSPrimitiveValue(scaleFactorValue)->getFloatValue
(); | 69 float scaleFactor = toCSSPrimitiveValue(scaleFactorValue).getFloatValue(
); |
70 | 70 |
71 ImageWithScale image; | 71 ImageWithScale image; |
72 image.imageURL = imageURL; | 72 image.imageURL = imageURL; |
73 image.referrer = SecurityPolicy::generateReferrer(imageValue->referrer()
.referrerPolicy, KURL(ParsedURLString, imageURL), imageValue->referrer().referre
r); | 73 image.referrer = SecurityPolicy::generateReferrer(imageValue.referrer().
referrerPolicy, KURL(ParsedURLString, imageURL), imageValue.referrer().referrer)
; |
74 image.scaleFactor = scaleFactor; | 74 image.scaleFactor = scaleFactor; |
75 m_imagesInSet.append(image); | 75 m_imagesInSet.append(image); |
76 ++i; | 76 ++i; |
77 } | 77 } |
78 | 78 |
79 // Sort the images so that they are stored in order from lowest resolution t
o highest. | 79 // Sort the images so that they are stored in order from lowest resolution t
o highest. |
80 std::sort(m_imagesInSet.begin(), m_imagesInSet.end(), CSSImageSetValue::comp
areByScaleFactor); | 80 std::sort(m_imagesInSet.begin(), m_imagesInSet.end(), CSSImageSetValue::comp
areByScaleFactor); |
81 } | 81 } |
82 | 82 |
83 CSSImageSetValue::ImageWithScale CSSImageSetValue::bestImageForScaleFactor() | 83 CSSImageSetValue::ImageWithScale CSSImageSetValue::bestImageForScaleFactor() |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
145 { | 145 { |
146 StringBuilder result; | 146 StringBuilder result; |
147 result.append("-webkit-image-set("); | 147 result.append("-webkit-image-set("); |
148 | 148 |
149 size_t length = this->length(); | 149 size_t length = this->length(); |
150 size_t i = 0; | 150 size_t i = 0; |
151 while (i < length) { | 151 while (i < length) { |
152 if (i > 0) | 152 if (i > 0) |
153 result.appendLiteral(", "); | 153 result.appendLiteral(", "); |
154 | 154 |
155 const CSSValue* imageValue = item(i); | 155 const CSSValue imageValue = item(i); |
156 result.append(imageValue->cssText()); | 156 result.append(imageValue.cssText()); |
157 result.append(' '); | 157 result.append(' '); |
158 | 158 |
159 ++i; | 159 ++i; |
160 ASSERT_WITH_SECURITY_IMPLICATION(i < length); | 160 ASSERT_WITH_SECURITY_IMPLICATION(i < length); |
161 const CSSValue* scaleFactorValue = item(i); | 161 const CSSValue scaleFactorValue = item(i); |
162 result.append(scaleFactorValue->cssText()); | 162 result.append(scaleFactorValue.cssText()); |
163 // FIXME: Eventually the scale factor should contain it's own unit http:
//wkb.ug/100120. | 163 // FIXME: Eventually the scale factor should contain it's own unit http:
//wkb.ug/100120. |
164 // For now 'x' is hard-coded in the parser, so we hard-code it here too. | 164 // For now 'x' is hard-coded in the parser, so we hard-code it here too. |
165 result.append('x'); | 165 result.append('x'); |
166 | 166 |
167 ++i; | 167 ++i; |
168 } | 168 } |
169 | 169 |
170 result.append(')'); | 170 result.append(')'); |
171 return result.toString(); | 171 return result.toString(); |
172 } | 172 } |
173 | 173 |
174 bool CSSImageSetValue::hasFailedOrCanceledSubresources() const | 174 bool CSSImageSetValue::hasFailedOrCanceledSubresources() const |
175 { | 175 { |
176 if (!m_imageSet || !m_imageSet->isImageResourceSet()) | 176 if (!m_imageSet || !m_imageSet->isImageResourceSet()) |
177 return false; | 177 return false; |
178 if (Resource* cachedResource = toStyleFetchedImageSet(m_imageSet)->cachedIma
ge()) | 178 if (Resource* cachedResource = toStyleFetchedImageSet(m_imageSet)->cachedIma
ge()) |
179 return cachedResource->loadFailedOrCanceled(); | 179 return cachedResource->loadFailedOrCanceled(); |
180 return true; | 180 return true; |
181 } | 181 } |
182 | 182 |
183 } // namespace blink | 183 } // namespace blink |
OLD | NEW |