[0054] In order to make the objectives, technical solutions, and advantages of the present invention clearer, the present invention will be further described in detail below with reference to the accompanying drawings and embodiments.
[0055] For clarity of expression, first define and explain the movement direction of the present invention: In view of the fact that when browsing the page, the user scrolls the page more along the Y axis in the two-dimensional coordinate, the focus movement method and device of the present invention only use the Y axis direction The focus movement of is taken as an example for description. The focus movement method in the X-axis direction is the same as the focus movement method in the Y-axis direction, and will not be repeated here.
[0056] image 3 It is a flowchart of the focus moving method based on the embedded browser of the present invention. Now combined image 3 , The focus moving method based on the embedded browser of the present invention is described, and the details are as follows:
[0057] Step 300: Start the browser and generate a render tree of the page to be browsed;
[0058] This step includes: step 3001, start the browser and initialize; step 3002, the browser parses the tags of the page to be browsed to generate a Document Object Model (DOM) node tree; step 3003, typeset the dom node tree to generate typeset ( render) tree.
[0059] The above-mentioned typesetting (render) tree for generating the page to be browsed can be generated by using an existing browser parsing engine, and the specific generating method will not be described here.
[0060] Step 301: Extract nodes that support true focus from the typesetting (render) tree, and generate multiple true focus linked lists;
[0061] This step includes: step 3011, calculate the number of true focus linked lists N according to the content height of the page to be viewed and the screen height, and generate N true focus linked lists; step 3012, according to each node contained in the typesetting (render) tree Extract all the nodes that support true focus in the page to be browsed; step 3013, use the Y-axis coordinates and screen height of the nodes that support true focus in the page to be browsed to determine to add the nodes that support true focus in the page to be browsed into one True focus list.
[0062] Among them, the content height of the page to be viewed and the screen height refer to the height in the Y-axis direction, usually expressed in pixels; the information contained in each node in the typesetting (render) tree includes at least: the X-axis of the node The coordinate of the direction, the coordinate of the Y-axis direction and whether it supports true focus; the coordinate of the X-axis direction and the coordinate of the Y-axis direction of the node are also expressed by the way of pixels.
[0063] When N true focus linked lists are generated in step 3011, the number of true focus linked lists N is the quotient of the content height of the page to be viewed and the screen height rounded up. For example, the content height of the page to be viewed is 1530px, and the screen height is 720px, the method of step 3011 can be used to generate 3 true focus linked lists; among them, px represents the pixel.
[0064] In step 3012, the method for extracting nodes that support true focus from all nodes included in the render tree may be based on whether the information contained in the node supports true focus or not, or using a method to determine whether to support true focus. Whether the node supports the true focus function to extract, for example, all nodes in the typesetting (render) tree are inherited from the parent class named node, which defines a virtual function to determine whether the node supports true focus virtual bool is Focusable()const, by calling this function to determine whether a node supports true focus, or use the existing method of determining whether a node supports true focus to achieve extraction, which will not be repeated here.
[0065] In step 3013, according to the content height interval of the page to be browsed corresponding to each true focus linked list and the coordinates of the Y-axis direction of the node that supports true focus in the page to be browsed, determine the true focus of the node that supports true focus in the page to be browsed. Focus linked list, for example, the Y-axis coordinate of the node where the a tag is located is 722px, and the content height range of the page to be viewed corresponding to the second true focus linked list is 721px to 1440px, then the node where the a tag is located belongs to the second true focus Linked list.
[0066] Step 302: Determine the target true focus list according to the true focus list of the node where the current true focus belongs and the moving direction;
[0067] This step includes: step 3021, judging whether the moving direction is the vertical direction, if yes, go to step 3023, otherwise go to step 3022; step 3022, determine the true focus linked list of the node where the current true focus belongs as the target true focus linked list; step 3023 , Judge whether the moving direction is downward, if yes, go to step 3024, otherwise go to step 3025; step 3024, determine the true focus list of the node where the current true focus belongs and the next true focus list of the true focus list as Target true focus linked list; Step 3025, the true focus linked list of the node where the current true focus belongs and the previous true focus linked list of the true focus linked list are determined as the target true focus linked list.
[0068] The vertical direction in the present invention refers to the Y-axis direction; downward movement refers to movement in the negative direction of the Y-axis, and upward movement refers to movement in the positive direction of the Y-axis.
[0069] Wherein, the above-mentioned method of judging the moving direction can be realized by using an existing judging method, for example, the moving direction of the focus is determined according to the instruction or information indicating the moving direction converted from the moving direction, and the specific method is not repeated here; The target true focus linked list is the true focus linked list of the node to be switched to in the page to be browsed.
[0070] The next true focus list of the true focus list in step 3024 and the last true focus list of the true focus list in step 3025 are determined with the moving direction as the reference direction, for example, the node where the current true focus belongs The true focus list is the nth true focus list. If it is determined that the moving direction is vertical downward movement, the next true focus list of the true focus list is the n+1 true focus list. If the movement direction is determined to move vertically upward , Then the last true focus linked list of the true focus linked list is the n-1th true focus linked list, and the N true focus linked lists are arranged in the Y-axis direction from the top to the bottom of the page to be browsed.
[0071] Step 303: Determine the node where the true focus of the target is located according to the target true focus linked list and switch;
[0072] This step includes: step 3031, calculating the distance between the true focus-supporting node included in the target true focus linked list and the node where the current true focus is located; step 3032, comparing the distance in step 3031, and calculating the node with the closest distance to the node where the current true focus is located As the node where the true focus of the target is located; step 3033, switch from the node where the current true focus is located to the node where the true focus of the target is located.
[0073] Step 304: End.
[0074] Figure 4 It is a schematic diagram of the structure of the focus mobile device based on the embedded browser of the present invention. Now combined Figure 4 , The focus mobile device based on the embedded browser of the present invention is described, specifically as follows:
[0075] The focus mobile device based on the embedded browser of the present invention includes: a parsing engine 401, a linked list generation module 402, and a mobile control module 403.
[0076] The parsing engine 401 is used to generate a render tree of the page to be browsed when the browser is started. Specifically, after the browser is started and initialized, the parsing engine 401 parses the tags of the page to be browsed, generates a dom node tree, and typesets the dom node tree to generate a typeset (render) tree.
[0077] The linked list generation module 402 extracts nodes that support true focus from the render tree generated by the parsing engine 401, and generates multiple true focus linked lists.
[0078] The movement control module 403 determines the target true focus linked list from the moving direction according to the multiple true focus linked lists generated by the linked list generating module 402, obtains the node where the true focus of the target is located through calculation, and switches the focus from the node where the current true focus is located to the target true focus. The node where the focus is located.
[0079] The linked list generating module 402 includes a linked list calculation unit 4021, a focus extraction unit 4022, and a linked list adding unit 4023.
[0080] The linked list calculation unit 4021 calculates the number N of true focus linked lists according to the content height and the screen height of the page to be browsed, and outputs it to the linked list adding unit 4023.
[0081] The focus extraction unit 4022 extracts all the nodes that support true focus in the page to be browsed according to the information of each node contained in the render tree generated by the parsing engine 401, and outputs it to the linked list adding unit 4023.
[0082] The linked list adding unit 4023 uses the Y-axis coordinates and the screen height of the node that supports true focus in the page to be browsed to determine to add the node that supports true focus in the page to be browsed to one of the N true focus linked lists.
[0083] The mobility control module 403 includes a linked list determining unit 4031 and a node determining unit 4032.
[0084] The linked list determining unit 4031 determines the target true focus linked list according to the multiple true focus linked lists generated by the linked list generating module 402 and the moving direction.
[0085] The node determining unit 4032 extracts the true focus-supporting nodes contained in the target true-focus linked list, calculates the distance between the true-focus-supporting node and the current true-focus node based on the information contained in the node, and selects the node with the smallest distance as the target true-focus node , And switch.
[0086] In the above-mentioned preferred embodiment of the present invention, the distance between each node in the render tree and the node where the current true focus is located is no longer calculated to determine the position of the next node that supports true focus in the moving direction, but in After the render tree is generated, the nodes that support the true focus are divided into the true focus list according to the position of the node that supports the true focus. When the focus is moved, the next target true focus list in the moving direction is determined first, and then the target is calculated The distance between the node that supports the true focus and the node where the current true focus is contained in the true focus list reduces the number of nodes that need to be searched and the number of calculations, improves the fluency of focus switching, and accelerates the speed of focus switching .
[0087] In summary, the above are only preferred embodiments of the present invention, and are not used to limit the protection scope of the present invention. Any modification, equivalent replacement, improvement, etc., made within the spirit and principle of the present invention shall be included in the protection scope of the present invention.