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

Side by Side Diff: third_party/WebKit/Source/core/html/HTMLDimension.cpp

Issue 2384273007: reflow comments in core/html/*.{cpp,h},core/html/imports (Closed)
Patch Set: comments Created 4 years, 2 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 unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2013 Google Inc. All rights reserved. 2 * Copyright (C) 2013 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 25 matching lines...) Expand all
36 36
37 namespace blink { 37 namespace blink {
38 38
39 template <typename CharacterType> 39 template <typename CharacterType>
40 static HTMLDimension parseDimension(const CharacterType* characters, 40 static HTMLDimension parseDimension(const CharacterType* characters,
41 size_t lastParsedIndex, 41 size_t lastParsedIndex,
42 size_t endOfCurrentToken) { 42 size_t endOfCurrentToken) {
43 HTMLDimension::HTMLDimensionType type = HTMLDimension::Absolute; 43 HTMLDimension::HTMLDimensionType type = HTMLDimension::Absolute;
44 double value = 0.; 44 double value = 0.;
45 45
46 // HTML5's split removes leading and trailing spaces so we need to skip the le ading spaces here. 46 // HTML5's split removes leading and trailing spaces so we need to skip the
47 // leading spaces here.
47 while (lastParsedIndex < endOfCurrentToken && 48 while (lastParsedIndex < endOfCurrentToken &&
48 isASCIISpace((characters[lastParsedIndex]))) 49 isASCIISpace((characters[lastParsedIndex])))
49 ++lastParsedIndex; 50 ++lastParsedIndex;
50 51
51 // This is Step 5.5. in the algorithm. Going to the last step would make the c ode less readable. 52 // This is Step 5.5. in the algorithm. Going to the last step would make the
53 // code less readable.
52 if (lastParsedIndex >= endOfCurrentToken) 54 if (lastParsedIndex >= endOfCurrentToken)
53 return HTMLDimension(value, HTMLDimension::Relative); 55 return HTMLDimension(value, HTMLDimension::Relative);
54 56
55 size_t position = lastParsedIndex; 57 size_t position = lastParsedIndex;
56 while (position < endOfCurrentToken && isASCIIDigit(characters[position])) 58 while (position < endOfCurrentToken && isASCIIDigit(characters[position]))
57 ++position; 59 ++position;
58 60
59 if (position > lastParsedIndex) { 61 if (position > lastParsedIndex) {
60 bool ok = false; 62 bool ok = false;
61 unsigned integerValue = charactersToUIntStrict( 63 unsigned integerValue = charactersToUIntStrict(
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
118 // Step 2. Remove the last character if it's a comma. 120 // Step 2. Remove the last character if it's a comma.
119 String trimmedString = input; 121 String trimmedString = input;
120 if (trimmedString.endsWith(comma)) 122 if (trimmedString.endsWith(comma))
121 trimmedString.truncate(trimmedString.length() - 1); 123 trimmedString.truncate(trimmedString.length() - 1);
122 124
123 // HTML5's split doesn't return a token for an empty string so 125 // HTML5's split doesn't return a token for an empty string so
124 // we need to match them here. 126 // we need to match them here.
125 if (trimmedString.isEmpty()) 127 if (trimmedString.isEmpty())
126 return Vector<HTMLDimension>(); 128 return Vector<HTMLDimension>();
127 129
128 // Step 3. To avoid String copies, we just look for commas instead of splittin g. 130 // Step 3. To avoid String copies, we just look for commas instead of
131 // splitting.
129 Vector<HTMLDimension> parsedDimensions; 132 Vector<HTMLDimension> parsedDimensions;
130 size_t lastParsedIndex = 0; 133 size_t lastParsedIndex = 0;
131 while (true) { 134 while (true) {
132 size_t nextComma = trimmedString.find(comma, lastParsedIndex); 135 size_t nextComma = trimmedString.find(comma, lastParsedIndex);
133 if (nextComma == kNotFound) 136 if (nextComma == kNotFound)
134 break; 137 break;
135 138
136 parsedDimensions.append( 139 parsedDimensions.append(
137 parseDimension(trimmedString, lastParsedIndex, nextComma)); 140 parseDimension(trimmedString, lastParsedIndex, nextComma));
138 lastParsedIndex = nextComma + 1; 141 lastParsedIndex = nextComma + 1;
139 } 142 }
140 143
141 parsedDimensions.append( 144 parsedDimensions.append(
142 parseDimension(trimmedString, lastParsedIndex, trimmedString.length())); 145 parseDimension(trimmedString, lastParsedIndex, trimmedString.length()));
143 return parsedDimensions; 146 return parsedDimensions;
144 } 147 }
145 148
146 } // namespace blink 149 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/html/HTMLDialogElement.cpp ('k') | third_party/WebKit/Source/core/html/HTMLDocument.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698