A method for generating a document interface and related devices
By obtaining an initial snapshot of the target document and generating a snapshot based on the comparison results, the problem of increased data volume caused by MutationObserver is solved, and faster interface playback is achieved.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- TENCENT TECHNOLOGY (SHENZHEN) CO LTD
- Filing Date
- 2021-04-19
- Publication Date
- 2026-04-14
AI Technical Summary
In existing technologies, when observing changes in the DOM tree structure using MutationObserver, node attribute changes are collected multiple times at the same refresh rate, resulting in a significant increase in data volume and consequently increasing the duration of interface playback.
By obtaining the initial snapshot of the target document, the first comparison result, and the second comparison result, the (t-1)th snapshot and the tth snapshot are generated, and the corresponding document interface is generated based on these snapshots, reducing the amount of data processed during interface playback.
This reduces the amount of data that needs to be processed during interface playback and shortens the playback time.
Smart Images

Figure CN115221112B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of big data, and in particular to a method and related equipment for generating a document interface. Background Technology
[0002] The Document Object Model (DOM) is a programming interface for Hypertext Markup Language (HTML) and Extensible Markup Language (XML) documents. It provides a structured representation of a document and defines a way to access and modify its structure, style, and content from within a program. The DOM resolves a document into a structured collection of nodes and objects (objects containing properties and methods).
[0003] Currently, changes in the DOM tree structure are mainly observed through the MutationObserver. However, since the MutationObserver responds to DOM changes in real time, multiple changes to the same DOM node within a single refresh frame will be collected. For example, if the initial value of a certain property of node A in the DOM node is 1, and the initial value of that property changes, then when collecting data for node A, the initial value of that property of node A at a single refresh frame and all data after the property changes will be collected. For example, if the property changes twice at the same refresh frame, then 3 data entries will be collected.
[0004] This would significantly increase the amount of data collected for a certain attribute of node A. As a result, when replaying the operation on node A, the amount of data that needs to be processed is larger, thus increasing the duration of the replay. Summary of the Invention
[0005] This application provides a method and related device for generating a document interface, which requires less data to be processed when playing back the interface, thereby reducing the time required for interface playback.
[0006] One embodiment of this application provides a method for generating a document interface, including:
[0007] In response to the interface playback command, retrieve the initial snapshot, the first comparison result, and the second comparison result for the target document from the database. The first comparison result is the comparison result between the (t-1)th snapshot and the initial snapshot, and the second comparison result is the comparison result between the tth snapshot and the initial snapshot, where t is an integer greater than 2.
[0008] Based on the initial snapshot and the first comparison result, generate the (t-1)th snapshot;
[0009] Based on the initial snapshot and the second comparison result, generate the t-th snapshot;
[0010] Generate the document interface corresponding to the t-th snapshot based on the (t-1)-th snapshot, the t-th snapshot, and the document interface corresponding to the (t-1)-th snapshot.
[0011] Another aspect of this application provides a document interface generation apparatus, including:
[0012] The acquisition unit is used to respond to the interface playback command and acquire the initial snapshot, the first comparison result and the second comparison result for the target document from the database. The first comparison result is the comparison result between the (t-1)th snapshot and the initial snapshot, and the second comparison result is the comparison result between the tth snapshot and the initial snapshot, where t is an integer greater than 2.
[0013] The first generation unit is used to generate the (t-1)th snapshot based on the initial snapshot and the first comparison result;
[0014] The second generation unit is used to generate the t-th snapshot based on the initial snapshot and the second comparison result;
[0015] The third generation unit is used to generate the document interface corresponding to the t-th snapshot based on the (t-1)-th snapshot, the t-th snapshot, and the document interface corresponding to the (t-1)-th snapshot.
[0016] In one possible design, in another implementation of another aspect of the embodiments of this application, the third generating unit is specifically used for:
[0017] The (t-1)th snapshot is compared with the tth snapshot to obtain the third comparison result. Each snapshot contains a script attribute list, which contains script attributes and their corresponding attribute values.
[0018] Based on the third comparison result and the document interface corresponding to the (t-1)th snapshot, generate the document interface corresponding to the tth snapshot.
[0019] In one possible design, in another implementation of another aspect of the embodiments of this application, the third generation unit generates the document interface corresponding to the t-th snapshot based on the third comparison result and the document interface corresponding to the (t-1)-th snapshot, including:
[0020] Based on the third comparison result, the script attribute whose attribute value is different from that in the t-th snapshot and the (t-1)-th snapshot is determined and used as the first script attribute;
[0021] Modify the document interface corresponding to the (t-1)th snapshot based on the attribute value of the first script attribute to generate the document interface corresponding to the tth snapshot.
[0022] In one possible design, in another implementation of another aspect of the embodiments of this application, the first generating unit is further configured to:
[0023] Based on the initial snapshot and the fourth comparison result, the (t-2)th snapshot is generated, where the fourth comparison result is the comparison result between the (t-2)th snapshot stored in the database and the initial snapshot;
[0024] The (t-1)th snapshot is compared with the (t-2)th snapshot to obtain the fifth comparison result;
[0025] Based on the fifth comparison result and the document interface corresponding to the (t-2)th snapshot, generate the document interface corresponding to the (t-1)th snapshot.
[0026] In one possible design, in another implementation of another aspect of the embodiments of this application, the third generation unit compares the (t-1)th snapshot with the tth snapshot to obtain the third comparison result, which includes:
[0027] Get the attribute list of the (t-1)th snapshot and the attribute list of the tth snapshot;
[0028] Determine the script attribute whose attribute value is different from that in the attribute list of the t-th snapshot and is used as the second script attribute;
[0029] The second script attribute with a different attribute value is identified as the third comparison result.
[0030] In one possible design, in another implementation of another aspect of the embodiments of this application, the first generating unit is specifically used for:
[0031] Based on the first comparison result, the script attribute that differs from the attribute value in the (t-1)th snapshot and the initial snapshot is determined and used as the third script attribute;
[0032] Get the attribute value of the third script attribute;
[0033] Based on the attribute value of the third script attribute, modify the attribute value of the script attribute corresponding to the third script attribute in the initial snapshot to obtain the (t-1)th snapshot.
[0034] In one possible design, in another implementation of another aspect of the embodiments of this application, the document interface generation apparatus further includes:
[0035] Processing unit, the processing unit is used for:
[0036] Create t snapshots of the target document corresponding to t time points, where t time points include the initial time point and (t-1) time points when the target document executes the callback function for each frame based on the timer;
[0037] The (t-1) snapshots are compared with the initial snapshot to obtain (t-1) comparison results. The (t-1) snapshots are the other snapshots among the t snapshots excluding the initial snapshot.
[0038] The initial snapshot and the initial time are stored as a pair of information in the database;
[0039] The (t-1) comparison results and (t-1) time points are stored as (t-1) information pairs in the database.
[0040] A third aspect of this application provides a computer device including at least one connected processor, memory, and transceiver, wherein the memory is used to store program code, and the processor is used to invoke the program code in the memory to execute the steps of the document interface generation method described in the above aspects.
[0041] A fourth aspect of this application provides a computer storage medium including instructions that, when executed on a computer, cause the computer to perform the steps of the document interface generation method described in the above aspects.
[0042] In summary, it can be seen that in this embodiment, the document interface generation device only needs to obtain the initial snapshot, the first comparison result, and the second comparison result of the document from the database when generating the document interface. The first comparison result is the comparison result between the (t-1)th snapshot and the initial snapshot, and the second comparison result is the comparison result between the t-th snapshot and the initial snapshot. The (t-1)th snapshot is generated based on the initial snapshot and the first comparison result, and the t-th snapshot is generated based on the initial snapshot and the second comparison result. Finally, the document interface corresponding to the t-th snapshot can be generated based on the (t-1)th snapshot, the t-th snapshot, and the document interface corresponding to the (t-1)th snapshot. Therefore, during document interface playback, only the initial snapshot of the document and the comparison result between the snapshots after the initial snapshot and the initial snapshot are needed to generate the document interface. Compared to storing multiple data entries at the same refresh rate, less data needs to be processed during interface playback, thus reducing the playback time. Attached Figure Description
[0043] Figure 1 A schematic diagram of the document interface generation system is provided for the embodiments of this application:
[0044] Figure 2A flowchart illustrating a method for generating a document interface as provided in an embodiment of this application;
[0045] Figure 3 A schematic diagram showing the initial snapshot of the target document stored in the database and the comparison results provided in the embodiments of this application;
[0046] Figure 4 A virtual structural diagram of the document interface generation apparatus provided in the embodiments of this application;
[0047] Figure 5 This is a schematic diagram of another hardware structure of the server provided in an embodiment of this application. Detailed Implementation
[0048] The technical solutions in the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this application, and not all embodiments.
[0049] The terms "first," "second," etc., used in the specification, claims, and accompanying drawings of this application are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence. It should be understood that such data can be interchanged where appropriate so that the embodiments described herein can be implemented in a sequence other than that illustrated or described herein. Furthermore, the terms "comprising" and "having," and any variations thereof, are intended to cover non-exclusive inclusion. For example, a process, method, system, product, or device that includes a series of steps or modules is not necessarily limited to those explicitly listed, but may include other steps or modules not explicitly listed or inherent to these processes, methods, products, or devices. The division of modules appearing in this application is merely a logical division; in practical applications, other division methods may be used. For example, multiple modules may be combined or integrated into another system, or some feature vectors may be ignored or not executed. Additionally, the shown or discussed mutual coupling or direct coupling or communication connection may be through some interface, and the indirect coupling or communication connection between modules may be electrical or other similar forms, none of which are limited in this application. Furthermore, the modules or sub-modules described as separate components may or may not be physically separate, may or may not be physical modules, or may be distributed among multiple circuit modules. Some or all of the modules may be selected according to actual needs to achieve the purpose of the solution in this application.
[0050] The document interface playback function can provide relevant personnel with a more intuitive view of document changes. This application provides a document interface generation method that can be implemented based on cloud computing technology, enabling document interface playback. Cloud computing refers to the delivery and usage model of Internet Technology (IT) infrastructure, meaning obtaining the required resources in an on-demand and easily scalable manner through the network; broadly speaking, cloud computing refers to the delivery and usage model of services, meaning obtaining the required services in an on-demand and easily scalable manner through the network. Such services can be IT and software, Internet-related, or other services. Cloud computing is a product of the development and integration of traditional computer and network technologies such as grid computing, distributed computing, parallel computing, utility computing, network storage technologies, virtualization, and load balancing. With the development of the Internet, real-time data streams, and the diversification of connected devices, as well as the driving force of demands such as search services, social networks, mobile commerce, and open collaboration, cloud computing has developed rapidly. Unlike previous parallel and distributed computing, the emergence of cloud computing will drive a revolutionary change in the entire Internet model and enterprise management model from a conceptual perspective.
[0051] The realization of cloud computing relies on cloud technology, which refers to a hosting technology that unifies hardware, software, and network resources within a wide area network (WAN) or local area network (LAN) to achieve data computation, storage, processing, and sharing. Cloud technology is a general term encompassing network technology, information technology, integration technology, management platform technology, and application technology applied to the cloud computing business model. It can form resource pools, providing flexible and convenient on-demand access. Cloud computing technology will become a crucial support. Backend services of technical network systems require substantial computing and storage resources, such as video websites, image websites, and many portal websites. With the rapid development and application of the internet industry, every item may have its own identification mark in the future, requiring transmission to backend systems for logical processing. Data at different levels will be processed separately, and various industry data will all require robust system support, which can only be achieved through cloud computing.
[0052] Please see Figure 1 , Figure 1 This is a schematic diagram of the architecture of the document interface generation system in the embodiments of this application, such as... Figure 1As shown, the document interface generation system includes a terminal device 101, a network 102, and a server 103. The target document is deployed on the terminal device, and the terminal device 101 communicates with the server 103 through the network 102. The server involved in this application can be an independent physical server, a server cluster or distributed system composed of multiple physical servers, or a cloud server providing basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communication, middleware services, domain name services, security services, content delivery networks (CDNs), and big data and artificial intelligence platforms. This application will use a cloud gaming server as an example. The terminal device can be a smartphone, tablet, laptop, PDA, personal computer, smart TV, smartwatch, etc., but is not limited to these. The terminal device and the server can be directly or indirectly connected via wired or wireless communication, which is not limited in this application. The number of servers and terminal devices is also not limited.
[0053] Based on the above introduction, the following section will describe the method for generating the document interface in this application from the server's perspective. Please refer to [link / reference]. Figure 2 One embodiment of the document interface generation method in this application includes:
[0054] 201. Respond to the interface playback command and retrieve the initial snapshot, first comparison result, and second comparison result for the target document from the database.
[0055] In this embodiment, the user performs an interface playback command through a terminal device, which triggers the server to respond to the interface playback command and retrieves the initial snapshot, the first comparison result, and the second comparison result for the target document from the database. The first comparison result is the comparison result between the (t-1)th snapshot and the initial snapshot, and the second comparison result is the comparison result between the tth snapshot and the initial snapshot, where t is an integer greater than or equal to 2. That is, the database stores the initial snapshot of the target document at the initial moment, and the comparison results of the (t-1)th snapshots corresponding to the (t-1)th moments after the initial moment when the target document executes the callback function of each frame based on the timer, respectively, with the initial snapshot.
[0056] Understandably, the reason for not storing the (t-1) snapshots corresponding to (t-1) time points after the initial time of the target document, but only storing the initial snapshot at the initial time and the comparison results between the initial snapshot and the snapshots at each subsequent time point, is that the differences between the initial snapshot and the subsequent snapshots of the target document can be obtained, while reducing the data volume stored in the database. A database, simply put, can be viewed as an electronic filing cabinet—a place to store electronic files, where users can perform operations such as adding, querying, updating, and deleting data. A "database" is a collection of data stored together in a certain way, which can be shared by multiple users, has as little redundancy as possible, and is independent of applications.
[0057] It's important to note that the snapshot here refers to saving the DOM nodes of the target document at a specific moment in a certain format, called a snapshot. This snapshot allows us to reconstruct the complete form of the DOM nodes at that time. Furthermore, when a DOM node in the target document is modified, the corresponding changes will be reflected in the target document's display interface. Therefore, snapshots can demonstrate the results of these changes to the DOM nodes in the target document.
[0058] In one embodiment, the operation for generating the interface playback instruction includes at least one of the following: gesture operation, swipe operation, click operation, and voice control operation. For example, when a user clicks on the display interface corresponding to the target document, the server can receive the click operation. At this time, the click operation generates the interface playback instruction. That is, the operation instruction can be defined in advance. For example, a swipe operation can be defined in advance to trigger the playback operation of a certain interface of the target document (such as left swipe, right swipe, up swipe, and down swipe, etc.), or a click operation can be defined to trigger the playback operation of a certain interface of the target document (such as double-click, mouse swipe, long press, single click, simultaneous left and right mouse button press, and scroll wheel and middle mouse button, etc.), or a gesture operation can be defined to trigger the playback operation of a certain interface of the target document (such as swinging the wrist or arm to the left, swinging the wrist or arm to the right, such as four-finger contraction operation or three-finger swipe up operation, etc.), or a voice control operation can be defined to trigger the playback operation of a certain interface of the target document (such as receiving a sound of a certain interface of the target document). The above are only examples and do not represent a limitation on the operation for generating the interface playback instruction. Of course, the interface playback command can also be generated by setting a corresponding shortcut key on the input device. For example, if the input device is a keyboard, the "CTRL+A key" on the keyboard can be set as the trigger to generate a playback operation of a certain interface of the target document. The specific method is not limited.
[0059] In one embodiment, the server may perform the following operations to obtain an initial snapshot of the target document and (t-1) comparison results, and store them in the database:
[0060] Create t snapshots of the target document corresponding to t time points, where t time points include the initial time point and (t-1) time points when the target document executes the callback function for each frame based on the timer;
[0061] The (t-1) snapshots are compared with the initial snapshot to obtain (t-1) comparison results. The (t-1) snapshots are the other snapshots among the t snapshots excluding the initial snapshot.
[0062] The initial snapshot and the initial time are stored as a pair of information in the database;
[0063] The (t-1) comparison results and (t-1) time points are stored as (t-1) information pairs in the database.
[0064] In this embodiment, the server can create t snapshots of the target document corresponding to t time points. The t time points include the initial time point and (t-1) time points in which the target document executes each frame callback function based on the timer. That is, the server can first create an initial snapshot of the target document at the initial time point, and then use the timer (requestAnimationFrame) as a time advancer to create a new snapshot of the target document in each frame callback function. This can obtain t snapshots of the target document corresponding to t time points. Then, the snapshots created in each frame callback function using the timer as a time advancer are compared with the initial snapshot to obtain (t-1) comparison results (that is, the changes of the target document in each subsequent frame callback function). Finally, the initial snapshot and the initial time point are stored as an information pair in the database, and the (t-1) comparison results and (t-1) time points are stored as an information pair in the database.
[0065] It's important to note that when creating `t` snapshots, a JS object generation method can be used to traverse the DOM tree structure of the target document (which can be in Hyper Text Markup Language (HTML) format, Extensible Markup Language (XML) format, or any other format; there are no specific limitations. The DOM defines the standard methods for accessing and manipulating HTML documents, and it represents HTML documents as a tree structure). This generates a JS object consistent with the DOM tree structure; that is, the snapshot is stored in the database as a JS object. It's understandable that the script attributes mentioned above refer to elements in the target document, such as "heading" elements, "table" elements, "font" elements, etc., in HTML format. The list of script attributes is a list of all elements in the target document.
[0066] The following is combined Figure 3 This section explains the initial snapshot stored in the database and the various comparison results. Figure 3 A schematic diagram of the data stored in the database provided in the embodiments of this application.
[0067] In this dataset, 301 represents the information pair between the initial time and the initial snapshot; 302 represents the information pair between the first comparison result and time (t-1), where the first comparison result is the comparison result between the (t-1)th snapshot and the initial snapshot; and 303 represents the information pair between the second comparison result and time t, where the second comparison result is the comparison result between the tth snapshot and the initial snapshot. Time t is the time after time (t-1), which is the time when the callback function for each frame is executed after the initial time, using a timer (requestAnimationFrame) as a time advancer. Time t is the time when the tth snapshot is created, and time (t-1) is the time when the (t-1)th snapshot is created. Therefore, when playing back the target document, the initial snapshot, the comparison result between the tth snapshot and the initial snapshot, and the comparison result between the (t-1)th snapshot and the initial snapshot can be retrieved from the database, achieving fast playback of the target document interface.
[0068] 202. Based on the initial snapshot and the first comparison result, generate the (t-1)th snapshot.
[0069] In this embodiment, after obtaining the initial snapshot and the first comparison result, the server can generate the (t-1)th snapshot based on the initial snapshot and the first comparison result, since the first comparison result is the comparison result between the initial snapshot and the (t-1)th snapshot stored in the database. Specifically, the server can first determine the script attribute whose attribute value is different from that in the initial snapshot based on the first comparison result, and use it as the third script attribute. The server then obtains the attribute value of the third script attribute, and modifies the attribute value of the script attribute corresponding to the third script attribute in the initial snapshot based on the attribute value of the third script attribute, thus obtaining the (t-1)th snapshot. That is, after obtaining the initial snapshot and the comparison results of each subsequent snapshot with the initial snapshot, the server can first determine the attribute value difference of the script attribute between the snapshot corresponding to the comparison result and the initial snapshot based on the comparison result. This attribute value difference is the modification part of each snapshot relative to the initial snapshot. Therefore, the server can modify the initial snapshot based on the attribute value difference of the script attribute, thereby obtaining the snapshot corresponding to the comparison result.
[0070] Each snapshot contains a list of script attributes, which includes script attributes and their corresponding attribute values.
[0071] It is understandable that the first comparison result is the script attribute whose attribute value is different from that in the (t-1)th snapshot and the initial snapshot. Then, the script attribute whose attribute value is different after comparison is determined as the third script attribute. Based on the third script attribute, the attribute value corresponding to the same script attribute is obtained from the attribute list of the (t-1)th snapshot, and the attribute value is used as the attribute value of the third script attribute.
[0072] For example, if the attribute value of the script attribute corresponding to "Title" in the initial snapshot is "Aligned", and the attribute value of the script attribute corresponding to "Title" in the (t-1)th snapshot is "Centered", then the first comparison result indicates that the script attribute with a different attribute value between the initial snapshot and the (t-1)th snapshot is "Title", i.e., the third script attribute is "Title". Since the attribute value of the script attribute that is the same as the third script attribute in the (t-1)th snapshot is "Centered", this attribute value "Centered" is used as the attribute value of the third script attribute. Therefore, when generating the (t-1)th snapshot based on the first comparison result and the initial snapshot, it is only necessary to modify the script attribute corresponding to "Title" in the initial snapshot to "Centered".
[0073] It should be noted that the first comparison result includes, but is not limited to, the following changes:
[0074] 1. Based on the change of DOM node type, the old node is directly unloaded and the new node is loaded. The old DOM node, including its child nodes, will be unloaded and replaced with the new DOM node.
[0075] 2. If the node type is the same, the node update can be completed by directly changing the attribute or attribute value based on the change of the attribute.
[0076] 3. Based on changes in text content, a text pair is also a Text Node, so you can directly modify the text content. We call this process TEXT.
[0077] 4. Perform at least one of the following operations on the child nodes of the DOM: move, add, or delete. For example, add a node F between nodes B and C in DOM nodes A and B, C, D, and E. If the first comparison result is that a node F is added between nodes B and C in DOM nodes A and B, C, D, and E, then the difference between the (t-1)th snapshot and the initial snapshot is the node F. Therefore, adding a node F between nodes B and C will yield the (t-1)th snapshot. It's important to understand that the above example only uses a single modification in the first comparison result. In practical applications, multiple modifications can be included, such as simultaneously modifying text and adding nodes. The specific implementation is not limited, as long as the comparison result and the initial snapshot can generate the corresponding snapshot.
[0078] 203. Generate the t-th snapshot based on the initial snapshot and the second comparison result.
[0079] In this embodiment, after obtaining the initial snapshot and the second comparison result, the server can generate the t-th snapshot based on the initial snapshot and the second comparison result, since the second comparison result is a comparison between the initial snapshot and the t-th snapshot stored in the database. It is understood that step 202 above has already provided a detailed explanation of how to generate the corresponding snapshot based on the initial snapshot and the comparison result, and will not be repeated here.
[0080] It should be noted that the server can generate the (t-1)th snapshot based on the initial snapshot and the first comparison result through step 202, and generate the tth snapshot based on the initial snapshot and the second comparison result through step 203. However, there is no restriction on the order of execution between these two steps. Step 202 can be executed first, or step 203 can be executed first, or they can be executed simultaneously. There is no specific limitation.
[0081] 204. Based on the (t-1)th snapshot, the tth snapshot, and the document interface corresponding to the (t-1)th snapshot, generate the document interface corresponding to the tth snapshot.
[0082] In this embodiment, after the server generates the (t-1)th snapshot and the tth snapshot, it can generate the document interface corresponding to the tth snapshot based on the (t-1)th snapshot, the tth snapshot, and the document interface corresponding to the (t-1)th snapshot.
[0083] In one embodiment, the server generates the document interface corresponding to the t-th snapshot based on the (t-1)-th snapshot, the t-th snapshot, and the document interface corresponding to the (t-1)-th snapshot, including:
[0084] The (t-1)th snapshot is compared with the tth snapshot to obtain the third comparison result;
[0085] Based on the third comparison result and the document interface corresponding to the (t-1)th snapshot, the document interface corresponding to the tth snapshot is generated. Each snapshot contains a script attribute list, which contains script attributes and their corresponding attribute values.
[0086] In this embodiment, the server can first compare the (t-1)th snapshot with the tth snapshot to obtain a third comparison result. Specifically, it can obtain the attribute list of the (t-1)th snapshot and the attribute list of the tth snapshot respectively. Then, it can identify the second script attribute whose attribute value differs from that of the attribute list of the tth snapshot and is determined as the third comparison result. Since the snapshot exists in the form of a JS object, the difference between the two snapshots can be obtained by comparing their attribute lists. This difference is the third comparison result. The server can then generate the document interface corresponding to the tth snapshot based on the third comparison result and the document interface corresponding to the (t-1)th snapshot. For example, if the attribute value of the script attribute corresponding to "Title" in the (t-1)th snapshot is "Aligned", and the attribute value of the script attribute corresponding to "Title" in the tth snapshot is "Centered", then the third comparison result can be determined to be the attribute value of the script attribute corresponding to "Title" and "Title" in the tth snapshot, which is "Centered". Therefore, when generating the document interface corresponding to the tth snapshot based on the third comparison result and the document interface corresponding to the (t-1)th snapshot, it is only necessary to modify the script attribute corresponding to "Title" in the document interface corresponding to the (t-1)th snapshot to "Centered" to obtain the document interface corresponding to the tth snapshot.
[0087] In one embodiment, the server generates the document interface corresponding to the t-th snapshot based on the third comparison result and the document interface corresponding to the (t-1)-th snapshot, including:
[0088] Based on the third comparison result, the script attribute whose attribute value is different from that in the t-th snapshot and the (t-1)-th snapshot is determined and used as the first script attribute;
[0089] Modify the document interface corresponding to the (t-1)th snapshot based on the attribute value of the first script attribute to generate the document interface corresponding to the tth snapshot.
[0090] In this embodiment, after obtaining the third comparison result, the server can determine the script attribute whose attribute value differs from that in the t-th snapshot and the (t-1)-th snapshot, and use it as the first script attribute. This determines the script attribute whose attribute value differs from that in the two snapshots. Then, the document interface corresponding to the (t-1)-th snapshot can be modified using the attribute value of this script attribute to generate the document interface corresponding to the t-th snapshot. For example, if the attribute value of the script attribute corresponding to "font" in the (t-1)-th snapshot is "4-point Songti" and the attribute value of the script attribute corresponding to "font" in the t-th snapshot is "5-point Kaiti", the third comparison result is the script attribute corresponding to "font" and "5-point Kaiti". When generating the document interface corresponding to the t-th snapshot, it is only necessary to modify the attribute value of the script attribute corresponding to "font" in the document interface corresponding to the (t-1)-th snapshot to "5-point Kaiti". The differences between the two snapshots in the comparison results have been explained above. At the same time, the document interface (i.e. the old interface) corresponding to the (t-1)th snapshot has also been obtained. Then, the first script attribute with different attribute value in the tth snapshot compared with the (t-1)th snapshot can be used to modify the document interface corresponding to the (t-1)th snapshot to generate the document interface corresponding to the tth snapshot.
[0091] It should be noted that the server can also retrieve a fourth comparison result from the database. This fourth comparison result is the comparison result between the (t-2)th snapshot stored in the database and the initial snapshot. Then, based on the initial snapshot and the fourth comparison result, a (t-2)th snapshot is generated. The (t-1)th snapshot is then compared with the (t-2)th snapshot to obtain a fifth comparison result. Finally, based on the fifth comparison result and the document interface corresponding to the (t-2)th snapshot, the interface corresponding to the (t-1)th snapshot is generated. This process continues, allowing the server to generate the document interface corresponding to each snapshot based on the initial snapshot stored in the database and the comparison results between each snapshot and the initial snapshot, thus enabling playback of the target document's document interface. The snapshot comparison and the generation of new snapshots based on the initial snapshot and comparison results have been explained in detail above, and will not be repeated here.
[0092] In summary, it can be seen that in this embodiment, the document interface generation device only needs to obtain the initial snapshot, the first comparison result, and the second comparison result of the document from the database when generating the document interface. The first comparison result is the comparison result between the (t-1)th snapshot and the initial snapshot, and the second comparison result is the comparison result between the t-th snapshot and the initial snapshot. The (t-1)th snapshot is generated based on the initial snapshot and the first comparison result, and the t-th snapshot is generated based on the initial snapshot and the second comparison result. Finally, the document interface corresponding to the t-th snapshot can be generated based on the (t-1)th snapshot, the t-th snapshot, and the document interface corresponding to the (t-1)th snapshot. Therefore, during document interface playback, only the initial snapshot of the document and the comparison result between the snapshots after the initial snapshot and the initial snapshot are needed to generate the document interface. Compared to storing multiple data entries at the same refresh rate, less data needs to be processed during interface playback, thus reducing the playback time.
[0093] The embodiments of this application have been described above from the perspective of the method for generating a document interface. The embodiments of this application will now be described below from the perspective of the device for generating a document interface.
[0094] Please see Figure 4 This application provides a document interface generation device, which includes:
[0095] The acquisition unit 401 is used to respond to the interface playback command and acquire the initial snapshot, the first comparison result and the second comparison result for the target document from the database. The first comparison result is the comparison result between the (t-1)th snapshot and the initial snapshot, and the second comparison result is the comparison result between the tth snapshot and the initial snapshot, where t is an integer greater than 2.
[0096] The first generation unit 402 is used to generate the (t-1)th snapshot based on the initial snapshot and the first comparison result;
[0097] The second generation unit 403 is used to generate the t-th snapshot based on the initial snapshot and the second comparison result;
[0098] The third generation unit 404 is used to generate the document interface corresponding to the t-th snapshot based on the (t-1)-th snapshot, the t-th snapshot, and the document interface corresponding to the (t-1)-th snapshot.
[0099] In one possible design, in another implementation of another aspect of the embodiments of this application, the third generation unit 404 is specifically used for:
[0100] The (t-1)th snapshot is compared with the tth snapshot to obtain the third comparison result. Each snapshot contains a script attribute list, which contains script attributes and their corresponding attribute values.
[0101] Based on the third comparison result and the document interface corresponding to the (t-1)th snapshot, generate the document interface corresponding to the tth snapshot.
[0102] In one possible design, in another implementation of another aspect of the embodiments of this application, the third generation unit 404 generates the document interface corresponding to the t-th snapshot based on the third comparison result and the document interface corresponding to the (t-1)-th snapshot, including:
[0103] Based on the third comparison result, the script attribute whose attribute value is different from that in the t-th snapshot and the (t-1)-th snapshot is determined and used as the first script attribute;
[0104] Modify the document interface corresponding to the (t-1)th snapshot based on the attribute value of the first script attribute to generate the document interface corresponding to the tth snapshot.
[0105] In one possible design, in another implementation of another aspect of the embodiments of this application, the first generating unit 402 is further configured to:
[0106] Based on the initial snapshot and the fourth comparison result, the (t-2)th snapshot is generated, where the fourth comparison result is the comparison result between the (t-2)th snapshot stored in the database and the initial snapshot;
[0107] The (t-1)th snapshot is compared with the (t-2)th snapshot to obtain the fifth comparison result;
[0108] Based on the fifth comparison result and the document interface corresponding to the (t-2)th snapshot, generate the document interface corresponding to the (t-1)th snapshot.
[0109] In one possible design, in another implementation of another aspect of the embodiments of this application, the third generation unit 404 compares the (t-1)th snapshot with the tth snapshot to obtain a third comparison result including:
[0110] Get the attribute list of the (t-1)th snapshot and the attribute list of the tth snapshot;
[0111] Determine the script attribute whose attribute value is different from that in the attribute list of the t-th snapshot and is used as the second script attribute;
[0112] The second script attribute with a different attribute value is identified as the third comparison result.
[0113] In one possible design, in another implementation of another aspect of the embodiments of this application, the first generating unit 402 is specifically used for:
[0114] Based on the first comparison result, the script attribute that differs from the attribute value in the (t-1)th snapshot and the initial snapshot is determined and used as the third script attribute;
[0115] Get the attribute value of the third script attribute;
[0116] Based on the attribute value of the third script attribute, modify the attribute value of the script attribute corresponding to the third script attribute in the initial snapshot to obtain the (t-1)th snapshot.
[0117] In one possible design, in another implementation of another aspect of the embodiments of this application, the apparatus further includes:
[0118] Processing unit 405, processing unit 405 is used for:
[0119] Create t snapshots of the target document corresponding to t time points, where t time points include the initial time point and (t-1) time points when the target document executes the callback function for each frame based on the timer;
[0120] The (t-1) snapshots are compared with the initial snapshot to obtain (t-1) comparison results. The (t-1) snapshots are the other snapshots among the t snapshots excluding the initial snapshot.
[0121] The initial snapshot and the initial time are stored as a pair of information in the database;
[0122] The (t-1) comparison results and (t-1) time points are stored as (t-1) information pairs in the database.
[0123] This application also provides another document interface generation apparatus, which is deployed on a server. Please refer to [link to previous document interface generation apparatus]. Figure 5 , Figure 5This is a schematic diagram of a server structure provided in an embodiment of the present invention. The server 500 can vary significantly due to different configurations or performance characteristics. It may include one or more central processing units (CPUs) 522 (e.g., one or more processors) and a memory 532, and one or more storage media 530 (e.g., one or more mass storage devices) for storing application programs 542 or data 544. The memory 532 and storage media 530 can be temporary or persistent storage. The program stored in the storage media 530 may include one or more modules (not shown in the diagram), each module including a series of instruction operations on the server. Furthermore, the CPU 522 may be configured to communicate with the storage media 530 and execute the series of instruction operations stored in the storage media 530 on the server 500.
[0124] Server 500 may also include: one or more power supplies 526, one or more wired or wireless network interfaces 550, one or more input / output interfaces 558, and at least one of one or more operating systems 541, wherein the operating system 541 may be Windows Server™, Mac OS X™, Unix™, Linux™, or FreeBSD™, etc.
[0125] The steps performed by the control device in the above embodiments can be based on this Figure 5 The server structure shown.
[0126] This application also provides a computer-readable storage medium storing a computer program thereon. When executed by a computer, the computer program implements the method flow related to the document interface generation apparatus in any of the above method embodiments. Correspondingly, the computer can be the aforementioned document interface generation apparatus.
[0127] This application also provides a computer program or a computer program product including a computer program, which, when executed on a computer, causes the computer to implement the method flow related to the document interface generation device in any of the above method embodiments. Correspondingly, the computer can be the aforementioned document interface generation device.
[0128] In the above Figure 2 The corresponding embodiments can be implemented entirely or partially through software, hardware, firmware, or any combination thereof. When implemented using software, it can be implemented entirely or partially in the form of a computer program product.
[0129] The computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, all or part of the processes or functions described in the embodiments of this application are generated. The computer may be a general-purpose computer, a special-purpose computer, a computer network, or other programmable device. The computer instructions may be stored in a computer-readable storage medium or transmitted from one computer-readable storage medium to another. For example, the computer instructions may be transmitted from one website, computer, server, or data center to another website, computer, server, or data center via wired (e.g., coaxial cable, fiber optic, digital subscriber line (DSL)) or wireless (e.g., infrared, wireless, microwave, etc.) means. The computer-readable storage medium may be any available medium that a computer can store or a data storage device such as a server or data center that integrates one or more available media. The available medium may be a magnetic medium (e.g., floppy disk, hard disk, magnetic tape), an optical medium (e.g., DVD), or a semiconductor medium (e.g., a solid-state disk (SSD)).
[0130] It should be understood that the processor mentioned in this application can be a Central Processing Unit (CPU), or other general-purpose processors, digital signal processors (DSPs), application-specific integrated circuits (ASICs), field-programmable gate arrays (FPGAs), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. A general-purpose processor can be a microprocessor or any conventional processor.
[0131] It should also be understood that the number of processors in this application can be one or more, and the specific number can be adjusted according to the actual application scenario. This is merely an illustrative example and is not intended to limit the application. The number of memory in the embodiments of this application can also be one or more, and the specific number can be adjusted according to the actual application scenario. This is merely an illustrative example and is not intended to limit the application.
[0132] It should also be noted that when the document interface generation device includes a processor (or processing unit) and a memory, the processor in this application may be integrated with the memory, or the processor and the memory may be connected through an interface. The specific configuration can be adjusted according to the actual application scenario and is not limited.
[0133] Those skilled in the art will clearly understand that, for the sake of convenience and brevity, the specific working processes of the systems, devices, and units described above can be referred to the corresponding processes in the foregoing method embodiments, and will not be repeated here.
[0134] In the several embodiments provided in this application, it should be understood that the disclosed systems, apparatuses, and methods can be implemented in other ways. For example, the apparatus embodiments described above are merely illustrative; for instance, the division of units is only a logical functional division, and in actual implementation, there may be other division methods. For example, multiple units or components may be combined or integrated into another system, or some features may be ignored or not executed. Furthermore, the coupling or direct coupling or communication connection shown or discussed may be an indirect coupling or communication connection between apparatuses or units through some interfaces, and may be electrical, mechanical, or other forms.
[0135] The units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the units can be selected to achieve the purpose of this embodiment according to actual needs.
[0136] Furthermore, the functional units in the various embodiments of this application can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit. The integrated unit can be implemented in hardware or as a software functional unit.
[0137] If the integrated unit is implemented as a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of this application, in essence, or the part that contributes to the prior art, or all or part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, a server, or other device, etc.) to execute this application. Figure 2 All or part of the steps of the method for generating the document interface.
[0138] It should be understood that the storage medium or memory mentioned in this application may include volatile memory or non-volatile memory, or both. Non-volatile memory may be read-only memory (ROM), programmable read-only memory (PROM), erasable programmable read-only memory (EPROM), electrically erasable programmable read-only memory (EEPROM), or flash memory. Volatile memory may be random access memory (RAM), which is used as an external cache. By way of example, but not limitation, many forms of RAM are available, such as Static RAM (SRAM), Dynamic RAM (DRAM), Synchronous DRAM (SDRAM), Double Data Rate SDRAM (DDR SDRAM), Enhanced Synchronous DRAM (ESDRAM), Synchronous Link DRAM (SLDRAM), and Direct Rambus RAM (DR RAM).
[0139] It should be noted that the memories described herein are intended to include, but are not limited to, these and any other suitable types of memories.
[0140] The above-described embodiments are only used to illustrate the technical solutions of this application, and are not intended to limit them. Although this application has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some of the technical features. Such modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the scope of the technical solutions of the embodiments of this application.
Claims
1. A method for generating a document interface, characterized in that, include: In response to the interface playback command, the system retrieves an initial snapshot, a first comparison result, and a second comparison result for the target document from the database. The first comparison result is the comparison result between the (t-1)th snapshot and the initial snapshot, and the second comparison result is the comparison result between the t-th snapshot and the initial snapshot, where t is an integer greater than 2. The first comparison result includes script attributes whose attribute values differ between the (t-1)th snapshot and the initial snapshot. Based on the initial snapshot and the first comparison result, the (t-1)th snapshot is generated; The t-th snapshot is generated based on the initial snapshot and the second comparison result; The (t-1)th snapshot is compared with the tth snapshot to obtain the third comparison result; The document interface corresponding to the t-th snapshot is generated based on the third comparison result and the document interface corresponding to the (t-1)-th snapshot. Each snapshot contains a script attribute list, which contains script attributes and attribute values corresponding to the script attributes.
2. The method according to claim 1, characterized in that, The step of generating the document interface corresponding to the t-th snapshot based on the third comparison result and the document interface corresponding to the (t-1)-th snapshot includes: Based on the third comparison result, the script attribute whose attribute value is different from that in the t-th snapshot and the (t-1)-th snapshot is determined and used as the first script attribute; The document interface corresponding to the (t-1)th snapshot is modified according to the attribute value of the first script attribute to generate the document interface corresponding to the tth snapshot.
3. The method according to claim 1, characterized in that, The method further includes: Based on the initial snapshot and the fourth comparison result, the (t-2)th snapshot is generated, wherein the fourth comparison result is the comparison result between the (t-2)th snapshot stored in the database and the initial snapshot; The (t-1)th snapshot is compared with the (t-2)th snapshot to obtain the fifth comparison result; The document interface corresponding to the (t-1)th snapshot is generated based on the fifth comparison result and the document interface corresponding to the (t-2)th snapshot.
4. The method according to claim 1, characterized in that, The step of comparing the (t-1)th snapshot with the tth snapshot to obtain the third comparison result includes: Obtain the attribute list of the (t-1)th snapshot and the attribute list of the tth snapshot; The script attribute whose attribute value is different from that in the attribute list of the t-th snapshot is determined and used as the second script attribute; The second script attribute with different attribute values is determined as the third comparison result.
5. The method according to any one of claims 1 to 4, characterized in that, The step of generating the (t-1)th snapshot based on the initial snapshot and the first comparison result includes: Based on the first comparison result, the script attribute whose attribute value is different from that in the (t-1)th snapshot is determined and used as the third script attribute; Obtain the attribute value of the third script attribute; Based on the attribute value of the third script attribute, the attribute value of the script attribute corresponding to the third script attribute in the initial snapshot is modified to obtain the (t-1)th snapshot.
6. The method according to any one of claims 1 to 4, characterized in that, Before the response interface playback command, the method further includes: Create t snapshots of the target document corresponding to t time points, where the t time points include the initial time point and (t-1) time points when the target document executes the callback function for each frame based on the timer; The (t-1) snapshots are compared with the initial snapshot to obtain (t-1) comparison results, where the (t-1) snapshots are the other snapshots among the t snapshots besides the initial snapshot; The initial snapshot and the initial time are stored as a pair of information in the database; The (t-1) comparison results and the (t-1) time points are stored as (t-1) information pairs in the database.
7. A document interface generation device, characterized in that, include: The acquisition unit is used to respond to the interface playback command and acquire an initial snapshot, a first comparison result, and a second comparison result for the target document from the database. The first comparison result is the comparison result between the (t-1)th snapshot and the initial snapshot, and the second comparison result is the comparison result between the t-th snapshot and the initial snapshot, where t is an integer greater than 2. The first comparison result includes script attributes whose attribute values are different between the (t-1)th snapshot and the initial snapshot. The first generation unit is configured to generate the (t-1)th snapshot based on the initial snapshot and the first comparison result; The second generation unit is used to generate the t-th snapshot based on the initial snapshot and the second comparison result; The third generation unit is used to generate the document interface corresponding to the t-th snapshot based on the (t-1)-th snapshot, the t-th snapshot, and the document interface corresponding to the (t-1)-th snapshot; The third generation unit is specifically used for: The (t-1)th snapshot is compared with the tth snapshot to obtain the third comparison result; The document interface corresponding to the t-th snapshot is generated based on the third comparison result and the document interface corresponding to the (t-1)-th snapshot. Each snapshot contains a script attribute list, which contains script attributes and attribute values corresponding to the script attributes.
8. The apparatus according to claim 7, characterized in that, The third generation unit generates the document interface corresponding to the t-th snapshot based on the third comparison result and the document interface corresponding to the (t-1)-th snapshot, including: Based on the third comparison result, the script attribute whose attribute value is different from that in the t-th snapshot and the (t-1)-th snapshot is determined and used as the first script attribute; The document interface corresponding to the (t-1)th snapshot is modified according to the attribute value of the first script attribute to generate the document interface corresponding to the tth snapshot.
9. The apparatus according to claim 7, characterized in that, The first generation unit is further configured to: Based on the initial snapshot and the fourth comparison result, the (t-2)th snapshot is generated, wherein the fourth comparison result is the comparison result between the (t-2)th snapshot stored in the database and the initial snapshot; The (t-1)th snapshot is compared with the (t-2)th snapshot to obtain the fifth comparison result; The document interface corresponding to the (t-1)th snapshot is generated based on the fifth comparison result and the document interface corresponding to the (t-2)th snapshot.
10. The apparatus according to claim 7, characterized in that, The third generation unit compares the (t-1)th snapshot with the tth snapshot to obtain the third comparison result, which includes: Obtain the attribute list of the (t-1)th snapshot and the attribute list of the tth snapshot; The script attribute whose attribute value is different from that in the attribute list of the t-th snapshot is determined and used as the second script attribute; The second script attribute with different attribute values is determined as the third comparison result.
11. The apparatus according to any one of claims 7-10, characterized in that, The first generation unit is specifically used for: Based on the first comparison result, the script attribute whose attribute value is different from that in the (t-1)th snapshot is determined and used as the third script attribute; Obtain the attribute value of the third script attribute; Based on the attribute value of the third script attribute, the attribute value of the script attribute corresponding to the third script attribute in the initial snapshot is modified to obtain the (t-1)th snapshot.
12. The apparatus according to any one of claims 7-10, characterized in that, The device also includes a processing unit, which is used for: Create t snapshots of the target document corresponding to t time points, where the t time points include the initial time point and (t-1) time points when the target document executes the callback function for each frame based on the timer; The (t-1) snapshots are compared with the initial snapshot to obtain (t-1) comparison results, where the (t-1) snapshots are the other snapshots among the t snapshots besides the initial snapshot; The initial snapshot and the initial time are stored as a pair of information in the database; The (t-1) comparison results and the (t-1) time points are stored as (t-1) information pairs in the database.
13. A computer device, characterized in that, include: Memory, processor, and bus system; The memory is used to store programs; The processor is configured to execute a program in the memory, and the processor is configured to execute the method of any one of claims 1 to 6 according to instructions in the program code; The bus system is used to connect the memory and the processor to enable communication between the memory and the processor.
14. A computer storage medium, characterized in that, It includes instructions that, when executed on a computer, cause the computer to perform the method as described in any one of claims 1-6.
15. A computer program product, characterized in that, The computer program product includes instructions that, when executed on a computer device, cause the computer to perform the method as described in any one of claims 1-6.
Citation Information
Patent Citations
Page snapshot display method and device, electronic equipment and storage medium
CN112307384A
Generating a Document Object Model (DOM) Differential
US20170357624A1