| OLD | NEW |
| 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 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 68 return HTMLDimension(0., HTMLDimension::Relative); | 68 return HTMLDimension(0., HTMLDimension::Relative); |
| 69 value += integerValue; | 69 value += integerValue; |
| 70 | 70 |
| 71 if (position < endOfCurrentToken && characters[position] == '.') { | 71 if (position < endOfCurrentToken && characters[position] == '.') { |
| 72 ++position; | 72 ++position; |
| 73 Vector<CharacterType> fractionNumbers; | 73 Vector<CharacterType> fractionNumbers; |
| 74 while (position < endOfCurrentToken && | 74 while (position < endOfCurrentToken && |
| 75 (isASCIIDigit(characters[position]) || | 75 (isASCIIDigit(characters[position]) || |
| 76 isASCIISpace(characters[position]))) { | 76 isASCIISpace(characters[position]))) { |
| 77 if (isASCIIDigit(characters[position])) | 77 if (isASCIIDigit(characters[position])) |
| 78 fractionNumbers.append(characters[position]); | 78 fractionNumbers.push_back(characters[position]); |
| 79 ++position; | 79 ++position; |
| 80 } | 80 } |
| 81 | 81 |
| 82 if (fractionNumbers.size()) { | 82 if (fractionNumbers.size()) { |
| 83 double fractionValue = charactersToUIntStrict( | 83 double fractionValue = charactersToUIntStrict( |
| 84 fractionNumbers.data(), fractionNumbers.size(), &ok); | 84 fractionNumbers.data(), fractionNumbers.size(), &ok); |
| 85 if (!ok) | 85 if (!ok) |
| 86 return HTMLDimension(0., HTMLDimension::Relative); | 86 return HTMLDimension(0., HTMLDimension::Relative); |
| 87 | 87 |
| 88 value += fractionValue / | 88 value += fractionValue / |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 131 | 131 |
| 132 // Step 3. To avoid String copies, we just look for commas instead of | 132 // Step 3. To avoid String copies, we just look for commas instead of |
| 133 // splitting. | 133 // splitting. |
| 134 Vector<HTMLDimension> parsedDimensions; | 134 Vector<HTMLDimension> parsedDimensions; |
| 135 size_t lastParsedIndex = 0; | 135 size_t lastParsedIndex = 0; |
| 136 while (true) { | 136 while (true) { |
| 137 size_t nextComma = trimmedString.find(comma, lastParsedIndex); | 137 size_t nextComma = trimmedString.find(comma, lastParsedIndex); |
| 138 if (nextComma == kNotFound) | 138 if (nextComma == kNotFound) |
| 139 break; | 139 break; |
| 140 | 140 |
| 141 parsedDimensions.append( | 141 parsedDimensions.push_back( |
| 142 parseDimension(trimmedString, lastParsedIndex, nextComma)); | 142 parseDimension(trimmedString, lastParsedIndex, nextComma)); |
| 143 lastParsedIndex = nextComma + 1; | 143 lastParsedIndex = nextComma + 1; |
| 144 } | 144 } |
| 145 | 145 |
| 146 parsedDimensions.append( | 146 parsedDimensions.push_back( |
| 147 parseDimension(trimmedString, lastParsedIndex, trimmedString.length())); | 147 parseDimension(trimmedString, lastParsedIndex, trimmedString.length())); |
| 148 return parsedDimensions; | 148 return parsedDimensions; |
| 149 } | 149 } |
| 150 | 150 |
| 151 template <typename CharacterType> | 151 template <typename CharacterType> |
| 152 static bool parseDimensionValue(const CharacterType* current, | 152 static bool parseDimensionValue(const CharacterType* current, |
| 153 const CharacterType* end, | 153 const CharacterType* end, |
| 154 HTMLDimension& dimension) { | 154 HTMLDimension& dimension) { |
| 155 skipWhile<CharacterType, isHTMLSpace>(current, end); | 155 skipWhile<CharacterType, isHTMLSpace>(current, end); |
| 156 // Deviation: HTML allows '+' here. | 156 // Deviation: HTML allows '+' here. |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 191 return false; | 191 return false; |
| 192 if (input.is8Bit()) { | 192 if (input.is8Bit()) { |
| 193 return parseDimensionValue(input.characters8(), | 193 return parseDimensionValue(input.characters8(), |
| 194 input.characters8() + input.length(), dimension); | 194 input.characters8() + input.length(), dimension); |
| 195 } | 195 } |
| 196 return parseDimensionValue(input.characters16(), | 196 return parseDimensionValue(input.characters16(), |
| 197 input.characters16() + input.length(), dimension); | 197 input.characters16() + input.length(), dimension); |
| 198 } | 198 } |
| 199 | 199 |
| 200 } // namespace blink | 200 } // namespace blink |
| OLD | NEW |