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