OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2011 Google Inc. All rights reserved. | 2 * Copyright (C) 2011 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 259 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
270 // 1-3 - Let input be the string being parsed and position be a pointer into
input | 270 // 1-3 - Let input be the string being parsed and position be a pointer into
input |
271 unsigned position = 0; | 271 unsigned position = 0; |
272 skipWhiteSpace(line, &position); | 272 skipWhiteSpace(line, &position); |
273 | 273 |
274 // 4-5 - Collect a WebVTT timestamp. If that fails, then abort and return fa
ilure. Otherwise, let cue's text track cue start time be the collected time. | 274 // 4-5 - Collect a WebVTT timestamp. If that fails, then abort and return fa
ilure. Otherwise, let cue's text track cue start time be the collected time. |
275 m_currentStartTime = collectTimeStamp(line, &position); | 275 m_currentStartTime = collectTimeStamp(line, &position); |
276 if (m_currentStartTime == malformedTime) | 276 if (m_currentStartTime == malformedTime) |
277 return BadCue; | 277 return BadCue; |
278 if (position >= line.length()) | 278 if (position >= line.length()) |
279 return BadCue; | 279 return BadCue; |
280 char nextChar = line[position++]; | 280 |
281 if (nextChar != ' ' && nextChar != '\t') | |
282 return BadCue; | |
283 skipWhiteSpace(line, &position); | 281 skipWhiteSpace(line, &position); |
284 | 282 |
285 // 6-9 - If the next three characters are not "-->", abort and return failur
e. | 283 // 6-9 - If the next three characters are not "-->", abort and return failur
e. |
286 if (line.find("-->", position) == notFound) | 284 if (line.find("-->", position) == notFound) |
287 return BadCue; | 285 return BadCue; |
288 position += 3; | 286 position += 3; |
289 if (position >= line.length()) | 287 if (position >= line.length()) |
290 return BadCue; | 288 return BadCue; |
291 nextChar = line[position++]; | 289 |
292 if (nextChar != ' ' && nextChar != '\t') | |
293 return BadCue; | |
294 skipWhiteSpace(line, &position); | 290 skipWhiteSpace(line, &position); |
295 | 291 |
296 // 10-11 - Collect a WebVTT timestamp. If that fails, then abort and return
failure. Otherwise, let cue's text track cue end time be the collected time. | 292 // 10-11 - Collect a WebVTT timestamp. If that fails, then abort and return
failure. Otherwise, let cue's text track cue end time be the collected time. |
297 m_currentEndTime = collectTimeStamp(line, &position); | 293 m_currentEndTime = collectTimeStamp(line, &position); |
298 if (m_currentEndTime == malformedTime) | 294 if (m_currentEndTime == malformedTime) |
299 return BadCue; | 295 return BadCue; |
300 skipWhiteSpace(line, &position); | 296 skipWhiteSpace(line, &position); |
301 | 297 |
302 // 12 - Parse the WebVTT settings for the cue (conducted in TextTrackCue). | 298 // 12 - Parse the WebVTT settings for the cue (conducted in TextTrackCue). |
303 m_currentSettings = line.substring(position, line.length()-1); | 299 m_currentSettings = line.substring(position, line.length()-1); |
(...skipping 263 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
567 unsigned oldPosition = *position; | 563 unsigned oldPosition = *position; |
568 while (*position < length && data[*position] != '\r' && data[*position] != '
\n') | 564 while (*position < length && data[*position] != '\r' && data[*position] != '
\n') |
569 (*position)++; | 565 (*position)++; |
570 String line = String::fromUTF8(data + oldPosition, *position - oldPosition); | 566 String line = String::fromUTF8(data + oldPosition, *position - oldPosition); |
571 skipLineTerminator(data, length, position); | 567 skipLineTerminator(data, length, position); |
572 return line; | 568 return line; |
573 } | 569 } |
574 | 570 |
575 } | 571 } |
576 | 572 |
OLD | NEW |