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 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
69 return m_token->type() == WebVTTToken::Type::Character; | 69 return m_token->type() == WebVTTToken::Type::Character; |
70 } | 70 } |
71 | 71 |
72 inline void bufferCharacter(UChar character) | 72 inline void bufferCharacter(UChar character) |
73 { | 73 { |
74 ASSERT(character != kEndOfFileMarker); | 74 ASSERT(character != kEndOfFileMarker); |
75 m_token->ensureIsCharacterToken(); | 75 m_token->ensureIsCharacterToken(); |
76 m_token->appendToCharacter(character); | 76 m_token->appendToCharacter(character); |
77 } | 77 } |
78 | 78 |
79 inline bool emitAndResumeIn(SegmentedString& source, State::State state) | 79 inline bool advanceAndEmitToken(SegmentedString& source, WebVTTTokenTypes::T
ype type) |
80 { | 80 { |
81 m_state = state; | |
82 source.advanceAndUpdateLineNumber(); | 81 source.advanceAndUpdateLineNumber(); |
| 82 return emitToken(type); |
| 83 } |
| 84 |
| 85 inline bool emitToken(WebVTTTokenTypes::Type type) |
| 86 { |
| 87 ASSERT(m_token->type() == type); |
83 return true; | 88 return true; |
84 } | 89 } |
85 | 90 |
86 inline bool emitEndOfFile(SegmentedString& source) | |
87 { | |
88 if (haveBufferedCharacterToken()) | |
89 return true; | |
90 m_state = State::DataState; | |
91 source.advanceAndUpdateLineNumber(); | |
92 m_token->clear(); | |
93 m_token->makeEndOfFile(); | |
94 return true; | |
95 } | |
96 | |
97 bool shouldSkipNullCharacters() const { return true; } | 91 bool shouldSkipNullCharacters() const { return true; } |
98 | 92 |
99 private: | 93 private: |
100 WebVTTTokenizer(); | 94 WebVTTTokenizer(); |
101 | 95 |
102 // m_token is owned by the caller. If nextToken is not on the stack, | 96 // m_token is owned by the caller. If nextToken is not on the stack, |
103 // this member might be pointing to unallocated memory. | 97 // this member might be pointing to unallocated memory. |
104 WebVTTToken* m_token; | 98 WebVTTToken* m_token; |
| 99 |
| 100 // This member does not really need to be an instance member - it's only use
d in nextToken. |
| 101 // The reason it's stored here is because of the use of the ADVANCE_TO state
helpers. |
105 WebVTTTokenizerState::State m_state; | 102 WebVTTTokenizerState::State m_state; |
106 | 103 |
107 Vector<LChar, 32> m_buffer; | 104 Vector<LChar, 32> m_buffer; |
108 | 105 |
109 // ://www.whatwg.org/specs/web-apps/current-work/#preprocessing-the-input-st
ream | 106 // ://www.whatwg.org/specs/web-apps/current-work/#preprocessing-the-input-st
ream |
110 InputStreamPreprocessor<WebVTTTokenizer> m_inputStreamPreprocessor; | 107 InputStreamPreprocessor<WebVTTTokenizer> m_inputStreamPreprocessor; |
111 }; | 108 }; |
112 | 109 |
113 } | 110 } |
114 | 111 |
115 #endif | 112 #endif |
OLD | NEW |