OLD | NEW |
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 Loading... |
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 |
OLD | NEW |