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

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

Issue 143983002: Rework end-of-value field handling in VTTRegion::parseSettingValue (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') | no next file » | 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 210 matching lines...) Expand 10 before | Expand all | Expand 10 after
221 221
222 inline void VTTScanner::advance(unsigned amount) 222 inline void VTTScanner::advance(unsigned amount)
223 { 223 {
224 ASSERT(position() < end()); 224 ASSERT(position() < end());
225 if (m_is8Bit) 225 if (m_is8Bit)
226 m_data.characters8 += amount; 226 m_data.characters8 += amount;
227 else 227 else
228 m_data.characters16 += amount; 228 m_data.characters16 += amount;
229 } 229 }
230 230
231 // Wrapper of VTTScanner that allows easy interaction with a parsing model
232 // where a <String, index> tuple is used.
233 class VTTLegacyScanner : public VTTScanner {
234 WTF_MAKE_NONCOPYABLE(VTTLegacyScanner);
235 public:
236 VTTLegacyScanner(const String& line, unsigned* outPosition)
237 : VTTScanner(line)
238 , m_outPosition(outPosition)
239 {
240 ASSERT(outPosition && *outPosition <= line.length());
241 // Adjust state according to |*outPosition|.
242 advance(*outPosition);
243 // Save the start position to allow adjusting |*outPosition|.
244 if (m_is8Bit)
245 m_start.characters8 = m_data.characters8;
246 else
247 m_start.characters16 = m_data.characters16;
248 }
249 ~VTTLegacyScanner()
250 {
251 // "Export" the updated position.
252 unsigned advancedChars = m_is8Bit ? m_data.characters8 - m_start.charact ers8 : m_data.characters16 - m_start.characters16;
253 *m_outPosition += advancedChars;
254 }
255
256 private:
257 unsigned* m_outPosition;
258 union {
259 const LChar* characters8;
260 const UChar* characters16;
261 } m_start;
262 };
263
264 } 231 }
265 232
266 #endif 233 #endif
OLDNEW
« no previous file with comments | « Source/core/html/track/vtt/VTTRegion.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698