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

Side by Side Diff: Source/core/html/track/vtt/VTTToken.h

Issue 73813002: Simplify state handling in WebVTTTokenizer::nextToken (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Rebased after files moved 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
« no previous file with comments | « no previous file | Source/core/html/track/vtt/VTTTokenizer.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 23 matching lines...) Expand all
34 namespace WebCore { 34 namespace WebCore {
35 35
36 class WebVTTTokenTypes { 36 class WebVTTTokenTypes {
37 public: 37 public:
38 enum Type { 38 enum Type {
39 Uninitialized, 39 Uninitialized,
40 Character, 40 Character,
41 StartTag, 41 StartTag,
42 EndTag, 42 EndTag,
43 TimestampTag, 43 TimestampTag,
44 EndOfFile,
45 }; 44 };
46 }; 45 };
47 46
48 class WebVTTToken { 47 class WebVTTToken {
49 WTF_MAKE_NONCOPYABLE(WebVTTToken); 48 WTF_MAKE_NONCOPYABLE(WebVTTToken);
50 WTF_MAKE_FAST_ALLOCATED; 49 WTF_MAKE_FAST_ALLOCATED;
51 public: 50 public:
52 typedef WebVTTTokenTypes Type; 51 typedef WebVTTTokenTypes Type;
53 typedef WTF::Vector<UChar, 1024> DataVector; // FIXME: Is this too large for WebVTT? 52 typedef WTF::Vector<UChar, 1024> DataVector; // FIXME: Is this too large for WebVTT?
54 53
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
167 m_annotation.clear(); 166 m_annotation.clear();
168 m_annotation.append(m_currentBuffer); 167 m_annotation.append(m_currentBuffer);
169 m_currentBuffer.clear(); 168 m_currentBuffer.clear();
170 } 169 }
171 170
172 const DataVector& annotation() const 171 const DataVector& annotation() const
173 { 172 {
174 return m_annotation; 173 return m_annotation;
175 } 174 }
176 175
177 void makeEndOfFile()
178 {
179 ASSERT(m_type == Type::Uninitialized);
180 m_type = Type::EndOfFile;
181 }
182
183 void clear() 176 void clear()
184 { 177 {
185 m_type = Type::Uninitialized; 178 m_type = Type::Uninitialized;
186 m_data.clear(); 179 m_data.clear();
187 m_annotation.clear(); 180 m_annotation.clear();
188 m_classes.clear(); 181 m_classes.clear();
189 m_currentBuffer.clear(); 182 m_currentBuffer.clear();
190 } 183 }
191 184
192 private: 185 private:
193 void appendToStartType(UChar character) 186 void appendToStartType(UChar character)
194 { 187 {
195 ASSERT(character); 188 ASSERT(character);
196 ASSERT(m_type == Type::StartTag); 189 ASSERT(m_type == Type::StartTag);
197 m_currentBuffer.append(character); 190 m_currentBuffer.append(character);
198 } 191 }
199 192
200 Type::Type m_type; 193 Type::Type m_type;
201 DataVector m_data; 194 DataVector m_data;
202 DataVector m_annotation; 195 DataVector m_annotation;
203 DataVector m_classes; 196 DataVector m_classes;
204 DataVector m_currentBuffer; 197 DataVector m_currentBuffer;
205 }; 198 };
206 199
207 } 200 }
208 201
209 #endif 202 #endif
OLDNEW
« no previous file with comments | « no previous file | Source/core/html/track/vtt/VTTTokenizer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698