WebKit for Qt analysis (6)

Source: Internet
Author: User

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 ()

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.