Disclosure of Invention
Based on this, it is necessary to provide a rendering method and system for a browser, a computer device, and a computer storage medium, for the technical problem that the conventional scheme can only perform rendering and other processing on a part of browsers and has limitations.
A rendering method of a browser, comprising:
when the loaded browser is identified as a specific browser, creating a gasket for performing image enhancement processing on the webpage object; wherein the specific browser is a browser of which the script code does not comprise a specified element adding event function;
adding the gasket into an image processing component corresponding to a browser script, determining the component sequence and each component information corresponding to the browser, and transmitting the component information into an engine;
and creating a service logic component instance in the engine according to the component information, and calling an API (application programming interface) function of the browser to render a browser page according to the component sequence and the service logic component instance.
According to the rendering method of the browser, when the loaded browser is identified as the specific browser, a gasket for performing image enhancement processing on a webpage object is created, the gasket is added into an image processing component corresponding to a browser script, the component sequence and each component information corresponding to the browser are determined, the component information is transmitted into an engine, a business logic component instance is created in the engine according to the component information, an API function of the browser is called to render a browser page according to the component sequence and the business logic component instance, page rendering of the specific browser is achieved, the process of performing corresponding rendering on the specific browser can be simplified, and the browser componentization processing function is perfected.
In one embodiment, before the process of creating a gasket for image enhancement processing of a web page object when the loaded browser is identified as a specific browser, the method further includes:
analyzing a script code provided by a browser to an engine, and detecting whether the script code contains a specified element adding event function;
if not, the browser is judged to be the specific browser.
The embodiment can accurately identify the specific browsers such as the IE7 browser and the IE8 browser which cannot be directly subjected to componentization development.
In one embodiment, after identifying that the loaded browser is the specific browser, the method further includes:
and identifying the version of the specific browser, and if the version is the set version, creating a gasket for processing the font icon.
The embodiment can effectively improve the rendering effect of the browser with the set version in the specific browser and further improve the corresponding component development function.
In one embodiment, before the process of creating a gasket for image enhancement processing of a web page object when the loaded browser is identified as a specific browser, the method further includes:
and loading a browser page, and creating an engine for performing componentized development on the browser.
In one embodiment, the process of calling the API function of the browser to render the browser page according to the component order and the service logic component instance includes:
and calling an API function of a browser by the component sequence and business logic component instance to generate a rendering object corresponding to the specific browser, adding the rendering object to the running environment of the browser, and finishing the rendering of the page of the specific browser.
The embodiment can ensure the effect of page rendering on the specific browser.
In one embodiment, the process of creating a pad for image enhancement processing of a web page object includes:
and referencing script codes for image processing of the webpage objects in the page of the browser, analyzing and executing the added script codes in the browser, and finishing the creation of the gasket of the browser.
In this embodiment, the image processing on the web page object may specifically include image enhancement processes such as supporting processing on font images in the web page and enhancing processing on web page events, so that the created gasket may provide an image enhancement processing function for a componentized rendering process of a specific browser, and the functions of browser componentized processing are effectively improved.
In one embodiment, the specific browsers include an IE7 browser and an IE8 browser.
The embodiment can realize the componentized rendering of various browsers, can perfect the rendering function of the browsers, and improves the corresponding user experience.
A rendering system for a browser, comprising:
the creation module is used for creating a gasket for carrying out image enhancement processing on the webpage object when the loaded browser is identified to be a specific browser; wherein the specific browser is a browser of which the script code does not comprise a specified element adding event function;
the adding module is used for adding the gasket into an image processing component corresponding to the browser script, determining the component sequence and each component information corresponding to the browser and transmitting the component information into an engine;
and the calling module is used for creating a service logic component instance in the engine according to the component information and calling an API (application program interface) function of the browser to render a browser page according to the component sequence and the service logic component instance.
The rendering system of the browser can create a gasket for performing image enhancement processing on a webpage object when a loaded browser is identified as a specific browser, add the gasket to an image processing component corresponding to a browser script, determine a component sequence and each component information corresponding to the browser, transmit the component information to an engine, create a business logic component instance in the engine according to the component information, and call an API (application program interface) function of the browser to render a browser page according to the component sequence and the business logic component instance, so that the page rendering of the specific browser is realized, the corresponding rendering process of the specific browser can be simplified, and the browser componentization processing function is perfected.
A computer device comprising a memory, a processor and a computer program stored on the memory and executable on the processor, the processor implementing the rendering method of the browser provided by any of the above embodiments when executing the computer program.
A computer storage medium having a computer program stored thereon, wherein the program, when executed by a processor, implements the rendering method of the browser provided in any one of the above embodiments.
According to the rendering method of the browser, the invention also provides computer equipment and a computer storage medium, which are used for realizing the rendering method of the browser through a program. The computer equipment and the computer storage medium can simplify the corresponding rendering process of specific browsers such as an IE7 browser and an IE8 browser, and improve the componentization processing function of the browsers. .
Detailed Description
In order to make the objects, technical solutions and advantages of the present invention more apparent, the present invention is further described in detail below with reference to the accompanying drawings and embodiments. It should be understood that the detailed description and specific examples, while indicating the scope of the invention, are intended for purposes of illustration only and are not intended to limit the scope of the invention.
It should be noted that the terms "first \ second \ third" related to the embodiments of the present invention only distinguish similar objects, and do not represent a specific ordering for the objects, and it should be understood that "first \ second \ third" may exchange a specific order or sequence when allowed. It should be understood that the terms first, second, and third, as used herein, are interchangeable under appropriate circumstances such that the embodiments of the invention described herein are capable of operation in other sequences than those illustrated or otherwise described herein.
The terms "comprises" and "comprising," and any variations thereof, of embodiments of the present invention are intended to cover non-exclusive inclusions. For example, a process, method, system, article, or apparatus that comprises a list of steps or modules is not limited to the listed steps or modules but may alternatively include other steps or modules not listed or inherent to such process, method, article, or apparatus.
Reference herein to "an embodiment" means that a particular feature, structure, or characteristic described in connection with the embodiment can be included in at least one embodiment of the application. The appearances of the phrase in various places in the specification are not necessarily all referring to the same embodiment, nor are separate or alternative embodiments mutually exclusive of other embodiments. It is explicitly and implicitly understood by one skilled in the art that the embodiments described herein can be combined with other embodiments.
Reference herein to "a plurality" means two or more. "and/or" describes the association relationship of the associated objects, meaning that there may be three relationships, e.g., a and/or B, which may mean: a exists alone, A and B exist simultaneously, and B exists alone. The character "/" generally indicates that the former and latter associated objects are in an "or" relationship.
Referring to fig. 1, fig. 1 is a flowchart of a rendering method of a browser according to an embodiment, including:
s10, when the loaded browser is identified as a specific browser, a gasket for carrying out image enhancement processing on the webpage object is created; wherein the specific browser is a browser of which the script code does not comprise a specified element adding event function;
the specific browser can comprise browsers which lack functional modules such as image enhancement processing and the like and cannot be directly developed in a componentization mode, such as an IE7 browser, an IE8 browser and the like. Since the specific browsers of IE7/IE8 may lack functional modules such as image enhancement processing and the like relative to other browsers, the functional modules can be completed by additionally adding functional pads in order that the same set of codes can run on the old browsers. The above-mentioned gasket refers to the function of simulating the high-level environment through the low-level environment language in the low-level environment (e.g. IE7/IE8 browser). The gasket can be an independent and complete JavaScript script, and the browser performs analysis and execution by referring script codes such as the JavaScript script corresponding to the gasket on the page to complete the creating action of the gasket.
The above-mentioned gasket for performing image enhancement processing on the web page object may include a JavaScript object function enhancement, a font icon support processing module, an event processing module, and other types of gaskets.
S20, adding the gasket into an image processing component corresponding to the browser script, determining the component sequence and each component information corresponding to the browser, and transmitting the component information into an engine;
the front-end component is an independently operable and reusable unit consisting of views, data and logic, and has the advantages of improving the maintainability and the operating performance of a front-end interface. The browser script corresponds to a plurality of components which can be developed in various aspects for the corresponding browser, and the created gasket is added to the image processing component corresponding to the browser script, so that the corresponding component has the capability of developing and processing the specific browser.
The engine may be a reach.js engine, and the reach.js engine may be developed by adopting a JavaScript standard (such as the JavaScript standard of es 5), so that the development efficiency and the development effect are particularly high. The above steps can respectively transmit the component sequence and each component information corresponding to the browser to the engine for subsequent browser componentization processing.
S30, creating a service logic component instance in the engine according to the component information, and calling an API function of the browser to render a browser page according to the component sequence and the service logic component instance.
The engine may be provided with a storage management module for storing internal components and management objects created during the operation of the engine and a compatible processing module for performing a function enhancement process on a specific browser. Specifically, the storage management module is accessed to obtain a component tree corresponding to the browser, an API function of the browser and a compatible processing module of an engine are called according to the sequence and logic (service logic component instance) of the component tree, rendering objects that can be identified by a specific browser, such as IE7/IE8, are generated, and the objects are added into the operating environment of the browser, so that the rendering of the page is completed.
According to the rendering method of the browser provided by the embodiment, when the loaded browser is identified as the specific browser, a gasket for performing image enhancement processing on a webpage object is created, the gasket is added to an image processing component corresponding to a browser script, a component sequence and each component information corresponding to the browser are determined, the component information is transmitted to an engine, a service logic component instance is created in the engine according to the component information, an API function of the browser is called to render a browser page according to the component sequence and the service logic component instance, so that the page rendering of the specific browser is realized, the process of performing corresponding rendering on the specific browser can be simplified, and the function of browser componentization processing is perfected.
In one embodiment, before the process of creating a gasket for image enhancement processing of a web page object when the loaded browser is identified as a specific browser, the method further includes:
analyzing a script code provided by a browser to an engine, and detecting whether the script code contains a specified element adding event function;
if not, the browser is judged to be the specific browser.
The specified element addition event function may be addEventListener; specifically, whether the script code in the operating environment provided by the browser to the javascript includes addEventListener may be determined according to the function, so as to obtain whether the current browser is a specific browser such as an IE browser. If it is under a particular browser, the engine shim module may be invoked to add the created shim module (e.g., object property enhancement module, event handling module).
The embodiment can accurately identify the specific browsers such as the IE7 browser and the IE8 browser which cannot be directly subjected to componentization development.
In one embodiment, after identifying that the loaded browser is the specific browser, the method further includes:
and identifying the version of the specific browser, and if the version is the set version, creating a gasket for processing the font icon.
The embodiment can obtain the version identifier of the current specific browser through the API function provided by the browser, and determine whether the version identifier is the set version. The set version can be IE7 in an IE browser, the gasket for processing the font icons can be a gasket comprising a font icon processing module, and the gasket for processing the font icons is created on the basis of creating the gasket for performing image enhancement processing on the webpage objects, so that the rendering effect of the browser with the set version in a specific browser can be effectively improved, and the corresponding component development function is further improved.
In one embodiment, before the process of creating a gasket for image enhancement processing of a web page object when the loaded browser is identified as a specific browser, the method further includes:
and loading a browser page, and creating an engine for performing componentized development on the browser.
The engine can be a React.js engine, the componentization thought of the React.js is very reasonable, and the JSX grammar provided by the React provides a convenient implementation mode for componentization development; JSX grammar provided by fact.
The browser page can comprise a plurality of components, and when the browser page is loaded, the browser can disassemble the page script according to the written service logic and the.
Specifically, the following modules may be set in the process of creating the required engine and implementing the rendering of the specific browser by the engine, and implemented by the following modules:
an initialization module: with the loading of the browser page, the engine module is loaded first, and at this time, the initialization module of the engine module can be called. The initialization module can prepare the running environment to be dependent on the needed memory space, global object, constant, object and other engine running requirements.
A storage management module: after the completion initialization module is executed, the execution engine creation action is started. The method comprises the steps of calling a storage management module, requesting a browser memory for applying a memory storage space through a script statement during initialization, and storing internal components and management objects created during the running of an engine.
A component generation module: and creating a component factory object, wherein the component factory object is responsible for generating a component class object with a uniform specification according to component information transmitted from the outside.
An analysis processing module: the method is a functional module written by using the es3 standard and used for analyzing a script compiled based on a JSX grammar, and the functional module is used for analyzing and converting a service logic into a JavaScript script based on the es3 standard through an analysis processing module, finally outputting an abstract component tree with sequence and structure, and storing the abstract component tree in a memory storage space through a storage module.
A compatible processing module: according to the judgment of the related information of the browser, basic function module enhancement is carried out, and mainly function enhancement is carried out on specific browsers such as IE7/IE8, for example, method enhancement of group objects, compatibility of an event monitoring calling mechanism and the like.
A component rendering module: and creating a component rendering factory object, wherein the component rendering factory object is responsible for rendering the component into the browser. The specific workflow is that a storage management module is accessed to obtain a component tree stored by an analysis engine, an API (application programming interface) related to a browser and an engine compatible processing module are called according to the sequence and logic of the component tree to generate rendering objects which can be identified by the IE7/IE8 browser, and the objects are added into the running environment of the browser to finish the rendering of the page.
In one embodiment, the process of calling the API function of the browser to render the browser page according to the component order and the business logic component instance includes:
and calling an API function of the browser according to the component sequence and the service logic component instance to generate a rendering object corresponding to the specific browser, adding the rendering object to the running environment of the browser, and finishing the rendering of the page of the specific browser.
The embodiment can ensure the effect of page rendering on the specific browser.
In one embodiment, the process of creating a shim for image enhancement processing of a web page object includes:
and referencing script codes for image processing of the webpage objects in the page of the browser, analyzing and executing the added script codes in the browser, and finishing the creation of the gasket of the browser.
In this embodiment, the image processing on the web page object may specifically include image enhancement processes such as supporting processing on font images in the web page and enhancing processing on web page events, so that the created gasket may provide an image enhancement processing function for a componentized rendering process of a specific browser, and the functions of browser componentized processing are effectively improved.
In one embodiment, the particular browsers include an IE7 browser and an IE8 browser.
Because IE7 browser and IE8 browser lack many functional modules compared with other modern browsers, these browsers have very high frequency of use in enterprise users, the gasket for performing componentized rendering for this kind of specific browser is set, and is added to the image processing component corresponding to the browser script, so that the same set of code can run on various browsers such as these old browsers, the componentized rendering of various browsers is realized, the rendering function of the browsers can be perfected, and the corresponding user experience is improved.
For an execution environment such as an IE7 browser or an IE8 browser, compatibility processing can be performed through the created shim, and functions of an advanced execution environment can be simulated. The compatible processing module is mainly used for processing API difference between an IE7 browser or an IE8 browser and a modern browser. When the compatible processing module is loaded, whether the current browser is under the IE7 browser or the IE8 browser can be judged, and if so, the gasket comprising each function enhancement module is loaded. On the native object, compared with the existing API interfaces of the native objects of the existing browser, the API interfaces which are not available in the IE7 browser or the IE8 browser are implemented one by one, and the enhancement effect on the native objects is achieved. Including native array objects, method volume objects, event processing objects, and the like. A pad of a font icon processing module for processing font icons can be additionally added below the set version of the IE7, so that the problem of using the font icons below the IE7 is compatible. The above process of performing componentization processing for the IE7 browser or the IE8 browser may include:
a compatible processing module is created.
Judging the version of the browser: calling an API provided by the browser, acquiring browser version information, and judging whether the currently running browser is IE7 or IE8 according to the acquired browser version information. If the current browser is not IE7/IE8, then compatibility processing is not required and the act of creating a compatibility processing module is directly ended. If IE7/IE8, then the shim loading is started.
Loading native object enhancement module shim: the engine calls an object enhancement module gasket which is placed in the engine creating process, and JavaScript objects under the IE7/IE8 browser are promoted to have the running capability and the functions under the high-level browser.
Loading a native event monitoring processing module gasket: the engine calls the event monitoring processing module gasket which is put in when the engine is created, and the declaration mode of event monitoring under the IE7/IE8 browser is added to have the declaration mode under the high-level browser.
Determine if the browser is IE 7: if not IE7, the creation of compatible processing modules is done directly. If IE7, then the font icon handling module shim module needs to be invoked.
Load font icon processing module shim module: the engine calls the event monitoring processing module gasket which is put in when the engine is built, and the problem that the IE7 browser cannot use the font icon is solved.
Referring to fig. 2, fig. 2 is a schematic structural diagram of a rendering system of a browser according to an embodiment, including:
a creating unit 10, configured to create a pad for performing image enhancement processing on a web page object when it is recognized that the loaded browser is a specific browser; wherein the specific browser is a browser of which the script code does not comprise a specified element adding event function;
an adding unit 20, configured to add the shim to an image processing component corresponding to a browser script, determine a component sequence and component information corresponding to a browser, and send the component information to an engine;
and the calling unit 30 is configured to create a service logic component instance in the engine according to the component information, and call an API function of the browser to render a browser page according to the component order and the service logic component instance.
In an embodiment, the rendering system structure diagram of the browser may further include:
the analysis unit is used for analyzing the script codes provided by the browser to the engine and detecting whether the script codes contain the specified element adding event function;
and the judging unit is used for judging that the browser is the specific browser if the browser is not the specific browser.
In an embodiment, the rendering system structure diagram of the browser may further include:
and the identification unit is used for identifying the version of the specific browser and creating a gasket for processing the font icon if the version is the set version.
In an embodiment, the rendering system structure diagram of the browser may further include:
and the loading unit is used for loading a browser page and creating an engine for performing componentized development on the browser.
In one embodiment, the invoking unit is further configured to:
and calling an API function of a browser by the component sequence and business logic component instance to generate a rendering object corresponding to the specific browser, adding the rendering object to the running environment of the browser, and finishing the rendering of the page of the specific browser.
In one embodiment, the creating unit is further configured to:
and referencing script codes for image processing of the webpage objects in the page of the browser, analyzing and executing the added script codes in the browser, and finishing the creation of the gasket of the browser.
In one embodiment, the specific browsers include IE7 browser and IE8 browser
FIG. 3 is a block diagram of a computer system 1000 upon which embodiments of the present invention may be implemented. The computer system 1000 is only one example of a suitable computing environment for the invention and is not intended to suggest any limitation as to the scope of use of the invention. Neither should the computer system 1000 be interpreted as having a dependency or requirement relating to a combination of one or more components of the exemplary computer system 1000 illustrated.
The computer system 1000 shown in FIG. 3 is one example of a computer system suitable for use with the present invention. Other architectures with different subsystem configurations may also be used. Such as desktop computers, notebooks, and the like, as are well known to those of ordinary skill, may be suitable for use with some embodiments of the present invention. But are not limited to, the devices listed above.
As shown in fig. 3, the computer system 1000 includes a processor 1010, a memory 1020, and a system bus 1022. Various system components including the memory 1020 and the processor 1010 are connected to the system bus 1022. The processor 1010 is hardware for executing computer program instructions through basic arithmetic and logical operations in a computer system. Memory 1020 is a physical device used for temporarily or permanently storing computing programs or data (e.g., program state information). The system bus 1020 may be any of several types of bus structures including a memory bus or memory controller, a peripheral bus, and a local bus. The processor 1010 and the memory 1020 may be in data communication via a system bus 1022. Wherein memory 1020 includes Read Only Memory (ROM) or flash memory (neither shown), and Random Access Memory (RAM), which typically refers to main memory loaded with an operating system and application programs.
The computer system 1000 also includes a display interface 1030 (e.g., a graphics processing unit), a display device 1040 (e.g., a liquid crystal display), an audio interface 1050 (e.g., a sound card), and an audio device 1060 (e.g., speakers).
Computer system 1000 typically includes a storage device 1070. Storage device 1070 may be selected from a variety of computer readable media, which refers to any available media that may be accessed by computer system 1000, including both removable and non-removable media. For example, computer-readable media includes, but is not limited to, flash memory (micro SD cards), CD-ROM, Digital Versatile Disks (DVD) or other optical disk storage, magnetic cassettes, magnetic tape, magnetic disk storage or other magnetic storage devices, or any other medium which can be used to store the desired information and which can accessed by computer system 1000.
Computer system 1000 also includes input device 1080 and input interface 1090 (e.g., an IO controller). A user may enter commands and information into computer system 1000 through input device 1080, such as a keyboard, a mouse, a touch-panel device on display device 1040. Input device 1080 is typically connected to system bus 1022 through an input interface 1090, but may be connected by other interface and bus structures, such as a Universal Serial Bus (USB).
Computer system 1000 may logically connect with one or more network devices in a network environment. The network device may be a personal computer, a server, a router, a tablet, or other common network node. The computer system 1000 is connected to a network device through a Local Area Network (LAN) interface 1100 or a mobile communication unit 1110. A Local Area Network (LAN) refers to a computer network formed by interconnecting within a limited area, such as a home, a school, a computer lab, or an office building using a network medium. WiFi and twisted pair wiring ethernet are the two most commonly used technologies to build local area networks. WiFi is a technology that enables computer systems 1000 to exchange data between themselves or to connect to a wireless network via radio waves. The mobile communication unit 1110 is capable of making and receiving calls over a radio communication link while moving throughout a wide geographic area. In addition to telephony, the mobile communication unit 1110 also supports internet access in a 2G, 3G or 4G cellular communication system providing mobile data services.
It should be noted that other computer systems, including more or less subsystems than computer system 1000, can also be suitable for use with the invention. As described above in detail, the computer system 1000 adapted to the present invention can perform the designated operation of the rendering method of the browser. The computer system 1000 performs these operations in the form of software instructions executed by the processor 1010 in a computer-readable medium. These software instructions may be read into memory 1020 from storage device 1070 or from another device via local network interface 1100. The software instructions stored in memory 1020 cause processor 1010 to perform the rendering method of the browser described above. Furthermore, the present invention can be implemented by hardware circuits or by a combination of hardware circuits and software instructions. Thus, implementations of the invention are not limited to any specific combination of hardware circuitry and software.
The rendering system of the browser and the rendering method of the browser are in one-to-one correspondence, and the technical features and the advantages thereof described in the embodiment of the rendering method of the browser are all applicable to the embodiment of the rendering system of the browser.
Based on the examples described above, there is also provided in one embodiment a computer device comprising a memory, a processor, and a computer program stored on the memory and executable on the processor, wherein the processor, when executing the program, implements the rendering method of the browser as in any of the above embodiments.
According to the computer equipment, the componentized rendering of the specific browser is realized through the computer program running on the processor, and the componentized processing function of the browser is perfected.
It will be understood by those skilled in the art that all or part of the processes in the methods of the above embodiments may be implemented by a computer program, which is stored in a non-volatile computer readable storage medium, and in the embodiments of the present invention, the program may be stored in the storage medium of a computer system and executed by at least one processor in the computer system to implement the processes of the embodiments including the rendering method of the browser. The storage medium may be a magnetic disk, an optical disk, a Read-Only Memory (ROM), a Random Access Memory (RAM), or the like.
Accordingly, in an embodiment, a computer storage medium is also provided, on which a computer program is stored, wherein the program, when executed by a processor, implements the rendering method of the browser as in any one of the above embodiments.
The computer storage medium can simplify the process of performing corresponding rendering on specific browsers such as an IE7 browser and an IE8 browser through the stored computer program, and improves corresponding user experience.
The technical features of the embodiments described above may be arbitrarily combined, and for the sake of brevity, all possible combinations of the technical features in the embodiments described above are not described, but should be considered as being within the scope of the present specification as long as there is no contradiction between the combinations of the technical features.
The above-mentioned embodiments only express several embodiments of the present invention, 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 inventive concept, which falls within the scope of the present invention. Therefore, the protection scope of the present patent shall be subject to the appended claims.