Chrome Source Analysis 1:content Model

Source: Internet
Author: User

A program can often be simply seen as being composed of model + interactions, and external requests are routed to the model via an interactive interface. Chrome is no exception, in general, Chrome is made up of model content, CONTENT-API, and interactive interfaces (chrome in the image below).



The content model and interaction interface are shown in the following figure. Webcontents represents a Web page that passes a URL to the object that can display the page that corresponds to the URL on the screen. The browser's interactive interface operates webcontents through the Navigationcontroller object. A Web page will contain multiple iframe,webcontents internally maintaining a frametree to represent the frame structure of the Web page. When you let webcontents display a new URL, the Frametree object is not recreated, but instead allows the Frametree root node to render the new URL.


The Frametreenode model and interactive interface are shown in the following figure. Frametreenode represents a frame in the page that is drawn to the display screen. Through the Frametreenode interface navigator. Under the default configuration, Frametreenode is rendered by a separate render. Because the Frametreenode object is maintained by the main process, Frametreenode has an associated renderframehostmanager that is responsible for collapsing process traffic with the rendering process. Renderframehostmanager through Renderframehostmanager: The:D elegate Interface maintains a reference to the webcontents, Renderframehostmanager can create a display area (a piece of memory area) from this interface, and the rendering process will draw the content to be displayed in this display area.


Example Analysis:

When you open a Chrome tab, what does Chrome do (see Chrome::navigate (navigateparams* params) for details. The new tab event handler creates the Webcontents object and then calls Webcontents's Getcontroller (). Loadurlwithparams (const loadurlparams& params) function navigates to the specified URL (note: Getcontroller () The webcontents function gets the Navigationcontrollerimpl object associated with the. The function then forwards the request to Navigationcontrollerimpl::navigatetopendingentry (Reloadtype reload_type) to process "Reload_type value is No_reload".

Each tab of Chrome associates a Webcontents object. When the page is refreshed, the Refresh event handler invokes the webcontents associated Navigationcontroller object's navigationcontrollerimpl::reload (bool check_for_repost) function. The function sets the Pending_entry_ object, and then forwards the request to Navigationcontrollerimpl::navigatetopendingentry (Reloadtype reload_type) to process "reload The _type value is reload ".

Navigationcontrollerimpl::navigatetopendingentry (Reloadtype reload_type) process is: Get frametree root node call frame-> Navigator ()->navigatetopendingentry (frame, *frame_entry,reload_type, false). Navigator () Gets the interactive Interface navigator object for Frametreenode.

The Navigatorimpl::navigatetopendingentry function calls Renderframehostmanager::navigate to navigate the current page to the specified URL. Instead, Renderframehostmanager::navigate notifies the rendering process to render the specified URL through the collapse process communication mechanism.

Postscript

Just graduated into the company engaged in the back-end development, wrote six months of Java code, deeply the team's back-end system design thinking is too outdated, make the system expansion difficult, code repetition rate is high, maintainability poor. Then into the front-end development, the front-end development is inseparable from chrome, personal more like to explore internal details, so download the chromium source code, explore chrome structure, operation mechanism;

familiar with chrome internal mechanism to better optimize the page;

The development of chrome also affects the way apps are developed. Chrome's development can give the Web application more native API, so that once the need to use a cumbersome app to achieve the functionality of the use of HTML+JS can be achieved, enhance the dynamic ability of the app. Learn about Chrome's source code and get to know the latest developments in chrome and become a participant in Chrome's trends.

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.