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 16 matching lines...) Expand all Loading... |
27 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 27 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
28 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 28 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
29 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 29 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
30 */ | 30 */ |
31 | 31 |
32 #include "config.h" | 32 #include "config.h" |
33 #include "core/html/parser/HTMLSrcsetParser.h" | 33 #include "core/html/parser/HTMLSrcsetParser.h" |
34 | 34 |
35 #include "core/dom/Document.h" | 35 #include "core/dom/Document.h" |
36 #include "core/fetch/MemoryCache.h" | 36 #include "core/fetch/MemoryCache.h" |
| 37 #include "core/fetch/ResourceFetcher.h" |
37 #include "core/frame/FrameConsole.h" | 38 #include "core/frame/FrameConsole.h" |
38 #include "core/frame/LocalFrame.h" | 39 #include "core/frame/LocalFrame.h" |
39 #include "core/frame/UseCounter.h" | 40 #include "core/frame/UseCounter.h" |
40 #include "core/html/parser/HTMLParserIdioms.h" | 41 #include "core/html/parser/HTMLParserIdioms.h" |
41 #include "core/inspector/ConsoleMessage.h" | 42 #include "core/inspector/ConsoleMessage.h" |
42 #include "platform/ParsingUtilities.h" | 43 #include "platform/ParsingUtilities.h" |
43 #include "platform/RuntimeEnabledFeatures.h" | 44 #include "platform/RuntimeEnabledFeatures.h" |
44 | 45 |
45 namespace blink { | 46 namespace blink { |
46 | 47 |
(...skipping 307 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
354 } | 355 } |
355 return i; | 356 return i; |
356 } | 357 } |
357 | 358 |
358 static unsigned avoidDownloadIfHigherDensityResourceIsInCache(Vector<ImageCandid
ate>& imageCandidates, unsigned winner, Document* document) | 359 static unsigned avoidDownloadIfHigherDensityResourceIsInCache(Vector<ImageCandid
ate>& imageCandidates, unsigned winner, Document* document) |
359 { | 360 { |
360 if (!document) | 361 if (!document) |
361 return winner; | 362 return winner; |
362 for (unsigned i = imageCandidates.size() - 1; i > winner; --i) { | 363 for (unsigned i = imageCandidates.size() - 1; i > winner; --i) { |
363 KURL url = document->completeURL(stripLeadingAndTrailingHTMLSpaces(image
Candidates[i].url())); | 364 KURL url = document->completeURL(stripLeadingAndTrailingHTMLSpaces(image
Candidates[i].url())); |
364 if (memoryCache()->resourceForURL(url)) | 365 if (memoryCache()->resourceForURL(url, document->fetcher()->getCacheIden
tifier())) |
365 return i; | 366 return i; |
366 } | 367 } |
367 return winner; | 368 return winner; |
368 } | 369 } |
369 | 370 |
370 static ImageCandidate pickBestImageCandidate(float deviceScaleFactor, float sour
ceSize, Vector<ImageCandidate>& imageCandidates, Document* document = nullptr) | 371 static ImageCandidate pickBestImageCandidate(float deviceScaleFactor, float sour
ceSize, Vector<ImageCandidate>& imageCandidates, Document* document = nullptr) |
371 { | 372 { |
372 const float defaultDensityValue = 1.0; | 373 const float defaultDensityValue = 1.0; |
373 bool ignoreSrc = false; | 374 bool ignoreSrc = false; |
374 if (imageCandidates.isEmpty()) | 375 if (imageCandidates.isEmpty()) |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
434 Vector<ImageCandidate> imageCandidates; | 435 Vector<ImageCandidate> imageCandidates; |
435 imageCandidates.append(srcsetImageCandidate); | 436 imageCandidates.append(srcsetImageCandidate); |
436 | 437 |
437 if (!srcAttribute.isEmpty()) | 438 if (!srcAttribute.isEmpty()) |
438 imageCandidates.append(ImageCandidate(srcAttribute, 0, srcAttribute.leng
th(), DescriptorParsingResult(), ImageCandidate::SrcOrigin)); | 439 imageCandidates.append(ImageCandidate(srcAttribute, 0, srcAttribute.leng
th(), DescriptorParsingResult(), ImageCandidate::SrcOrigin)); |
439 | 440 |
440 return pickBestImageCandidate(deviceScaleFactor, sourceSize, imageCandidates
).toString(); | 441 return pickBestImageCandidate(deviceScaleFactor, sourceSize, imageCandidates
).toString(); |
441 } | 442 } |
442 | 443 |
443 } | 444 } |
OLD | NEW |