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

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

Issue 52713005: Decouple tokenizer/tree builder state from 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
« no previous file with comments | « Source/core/html/track/TextTrackCue.cpp ('k') | Source/core/html/track/WebVTTParser.cpp » ('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 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
93 return c == ' ' || c == '\t'; 93 return c == ' ' || c == '\t';
94 } 94 }
95 static String collectDigits(const String&, unsigned*); 95 static String collectDigits(const String&, unsigned*);
96 static String collectWord(const String&, unsigned*); 96 static String collectWord(const String&, unsigned*);
97 static double collectTimeStamp(const String&, unsigned*); 97 static double collectTimeStamp(const String&, unsigned*);
98 98
99 // Useful functions for parsing percentage settings. 99 // Useful functions for parsing percentage settings.
100 static float parseFloatPercentageValue(const String&, bool&); 100 static float parseFloatPercentageValue(const String&, bool&);
101 static FloatPoint parseFloatPercentageValuePair(const String&, char, bool&); 101 static FloatPoint parseFloatPercentageValuePair(const String&, char, bool&);
102 102
103 // Create the DocumentFragment representation of the WebVTT cue text.
104 static PassRefPtr<DocumentFragment> createDocumentFragmentFromCueText(Docume nt&, const String&);
105
103 // Input data to the parser to parse. 106 // Input data to the parser to parse.
104 void parseBytes(const char* data, unsigned length); 107 void parseBytes(const char* data, unsigned length);
105 108
106 // Transfers ownership of last parsed cues to caller. 109 // Transfers ownership of last parsed cues to caller.
107 void getNewCues(Vector<RefPtr<TextTrackCue> >&); 110 void getNewCues(Vector<RefPtr<TextTrackCue> >&);
108 void getNewRegions(Vector<RefPtr<TextTrackRegion> >&); 111 void getNewRegions(Vector<RefPtr<TextTrackRegion> >&);
109 112
110 PassRefPtr<DocumentFragment> createDocumentFragmentFromCueText(const String& );
111
112 private: 113 private:
113 WebVTTParser(WebVTTParserClient*, Document&); 114 WebVTTParser(WebVTTParserClient*, Document&);
114 115
115 Document* m_document; 116 Document* m_document;
116 ParseState m_state; 117 ParseState m_state;
117 118
118 bool hasRequiredFileIdentifier(const String& line); 119 bool hasRequiredFileIdentifier(const String& line);
119 ParseState collectCueId(const String&); 120 ParseState collectCueId(const String&);
120 ParseState collectTimingsAndSettings(const String&); 121 ParseState collectTimingsAndSettings(const String&);
121 ParseState collectCueText(const String&, bool); 122 ParseState collectCueText(const String&, bool);
122 ParseState ignoreBadCue(const String&); 123 ParseState ignoreBadCue(const String&);
123 124
124 void createNewCue(); 125 void createNewCue();
125 void resetCueValues(); 126 void resetCueValues();
126 127
127 void collectMetadataHeader(const String&); 128 void collectMetadataHeader(const String&);
128 void createNewRegion(); 129 void createNewRegion();
129 130
130 void skipWhiteSpace(const String&, unsigned*); 131 void skipWhiteSpace(const String&, unsigned*);
131 static void skipLineTerminator(const String& data, unsigned*); 132 static void skipLineTerminator(const String& data, unsigned*);
132 static String collectNextLine(const String& data, unsigned*); 133 static String collectNextLine(const String& data, unsigned*);
133 134
134 void constructTreeFromToken(Document&);
135
136 String m_currentHeaderName; 135 String m_currentHeaderName;
137 String m_currentHeaderValue; 136 String m_currentHeaderValue;
138 137
139 RefPtr<TextResourceDecoder> m_decoder; 138 RefPtr<TextResourceDecoder> m_decoder;
140 String m_currentId; 139 String m_currentId;
141 double m_currentStartTime; 140 double m_currentStartTime;
142 double m_currentEndTime; 141 double m_currentEndTime;
143 StringBuilder m_currentContent; 142 StringBuilder m_currentContent;
144 String m_currentSettings; 143 String m_currentSettings;
145 144
146 WebVTTToken m_token;
147 OwnPtr<WebVTTTokenizer> m_tokenizer;
148
149 RefPtr<ContainerNode> m_currentNode;
150
151 WebVTTParserClient* m_client; 145 WebVTTParserClient* m_client;
152 146
153 Vector<AtomicString> m_languageStack;
154 Vector<RefPtr<TextTrackCue> > m_cuelist; 147 Vector<RefPtr<TextTrackCue> > m_cuelist;
155 148
156 Vector<RefPtr<TextTrackRegion> > m_regionList; 149 Vector<RefPtr<TextTrackRegion> > m_regionList;
157 }; 150 };
158 151
159 } // namespace WebCore 152 } // namespace WebCore
160 153
161 #endif 154 #endif
OLDNEW
« no previous file with comments | « Source/core/html/track/TextTrackCue.cpp ('k') | Source/core/html/track/WebVTTParser.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698