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 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
50 if (lastParsedIndex >= endOfCurrentToken) | 50 if (lastParsedIndex >= endOfCurrentToken) |
51 return HTMLDimension(value, HTMLDimension::Relative); | 51 return HTMLDimension(value, HTMLDimension::Relative); |
52 | 52 |
53 size_t position = lastParsedIndex; | 53 size_t position = lastParsedIndex; |
54 while (position < endOfCurrentToken && isASCIIDigit(characters[position])) | 54 while (position < endOfCurrentToken && isASCIIDigit(characters[position])) |
55 ++position; | 55 ++position; |
56 | 56 |
57 if (position > lastParsedIndex) { | 57 if (position > lastParsedIndex) { |
58 bool ok = false; | 58 bool ok = false; |
59 unsigned integerValue = charactersToUIntStrict(characters + lastParsedIn
dex, position - lastParsedIndex, &ok); | 59 unsigned integerValue = charactersToUIntStrict(characters + lastParsedIn
dex, position - lastParsedIndex, &ok); |
60 ASSERT(ok); | 60 if (!ok) |
| 61 return HTMLDimension(0., HTMLDimension::Relative); |
61 value += integerValue; | 62 value += integerValue; |
62 | 63 |
63 if (position < endOfCurrentToken && characters[position] == '.') { | 64 if (position < endOfCurrentToken && characters[position] == '.') { |
64 ++position; | 65 ++position; |
65 Vector<CharacterType> fractionNumbers; | 66 Vector<CharacterType> fractionNumbers; |
66 while (position < endOfCurrentToken && (isASCIIDigit(characters[posi
tion]) || isASCIISpace(characters[position]))) { | 67 while (position < endOfCurrentToken && (isASCIIDigit(characters[posi
tion]) || isASCIISpace(characters[position]))) { |
67 if (isASCIIDigit(characters[position])) | 68 if (isASCIIDigit(characters[position])) |
68 fractionNumbers.append(characters[position]); | 69 fractionNumbers.append(characters[position]); |
69 ++position; | 70 ++position; |
70 } | 71 } |
71 | 72 |
72 if (fractionNumbers.size()) { | 73 if (fractionNumbers.size()) { |
73 double fractionValue = charactersToUIntStrict(fractionNumbers.da
ta(), fractionNumbers.size(), &ok); | 74 double fractionValue = charactersToUIntStrict(fractionNumbers.da
ta(), fractionNumbers.size(), &ok); |
74 ASSERT(ok); | 75 if (!ok) |
| 76 return HTMLDimension(0., HTMLDimension::Relative); |
75 | 77 |
76 value += fractionValue / pow(10., static_cast<double>(fractionNu
mbers.size())); | 78 value += fractionValue / pow(10., static_cast<double>(fractionNu
mbers.size())); |
77 } | 79 } |
78 } | 80 } |
79 } | 81 } |
80 | 82 |
81 while (position < endOfCurrentToken && isASCIISpace(characters[position])) | 83 while (position < endOfCurrentToken && isASCIISpace(characters[position])) |
82 ++position; | 84 ++position; |
83 | 85 |
84 if (position < endOfCurrentToken) { | 86 if (position < endOfCurrentToken) { |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
124 | 126 |
125 parsedDimensions.append(parseDimension(trimmedString, lastParsedIndex, n
extComma)); | 127 parsedDimensions.append(parseDimension(trimmedString, lastParsedIndex, n
extComma)); |
126 lastParsedIndex = nextComma + 1; | 128 lastParsedIndex = nextComma + 1; |
127 } | 129 } |
128 | 130 |
129 parsedDimensions.append(parseDimension(trimmedString, lastParsedIndex, trimm
edString.length())); | 131 parsedDimensions.append(parseDimension(trimmedString, lastParsedIndex, trimm
edString.length())); |
130 return parsedDimensions; | 132 return parsedDimensions; |
131 } | 133 } |
132 | 134 |
133 } // namespace blink | 135 } // namespace blink |
OLD | NEW |