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 27 matching lines...) Expand all Loading... |
38 #include "core/html/track/vtt/VTTScanner.h" | 38 #include "core/html/track/vtt/VTTScanner.h" |
39 #include "platform/RuntimeEnabledFeatures.h" | 39 #include "platform/RuntimeEnabledFeatures.h" |
40 #include "platform/text/SegmentedString.h" | 40 #include "platform/text/SegmentedString.h" |
41 #include "wtf/text/CharacterNames.h" | 41 #include "wtf/text/CharacterNames.h" |
42 #include "wtf/text/WTFString.h" | 42 #include "wtf/text/WTFString.h" |
43 | 43 |
44 namespace blink { | 44 namespace blink { |
45 | 45 |
46 using namespace HTMLNames; | 46 using namespace HTMLNames; |
47 | 47 |
48 const double secondsPerHour = 3600; | |
49 const double secondsPerMinute = 60; | |
50 const double secondsPerMillisecond = 0.001; | |
51 const unsigned fileIdentifierLength = 6; | 48 const unsigned fileIdentifierLength = 6; |
52 | 49 |
53 bool VTTParser::parseFloatPercentageValue(VTTScanner& valueScanner, | 50 bool VTTParser::parseFloatPercentageValue(VTTScanner& valueScanner, |
54 float& percentage) { | 51 float& percentage) { |
55 float number; | 52 float number; |
56 if (!valueScanner.scanFloat(number)) | 53 if (!valueScanner.scanFloat(number)) |
57 return false; | 54 return false; |
58 // '%' must be present and at the end of the setting value. | 55 // '%' must be present and at the end of the setting value. |
59 if (!valueScanner.scan('%')) | 56 if (!valueScanner.scan('%')) |
60 return false; | 57 return false; |
(...skipping 374 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
435 } | 432 } |
436 | 433 |
437 // Steps 13 - 17 - Collect next sequence of 0-9 after '.' (must be 3 chars). | 434 // Steps 13 - 17 - Collect next sequence of 0-9 after '.' (must be 3 chars). |
438 int value4; | 435 int value4; |
439 if (!input.scan('.') || input.scanDigits(value4) != 3) | 436 if (!input.scan('.') || input.scanDigits(value4) != 3) |
440 return false; | 437 return false; |
441 if (value2 > 59 || value3 > 59) | 438 if (value2 > 59 || value3 > 59) |
442 return false; | 439 return false; |
443 | 440 |
444 // Steps 18 - 19 - Calculate result. | 441 // Steps 18 - 19 - Calculate result. |
| 442 const double secondsPerHour = 3600; |
| 443 const double secondsPerMinute = 60; |
| 444 const double secondsPerMillisecond = 0.001; |
445 timeStamp = (value1 * secondsPerHour) + (value2 * secondsPerMinute) + value3 + | 445 timeStamp = (value1 * secondsPerHour) + (value2 * secondsPerMinute) + value3 + |
446 (value4 * secondsPerMillisecond); | 446 (value4 * secondsPerMillisecond); |
447 return true; | 447 return true; |
448 } | 448 } |
449 | 449 |
450 static VTTNodeType tokenToNodeType(VTTToken& token) { | 450 static VTTNodeType tokenToNodeType(VTTToken& token) { |
451 switch (token.name().length()) { | 451 switch (token.name().length()) { |
452 case 1: | 452 case 1: |
453 if (token.name()[0] == 'c') | 453 if (token.name()[0] == 'c') |
454 return VTTNodeTypeClass; | 454 return VTTNodeTypeClass; |
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
559 } | 559 } |
560 | 560 |
561 DEFINE_TRACE(VTTParser) { | 561 DEFINE_TRACE(VTTParser) { |
562 visitor->trace(m_document); | 562 visitor->trace(m_document); |
563 visitor->trace(m_client); | 563 visitor->trace(m_client); |
564 visitor->trace(m_cueList); | 564 visitor->trace(m_cueList); |
565 visitor->trace(m_regionMap); | 565 visitor->trace(m_regionMap); |
566 } | 566 } |
567 | 567 |
568 } // namespace blink | 568 } // namespace blink |
OLD | NEW |