| 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 333 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 344 } | 344 } |
| 345 return i; | 345 return i; |
| 346 } | 346 } |
| 347 | 347 |
| 348 static unsigned avoidDownloadIfHigherDensityResourceIsInCache(Vector<ImageCandid
ate*>& imageCandidates, unsigned winner, Document* document) | 348 static unsigned avoidDownloadIfHigherDensityResourceIsInCache(Vector<ImageCandid
ate*>& imageCandidates, unsigned winner, Document* document) |
| 349 { | 349 { |
| 350 if (!document) | 350 if (!document) |
| 351 return winner; | 351 return winner; |
| 352 for (unsigned i = imageCandidates.size() - 1; i > winner; --i) { | 352 for (unsigned i = imageCandidates.size() - 1; i > winner; --i) { |
| 353 KURL url = document->completeURL(stripLeadingAndTrailingHTMLSpaces(image
Candidates[i]->url())); | 353 KURL url = document->completeURL(stripLeadingAndTrailingHTMLSpaces(image
Candidates[i]->url())); |
| 354 if (memoryCache()->resourceForURL(url, document->fetcher()->getCacheIden
tifier())) | 354 if (memoryCache()->resourceForURL(url, document->fetcher()->getCacheIden
tifier()) || url.protocolIsData()) |
| 355 return i; | 355 return i; |
| 356 } | 356 } |
| 357 return winner; | 357 return winner; |
| 358 } | 358 } |
| 359 | 359 |
| 360 static ImageCandidate pickBestImageCandidate(float deviceScaleFactor, float sour
ceSize, Vector<ImageCandidate>& imageCandidates, Document* document = nullptr) | 360 static ImageCandidate pickBestImageCandidate(float deviceScaleFactor, float sour
ceSize, Vector<ImageCandidate>& imageCandidates, Document* document = nullptr) |
| 361 { | 361 { |
| 362 const float defaultDensityValue = 1.0; | 362 const float defaultDensityValue = 1.0; |
| 363 bool ignoreSrc = false; | 363 bool ignoreSrc = false; |
| 364 if (imageCandidates.isEmpty()) | 364 if (imageCandidates.isEmpty()) |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 431 Vector<ImageCandidate> imageCandidates; | 431 Vector<ImageCandidate> imageCandidates; |
| 432 imageCandidates.append(srcsetImageCandidate); | 432 imageCandidates.append(srcsetImageCandidate); |
| 433 | 433 |
| 434 if (!srcAttribute.isEmpty()) | 434 if (!srcAttribute.isEmpty()) |
| 435 imageCandidates.append(ImageCandidate(srcAttribute, 0, srcAttribute.leng
th(), DescriptorParsingResult(), ImageCandidate::SrcOrigin)); | 435 imageCandidates.append(ImageCandidate(srcAttribute, 0, srcAttribute.leng
th(), DescriptorParsingResult(), ImageCandidate::SrcOrigin)); |
| 436 | 436 |
| 437 return pickBestImageCandidate(deviceScaleFactor, sourceSize, imageCandidates
).toString(); | 437 return pickBestImageCandidate(deviceScaleFactor, sourceSize, imageCandidates
).toString(); |
| 438 } | 438 } |
| 439 | 439 |
| 440 } | 440 } |
| OLD | NEW |