WebKit HTML Element support process

Source: Internet
Author: User
Tags prefetch

This section describes how WebKit parses HTML elements.

After documentloader receives HTML, it calls htmldocumentparser: appendbytes through documentwriter. After decoding by documentwriter, it calls htmldocumentparser: append to add it to htmlinputstream. If JavaScript code is currently being executed, call htmlpreloadparts to download some IMG and CSS resources in advance. If suspend is used, wait for htmlparserscheduler to resume, call htmltokenizer to obtain an htmltoken, and call htmltreebuilder to create Dom.
Tree. If a script needs to be run, give htmltreebuilder to pause. Then, run the script through htmlscriptrunner before obtaining the token next time.
The parsing process mainly involves htmltreebuilder. cpp, htmltokenizer. cpp, and htmldocumentparser. cpp. The setinsertionmode mainly records the resolution status.

 

 

Htmltokenizer provides the nexttoken method to parse htmlinputstream. Each call resolves a token (including the tagname and other attribute names and attribute values) and submits it to the processtoken method of htmltreebuilder for processing. The specific parsing process is as follows:

 

Suppose there are the following HTML files:

<HTML>

<Head>

<LINK rel = "prefetch" type = "text/html" href = "http: // 127.0.0.1/index.html"/>

</Head>

<Body>

Test

</Body>

</Html>

1. the tagname parsed to token is HTML and the type is starttag. It is handed to the processtoken method of htmltreebuilder for processing. processstarttag ----> defaultforinitial ---> setinsertionmode (beforehtmlmode) ---> token (token) ---> Create an HTML element (htmlhtmlelement class) object and m_openelements.pushhtmlhtmlelement ---> node. attach ()
2. parse the token type to character and hand it to the processtoken method of htmltreebuilder for processing. processcharacter (token)
3. the tagname resolved to the token is head, the type is starttag, and is handed over to the processtoken method of htmltreebuilder for processing. processstarttag ----> m_tree.inserthtmlheadelement (token) ---> Create head element (htmlheadelement class) and m_openelements.pushhtmlheadelement ---> node. attach ()
4. parse the token type to character and hand it to the processtoken method of htmltreebuilder for processing. processcharacter (token)
5. the tagname resolved to the token is link and the type is starttag. it is handed over to the processtoken method of htmltreebuilder for processing. processstarttag ---> processstarttagforinhead (token) ---> m_tree.insertselfclosinghtmlelement) ---> Create an object of The Link element (htmllinkelement class) and enter the htmllinkelement class for some actual operations, such as checking attributes and performing related operations based on existing attributes. ---> Node. Attach ()
6. parse the token type to character and hand it to the processtoken method of htmltreebuilder for processing. processcharacter (token)
7. the tagname resolved to the token is head, And the type is endtag. It is handed to the processtoken method of htmltreebuilder for processing. processendtag (token) ---> m_tree.openelements ()-> pophtmlheadelement () ---> setinsertionmode) ---> node. attach ()
8. parse the token type to character and hand it to the processtoken method of htmltreebuilder for processing. processcharacter (token)
9. the tagname resolved to the token is body and the type is starttag. it is handed over to the processtoken method of htmltreebuilder for processing. processstarttag (token) ---> m_framesetok = false ---> creates the body element (htmlbodyelement class) and pushhtmlbodyelement (attachtocurrent (Object of the Body element) ---> attach (currentnode (), body object) ---> node. attach ()
10. the token type is parsed to character and handed to the processtoken method of htmltreebuilder for processing. processcharacter (token) ---> processcharacterbuffer (buffer) ---> obtains the characters value as test ---> m_tree.inserttextnode) ---> attachatsite ---> text: attach () ---> node: createrendererifneeded () ---> node. attach ()
11. the tagname resolved to the token is body, and the type is endtag. The tagname is handed to the processtoken method of htmltreebuilder for processing. processendtag (token) ---> processendtagforinbody (token) ---> processbodyendtagforinbody) ---> setinsertionmode (afterbodymode)
12. parse the token type to character and hand it to the processtoken method of htmltreebuilder for processing. processcharacter (token) ---> processcharacterbuffer ---> m_tree.inserttextnode (characters)
13. The tagname resolved to the token is HTML, the type is endtag, and is handed to the processtoken method of htmltreebuilder for processing. processendtag (token) ---> processendtagforinbody (token) ---> setinsertionmode)
14. parse to the token type as endoffile and hand it to the processtoken method of htmltreebuilder for processing. processendoffile (token) ---> m_tree.openelements ()-> popall () to clear htmlelementstack.

 

I hope it will be useful to you. Currently, few people are engaged in WebKit ~~~.

 

HTML5 A labels attached

 

Attribute Value Description
Charset Char_encoding HTML 5 is not supported.
Coords Coordinates HTML 5 is not supported.
Href URL The target URL of the link.
Hreflang Language_code Specifies the reference language of the target URL. It is used only when the href attribute exists.
Media Media Query

Specifies the media type of the target URL.

Default Value: All. It is used only when the href attribute exists.

Name Section_name HTML 5 is not supported.
REL
  • Alternate
  • Archives
  • Author
  • Bookmark
  • Contact
  • External
  • First
  • Help
  • Icon
  • Index
  • Last
  • License
  • Next
  • Nofollow
  • Noreferrer
  • Pingback
  • Prefetch
  • Prev
  • Search
  • Stylesheet
  • Sidebar
  • Tag
  • Up

Specifies the relationship between the current document and the target URL.

It is used only when the href attribute exists.

Rev Text HTML 5 is not supported.
Shape
  • Default
  • Rect
  • Circle
  • Poly
HTML 5 is not supported.
Target
  • _ Blank
  • _ Parent
  • _ Self
  • _ Top
Where to open the target URL. It is used only when the href attribute exists.
Type Mime_type

Specifies the MIME type of the target URL. It is used only when the href attribute exists.

Note: mime = Multipurpose Internet Mail Extensions.

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.