2 * Copyright (C) 2011 Google Inc. All rights reserved.
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above
11 * copyright notice, this list of conditions and the following disclaimer
12 * in the documentation and/or other materials provided with the
14 * * Neither the name of Google Inc. nor the names of its
15 * contributors may be used to endorse or promote products derived from
16 * this software without specific prior written permission.
18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
22 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34 #if ENABLE(VIDEO_TRACK)
36 #include "MarkupTokenBase.h"
40 class WebVTTTokenTypes {
52 class WebVTTToken : public MarkupTokenBase<WebVTTTokenTypes> {
54 void appendToName(UChar character)
56 ASSERT(m_type == WebVTTTokenTypes::StartTag || m_type == WebVTTTokenTypes::EndTag);
57 MarkupTokenBase<WebVTTTokenTypes>::appendToName(character);
60 const DataVector& name() const
62 return MarkupTokenBase<WebVTTTokenTypes>::name();
65 const DataVector& characters() const
67 ASSERT(m_type == Type::Character || m_type == Type::TimestampTag);
71 void beginEmptyStartTag()
73 ASSERT(m_type == Type::Uninitialized);
74 m_type = Type::StartTag;
75 m_currentAttribute = 0;
80 void beginTimestampTag(UChar character)
83 ASSERT(m_type == Type::Uninitialized);
84 m_type = Type::TimestampTag;
86 m_data.append(character);
89 void appendToTimestamp(UChar character)
92 ASSERT(m_type == Type::TimestampTag);
93 m_data.append(character);
96 void appendToClass(UChar character)
98 appendToStartType(character);
103 ASSERT(m_type == Type::StartTag);
104 if (!m_classes.isEmpty())
105 m_classes.append(' ');
106 m_classes.append(m_currentBuffer);
107 m_currentBuffer.clear();
110 const DataVector& classes() const
115 void appendToAnnotation(UChar character)
117 appendToStartType(character);
120 void addNewAnnotation()
122 ASSERT(m_type == Type::StartTag);
123 m_annotation.clear();
124 m_annotation.append(m_currentBuffer);
125 m_currentBuffer.clear();
128 const DataVector& annotation() const
135 m_annotation.clear();
137 m_currentBuffer.clear();
138 MarkupTokenBase<WebVTTTokenTypes>::clear();
142 void appendToStartType(UChar character)
145 ASSERT(m_type == Type::StartTag);
146 m_currentBuffer.append(character);
149 DataVector m_annotation;
150 DataVector m_classes;
151 DataVector m_currentBuffer;