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

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

Issue 137033002: Use VTTScanner for VTT region settings parsing (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 6 years, 11 months 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/vtt/VTTRegion.cpp ('k') | Source/core/html/track/vtt/VTTScannerTest.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) 2013, Opera Software ASA. All rights reserved. 2 * Copyright (c) 2013, Opera Software ASA. 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 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 1. Redistributions of source code must retain the above copyright 7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer. 8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright 9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the 10 * notice, this list of conditions and the following disclaimer in the
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
84 // Scan the literal |characters|. 84 // Scan the literal |characters|.
85 template<unsigned charactersCount> 85 template<unsigned charactersCount>
86 bool scan(const char (&characters)[charactersCount]); 86 bool scan(const char (&characters)[charactersCount]);
87 87
88 // Skip (advance the input pointer) as long as the specified 88 // Skip (advance the input pointer) as long as the specified
89 // |characterPredicate| returns true, and the input pointer is not passed 89 // |characterPredicate| returns true, and the input pointer is not passed
90 // the end of the input. 90 // the end of the input.
91 template<bool characterPredicate(UChar)> 91 template<bool characterPredicate(UChar)>
92 void skipWhile(); 92 void skipWhile();
93 93
94 // Like skipWhile, but using a negated predicate.
95 template<bool characterPredicate(UChar)>
96 void skipUntil();
97
94 // Return the run of characters for which the specified 98 // Return the run of characters for which the specified
95 // |characterPredicate| returns true. The start of the run will be the 99 // |characterPredicate| returns true. The start of the run will be the
96 // current input pointer. 100 // current input pointer.
97 template<bool characterPredicate(UChar)> 101 template<bool characterPredicate(UChar)>
98 Run collectWhile(); 102 Run collectWhile();
99 103
100 // Like collectWhile, but using a negated predicate. 104 // Like collectWhile, but using a negated predicate.
101 template<bool characterPredicate(UChar)> 105 template<bool characterPredicate(UChar)>
102 Run collectUntil(); 106 Run collectUntil();
103 107
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
159 template<bool characterPredicate(UChar)> 163 template<bool characterPredicate(UChar)>
160 inline void VTTScanner::skipWhile() 164 inline void VTTScanner::skipWhile()
161 { 165 {
162 if (m_is8Bit) 166 if (m_is8Bit)
163 ::skipWhile<LChar, LCharPredicateAdapter<characterPredicate> >(m_data.ch aracters8, m_end.characters8); 167 ::skipWhile<LChar, LCharPredicateAdapter<characterPredicate> >(m_data.ch aracters8, m_end.characters8);
164 else 168 else
165 ::skipWhile<UChar, characterPredicate>(m_data.characters16, m_end.charac ters16); 169 ::skipWhile<UChar, characterPredicate>(m_data.characters16, m_end.charac ters16);
166 } 170 }
167 171
168 template<bool characterPredicate(UChar)> 172 template<bool characterPredicate(UChar)>
173 inline void VTTScanner::skipUntil()
174 {
175 if (m_is8Bit)
176 ::skipUntil<LChar, LCharPredicateAdapter<characterPredicate> >(m_data.ch aracters8, m_end.characters8);
177 else
178 ::skipUntil<UChar, characterPredicate>(m_data.characters16, m_end.charac ters16);
179 }
180
181 template<bool characterPredicate(UChar)>
169 inline VTTScanner::Run VTTScanner::collectWhile() 182 inline VTTScanner::Run VTTScanner::collectWhile()
170 { 183 {
171 if (m_is8Bit) { 184 if (m_is8Bit) {
172 const LChar* current = m_data.characters8; 185 const LChar* current = m_data.characters8;
173 ::skipWhile<LChar, LCharPredicateAdapter<characterPredicate> >(current, m_end.characters8); 186 ::skipWhile<LChar, LCharPredicateAdapter<characterPredicate> >(current, m_end.characters8);
174 return Run(position(), current, m_is8Bit); 187 return Run(position(), current, m_is8Bit);
175 } 188 }
176 const UChar* current = m_data.characters16; 189 const UChar* current = m_data.characters16;
177 ::skipWhile<UChar, characterPredicate>(current, m_end.characters16); 190 ::skipWhile<UChar, characterPredicate>(current, m_end.characters16);
178 return Run(position(), reinterpret_cast<Position>(current), m_is8Bit); 191 return Run(position(), reinterpret_cast<Position>(current), m_is8Bit);
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
241 unsigned* m_outPosition; 254 unsigned* m_outPosition;
242 union { 255 union {
243 const LChar* characters8; 256 const LChar* characters8;
244 const UChar* characters16; 257 const UChar* characters16;
245 } m_start; 258 } m_start;
246 }; 259 };
247 260
248 } 261 }
249 262
250 #endif 263 #endif
OLDNEW
« no previous file with comments | « Source/core/html/track/vtt/VTTRegion.cpp ('k') | Source/core/html/track/vtt/VTTScannerTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698