CN111783019A - Browser sub-page creation method and device, computer equipment and storage medium - Google Patents

Browser sub-page creation method and device, computer equipment and storage medium Download PDF

Info

Publication number
CN111783019A
CN111783019A CN202010772290.7A CN202010772290A CN111783019A CN 111783019 A CN111783019 A CN 111783019A CN 202010772290 A CN202010772290 A CN 202010772290A CN 111783019 A CN111783019 A CN 111783019A
Authority
CN
China
Prior art keywords
page
sub
browser
thread
creating
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202010772290.7A
Other languages
Chinese (zh)
Inventor
陈嘉鹏
梁百怡
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Tencent Technology Shenzhen Co Ltd
Original Assignee
Tencent Technology Shenzhen Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Tencent Technology Shenzhen Co Ltd filed Critical Tencent Technology Shenzhen Co Ltd
Priority to CN202010772290.7A priority Critical patent/CN111783019A/en
Publication of CN111783019A publication Critical patent/CN111783019A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/90Details of database functions independent of the retrieved data types
    • G06F16/95Retrieval from the web
    • G06F16/958Organisation or management of web site content, e.g. publishing, maintaining pages or automatic linking
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/90Details of database functions independent of the retrieved data types
    • G06F16/95Retrieval from the web
    • G06F16/957Browsing optimisation, e.g. caching or content distillation

Landscapes

  • Engineering & Computer Science (AREA)
  • Databases & Information Systems (AREA)
  • Theoretical Computer Science (AREA)
  • Data Mining & Analysis (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • User Interface Of Digital Computer (AREA)

Abstract

The application relates to a browser sub-page creation method, a browser sub-page creation device, computer equipment and a storage medium, wherein the method comprises the steps of obtaining a sub-page creation request corresponding to a browser component in an application; calling a sub-page callback interface in a main thread of a browser component according to the sub-page creation request, and creating a page instance of the sub-page; when the creation of the page instance of the sub-page is completed, creating a window interface of the sub-page through a user interface thread of the application; and creating a browser sub-page based on the page instance of the sub-page and the window interface of the sub-page. According to the browser sub-page creating method and device, the sub-page instances of the required browser sub-pages are directly generated in the main thread of the browser component only through the sub-page callback interface, but the interface elements of the user interface are not operated, the interface elements of the user interface are operated in the user interface thread, the sub-page instances are separated from the sub-page window to create the browser sub-pages, and thread safety during browser sub-page creating can be effectively guaranteed.

Description

Browser sub-page creation method and device, computer equipment and storage medium
Technical Field
The present application relates to the field of computer technologies, and in particular, to a method and an apparatus for creating a browser sub-page, a computer device, and a storage medium.
Background
With the development of computer technology, browser component technology has emerged, and browsers are application programs used to retrieve, present, and deliver Web information resources. And the browser component is used for adding browser functions to the application program. Most of the browser components for desktop applications in the market are mostly Cef (chrome Embedded Framework) used at present. Cef is an open source browser control based on the Google chrome project. Using this component developers can add Web browsing functionality to their applications.
When the child page window is popped up by the Cef, the callback of the corresponding callback function is triggered in the main thread of the Cef, the client parameter is used as an example of the child window, the client parameter needs to be synchronously returned to the parent window in the callback function, and otherwise, the parent page and the child page cannot communicate. However, when the UI (User Interface) thread of the application program and the main thread of the Cef are not the same thread, since the Interface windows are maintained in the UI thread, if the page windows are synchronously popped up in the callback function, a series of thread safety problems will be caused.
In the prior art, a sub-page window can be created and displayed synchronously in the Cef main thread, the scheme needs to operate a UI object in the Cef main thread, but the Cef main thread may throw messages to the UI thread to process, and the UI thread may wait for the Cef main thread to process some logic, so that a deadlock safety problem can be caused.
Disclosure of Invention
In view of the foregoing, it is necessary to provide a browser sub-page creation method, an apparatus, a computer device, and a storage medium, which can effectively ensure thread security when creating a browser sub-page.
A browser sub-page creation method, the method comprising:
acquiring a sub-page creation request corresponding to a browser component in an application;
calling a sub-page callback interface in a main thread of the browser component according to the sub-page creation request, and creating a page instance of a sub-page;
when the creation of the page instance of the sub-page is completed, creating a window interface of the sub-page through a user interface thread of the application;
and creating a browser sub-page based on the page example of the sub-page and the window interface of the sub-page.
An apparatus for creating a browser sub-page, the apparatus comprising:
the request acquisition module is used for acquiring a sub-page creation request corresponding to a browser component in an application;
the instance creating module is used for calling a sub-page callback interface in a main thread of the browser component according to the sub-page creating request and creating a page instance of a sub-page;
the window creating module is used for creating a window interface of the sub-page through the user interface thread of the application when the creation of the page instance of the sub-page is completed;
and the sub-page creating module is used for creating the browser sub-page based on the page example of the sub-page and the window interface of the sub-page.
A computer device comprising a memory and a processor, the memory storing a computer program, the processor implementing the following steps when executing the computer program:
acquiring a sub-page creation request corresponding to a browser component in an application;
calling a sub-page callback interface in a main thread of the browser component according to the sub-page creation request, and creating a page instance of a sub-page;
when the creation of the page instance of the sub-page is completed, creating a window interface of the sub-page through a user interface thread of the application;
and creating a browser sub-page based on the page example of the sub-page and the window interface of the sub-page.
A computer-readable storage medium, on which a computer program is stored which, when executed by a processor, carries out the steps of:
acquiring a sub-page creation request corresponding to a browser component in an application;
calling a sub-page callback interface in a main thread of the browser component according to the sub-page creation request, and creating a page instance of a sub-page;
when the creation of the page instance of the sub-page is completed, creating a window interface of the sub-page through a user interface thread of the application;
and creating a browser sub-page based on the page example of the sub-page and the window interface of the sub-page.
According to the browser sub-page creation method, the browser sub-page creation device, the computer equipment and the storage medium, a sub-page creation request corresponding to a browser component in an application is obtained; calling a sub-page callback interface in a main thread of the browser component according to the sub-page creation request, and creating a page instance of a sub-page; when the creation of the page instance of the sub-page is completed, creating a window interface of the sub-page through a user interface thread of the application; and creating a browser sub-page based on the page example of the sub-page and the window interface of the sub-page. According to the browser sub-page creating method and device, the sub-page instances of the required browser sub-pages are directly generated in the main thread of the browser component only through the sub-page callback interface, but the interface elements of the user interface are not operated, the interface elements of the user interface are operated in the user interface thread, the sub-page instances are separated from the sub-page window to create the browser sub-pages, and thread safety during browser sub-page creating can be effectively guaranteed.
Drawings
FIG. 1 is a flowchart illustrating a method for creating a sub-page of a browser in one embodiment;
FIG. 2 is a flowchart illustrating a method for creating a sub-page of a browser in another embodiment;
FIG. 3 is a flowchart illustrating the steps of creating a window interface for a sub-page in one embodiment;
FIG. 4 is a flowchart illustrating the steps of generating a browser sub-page in one embodiment;
FIG. 5 is a flowchart illustrating the steps of pre-generating a browser sub-page corresponding to a target sub-page link in one embodiment;
FIG. 6 is a flowchart illustrating a step of destroying a generated browser sub-page in one embodiment;
FIG. 7 is a flowchart illustrating a browser sub-page creation method according to yet another embodiment;
FIG. 8 is a block diagram showing the construction of a browser sub-page creation means in one embodiment;
FIG. 9 is a diagram illustrating an internal structure of a computer device according to an embodiment.
Detailed Description
In order to make the objects, technical solutions and advantages of the present application more apparent, the present application is described in further detail below with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative of the present application and are not intended to limit the present application.
In order to make the objects, technical solutions and advantages of the present application more apparent, the present application is described in further detail below with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative of the present application and are not intended to limit the present application.
The browser sub-page creation method can be applied to a terminal, and the terminal obtains a sub-page creation request corresponding to a browser component in application; calling a sub-page callback interface in a main thread of a browser component according to the sub-page creation request, and creating a page instance of the sub-page; when the creation of the page instance of the sub-page is completed, creating a window interface of the sub-page through a user interface thread of the application; and creating a browser sub-page based on the page instance of the sub-page and the window interface of the sub-page. The terminal can be, but is not limited to, various personal computers, notebook computers, smart phones, tablet computers and portable wearable devices, and it is understood that the method can also be applied to a server, and can also be applied to a system comprising the terminal and the server, and is implemented through interaction between the terminal and the server.
In one embodiment, as shown in fig. 1, a method for creating a browser sub-page is provided, which is described by taking an example that the method is applied to a terminal, and the method includes the following steps:
and 102, acquiring a sub-page creation request corresponding to a browser component in the application.
The application may specifically include a desktop application. And the browser component refers to a plug-in on the desktop application for realizing the browser function. For implementing web browsing functionality on a desktop application. Currently, most desktop browser components are essentially Cef in use. Cef is an open source Web browser control based on the Google chrome project. Using this component, developers can add Web browsing functionality to their applications, and create user interfaces for the applications using HTML (Hyper text markup Language), CSS (Cascading Style Sheets), and js (javascript). And the sub-page creation request refers to a request for creating a sub-page corresponding to the main page on the browser. The main page of the browser is attached with a plurality of links, the links point to new web pages, and the web pages generated by the links on the main page are the sub-pages corresponding to the main page. And the request for creating these pages is a child page creation request.
Specifically, in one embodiment, a user may perform a browsing operation of a web page through a browser component in an application. When a user clicks on a web page link on a page, the user may be considered to have initiated a sub-page creation request on the current web page. At this time, the terminal operated by the user may create a corresponding browser sub-page by sending a sub-page creation request corresponding to the browser component. When the method is applied to the terminal, the processor on the terminal can sense the click operation of the user on the webpage link, and the processor is regarded as obtaining a sub-page creation request corresponding to the browser component in the application after the click operation.
And step 104, calling a sub-page callback interface in the main thread of the browser component according to the sub-page creation request, and creating a page instance of the sub-page.
The main thread of the browser component specifically refers to a main running thread of the browser, and is used for controlling the browser component to create a web page, render the page, close the page and the like. In one embodiment, the browser component is specifically implemented by Cef, and the main thread of the browser component specifically refers to a Cef main thread. And the sub-page callback interface refers to a callback interface used by a main thread of the browser component in the process of creating the sub-page. And the page instance of the sub-page is a component of the sub-page to be constructed.
Specifically, when the browser component is implemented by Cef, the application needs to call the CefInitialize (CefSettings & settings) function to initialize the runtime environment of Cef. The multi _ threaded _ message _ loop field in cefSettings is used to control the running thread model of Cef, and if this field is set to True, Cef will create a sub-thread as the main thread of the browser. If False is set, the main thread of Cef is the main thread of the application program, and at this time, in the main thread message loop of the application program, the CefDoMessageLoopWork () function needs to be executed periodically to drive the Cef processing task. In general, if the application body does not create a user interface using Cef, the multi _ threded _ message _ loop field needs to be set to True. When the Cef pops up a child page window, the main thread of the Cef triggers the callback of the child page callback interface of OnBeforePop, the client parameter in the OnBeforePop is an example of the child page window, the client parameter needs to be synchronously returned to the parent window in the callback interface, otherwise, the parent page and the child page cannot communicate. However, since the user interface thread of the application and the main thread of the Cef are not the same thread when the multi _ threded _ message _ loop is set to true, and since the interface windows of all pages in the browser are maintained in the user interface thread at this time, if the pop-up page windows are synchronously popped up in the onbeforoppup, a series of thread security problems will be caused. In the prior art, sub-page windows are generally created and displayed synchronously in a Cef main thread. The user interface object needs to be operated in the Cef main thread. At this time, since many interface interfaces of win32 need to be executed in the UI thread, many problems may be caused; if the data associated with the user interface needs to consider the multithreading access problem, the challenge is brought to the maintenance of the data logic service; also, for example, the Cef main thread may internally throw messages to the user interface thread for processing, and the user interface thread may wait for the Cef main thread to process some logic, thereby possibly causing deadlock problems.
Therefore, in the scheme of the application, the page instance of the sub-page to be created and the sub-page window are separately created, when the sub-page creation request is received, the main thread of the browser component is called first, the sub-page callback interface is called in the main thread of the browser component, and the required sub-page instance is directly created, but the user interface element is not operated.
And 106, when the page instance of the sub-page is created, creating a window interface of the sub-page through the user interface thread of the application.
The user interface thread refers to a UI thread of an application, and is mainly responsible for controlling display, updating and control interaction of an application UI in the application. The window interface of the sub-page is an additional component except the page instance
Specifically, when the creation of the page instance of the sub-page is completed, the window interface corresponding to the sub-page may be created through the UI thread on the application at the same time, and the window interface of the sub-page is generated by operating the user interface element in the UI thread, so that it is possible to avoid operating the user interface element in the main thread of the browser component, but only create the page instance in the main thread of the browser component, and when the creation of the page instance of the sub-page is completed, the window interface of the sub-page is created through the user interface thread, and the required browser sub-page is obtained by combining the two, thereby improving the security of the thread.
And step 108, creating a browser sub-page based on the page example of the sub-page and the window interface of the sub-page.
Specifically, after the page instance of the sub-page is created in the main thread of the browser component and the window interface of the sub-page is created in the user interface thread of the application, the two can be combined to obtain the browser sub-page, and the obtained browser sub-page is pushed to the user. Therefore, after the user clicks the main page link of the browser in the application, the corresponding sub-page can be obtained. In one embodiment, as shown in fig. 2, in a main thread of a browser component, only a subpage instance CefClient of a required browser subpage is directly generated through a subpage callback interface OnBeforePopup, but an interface element of a user interface is not operated, but an interface element of the user interface is operated in a user interface thread, and the subpage instance and a subpage window are separated to create the browser subpage, so that thread safety can be effectively ensured when the browser subpage is created.
In the browser sub-page creation method, a terminal acquires a sub-page creation request corresponding to a browser component in an application; calling a sub-page callback interface in a main thread of a browser component according to the sub-page creation request, and creating a page instance of the sub-page; when the creation of the page instance of the sub-page is completed, creating a window interface of the sub-page through a user interface thread of the application; and creating a browser sub-page based on the page instance of the sub-page and the window interface of the sub-page. According to the browser sub-page creating method and device, the sub-page instances of the required browser sub-pages are directly generated in the main thread of the browser component only through the sub-page callback interface, but the interface elements of the user interface are not operated, the interface elements of the user interface are operated in the user interface thread, the sub-page instances are separated from the sub-page window to create the browser sub-pages, and thread safety during browser sub-page creating can be effectively guaranteed.
In one embodiment, as shown in FIG. 3, step 106 includes:
step 302, asynchronously sending a window creation instruction to a user interface thread of an application via a main thread of a browser component.
And step 304, when the user interface thread of the application receives the window creation instruction, controlling the user interface thread of the application to create the window interface of the sub-page according to the window creation instruction.
The window creating instruction is used for informing the user interface thread that the page instance of the sub page is created completely, and meanwhile, the user interface thread is instructed to create the window interface of the sub page. Meanwhile, the window creating instruction can also contain information such as page elements and the like required to be used by the window interface of the sub-page.
Specifically, when the creation of the page instance of the sub-page is completed, the task of creating the window interface of the sub-page can be thrown into the user interface thread in an asynchronous manner in the main thread of the browser component, and when the user interface thread of the application receives a window creation instruction asynchronously sent by the main thread of the browser component, the user interface thread can create the window interface of the sub-page according to the window creation instruction without the creation by the main thread of the browser component, so that the security of the sub-window creation process is improved. In the embodiment, the window interface of the sub-page is created by asynchronously sending the window creating instruction to the user interface thread, so that the effect of ensuring the thread safety in the sub-page creating process and the generation efficiency of the sub-page can be achieved.
In one embodiment, the window creation instruction includes a page instance of the sub-page; as shown in fig. 4, step 108 includes:
in step 401, a page instance of a sub-page contained within a user interface thread fetch window creation instruction is created.
And step 403, mounting the page instance of the sub-page on the window interface of the sub-page, and acquiring the sub-page of the browser.
Also included within the window creation instruction is a page instance of a sub-page that has been created to be completed in the main thread of the browser component. After the window creation instruction is asynchronously sent to the user interface thread of the application through the main thread of the browser component, the window creation instruction can be analyzed in the user interface thread to obtain a complete page instance of the sub-page. And then, after the window interface of the sub-page is generated, directly hanging the page instance of the sub-page obtained by analysis on the newly generated window interface in the user interface thread, and directly obtaining the browser sub-page. Without subsequent thread communication. In the embodiment, the page instance of the sub-page is sent to the user interface thread and is directly hung on the generated browser sub-page, so that the generation efficiency of the browser sub-page can be effectively ensured.
In one embodiment, after step 108, the method further includes: acquiring input content of a sub-page corresponding to the sub-page; generating a content updating instruction according to the input content of the sub-page; sending the content updating instruction to the browser component, and forwarding the content updating instruction to the user interface thread by a main thread of the browser component; and calling a user interface thread to modify the input content of the browser sub-page.
The sub-page input content refers to content input by a user on a sub-page, for example, the sub-page includes a text box, and when the user types in the text box of the sub-page, the user can regard the type of the character as the sub-page input content.
Specifically, when the user inputs content in the text box, in order to update the input content on the browser sub-page, the server may first obtain the sub-page input content; then generating a content updating instruction according to the input content of the sub-page; and sending a content updating instruction to the browser component, wherein the browser component completes the updating of the input content, because the content is the updating of the display content in the browser. The main thread of the browser component can forward the content updating instruction to the user interface thread; to invoke a user interface thread to modify the input content of the browser sub-page. Thereby presenting the changed input content sub-page to the user. In this embodiment, the display content may be updated on the created browser sub-page through the content update instruction, so as to ensure the update efficiency of the newly generated browser sub-page content.
In one embodiment, after creating the browser sub-page based on the page instance of the sub-page and the window interface of the sub-page, the method further includes: acquiring a sub-page attribute modification message corresponding to the sub-page; generating an attribute updating instruction according to the sub-page attribute modification message; sending the attribute updating instruction to the browser component, and forwarding the attribute updating instruction to a user interface thread by a main thread of the browser component; and calling a user interface thread to modify the page attribute in the browser sub-page.
The sub-page attribute modification message is a message used for modifying content presented in the browser, and when a user sees a browser sub-page, the user may not be satisfied with page attributes set in the browser sub-page, such as the size of fonts in the browser page needs to be modified, the definition of images in the page needs to be modified, and the like. The page attributes on the sub-page can be modified by submitting the corresponding sub-page attribute modification message at this time.
Specifically, after the user sends a sub-page attribute modification message corresponding to a browser sub-page, the server may receive the sub-page attribute modification message; then generating an attribute updating instruction according to the sub-page attribute modification message; and sending the attribute updating instruction to the browser component, and finishing the modification of the browser page attribute by the browser component, wherein the modification is the updating of the browser internal word page. The main thread of the browser component can forward the attribute updating instruction to the user interface thread; to invoke a user interface thread to modify the page properties of the browser sub-page. And the sub-page with the changed page attribute is presented to the user. In this embodiment, the attribute of the created browser sub-page may be modified through the attribute update instruction, so as to ensure the modification efficiency of the newly generated browser sub-page attribute.
In one embodiment, as shown in fig. 5, after step 108, the method further includes:
step 502, identifying a sub-page link in a browser sub-page, and searching a target sub-page link, wherein the page attribute of the browser sub-page corresponding to the target sub-page link is invisible.
Step 504, a browser sub-page corresponding to the target sub-page link is generated.
Step 506, when an access request corresponding to the target sub-page link is received, converting the page attribute of the browser sub-page corresponding to the target sub-page link from invisible to visible.
The sub-page links in the browser sub-page refer to links corresponding to new sub-pages which can be generated in the sub-page. There will also typically be multiple new subpage links on a subpage. When the user clicks the links, the browser main thread controls the generation of sub-pages corresponding to the page links, namely, sub-pages of the sub-pages.
Specifically, after the browser sub-page is created, in order to ensure the efficiency of creating the browser sub-page in the subsequent process. The server can directly identify sub-page links in the browser sub-page and search target sub-page links, and the page attributes of the browser sub-page corresponding to the target sub-page links are invisible. And then directly generating browser sub-pages corresponding to the target sub-page links, namely generating invisible browser sub-pages before the user clicks the sub-page links. And after the user clicks the sub-page link in the browser sub-page, the server receives the access request corresponding to the sub-page link, and at the moment, the page attribute of the browser sub-page corresponding to the sub-page link can be directly converted from invisible to visible. The user can directly browse the content on the browser sub-page corresponding to the clicked target sub-page link without waiting. In one embodiment, page tags and page attributes corresponding to sub-page links in a browser sub-page can be identified firstly, then recommendation degrees of different web page links are determined based on historical browsing records of a user, the recommendation degrees are used for representing and determining which page links are the page links which are most likely to be clicked by the user, then the browser sub-page corresponding to the page links is generated based on recommendation degree ranking, and reliability and efficiency of a generating process are guaranteed. In this embodiment, by generating the browser sub-page corresponding to the sub-page link in the browser sub-page in advance, the browser sub-page can be directly displayed to the user after the user performs the click operation, so that the real-time generation efficiency of the browser sub-page is improved.
In one embodiment, as shown in fig. 6, after step 108, the method further includes:
step 601, obtaining a sub-page destruction instruction.
Step 603, destroying rendering processes corresponding to the browser sub-pages in the main thread of the browser assembly and the browser sub-pages in the user interface thread according to the sub-page destroying instruction.
And the sub-page destroying instruction is used for destroying the newly generated browser sub-page.
Specifically, when a user wishes to close a browser sub-page, the closing and destruction of the browser sub-page can be completed by sending a sub-page destruction instruction. Specifically, the server receives the sub-page destruction instruction, destroys the rendering process corresponding to the sub-page of the browser in the main thread of the browser component according to the sub-page destruction instruction, and destroys the sub-page of the browser in the user interface thread. In this embodiment, the rendering thread corresponding to the generated browser sub-page and the browser sub-page in the user interface thread may be destroyed based on the sub-page destruction instruction, so as to ensure thread security of the browser sub-page in the generating and using processes.
In one embodiment, the browser sub-page creation method specifically includes the following steps: acquiring a sub-page creation request corresponding to a browser component in an application; calling a sub-page callback interface in a main thread of a browser component according to the sub-page creation request, and creating a page instance of the sub-page; when the creation of the page instance of the sub page is completed, asynchronously sending a window creation instruction to a user interface thread of the application through a main thread of the browser component;
and when the user interface thread of the application receives the window creation instruction, controlling the user interface thread of the application to create the window interface of the sub-page according to the window creation instruction. Extracting a page instance of a sub-page contained in the window creation instruction in the user interface thread; and mounting the page example of the sub-page on the window interface of the sub-page, and acquiring the sub-page of the browser. Acquiring input content of a sub-page corresponding to the sub-page; generating a content updating instruction according to the input content of the sub-page; sending the content updating instruction to the browser component, and forwarding the content updating instruction to the user interface thread by a main thread of the browser component; and calling a user interface thread to modify the input content of the browser sub-page. Acquiring a sub-page attribute modification message corresponding to the sub-page; generating an attribute updating instruction according to the sub-page attribute modification message; sending the attribute updating instruction to the browser component, and forwarding the attribute updating instruction to a user interface thread by a main thread of the browser component; and calling a user interface thread to modify the page attribute in the browser sub-page. Identifying sub-page links in the browser sub-page, searching a target sub-page link, wherein the page attribute of the browser sub-page corresponding to the target sub-page link is invisible; generating a browser sub-page corresponding to the target sub-page link; and when an access request corresponding to the target sub-page link is received, converting the page attribute of the browser sub-page corresponding to the target sub-page link from invisible to visible. Acquiring a sub-page destroying instruction; and destroying rendering processes corresponding to the browser sub-pages in the main thread of the browser assembly and the browser sub-pages in the user interface thread according to the sub-page destroying instruction.
The application also provides an application scene, and the application scene applies the browser sub-page creation method. Specifically, the application of the browser sub-page creation method in the application scenario is as follows:
when a user uses an application installed on a PC (Personal Computer) at the PC side, if a browser component is built in the application, the user can browse a target web page through the browser component on the application, for example, the user enters a web portal through the browser component, and the web portal includes a plurality of web page links, and the web page links respectively point to different target pages. When a user clicks on a web page link, for example, clicks on a web page link corresponding to a certain news item, the processor of the PC receives a sub-page creation request corresponding to the generated news web page link. And the sub-page creation request is a sub-page creation request corresponding to a browser component in the application in the browser sub-page creation method of the application. The processor needs to generate a sub-page corresponding to the news through the browser component. Specifically, the processor calls a sub-page callback interface in a main thread of the browser component according to the sub-page creation request to create a page instance of the sub-page. The browser component is realized through the Cef, in order to guarantee the safety of the main thread of the Cef and avoid operating the UI object in the Cef, the sub-page callback interface of the main thread of the browser component is called according to the sub-page creation request, and the page instance of the sub-page is created. That is, when the Cef pops up a sub-page window, the main thread of the Cef triggers the callback of the OnBeforePop sub-page callback interface, and creates a page instance of the sub-page corresponding to the news page. And meanwhile, after the page instance of the sub-page is created, the processor asynchronously sends a window creating instruction to the user interface thread of the application through the main thread of the browser component, and the user interface thread is used for creating the window interface of the sub-page. The processor may cast the task of creating a window interface for a sub-page to the user interface thread in the main thread of the browser component. And when the user interface thread of the application receives the window creation instruction, controlling the user interface thread of the application to create the window interface of the sub-page according to the window creation instruction. The window creating instruction also comprises a page instance of the sub-page, and after the user interface thread creates the window interface of the sub-page, the page instance of the sub-page contained in the window creating instruction can be extracted from the user interface thread; the processor can mount the page example of the sub-page on the window interface of the generated sub-page, and directly obtain the browser sub-page which can be browsed by the user. When the user needs to comment on news on the browser sub-page, the user can input characters in the corresponding input field and then select to submit. At the moment, the processor can acquire the input content of the sub-page corresponding to the sub-page of the user; generating a content updating instruction according to the input content of the sub-page; sending the content updating instruction to the browser component, and forwarding the content updating instruction to the user interface thread by a main thread of the browser component; and calling a user interface thread to modify the input content of the browser sub-page. At the moment, the user can see own comment information on the updated browser sub-page. When the user needs to modify the size of the news characters on the browser sub-page, the user can submit the corresponding sub-page attribute modification message to the processor by clicking the corresponding character size adjustment button. When the processor receives a sub-page attribute modification message corresponding to the sub-page; generating an attribute updating instruction according to the sub-page attribute modification message; sending the attribute updating instruction to the browser component, and forwarding the attribute updating instruction to a user interface thread by a main thread of the browser component; and then calling a user interface thread to modify the page attribute in the browser sub-page. At this time, the user can see the new page with the adjusted font size on the updated browser sub-page. Meanwhile, a plurality of related news links are generally carried on a browser sub-page related to news browsed by a user, after the user opens the browser sub-page, the processor further identifies sub-page links in the browser sub-page and searches for a target sub-page link, and the page attribute of the browser sub-page corresponding to the target sub-page link is invisible; generating a browser sub-page corresponding to the target sub-page link; and when an access request corresponding to the target sub-page link is received, converting the page attribute of the browser sub-page corresponding to the target sub-page link from invisible to visible. When the user clicks the links corresponding to the related news, the corresponding news interface can be directly obtained without waiting for the generation process of the page. In addition, when the user clicks a close button corresponding to the browser sub-page. The processor receives a corresponding sub-page destroy instruction. In order to close the browser sub-page, the processor destroys the rendering process corresponding to the browser sub-page in the main thread of the browser assembly and the browser sub-page in the user interface thread according to the sub-page destroying instruction. In this embodiment, an application running on a separate thread using a browser thread of the Cef specified component may cause a series of stability problems if a sub-page window is popped up directly on the browser thread. However, if the browser thread is set as the main thread of the application to solve this problem, the application response performance is necessarily reduced because the CefDoMessageLoopWork () function needs to be periodically executed in the main thread message loop of the application to drive the Cef processing task. In this embodiment, the single thread is used as a mode of the CEF browser thread, which does not affect the response performance of the application program, and can avoid the stability problem caused by operating the interface element of the application program in the CEF browser thread.
FIG. 7 is a flowchart illustrating a method for creating a browser sub-page in one embodiment. It should be understood that although the various steps in the flowcharts of fig. 1-7 are shown in order as indicated by the arrows, the steps are not necessarily performed in order as indicated by the arrows. The steps are not performed in the exact order shown and described, and may be performed in other orders, unless explicitly stated otherwise. Moreover, at least some of the steps in fig. 1-7 may include multiple steps or multiple stages, which are not necessarily performed at the same time, but may be performed at different times, which are not necessarily performed in sequence, but may be performed in turn or alternately with other steps or at least some of the other steps.
In one embodiment, as shown in fig. 8, there is provided a browser sub-page creating apparatus, which may be a part of a computer device using a software module or a hardware module, or a combination of the two, and specifically includes: the device comprises a request acquisition module, an instance creation module, a window creation module and a sub-page creation module, wherein:
a request obtaining module 801, configured to obtain a sub-page creation request corresponding to a browser component in an application;
an instance creating module 803, configured to invoke a sub-page callback interface in a main thread of a browser component according to the sub-page creating request, and create a page instance of the sub-page;
a window creating module 805, configured to create, when creation of a page instance of a sub-page is completed, a window interface of the sub-page through a user interface thread of an application;
a sub-page creating module 807 for creating a browser sub-page based on the page instance of the sub-page and the window interface of the sub-page.
In one embodiment, the window creating module 805 is specifically configured to: asynchronously sending a window creation instruction to a user interface thread of an application through a main thread of a browser component; and when the user interface thread of the application receives the window creation instruction, controlling the user interface thread of the application to create the window interface of the sub-page according to the window creation instruction.
In one embodiment, the window creation instruction includes a page instance of the sub-page; the sub-page creating module 807 is specifically configured to: extracting a page instance of a sub-page contained in the window creation instruction in the user interface thread; and mounting the page example of the sub-page on the window interface of the sub-page, and acquiring the sub-page of the browser.
In one embodiment, the system further comprises an input content updating module, configured to: acquiring input content of a sub-page corresponding to the sub-page; generating a content updating instruction according to the input content of the sub-page; sending the content updating instruction to the browser component, and forwarding the content updating instruction to the user interface thread by a main thread of the browser component; and calling a user interface thread to modify the input content of the browser sub-page.
In one embodiment, the system further includes a page attribute modification module, configured to: acquiring a sub-page attribute modification message corresponding to the sub-page; generating an attribute updating instruction according to the sub-page attribute modification message; sending the attribute updating instruction to the browser component, and forwarding the attribute updating instruction to a user interface thread by a main thread of the browser component; and calling a user interface thread to modify the page attribute in the browser sub-page.
In one embodiment, the method further includes a page pre-generation module, configured to: identifying sub-page links in the browser sub-page, searching a target sub-page link, wherein the page attribute of the browser sub-page corresponding to the target sub-page link is invisible; generating a browser sub-page corresponding to the target sub-page link; and when an access request corresponding to the target sub-page link is received, converting the page attribute of the browser sub-page corresponding to the target sub-page link from invisible to visible.
In one embodiment, the system further comprises a page destruction module, configured to: acquiring a sub-page destroying instruction; and destroying rendering processes corresponding to the browser sub-pages in the main thread of the browser assembly and the browser sub-pages in the user interface thread according to the sub-page destroying instruction.
For specific limitations of the browser sub-page creation device, reference may be made to the above limitations of the browser sub-page creation method, which will not be described herein again. The modules in the browser subpage creating device may be wholly or partially implemented by software, hardware and a combination thereof. The modules can be embedded in a hardware form or independent from a processor in the computer device, and can also be stored in a memory in the computer device in a software form, so that the processor can call and execute operations corresponding to the modules.
In one embodiment, a computer device is provided, which may be a terminal, and its internal structure diagram may be as shown in fig. 9. The computer device includes a processor, a memory, a communication interface, a display screen, and an input device connected by a system bus. Wherein the processor of the computer device is configured to provide computing and control capabilities. The memory of the computer device comprises a nonvolatile storage medium and an internal memory. The non-volatile storage medium stores an operating system and a computer program. The internal memory provides an environment for the operation of an operating system and computer programs in the non-volatile storage medium. The communication interface of the computer device is used for carrying out wired or wireless communication with an external terminal, and the wireless communication can be realized through WIFI, an operator network, NFC (near field communication) or other technologies. The computer program is executed by a processor to implement a browser subpage creation method. The display screen of the computer equipment can be a liquid crystal display screen or an electronic ink display screen, and the input device of the computer equipment can be a touch layer covered on the display screen, a key, a track ball or a touch pad arranged on the shell of the computer equipment, an external keyboard, a touch pad or a mouse and the like.
Those skilled in the art will appreciate that the architecture shown in fig. 9 is merely a block diagram of some of the structures associated with the disclosed aspects and is not intended to limit the computing devices to which the disclosed aspects apply, as particular computing devices may include more or less components than those shown, or may combine certain components, or have a different arrangement of components.
In one embodiment, a computer device is further provided, which includes a memory and a processor, the memory stores a computer program, and the processor implements the steps of the above method embodiments when executing the computer program.
In an embodiment, a computer-readable storage medium is provided, in which a computer program is stored which, when being executed by a processor, carries out the steps of the above-mentioned method embodiments.
In one embodiment, a computer program product or computer program is provided that includes computer instructions stored in a computer-readable storage medium. The computer instructions are read by a processor of a computer device from a computer-readable storage medium, and the computer instructions are executed by the processor to cause the computer device to perform the steps in the above-mentioned method embodiments.
It will be understood by those skilled in the art that all or part of the processes of the methods of the embodiments described above can be implemented by hardware related to instructions of a computer program, which can be stored in a non-volatile computer-readable storage medium, and when executed, can include the processes of the embodiments of the methods described above. Any reference to memory, storage, database or other medium used in the embodiments provided herein can include at least one of non-volatile and volatile memory. Non-volatile memory may include Read-only memory (ROM), magnetic tape, floppy disk, flash memory, optical storage, or the like. Volatile memory can include Random Access Memory (RAM) or external cache memory. By way of illustration and not limitation, RAM can take many forms, such as Static Random Access Memory (SRAM) or Dynamic Random Access Memory (DRAM), among others.
The technical features of the above embodiments can be arbitrarily combined, and for the sake of brevity, all possible combinations of the technical features in the above embodiments are not described, but should be considered as the scope of the present specification as long as there is no contradiction between the combinations of the technical features.
The above examples only express several embodiments of the present application, and the description thereof is more specific and detailed, but not construed as limiting the scope of the invention. It should be noted that, for a person skilled in the art, several variations and modifications can be made without departing from the concept of the present application, which falls within the scope of protection of the present application. Therefore, the protection scope of the present patent shall be subject to the appended claims.

Claims (10)

1. A browser sub-page creation method, comprising:
acquiring a sub-page creation request corresponding to a browser component in an application;
calling a sub-page callback interface in a main thread of the browser component according to the sub-page creation request, and creating a page instance of a sub-page;
when the creation of the page instance of the sub-page is completed, creating a window interface of the sub-page through a user interface thread of the application;
and creating a browser sub-page based on the page example of the sub-page and the window interface of the sub-page.
2. The method of claim 1, wherein creating a window interface for a sub-page through a user interface thread of the application comprises:
asynchronously sending a window creation instruction to a user interface thread of the application through a main thread of the browser component;
and when the user interface thread of the application receives a window creation instruction, controlling the user interface thread of the application to create a window interface of the sub-page according to the window creation instruction.
3. The method of claim 2, wherein the window creation instruction comprises a page instance of a sub-page;
the creating a browser sub-page based on the page instance of the sub-page and the window interface of the sub-page comprises:
extracting, at the user interface thread, a page instance of a sub-page contained within the window creation instruction;
and mounting the page example of the sub-page on the window interface of the sub-page, and acquiring the browser sub-page.
4. The method of claim 3, wherein after creating a browser sub-page based on the page instance of the sub-page and the window interface of the sub-page, further comprising:
acquiring input content of a sub-page corresponding to the sub-page;
generating a content updating instruction according to the input content of the sub-page;
sending the content updating instruction to the browser component, and forwarding the content updating instruction to the user interface thread by a main thread of the browser component;
and calling a user interface thread to modify the input content of the browser sub-page.
5. The method of claim 3, after creating a browser sub-page based on the page instance of the sub-page and the window interface of the sub-page, further comprising:
acquiring a sub-page attribute modification message corresponding to the sub-page;
generating an attribute updating instruction according to the sub-page attribute modification message;
sending the attribute updating instruction to the browser component, and forwarding the attribute updating instruction to the user interface thread by a main thread of the browser component;
and calling a user interface thread to modify the page attribute in the browser sub-page.
6. The method of claim 5, wherein after creating a browser sub-page based on the page instance of the sub-page and the window interface of the sub-page, further comprising:
identifying sub-page links in the browser sub-page, and searching a target sub-page link, wherein the page attribute of the browser sub-page corresponding to the target sub-page link is invisible;
generating a browser sub-page corresponding to the target sub-page link;
and when an access request corresponding to the target sub-page link is received, converting the page attribute of the browser sub-page corresponding to the target sub-page link from invisible to visible.
7. The method of claim 1, further comprising:
acquiring a sub-page destroying instruction;
and destroying rendering processes corresponding to the browser sub-pages in the main thread of the browser assembly and browser sub-pages in the user interface thread according to the sub-page destroying instruction.
8. An apparatus for creating a browser sub-page, the apparatus comprising:
the request acquisition module is used for acquiring a sub-page creation request corresponding to a browser component in an application;
the instance creating module is used for calling a sub-page callback interface in a main thread of the browser component according to the sub-page creating request and creating a page instance of a sub-page;
the window creating module is used for creating a window interface of the sub-page through the user interface thread of the application when the creation of the page instance of the sub-page is completed;
and the sub-page creating module is used for creating the browser sub-page based on the page example of the sub-page and the window interface of the sub-page.
9. A computer device comprising a memory and a processor, the memory storing a computer program, characterized in that the processor, when executing the computer program, implements the steps of the method of any of claims 1 to 7.
10. A computer-readable storage medium, in which a computer program is stored which, when being executed by a processor, carries out the steps of the method according to any one of claims 1 to 7.
CN202010772290.7A 2020-08-04 2020-08-04 Browser sub-page creation method and device, computer equipment and storage medium Pending CN111783019A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202010772290.7A CN111783019A (en) 2020-08-04 2020-08-04 Browser sub-page creation method and device, computer equipment and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202010772290.7A CN111783019A (en) 2020-08-04 2020-08-04 Browser sub-page creation method and device, computer equipment and storage medium

Publications (1)

Publication Number Publication Date
CN111783019A true CN111783019A (en) 2020-10-16

Family

ID=72765469

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202010772290.7A Pending CN111783019A (en) 2020-08-04 2020-08-04 Browser sub-page creation method and device, computer equipment and storage medium

Country Status (1)

Country Link
CN (1) CN111783019A (en)

Cited By (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112506506A (en) * 2020-10-30 2021-03-16 福建亿能达信息技术股份有限公司 Method, device, equipment and medium for configuring pages of electronic medical record browser
CN113986447A (en) * 2021-12-24 2022-01-28 畅捷通信息技术股份有限公司 Interaction method and device of local application service and browser and storage medium
CN114518912A (en) * 2022-02-21 2022-05-20 度小满科技(北京)有限公司 Page loading method, device and equipment and readable storage medium

Cited By (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112506506A (en) * 2020-10-30 2021-03-16 福建亿能达信息技术股份有限公司 Method, device, equipment and medium for configuring pages of electronic medical record browser
CN112506506B (en) * 2020-10-30 2022-11-11 福建亿能达信息技术股份有限公司 Method, device, equipment and medium for configuring pages of electronic medical record browser
CN113986447A (en) * 2021-12-24 2022-01-28 畅捷通信息技术股份有限公司 Interaction method and device of local application service and browser and storage medium
CN113986447B (en) * 2021-12-24 2022-03-29 畅捷通信息技术股份有限公司 Interaction method and device of local application service and browser and storage medium
CN114518912A (en) * 2022-02-21 2022-05-20 度小满科技(北京)有限公司 Page loading method, device and equipment and readable storage medium
CN114518912B (en) * 2022-02-21 2023-04-25 度小满科技(北京)有限公司 Page loading method, device, equipment and readable storage medium

Similar Documents

Publication Publication Date Title
US20190251143A1 (en) Web page rendering method and related device
US10754917B2 (en) Method and system for displaying customized webpage on double webview
KR102436987B1 (en) Method and terminal device for extracting web page content
CN106991154B (en) Webpage rendering method and device, terminal and server
US10303526B2 (en) Device specific handling of user interface components
US8196039B2 (en) Relevant term extraction and classification for Wiki content
US10542123B2 (en) System and method for generating and monitoring feedback of a published webpage as implemented on a remote client
CN111783019A (en) Browser sub-page creation method and device, computer equipment and storage medium
CN108595697B (en) Webpage integration method, device and system
CN110647699A (en) Web page rendering method and device, computer equipment and storage medium
US20180349149A1 (en) A method and system for providing and executing web applications
CN110647700A (en) Page resource loading method and device, computer equipment and storage medium
US20130080871A1 (en) Method for retrieving a representation of an annotated web document, associated computer program and electronic device
JP2017504129A (en) Construction of a state expression represented in a web browser
CN106155654B (en) Method and device for shielding webpage operation and electronic equipment
CN113010170A (en) Page rendering method, device, medium and electronic equipment based on Vue3 component
CN115309470B (en) Method, device, equipment and storage medium for loading widget
US11930096B2 (en) Systems and methods for rendering interactive web pages
US20080282150A1 (en) Finding important elements in pages that have changed
US20220237042A1 (en) Resource pre-fetch using age threshold
CN109582890A (en) Page loading method, device, computer equipment and storage medium
CN103902727B (en) Network search method and device
US10261979B2 (en) Method and apparatus for rendering a screen-representation of an electronic document
Koehl et al. M. site: Efficient content adaptation for mobile devices
CN111931111A (en) Webpage development method, webpage display method, device and equipment

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination