summaryrefslogtreecommitdiff
path: root/Source/WebCore/html/track/WebVTTTokenizer.h
diff options
context:
space:
mode:
Diffstat (limited to 'Source/WebCore/html/track/WebVTTTokenizer.h')
-rw-r--r--Source/WebCore/html/track/WebVTTTokenizer.h83
1 files changed, 10 insertions, 73 deletions
diff --git a/Source/WebCore/html/track/WebVTTTokenizer.h b/Source/WebCore/html/track/WebVTTTokenizer.h
index 79ee06b26..2b0c0c02d 100644
--- a/Source/WebCore/html/track/WebVTTTokenizer.h
+++ b/Source/WebCore/html/track/WebVTTTokenizer.h
@@ -1,5 +1,6 @@
/*
- * Copyright (C) 2011 Google Inc. All rights reserved.
+ * Copyright (C) 2011, 2013 Google Inc. All rights reserved.
+ * Copyright (C) 2014 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
@@ -28,91 +29,27 @@
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#ifndef WebVTTTokenizer_h
-#define WebVTTTokenizer_h
+#pragma once
#if ENABLE(VIDEO_TRACK)
#include "InputStreamPreprocessor.h"
#include "WebVTTToken.h"
-#include <wtf/PassOwnPtr.h>
namespace WebCore {
-class WebVTTTokenizerState {
-public:
- enum State {
- DataState,
- EscapeState,
- TagState,
- StartTagState,
- StartTagClassState,
- StartTagAnnotationState,
- EndTagState,
- EndTagOpenState,
- TimestampTagState,
- };
-};
-
class WebVTTTokenizer {
- WTF_MAKE_NONCOPYABLE(WebVTTTokenizer);
- WTF_MAKE_FAST_ALLOCATED;
public:
- static OwnPtr<WebVTTTokenizer> create() { return adoptPtr(new WebVTTTokenizer); }
-
- typedef WebVTTTokenizerState State;
-
- void reset();
-
- bool nextToken(SegmentedString&, WebVTTToken&);
-
- inline bool haveBufferedCharacterToken()
- {
- return m_token->type() == WebVTTToken::Type::Character;
- }
+ explicit WebVTTTokenizer(const String&);
+ bool nextToken(WebVTTToken&);
- inline void bufferCharacter(UChar character)
- {
- ASSERT(character != kEndOfFileMarker);
- m_token->ensureIsCharacterToken();
- m_token->appendToCharacter(character);
- }
-
- inline bool emitAndResumeIn(SegmentedString& source, State::State state)
- {
- m_state = state;
- source.advanceAndUpdateLineNumber();
- return true;
- }
-
- inline bool emitEndOfFile(SegmentedString& source)
- {
- if (haveBufferedCharacterToken())
- return true;
- m_state = State::DataState;
- source.advanceAndUpdateLineNumber();
- m_token->clear();
- m_token->makeEndOfFile();
- return true;
- }
-
- bool shouldSkipNullCharacters() const { return true; }
+ static bool neverSkipNullCharacters() { return false; }
private:
- WebVTTTokenizer();
-
- // m_token is owned by the caller. If nextToken is not on the stack,
- // this member might be pointing to unallocated memory.
- WebVTTToken* m_token;
- WebVTTTokenizerState::State m_state;
-
- Vector<LChar, 32> m_buffer;
-
- // ://www.whatwg.org/specs/web-apps/current-work/#preprocessing-the-input-stream
- InputStreamPreprocessor<WebVTTTokenizer> m_inputStreamPreprocessor;
+ SegmentedString m_input;
+ InputStreamPreprocessor<WebVTTTokenizer> m_preprocessor;
};
-}
+} // namespace WebCore
-#endif
-#endif
+#endif // ENABLE(VIDEO_TRACK)