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

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

Issue 236713005: Use SizesAttributeParser to get the right srcset resource (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@sizes_parser8
Patch Set: Fixed nits Created 6 years, 8 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 | « Source/core/html/parser/HTMLSrcsetParser.h ('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 1fffc5d561e1b182427536901fa24113b009f0df..eec44809b23097c7faf8eb94c62c4a2969a58f2b 100644
--- a/Source/core/html/parser/HTMLSrcsetParser.cpp
+++ b/Source/core/html/parser/HTMLSrcsetParser.cpp
@@ -142,7 +142,7 @@ static void parseImageCandidatesFromSrcsetAttribute(const String& attribute, Vec
parseImageCandidatesFromSrcsetAttribute<UChar>(attribute, attribute.characters16(), attribute.length(), imageCandidates);
}
-static ImageCandidate pickBestImageCandidate(float deviceScaleFactor, int effectiveSize, Vector<ImageCandidate>& imageCandidates)
+static ImageCandidate pickBestImageCandidate(float deviceScaleFactor, unsigned sourceSize, Vector<ImageCandidate>& imageCandidates)
{
bool ignoreSrc = false;
if (imageCandidates.isEmpty())
@@ -151,7 +151,7 @@ static ImageCandidate pickBestImageCandidate(float deviceScaleFactor, int effect
// http://picture.responsiveimages.org/#normalize-source-densities
for (Vector<ImageCandidate>::iterator it = imageCandidates.begin(); it != imageCandidates.end(); ++it) {
if (it->resourceWidth() > 0) {
- it->setScaleFactor((float)it->resourceWidth() / (float)effectiveSize);
+ it->setScaleFactor((float)it->resourceWidth() / (float)sourceSize);
ignoreSrc = true;
}
}
@@ -174,16 +174,16 @@ static ImageCandidate pickBestImageCandidate(float deviceScaleFactor, int effect
return imageCandidates[winner];
}
-ImageCandidate bestFitSourceForSrcsetAttribute(float deviceScaleFactor, int effectiveSize, const String& srcsetAttribute)
+ImageCandidate bestFitSourceForSrcsetAttribute(float deviceScaleFactor, unsigned sourceSize, const String& srcsetAttribute)
{
Vector<ImageCandidate> imageCandidates;
parseImageCandidatesFromSrcsetAttribute(srcsetAttribute, imageCandidates);
- return pickBestImageCandidate(deviceScaleFactor, effectiveSize, imageCandidates);
+ return pickBestImageCandidate(deviceScaleFactor, sourceSize, imageCandidates);
}
-ImageCandidate bestFitSourceForImageAttributes(float deviceScaleFactor, int effectiveSize, const String& srcAttribute, const String& srcsetAttribute)
+ImageCandidate bestFitSourceForImageAttributes(float deviceScaleFactor, unsigned sourceSize, const String& srcAttribute, const String& srcsetAttribute)
{
DescriptorParsingResult defaultResult;
defaultResult.scaleFactor = 1.0;
@@ -201,10 +201,10 @@ ImageCandidate bestFitSourceForImageAttributes(float deviceScaleFactor, int effe
if (!srcAttribute.isEmpty())
imageCandidates.append(ImageCandidate(srcAttribute, 0, srcAttribute.length(), defaultResult, ImageCandidate::SrcOrigin));
- return pickBestImageCandidate(deviceScaleFactor, effectiveSize, imageCandidates);
+ return pickBestImageCandidate(deviceScaleFactor, sourceSize, imageCandidates);
}
-String bestFitSourceForImageAttributes(float deviceScaleFactor, int effectiveSize, const String& srcAttribute, ImageCandidate& srcsetImageCandidate)
+String bestFitSourceForImageAttributes(float deviceScaleFactor, unsigned sourceSize, const String& srcAttribute, ImageCandidate& srcsetImageCandidate)
{
DescriptorParsingResult defaultResult;
defaultResult.scaleFactor = 1.0;
@@ -218,7 +218,7 @@ String bestFitSourceForImageAttributes(float deviceScaleFactor, int effectiveSiz
if (!srcAttribute.isEmpty())
imageCandidates.append(ImageCandidate(srcAttribute, 0, srcAttribute.length(), defaultResult, ImageCandidate::SrcOrigin));
- return pickBestImageCandidate(deviceScaleFactor, effectiveSize, imageCandidates).toString();
+ return pickBestImageCandidate(deviceScaleFactor, sourceSize, imageCandidates).toString();
}
}
« no previous file with comments | « Source/core/html/parser/HTMLSrcsetParser.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698