OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2013 Apple Inc. All rights reserved. | 2 * Copyright (C) 2013 Apple Inc. All rights reserved. |
3 * Copyright (C) 2013 Google Inc. All rights reserved. | 3 * Copyright (C) 2013 Google Inc. All rights reserved. |
4 * | 4 * |
5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
6 * modification, are permitted provided that the following conditions are | 6 * modification, are permitted provided that the following conditions are |
7 * met: | 7 * met: |
8 * | 8 * |
9 * * Redistributions of source code must retain the above copyright | 9 * * Redistributions of source code must retain the above copyright |
10 * notice, this list of conditions and the following disclaimer. | 10 * notice, this list of conditions and the following disclaimer. |
(...skipping 352 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
363 | 363 |
364 static ImageCandidate pickBestImageCandidate(float deviceScaleFactor, float sour
ceSize, Vector<ImageCandidate>& imageCandidates, Document* document = nullptr) | 364 static ImageCandidate pickBestImageCandidate(float deviceScaleFactor, float sour
ceSize, Vector<ImageCandidate>& imageCandidates, Document* document = nullptr) |
365 { | 365 { |
366 const float defaultDensityValue = 1.0; | 366 const float defaultDensityValue = 1.0; |
367 bool ignoreSrc = false; | 367 bool ignoreSrc = false; |
368 if (imageCandidates.isEmpty()) | 368 if (imageCandidates.isEmpty()) |
369 return ImageCandidate(); | 369 return ImageCandidate(); |
370 | 370 |
371 // http://picture.responsiveimages.org/#normalize-source-densities | 371 // http://picture.responsiveimages.org/#normalize-source-densities |
372 for (ImageCandidate& image : imageCandidates) { | 372 for (ImageCandidate& image : imageCandidates) { |
373 if (image.resourceWidth() > 0) { | 373 if (image.getResourceWidth() > 0) { |
374 image.setDensity((float)image.resourceWidth() / sourceSize); | 374 image.setDensity((float)image.getResourceWidth() / sourceSize); |
375 ignoreSrc = true; | 375 ignoreSrc = true; |
376 } else if (image.density() < 0) { | 376 } else if (image.density() < 0) { |
377 image.setDensity(defaultDensityValue); | 377 image.setDensity(defaultDensityValue); |
378 } | 378 } |
379 } | 379 } |
380 | 380 |
381 std::stable_sort(imageCandidates.begin(), imageCandidates.end(), compareByDe
nsity); | 381 std::stable_sort(imageCandidates.begin(), imageCandidates.end(), compareByDe
nsity); |
382 | 382 |
383 Vector<ImageCandidate*> deDupedImageCandidates; | 383 Vector<ImageCandidate*> deDupedImageCandidates; |
384 float prevDensity = -1.0; | 384 float prevDensity = -1.0; |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
435 Vector<ImageCandidate> imageCandidates; | 435 Vector<ImageCandidate> imageCandidates; |
436 imageCandidates.append(srcsetImageCandidate); | 436 imageCandidates.append(srcsetImageCandidate); |
437 | 437 |
438 if (!srcAttribute.isEmpty()) | 438 if (!srcAttribute.isEmpty()) |
439 imageCandidates.append(ImageCandidate(srcAttribute, 0, srcAttribute.leng
th(), DescriptorParsingResult(), ImageCandidate::SrcOrigin)); | 439 imageCandidates.append(ImageCandidate(srcAttribute, 0, srcAttribute.leng
th(), DescriptorParsingResult(), ImageCandidate::SrcOrigin)); |
440 | 440 |
441 return pickBestImageCandidate(deviceScaleFactor, sourceSize, imageCandidates
).toString(); | 441 return pickBestImageCandidate(deviceScaleFactor, sourceSize, imageCandidates
).toString(); |
442 } | 442 } |
443 | 443 |
444 } // namespace blink | 444 } // namespace blink |
OLD | NEW |