Simplify state handling in WebVTTTokenizer::nextToken

When the WebVTT tokenizer returns a new token, it always returns to the
'Data' state - except for when encountering an opening '<' while in the
'Data' state, and having collected a non-empty text-node. In that
particular case though, we can avoid the transition to the 'Tag' state
by not advancing the input, and simply return indicating a new token.

With the above change, and the change to always set the FSM state to
'Data', the 'state' argument to emitAndResumeIn() becomes redundant -
so it can be removed. With the argument gone, rename the method to
advanceAndEmitToken (since it no longer needs to set a state to resume
in). Also add a new method emitToken which only returns true, and
is currently only used as a marker.

Add a (currently unused) argument to the various emitter methods in
WebVTTTokenizer. Use this new argument to indicate what type of token
each return statement should produce.

With the annotations in place it becomes clear that - after adding
additional "ensurance" to one of the instances - that the emitEndOfFile
emitter is redundant (always emits "Character" tokens and always has a
token "buffered" - i.e. haveBufferedCharacterToken() will return true),
and can be replaced by a call to emitToken instead. This also means that
WebVTTToken::makeEndOfFile and the corresponding state can be removed.

BUG=319391

Review URL: https://codereview.chromium.org/73813002

git-svn-id: svn://svn.chromium.org/blink/trunk@162198 bbb929c8-8fbe-4397-9dbb-9b2b20218538
3 files changed