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

Side by Side Diff: Source/core/html/track/vtt/VTTScanner.cpp

Issue 139343006: Rework float value/percentage scanning for VTTRegion (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 6 years, 11 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, Opera Software ASA. All rights reserved. 2 * Copyright (c) 2013, Opera Software ASA. 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 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 1. Redistributions of source code must retain the above copyright 7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer. 8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright 9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the 10 * notice, this list of conditions and the following disclaimer in the
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
132 // hence that's what got passed to charactersToInt()), the remaining 132 // hence that's what got passed to charactersToInt()), the remaining
133 // failure mode for charactersToInt() is overflow, so if |validNumber| is 133 // failure mode for charactersToInt() is overflow, so if |validNumber| is
134 // not true, then set |number| to the maximum int value. 134 // not true, then set |number| to the maximum int value.
135 if (!validNumber) 135 if (!validNumber)
136 number = std::numeric_limits<int>::max(); 136 number = std::numeric_limits<int>::max();
137 // Consume the digits. 137 // Consume the digits.
138 seekTo(runOfDigits.end()); 138 seekTo(runOfDigits.end());
139 return numDigits; 139 return numDigits;
140 } 140 }
141 141
142 bool VTTScanner::scanFloat(float& number)
143 {
144 Run integerRun = collectWhile<isASCIIDigit>();
145 seekTo(integerRun.end());
146 Run decimalRun(position(), position(), m_is8Bit);
147 if (scan('.')) {
148 decimalRun = collectWhile<isASCIIDigit>();
149 seekTo(decimalRun.end());
150 }
151
152 // At least one digit required.
153 if (integerRun.isEmpty() && decimalRun.isEmpty()) {
154 // Restore to starting position.
155 seekTo(integerRun.start());
156 return false;
Mike West 2014/01/21 07:59:24 Here you return false without setting `number`. At
fs 2014/01/21 08:19:57 Intentional, yes. At this point, we have not manag
157 }
158
159 size_t lengthOfFloat = Run(integerRun.start(), position(), m_is8Bit).length( );
160 bool validNumber;
161 if (m_is8Bit)
162 number = charactersToFloat(integerRun.start(), lengthOfFloat, &validNumb er);
163 else
164 number = charactersToFloat(reinterpret_cast<const UChar*>(integerRun.sta rt()), lengthOfFloat, &validNumber);
165
166 if (!validNumber)
167 number = std::numeric_limits<float>::max();
168 return true;
142 } 169 }
170
171 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698