Program life 21:44:30 read 310 comments 0 font size: LargeMediumSmall subscription
Before continuing to analyze frameloader: Write (), return to QT analysis WebKit (2). A complete call stack is saved there,
......
Qtwebkitd4.dll! WebCore: htmltokenizer: Write (const WebCore: segmentedstring & STR = {...}, bool appenddata = true) Row 1730 + 0x23 bytes C ++
Qtwebkitd4.dll! WebCore: frameloader: Write (const char *
The call order is: frameloader: Write (). htmltokenizer: Write () is called ().
The following is the definition of frameloader: Write:
Void write (const char * STR, int Len =-1, bool flush = false );
There are two default call definitions. In the previous article, the call form is: Write (bytes, length );
Actually transmitted is: Write (bytes, length, false );
Next, let's look at the implementation of write:
Void frameloader: Write (const char * STR, int Len, bool flush)
{
If (LEN = 0 &&! Flush)
Return;
If (LEN =-1)
Len = strlen (STR );
Tokenizer * tokenizer = m_frame-> document ()-> tokenizer ();
If (tokenizer & tokenizer-> wantsrawdata ()){
If (LEN> 0)
Tokenizer-> writerawdata (STR, Len );
Return;
}
If (! M_decoder ){
Settings * settings = m_frame-> Settings ();
M_decoder = textresourcedecoder: Create (m_responsemimetype, settings? Settings-> defaulttextencodingname (): string ());
If (m_encoding.isempty ()){
Frame * parentframe = m_frame-> tree ()-> parent ();
If (parentframe & parentframe-> document ()-> securityorigin ()-> canaccess (m_frame-> document ()-> securityorigin ()))
M_decoder-> setencoding (parentframe-> document ()-> inputencoding (), textresourcedecoder: defaultencoding );
} Else {
M_decoder-> setencoding (m_encoding,
M_encodingwaschosenbyuser? Textresourcedecoder: userchosenencoding: textresourcedecoder: encodingfromhttpheader );
}
M_frame-> document ()-> setdecoder (m_decoder.get ());
}
String decoded = m_decoder-> decode (STR, Len );
If (flush)
Decoded + = m_decoder-> flush ();
If (decoded. isempty ())
Return;
# If use (low_bandwidth_display)
If (m_frame-> document ()-> inlowbandwidthdisplay ())
M_pendingsourceinlowbandwidthdisplay.append (decoded );
# Endif
If (! M_receiveddata ){
M_receiveddata = true;
If (m_decoder-> encoding (). usesvisualordering ())
M_frame-> document ()-> setvisuallyordered ();
M_frame-> document ()-> recalcstyle (node: Force );
}
If (tokenizer ){
Assert (! Tokenizer-> wantsrawdata ());
Tokenizer-> write (decoded, true );
}
}
How is it associated with htmltokenizer? It is associated when the document object is initialized in "WebKit (3) of QT analysis.
Domimplementation: createdocument ()
The above program has done some edge work, such as setting the encoding (because the encoding can be specified in the HTTP protocol, the title part of HTML, or the browser ), it mainly creates a new decoder and calls tokenizer-> write ()