This source file includes following definitions.
- m_tokenizer
- pumpTokenizer
- append
- finish
#include "config.h"
#include "core/html/parser/HTMLViewSourceParser.h"
#include "core/dom/DOMImplementation.h"
#include "core/html/parser/HTMLParserIdioms.h"
#include "core/html/parser/HTMLParserOptions.h"
#include "core/html/parser/HTMLToken.h"
namespace WebCore {
HTMLViewSourceParser::HTMLViewSourceParser(HTMLViewSourceDocument* document, const String& mimeType)
: DecodedDataDocumentParser(document)
, m_tokenizer(HTMLTokenizer::create(HTMLParserOptions(document)))
{
if (mimeType != "text/html" && !DOMImplementation::isXMLMIMEType(mimeType))
m_tokenizer->setState(HTMLTokenizer::PLAINTEXTState);
}
void HTMLViewSourceParser::pumpTokenizer()
{
while (true) {
m_sourceTracker.start(m_input.current(), m_tokenizer.get(), m_token);
if (!m_tokenizer->nextToken(m_input.current(), m_token))
return;
m_sourceTracker.end(m_input.current(), m_tokenizer.get(), m_token);
document()->addSource(m_sourceTracker.sourceForToken(m_token), m_token);
if (m_token.type() == HTMLToken::StartTag)
m_tokenizer->updateStateFor(attemptStaticStringCreation(m_token.name(), Likely8Bit));
m_token.clear();
}
}
void HTMLViewSourceParser::append(PassRefPtr<StringImpl> input)
{
m_input.appendToEnd(String(input));
pumpTokenizer();
}
void HTMLViewSourceParser::finish()
{
if (!m_input.haveSeenEndOfFile())
m_input.markEndOfFile();
pumpTokenizer();
document()->finishedParsing();
}
}