OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2013 Google Inc. All rights reserved. | 2 * Copyright (C) 2013 Google 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 are | 5 * modification, are permitted provided that the following conditions are |
6 * met: | 6 * met: |
7 * | 7 * |
8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
157 } | 157 } |
158 | 158 |
159 std::stable_sort(imageCandidates.begin(), imageCandidates.end(), compareBySc
aleFactor); | 159 std::stable_sort(imageCandidates.begin(), imageCandidates.end(), compareBySc
aleFactor); |
160 | 160 |
161 unsigned i; | 161 unsigned i; |
162 for (i = 0; i < imageCandidates.size() - 1; ++i) { | 162 for (i = 0; i < imageCandidates.size() - 1; ++i) { |
163 if ((imageCandidates[i].scaleFactor() >= deviceScaleFactor) && (!ignoreS
rc || !imageCandidates[i].srcOrigin())) | 163 if ((imageCandidates[i].scaleFactor() >= deviceScaleFactor) && (!ignoreS
rc || !imageCandidates[i].srcOrigin())) |
164 break; | 164 break; |
165 } | 165 } |
166 | 166 |
| 167 if (imageCandidates[i].srcOrigin() && ignoreSrc) { |
| 168 ASSERT(i > 0); |
| 169 --i; |
| 170 } |
167 float winningScaleFactor = imageCandidates[i].scaleFactor(); | 171 float winningScaleFactor = imageCandidates[i].scaleFactor(); |
| 172 |
168 unsigned winner = i; | 173 unsigned winner = i; |
169 // 16. If an entry b in candidates has the same associated ... pixel density
as an earlier entry a in candidates, | 174 // 16. If an entry b in candidates has the same associated ... pixel density
as an earlier entry a in candidates, |
170 // then remove entry b | 175 // then remove entry b |
171 while ((i > 0) && (imageCandidates[--i].scaleFactor() == winningScaleFactor)
) | 176 while ((i > 0) && (imageCandidates[--i].scaleFactor() == winningScaleFactor)
) |
172 winner = i; | 177 winner = i; |
173 | 178 |
174 return imageCandidates[winner]; | 179 return imageCandidates[winner]; |
175 } | 180 } |
176 | 181 |
177 ImageCandidate bestFitSourceForSrcsetAttribute(float deviceScaleFactor, unsigned
sourceSize, const String& srcsetAttribute) | 182 ImageCandidate bestFitSourceForSrcsetAttribute(float deviceScaleFactor, unsigned
sourceSize, const String& srcsetAttribute) |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
215 Vector<ImageCandidate> imageCandidates; | 220 Vector<ImageCandidate> imageCandidates; |
216 imageCandidates.append(srcsetImageCandidate); | 221 imageCandidates.append(srcsetImageCandidate); |
217 | 222 |
218 if (!srcAttribute.isEmpty()) | 223 if (!srcAttribute.isEmpty()) |
219 imageCandidates.append(ImageCandidate(srcAttribute, 0, srcAttribute.leng
th(), defaultResult, ImageCandidate::SrcOrigin)); | 224 imageCandidates.append(ImageCandidate(srcAttribute, 0, srcAttribute.leng
th(), defaultResult, ImageCandidate::SrcOrigin)); |
220 | 225 |
221 return pickBestImageCandidate(deviceScaleFactor, sourceSize, imageCandidates
).toString(); | 226 return pickBestImageCandidate(deviceScaleFactor, sourceSize, imageCandidates
).toString(); |
222 } | 227 } |
223 | 228 |
224 } | 229 } |
OLD | NEW |