2012年3月26日 星期一

[WebKit] HTML Parsing Flow

This is a simple note about the function flow of webkit data parsing. 
Assume webkit had gotten html from ResourceHandle, you can find previous article about data loading flow here. (http://twnin.blogspot.com/2012/03/webkit-loading-flow.html)

HTML Parsing
>> start from void DocumentWriter::endIfNotLoadingMainResource()
void DecodedDataDocumentParser::flush(DocumentWriter* writer)
void HTMLDocumentParser::append(const SegmentedString& source)
void HTMLDocumentParser::pumpTokenizerIfPossible(SynchronousMode mode)
void HTMLDocumentParser::pumpTokenizer(SynchronousMode mode)
node tree constructing loop
void HTMLSourceTracker::start(const HTMLInputStream& input, HTMLTokenizer* tokenizer, HTMLToken& token)
bool HTMLTokenizer::nextToken(SegmentedString& source, HTMLToken& token)
void HTMLSourceTracker::end(const HTMLInputStream& input, HTMLTokenizer* tokenizer, HTMLToken& token)
void HTMLTreeBuilder::constructTreeFromToken(HTMLToken& rawToken)
// Here omit detailed tree construction.
end loop
>> return to void DocumentWriter::endIfNotLoadingMainResource() 
void HTMLDocumentParser::finish()
void HTMLDocumentParser::attemptToEnd()
void HTMLDocumentParser::prepareToStopParsing()
void HTMLDocumentParser::attemptToRunDeferredScriptsAndEnd()
void HTMLDocumentParser::end()
void HTMLTreeBuilder::finished()
void Document::finishedParsing()
        bool Node::dispatchEvent(PassRefPtr<Event> event) // DOMContentLoadedEvent

void FrameLoader::finishedParsing()
        void WebFrameLoaderClient::dispatchDidFinishDocumentLoad()
        bool MessageSender::send(const U& message) // dispatchDidFinishDocumentLoad

>> return to void FrameLoader::finishedLoading()
        void WebFrameLoaderClient::dispatchDidLoadMainResource(DocumentLoader*)

>> return to head of call stack


So far, we establish a html node tree, then we are going to load content of DOM.

1 則留言:

  1. Hi Ninna,
    I'm starting to learn Webkit. Your posts are very useful. Thank you so much. Could you continue writing about loading content of DOM, or do you know any document for it?

    回覆刪除