| 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 337 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 348 } | 348 } |
| 349 return i; | 349 return i; |
| 350 } | 350 } |
| 351 | 351 |
| 352 static unsigned avoidDownloadIfHigherDensityResourceIsInCache(Vector<ImageCandid
ate*>& imageCandidates, unsigned winner, Document* document) | 352 static unsigned avoidDownloadIfHigherDensityResourceIsInCache(Vector<ImageCandid
ate*>& imageCandidates, unsigned winner, Document* document) |
| 353 { | 353 { |
| 354 if (!document) | 354 if (!document) |
| 355 return winner; | 355 return winner; |
| 356 for (unsigned i = imageCandidates.size() - 1; i > winner; --i) { | 356 for (unsigned i = imageCandidates.size() - 1; i > winner; --i) { |
| 357 KURL url = document->completeURL(stripLeadingAndTrailingHTMLSpaces(image
Candidates[i]->url())); | 357 KURL url = document->completeURL(stripLeadingAndTrailingHTMLSpaces(image
Candidates[i]->url())); |
| 358 if (memoryCache()->resourceForURL(url, document->fetcher()->getCacheIden
tifier())) | 358 if (memoryCache()->resourceForURL(url, document->fetcher()->getCacheIden
tifier()) || url.protocolIsData()) |
| 359 return i; | 359 return i; |
| 360 } | 360 } |
| 361 return winner; | 361 return winner; |
| 362 } | 362 } |
| 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()) |
| (...skipping 66 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 } | 444 } |
| OLD | NEW |