| 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 15 matching lines...) Expand all Loading... |
| 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 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" | |
| 37 | 36 |
| 38 namespace WebCore { | 37 namespace WebCore { |
| 39 | 38 |
| 40 class VTTTokenizerState { | |
| 41 public: | |
| 42 enum State { | |
| 43 DataState, | |
| 44 EscapeState, | |
| 45 TagState, | |
| 46 StartTagState, | |
| 47 StartTagClassState, | |
| 48 StartTagAnnotationState, | |
| 49 EndTagState, | |
| 50 TimestampTagState, | |
| 51 }; | |
| 52 }; | |
| 53 | |
| 54 class VTTTokenizer { | 39 class VTTTokenizer { |
| 55 WTF_MAKE_NONCOPYABLE(VTTTokenizer); | 40 WTF_MAKE_NONCOPYABLE(VTTTokenizer); |
| 56 public: | 41 public: |
| 57 explicit VTTTokenizer(const String& input); | 42 explicit VTTTokenizer(const String& input); |
| 58 | 43 |
| 59 typedef VTTTokenizerState State; | |
| 60 | |
| 61 void reset(); | |
| 62 | |
| 63 bool nextToken(VTTToken&); | 44 bool nextToken(VTTToken&); |
| 64 | 45 |
| 65 inline bool haveBufferedCharacterToken() { return false; } | 46 inline bool shouldSkipNullCharacters() const { return true; } |
| 66 | |
| 67 inline bool advanceAndEmitToken(SegmentedString& source, const VTTToken& tok
en) | |
| 68 { | |
| 69 source.advanceAndUpdateLineNumber(); | |
| 70 return emitToken(token); | |
| 71 } | |
| 72 | |
| 73 inline bool emitToken(const VTTToken& token) | |
| 74 { | |
| 75 *m_token = token; | |
| 76 return true; | |
| 77 } | |
| 78 | |
| 79 bool shouldSkipNullCharacters() const { return true; } | |
| 80 | 47 |
| 81 private: | 48 private: |
| 82 // m_token is owned by the caller. If nextToken is not on the stack, | |
| 83 // this member might be pointing to unallocated memory. | |
| 84 VTTToken* m_token; | |
| 85 | |
| 86 // This member does not really need to be an instance member - it's only use
d in nextToken. | |
| 87 // The reason it's stored here is because of the use of the ADVANCE_TO state
helpers. | |
| 88 VTTTokenizerState::State m_state; | |
| 89 | |
| 90 SegmentedString m_input; | 49 SegmentedString m_input; |
| 91 | 50 |
| 92 // ://www.whatwg.org/specs/web-apps/current-work/#preprocessing-the-input-st
ream | 51 // ://www.whatwg.org/specs/web-apps/current-work/#preprocessing-the-input-st
ream |
| 93 InputStreamPreprocessor<VTTTokenizer> m_inputStreamPreprocessor; | 52 InputStreamPreprocessor<VTTTokenizer> m_inputStreamPreprocessor; |
| 94 }; | 53 }; |
| 95 | 54 |
| 96 } | 55 } |
| 97 | 56 |
| 98 #endif | 57 #endif |
| OLD | NEW |