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 16 matching lines...) Expand all Loading... |
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
29 */ | 29 */ |
30 | 30 |
31 #ifndef VTTTokenizer_h | 31 #ifndef VTTTokenizer_h |
32 #define VTTTokenizer_h | 32 #define VTTTokenizer_h |
33 | 33 |
34 #include "core/html/parser/InputStreamPreprocessor.h" | 34 #include "core/html/parser/InputStreamPreprocessor.h" |
35 #include "core/html/track/vtt/VTTToken.h" | 35 #include "core/html/track/vtt/VTTToken.h" |
36 #include "wtf/PassOwnPtr.h" | 36 #include "wtf/PassOwnPtr.h" |
37 #include "wtf/text/StringBuilder.h" | |
38 | 37 |
39 namespace WebCore { | 38 namespace WebCore { |
40 | 39 |
41 class VTTTokenizerState { | 40 class VTTTokenizerState { |
42 public: | 41 public: |
43 enum State { | 42 enum State { |
44 DataState, | 43 DataState, |
45 EscapeState, | 44 EscapeState, |
46 TagState, | 45 TagState, |
47 StartTagState, | 46 StartTagState, |
(...skipping 10 matching lines...) Expand all Loading... |
58 explicit VTTTokenizer(const String& input); | 57 explicit VTTTokenizer(const String& input); |
59 | 58 |
60 typedef VTTTokenizerState State; | 59 typedef VTTTokenizerState State; |
61 | 60 |
62 void reset(); | 61 void reset(); |
63 | 62 |
64 bool nextToken(VTTToken&); | 63 bool nextToken(VTTToken&); |
65 | 64 |
66 inline bool haveBufferedCharacterToken() { return false; } | 65 inline bool haveBufferedCharacterToken() { return false; } |
67 | 66 |
68 inline bool advanceAndEmitToken(SegmentedString& source, VTTTokenTypes::Type
type) | 67 inline bool advanceAndEmitToken(SegmentedString& source, const VTTToken& tok
en) |
69 { | 68 { |
70 source.advanceAndUpdateLineNumber(); | 69 source.advanceAndUpdateLineNumber(); |
71 return emitToken(type); | 70 return emitToken(token); |
72 } | 71 } |
73 | 72 |
74 inline bool emitToken(VTTTokenTypes::Type type) | 73 inline bool emitToken(const VTTToken& token) |
75 { | 74 { |
76 m_token->setType(type); | 75 *m_token = token; |
77 return true; | 76 return true; |
78 } | 77 } |
79 | 78 |
80 bool shouldSkipNullCharacters() const { return true; } | 79 bool shouldSkipNullCharacters() const { return true; } |
81 | 80 |
82 private: | 81 private: |
83 // m_token is owned by the caller. If nextToken is not on the stack, | 82 // m_token is owned by the caller. If nextToken is not on the stack, |
84 // this member might be pointing to unallocated memory. | 83 // this member might be pointing to unallocated memory. |
85 VTTToken* m_token; | 84 VTTToken* m_token; |
86 | 85 |
87 // This member does not really need to be an instance member - it's only use
d in nextToken. | 86 // This member does not really need to be an instance member - it's only use
d in nextToken. |
88 // The reason it's stored here is because of the use of the ADVANCE_TO state
helpers. | 87 // The reason it's stored here is because of the use of the ADVANCE_TO state
helpers. |
89 VTTTokenizerState::State m_state; | 88 VTTTokenizerState::State m_state; |
90 | 89 |
91 StringBuilder m_buffer; | |
92 SegmentedString m_input; | 90 SegmentedString m_input; |
93 | 91 |
94 // ://www.whatwg.org/specs/web-apps/current-work/#preprocessing-the-input-st
ream | 92 // ://www.whatwg.org/specs/web-apps/current-work/#preprocessing-the-input-st
ream |
95 InputStreamPreprocessor<VTTTokenizer> m_inputStreamPreprocessor; | 93 InputStreamPreprocessor<VTTTokenizer> m_inputStreamPreprocessor; |
96 }; | 94 }; |
97 | 95 |
98 } | 96 } |
99 | 97 |
100 #endif | 98 #endif |
OLD | NEW |