| 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 14 matching lines...) Expand all Loading... |
| 25 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | 25 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
| 26 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED | 26 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED |
| 27 * OF THE POSSIBILITY OF SUCH DAMAGE. | 27 * OF THE POSSIBILITY OF SUCH DAMAGE. |
| 28 */ | 28 */ |
| 29 | 29 |
| 30 #ifndef VTTScanner_h | 30 #ifndef VTTScanner_h |
| 31 #define VTTScanner_h | 31 #define VTTScanner_h |
| 32 | 32 |
| 33 #include "core/CoreExport.h" | 33 #include "core/CoreExport.h" |
| 34 #include "platform/ParsingUtilities.h" | 34 #include "platform/ParsingUtilities.h" |
| 35 #include "wtf/Allocator.h" |
| 35 #include "wtf/text/WTFString.h" | 36 #include "wtf/text/WTFString.h" |
| 36 | 37 |
| 37 namespace blink { | 38 namespace blink { |
| 38 | 39 |
| 39 // Helper class for "scanning" an input string and performing parsing of | 40 // Helper class for "scanning" an input string and performing parsing of |
| 40 // "micro-syntax"-like constructs. | 41 // "micro-syntax"-like constructs. |
| 41 // | 42 // |
| 42 // There's two primary operations: match and scan. | 43 // There's two primary operations: match and scan. |
| 43 // | 44 // |
| 44 // The 'match' operation matches an explicitly or implicitly specified sequence | 45 // The 'match' operation matches an explicitly or implicitly specified sequence |
| 45 // against the characters ahead of the current input pointer, and returns true | 46 // against the characters ahead of the current input pointer, and returns true |
| 46 // if the sequence can be matched. | 47 // if the sequence can be matched. |
| 47 // | 48 // |
| 48 // The 'scan' operation performs a 'match', and if the match is successful it | 49 // The 'scan' operation performs a 'match', and if the match is successful it |
| 49 // advance the input pointer past the matched sequence. | 50 // advance the input pointer past the matched sequence. |
| 50 class CORE_EXPORT VTTScanner { | 51 class CORE_EXPORT VTTScanner { |
| 52 STACK_ALLOCATED(); |
| 51 WTF_MAKE_NONCOPYABLE(VTTScanner); | 53 WTF_MAKE_NONCOPYABLE(VTTScanner); |
| 52 public: | 54 public: |
| 53 explicit VTTScanner(const String& line); | 55 explicit VTTScanner(const String& line); |
| 54 | 56 |
| 55 typedef const LChar* Position; | 57 typedef const LChar* Position; |
| 56 | 58 |
| 57 class Run { | 59 class Run { |
| 60 STACK_ALLOCATED(); |
| 58 public: | 61 public: |
| 59 Run(Position start, Position end, bool is8Bit) | 62 Run(Position start, Position end, bool is8Bit) |
| 60 : m_start(start), m_end(end), m_is8Bit(is8Bit) { } | 63 : m_start(start), m_end(end), m_is8Bit(is8Bit) { } |
| 61 | 64 |
| 62 Position start() const { return m_start; } | 65 Position start() const { return m_start; } |
| 63 Position end() const { return m_end; } | 66 Position end() const { return m_end; } |
| 64 | 67 |
| 65 bool isEmpty() const { return m_start == m_end; } | 68 bool isEmpty() const { return m_start == m_end; } |
| 66 size_t length() const; | 69 size_t length() const; |
| 67 | 70 |
| (...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 228 ASSERT(position() < end()); | 231 ASSERT(position() < end()); |
| 229 if (m_is8Bit) | 232 if (m_is8Bit) |
| 230 m_data.characters8 += amount; | 233 m_data.characters8 += amount; |
| 231 else | 234 else |
| 232 m_data.characters16 += amount; | 235 m_data.characters16 += amount; |
| 233 } | 236 } |
| 234 | 237 |
| 235 } | 238 } |
| 236 | 239 |
| 237 #endif | 240 #endif |
| OLD | NEW |