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 17 matching lines...) Expand all Loading... |
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 WebVTTParser_h | 31 #ifndef WebVTTParser_h |
32 #define WebVTTParser_h | 32 #define WebVTTParser_h |
33 | 33 |
34 #include "HTMLNames.h" | 34 #include "HTMLNames.h" |
35 #include "RuntimeEnabledFeatures.h" | 35 #include "RuntimeEnabledFeatures.h" |
36 #include "core/dom/DocumentFragment.h" | 36 #include "core/dom/DocumentFragment.h" |
37 #include "core/fetch/TextResourceDecoder.h" | 37 #include "core/fetch/TextResourceDecoder.h" |
| 38 #include "core/html/track/BufferedLineReader.h" |
38 #include "core/html/track/TextTrackCue.h" | 39 #include "core/html/track/TextTrackCue.h" |
39 #include "core/html/track/VTTRegion.h" | 40 #include "core/html/track/VTTRegion.h" |
40 #include "core/html/track/WebVTTTokenizer.h" | 41 #include "core/html/track/WebVTTTokenizer.h" |
41 #include "wtf/PassOwnPtr.h" | 42 #include "wtf/PassOwnPtr.h" |
42 #include "wtf/text/StringBuilder.h" | 43 #include "wtf/text/StringBuilder.h" |
43 | 44 |
44 namespace WebCore { | 45 namespace WebCore { |
45 | 46 |
46 using namespace HTMLNames; | 47 using namespace HTMLNames; |
47 | 48 |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
110 // Transfers ownership of last parsed cues to caller. | 111 // Transfers ownership of last parsed cues to caller. |
111 void getNewCues(Vector<RefPtr<TextTrackCue> >&); | 112 void getNewCues(Vector<RefPtr<TextTrackCue> >&); |
112 void getNewRegions(Vector<RefPtr<VTTRegion> >&); | 113 void getNewRegions(Vector<RefPtr<VTTRegion> >&); |
113 | 114 |
114 private: | 115 private: |
115 WebVTTParser(WebVTTParserClient*, Document&); | 116 WebVTTParser(WebVTTParserClient*, Document&); |
116 | 117 |
117 Document* m_document; | 118 Document* m_document; |
118 ParseState m_state; | 119 ParseState m_state; |
119 | 120 |
120 void parse(const String& textData); | 121 void parse(); |
121 void flushPendingCue(); | 122 void flushPendingCue(); |
122 bool hasRequiredFileIdentifier(const String& line); | 123 bool hasRequiredFileIdentifier(const String& line); |
123 ParseState collectCueId(const String&); | 124 ParseState collectCueId(const String&); |
124 ParseState collectTimingsAndSettings(const String&); | 125 ParseState collectTimingsAndSettings(const String&); |
125 ParseState collectCueText(const String&); | 126 ParseState collectCueText(const String&); |
126 ParseState ignoreBadCue(const String&); | 127 ParseState ignoreBadCue(const String&); |
127 | 128 |
128 void createNewCue(); | 129 void createNewCue(); |
129 void resetCueValues(); | 130 void resetCueValues(); |
130 | 131 |
131 void collectMetadataHeader(const String&); | 132 void collectMetadataHeader(const String&); |
132 void createNewRegion(); | 133 void createNewRegion(); |
133 | 134 |
134 void skipWhiteSpace(const String&, unsigned*); | 135 void skipWhiteSpace(const String&, unsigned*); |
135 static void skipLineTerminator(const String& data, unsigned*); | |
136 static String collectNextLine(const String& data, unsigned*); | |
137 | 136 |
138 String m_currentHeaderName; | 137 String m_currentHeaderName; |
139 String m_currentHeaderValue; | 138 String m_currentHeaderValue; |
140 | 139 |
| 140 BufferedLineReader m_lineReader; |
141 RefPtr<TextResourceDecoder> m_decoder; | 141 RefPtr<TextResourceDecoder> m_decoder; |
142 String m_currentId; | 142 String m_currentId; |
143 double m_currentStartTime; | 143 double m_currentStartTime; |
144 double m_currentEndTime; | 144 double m_currentEndTime; |
145 StringBuilder m_currentContent; | 145 StringBuilder m_currentContent; |
146 String m_currentSettings; | 146 String m_currentSettings; |
147 | 147 |
148 WebVTTParserClient* m_client; | 148 WebVTTParserClient* m_client; |
149 | 149 |
150 Vector<RefPtr<TextTrackCue> > m_cuelist; | 150 Vector<RefPtr<TextTrackCue> > m_cuelist; |
151 | 151 |
152 Vector<RefPtr<VTTRegion> > m_regionList; | 152 Vector<RefPtr<VTTRegion> > m_regionList; |
153 }; | 153 }; |
154 | 154 |
155 } // namespace WebCore | 155 } // namespace WebCore |
156 | 156 |
157 #endif | 157 #endif |
OLD | NEW |