| 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 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 89 | 89 |
| 90 return number; | 90 return number; |
| 91 } | 91 } |
| 92 | 92 |
| 93 FloatPoint WebVTTParser::parseFloatPercentageValuePair(const String& value, char
delimiter, bool& isValidSetting) | 93 FloatPoint WebVTTParser::parseFloatPercentageValuePair(const String& value, char
delimiter, bool& isValidSetting) |
| 94 { | 94 { |
| 95 // The delimiter can't be the first or second value because a pair of | 95 // The delimiter can't be the first or second value because a pair of |
| 96 // percentages (x%,y%) implies that at least the first two characters | 96 // percentages (x%,y%) implies that at least the first two characters |
| 97 // are the first percentage value. | 97 // are the first percentage value. |
| 98 size_t delimiterOffset = value.find(delimiter, 2); | 98 size_t delimiterOffset = value.find(delimiter, 2); |
| 99 if (delimiterOffset == notFound || delimiterOffset == value.length() - 1) { | 99 if (delimiterOffset == kNotFound || delimiterOffset == value.length() - 1) { |
| 100 isValidSetting = false; | 100 isValidSetting = false; |
| 101 return FloatPoint(0, 0); | 101 return FloatPoint(0, 0); |
| 102 } | 102 } |
| 103 | 103 |
| 104 bool isFirstValueValid; | 104 bool isFirstValueValid; |
| 105 float firstCoord = parseFloatPercentageValue(value.substring(0, delimiterOff
set), isFirstValueValid); | 105 float firstCoord = parseFloatPercentageValue(value.substring(0, delimiterOff
set), isFirstValueValid); |
| 106 | 106 |
| 107 bool isSecondValueValid; | 107 bool isSecondValueValid; |
| 108 float secondCoord = parseFloatPercentageValue(value.substring(delimiterOffse
t + 1, value.length() - 1), isSecondValueValid); | 108 float secondCoord = parseFloatPercentageValue(value.substring(delimiterOffse
t + 1, value.length() - 1), isSecondValueValid); |
| 109 | 109 |
| (...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 273 // 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. | 273 // 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 m_currentStartTime = collectTimeStamp(line, &position); | 274 m_currentStartTime = collectTimeStamp(line, &position); |
| 275 if (m_currentStartTime == malformedTime) | 275 if (m_currentStartTime == malformedTime) |
| 276 return BadCue; | 276 return BadCue; |
| 277 if (position >= line.length()) | 277 if (position >= line.length()) |
| 278 return BadCue; | 278 return BadCue; |
| 279 | 279 |
| 280 skipWhiteSpace(line, &position); | 280 skipWhiteSpace(line, &position); |
| 281 | 281 |
| 282 // 6-9 - If the next three characters are not "-->", abort and return failur
e. | 282 // 6-9 - If the next three characters are not "-->", abort and return failur
e. |
| 283 if (line.find("-->", position) == notFound) | 283 if (line.find("-->", position) == kNotFound) |
| 284 return BadCue; | 284 return BadCue; |
| 285 position += 3; | 285 position += 3; |
| 286 if (position >= line.length()) | 286 if (position >= line.length()) |
| 287 return BadCue; | 287 return BadCue; |
| 288 | 288 |
| 289 skipWhiteSpace(line, &position); | 289 skipWhiteSpace(line, &position); |
| 290 | 290 |
| 291 // 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. | 291 // 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 m_currentEndTime = collectTimeStamp(line, &position); | 292 m_currentEndTime = collectTimeStamp(line, &position); |
| 293 if (m_currentEndTime == malformedTime) | 293 if (m_currentEndTime == malformedTime) |
| (...skipping 272 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 566 unsigned oldPosition = *position; | 566 unsigned oldPosition = *position; |
| 567 while (*position < length && data[*position] != '\r' && data[*position] != '
\n') | 567 while (*position < length && data[*position] != '\r' && data[*position] != '
\n') |
| 568 (*position)++; | 568 (*position)++; |
| 569 String line = String::fromUTF8(data + oldPosition, *position - oldPosition); | 569 String line = String::fromUTF8(data + oldPosition, *position - oldPosition); |
| 570 skipLineTerminator(data, length, position); | 570 skipLineTerminator(data, length, position); |
| 571 return line; | 571 return line; |
| 572 } | 572 } |
| 573 | 573 |
| 574 } | 574 } |
| 575 | 575 |
| OLD | NEW |