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 22 matching lines...) Expand all Loading... |
33 #include "core/xml/parser/MarkupTokenizerInlines.h" | 33 #include "core/xml/parser/MarkupTokenizerInlines.h" |
34 #include "wtf/text/CharacterNames.h" | 34 #include "wtf/text/CharacterNames.h" |
35 #include "wtf/text/StringBuilder.h" | 35 #include "wtf/text/StringBuilder.h" |
36 | 36 |
37 namespace blink { | 37 namespace blink { |
38 | 38 |
39 #define WEBVTT_BEGIN_STATE(stateName) case stateName: stateName: | 39 #define WEBVTT_BEGIN_STATE(stateName) case stateName: stateName: |
40 #define WEBVTT_ADVANCE_TO(stateName) \ | 40 #define WEBVTT_ADVANCE_TO(stateName) \ |
41 do { \ | 41 do { \ |
42 state = stateName; \ | 42 state = stateName; \ |
43 ASSERT(!m_input.isEmpty()); \ | 43 DCHECK(!m_input.isEmpty()); \ |
44 m_inputStreamPreprocessor.advance(m_input); \ | 44 m_inputStreamPreprocessor.advance(m_input); \ |
45 cc = m_inputStreamPreprocessor.nextInputCharacter(); \ | 45 cc = m_inputStreamPreprocessor.nextInputCharacter(); \ |
46 goto stateName; \ | 46 goto stateName; \ |
47 } while (false) | 47 } while (false) |
48 | 48 |
49 template<unsigned charactersCount> | 49 template<unsigned charactersCount> |
50 ALWAYS_INLINE bool equalLiteral(const StringBuilder& s, const char (&characters)
[charactersCount]) | 50 ALWAYS_INLINE bool equalLiteral(const StringBuilder& s, const char (&characters)
[charactersCount]) |
51 { | 51 { |
52 return WTF::equal(s, reinterpret_cast<const LChar*>(characters), charactersC
ount - 1); | 52 return WTF::equal(s, reinterpret_cast<const LChar*>(characters), charactersC
ount - 1); |
53 } | 53 } |
(...skipping 15 matching lines...) Expand all Loading... |
69 { | 69 { |
70 source.advanceAndUpdateLineNumber(); | 70 source.advanceAndUpdateLineNumber(); |
71 return emitToken(resultToken, token); | 71 return emitToken(resultToken, token); |
72 } | 72 } |
73 | 73 |
74 VTTTokenizer::VTTTokenizer(const String& input) | 74 VTTTokenizer::VTTTokenizer(const String& input) |
75 : m_input(input) | 75 : m_input(input) |
76 , m_inputStreamPreprocessor(this) | 76 , m_inputStreamPreprocessor(this) |
77 { | 77 { |
78 // Append a EOF marker and close the input "stream". | 78 // Append a EOF marker and close the input "stream". |
79 ASSERT(!m_input.isClosed()); | 79 DCHECK(!m_input.isClosed()); |
80 m_input.append(SegmentedString(String(&kEndOfFileMarker, 1))); | 80 m_input.append(SegmentedString(String(&kEndOfFileMarker, 1))); |
81 m_input.close(); | 81 m_input.close(); |
82 } | 82 } |
83 | 83 |
84 bool VTTTokenizer::nextToken(VTTToken& token) | 84 bool VTTTokenizer::nextToken(VTTToken& token) |
85 { | 85 { |
86 if (m_input.isEmpty() || !m_inputStreamPreprocessor.peek(m_input)) | 86 if (m_input.isEmpty() || !m_inputStreamPreprocessor.peek(m_input)) |
87 return false; | 87 return false; |
88 | 88 |
89 UChar cc = m_inputStreamPreprocessor.nextInputCharacter(); | 89 UChar cc = m_inputStreamPreprocessor.nextInputCharacter(); |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
167 WEBVTT_ADVANCE_TO(EscapeState); | 167 WEBVTT_ADVANCE_TO(EscapeState); |
168 } | 168 } |
169 result.append(cc); | 169 result.append(cc); |
170 WEBVTT_ADVANCE_TO(DataState); | 170 WEBVTT_ADVANCE_TO(DataState); |
171 } | 171 } |
172 } | 172 } |
173 END_STATE() | 173 END_STATE() |
174 | 174 |
175 WEBVTT_BEGIN_STATE(TagState) { | 175 WEBVTT_BEGIN_STATE(TagState) { |
176 if (isTokenizerWhitespace(cc)) { | 176 if (isTokenizerWhitespace(cc)) { |
177 ASSERT(result.isEmpty()); | 177 DCHECK(result.isEmpty()); |
178 WEBVTT_ADVANCE_TO(StartTagAnnotationState); | 178 WEBVTT_ADVANCE_TO(StartTagAnnotationState); |
179 } else if (cc == '.') { | 179 } else if (cc == '.') { |
180 ASSERT(result.isEmpty()); | 180 DCHECK(result.isEmpty()); |
181 WEBVTT_ADVANCE_TO(StartTagClassState); | 181 WEBVTT_ADVANCE_TO(StartTagClassState); |
182 } else if (cc == '/') { | 182 } else if (cc == '/') { |
183 WEBVTT_ADVANCE_TO(EndTagState); | 183 WEBVTT_ADVANCE_TO(EndTagState); |
184 } else if (WTF::isASCIIDigit(cc)) { | 184 } else if (WTF::isASCIIDigit(cc)) { |
185 result.append(cc); | 185 result.append(cc); |
186 WEBVTT_ADVANCE_TO(TimestampTagState); | 186 WEBVTT_ADVANCE_TO(TimestampTagState); |
187 } else if (cc == '>' || cc == kEndOfFileMarker) { | 187 } else if (cc == '>' || cc == kEndOfFileMarker) { |
188 ASSERT(result.isEmpty()); | 188 DCHECK(result.isEmpty()); |
189 return advanceAndEmitToken(m_input, token, VTTToken::StartTag(re
sult.toString())); | 189 return advanceAndEmitToken(m_input, token, VTTToken::StartTag(re
sult.toString())); |
190 } else { | 190 } else { |
191 result.append(cc); | 191 result.append(cc); |
192 WEBVTT_ADVANCE_TO(StartTagState); | 192 WEBVTT_ADVANCE_TO(StartTagState); |
193 } | 193 } |
194 } | 194 } |
195 END_STATE() | 195 END_STATE() |
196 | 196 |
197 WEBVTT_BEGIN_STATE(StartTagState) { | 197 WEBVTT_BEGIN_STATE(StartTagState) { |
198 if (isTokenizerWhitespace(cc)) { | 198 if (isTokenizerWhitespace(cc)) { |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
248 WEBVTT_BEGIN_STATE(TimestampTagState) { | 248 WEBVTT_BEGIN_STATE(TimestampTagState) { |
249 if (cc == '>' || cc == kEndOfFileMarker) | 249 if (cc == '>' || cc == kEndOfFileMarker) |
250 return advanceAndEmitToken(m_input, token, VTTToken::TimestampTa
g(result.toString())); | 250 return advanceAndEmitToken(m_input, token, VTTToken::TimestampTa
g(result.toString())); |
251 result.append(cc); | 251 result.append(cc); |
252 WEBVTT_ADVANCE_TO(TimestampTagState); | 252 WEBVTT_ADVANCE_TO(TimestampTagState); |
253 } | 253 } |
254 END_STATE() | 254 END_STATE() |
255 | 255 |
256 } | 256 } |
257 | 257 |
258 ASSERT_NOT_REACHED(); | 258 NOTREACHED(); |
259 return false; | 259 return false; |
260 } | 260 } |
261 | 261 |
262 } // namespace blink | 262 } // namespace blink |
OLD | NEW |