OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright (C) 2011, 2012 Apple Inc. All rights reserved. | 2 * Copyright (C) 2011, 2012 Apple 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 | 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 13 matching lines...) Expand all Loading... | |
24 */ | 24 */ |
25 | 25 |
26 #include "core/html/MediaFragmentURIParser.h" | 26 #include "core/html/MediaFragmentURIParser.h" |
27 | 27 |
28 #include "wtf/text/CString.h" | 28 #include "wtf/text/CString.h" |
29 #include "wtf/text/StringBuilder.h" | 29 #include "wtf/text/StringBuilder.h" |
30 #include "wtf/text/WTFString.h" | 30 #include "wtf/text/WTFString.h" |
31 | 31 |
32 namespace blink { | 32 namespace blink { |
33 | 33 |
34 const int secondsPerHour = 3600; | |
35 const int secondsPerMinute = 60; | |
36 const unsigned nptIdentiferLength = 4; // "npt:" | 34 const unsigned nptIdentiferLength = 4; // "npt:" |
37 | 35 |
38 static String collectDigits(const LChar* input, | 36 static String collectDigits(const LChar* input, |
39 unsigned length, | 37 unsigned length, |
40 unsigned& position) { | 38 unsigned& position) { |
41 StringBuilder digits; | 39 StringBuilder digits; |
42 | 40 |
43 // http://www.ietf.org/rfc/rfc2326.txt | 41 // http://www.ietf.org/rfc/rfc2326.txt |
44 // DIGIT ; any positive number | 42 // DIGIT ; any positive number |
45 while (position < length && isASCIIDigit(input[position])) | 43 while (position < length && isASCIIDigit(input[position])) |
(...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
251 // specification of NPT RFC 2326. | 249 // specification of NPT RFC 2326. |
252 // | 250 // |
253 // ; defined in RFC 2326 | 251 // ; defined in RFC 2326 |
254 // npt-sec = 1*DIGIT [ "." *DIGIT ] | 252 // npt-sec = 1*DIGIT [ "." *DIGIT ] |
255 // npt-hhmmss = npt-hh ":" npt-mm ":" npt-ss [ "." *DIGIT] | 253 // npt-hhmmss = npt-hh ":" npt-mm ":" npt-ss [ "." *DIGIT] |
256 // npt-mmss = npt-mm ":" npt-ss [ "." *DIGIT] | 254 // npt-mmss = npt-mm ":" npt-ss [ "." *DIGIT] |
257 // npt-hh = 1*DIGIT ; any positive number | 255 // npt-hh = 1*DIGIT ; any positive number |
258 // npt-mm = 2DIGIT ; 0-59 | 256 // npt-mm = 2DIGIT ; 0-59 |
259 // npt-ss = 2DIGIT ; 0-59 | 257 // npt-ss = 2DIGIT ; 0-59 |
260 | 258 |
259 const int secondsPerHour = 3600; | |
260 const int secondsPerMinute = 60; | |
fs
2017/03/02 15:52:15
Maybe just fold these into their (single) use inst
| |
261 String digits1 = collectDigits(timeString, length, offset); | 261 String digits1 = collectDigits(timeString, length, offset); |
262 int value1 = digits1.toInt(); | 262 int value1 = digits1.toInt(); |
263 if (offset >= length || timeString[offset] == ',') { | 263 if (offset >= length || timeString[offset] == ',') { |
264 time = value1; | 264 time = value1; |
265 return true; | 265 return true; |
266 } | 266 } |
267 | 267 |
268 double fraction = 0; | 268 double fraction = 0; |
269 if (timeString[offset] == '.') { | 269 if (timeString[offset] == '.') { |
270 if (offset == length) | 270 if (offset == length) |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
309 | 309 |
310 if (offset < length && timeString[offset] == '.') | 310 if (offset < length && timeString[offset] == '.') |
311 fraction = collectFraction(timeString, length, offset).toDouble(); | 311 fraction = collectFraction(timeString, length, offset).toDouble(); |
312 | 312 |
313 time = (value1 * secondsPerHour) + (value2 * secondsPerMinute) + value3 + | 313 time = (value1 * secondsPerHour) + (value2 * secondsPerMinute) + value3 + |
314 fraction; | 314 fraction; |
315 return true; | 315 return true; |
316 } | 316 } |
317 | 317 |
318 } // namespace blink | 318 } // namespace blink |
OLD | NEW |