OLD | NEW |
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 949 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
960 | 960 |
961 m_linePosition = number; | 961 m_linePosition = number; |
962 } | 962 } |
963 break; | 963 break; |
964 case Position: | 964 case Position: |
965 { | 965 { |
966 // 1. If value contains any characters other than U+0025 PERCENT SIG
N characters (%) and characters in the range | 966 // 1. If value contains any characters other than U+0025 PERCENT SIG
N characters (%) and characters in the range |
967 // U+0030 DIGIT ZERO (0) to U+0039 DIGIT NINE (9), then jump to t
he step labeled next setting. | 967 // U+0030 DIGIT ZERO (0) to U+0039 DIGIT NINE (9), then jump to t
he step labeled next setting. |
968 // 2. If value does not contain at least one character in the range
U+0030 DIGIT ZERO (0) to U+0039 DIGIT NINE (9), | 968 // 2. If value does not contain at least one character in the range
U+0030 DIGIT ZERO (0) to U+0039 DIGIT NINE (9), |
969 // then jump to the step labeled next setting. | 969 // then jump to the step labeled next setting. |
970 String textPosition = VTTParser::collectDigits(input, &position); | 970 int number; |
971 if (textPosition.isEmpty()) | 971 if (!VTTParser::collectDigitsToInt(input, &position, number)) |
972 break; | 972 break; |
973 if (position >= input.length()) | 973 if (position >= input.length()) |
974 break; | 974 break; |
975 | 975 |
976 // 3. If any character in value other than the last character is a U
+0025 PERCENT SIGN character (%), then jump | 976 // 3. If any character in value other than the last character is a U
+0025 PERCENT SIGN character (%), then jump |
977 // to the step labeled next setting. | 977 // to the step labeled next setting. |
978 // 4. If the last character in value is not a U+0025 PERCENT SIGN ch
aracter (%), then jump to the step labeled | 978 // 4. If the last character in value is not a U+0025 PERCENT SIGN ch
aracter (%), then jump to the step labeled |
979 // next setting. | 979 // next setting. |
980 if (input[position++] != '%') | 980 if (input[position++] != '%') |
981 break; | 981 break; |
982 if (position < input.length() && !VTTParser::isValidSettingDelimiter
(input[position])) | 982 if (position < input.length() && !VTTParser::isValidSettingDelimiter
(input[position])) |
983 break; | 983 break; |
984 | 984 |
985 // 5. Ignoring the trailing percent sign, interpret value as an inte
ger, and let number be that number. | 985 // 5. Ignoring the trailing percent sign, interpret value as an inte
ger, and let number be that number. |
986 // 6. If number is not in the range 0 ≤ number ≤ 100, then jump to t
he step labeled next setting. | 986 // 6. If number is not in the range 0 ≤ number ≤ 100, then jump to t
he step labeled next setting. |
987 // NOTE: toInt ignores trailing non-digit characters, such as '%'. | 987 // NOTE: toInt ignores trailing non-digit characters, such as '%'. |
988 bool validNumber; | |
989 int number = textPosition.toInt(&validNumber); | |
990 if (!validNumber) | |
991 break; | |
992 if (number < 0 || number > 100) | 988 if (number < 0 || number > 100) |
993 break; | 989 break; |
994 | 990 |
995 // 7. Let cue's text track cue text position be number. | 991 // 7. Let cue's text track cue text position be number. |
996 m_textPosition = number; | 992 m_textPosition = number; |
997 } | 993 } |
998 break; | 994 break; |
999 case Size: | 995 case Size: |
1000 { | 996 { |
1001 // 1. If value contains any characters other than U+0025 PERCENT SIG
N characters (%) and characters in the | 997 // 1. If value contains any characters other than U+0025 PERCENT SIG
N characters (%) and characters in the |
1002 // range U+0030 DIGIT ZERO (0) to U+0039 DIGIT NINE (9), then jum
p to the step labeled next setting. | 998 // range U+0030 DIGIT ZERO (0) to U+0039 DIGIT NINE (9), then jum
p to the step labeled next setting. |
1003 // 2. If value does not contain at least one character in the range
U+0030 DIGIT ZERO (0) to U+0039 DIGIT | 999 // 2. If value does not contain at least one character in the range
U+0030 DIGIT ZERO (0) to U+0039 DIGIT |
1004 // NINE (9), then jump to the step labeled next setting. | 1000 // NINE (9), then jump to the step labeled next setting. |
1005 String cueSize = VTTParser::collectDigits(input, &position); | 1001 int number; |
1006 if (cueSize.isEmpty()) | 1002 if (!VTTParser::collectDigitsToInt(input, &position, number)) |
1007 break; | 1003 break; |
1008 if (position >= input.length()) | 1004 if (position >= input.length()) |
1009 break; | 1005 break; |
1010 | 1006 |
1011 // 3. If any character in value other than the last character is a U
+0025 PERCENT SIGN character (%), | 1007 // 3. If any character in value other than the last character is a U
+0025 PERCENT SIGN character (%), |
1012 // then jump to the step labeled next setting. | 1008 // then jump to the step labeled next setting. |
1013 // 4. If the last character in value is not a U+0025 PERCENT SIGN ch
aracter (%), then jump to the step | 1009 // 4. If the last character in value is not a U+0025 PERCENT SIGN ch
aracter (%), then jump to the step |
1014 // labeled next setting. | 1010 // labeled next setting. |
1015 if (input[position++] != '%') | 1011 if (input[position++] != '%') |
1016 break; | 1012 break; |
1017 if (position < input.length() && !VTTParser::isValidSettingDelimiter
(input[position])) | 1013 if (position < input.length() && !VTTParser::isValidSettingDelimiter
(input[position])) |
1018 break; | 1014 break; |
1019 | 1015 |
1020 // 5. Ignoring the trailing percent sign, interpret value as an inte
ger, and let number be that number. | 1016 // 5. Ignoring the trailing percent sign, interpret value as an inte
ger, and let number be that number. |
1021 // 6. If number is not in the range 0 ≤ number ≤ 100, then jump to t
he step labeled next setting. | 1017 // 6. If number is not in the range 0 ≤ number ≤ 100, then jump to t
he step labeled next setting. |
1022 bool validNumber; | |
1023 int number = cueSize.toInt(&validNumber); | |
1024 if (!validNumber) | |
1025 break; | |
1026 if (number < 0 || number > 100) | 1018 if (number < 0 || number > 100) |
1027 break; | 1019 break; |
1028 | 1020 |
1029 // 7. Let cue's text track cue size be number. | 1021 // 7. Let cue's text track cue size be number. |
1030 m_cueSize = number; | 1022 m_cueSize = number; |
1031 } | 1023 } |
1032 break; | 1024 break; |
1033 case Align: | 1025 case Align: |
1034 { | 1026 { |
1035 String cueAlignment = VTTParser::collectWord(input, &position); | 1027 String cueAlignment = VTTParser::collectWord(input, &position); |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1110 return m_cueBackgroundBox->executionContext(); | 1102 return m_cueBackgroundBox->executionContext(); |
1111 } | 1103 } |
1112 | 1104 |
1113 Document& VTTCue::document() const | 1105 Document& VTTCue::document() const |
1114 { | 1106 { |
1115 ASSERT(m_cueBackgroundBox); | 1107 ASSERT(m_cueBackgroundBox); |
1116 return m_cueBackgroundBox->document(); | 1108 return m_cueBackgroundBox->document(); |
1117 } | 1109 } |
1118 | 1110 |
1119 } // namespace WebCore | 1111 } // namespace WebCore |
OLD | NEW |