Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1009)

Unified Diff: Source/core/html/parser/HTMLSrcsetParser.cpp

Issue 839783002: Ignore src candidates when looking for already in-cache resources (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 5 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « LayoutTests/fast/dom/HTMLImageElement/image-src-added-srcset-w-descriptors-expected.txt ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/html/parser/HTMLSrcsetParser.cpp
diff --git a/Source/core/html/parser/HTMLSrcsetParser.cpp b/Source/core/html/parser/HTMLSrcsetParser.cpp
index 05b6ee6ce0a346acac0e30601b10c89f3ba79a6c..1069af3f21dd390c58173719ecc472f9c88541e4 100644
--- a/Source/core/html/parser/HTMLSrcsetParser.cpp
+++ b/Source/core/html/parser/HTMLSrcsetParser.cpp
@@ -356,11 +356,13 @@ static int selectionLogic(Vector<ImageCandidate>& imageCandidates, float deviceS
return i;
}
-static unsigned avoidDownloadIfHigherDensityResourceIsInCache(Vector<ImageCandidate>& imageCandidates, unsigned winner, Document* document)
+static unsigned avoidDownloadIfHigherDensityResourceIsInCache(Vector<ImageCandidate>& imageCandidates, unsigned winner, Document* document, bool ignoreSrc)
{
if (!document)
return winner;
for (unsigned i = imageCandidates.size() - 1; i > winner; --i) {
+ if (ignoreSrc && imageCandidates[i].srcOrigin())
+ continue;
KURL url = document->completeURL(stripLeadingAndTrailingHTMLSpaces(imageCandidates[i].url()));
if (memoryCache()->resourceForURL(url, document->fetcher()->getCacheIdentifier()))
return i;
@@ -389,7 +391,7 @@ static ImageCandidate pickBestImageCandidate(float deviceScaleFactor, float sour
unsigned winner = selectionLogic(imageCandidates, deviceScaleFactor, ignoreSrc);
ASSERT(winner < imageCandidates.size());
- winner = avoidDownloadIfHigherDensityResourceIsInCache(imageCandidates, winner, document);
+ winner = avoidDownloadIfHigherDensityResourceIsInCache(imageCandidates, winner, document, ignoreSrc);
float winningDensity = imageCandidates[winner].density();
// 16. If an entry b in candidates has the same associated ... pixel density as an earlier entry a in candidates,
« no previous file with comments | « LayoutTests/fast/dom/HTMLImageElement/image-src-added-srcset-w-descriptors-expected.txt ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698