Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(110)

Side by Side Diff: Source/core/html/track/WebVTTParser.h

Issue 54203003: Use TextResourceDecoder for the WebVTTParser (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 7 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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 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/html/track/TextTrackCue.h" 38 #include "core/html/track/TextTrackCue.h"
38 #include "core/html/track/TextTrackRegion.h" 39 #include "core/html/track/TextTrackRegion.h"
39 #include "core/html/track/WebVTTTokenizer.h" 40 #include "core/html/track/WebVTTTokenizer.h"
40 #include "wtf/PassOwnPtr.h" 41 #include "wtf/PassOwnPtr.h"
41 #include "wtf/text/StringBuilder.h" 42 #include "wtf/text/StringBuilder.h"
42 43
43 namespace WebCore { 44 namespace WebCore {
44 45
45 using namespace HTMLNames; 46 using namespace HTMLNames;
46 47
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
107 108
108 PassRefPtr<DocumentFragment> createDocumentFragmentFromCueText(const String& ); 109 PassRefPtr<DocumentFragment> createDocumentFragmentFromCueText(const String& );
109 double collectTimeStamp(const String&, unsigned*); 110 double collectTimeStamp(const String&, unsigned*);
110 111
111 private: 112 private:
112 WebVTTParser(WebVTTParserClient*, Document&); 113 WebVTTParser(WebVTTParserClient*, Document&);
113 114
114 Document* m_document; 115 Document* m_document;
115 ParseState m_state; 116 ParseState m_state;
116 117
117 bool hasRequiredFileIdentifier(); 118 bool hasRequiredFileIdentifier(const String& line);
118 ParseState collectCueId(const String&); 119 ParseState collectCueId(const String&);
119 ParseState collectTimingsAndSettings(const String&); 120 ParseState collectTimingsAndSettings(const String&);
120 ParseState collectCueText(const String&, unsigned length, unsigned); 121 ParseState collectCueText(const String&, bool);
121 ParseState ignoreBadCue(const String&); 122 ParseState ignoreBadCue(const String&);
122 123
123 void createNewCue(); 124 void createNewCue();
124 void resetCueValues(); 125 void resetCueValues();
125 126
126 void collectMetadataHeader(const String&); 127 void collectMetadataHeader(const String&);
127 void createNewRegion(); 128 void createNewRegion();
128 129
129 void skipWhiteSpace(const String&, unsigned*); 130 void skipWhiteSpace(const String&, unsigned*);
130 static void skipLineTerminator(const char* data, unsigned length, unsigned*) ; 131 static void skipLineTerminator(const String& data, unsigned*);
131 static String collectNextLine(const char* data, unsigned length, unsigned*); 132 static String collectNextLine(const String& data, unsigned*);
132 133
133 void constructTreeFromToken(Document&); 134 void constructTreeFromToken(Document&);
134 135
135 String m_currentHeaderName; 136 String m_currentHeaderName;
136 String m_currentHeaderValue; 137 String m_currentHeaderValue;
137 138
138 Vector<char> m_identifierData; 139 RefPtr<TextResourceDecoder> m_decoder;
139 String m_currentId; 140 String m_currentId;
140 double m_currentStartTime; 141 double m_currentStartTime;
141 double m_currentEndTime; 142 double m_currentEndTime;
142 StringBuilder m_currentContent; 143 StringBuilder m_currentContent;
143 String m_currentSettings; 144 String m_currentSettings;
144 145
145 WebVTTToken m_token; 146 WebVTTToken m_token;
146 OwnPtr<WebVTTTokenizer> m_tokenizer; 147 OwnPtr<WebVTTTokenizer> m_tokenizer;
147 148
148 RefPtr<ContainerNode> m_currentNode; 149 RefPtr<ContainerNode> m_currentNode;
149 150
150 WebVTTParserClient* m_client; 151 WebVTTParserClient* m_client;
151 152
152 Vector<AtomicString> m_languageStack; 153 Vector<AtomicString> m_languageStack;
153 Vector<RefPtr<TextTrackCue> > m_cuelist; 154 Vector<RefPtr<TextTrackCue> > m_cuelist;
154 155
155 Vector<RefPtr<TextTrackRegion> > m_regionList; 156 Vector<RefPtr<TextTrackRegion> > m_regionList;
156 }; 157 };
157 158
158 } // namespace WebCore 159 } // namespace WebCore
159 160
160 #endif 161 #endif
OLDNEW
« no previous file with comments | « LayoutTests/media/track/opera/track/webvtt/parsing/001-expected.txt ('k') | Source/core/html/track/WebVTTParser.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698