Chromium Code Reviews| 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 --i; | |
|
eseidel
2014/04/23 20:55:27
And i is never 0 here? can't fall off the end of t
| |
| 167 float winningScaleFactor = imageCandidates[i].scaleFactor(); | 169 float winningScaleFactor = imageCandidates[i].scaleFactor(); |
| 170 | |
| 168 unsigned winner = i; | 171 unsigned winner = i; |
| 169 // 16. If an entry b in candidates has the same associated ... pixel density as an earlier entry a in candidates, | 172 // 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 | 173 // then remove entry b |
| 171 while ((i > 0) && (imageCandidates[--i].scaleFactor() == winningScaleFactor) ) | 174 while ((i > 0) && (imageCandidates[--i].scaleFactor() == winningScaleFactor) ) |
| 172 winner = i; | 175 winner = i; |
| 173 | 176 |
| 174 return imageCandidates[winner]; | 177 return imageCandidates[winner]; |
| 175 } | 178 } |
| 176 | 179 |
| 177 ImageCandidate bestFitSourceForSrcsetAttribute(float deviceScaleFactor, unsigned sourceSize, const String& srcsetAttribute) | 180 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; | 218 Vector<ImageCandidate> imageCandidates; |
| 216 imageCandidates.append(srcsetImageCandidate); | 219 imageCandidates.append(srcsetImageCandidate); |
| 217 | 220 |
| 218 if (!srcAttribute.isEmpty()) | 221 if (!srcAttribute.isEmpty()) |
| 219 imageCandidates.append(ImageCandidate(srcAttribute, 0, srcAttribute.leng th(), defaultResult, ImageCandidate::SrcOrigin)); | 222 imageCandidates.append(ImageCandidate(srcAttribute, 0, srcAttribute.leng th(), defaultResult, ImageCandidate::SrcOrigin)); |
| 220 | 223 |
| 221 return pickBestImageCandidate(deviceScaleFactor, sourceSize, imageCandidates ).toString(); | 224 return pickBestImageCandidate(deviceScaleFactor, sourceSize, imageCandidates ).toString(); |
| 222 } | 225 } |
| 223 | 226 |
| 224 } | 227 } |
| OLD | NEW |