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

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

Issue 656723005: Use C++11 features in core/html (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: mike's comments Created 6 years, 1 month 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/HTMLResourcePreloader.h ('k') | Source/core/html/parser/HTMLTreeBuilder.cpp » ('j') | 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 b6381e38610a4ef044dcc529bcef4925ca43391a..05b6ee6ce0a346acac0e30601b10c89f3ba79a6c 100644
--- a/Source/core/html/parser/HTMLSrcsetParser.cpp
+++ b/Source/core/html/parser/HTMLSrcsetParser.cpp
@@ -196,17 +196,17 @@ static void srcsetError(Document* document, String message)
template<typename CharType>
static bool parseDescriptors(const CharType* attribute, Vector<DescriptorToken>& descriptors, DescriptorParsingResult& result, Document* document)
{
- for (Vector<DescriptorToken>::iterator it = descriptors.begin(); it != descriptors.end(); ++it) {
- if (it->length == 0)
+ for (DescriptorToken& descriptor : descriptors) {
+ if (descriptor.length == 0)
continue;
- CharType c = attribute[it->lastIndex()];
+ CharType c = attribute[descriptor.lastIndex()];
bool isValid = false;
if (RuntimeEnabledFeatures::pictureSizesEnabled() && c == 'w') {
if (result.hasDensity() || result.hasWidth()) {
srcsetError(document, "it has multiple 'w' descriptors or a mix of 'x' and 'w' descriptors.");
return false;
}
- int resourceWidth = it->toInt(attribute, isValid);
+ int resourceWidth = descriptor.toInt(attribute, isValid);
if (!isValid || resourceWidth <= 0) {
srcsetError(document, "its 'w' descriptor is invalid.");
return false;
@@ -219,7 +219,7 @@ static bool parseDescriptors(const CharType* attribute, Vector<DescriptorToken>&
srcsetError(document, "it has multiple 'h' descriptors or a mix of 'x' and 'h' descriptors.");
return false;
}
- int resourceHeight = it->toInt(attribute, isValid);
+ int resourceHeight = descriptor.toInt(attribute, isValid);
if (!isValid || resourceHeight <= 0) {
srcsetError(document, "its 'h' descriptor is invalid.");
return false;
@@ -230,7 +230,7 @@ static bool parseDescriptors(const CharType* attribute, Vector<DescriptorToken>&
srcsetError(document, "it has multiple 'x' descriptors or a mix of 'x' and 'w'/'h' descriptors.");
return false;
}
- float density = it->toFloat(attribute, isValid);
+ float density = descriptor.toFloat(attribute, isValid);
if (!isValid || density < 0) {
srcsetError(document, "its 'x' descriptor is invalid.");
return false;
@@ -265,7 +265,7 @@ static void parseImageCandidatesFromSrcsetAttribute(const String& attribute, con
while (position < attributeEnd) {
// 4. Splitting loop: Collect a sequence of characters that are space characters or U+002C COMMA characters.
- skipWhile<CharType, isHTMLSpaceOrComma<CharType> >(position, attributeEnd);
+ skipWhile<CharType, isHTMLSpaceOrComma<CharType>>(position, attributeEnd);
if (position == attributeEnd) {
// Contrary to spec language - descriptor parsing happens on each candidate, so when we reach the attributeEnd, we can exit.
break;
@@ -273,7 +273,7 @@ static void parseImageCandidatesFromSrcsetAttribute(const String& attribute, con
const CharType* imageURLStart = position;
// 6. Collect a sequence of characters that are not space characters, and let that be url.
- skipUntil<CharType, isHTMLSpace<CharType> >(position, attributeEnd);
+ skipUntil<CharType, isHTMLSpace<CharType>>(position, attributeEnd);
const CharType* imageURLEnd = position;
DescriptorParsingResult result;
@@ -376,12 +376,12 @@ static ImageCandidate pickBestImageCandidate(float deviceScaleFactor, float sour
return ImageCandidate();
// http://picture.responsiveimages.org/#normalize-source-densities
- for (Vector<ImageCandidate>::iterator it = imageCandidates.begin(); it != imageCandidates.end(); ++it) {
- if (it->resourceWidth() > 0) {
- it->setDensity((float)it->resourceWidth() / sourceSize);
+ for (ImageCandidate& image : imageCandidates) {
+ if (image.resourceWidth() > 0) {
+ image.setDensity((float)image.resourceWidth() / sourceSize);
ignoreSrc = true;
- } else if (it->density() < 0) {
- it->setDensity(defaultDensityValue);
+ } else if (image.density() < 0) {
+ image.setDensity(defaultDensityValue);
}
}
« no previous file with comments | « Source/core/html/parser/HTMLResourcePreloader.h ('k') | Source/core/html/parser/HTMLTreeBuilder.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698