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

Unified Diff: Source/core/html/track/vtt/VTTTokenizer.h

Issue 73813002: Simplify state handling in WebVTTTokenizer::nextToken (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Rebased after files moved Created 7 years, 1 month 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Source/core/html/track/vtt/VTTToken.h ('k') | Source/core/html/track/vtt/VTTTokenizer.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/html/track/vtt/VTTTokenizer.h
diff --git a/Source/core/html/track/vtt/VTTTokenizer.h b/Source/core/html/track/vtt/VTTTokenizer.h
index 9a2721bb382762f998a49afa43626b6c0b4d36ab..f86a6aebafdc54d587ad57ad4c64c4854c93e835 100644
--- a/Source/core/html/track/vtt/VTTTokenizer.h
+++ b/Source/core/html/track/vtt/VTTTokenizer.h
@@ -76,21 +76,15 @@ public:
m_token->appendToCharacter(character);
}
- inline bool emitAndResumeIn(SegmentedString& source, State::State state)
+ inline bool advanceAndEmitToken(SegmentedString& source, WebVTTTokenTypes::Type type)
{
- m_state = state;
source.advanceAndUpdateLineNumber();
- return true;
+ return emitToken(type);
}
- inline bool emitEndOfFile(SegmentedString& source)
+ inline bool emitToken(WebVTTTokenTypes::Type type)
{
- if (haveBufferedCharacterToken())
- return true;
- m_state = State::DataState;
- source.advanceAndUpdateLineNumber();
- m_token->clear();
- m_token->makeEndOfFile();
+ ASSERT(m_token->type() == type);
return true;
}
@@ -102,6 +96,9 @@ private:
// 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;
+
+ // This member does not really need to be an instance member - it's only used in nextToken.
+ // The reason it's stored here is because of the use of the ADVANCE_TO state helpers.
WebVTTTokenizerState::State m_state;
Vector<LChar, 32> m_buffer;
« no previous file with comments | « Source/core/html/track/vtt/VTTToken.h ('k') | Source/core/html/track/vtt/VTTTokenizer.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698