Page display method, device, electronic device and readable storage medium
By using two threads to process tasks in parallel during the page display process, the problem in the existing technology that the page display speed is not significantly improved is solved, and a faster page display effect is achieved.
Patent Information
- Application Number
- CN202010615005.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2020-06-30
- Publication Date
- 2024-08-30
- Estimated Expiration
- 2040-08-30
AI Technical Summary
The existing technology has no obvious effect in improving the page display speed, mainly because multiple tasks still need to be performed in series during the page display process, resulting in limited overall speed improvement.
Two threads are used to perform tasks in the page display process in parallel. One thread is used to build the rendering tree, and the other thread is used for network data acquisition and DNS resolution. Parallel processing reduces the serial dependence of the task links.
The page display speed is significantly improved. Compared with traditional methods, the page can be displayed faster and the page opening time is reduced.
Smart Images

Figure CN111859215B
Abstract
Description
Technical Field
[0001] The present application belongs to the technical field of page display, and specifically relates to a page display method, device, electronic device and readable storage medium. Background Art
[0002] In order to display activities, products and other information in a rich manner, web pages (eg, Hypertext Markup Language (HTML) 5 pages) are often used as carriers of such information. However, the page opening speed, that is, the page display speed, is relatively slow.
[0003] Since the entire display process of the page requires multiple tasks to be performed in series, the relevant technologies have been optimized and accelerated for some of these tasks, such as Domain Name System (DNS) resolution optimization (the interface is consistent with the main domain name of the web page), lazy loading of images, etc.
[0004] In the process of implementing this application, the inventors found that there are at least the following problems in the related technology:
[0005] Although the relevant technology can improve the display speed of the page to a certain extent, the improvement in display speed is not obvious.
[0006] Therefore, how to display pages more quickly is a technical problem that those skilled in the art need to solve urgently. Summary of the invention
[0007] The purpose of the embodiments of the present application is to provide a page display method, device, electronic device and readable storage medium, which can display pages more quickly.
[0008] In order to solve the above technical problems, this application is implemented as follows:
[0009] In a first aspect, an embodiment of the present application provides a page display method, comprising:
[0010] receiving a first input from a user;
[0011] In response to the first input, based on the first thread, a first rendering tree is constructed using a preset file; at the same time, based on the second thread, a network data acquisition request is sent to the network server, and network data sent by the network server is received; wherein the network data is data sent by the network server in response to the network data acquisition request;
[0012] Rendering the first rendering tree according to the network data to obtain a target rendering tree;
[0013] Based on the target render tree, a page associated with the first input is displayed.
[0014] Optionally, the preset file is an HTML file, and before constructing the first rendering tree based on the first thread using the preset file, the method further includes:
[0015] Receive the HTML file sent by the server.
[0016] Optionally, when the HTML file includes HTML tags and Cascading Style Sheets (CSS) tags, a first rendering tree is constructed using a preset file, including:
[0017] Convert HTML tags into a Document Object Model (DOM) tree;
[0018] Convert CSS tags into a Cascading Style Sheets ObjectModel (CSSOM) tree;
[0019] Merge the DOM tree and the CSSOM tree to get the first rendering tree.
[0020] Optionally, based on the second thread, sending a network data acquisition request to a network server and receiving network data sent by the network server include:
[0021] Performing Domain Name System (DNS) resolution based on the second thread to obtain the Internet Protocol (IP) address of the network server;
[0022] Based on the IP address, multiple network data acquisition requests are sent to the network server;
[0023] Receive network data corresponding to each network data acquisition request.
[0024] Optionally, rendering the first rendering tree according to the network data to obtain a target rendering tree includes:
[0025] Each time a piece of network data is received, a node of the first rendering tree is rendered according to the network data until all network data are received to obtain a target rendering tree.
[0026] Optionally, based on the target rendering tree, displaying a page associated with the first input includes:
[0027] Based on the target rendering tree, determine the location information of each node;
[0028] Based on the position information of each node, draw each node to obtain a page associated with the first input;
[0029] Display the page.
[0030] In a second aspect, an embodiment of the present application provides a page display device, including:
[0031] A first receiving module, used to receive a first input from a user;
[0032] The acquisition module is used to respond to the first input, build a first rendering tree based on the first thread using a preset file; at the same time, based on the second thread, send a network data acquisition request to the network server, and receive network data sent by the network server; wherein the network data is data sent by the network server in response to the network data acquisition request;
[0033] A rendering module, used to render the first rendering tree according to the network data to obtain a target rendering tree;
[0034] The display module is configured to display a page associated with the first input based on the target rendering tree.
[0035] Optionally, the preset file is an HTML file, and the device further includes:
[0036] The second receiving module is used to receive the HTML file sent by the server.
[0037] Optionally, when the HTML file includes HTML tags and CSS tags, the modules are obtained, including:
[0038] A first conversion unit, used to convert HTML tags into a DOM tree;
[0039] A second conversion unit, configured to convert the CSS markup into a CSSOM tree;
[0040] The merging unit is used to merge the DOM tree and the CSSOM tree to obtain a first rendering tree.
[0041] Optionally, obtain modules, including:
[0042] A resolution unit, configured to perform DNS resolution based on the second thread to obtain an IP address of a network server;
[0043] A sending unit, used for sending multiple network data acquisition requests to a network server based on an IP address;
[0044] The receiving unit is used to receive the network data corresponding to each network data acquisition request.
[0045] Optional, rendering module, including:
[0046] The rendering unit is used for rendering a node of the first rendering tree according to the network data each time a network data is received until all the network data are received to obtain a target rendering tree.
[0047] Optional, display module, including:
[0048] A determination unit, used to determine the position information of each node based on the target rendering tree;
[0049] A drawing unit, used for drawing each node based on the position information of each node to obtain a page associated with the first input;
[0050] The display unit is used to display pages.
[0051] In a third aspect, an embodiment of the present application provides an electronic device, which includes a processor, a memory, and a program or instruction stored in the memory and executable on the processor, and when the program or instruction is executed by the processor, the steps of the page display method described in the first aspect are implemented.
[0052] In a fourth aspect, an embodiment of the present application provides a readable storage medium, on which a program or instruction is stored, and when the program or instruction is executed by a processor, the steps of the page display method described in the first aspect are implemented.
[0053] In a fifth aspect, an embodiment of the present application provides a chip, the chip including a processor and a communication interface, the communication interface is coupled to the processor, and the processor is used to run a program or instruction to implement the page display method as described in the first aspect.
[0054] In an embodiment of the present application, in response to the first input, two threads are used to perform the task links in the page display process in parallel, that is, based on the first thread, a first rendering tree is constructed using a preset file; at the same time, based on the second thread, a network data acquisition request is sent to the network server, and the network data sent by the network server is received. Although the related art optimizes and speeds up some task links in the entire display process of the page, it still needs to perform multiple task links in series. In this way, compared with the related art, the embodiment of the present application can display pages faster. BRIEF DESCRIPTION OF THE DRAWINGS
[0055] Figure 1 It is a schematic diagram of a series of task links displayed on a page provided in an embodiment of the present application;
[0056] Figure 2 It is a flow chart of a page display method provided in an embodiment of the present application;
[0057] Figure 3 It is a flowchart of an HTML5 page display method provided in an embodiment of the present application;
[0058] Figure 4 is a structural schematic diagram of a page display device provided in an embodiment of the present application;
[0059] Figure 5 It is a structural schematic diagram of an electronic device provided in an embodiment of the present application;
[0060] Figure 6 It is a schematic diagram of the structure of another electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0061] The following will be combined with the drawings in the embodiments of the present application to clearly and completely describe the technical solutions in the embodiments of the present application. Obviously, the described embodiments are part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this application.
[0062] The terms "first", "second", etc. in the specification and claims of the present application are used to distinguish similar objects, and are not used to describe a specific order or sequence. It should be understood that the data used in this way can be interchangeable under appropriate circumstances, so that the embodiments of the present application can be implemented in an order other than those illustrated or described here, and the objects distinguished by "first", "second", etc. are generally of one type, and the number of objects is not limited. For example, the first object can be one or more. In addition, "and / or" in the specification and claims represents at least one of the connected objects, and the character " / " generally indicates that the objects associated with each other are in an "or" relationship.
[0063] Based on the background technology, the entire display process of the page requires multiple task links to be performed in series. Figure 1 As shown in the figure, the entire display process of a page usually requires a series of tasks such as prompt uninstall, redirect, uninstall, application (Application, APP) cache, domain name resolution, transmission control protocol (Transmission Control Protocol, TCP) connection, request, response, processing, DOM content loaded and loading. Therefore, the time it takes for a page to be fully opened is Figure 1 The sum of the time periods corresponding to all task links in the task chain.
[0064] based on Figure 1 , and explain some of the states:
[0065] DNS query time: domain lookup start to domain lookup end (domainLookupStart-domainLookupEnd);
[0066] TCP connection time: connection start to connection end (connectStart-connectEnd);
[0067] Request time: request start to response end (requestStart-responseEnd);
[0068] Time-consuming to parse the DOM tree: DOM interaction to DOM completion (domInteractive-domComplete);
[0069] White screen time: domain lookup start to response start (domainLookupStart-responseStart);
[0070] User operable time: domain lookup starts to dom content loading event ends (domainLookupStart-domContentloadedEventEnd);
[0071] Total download time: load event start to load event end (loadEventStart - loadEventEnd).
[0072] At present, relevant technologies have optimized and accelerated some of the task links, such as DNS resolution optimization and lazy loading of images. Although relevant technologies can improve the display speed of pages to a certain extent, they still require multiple task links to be connected in series, so the display speed improvement is not obvious.
[0073] The applicant has found through research that in order to display a page more quickly, in response to the user's first input, two threads are used to perform the task links in the page display process in parallel, that is, based on the first thread, a first rendering tree is constructed using a preset file; at the same time, based on the second thread, a network data acquisition request is sent to the network server, and the network data sent by the network server is received. Since two threads are used to perform the task links in the page display process in parallel, the page can be displayed more quickly.
[0074] The page display method provided in the embodiment of the present application is described in detail below through specific embodiments and application scenarios in conjunction with the accompanying drawings.
[0075] Figure 2 is a flow chart of a page display method provided by an embodiment of the present application, such as Figure 2 As shown, the page display method may include:
[0076] S210: Receive a first input from a user.
[0077] S220. In response to the first input, based on the first thread, build a first rendering tree using a preset file; at the same time, based on the second thread, send a network data acquisition request to the network server, and receive the network data sent by the network server; wherein the network data is the data sent by the network server in response to the network data acquisition request.
[0078] See also Figure 1 , Figure 1 The entire display process of the page shown includes two parts, A and B. Part A is the process of building a first rendering tree using a preset file, and part B is the process of sending a network data acquisition request to a network server and receiving network data sent by the network server. Since there is no restriction on the execution order of parts A and B, part B does not need to wait for the execution of part A to be completed before proceeding, so two threads can be used to execute parts A and B respectively, so as to achieve the purpose of improving the page display speed.
[0079] For example, if the time taken to construct the first rendering tree using the preset file is T1 (unit: ms), and two threads are used to perform parts A and B respectively, the entire page display time can be reduced by T1.
[0080] Among them, the preset file can be an HTML file, a MarkDown file, etc., which is not specifically limited in the embodiment of the present application.
[0081] S230: Render the first rendering tree according to the network data to obtain a target rendering tree.
[0082] S240: Display a page associated with the first input based on the target rendering tree.
[0083] The page display method, in response to the user's first input, uses two threads to perform the task links in the page display process in parallel, that is, based on the first thread, a first rendering tree is constructed using a preset file; at the same time, based on the second thread, a network data acquisition request is sent to the network server, and the network data sent by the network server is received. Although the related art optimizes and speeds up some task links in the entire display process of the page, it still needs to perform multiple task links in series. In this way, compared with the related art, the page display method provided in the embodiment of the present application can display pages more quickly.
[0084] In order to display the page more quickly, in one embodiment, when the preset file is an HTML file, before constructing the first rendering tree based on the first thread using the preset file, the method may further include:
[0085] Receive the HTML file sent by the server.
[0086] It is understandable that, since the HTML file is obtained from the server in advance, it is not necessary to temporarily obtain it from the server when constructing the first rendering tree, thereby being able to display the HTML page corresponding to the HTML file more quickly. Optionally, the HTML page may be an HTML5 page.
[0087] In order to improve the efficiency of building the rendering tree, in one embodiment, when the HTML file may include HTML tags and Cascading Style Sheet (CSS) tags, building the first rendering tree using a preset file may include:
[0088] Convert HTML tags into DOM tree;
[0089] Convert CSS markup into a CSSOM tree;
[0090] Merge the DOM tree and the CSSOM tree to get the first rendering tree.
[0091] HTML tags and CSS tags are the beginning and ending marks containing attributes, which are used to mark HTML files. Since the DOM tree and the CSSOM tree are both independent data structures, the HTML tags are first converted into the DOM tree and the CSS tags are converted into the CSSOM tree, and then the DOM tree and the CSSOM tree are merged to obtain the first rendering tree, which can improve the construction efficiency of the rendering tree.
[0092] In order to improve the efficiency of obtaining network data, in one embodiment, the above-mentioned sending a network data obtaining request to a network server based on the second thread and receiving the network data sent by the network server may include:
[0093] Perform DNS resolution based on the second thread to obtain the IP address of the network server;
[0094] Based on the IP address, multiple network data acquisition requests are sent to the network server;
[0095] Receive network data corresponding to each network data acquisition request.
[0096] In this embodiment, multiple network data acquisition requests can be sent to the network server in parallel, so the efficiency of acquiring network data can be improved.
[0097] In order to improve rendering efficiency, in one embodiment, step S230 may include:
[0098] Each time a piece of network data is received, a node of the first rendering tree is rendered according to the network data until all network data are received to obtain a target rendering tree.
[0099] In this embodiment, each time a network data is received, a node of the first rendering tree is rendered according to the network data. That is, in the process of receiving multiple network data, the first rendering tree is continuously rendered, that is, a continuous rendering operation is performed, which can improve rendering efficiency.
[0100] For example, if the network request time in the related art is T2 and the time taken to render the first rendering tree is T3, then this embodiment can reduce the entire page display time by T2 by performing continuous rendering operations on the rendering tree.
[0101] In order to ensure that the page display is not chaotic, in one embodiment, step S240 may include:
[0102] Based on the target rendering tree, determine the location information of each node;
[0103] Based on the position information of each node, draw each node to obtain a page associated with the first input;
[0104] Display the page.
[0105] This embodiment first determines the position information of each node based on the target rendering tree, and then draws each node based on the position information of each node, which can ensure that there is no deviation in node drawing, and further ensure that there is no confusion in page display.
[0106] The above content is specifically described below by taking the display process of an HTML5 page as an example.
[0107] like Figure 3 As shown, the display process of the HTML5 page may include:
[0108] S301. Obtain the HTML file sent by the server.
[0109] The HTML file is sent by the server, and the client application (Application, APP) caches the HTML file to the local end.
[0110] S302: Receive user input for opening an HTML5 page.
[0111] S303: Construct a first rendering tree using the HTML file.
[0112] Receive input from the user to open the HTML5 page, use the web view (WebView) to initialize the rendering tree, and WebView can preload the rendering tree by loading the HTML file and the files that must be requested in the HTML file until the rendering tree is initialized and the constructed rendering tree is obtained.
[0113] S304: Send a network data acquisition request to the network server, and receive the network data sent by the network server.
[0114] Step S304 is synchronized with step S303, WebView performs DNS resolution to obtain the IP address of the network server; based on the IP address, multiple network data acquisition requests are sent to the network server; and network data corresponding to each network data acquisition request is received.
[0115] S305 , each time a piece of network data is received, a node of the first rendering tree is rendered according to the network data until all network data are received to obtain a target rendering tree.
[0116] Each time a network data is received, a node of the first rendering tree is rendered according to the network data, that is, the rendering tree is parsed for the node. In other words, in the process of receiving multiple network data, the first rendering tree is continuously rendered, that is, a continuous rendering operation is performed.
[0117] S306: Displaying an HTML5 page based on the target rendering tree.
[0118] In this embodiment, two threads are used to perform step S303 and step S304 simultaneously, and the HTML file is obtained in advance in step S301, and a continuous rendering operation is performed in step S305, so that the HTML5 page can be displayed more quickly.
[0119] It should be noted that the page display method provided in the embodiment of the present application can be executed by a page display device or a control module in the page display device for executing the page display method. In the embodiment of the present application, the page display device provided in the embodiment of the present application is described by taking the page display device executing the page display method as an example.
[0120] The page display device provided in the embodiment of the present application is as follows: Figure 4 As shown, the page display device may include:
[0121] The first receiving module 401 is used to receive a first input from a user;
[0122] The acquisition module 402 is used to respond to the first input, build a first rendering tree based on the first thread using a preset file; at the same time, based on the second thread, send a network data acquisition request to the network server, and receive network data sent by the network server; wherein the network data is data sent by the network server in response to the network data acquisition request;
[0123] A rendering module 403, configured to render the first rendering tree according to the network data to obtain a target rendering tree;
[0124] The display module 404 is configured to display a page associated with the first input based on the target rendering tree.
[0125] The page display device, in response to the user's first input, uses two threads to perform the task links in the page display process in parallel, that is, based on the first thread, a first rendering tree is constructed using a preset file; at the same time, based on the second thread, a network data acquisition request is sent to the network server, and the network data sent by the network server is received. Although the related art optimizes and speeds up some task links in the entire display process of the page, it still needs to perform multiple task links in series. In this way, compared with the related art, the page display device provided in the embodiment of the present application can display pages more quickly.
[0126] Optionally, in one embodiment, the preset file is an HTML file, and the device may further include:
[0127] The second receiving module is used to receive the HTML file sent by the server.
[0128] Since the HTML file is obtained from the server in advance, it does not need to be temporarily obtained from the server when constructing the first rendering tree, so that the HTML page corresponding to the HTML file can be displayed more quickly.
[0129] Optionally, in one embodiment, when the HTML file may include HTML tags and CSS tags, the acquisition module 402 may include: a first conversion unit, configured to convert the HTML tags into a document object model DOM tree;
[0130] A second conversion unit, configured to convert the CSS markup into a Cascading Style Sheet Object Model CSSOM tree;
[0131] The merging unit is used to merge the DOM tree and the CSSOM tree to obtain a first rendering tree.
[0132] HTML tags and CSS tags are the beginning and ending marks containing attributes, which are used to mark HTML files. Since the DOM tree and the CSSOM tree are both independent data structures, the HTML tags are first converted into the DOM tree and the CSS tags are converted into the CSSOM tree, and then the DOM tree and the CSSOM tree are merged to obtain the first rendering tree, which can improve the construction efficiency of the rendering tree.
[0133] Optionally, in one embodiment, the acquisition module 402 may include:
[0134] A resolution unit, configured to perform DNS resolution based on the second thread to obtain an IP address of a network server;
[0135] A sending unit, used for sending multiple network data acquisition requests to a network server based on an IP address;
[0136] The receiving unit is used to receive the network data corresponding to each network data acquisition request.
[0137] In this embodiment, multiple network data acquisition requests can be sent to the network server in parallel, so the efficiency of acquiring network data can be improved.
[0138] Optionally, in one embodiment, the rendering module 403 may include:
[0139] The rendering unit is used for rendering a node of the first rendering tree according to the network data each time a network data is received until all the network data are received to obtain a target rendering tree.
[0140] In this embodiment, each time a network data is received, a node of the first rendering tree is rendered according to the network data. That is, in the process of receiving multiple network data, the first rendering tree is continuously rendered, that is, a continuous rendering operation is performed, which can improve rendering efficiency.
[0141] Optionally, in one embodiment, the display module 404 may include:
[0142] A determination unit, used to determine the position information of each node based on the target rendering tree;
[0143] A drawing unit, used for drawing each node based on the position information of each node to obtain a page associated with the first input;
[0144] The display unit is used to display pages.
[0145] This embodiment first determines the position information of each node based on the target rendering tree, and then draws each node based on the position information of each node, which can ensure that there is no deviation in node drawing, and further ensure that there is no confusion in page display.
[0146] The page display device in the embodiment of the present application can be a device, or a component, integrated circuit, or chip in a terminal. The device can be a mobile electronic device or a non-mobile electronic device. Exemplarily, the mobile electronic device can be a mobile phone, a tablet computer, a laptop computer, a PDA, an in-vehicle electronic device, a wearable device, an ultra-mobile personal computer (UMPC), a netbook, or a personal digital assistant (PDA), etc. The non-mobile electronic device can be a server, a network attached storage (NAS), a personal computer (PC), a television (TV), a teller machine or a self-service machine, etc., which is not specifically limited in the embodiment of the present application.
[0147] The page display device in the embodiment of the present application may be a device having an operating system. The operating system may be an Android operating system, an iOS operating system, or other possible operating systems, which are not specifically limited in the embodiment of the present application.
[0148] The page display device provided in the embodiment of the present application can achieve Figure 2 To avoid repetition, the various processes implemented in the method embodiment will not be described again here.
[0149] Optional, such as Figure 5 As shown, the embodiment of the present application also provides an electronic device 500, which may include a processor 501, a memory 502, and a program or instruction stored in the memory 502 and executable on the processor 501. When the program or instruction is executed by the processor 501, each process of the above-mentioned page display method embodiment is implemented, and the same technical effect can be achieved. To avoid repetition, it will not be repeated here.
[0150] It should be noted that the electronic devices in the embodiments of the present application may include the mobile electronic devices and non-mobile electronic devices mentioned above.
[0151] Figure 6 A schematic diagram of the hardware structure of an electronic device to implement an embodiment of the present application.
[0152] The electronic device 600 may include but is not limited to: a radio frequency unit 601, a network module 602, an audio output unit 603, an input unit 604, a sensor 605, a display unit 606, a user input unit 607, an interface unit 608, a memory 609, and a processor 610 and other components.
[0153] Those skilled in the art will appreciate that the electronic device 600 may also include a power source (such as a battery) for supplying power to each component, and the power source may be logically connected to the processor 610 through a power management system, thereby implementing functions such as managing charging, discharging, and power consumption management through the power management system. Figure 6 The electronic device structure shown in the figure does not constitute a limitation on the electronic device. The electronic device may include more or fewer components than shown in the figure, or combine certain components, or arrange the components differently, which will not be described in detail here.
[0154] The user input unit 607 is used to receive a first input from a user;
[0155] The processor 610 is configured to construct a first rendering tree using a preset file based on a first thread in response to a first input; and render the first rendering tree according to network data to obtain a target rendering tree;
[0156] The radio frequency unit 601 is used to send a network data acquisition request to the network server based on the second thread, and receive network data sent by the network server; wherein the network data is data sent by the network server in response to the network data acquisition request;
[0157] The display unit 606 is configured to display a page associated with the first input based on the target rendering tree.
[0158] In response to the user's first input, two threads are used to perform the task links in the page display process in parallel, that is, based on the first thread, a first rendering tree is constructed using a preset file; at the same time, based on the second thread, a network data acquisition request is sent to the network server, and the network data sent by the network server is received. Although the related art optimizes and speeds up some task links in the entire page display process, it still needs to perform multiple task links in series. In this way, compared with the related art, the page can be displayed faster.
[0159] Optionally, in one embodiment, the radio frequency unit 601 is used to receive an HTML file sent by the server.
[0160] Since the HTML file is obtained from the server in advance, it does not need to be temporarily obtained from the server when constructing the first rendering tree, so that the HTML page corresponding to the HTML file can be displayed more quickly.
[0161] Optionally, in one embodiment, the processor 610 is used to convert HTML tags into a document object model DOM tree; convert CSS tags into a cascading style sheet object model CSSOM tree; merge the DOM tree and the CSSOM tree to obtain a first rendering tree.
[0162] HTML tags and CSS tags are the beginning and ending marks containing attributes, which are used to mark HTML files. Since the DOM tree and the CSSOM tree are both independent data structures, the HTML tags are first converted into the DOM tree and the CSS tags are converted into the CSSOM tree, and then the DOM tree and the CSSOM tree are merged to obtain the first rendering tree, which can improve the construction efficiency of the rendering tree.
[0163] Optionally, in one embodiment, the processor 610 is configured to perform DNS resolution based on the second thread to obtain an IP address of the network server;
[0164] The radio frequency unit 601 is used to send multiple network data acquisition requests to the network server based on the IP address; and receive network data corresponding to each network data acquisition request.
[0165] In this embodiment, multiple network data acquisition requests can be sent to the network server in parallel, so the efficiency of acquiring network data can be improved.
[0166] Optionally, in one embodiment, the processor 610 is configured to render a node of the first rendering tree according to the network data each time a piece of network data is received until all the network data is received to obtain a target rendering tree.
[0167] Each time a network data is received, a node of the first rendering tree is rendered according to the network data. That is, in the process of receiving multiple network data, the first rendering tree is continuously rendered, that is, continuous rendering operation is performed, which can improve rendering efficiency.
[0168] Optionally, in one embodiment, the processor 610 is configured to determine the position information of each node based on the target rendering tree; draw each node based on the position information of each node to obtain a page associated with the first input;
[0169] The display unit 606 is used to display pages.
[0170] This embodiment first determines the position information of each node based on the target rendering tree, and then draws each node based on the position information of each node, which can ensure that there is no deviation in node drawing, and further ensure that there is no confusion in page display.
[0171] It should be understood that in the embodiment of the present application, the input unit 604 may include a graphics processor (Graphics Processing Unit, GPU) 6041 and a microphone 6042, and the graphics processor 6041 processes the image data of the static picture or video obtained by the image capture device (such as a camera) in the video capture mode or the image capture mode. The display unit 606 may include a display panel 6061, and the display panel 6061 may be configured in the form of a liquid crystal display, an organic light emitting diode, etc. The user input unit 607 may include a touch panel 6071 and other input devices 6072. The touch panel 6071 is also called a touch screen. The touch panel 6071 may include two parts: a touch detection device and a touch controller. Other input devices 6072 include but are not limited to physical keyboards, function keys (such as volume control buttons, switch buttons, etc.), trackballs, mice, and joysticks, which are not repeated here. The memory 609 can be used to store software programs and various data, including but not limited to applications and operating systems. The processor 610 can integrate an application processor and a modem processor, wherein the application processor mainly processes the operating system, the user interface, and the application program, and the modem processor mainly processes wireless communication. It is understandable that the above-mentioned modem processor may not be integrated into the processor 610.
[0172] An embodiment of the present application also provides a readable storage medium, on which a program or instruction is stored. When the program or instruction is executed by a processor, each process of the above-mentioned page display method embodiment is implemented, and the same technical effect can be achieved. To avoid repetition, it will not be repeated here.
[0173] The processor is a processor in the electronic device described in the above embodiment. The readable storage medium may include a computer readable storage medium, such as a computer read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk.
[0174] An embodiment of the present application further provides a chip, which may include a processor and a communication interface, wherein the communication interface is coupled to the processor, and the processor is used to run programs or instructions to implement the various processes of the above-mentioned page display method embodiment, and can achieve the same technical effect. To avoid repetition, it will not be repeated here.
[0175] It should be understood that the chip mentioned in the embodiments of the present application can also be called a system-level chip, a system chip, a chip system or a system-on-chip chip, etc.
[0176] It should be noted that, in this article, the terms "comprise", "include" or any other variant thereof are intended to cover non-exclusive inclusion, so that the process, method, article or device including a series of elements includes not only those elements, but also includes other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, the elements defined by the sentence "comprise one..." do not exclude the presence of other identical elements in the process, method, article or device including the element. In addition, it should be pointed out that the scope of the methods and devices in the embodiments of the present application is not limited to performing functions in the order shown or discussed, and may also include performing functions in a substantially simultaneous manner or in reverse order according to the functions involved, for example, the described method may be performed in an order different from that described, and various steps may also be added, omitted, or combined. In addition, the features described with reference to certain examples may be combined in other examples.
[0177] Through the description of the above implementation methods, those skilled in the art can clearly understand that the above-mentioned embodiment methods can be implemented by means of software plus a necessary general hardware platform, and of course by hardware, but in many cases the former is a better implementation method. Based on such an understanding, the technical solution of the present application, or the part that contributes to the prior art, can be embodied in the form of a software product, which is stored in a storage medium (such as ROM / RAM, a magnetic disk, or an optical disk), and can include a number of instructions to enable a terminal (which can be a mobile phone, a computer, a server, an air conditioner, or a network device, etc.) to execute the methods described in each embodiment of the present application.
[0178] The embodiments of the present application are described above in conjunction with the accompanying drawings, but the present application is not limited to the above-mentioned specific implementation methods. The above-mentioned specific implementation methods are merely illustrative and not restrictive. Under the guidance of the present application, ordinary technicians in this field can also make many forms without departing from the purpose of the present application and the scope of protection of the claims, all of which are within the protection of the present application.
Claims
1. A page display method, It is characterized in that include: receiving a first input from a user; In response to the first input, based on the first thread, construct a first rendering tree using a preset file; At the same time, based on the second thread, a network data acquisition request is sent to the network server, and network data sent by the network server is received; wherein the network data is data sent by the network server in response to the network data acquisition request; Rendering the first rendering tree according to the network data to obtain a target rendering tree; Based on the target rendering tree, displaying a page associated with the first input; Wherein, based on the second thread, sending a network data acquisition request to a network server and receiving network data sent by the network server includes: Performing a Domain Name System (DNS) resolution based on the second thread to obtain an Internet Protocol (IP) address of the network server; Based on the IP address, sending a plurality of network data acquisition requests to the network server in parallel; Receiving network data corresponding to each of the network data acquisition requests; The rendering of the first rendering tree according to the network data to obtain a target rendering tree includes: Each time a piece of the network data is received, a node of the first rendering tree is rendered according to the network data until all the network data are received to obtain the target rendering tree.
2. The page display method according to claim 1, It is characterized in that The preset file is a hypertext markup language HTML file. Before constructing the first rendering tree based on the first thread using the preset file, the method further includes: Receive the HTML file sent by the server.
3. The page display method according to claim 2, It is characterized in that When the HTML file includes HTML tags and Cascading Style Sheet (CSS) tags, the step of constructing a first rendering tree using a preset file includes: Convert the HTML markup into a Document Object Model (DOM) tree; Convert the CSS markup into a Cascading Style Sheet Object Model (CSSOM) tree; The DOM tree and the CSSOM tree are merged to obtain the first rendering tree.
4. The page display method according to claim 1, It is characterized in that The displaying a page associated with the first input based on the target rendering tree includes: Based on the target rendering tree, determining position information of each of the nodes; Based on the position information of each of the nodes, draw each of the nodes to obtain a page associated with the first input; The page is displayed.
5. A page display device, It is characterized in that include: A first receiving module, used to receive a first input from a user; an acquisition module, configured to construct a first rendering tree using a preset file based on a first thread in response to the first input; and at the same time, based on a second thread, send a network data acquisition request to a network server and receive network data sent by the network server; wherein the network data is data sent by the network server in response to the network data acquisition request; A rendering module, configured to render the first rendering tree according to the network data to obtain a target rendering tree; A display module, configured to display a page associated with the first input based on the target rendering tree; The acquisition module comprises: A resolution unit, configured to perform a Domain Name System (DNS) resolution based on the second thread to obtain an Internet Protocol (IP) address of the network server; A sending unit, configured to send a plurality of network data acquisition requests to the network server in parallel based on the IP address; A receiving unit, configured to receive network data corresponding to each network data acquisition request; The rendering module is specifically configured to render a node of the first rendering tree according to the network data each time the network data is received, until all the network data are received to obtain the target rendering tree.
6. The page display device according to claim 5, It is characterized in that The preset file is a hypertext markup language HTML file, and the device also includes: The second receiving module is used to receive the HTML file sent by the server.
7. The page display device according to claim 6, It is characterized in that When the HTML file includes HTML tags and Cascading Style Sheet (CSS) tags, the acquisition module includes: A first conversion unit, used for converting the HTML tag into a document object model DOM tree; A second conversion unit, configured to convert the CSS markup into a Cascading Style Sheet Object Model CSSOM tree; A merging unit is used to merge the DOM tree and the CSSOM tree to obtain the first rendering tree.
Citation Information
Patent Citations
Method, apparatus, storage medium and electronic device for displaying application page
CN109388453A
