WO2015196822A1 - Method and device for adapting webpage to screen layout - Google Patents

Method and device for adapting webpage to screen layout Download PDF

Info

Publication number
WO2015196822A1
WO2015196822A1 PCT/CN2015/072948 CN2015072948W WO2015196822A1 WO 2015196822 A1 WO2015196822 A1 WO 2015196822A1 CN 2015072948 W CN2015072948 W CN 2015072948W WO 2015196822 A1 WO2015196822 A1 WO 2015196822A1
Authority
WO
WIPO (PCT)
Prior art keywords
node
width
screen
layout
subunit
Prior art date
Application number
PCT/CN2015/072948
Other languages
French (fr)
Chinese (zh)
Inventor
许国庆
Original Assignee
广州市动景计算机科技有限公司
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by 广州市动景计算机科技有限公司 filed Critical 广州市动景计算机科技有限公司
Publication of WO2015196822A1 publication Critical patent/WO2015196822A1/en

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor

Definitions

  • the present invention relates to the field of web page layout technology, and in particular, to a web page adaptation screen layout method and apparatus.
  • the browser In order to make the webpage display properly on the mobile terminal and improve the user experience, the browser usually modifies all the webpage elements of the webpage, and organizes the content into a data stream for layout according to the standard of all webpage elements not exceeding one screen width. This method only has a good display of pictures and texts. The original layout and style of the webpage are completely destroyed, and the problem of the typesetting characteristics of the original webpage is lost.
  • a webpage adaptation screen layout method and device are provided to solve the problem that the related webpage layout technology cannot retain the original webpage layout and style.
  • a webpage adaptation screen layout method including:
  • the width of the node is less than or equal to the screen width, the original style of the node is retained, and the node is typeset according to a standard flow; otherwise, the style of the node is modified, and the node is typeset according to the adaptive screen rules.
  • the calculating the width of each node in the webpage layout tree includes:
  • the width of the cascading style sheet of the node is the width of the node
  • the width value is not set in the cascading style sheet of the node, all child nodes of the node are searched, and the width of the child node having the largest width is the width of the node, and the width of the child node is a cascading of the child nodes.
  • the width of the node is set to be less than or equal to the width of the screen.
  • the modifying the style of the node includes:
  • the adapting to the screen rule layout includes:
  • the height of the element content of the node is the layout height of the node, and the typesetting is performed according to the layout height of the node;
  • the floating element is dynamically stretched, and after the n floating elements are typeset in one line, when there is a blank area on the right side of the line, the width value of the floating element is set to the floating After the minimum width value of the element, determining whether the blank area on the right side of the line is greater than the width of one or more of the floating elements, when the blank area on the right side of the line is larger than one or more of the floating elements In the width, one or more of the floating elements are added to the blank area on the right side of the line, where n is the number of the floating elements typeset in one line when typesetting according to a standard process.
  • a webpage adaptation screen layout apparatus including:
  • a calculation unit configured to calculate a width of each node in the webpage layout tree
  • a first determining unit configured to determine whether a width of each node is less than or equal to a screen width
  • a first execution unit configured to reserve an original style of the node when the width of the node is less than or equal to a screen width, and typeset the node according to a standard process
  • a second execution unit configured to modify a style of the node when the width of the node is greater than a width of the screen, and format the node according to an adaptive screen rule.
  • the calculating unit includes:
  • a first execution subunit configured to traverse a node of a webpage layout tree
  • a first determining subunit configured to determine whether a width value is set in a cascading style sheet of each node
  • a second execution subunit configured to use a width of the cascading style sheet of the node as a width of a node when a width value is set in a cascading style sheet of the node;
  • a third execution subunit configured to find all child nodes of the node when a width value is not set in the cascading style sheet of the node;
  • a second determining subunit configured to determine whether a width value is not set in a cascading style sheet of all child nodes of the node
  • a fourth execution subunit configured to set a width of the node to be less than or equal to a width of the screen when a width value is not set in a cascading style sheet of all child nodes of the node;
  • a fifth execution subunit configured to: when a width value is set in the cascading style sheet of the child node having the node, the width of the child node having the largest width is the width of the node.
  • the second execution unit includes:
  • Adapt to the screen rule layout sub-unit used to format the nodes according to the rules of the screen.
  • the modified style subunit includes:
  • a width modification sub-unit configured to modify a width value and a maximum width value of the cascading style sheet of the node, so that the width value and the maximum width value of the cascading style sheet are smaller than the screen width;
  • the margin modification subunit modifies the resolution of the padding attribute and the margin attribute of the cascading style sheet element box model in the node, so that the resolution of the padding attribute and the margin attribute are respectively less than or equal to their preset values.
  • the adapting screen rule typesetting subunit includes:
  • a high typesetting subunit configured to modify a node's style, the height of the element content of the node is a layout height of the node, and typeset according to a layout height of the node;
  • the dynamic stretching subunit includes:
  • a third determining subunit configured to determine whether there is a blank area on the right side of the line after the row of n floating elements is determined
  • a sixth execution subunit configured to set a width value of the floating element to a minimum width value of the floating element when a blank area exists on a right side of the row;
  • a fourth determining subunit configured to: when a blank area exists on a right side of the row, set a width value of the floating element to a minimum width value of the floating element, and determine a blank area on a right side of the row Whether it is greater than the width of one or more of the floating elements;
  • a seventh execution subunit configured to add one or more of the floating areas in a blank area to the right of the row when a blank area to the right of the row is greater than a width of one or more of the floating elements element
  • n is the number of the floating elements typeset in a line when typesetting according to a standard process.
  • the application also provides a webpage adaptation screen layout apparatus, comprising a processor, the processor is configured to execute the following program unit:
  • a calculation unit configured to calculate a width of each node in the webpage layout tree
  • a first determining unit configured to determine whether a width of each node is less than or equal to a screen width
  • a first execution unit configured to reserve an original style of the node when the width of the node is less than or equal to a screen width, and typeset the node according to a standard process
  • a second execution unit configured to modify a style of the node when the width of the node is greater than a width of the screen, and format the node according to an adaptive screen rule.
  • the present application also provides a computer readable medium having program code executable by a processor, which, when executed, causes the processor to perform the steps of: calculating a width of each node in a web page layout tree; Whether the width of each node is less than or equal to the screen width; and if the width of the node is less than or equal to the screen width Degree, the original style of the node is retained, and the node is typeset according to a standard process; otherwise, the style of the node is modified, and the node is typeset according to the adaptive screen rules.
  • the technical solution disclosed in the embodiment of the present application calculates the width of each node of the typesetting tree, limits the width of the node to the node of the smart terminal screen, limits the width of the node, modifies the style of the node, and formats according to the adaptive screen rules.
  • the display of the node can be adapted to the screen; the node whose width is less than or equal to the screen of the smart terminal is not styled, and is formatted according to a standard process, retaining its original style.
  • the solution is simple and optimizes compatibility between various web page scripts.
  • This scheme retains the original style of a large number of page nodes, and only modifies the styles of the nodes whose width is larger than the screen and uses the screen rules to adapt to the screen rules. Therefore, it is generally not easy to conflict with the standard process, which reduces the difficulty in compatibility between various page writing methods. problem.
  • FIG. 1 is a diagram showing the structure of a computer having a browser kernel according to an embodiment of the present application
  • FIG. 2 is a schematic diagram of a block model of a CSS provided according to an embodiment of the present application.
  • FIG. 3 is a schematic flowchart of a method for adapting a webpage to a screen according to an embodiment of the present application
  • FIG. 4 is a schematic flowchart of calculating a width of each node in a webpage layout tree in the method shown in FIG. 3;
  • FIG. 5 is a schematic structural diagram of a webpage adaptation screen typesetting apparatus according to an embodiment of the present application.
  • Figure 6 is a schematic structural view of a computing unit in the apparatus shown in Figure 5;
  • Figure 7 is a schematic structural view of a second execution unit in the apparatus shown in Figure 5;
  • FIG. 8 is a schematic structural diagram of a style modification subunit in the second execution unit shown in FIG. 7;
  • FIG. 9 is a schematic structural diagram of a screen-alignment type sub-unit adapted to a screen in the second execution unit shown in FIG. 7;
  • FIG. 10 is a schematic structural diagram of a dynamic stretching subunit in the adaptive screen layout type subunit shown in FIG. 9.
  • FIG. 1 is a diagram of a structure of a computer having a browser kernel provided in accordance with an embodiment of the present application.
  • the computer can be implemented as various types of computer devices, such as desktops, portable computers, tablets, smart phones, personal data assistants (PDAs), or other types of computer devices, but is not limited to any particular form.
  • the computer can include a processing module 100, a storage subsystem 200, an input device 300, a display 400, a network interface 500, and a bus 600.
  • the processing module 100 can be a multi-core processor or multiple processors. In some embodiments, processing module 100 can execute executable instructions stored on storage subsystem 200. In the embodiment illustrated in FIG. 1, the processing module 100 is provided with an operating system 110 and a browser 120 running on the operating system 110.
  • the browser 120 includes a typesetting engine (Webcore) 1231.
  • the typesetting engine 1231 further includes three modules: a parsing module, a typesetting module, and a rendering module.
  • the parsing module can in turn include an HTML parser and a CSS parser.
  • the HTML parser includes a tag generator and a tree constructor.
  • the tag generator is used to parse the input web page content (usually the XML document format) into multiple HTML tags. HTML tags include start tags, end tags, attribute names, and attribute values. The tag generator identifies these tags and passes them to the tree constructor, then receives the next character to identify the next tag; iterates until the end of the input.
  • Storage subsystem 200 can include various types of storage units, such as system memory, read only memory (ROM), and persistent storage.
  • storage units such as system memory, read only memory (ROM), and persistent storage.
  • the user interface can be provided by one or more user input devices 300, display 400, and/or one or more other user output devices.
  • Input device 300 can include means for a user to input signals to a computer that can interpret such signals containing particular user requests or information.
  • the web address may be input to the user interface through the keyboard, and the browser 120 is required to display the webpage content corresponding to the input web address through the user interface.
  • input device 300 can include some or all of a keyboard button, touch screen, mouse or other pointing device, scroll wheel, click wheel, dial, button, switch, keypad, microphone, and the like.
  • Display 400 can display images generated by a computer, and can include various types of image devices.
  • the user interface can be provided through a graphical user interface. Certain areas of the display 400 define some visual graphical elements as interactive objects or control objects that the user selects through the input device 300.
  • Network interface 500 provides sound and/or data communication functionality to the computer.
  • the bus 600 can include various systems, external devices, and chip buses that connect various components within the computer.
  • processing device 100 can implement multiple types of functions for the computer. For example, processing device 100 downloads web page content from a server to storage subsystem 200 via network interface 500. The processing device 100 then reads the web page file from the storage subsystem 200 to the typesetting engine 1231.
  • the parsing module of the typesetting engine 1231 parses the web page and constructs it into a DOM tree. When the DOM tree is created, the typesetting module of the typesetting engine 1231 receives the style information of the CSS parser, constructs a new internal drawing model (RenderobjectTree, a rendering object tree, also called a typesetting tree), and calculates various elements in the model by the typesetting module. The position and size are then drawn from the model to the graphics by the rendering module.
  • the primary role of the browser is to display web pages.
  • a web page is a document written in HTML.
  • CSS style language and JavaScript language to control the display characteristics of web pages.
  • CSS is used to describe the display information of the webpage
  • JS code is used to control the internal logic of the webpage.
  • CSS ascading Style Sheet
  • HTML is a style sheet language that defines a series of style rules that act on each element to describe the display information of the element and control the display style of the web page.
  • FIG. 2 is a schematic diagram of a block model of a CSS according to an embodiment of the present application.
  • Each visual element in a web page is a network node.
  • the layout of each visual element in an HTML page is designed according to the box model.
  • CSS describes the layout structure of HTML elements through a box model (also known as a box model).
  • a box model is divided into four parts from the inside out: the margins, the border, the padding, and the content.
  • Web pages can achieve specific layout effects by setting these style properties on the elements.
  • Web developers have two ways to use CSS. One is to put the CSS code into the element "style”, called the internal style sheet; the other is to reference the external CSS document, called the external style sheet. In addition, there is one Put the CSS code inside the ⁇ head> tag, called the internal style sheet.
  • the internal style sheet is the default style sheet for the browser, and web page developers cannot control this part of the style sheet.
  • CSS parser parses CSS, whether it's using inline CSS code or an external style sheet.
  • the CSS parsing process refers to the process of changing the CSS string into the internal rules representation of the typesetting engine after being processed by the CSS parser.
  • the browser needs to parse the CSS content, it calls the parser to parse the CSS style, and finally stores the created result.
  • the rendering module of the layout engine selects appropriate style information for some visual nodes of the DOM tree according to the parsing result of the CSS parser to form a new internal drawing model.
  • the new internal drawing model is a tree of visual elements in the order in which they are displayed, as well as a visual representation of the document. Its purpose is to let the browser draw content in the correct order.
  • each new internal drawing model represent a rectangular area, usually corresponding to the CSS box of the relevant node; where the type of the box is affected by the "display" style attribute associated with the node.
  • the node type of the new internal drawing model is also one of the considerations, such as form controls and tables correspond to special frameworks.
  • FIG. 3 is a schematic flowchart of a webpage adaptation screen layout method according to an embodiment of the present application. As shown in FIG. 3, the method includes the following steps.
  • step S101 calculating a width of each node in the webpage layout tree
  • step S102 it is determined whether the width of each node is less than or equal to the screen width
  • step S103 according to the determination result of step S102, if the width of the node is less than or equal to the screen width, the original style of the node is retained, and the node is typeset according to a standard process;
  • step S104 according to the judgment result of step S102, if the width of the node is not less than or equal to the screen width, the style of the node is modified, and the node is typeset according to the adaptive screen rule.
  • the mobile terminal browser parses the page elements included in the acquired webpage resource, calculates the width of each node in the process of generating the typesetting tree node according to the parsing, or generates all the typesetting tree nodes according to the parsing. After that, it traverses the layout tree and calculates the width of each node.
  • step S101 the width of each node in the webpage layout tree is calculated.
  • the following steps may be included:
  • the width of the cascading style sheet of the node is the width of the node
  • the width value is not set in the cascading style sheet of the node, all child nodes of the node are searched, and the width of the child node having the largest width is the width of the node, and the width of the child node is a cascading of the child nodes.
  • the width of the node is set to be less than or equal to the width of the screen.
  • calculating a width of each node in the layout tree may include:
  • step S201 traversing a node of a webpage layout tree
  • step S202 it is determined whether a width value is set in the cascading style sheet of each node.
  • step S203 when the width value is set in the cascading style sheet of the node, the width of the cascading style sheet of the node is the width of the node;
  • step S204 when the width value is not set in the cascading style sheet of the node, all the child nodes of the node are searched;
  • step S205 it is determined whether the width value is not set in the cascading style sheet of all the child nodes of the node
  • step S206 when the result of the determination in step S205 is that the width value is not set in the cascading style sheet of all the child nodes of the node, the width of the node is set to be less than or equal to the width of the screen;
  • step S207 when the result of the determination in step S205 is that the width value is set in the cascading style sheet of the child node having the node, the width of the child node having the largest width is the width of the node.
  • step S206 the width of the node is set to be less than or equal to the width of the screen, so that the width of the node is a width value less than or equal to the width of the screen, and the node is typeset according to a standard process.
  • step S207 when a child node having a width value set in the cascading style sheet exists in a child node of the node, the width of the child node having the largest width among the child nodes in which the width value is set in the cascading style sheet is taken as Place The width of the node.
  • Finding the child node with the largest width in the child node may adopt a conventional round-robin method of finding the maximum value, for example, setting the intermediate variable max to find all the child nodes of the node, in the process of searching all the child nodes of the node,
  • the width of the first child node whose width value is set in the cascading style sheet is taken as the initial value of max; in the subsequent search process, the width of the child node whose width value is set in the cascading style sheet is compared with max, If the width of the child node is less than max, the value of max is kept unchanged, and if the width of the child node is greater than or equal to max, let max be equal to the width of the child node; and so on, until the search is completed.
  • the width of the set node is max
  • the max is the width of the child node with the largest width. Since the width of the set node is to determine the size of the width of the node, it is not necessary to know which sub-node of the node corresponds to the maximum width in the process of finding, but knowing which maximum node corresponds to which sub-node of the node does not affect the present application. The principle.
  • the width of each node is calculated in the process of generating the typeset tree node according to the parsing, when the width value is not set in the cascading style sheet of a certain node, the downward direction is continued.
  • the layer parses the child nodes of the node, the width of the child node having the largest width is the width of the node, and the width of the child node is the width of the cascading style sheet of the child node; if all the child nodes of the node are After the parsing is completed, and the width values are not set in the cascading style sheets of the child nodes of all the nodes, the width of the nodes is set to be less than or equal to the width of the screen.
  • step S103 according to the judgment result of step S102, if the width of the node is less than or equal to the screen width, the original style of the node is retained, and the node is typeset according to a standard flow.
  • step S104 according to the judgment result of step S102, if the width of the node is not less than or equal to the screen width, the style of the node is modified, and the node is typeset according to the adaptive screen rule.
  • Modifying the style of the node in step S104 may include, but is not limited to, the following rules:
  • the size attribute of the node's cascading style sheet includes width, maximum width, and minimum width, etc., wherein the width of the cascading style sheet is used to set the width of the element content area, and is used to determine the actual width of the object; the cascading style sheet
  • the maximum width is used to limit the maximum width of the element, preventing element overflow, and along with the minimum width of the cascading style sheet, to prevent web page pages from being distorted due to being too large or too small.
  • the width value of the cascading style sheet of the node is modified, so that the width value of the cascading style sheet is smaller than the screen width, that is, the width of the element content area does not exceed the screen. Width so that the element content does not exceed the screen when displayed. And modify the maximum width value of the node's cascading style sheet so that the maximum width value in the cascading style sheet is smaller than the screen width, thereby further preventing the element from overflowing the screen or deforming when displayed.
  • the width of the cascading style sheet of the set node is equal to the width of the screen, This will cause some of the display content to be close to the screen, affecting the visual experience, so it is preferable to set the width of the cascading style sheet of the node to be smaller than the width of the screen.
  • the minimum width of the cascading style sheet is by default smaller than the width of the cascading style sheet, so the setting of the minimum width of the cascading style sheet is not described.
  • the actual width of an element is determined by the sum of the width of the element content, the border property, the fill property, and the margin property.
  • the value of the border property is usually small, so the adjustment of the border property can be ignored.
  • the fill property is the interval between the content of the element and the border; the margin property is the interval between one element and another.
  • the Fill and Margin properties are used to block the elements.
  • the preset value of the fill property and the preset value of the margin property may be the same or different.
  • the preset value of the fill attribute and the preset value of the margin attribute can be set to 6px, so that the blank area of the screen is not too big or too small, so that the user has a better visual experience.
  • the preset value of the padding attribute and the preset value of the margin attribute may also be determined according to the screen size of the smart terminal used by the current user. For example, when the screen is large, a larger padding attribute preset value and a margin attribute may be taken. Set the value. When the screen is small, you can take a smaller padding property preset and margin property preset.
  • the display of the element content can be adapted to the width of the screen to avoid overflow.
  • the content is incomplete and deformed.
  • the modifying the style of the node may further include:
  • the filtering resolution is larger than the background image of the preset image to avoid the page display effect. Uncoordinated, the page display is more concise, and the background image with resolution less than the preset value can be retained.
  • the preset value may be 240*300px, and the preset value may also be set according to the screen size of the smart terminal.
  • the limiting the font size of the text element includes: if the font size of the text element is less than or equal to the font preset value, the font size of the text element is not changed, and if the font size of the text element is greater than the font preset value, modifying the The font size of the text element such that the text font size is equal to the font preset value. Limiting the font size of text elements can prevent fonts from being too large to cause overlap after folding. For most current mobile phone screens, the font default value can be set to 20, which makes the font display clear and has good visibility. To avoid folding, the font preset value can also be set according to the screen size of the smart terminal.
  • the same value may be a conventional text indentation value, such as 2px, or may be determined according to the screen size of the smart terminal.
  • the adaptation screen rule layout may include but is not limited to the following rules:
  • the height of the element content of the node is the layout height of the node, and the typesetting is performed according to the layout height of the node.
  • the height of the element content of the node may change accordingly, so the height of the content of the changed element is the node.
  • the height of the layout rather than the height of the cascading style sheet of the node, is the height of the layout of the node, so that the content of the element is not displayed when it is displayed.
  • Floating element attributes include width, minimum width, and maximum width. Setting the width of the floating element to its minimum width value reduces the width of the floating element.
  • one or more of the floating elements are added to the blank area on the right side of the line.
  • the layout of the floating element is not processed.
  • the dynamic stretching floating element may include the following process steps:
  • the width value of the floating element is set to the minimum width value of the floating element
  • step (2) setting the width value of the floating element to the minimum width value of the floating element, determining whether the blank area on the right side of the line is greater than the width of one or more floating elements;
  • step (3) when the judgment result of the step (3) is that the blank area on the right side of the line is larger than the width of one or more floating elements, one or more of the blank areas in the right side of the line are added. Floating element.
  • step (3) may be: acquiring a width value of a blank area on the right side of the row, and dividing a width value of the blank area on the right side of the row by a floating element. a width value, rounding the obtained result, and determining whether the rounded result m is greater than or equal to 1;
  • step (4) is: when the result of the determination in step (3) is that m is greater than or equal to 1, m floating elements are added to the blank area on the right side of the row;
  • step (3) If the judgment result of the step (3) is that there is no blank area on the right side of the line, or if the result of the judgment in the step (3) is that m is less than 1, the dynamic stretch floating element flow is ended, The layout of floating elements is not processed.
  • the adapting to the screen rule layout may further include:
  • Type a table by line. Typesetting the rows by row instead of tabular.
  • the line-by-line typesetting table is: sequentially arranging cells in the same row of the table in a layout line in the order of the cells themselves, and continuing to typeset a cell in a typesetting line that has not been typeset. When the cells in the same row in the table are typeset, the cells in the next row in the table are further typeset.
  • the line layout table can better adapt the table to the size of the screen, so that the table can be displayed on the screen in a complete and orderly manner, preventing the table content from being lost and cell deformation, and preventing the table contents from overlapping and confusing after the node's style is modified. happening.
  • the removing the excess blank area includes: for a plurality of empty labels ( ⁇ br>) that appear consecutively, only one empty label is reserved, and other empty labels are deleted, thereby compressing the height of the blank line; removing the paragraph label ( ⁇ p>) , a single label in the cell label ( ⁇ td>) and the block label ( ⁇ div>), and the separate space is removed: when there is only one in a row and no other elements or content, ignore This line does not make a layout for this line. Removing unnecessary white space can make the effect of adapting to screen rule layout more compact.
  • the aspect ratio of the image, video, and plug-in elements is: obtaining the original aspect ratio of the image, video, and plug-in elements, and when the style of the node is modified, respectively, according to the width of the modified image, video, and plug-in elements, and
  • the original aspect ratio adjusts the height of the modified image, video, and plug-in elements.
  • the original size of the image is 400*600px
  • the original aspect ratio is 3:2
  • the width of the image is changed to 200px after the style of the node is modified.
  • the height of the image is adjusted to 300px
  • the size of the image is adjusted to 200*300px.
  • the method for adapting a screen of a webpage is to modify a style of the node only for a node whose width is larger than a screen of the smart terminal, and to perform layout according to an adaptive screen rule, so that the display of the node can adapt to the screen. And has a beautiful effect and visual experience; and the node whose width is less than or equal to the screen of the smart terminal retains its original style and is typeset according to standard procedures. Therefore, the original layout, style and style of the page are more preserved on the basis of ensuring that the webpage is adapted to the screen, and since only a part of the nodes are changed, the typesetting resources are saved, and it is generally not easy to conflict with the standard process, and is applicable to various page writing methods.
  • the present application can be implemented by means of software plus a necessary general hardware platform, and of course, by hardware, but in many cases, the former is better.
  • Implementation Based on such understanding, the technical solution of the present application, which is essential or contributes to the prior art, may be embodied in the form of a software product stored in a storage medium, including a plurality of instructions for making a Computer device (can be a personal computer, server, or network device, etc.) to execute this application All or part of the steps of the methods described in the various embodiments are contemplated.
  • the foregoing storage medium includes various types of media that can store program codes, such as a read only memory (ROM), a random access memory (RAM), a magnetic disk, or an optical disk.
  • FIG. 5 is a schematic structural diagram of a webpage adaptation screen layout apparatus according to an embodiment of the present disclosure.
  • the apparatus includes:
  • a calculating unit U301 configured to calculate a width of each node in the webpage layout tree
  • the first determining unit U302 is connected to the calculating unit U301, and is configured to determine whether the width of each node is less than or equal to the screen width;
  • the first execution unit U303 is connected to the first determining unit U302, and is configured to reserve the original style of the node when the width of the node is less than or equal to the screen width, and typeset the node according to a standard process;
  • the second execution unit U304 is connected to the first determining unit U302, and is configured to modify the style of the node when the width of the node is greater than the width of the screen, and typeset the node according to the adaptive screen rule.
  • the foregoing first determining unit U302, the first executing unit U303, and the second executing unit U304 may be run in a computer terminal as part of the device, and may be implemented by a processor in the computer terminal.
  • the computer terminal can also be a smart phone (such as an Android phone, an iOS phone, etc.), a tablet computer, an applause computer, and a mobile Internet device (MID), a PAD, and the like.
  • FIG. 6 is a schematic structural view of a computing unit in the apparatus shown in FIG. 5.
  • the computing unit U301 as shown in FIG. 6, includes:
  • a first execution subunit U401 configured to traverse a node of a webpage layout tree
  • the first determining subunit U402 is connected to the first executing subunit U401, and is configured to determine whether a width value is set in the cascading style sheet of each node;
  • the second execution subunit U403 is connected to the first judging subunit U402, and is configured to use the width of the cascading style sheet of the node as the width of the node when the width value is set in the cascading style sheet of the node;
  • the third execution subunit U404 is connected to the first determining subunit U402, and is configured to search all the child nodes of the node when the width value is not set in the cascading style sheet of the node;
  • the second determining subunit U405 is connected to the third executing subunit U404, and is configured to determine whether the width value is not set in the cascading style sheet of all the child nodes of the node;
  • the fourth execution subunit U406 is connected to the second judging subunit U405 and the third execution subunit U404, and is configured to set the node when the width value is not set in the cascading style sheet of all the child nodes of the node.
  • the width is less than or equal to the width of the screen;
  • a fifth execution subunit U407 connected to the second judging subunit U405 and the third execution subunit U404, for when the width value is set in the cascading style sheet of the child node of the node, the width is the largest
  • the width of the child node is the width of the node.
  • first execution subunit U401, first judgment subunit U402, second execution subunit U403, third execution subunit U404, second judgment subunit U405, fourth execution subunit U406 and The fifth execution subunit U407 can be run in the computer terminal as part of the device, and the function implemented by the above module can be executed by a processor in the computer terminal, and the computer terminal can also be a smart phone (such as an Android mobile phone, an iOS mobile phone, etc.). Tablet PCs, applause computers, and mobile Internet devices (MID), PAD and other terminal devices.
  • smart phone such as an Android mobile phone, an iOS mobile phone, etc.
  • MID mobile Internet devices
  • FIG. 7 is a schematic structural view of a second execution unit in the apparatus shown in FIG. 5.
  • the second executing unit U304 as shown in FIG. 7, includes:
  • the style modification subunit U501 is used to modify the style of the node
  • the screen-adapted layout sub-unit U502 is connected to the style modification sub-unit U501 for formatting the nodes according to the adaptive screen rules.
  • the above-mentioned creation pattern modification subunit U501 and the adaptation screen rule layout subunit U502 can be run in the computer terminal as part of the device, and the functions implemented by the above module can be executed by the processor in the computer terminal, the computer
  • the terminal can also be a smart phone (such as an Android phone, an iOS phone, etc.), a tablet computer, an applause computer, and a mobile Internet device (MID), a PAD, and the like.
  • FIG. 8 is a schematic structural diagram of a pattern modification subunit in the second execution unit shown in FIG. 7.
  • the modified style subunit as shown in FIG. 8, includes:
  • a width modifying subunit U601 configured to modify a width value and a maximum width value of the cascading style sheet of the node, so that the width value and the maximum width value of the cascading style sheet are smaller than the screen width;
  • the margin modification subunit U602 the resolution of the padding attribute and the margin attribute of the cascading style sheet element box model in the node is modified, so that the resolutions of the padding attribute and the margin attribute are respectively less than or equal to their preset values. .
  • width modification subunit U601 and the margin modification subunit U602 may be run in a computer terminal as part of the device, and the functions implemented by the above module may be performed by a processor in the computer terminal, and the computer terminal is also It can be a smart phone (such as Android phone, iOS phone, etc.), tablet computer, applause computer, and mobile Internet devices (MID), PAD and other terminal devices.
  • FIG. 9 is a schematic structural diagram of a screen-aligning sub-unit adapted to a screen in the second execution unit shown in FIG. 7.
  • the adapting screen rule typesetting subunit includes:
  • a high typesetting subunit U701 configured to modify a node's style, the height of the element content of the node is a layout height of the node, and typeset according to the typesetting height of the node;
  • Dynamic stretching subunit U702 for dynamically stretching floating elements.
  • the above-mentioned height type sub-unit U701 and dynamic stretch sub-unit U702 can be run in a computer terminal as part of the device, and the functions implemented by the above modules can be executed by a processor in the computer terminal, and the computer terminal is also It can be a smart phone (such as Android phone, iOS phone, etc.), tablet computer, applause computer, and mobile Internet devices (MID), PAD and other terminal devices.
  • a smart phone such as Android phone, iOS phone, etc.
  • tablet computer such as Samsung Galaxy Tabs, etc.
  • applause computer such as Samsung Galaxy Tabs, etc.
  • PAD mobile Internet devices
  • FIG. 10 is a schematic structural diagram of a dynamic stretching subunit in the adaptive screen layout type subunit shown in FIG. 9.
  • the dynamic stretching subunit as shown in FIG. 10, includes:
  • the third determining sub-unit U801 is configured to determine whether there is a blank area on the right side of the line after the row of n floating elements is typed;
  • a sixth execution sub-unit U802 connected to the third determining sub-unit U801, configured to set a width value of the floating element to a minimum width value of the floating element when a blank area exists on a right side of the row;
  • the fourth determining sub-unit U803 is connected to the sixth executing sub-unit U802, and is configured to set a width value of the floating element to a minimum width value of the floating element when a blank area exists on a right side of the line, Determining whether a blank area on the right side of the line is greater than a width of one or more of the floating elements;
  • the seventh execution subunit U804 is connected to the fourth judging subunit U803 for blanking on the right side of the row when the blank area on the right side of the row is larger than the width of one or more of the floating elements One or more of the floating elements are added to the area.
  • the third determining subunit U801, the sixth executing subunit U802, the fourth judging subunit U803, and the seventh executing subunit U804 may be run in a computer terminal as part of the device, and may be through a computer terminal.
  • the processor in the above module performs the functions implemented by the above modules, and the computer terminal can also be a smart phone (such as an Android phone, an iOS phone, etc.), a tablet computer, a palm computer, and a mobile Internet device (MID), a PAD, and the like. .
  • the webpage adapting screen typesetting apparatus provided by the embodiment of the present application, by calculating the width of each node in the webpage layout tree, retaining the original style of the node whose width of the node is less than or equal to the screen of the smart terminal, and formatting according to a standard process; If the width of the node is larger than the node of the smart terminal screen, the style of the node is modified, the width of the node is limited, and the layout is adapted according to the rules of the screen, so that the display of the node can adapt to the screen, and has an aesthetic effect and a visual experience.
  • the original layout, style and style of the page are more reserved on the basis of ensuring that the webpage is adapted to the screen, and since only a part of the nodes are changed, the structure is simplified, the typesetting resources are saved, and the standard process conflict is not easy, and is applicable to Typesetting of various page writing methods.
  • the various functional units provided by the embodiments of the present application may be operated in a mobile terminal, a computer terminal, or the like, or may be stored as part of a storage medium.
  • embodiments of the present invention may provide a computer terminal, which may be any computer terminal device in a group of computer terminals.
  • a computer terminal may also be replaced with a terminal device such as a mobile terminal.
  • the computer terminal may be located in at least one network device of the plurality of network devices of the computer network.
  • the computer terminal may execute the program code of the following steps in the method for acquiring a stereo heat map: acquiring data of a plane heat map of a webpage page, and the data of the plane heat map includes click data of the webpage page; A three-dimensional coordinate system is established to obtain an axonometric map; the data of the planar thermodynamic map is displayed on the isometric view to obtain a stereoscopic thermogram.
  • the computer terminal can include: one or more processors, memory, and transmission means.
  • the memory can be used to store the software program and the module, such as the method and device corresponding to the method for acquiring the stereo heat map in the embodiment of the present invention, and the processor executes the software program and the module stored in the memory, thereby executing each A functional application and data processing, that is, the above method of acquiring a stereo heat map.
  • the memory may include a high speed random access memory, and may also include non-volatile memory such as one or more magnetic storage devices, flash memory, or other non-volatile solid state memory.
  • the memory can further include These remote memories can be connected to the terminal over a network with respect to the memory remotely set by the processor. Examples of such networks include, but are not limited to, the Internet, intranets, local area networks, mobile communication networks, and combinations thereof.
  • the above transmission device is for receiving or transmitting data via a network.
  • Specific examples of the above network may include a wired network and a wireless network.
  • the transmission device includes a Network Interface Controller (NIC) that can be connected to other network devices and routers via a network cable to communicate with the Internet or a local area network.
  • the transmission device is a Radio Frequency (RF) module for communicating with the Internet wirelessly.
  • NIC Network Interface Controller
  • RF Radio Frequency
  • the memory is used to store preset action conditions and information of the preset rights user, and an application.
  • the processor can call the memory stored information and the application by the transmitting device to execute the program code of the method steps of each of the alternative or preferred embodiments of the above method embodiments.
  • the computer terminal can also be a smart phone (such as an Android phone, an iOS phone, etc.), a tablet computer, an applause computer, and a mobile Internet device (MID), a PAD, and the like.
  • a smart phone such as an Android phone, an iOS phone, etc.
  • a tablet computer such as an iPad, Samsung Galaxy Tab, Samsung Galaxy Tab, etc.
  • MID mobile Internet device
  • PAD PAD
  • Embodiments of the present invention also provide a storage medium.
  • the foregoing storage medium may be used to save the program code executed by the method for obtaining a stereo heat map provided by the foregoing method embodiment and the device embodiment.
  • the foregoing storage medium may be located in any one of the computer terminal groups in the computer network, or in any one of the mobile terminal groups.
  • the storage medium is configured to store program code for performing the following steps: acquiring data of a plane heat map of the webpage page, the data of the plane heat map including click data of the webpage page;
  • the layer establishes a three-dimensional coordinate system to obtain an axonometric map; the data of the planar thermodynamic map is displayed on the isometric view to obtain a stereoscopic thermogram.
  • the storage medium may also be configured to store program code of various preferred or optional method steps provided by the method of acquiring a stereo heat map.
  • the various embodiments in the specification are described in a progressive manner, and the same or similar parts between the various embodiments may be referred to each other, and each embodiment focuses on the differences from the other embodiments.
  • the description is relatively simple, and the relevant parts can be referred to the description of the method embodiment.
  • the device embodiments described above are merely illustrative, wherein the units described as separate components may or may not be physically separate, and the components displayed as units may or may not be physical units, ie may be located A place, or it can be distributed to multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the solution of the embodiment. Those of ordinary skill in the art can understand and implement without any creative effort.
  • the application can be described in the general context of computer-executable instructions executed by a computer, such as a program module.
  • program modules include routines, programs, objects, components, data structures, and the like that perform particular tasks or implement particular abstract data types.
  • the present application can also be practiced in distributed computing environments where tasks are performed by remote processing devices that are connected through a communication network.
  • program modules can be located in both local and remote computer storage media including storage devices.

Landscapes

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

Abstract

A method and device for adapting a webpage to screen layout. The method comprises: calculating the width of each node of a layout tree (S101); for nodes of which the widths are greater than the width of an intelligent terminal screen, limiting the widths of these nodes, modifying the styles of these nodes, and conducting layout in accordance with a screen adaptation rule (S104); and for nodes of which the widths are less than or equal to the width of the intelligent terminal screen, not conducting style processing, conducting layout in accordance with a standard flow, and reserving the original styles thereof (S103). Therefore, on the basis of adapting a webpage page to the screen, the original style of the page is reserved to a greater extent, so that the page display has better effects and visual experience. Moreover, by means of the method and device, the layout is only conducted on the nodes of which the widths are greater than the width of the screen using the screen adaptation rule, so that it is not easy to conflict with the standard flow generally, thereby solving the problem caused by the fact that it is difficult to achieve compatibility among various writing styles of pages.

Description

一种网页适应屏幕排版方法及装置Web page adaptation screen layout method and device 技术领域Technical field
本发明涉及网页排版技术领域,特别是涉及一种网页适应屏幕排版方法及装置。The present invention relates to the field of web page layout technology, and in particular, to a web page adaptation screen layout method and apparatus.
背景技术Background technique
随着智能手机与平板电脑等移动终端的普及和移动网络技术的快速发展,使用移动终端上网已成为人们生活的常态。但目前网站的网页主要针对电脑屏幕进行设计,当用户使用移动终端浏览网站时,由于移动终端屏幕尺寸的限制,网页显示常常出现变形、杂乱、内容丢失等情况,极大降低了用户的浏览体验。With the popularity of mobile terminals such as smartphones and tablets and the rapid development of mobile network technologies, using mobile terminals to access the Internet has become the norm in people's lives. However, the current webpage of the website is mainly designed for the computer screen. When the user browses the website using the mobile terminal, due to the limitation of the screen size of the mobile terminal, the webpage display often appears deformed, disordered, and the content is lost, which greatly reduces the browsing experience of the user. .
为使网页在移动终端上正常显示,提高用户的体验,浏览器通常将网页的所有网页元素进行样式修改后,按所有网页元素不超过一个屏幕宽度的标准将内容组织成数据流进行排版,然而这种方法仅对图片和文字有较好的展现,网页原有的布局和样式则被完全破坏,失去了原有网页的排版特性的问题。In order to make the webpage display properly on the mobile terminal and improve the user experience, the browser usually modifies all the webpage elements of the webpage, and organizes the content into a data stream for layout according to the standard of all webpage elements not exceeding one screen width. This method only has a good display of pictures and texts. The original layout and style of the webpage are completely destroyed, and the problem of the typesetting characteristics of the original webpage is lost.
发明内容Summary of the invention
本申请实施例中提供了一种网页适应屏幕排版方法及装置,以解决相关网页排版技术不能保留原网页布局和样式的问题。In the embodiment of the present application, a webpage adaptation screen layout method and device are provided to solve the problem that the related webpage layout technology cannot retain the original webpage layout and style.
为了解决上述技术问题,本申请实施例公开了如下技术方案:In order to solve the above technical problem, the embodiment of the present application discloses the following technical solutions:
根据本申请实施例的第一方面,提供一种网页适应屏幕排版方法,包括:According to a first aspect of the embodiments of the present application, a webpage adaptation screen layout method is provided, including:
计算网页排版树中各个节点的宽度;Calculating the width of each node in the web page layout tree;
判断各个节点的宽度是否小于或等于屏幕宽度;以及Determine whether the width of each node is less than or equal to the screen width;
如果节点的宽度小于或等于屏幕宽度,则保留所述节点的原样式,并对所述节点按标准流程排版,否则,修改所述节点的样式,并对所述节点按适应屏幕规则排版。If the width of the node is less than or equal to the screen width, the original style of the node is retained, and the node is typeset according to a standard flow; otherwise, the style of the node is modified, and the node is typeset according to the adaptive screen rules.
可选的,所述计算网页排版树中各个节点的宽度,包括:Optionally, the calculating the width of each node in the webpage layout tree includes:
遍历网页排版树的节点;Traversing the nodes of the web page layout tree;
判断各个节点的层叠样式表中是否设置了宽度值; Determine whether the width value is set in the cascading style sheet of each node;
如果节点的层叠样式表中设置了宽度值,以所述节点的层叠样式表的宽度为节点的宽度;If the width value is set in the cascading style sheet of the node, the width of the cascading style sheet of the node is the width of the node;
如果节点的层叠样式表中未设置宽度值,则查找所述节点的所有子节点,以宽度最大的子节点的宽度为所述节点的宽度,所述子节点的宽度为所述子节点的层叠样式表的宽度;If the width value is not set in the cascading style sheet of the node, all child nodes of the node are searched, and the width of the child node having the largest width is the width of the node, and the width of the child node is a cascading of the child nodes. The width of the style sheet;
如果节点的层叠样式表中未设置宽度值,且所述节点的所有子节点中的层叠样式表中未设置宽度值,则设置所述节点的宽度小于或等于屏幕的宽度。If the width value is not set in the cascading style sheet of the node, and the width value is not set in the cascading style sheet in all the child nodes of the node, the width of the node is set to be less than or equal to the width of the screen.
可选的,所述修改节点的样式,包括:Optionally, the modifying the style of the node includes:
修改节点的层叠样式表的宽度值和最大宽度值,使所述层叠样式表的宽度值和最大宽度值小于屏幕宽度;Modifying the width value and the maximum width value of the cascading style sheet of the node such that the width value and the maximum width value of the cascading style sheet are smaller than the screen width;
修改节点中层叠样式表元素盒模型的填充属性和边距属性的分辨率,使所述填充属性和所述边距属性的分辨率分别小于或等于自身的预设值。Modifying the resolution of the padding attribute and the margin attribute of the cascading style sheet element box model in the node such that the resolution of the padding attribute and the margin attribute are respectively less than or equal to their preset values.
可选的,所述适应屏幕规则排版,包括:Optionally, the adapting to the screen rule layout includes:
以修改节点的样式后所述节点的元素内容的高度为所述节点的排版高度,按所述节点的排版高度进行排版;After modifying the style of the node, the height of the element content of the node is the layout height of the node, and the typesetting is performed according to the layout height of the node;
动态拉伸浮动元素,所述动态拉伸浮动元素为:在一行中排版n个浮动元素后,当所述行的右方存在空白区域时,将所述浮动元素的宽度值设置为所述浮动元素的最小宽度值后,判断所述行的右方的空白区域是否大于一个或多个所述浮动元素的宽度,当所述行的右方的空白区域大于一个或多个所述浮动元素的宽度时,在所述行的右方的空白区域中加入一个或多个所述浮动元素,其中,n为按标准流程排版时,一行中排版的所述浮动元素的个数。The floating element is dynamically stretched, and after the n floating elements are typeset in one line, when there is a blank area on the right side of the line, the width value of the floating element is set to the floating After the minimum width value of the element, determining whether the blank area on the right side of the line is greater than the width of one or more of the floating elements, when the blank area on the right side of the line is larger than one or more of the floating elements In the width, one or more of the floating elements are added to the blank area on the right side of the line, where n is the number of the floating elements typeset in one line when typesetting according to a standard process.
根据本申请实施例的第二方面,提供一种网页适应屏幕排版装置,包括:According to a second aspect of the embodiments of the present application, a webpage adaptation screen layout apparatus is provided, including:
计算单元,用于计算网页排版树中各个节点的宽度;a calculation unit, configured to calculate a width of each node in the webpage layout tree;
第一判断单元,用于判断各个节点的宽度是否小于或等于屏幕宽度;a first determining unit, configured to determine whether a width of each node is less than or equal to a screen width;
第一执行单元,用于当节点的宽度小于或等于屏幕宽度时,保留所述节点的原样式,并对所述节点按标准流程排版; a first execution unit, configured to reserve an original style of the node when the width of the node is less than or equal to a screen width, and typeset the node according to a standard process;
第二执行单元,用于当节点的宽度大于屏幕宽度时,修改所述节点的样式,并对所述节点按适应屏幕规则排版。a second execution unit, configured to modify a style of the node when the width of the node is greater than a width of the screen, and format the node according to an adaptive screen rule.
可选的,所述计算单元,包括:Optionally, the calculating unit includes:
第一执行子单元,用于遍历网页排版树的节点;a first execution subunit, configured to traverse a node of a webpage layout tree;
第一判断子单元,用于判断各个节点的层叠样式表中是否设置了宽度值;a first determining subunit, configured to determine whether a width value is set in a cascading style sheet of each node;
第二执行子单元,用于当节点的层叠样式表中设置了宽度值时,以所述节点的层叠样式表的宽度为节点的宽度;a second execution subunit, configured to use a width of the cascading style sheet of the node as a width of a node when a width value is set in a cascading style sheet of the node;
第三执行子单元,用于当节点的层叠样式表中未设置宽度值时,查找所述节点的所有子节点;a third execution subunit, configured to find all child nodes of the node when a width value is not set in the cascading style sheet of the node;
第二判断子单元,用于判断所述节点的所有子节点的层叠样式表中是否都未设置宽度值;a second determining subunit, configured to determine whether a width value is not set in a cascading style sheet of all child nodes of the node;
第四执行子单元,用于当所述节点的所有子节点的层叠样式表中都未设置宽度值时,设置所述节点的宽度小于或等于屏幕的宽度;a fourth execution subunit, configured to set a width of the node to be less than or equal to a width of the screen when a width value is not set in a cascading style sheet of all child nodes of the node;
第五执行子单元,用于当有所述节点的子节点的层叠样式表中设置了宽度值时,以宽度最大的所述子节点的宽度为所述节点的宽度。And a fifth execution subunit, configured to: when a width value is set in the cascading style sheet of the child node having the node, the width of the child node having the largest width is the width of the node.
可选的,所述第二执行单元包括:Optionally, the second execution unit includes:
样式修改子单元,用于修改节点的样式;A style modification subunit for modifying the style of a node;
适应屏幕规则排版子单元,用于对节点按适应屏幕规则排版。Adapt to the screen rule layout sub-unit, used to format the nodes according to the rules of the screen.
可选的,所述修改样式子单元包括:Optionally, the modified style subunit includes:
宽度修改子单元,用于修改节点的层叠样式表的宽度值和最大宽度值,使所述层叠样式表的宽度值和最大宽度值小于屏幕宽度;a width modification sub-unit, configured to modify a width value and a maximum width value of the cascading style sheet of the node, so that the width value and the maximum width value of the cascading style sheet are smaller than the screen width;
边距修改子单元,修改节点中层叠样式表元素盒模型的填充属性和边距属性的分辨率,使所述填充属性和所述边距属性的分辨率分别小于或等于自身的预设值。The margin modification subunit modifies the resolution of the padding attribute and the margin attribute of the cascading style sheet element box model in the node, so that the resolution of the padding attribute and the margin attribute are respectively less than or equal to their preset values.
可选的,所述适应屏幕规则排版子单元,包括: Optionally, the adapting screen rule typesetting subunit includes:
高度排版子单元,用于以修改节点的样式后所述节点的元素内容的高度为所述节点的排版高度,按所述节点的排版高度进行排版;a high typesetting subunit, configured to modify a node's style, the height of the element content of the node is a layout height of the node, and typeset according to a layout height of the node;
动态拉伸子单元,用于动态拉伸浮动元素。Dynamically stretch subunits for dynamically stretching floating elements.
可选的,所述动态拉伸子单元,包括:Optionally, the dynamic stretching subunit includes:
第三判断子单元,用于判断一行排版n个浮动元素后,所述行的右方是否存在空白区域;a third determining subunit, configured to determine whether there is a blank area on the right side of the line after the row of n floating elements is determined;
第六执行子单元,用于当所述行的右方存在空白区域时,将所述浮动元素的宽度值设置为所述浮动元素的最小宽度值;a sixth execution subunit, configured to set a width value of the floating element to a minimum width value of the floating element when a blank area exists on a right side of the row;
第四判断子单元,用于当所述行的右方存在空白区域时,将所述浮动元素的宽度值设置为所述浮动元素的最小宽度值后,判断所述行的右方的空白区域是否大于一个或多个所述浮动元素的宽度;a fourth determining subunit, configured to: when a blank area exists on a right side of the row, set a width value of the floating element to a minimum width value of the floating element, and determine a blank area on a right side of the row Whether it is greater than the width of one or more of the floating elements;
第七执行子单元,用于当所述行的右方的空白区域大于一个或多个所述浮动元素的宽度时,在所述行的右方的空白区域中加入一个或多个所述浮动元素,a seventh execution subunit, configured to add one or more of the floating areas in a blank area to the right of the row when a blank area to the right of the row is greater than a width of one or more of the floating elements element,
其中,n为按标准流程排版时,一行中排版的所述浮动元素的个数。Where n is the number of the floating elements typeset in a line when typesetting according to a standard process.
本申请还提供了一种网页适应屏幕排版装置,包括处理器,所述处理器用于执行以下程序单元:The application also provides a webpage adaptation screen layout apparatus, comprising a processor, the processor is configured to execute the following program unit:
计算单元,用于计算网页排版树中各个节点的宽度;a calculation unit, configured to calculate a width of each node in the webpage layout tree;
第一判断单元,用于判断各个节点的宽度是否小于或等于屏幕宽度;a first determining unit, configured to determine whether a width of each node is less than or equal to a screen width;
第一执行单元,用于当节点的宽度小于或等于屏幕宽度时,保留所述节点的原样式,并对所述节点按标准流程排版;a first execution unit, configured to reserve an original style of the node when the width of the node is less than or equal to a screen width, and typeset the node according to a standard process;
第二执行单元,用于当节点的宽度大于屏幕宽度时,修改所述节点的样式,并对所述节点按适应屏幕规则排版。a second execution unit, configured to modify a style of the node when the width of the node is greater than a width of the screen, and format the node according to an adaptive screen rule.
本申请还提供了一种具有处理器可执行的程序代码的计算机可读介质,,在被执行时,所述程序代码使得处理器执行下述步骤:计算网页排版树中各个节点的宽度;判断各个节点的宽度是否小于或等于屏幕宽度;以及如果节点的宽度小于或等于屏幕宽 度,则保留所述节点的原样式,并对所述节点按标准流程排版,否则,修改所述节点的样式,并对所述节点按适应屏幕规则排版。The present application also provides a computer readable medium having program code executable by a processor, which, when executed, causes the processor to perform the steps of: calculating a width of each node in a web page layout tree; Whether the width of each node is less than or equal to the screen width; and if the width of the node is less than or equal to the screen width Degree, the original style of the node is retained, and the node is typeset according to a standard process; otherwise, the style of the node is modified, and the node is typeset according to the adaptive screen rules.
本申请实施例公开的技术方案,计算排版树每个节点的宽度,对节点的宽度大于智能终端屏幕的节点,限制所述节点的宽度,修改所述节点的样式,并按适应屏幕规则排版,使所述节点的显示能够适应屏幕;对节点的宽度小于或等于智能终端屏幕的节点,不做样式处理,并按标准流程排版,保留其原样式。本申请实施例公开的技术方案包括以下有益效果:The technical solution disclosed in the embodiment of the present application calculates the width of each node of the typesetting tree, limits the width of the node to the node of the smart terminal screen, limits the width of the node, modifies the style of the node, and formats according to the adaptive screen rules. The display of the node can be adapted to the screen; the node whose width is less than or equal to the screen of the smart terminal is not styled, and is formatted according to a standard process, retaining its original style. The technical solutions disclosed in the embodiments of the present application include the following beneficial effects:
第一,在保证网页页面适应屏幕的基础上更多地保留页面原来的布局和样式,使页面显示有更好的效果和视觉体验;First, on the basis of ensuring that the webpage page adapts to the screen, the original layout and style of the page are more reserved, so that the page display has better effects and visual experience;
第二,方案简单,且优化了各种网页页面写法之间的兼容。本方案保留了大量页面节点的原样式,只对宽度大于屏幕的节点修改样式并采用适应屏幕规则排版,因而总体上不容易与标准流程冲突,降低了各种页面写法之间因为难以兼容造成的问题。Second, the solution is simple and optimizes compatibility between various web page scripts. This scheme retains the original style of a large number of page nodes, and only modifies the styles of the nodes whose width is larger than the screen and uses the screen rules to adapt to the screen rules. Therefore, it is generally not easy to conflict with the standard process, which reduces the difficulty in compatibility between various page writing methods. problem.
附图说明DRAWINGS
为了更清楚地说明本申请实施例或现有技术中的技术方案,下面将对实施例或现有技术描述中所需要使用的附图作简单地介绍,显而易见地,对于本领域普通技术人员而言,在不付出创造性劳动性的前提下,还可以根据这些附图获得其他的附图。In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings used in the embodiments or the description of the prior art will be briefly described below, and it will be apparent to those skilled in the art that In other words, other drawings can be obtained based on these drawings without paying for creative labor.
图1为根据本申请实施方式提供的具有浏览器内核的计算机的结构;1 is a diagram showing the structure of a computer having a browser kernel according to an embodiment of the present application;
图2为根据本申请实施方式提供的CSS的框模型示意图;2 is a schematic diagram of a block model of a CSS provided according to an embodiment of the present application;
图3为本申请实施例提供的一种网页适应屏幕排版方法的流程示意图;3 is a schematic flowchart of a method for adapting a webpage to a screen according to an embodiment of the present application;
图4为图3所示的方法中计算网页排版树中各个节点的宽度的流程示意图;4 is a schematic flowchart of calculating a width of each node in a webpage layout tree in the method shown in FIG. 3;
图5为本申请实施例提供的一种网页适应屏幕排版装置的结构示意图;FIG. 5 is a schematic structural diagram of a webpage adaptation screen typesetting apparatus according to an embodiment of the present application;
图6为图5所示的装置中计算单元的结构示意图;Figure 6 is a schematic structural view of a computing unit in the apparatus shown in Figure 5;
图7为图5所示的装置中第二执行单元的结构示意图;Figure 7 is a schematic structural view of a second execution unit in the apparatus shown in Figure 5;
图8为图7所示的第二执行单元中样式修改子单元的结构示意图;8 is a schematic structural diagram of a style modification subunit in the second execution unit shown in FIG. 7;
图9为图7所示的第二执行单元中适应屏幕规则排版子单元的结构示意图;以及 9 is a schematic structural diagram of a screen-alignment type sub-unit adapted to a screen in the second execution unit shown in FIG. 7;
图10为图9所示适应屏幕规则排版子单元中动态拉伸子单元的结构示意图。FIG. 10 is a schematic structural diagram of a dynamic stretching subunit in the adaptive screen layout type subunit shown in FIG. 9.
具体实施方式detailed description
为了使本技术领域的人员更好地理解本申请中的技术方案,下面将结合本申请实施例中的附图,对本申请实施例中的技术方案进行清楚、完整地描述,显然,所描述的实施例仅仅是本申请一部分实施例,而不是全部的实施例。基于本申请中的实施例,本领域普通技术人员在没有做出创造性劳动前提下所获得的所有其他实施例,都应当属于本申请保护的范围。The technical solutions in the embodiments of the present application are clearly and completely described in the following, in which the technical solutions in the embodiments of the present application are clearly and completely described. The embodiments are only a part of the embodiments of the present application, and not all of them. All other embodiments obtained by a person of ordinary skill in the art based on the embodiments of the present application without departing from the inventive scope shall fall within the scope of the application.
图1是根据本申请实施方式提供的具有浏览器内核的计算机的结构。1 is a diagram of a structure of a computer having a browser kernel provided in accordance with an embodiment of the present application.
如图1,根据本发明实施方式提供的具有浏览器内核的计算机的结构。计算机可以实施为各种类型的计算机装置,例如台式机、便携式计算机、平板电脑、智能手机、个人数据助理(PDA),或者其他类型的计算机装置,但是不限于任何特定形式。计算机可以包括处理模块100,存储子系统200,输入装置300、显示器400、网络接口500,以及总线600。1, a structure of a computer having a browser kernel provided in accordance with an embodiment of the present invention. The computer can be implemented as various types of computer devices, such as desktops, portable computers, tablets, smart phones, personal data assistants (PDAs), or other types of computer devices, but is not limited to any particular form. The computer can include a processing module 100, a storage subsystem 200, an input device 300, a display 400, a network interface 500, and a bus 600.
处理模块100可以是一个多核的处理器,也可以包含多个处理器。在一些实施例中,处理模块100可以执行存储在存储子系统200上的可执行指令。在图1示出的实施方式中,处理模块100设有操作系统110和运行在操作系统110上的浏览器120。浏览器120包括排版引擎(Webcore)1231。The processing module 100 can be a multi-core processor or multiple processors. In some embodiments, processing module 100 can execute executable instructions stored on storage subsystem 200. In the embodiment illustrated in FIG. 1, the processing module 100 is provided with an operating system 110 and a browser 120 running on the operating system 110. The browser 120 includes a typesetting engine (Webcore) 1231.
在图1示出的结构中,排版引擎1231又包括三个模块:解析模块,排版模块和渲染模块。其中,解析模块又可以包含HTML解析器和CSS解析器。HTML解析器包括标记生成器和树构造器。标记生成器用于将输入的网页内容(通常是XML文档格式)解析成多个HTML标记。HTML标记包括起始标记、结束标记、属性名称和属性值。标记生成器用于识别这些标记,并传递给树构造器,然后接收下一个字符以识别下一个标记;如此反复直到输入的结束。In the structure shown in FIG. 1, the typesetting engine 1231 further includes three modules: a parsing module, a typesetting module, and a rendering module. The parsing module can in turn include an HTML parser and a CSS parser. The HTML parser includes a tag generator and a tree constructor. The tag generator is used to parse the input web page content (usually the XML document format) into multiple HTML tags. HTML tags include start tags, end tags, attribute names, and attribute values. The tag generator identifies these tags and passes them to the tree constructor, then receives the next character to identify the next tag; iterates until the end of the input.
存储子系统200可以包括各种类型的存储单元,例如系统内存、只读存储器(ROM),和永久存储装置。 Storage subsystem 200 can include various types of storage units, such as system memory, read only memory (ROM), and persistent storage.
用户界面可以由一个或多个用户输入装置300、显示器400,和/或一个或多个其他用户输出设备提供。输入装置300可以包括用户向计算机输入信号的装置,计算机可以解释这些信号包含有特定的用户请求或信息。在一些实施方式中,可以通过键盘向用户界面输入网址,要求浏览器120通过用户界面显示输入网址对应的网页内容。 在一些实施方式中,输入装置300可以包含一些或所有的键盘按钮、触摸屏、鼠标或其他定点设备、滚轮、点击轮、转盘、按键、开关、小型键盘、麦克风等等。The user interface can be provided by one or more user input devices 300, display 400, and/or one or more other user output devices. Input device 300 can include means for a user to input signals to a computer that can interpret such signals containing particular user requests or information. In some embodiments, the web address may be input to the user interface through the keyboard, and the browser 120 is required to display the webpage content corresponding to the input web address through the user interface. In some embodiments, input device 300 can include some or all of a keyboard button, touch screen, mouse or other pointing device, scroll wheel, click wheel, dial, button, switch, keypad, microphone, and the like.
显示器400可以显示由计算机生成的图像,可以包括各种类型的图像设备。 Display 400 can display images generated by a computer, and can include various types of image devices.
在一些实施方式中,用户界面可以通过图形用户界面提供。在显示器400中的某些区域定义一些可视的图形元素作为用户通过输入装置300选择的交互对象或者控制对象。In some embodiments, the user interface can be provided through a graphical user interface. Certain areas of the display 400 define some visual graphical elements as interactive objects or control objects that the user selects through the input device 300.
网络接口500为计算机提供声音和/或数据通讯功能。 Network interface 500 provides sound and/or data communication functionality to the computer.
总线600可以包括各种连接计算机内部各部件的系统、外部设备和芯片总线。The bus 600 can include various systems, external devices, and chip buses that connect various components within the computer.
通过适当的编程,处理装置100为计算机可以实现多种类型的功能。例如,处理装置100通过网络接口500从服务器下载网页内容至存储子系统200。然后,处理装置100从存储子系统200中读取网页文件至排版引擎1231。排版引擎1231的解析模块对网页进行解析后构建成一颗DOM树。当DOM树建立的时候,排版引擎1231的排版模块接收CSS解析器的样式信息,构建一个新的内部绘图模型(RenderobjectTree,渲染对象树,又叫排版树),并由排版模块计算模型内各个元素的位置和大小,然后由渲染模块完成从模型到图形的绘制。With proper programming, the processing device 100 can implement multiple types of functions for the computer. For example, processing device 100 downloads web page content from a server to storage subsystem 200 via network interface 500. The processing device 100 then reads the web page file from the storage subsystem 200 to the typesetting engine 1231. The parsing module of the typesetting engine 1231 parses the web page and constructs it into a DOM tree. When the DOM tree is created, the typesetting module of the typesetting engine 1231 receives the style information of the CSS parser, constructs a new internal drawing model (RenderobjectTree, a rendering object tree, also called a typesetting tree), and calculates various elements in the model by the typesetting module. The position and size are then drawn from the model to the graphics by the rendering module.
在图1示出的实施方式中,浏览器的主要作用是用于显示网页。目前,网页是一种使用HTML语言撰写的文档。随着技术的发展,现在网页的样式更为丰富,使用CSS样式语言和JavaScript语言对网页显示特性进行控制。其中,CSS用于描述网页的显示信息,而JS代码用于控制网页的内部逻辑。In the embodiment shown in Figure 1, the primary role of the browser is to display web pages. Currently, a web page is a document written in HTML. With the development of technology, the style of web pages is now more abundant, using CSS style language and JavaScript language to control the display characteristics of web pages. Among them, CSS is used to describe the display information of the webpage, and the JS code is used to control the internal logic of the webpage.
CSS(Cascading Style Sheet,式级联样式表)是一种样式表语言,其中定义了一系列作用在各个元素上的样式规则,用于描述元素的显示信息,控制网页的显示风格。CSS (Cascading Style Sheet) is a style sheet language that defines a series of style rules that act on each element to describe the display information of the element and control the display style of the web page.
参见图2,图2是根据本申请实施方式提供的CSS的框模型示意图。网页中的每个可视元素为一个网络节点。HTML网页中每个可视元素的布局都是按照框模型来设计的。CSS通过框模型(又称箱子模型)来描述HTML元素的布局结构。一个框模型从内至外分为四个部分:外边距、边框、内边距和内容。网页通过对元素设置这些样式属性,就可以达到特定的布局效果。Referring to FIG. 2, FIG. 2 is a schematic diagram of a block model of a CSS according to an embodiment of the present application. Each visual element in a web page is a network node. The layout of each visual element in an HTML page is designed according to the box model. CSS describes the layout structure of HTML elements through a box model (also known as a box model). A box model is divided into four parts from the inside out: the margins, the border, the padding, and the content. Web pages can achieve specific layout effects by setting these style properties on the elements.
网页开发者有两种方法可以使用CSS,一种是将CSS的代码放入元素“style”中,称为内部样式表;另外一种是引用外部的CSS文档,称为外部样式表。此外,还有一 种将CSS的代码放入<head>标签内部,称为内部样式表。内部样式表是浏览器默认的样式表,网页开发者无法控制这部分样式表。Web developers have two ways to use CSS. One is to put the CSS code into the element "style", called the internal style sheet; the other is to reference the external CSS document, called the external style sheet. In addition, there is one Put the CSS code inside the <head> tag, called the internal style sheet. The internal style sheet is the default style sheet for the browser, and web page developers cannot control this part of the style sheet.
在CSS解析器解析CSS时,不管是使用内嵌的CSS代码还是外联的外部样式表。When the CSS parser parses CSS, whether it's using inline CSS code or an external style sheet.
CSS的解析过程是指从CSS字符串经过CSS解析器处理后变成排版引擎的内部规则表示的过程。当浏览器需要解析CSS内容时,它调用解析器对CSS样式进行解析,最后将创建好的结果存储起来。当CSS解析器工作完成后,排版引擎的渲染模块根据CSS解析器的解析结果,会为DOM树的一些可视节点选择合适的样式信息,形成新的内部绘图模型。新的内部绘图模型是由可视化元素按照其显示顺序而组成的树,也是文档的可视化表示。它的作用是让浏览器按照正确的顺序绘制内容。每一个新的内部绘图模型的节点都代表了一个矩形的区域,通常对应于相关节点的CSS框;其中,框的类型会受到与节点相关的“display”样式属性的影响。此外,新的内部绘图模型的节点类型也是考虑因素之一,例如表单控件和表格都对应特殊的框架。The CSS parsing process refers to the process of changing the CSS string into the internal rules representation of the typesetting engine after being processed by the CSS parser. When the browser needs to parse the CSS content, it calls the parser to parse the CSS style, and finally stores the created result. After the CSS parser works, the rendering module of the layout engine selects appropriate style information for some visual nodes of the DOM tree according to the parsing result of the CSS parser to form a new internal drawing model. The new internal drawing model is a tree of visual elements in the order in which they are displayed, as well as a visual representation of the document. Its purpose is to let the browser draw content in the correct order. The nodes of each new internal drawing model represent a rectangular area, usually corresponding to the CSS box of the relevant node; where the type of the box is affected by the "display" style attribute associated with the node. In addition, the node type of the new internal drawing model is also one of the considerations, such as form controls and tables correspond to special frameworks.
图3是本申请实施例提供的一种网页适应屏幕排版方法的流程示意图,如图3所示,所述方法包括以下步骤。FIG. 3 is a schematic flowchart of a webpage adaptation screen layout method according to an embodiment of the present application. As shown in FIG. 3, the method includes the following steps.
在步骤S101中,计算网页排版树中各个节点的宽度;In step S101, calculating a width of each node in the webpage layout tree;
在步骤S102中,判断各个节点的宽度是否小于或等于屏幕宽度;In step S102, it is determined whether the width of each node is less than or equal to the screen width;
在步骤S103中,根据步骤S102的判断结果,如果节点的宽度小于或等于屏幕宽度,则保留所述节点的原样式,并对所述节点按标准流程排版;In step S103, according to the determination result of step S102, if the width of the node is less than or equal to the screen width, the original style of the node is retained, and the node is typeset according to a standard process;
在步骤S104中,根据步骤S102的判断结果,如果节点的宽度不小于或等于屏幕宽度,则修改所述节点的样式,并对所述节点按适应屏幕规则排版。In step S104, according to the judgment result of step S102, if the width of the node is not less than or equal to the screen width, the style of the node is modified, and the node is typeset according to the adaptive screen rule.
其中,移动终端浏览器对获取的网页资源中包含的页面元素进行解析,在根据所述解析生成排版树节点的过程中,计算各个节点的宽度,或者,在根据所述解析生成所有排版树节点后,遍历排版树,并计算各个节点的宽度。The mobile terminal browser parses the page elements included in the acquired webpage resource, calculates the width of each node in the process of generating the typesetting tree node according to the parsing, or generates all the typesetting tree nodes according to the parsing. After that, it traverses the layout tree and calculates the width of each node.
在步骤S101中,计算网页排版树中各个节点的宽度,在一种可能的实施方式中,可以包括以下步骤:In the step S101, the width of each node in the webpage layout tree is calculated. In a possible implementation manner, the following steps may be included:
遍历网页排版树的节点;Traversing the nodes of the web page layout tree;
判断各个节点的层叠样式表中是否设置了宽度值; Determine whether the width value is set in the cascading style sheet of each node;
如果节点的层叠样式表中设置了宽度值,以所述节点的层叠样式表的宽度为节点的宽度;If the width value is set in the cascading style sheet of the node, the width of the cascading style sheet of the node is the width of the node;
如果节点的层叠样式表中未设置宽度值,则查找所述节点的所有子节点,以宽度最大的子节点的宽度为所述节点的宽度,所述子节点的宽度为所述子节点的层叠样式表的宽度;If the width value is not set in the cascading style sheet of the node, all child nodes of the node are searched, and the width of the child node having the largest width is the width of the node, and the width of the child node is a cascading of the child nodes. The width of the style sheet;
如果节点的层叠样式表中未设置宽度值,且所述节点的所有子节点的层叠样式表中未设置宽度值,则设置所述节点的宽度小于或等于屏幕的宽度。If the width value is not set in the cascading style sheet of the node, and the width value is not set in the cascading style sheet of all the child nodes of the node, the width of the node is set to be less than or equal to the width of the screen.
图4为图3所示的方法中计算网页排版树中各个节点的宽度的流程示意图,图4所示的步骤与上述计算排版树中各个节点的宽度在一种可能的实施方式中的步骤对应。如图4所示,在一种可能的实施方式中,计算排版树中各个节点的宽度,可以包括:4 is a flow chart showing the calculation of the width of each node in the webpage layout tree in the method shown in FIG. 3. The step shown in FIG. 4 corresponds to the step of calculating the width of each node in the layout tree in one possible implementation manner. . As shown in FIG. 4, in a possible implementation manner, calculating a width of each node in the layout tree may include:
在步骤S201中,遍历网页排版树的节点;In step S201, traversing a node of a webpage layout tree;
在步骤S202中,判断各个节点的层叠样式表中是否设置了宽度值;In step S202, it is determined whether a width value is set in the cascading style sheet of each node;
在步骤S203中,当节点的层叠样式表中设置了宽度值时,以所述节点的层叠样式表的宽度为节点的宽度;In step S203, when the width value is set in the cascading style sheet of the node, the width of the cascading style sheet of the node is the width of the node;
在步骤S204中,当节点的层叠样式表中未设置宽度值时,查找所述节点的所有子节点;In step S204, when the width value is not set in the cascading style sheet of the node, all the child nodes of the node are searched;
在步骤S205中,判断所述节点的所有子节点的层叠样式表中是否都未设置宽度值;In step S205, it is determined whether the width value is not set in the cascading style sheet of all the child nodes of the node;
在步骤S206中,当步骤S205判断的结果为所述节点的所有子节点的层叠样式表中都未设置宽度值时,设置所述节点的宽度小于或等于屏幕的宽度;In step S206, when the result of the determination in step S205 is that the width value is not set in the cascading style sheet of all the child nodes of the node, the width of the node is set to be less than or equal to the width of the screen;
在步骤S207中,当步骤S205判断的结果为有所述节点的子节点的层叠样式表中设置了宽度值时,以宽度最大的子节点的宽度为所述节点的宽度。In step S207, when the result of the determination in step S205 is that the width value is set in the cascading style sheet of the child node having the node, the width of the child node having the largest width is the width of the node.
其中,步骤S206中,设置所述节点的宽度小于或等于屏幕的宽度,使所述节点的宽度值为一个小于或等于屏幕宽度的宽度值,对所述节点按标准流程排版。In step S206, the width of the node is set to be less than or equal to the width of the screen, so that the width of the node is a width value less than or equal to the width of the screen, and the node is typeset according to a standard process.
其中,步骤S207中,当所述节点的子节点中存在层叠样式表中设置了宽度值的子节点,则将层叠样式表中设置了宽度值的子节点中,宽度最大的子节点的宽度作为所 述节点的宽度。在子节点中寻找宽度最大的子节点可以采用常规的寻找最大值的循环方法,例如,设置中间变量max,查找所述节点的所有子节点,在查找所述节点的所有子节点的过程中,将第一个在层叠样式表中设置了宽度值的子节点的宽度作为max的初值;在之后的查找过程中,将层叠样式表中设置了宽度值的子节点的宽度与max进行比较,如果所述子节点的宽度小于max,则保持max的值不变,如果所述子节点的宽度大于或等于max,则令max等于所述子节点的宽度;以此类推,直至查找完毕所述节点的所有子节点,设置节点的宽度为max,所述max即为宽度最大的子节点的宽度。由于设置节点的宽度在于确定节点的宽度的大小,因此不必要知道查找的过程中最大的宽度对应于节点的哪个子节点,但知道最大的宽度对应于节点的哪个子节点,并不影响本申请的原理。Wherein, in step S207, when a child node having a width value set in the cascading style sheet exists in a child node of the node, the width of the child node having the largest width among the child nodes in which the width value is set in the cascading style sheet is taken as Place The width of the node. Finding the child node with the largest width in the child node may adopt a conventional round-robin method of finding the maximum value, for example, setting the intermediate variable max to find all the child nodes of the node, in the process of searching all the child nodes of the node, The width of the first child node whose width value is set in the cascading style sheet is taken as the initial value of max; in the subsequent search process, the width of the child node whose width value is set in the cascading style sheet is compared with max, If the width of the child node is less than max, the value of max is kept unchanged, and if the width of the child node is greater than or equal to max, let max be equal to the width of the child node; and so on, until the search is completed. All the child nodes of the node, the width of the set node is max, and the max is the width of the child node with the largest width. Since the width of the set node is to determine the size of the width of the node, it is not necessary to know which sub-node of the node corresponds to the maximum width in the process of finding, but knowing which maximum node corresponds to which sub-node of the node does not affect the present application. The principle.
在另一种可能的实施方式中,如果是在根据所述解析生成排版树节点的过程中计算各个节点的宽度,则当某个节点的层叠样式表中未设置宽度值时,继续向下逐层解析所述节点的子节点,以宽度最大的子节点的宽度为所述节点的宽度,所述子节点的宽度为所述子节点的层叠样式表的宽度;如果所述节点的子节点全部解析完毕,而所有所述节点的子节点的层叠样式表中皆未设置宽度值,则设置所述节点的宽度小于或等于屏幕的宽度。In another possible implementation manner, if the width of each node is calculated in the process of generating the typeset tree node according to the parsing, when the width value is not set in the cascading style sheet of a certain node, the downward direction is continued. The layer parses the child nodes of the node, the width of the child node having the largest width is the width of the node, and the width of the child node is the width of the cascading style sheet of the child node; if all the child nodes of the node are After the parsing is completed, and the width values are not set in the cascading style sheets of the child nodes of all the nodes, the width of the nodes is set to be less than or equal to the width of the screen.
在步骤S103中,根据步骤S102的判断结果,如果节点的宽度小于或等于屏幕宽度,则保留所述节点的原样式,并对所述节点按标准流程排版。In step S103, according to the judgment result of step S102, if the width of the node is less than or equal to the screen width, the original style of the node is retained, and the node is typeset according to a standard flow.
在步骤S104中,根据步骤S102的判断结果,如果节点的宽度不小于或等于屏幕宽度,则修改所述节点的样式,并对所述节点按适应屏幕规则排版。In step S104, according to the judgment result of step S102, if the width of the node is not less than or equal to the screen width, the style of the node is modified, and the node is typeset according to the adaptive screen rule.
步骤S104中修改所述节点的样式可以包括但不局限于下述规则:Modifying the style of the node in step S104 may include, but is not limited to, the following rules:
修改节点的层叠样式表的宽度值和最大宽度值,使所述层叠样式表的宽度值和最大宽度值小于或等于屏幕宽度。在网页排版中,节点的层叠样式表的尺寸属性包括宽度、最大宽度和最小宽度等,其中,层叠样式表的宽度用于设置元素内容区的宽度,并用于确定对象的实际宽度;层叠样式表的最大宽度用于限制元素宽度的最大值,防止元素的溢出,并与层叠样式表的最小宽度一起,用于防止网页页面因过大或过小而产生变形。本申请公开的实施例中,如果节点的宽度大于屏幕的宽度,则修改节点的层叠样式表的宽度值,使层叠样式表的宽度值小于屏幕宽度,也就是说元素内容区的宽度不超过屏幕宽度,从而使元素内容在显示时不会超出屏幕。并修改节点的层叠样式表的最大宽度值,使层叠样式表中的最大宽度值小于屏幕宽度,从而进一步防止元素在显示时溢出屏幕或发生变形。如果设置节点的层叠样式表的宽度等于屏幕宽度, 则会造成部分显示内容紧靠屏幕,影响视觉体验,因此优选的是设置节点的层叠样式表的宽度小于屏幕的宽度。层叠样式表的最小宽度默认小于层叠样式表的宽度,因此不赘述层叠样式表的最小宽度的设置。Modify the width and maximum width values of the cascading style sheet of the node such that the width and maximum width values of the cascading style sheet are less than or equal to the screen width. In web page layout, the size attribute of the node's cascading style sheet includes width, maximum width, and minimum width, etc., wherein the width of the cascading style sheet is used to set the width of the element content area, and is used to determine the actual width of the object; the cascading style sheet The maximum width is used to limit the maximum width of the element, preventing element overflow, and along with the minimum width of the cascading style sheet, to prevent web page pages from being distorted due to being too large or too small. In the embodiment disclosed in the present application, if the width of the node is greater than the width of the screen, the width value of the cascading style sheet of the node is modified, so that the width value of the cascading style sheet is smaller than the screen width, that is, the width of the element content area does not exceed the screen. Width so that the element content does not exceed the screen when displayed. And modify the maximum width value of the node's cascading style sheet so that the maximum width value in the cascading style sheet is smaller than the screen width, thereby further preventing the element from overflowing the screen or deforming when displayed. If the width of the cascading style sheet of the set node is equal to the width of the screen, This will cause some of the display content to be close to the screen, affecting the visual experience, so it is preferable to set the width of the cascading style sheet of the node to be smaller than the width of the screen. The minimum width of the cascading style sheet is by default smaller than the width of the cascading style sheet, so the setting of the minimum width of the cascading style sheet is not described.
修改节点中层叠样式表的填充属性和边距属性的分辨率,使所述填充属性和所述边距属性的分辨率分别小于或等于自身的预设值。层叠样式表中,元素的实际宽度由元素内容的宽度、边框属性、填充属性以及边距属性的和确定。其中,边框属性的值通常很小,因此可以不考虑边框属性的调整;填充属性是元素内容和边框之间的间隔;边距属性是一个元素和另一个元素之间的间隔。填充属性和边距属性用于将元素分块显示。Modifying the resolution of the padding attribute and the margin attribute of the cascading style sheet in the node such that the resolution of the padding attribute and the margin attribute are respectively less than or equal to their preset values. In a cascading style sheet, the actual width of an element is determined by the sum of the width of the element content, the border property, the fill property, and the margin property. The value of the border property is usually small, so the adjustment of the border property can be ignored. The fill property is the interval between the content of the element and the border; the margin property is the interval between one element and another. The Fill and Margin properties are used to block the elements.
修改节点中层叠样式表元素盒模型的填充属性和边距属性的分辨率,使所述填充属性和所述边距属性的分辨率分别小于或等于自身的预设值,从而防止元素内容在显示时四周有过多的空白区域,进一步扩大元素内容在屏幕上的显示空间,并避免填充属性和边距属性过大造成网页页面中文本内容折行的问题。填充属性的预设值和边距属性的预设值可以相同,也可以不同。对于目前大多数的手机屏幕而言,填充属性的预设值和边距属性的预设值可以都设为6px,使屏幕空白区域不过大也不过小,让用户有较好的视觉体验。填充属性的预设值和边距属性的预设值也可以根据当前用户使用的智能终端的屏幕大小确定,例如屏幕较大时,可以取较大的填充属性预设值和边距属性的预设值,屏幕较小时,可以取较小的填充属性预设值和边距属性预设值。Modifying the resolution of the padding attribute and the margin attribute of the cascading style sheet element box model in the node, so that the resolution of the padding attribute and the margin attribute are respectively less than or equal to their own preset values, thereby preventing the element content from being displayed. There are too many blank areas around the screen, further expanding the display space of the element content on the screen, and avoiding the problem that the fill attribute and the margin attribute are too large to cause the text content to be broken in the web page. The preset value of the fill property and the preset value of the margin property may be the same or different. For most current mobile phone screens, the preset value of the fill attribute and the preset value of the margin attribute can be set to 6px, so that the blank area of the screen is not too big or too small, so that the user has a better visual experience. The preset value of the padding attribute and the preset value of the margin attribute may also be determined according to the screen size of the smart terminal used by the current user. For example, when the screen is large, a larger padding attribute preset value and a margin attribute may be taken. Set the value. When the screen is small, you can take a smaller padding property preset and margin property preset.
通过修改节点的层叠样式表的宽度值和最大宽度值,以及修改节点中层叠样式表元素盒模型的填充属性和边距属性的分辨率,可以使元素内容的显示适应屏幕的宽度,避免溢出、内容显示不全和变形的问题。By modifying the width and maximum width values of the node's cascading style sheet, and modifying the fill and margin properties of the cascading style sheet element box model in the node, the display of the element content can be adapted to the width of the screen to avoid overflow. The content is incomplete and deformed.
在较佳的实施方式中,所述修改节点的样式,还可以包括:In a preferred embodiment, the modifying the style of the node may further include:
设置所有元素的垂直对齐属性为baseline(元素放置在父元素的基线上)。即对所有元素设置统一的垂直对齐属性,且所述垂直对齐属性为baseline,垂直对齐属性的baseline值指将元素放置在父元素的基线上,从而使所有元素显示整齐,且防止由于元素的垂直对齐属性不一致造成的元素显示在垂直方向上的错乱。Sets the vertical alignment property of all elements to baseline (the element is placed on the baseline of the parent element). That is, a uniform vertical alignment property is set for all elements, and the vertical alignment property is baseline, and the baseline value of the vertical alignment property refers to placing the element on the baseline of the parent element, so that all the elements are displayed neatly and prevented from being vertical due to the element. Elements caused by inconsistent alignment attributes show confusion in the vertical direction.
过滤分辨率大于预设值的背景图。分辨率大于预设值的背景图在节点进行适应屏幕规则排版后也很难与前景的文本或上下文保持原有的协调效果,因而过滤分辨率大于预设图的背景图,避免页面显示效果的不协调,使页面显示更简洁,对分辨率小于预设值的背景图,则可以保留。对目前大多数的手机屏幕而言,所述预设值可以为240*300px,所述预设值也可以根据智能终端的屏幕大小进行设置。 Filter the background image with a resolution greater than the preset value. The background image with the resolution greater than the preset value is difficult to maintain the original coordination effect with the text or context of the foreground after the node adapts to the screen rules. Therefore, the filtering resolution is larger than the background image of the preset image to avoid the page display effect. Uncoordinated, the page display is more concise, and the background image with resolution less than the preset value can be retained. For most current mobile phone screens, the preset value may be 240*300px, and the preset value may also be set according to the screen size of the smart terminal.
限制文本元素的字体大小,使字体大小不超过字体预设值。所述限制文本元素的字体大小,包括:如果文本元素的字体大小小于或等于字体预设值,则不改变文本元素的字体大小,如果文本元素的字体大小大于字体预设值,则修改所述文本元素的字体大小,使所述文本字体大小等于字体预设值。限制文本元素的字体大小,可以防止字体太大造成折行后的重叠,对目前大多数的手机屏幕而言,字体预设值可以设为20号,使字体显示清晰,可视性好,同时避免造成折行,字体预设值也可以根据智能终端的屏幕大小进行设置。Limit the font size of text elements so that the font size does not exceed the font defaults. The limiting the font size of the text element includes: if the font size of the text element is less than or equal to the font preset value, the font size of the text element is not changed, and if the font size of the text element is greater than the font preset value, modifying the The font size of the text element such that the text font size is equal to the font preset value. Limiting the font size of text elements can prevent fonts from being too large to cause overlap after folding. For most current mobile phone screens, the font default value can be set to 20, which makes the font display clear and has good visibility. To avoid folding, the font preset value can also be set according to the screen size of the smart terminal.
设置所有文本元素的行高为所述文本元素的字号的1.6倍。将所有文本元素的行高设置为所述文本元素的字号的1.6倍,可以使文本的行间距适中,不会太紧密也不会太稀疏,提高文本显示的视觉体验。Sets the line height of all text elements to be 1.6 times the font size of the text element. Setting the line height of all text elements to 1.6 times the font size of the text element can make the line spacing of the text moderate, not too close or too sparse, and improve the visual experience of text display.
设置所有文本元素的缩进为相同值。将所有文本元素的缩进设置为相同的值,可以使文本缩进统一,段落换行时可以更好的对齐,从而获得更好的显示效果。所述相同值可以为常规的文本缩进值,例如2px,也可以根据智能终端的屏幕大小确定。Set the indentation of all text elements to the same value. Setting the indentation of all text elements to the same value allows the text to be indented and better aligned when the paragraph is wrapped, resulting in a better display. The same value may be a conventional text indentation value, such as 2px, or may be determined according to the screen size of the smart terminal.
设置文本元素为左对齐,设置图片元素为居中对齐。将文本元素和图片元素设置为统一且符合视觉美感的对齐格式,可以提高用户对图文显示的视觉体验。Set the text element to be left aligned and set the picture element to center aligned. Setting the text element and picture element to a uniform and visually pleasing alignment format can improve the user's visual experience with the graphic display.
在步骤S104中,所述适应屏幕规则排版可以包括但不局限于下述规则:In step S104, the adaptation screen rule layout may include but is not limited to the following rules:
以修改节点的样式后所述节点的元素内容的高度为所述节点的排版高度,按所述节点的排版高度进行排版。修改节点的样式后,由于节点的宽度发生变化,即节点的元素内容的宽度发生变化,相应地可能会导致节点的元素内容的高度发生变化,因此按发生变化后的元素内容的高度为节点的排版高度,而非采用节点的层叠样式表的高度为节点的排版高度,从而保证元素内容在显示时不会出现缺失。After modifying the style of the node, the height of the element content of the node is the layout height of the node, and the typesetting is performed according to the layout height of the node. After modifying the style of the node, since the width of the node changes, that is, the width of the element content of the node changes, the height of the element content of the node may change accordingly, so the height of the content of the changed element is the node. The height of the layout, rather than the height of the cascading style sheet of the node, is the height of the layout of the node, so that the content of the element is not displayed when it is displayed.
动态拉伸浮动(float)元素,所述动态拉伸浮动元素为:在一行中排版n个浮动元素后,当所述行的右方存在空白区域时,将所述浮动元素的宽度值设置为所述浮动元素的最小宽度值后,判断所述行的右方的空白区域是否大于一个或多个所述浮动元素的宽度,当所述行的右方的空白区域大于一个或多个所述浮动元素的宽度时,在所述行的右方的空白区域中加入一个或多个所述浮动元素。其中,n为按标准流程排版时,一行中排版的所述浮动元素的个数。浮动元素的属性包括宽度、最小宽度和最大宽度,将浮动元素的宽度值设置为其最小宽度值,可以将浮动元素的宽度缩小。只有满足所述行的右方的空白区域大于一个或多个所述浮动元素的宽度的条件时,在所述行的右方的空白区域中加入一个或多个所述浮动元素。当所述行的右方不存在空白区 域时,或者当所述行的右方存在空白区域但所述行的右方的空白区域小于一个所述浮动元素的宽度时,对所述浮动元素的排版不作处理。Dynamically stretching a float element, after dynamically formatting a floating element in a row, when a blank area exists on the right side of the line, the width value of the floating element is set to After the minimum width value of the floating element, determining whether the blank area on the right side of the line is greater than the width of one or more of the floating elements, when the blank area on the right side of the line is larger than one or more When floating the width of an element, one or more of the floating elements are added to the blank area to the right of the line. Where n is the number of the floating elements typeset in a line when typesetting according to a standard process. Floating element attributes include width, minimum width, and maximum width. Setting the width of the floating element to its minimum width value reduces the width of the floating element. When only the condition that the blank area on the right side of the line is larger than the width of one or more of the floating elements is satisfied, one or more of the floating elements are added to the blank area on the right side of the line. When there is no blank area on the right side of the line In the case of a domain, or when there is a blank area on the right side of the line but the blank area on the right side of the line is smaller than the width of one of the floating elements, the layout of the floating element is not processed.
与上述动态拉伸浮动元素步骤相对应,所述动态拉伸浮动元素可以包括如下流程步骤:Corresponding to the step of dynamically stretching the floating element, the dynamic stretching floating element may include the following process steps:
(1)判断一行排版n个浮动元素后,所述行的右方是否存在空白区域;(1) After judging a row of n floating elements, whether there is a blank area on the right side of the line;
(2)当步骤(1)的判断结果为所述行的右方存在空白区域时,将所述浮动元素的宽度值设置为所述浮动元素的最小宽度值;(2) when the judgment result of the step (1) is that there is a blank area on the right side of the line, the width value of the floating element is set to the minimum width value of the floating element;
(3)在步骤(2)将所述浮动元素的宽度值设置为所述浮动元素的最小宽度值后,判断所述行的右方的空白区域是否大于一个或多个浮动元素的宽度;(3) after step (2) setting the width value of the floating element to the minimum width value of the floating element, determining whether the blank area on the right side of the line is greater than the width of one or more floating elements;
(4)当步骤(3)的判断结果为所述行的右方的空白区域大于一个或多个浮动元素的宽度时,在所述行的右方的空白区域中加入一个或多个所述浮动元素。(4) when the judgment result of the step (3) is that the blank area on the right side of the line is larger than the width of one or more floating elements, one or more of the blank areas in the right side of the line are added. Floating element.
其中,在一种可能的实施方式中,步骤(3)可以为:获取所述行的右方的空白区域的宽度值,以所述行的右方的空白区域的宽度值除以浮动元素的宽度值,对所得到的结果取整,判断取整的结果m是否大于或等于1;In a possible implementation manner, step (3) may be: acquiring a width value of a blank area on the right side of the row, and dividing a width value of the blank area on the right side of the row by a floating element. a width value, rounding the obtained result, and determining whether the rounded result m is greater than or equal to 1;
相应地,步骤(4)为:当步骤(3)中判断的结果为m大于或等于1时,在所述行的右方的空白区域中加入m个浮动元素;Correspondingly, step (4) is: when the result of the determination in step (3) is that m is greater than or equal to 1, m floating elements are added to the blank area on the right side of the row;
如果步骤(3)的判断结果为所述行的右方不存在空白区域,或者,如果步骤(3)中判断的结果为m小于1,则结束所述动态拉伸浮动元素流程,对所述浮动元素的排版不作处理。If the judgment result of the step (3) is that there is no blank area on the right side of the line, or if the result of the judgment in the step (3) is that m is less than 1, the dynamic stretch floating element flow is ended, The layout of floating elements is not processed.
通过动态拉伸浮动元素,可以扩大浮动元素的可显示区域,在一行中尽可能多的排版浮动元素,从而避免因为节点的样式修改后浮动元素出现折行造成显示混乱和不均匀,也避免屏幕上出现过多空白区域。By dynamically stretching the floating elements, you can expand the displayable area of the floating elements, and type as many floating elements as possible in one line, thereby avoiding the display confusion and unevenness caused by the folding of the floating elements of the node's style, and also avoiding the screen. There are too many blank areas on the top.
在较佳的实施方式中,所述适应屏幕规则排版,还可以包括:In a preferred embodiment, the adapting to the screen rule layout may further include:
展开所有的框架(Frame)和浮动框架(Iframe)元素。由于框架元素和浮动框架元素中通常嵌套了另一个页面,如果不展开这些元素,将难以查看被嵌套的页面。展开框架集(FrameSet)中所有的框架元素,以及所有页面中的浮动框架元素,从而显示框架元素和浮动框架元素中的所有内容,防止适应屏幕排版中无法显示被嵌套页面而造成内容缺失。 Expand all the Frame and Iframe elements. Since another page is usually nested in the frame element and the floating frame element, it is difficult to view the nested page without expanding them. Expands all the frame elements in the FrameSet, as well as the floating frame elements in all the pages, to display all the content in the frame elements and floating frame elements, preventing the content from being missing due to the inability to display the nested pages in the screen layout.
按行排版表格。对表格按行进行排版,而非按表格方式进行排版。所述按行排版表格为:将表格中同一行内的单元格按单元格本身的顺序在一个排版行中依次排版,并将在一个排版行中未排版完毕的单元格另起一个排版行继续排版;当表格中同一行的单元格排版完毕后,将表格中下一行的单元格另起一个排版行进行排版。Type a table by line. Typesetting the rows by row instead of tabular. The line-by-line typesetting table is: sequentially arranging cells in the same row of the table in a layout line in the order of the cells themselves, and continuing to typeset a cell in a typesetting line that has not been typeset. When the cells in the same row in the table are typeset, the cells in the next row in the table are further typeset.
按行排版表格可以更好的使表格适应屏幕的大小,让表格可以完整有序地显示在屏幕上,防止表格内容丢失和单元格变形,以及防止节点的样式修改后表格内容出现重叠和错乱的情况。The line layout table can better adapt the table to the size of the screen, so that the table can be displayed on the screen in a complete and orderly manner, preventing the table content from being lost and cell deformation, and preventing the table contents from overlapping and confusing after the node's style is modified. Happening.
去除多余的空白区域。所述去除多余的空白区域,包括:对于连续出现的多个空标签(<br>),只保留一个空标签,删除其他空标签,从而压缩空行的高度;去掉段落标签(<p>)、单元格标签(<td>)和区块标签(<div>)内单独的空格(&nbsp),所述去掉单独的空格为:当某一行中只有一个&nbsp而无其他元素或内容时,忽略此行,对此行不作排版。去除不必要的空白区域,可以使适应屏幕规则排版的效果更紧凑。Remove excess white space. The removing the excess blank area includes: for a plurality of empty labels (<br>) that appear consecutively, only one empty label is reserved, and other empty labels are deleted, thereby compressing the height of the blank line; removing the paragraph label (<p>) , a single label in the cell label (<td>) and the block label (<div>), and the separate space is removed: when there is only one in a row and no other elements or content, ignore This line does not make a layout for this line. Removing unnecessary white space can make the effect of adapting to screen rule layout more compact.
保持图片、视频和插件元素的长宽比。所述保持图片、视频和插件元素的长宽比为:获取图片、视频和插件元素的原始长宽比,当节点的样式修改后,分别按修改后的图片、视频和插件元素的宽度和自身的原始长宽比调整修改后的图片、视频和插件元素的高度,例如,图片原始的大小为400*600px,原始长宽比为3∶2,节点的样式修改后,图片的宽度变为200px,则图片的高度相应地调整为300px,图片的大小调整为200*300px。Keep the aspect ratio of your images, videos, and plugin elements. The aspect ratio of the image, video, and plug-in elements is: obtaining the original aspect ratio of the image, video, and plug-in elements, and when the style of the node is modified, respectively, according to the width of the modified image, video, and plug-in elements, and The original aspect ratio adjusts the height of the modified image, video, and plug-in elements. For example, the original size of the image is 400*600px, the original aspect ratio is 3:2, and the width of the image is changed to 200px after the style of the node is modified. , the height of the image is adjusted to 300px, and the size of the image is adjusted to 200*300px.
保持图片、视频和插件的长宽比,可以取得更好的显示效果,防止图片、视频和插件在显示时变形。Keep the aspect ratio of images, videos, and plug-ins for better display and prevent images, videos, and plug-ins from morphing as they appear.
本申请实施例提供的一种网页适应屏幕排版方法,只对节点的宽度大于智能终端屏幕的节点,修改所述节点的样式,并按适应屏幕规则排版,使所述节点的显示能够适应屏幕,并具有美观的效果和视觉体验;而对节点的宽度小于或等于智能终端屏幕的节点,则保留其原样式,并按标准流程排版。从而在保证网页页面适应屏幕的基础上更多地保留页面原来的布局、样式和风格,而且由于只改动一部分节点,节省了排版资源,总体上不容易与标准流程冲突,适用于各种页面写法。通过以上的方法实施例的描述,所属领域的技术人员可以清楚地了解到本申请可借助软件加必需的通用硬件平台的方式来实现,当然也可以通过硬件,但很多情况下前者是更佳的实施方式。基于这样的理解,本申请的技术方案本质上或者说对现有技术做出贡献的部分可以以软件产品的形式体现出来,该计算机软件产品存储在一个存储介质中,包括若干指令用以使得一台计算机设备(可以是个人计算机,服务器,或者网络设备等)执行本申 请各个实施例所述方法的全部或部分步骤。而前述的存储介质包括:只读存储器(ROM)、随机存取存储器(RAM)、磁碟或者光盘等各种可以存储程序代码的介质。The method for adapting a screen of a webpage according to an embodiment of the present application is to modify a style of the node only for a node whose width is larger than a screen of the smart terminal, and to perform layout according to an adaptive screen rule, so that the display of the node can adapt to the screen. And has a beautiful effect and visual experience; and the node whose width is less than or equal to the screen of the smart terminal retains its original style and is typeset according to standard procedures. Therefore, the original layout, style and style of the page are more preserved on the basis of ensuring that the webpage is adapted to the screen, and since only a part of the nodes are changed, the typesetting resources are saved, and it is generally not easy to conflict with the standard process, and is applicable to various page writing methods. . Through the description of the above method embodiments, those skilled in the art can clearly understand that the present application can be implemented by means of software plus a necessary general hardware platform, and of course, by hardware, but in many cases, the former is better. Implementation. Based on such understanding, the technical solution of the present application, which is essential or contributes to the prior art, may be embodied in the form of a software product stored in a storage medium, including a plurality of instructions for making a Computer device (can be a personal computer, server, or network device, etc.) to execute this application All or part of the steps of the methods described in the various embodiments are contemplated. The foregoing storage medium includes various types of media that can store program codes, such as a read only memory (ROM), a random access memory (RAM), a magnetic disk, or an optical disk.
根据本申请实施例的第二方面,与本申请实施例提供的一种网页适应屏幕排版方法相对应,本申请实施例还提供了一种网页适应屏幕排版装置。图5为本申请实施例提供的一种网页适应屏幕排版装置的结构示意图,在一种可能的实施方式中,如图5所示,所述装置包括:According to the second aspect of the embodiments of the present application, a webpage adaptation screen layout apparatus provided by the embodiment of the present application is provided. The embodiment of the present application further provides a webpage adaptation screen layout apparatus. FIG. 5 is a schematic structural diagram of a webpage adaptation screen layout apparatus according to an embodiment of the present disclosure. In a possible implementation manner, as shown in FIG. 5, the apparatus includes:
计算单元U301,用于计算网页排版树中各个节点的宽度;a calculating unit U301, configured to calculate a width of each node in the webpage layout tree;
第一判断单元U302,与计算单元U301连接,用于判断各个节点的宽度是否小于或等于屏幕宽度;The first determining unit U302 is connected to the calculating unit U301, and is configured to determine whether the width of each node is less than or equal to the screen width;
第一执行单元U303,与第一判断单元U302连接,用于当节点的宽度小于或等于屏幕宽度时,保留所述节点的原样式,并对所述节点按标准流程排版;The first execution unit U303 is connected to the first determining unit U302, and is configured to reserve the original style of the node when the width of the node is less than or equal to the screen width, and typeset the node according to a standard process;
第二执行单元U304,与第一判断单元U302连接,用于当节点的宽度大于屏幕宽度时,修改所述节点的样式,并对所述节点按适应屏幕规则排版。The second execution unit U304 is connected to the first determining unit U302, and is configured to modify the style of the node when the width of the node is greater than the width of the screen, and typeset the node according to the adaptive screen rule.
此处需要说明的是,上述第一判断单元U302、第一执行单元U303、第二执行单元U304可以作为装置的一部分运行在计算机终端中,可以通过计算机终端中的处理器来执行上述模块实现的功能,计算机终端也可以是智能手机(如Android手机、iOS手机等)、平板电脑、掌声电脑以及移动互联网设备(Mobile Internet Devices,MID)、PAD等终端设备。It should be noted that the foregoing first determining unit U302, the first executing unit U303, and the second executing unit U304 may be run in a computer terminal as part of the device, and may be implemented by a processor in the computer terminal. Function, the computer terminal can also be a smart phone (such as an Android phone, an iOS phone, etc.), a tablet computer, an applause computer, and a mobile Internet device (MID), a PAD, and the like.
图6为图5所示的装置中计算单元的结构示意图。在一种可能的实施方式中,所述计算单元U301,如图6所示,包括:FIG. 6 is a schematic structural view of a computing unit in the apparatus shown in FIG. 5. In a possible implementation, the computing unit U301, as shown in FIG. 6, includes:
第一执行子单元U401,用于遍历网页排版树的节点;a first execution subunit U401, configured to traverse a node of a webpage layout tree;
第一判断子单元U402,与第一执行子单元U401连接,用于判断各个节点的层叠样式表中是否设置了宽度值;The first determining subunit U402 is connected to the first executing subunit U401, and is configured to determine whether a width value is set in the cascading style sheet of each node;
第二执行子单元U403,与第一判断子单元U402连接,用于当节点的层叠样式表中设置了宽度值时,以所述节点的层叠样式表的宽度为节点的宽度;The second execution subunit U403 is connected to the first judging subunit U402, and is configured to use the width of the cascading style sheet of the node as the width of the node when the width value is set in the cascading style sheet of the node;
第三执行子单元U404,与第一判断子单元U402连接,用于当节点的层叠样式表中未设置宽度值时,查找所述节点的所有子节点; The third execution subunit U404 is connected to the first determining subunit U402, and is configured to search all the child nodes of the node when the width value is not set in the cascading style sheet of the node;
第二判断子单元U405,与第三执行子单元U404连接,用于判断所述节点的所有子节点的层叠样式表中是否都未设置宽度值;The second determining subunit U405 is connected to the third executing subunit U404, and is configured to determine whether the width value is not set in the cascading style sheet of all the child nodes of the node;
第四执行子单元U406,与第二判断子单元U405和第三执行子单元U404连接,用于当所述节点的所有子节点的层叠样式表中都未设置宽度值时,设置所述节点的宽度小于或等于屏幕的宽度;The fourth execution subunit U406 is connected to the second judging subunit U405 and the third execution subunit U404, and is configured to set the node when the width value is not set in the cascading style sheet of all the child nodes of the node. The width is less than or equal to the width of the screen;
第五执行子单元U407,与第二判断子单元U405和第三执行子单元U404连接,用于当有所述节点的子节点的层叠样式表中设置了宽度值时,以宽度最大的所述子节点的宽度为所述节点的宽度。a fifth execution subunit U407, connected to the second judging subunit U405 and the third execution subunit U404, for when the width value is set in the cascading style sheet of the child node of the node, the width is the largest The width of the child node is the width of the node.
此处需要说明的是,上述第一执行子单元U401、第一判断子单元U402、第二执行子单元U403、第三执行子单元U404、第二判断子单元U405、第四执行子单元U406和第五执行子单元U407可以作为装置的一部分运行在计算机终端中,可以通过计算机终端中的处理器来执行上述模块实现的功能,计算机终端也可以是智能手机(如Android手机、iOS手机等)、平板电脑、掌声电脑以及移动互联网设备(Mobile Internet Devices,MID)、PAD等终端设备。It should be noted that the foregoing first execution subunit U401, first judgment subunit U402, second execution subunit U403, third execution subunit U404, second judgment subunit U405, fourth execution subunit U406 and The fifth execution subunit U407 can be run in the computer terminal as part of the device, and the function implemented by the above module can be executed by a processor in the computer terminal, and the computer terminal can also be a smart phone (such as an Android mobile phone, an iOS mobile phone, etc.). Tablet PCs, applause computers, and mobile Internet devices (MID), PAD and other terminal devices.
图7为图5所示的装置中第二执行单元的结构示意图。在一种可能的实施方式中,所述第二执行单元U304,如图7所示,包括:FIG. 7 is a schematic structural view of a second execution unit in the apparatus shown in FIG. 5. In a possible implementation manner, the second executing unit U304, as shown in FIG. 7, includes:
样式修改子单元U501,用于修改节点的样式;The style modification subunit U501 is used to modify the style of the node;
适应屏幕规则排版子单元U502,与样式修改子单元U501连接,用于对节点按适应屏幕规则排版。The screen-adapted layout sub-unit U502 is connected to the style modification sub-unit U501 for formatting the nodes according to the adaptive screen rules.
此处需要说明的是,上述创样式修改子单元U501和适应屏幕规则排版子单元U502可以作为装置的一部分运行在计算机终端中,可以通过计算机终端中的处理器来执行上述模块实现的功能,计算机终端也可以是智能手机(如Android手机、iOS手机等)、平板电脑、掌声电脑以及移动互联网设备(Mobile Internet Devices,MID)、PAD等终端设备。It should be noted that the above-mentioned creation pattern modification subunit U501 and the adaptation screen rule layout subunit U502 can be run in the computer terminal as part of the device, and the functions implemented by the above module can be executed by the processor in the computer terminal, the computer The terminal can also be a smart phone (such as an Android phone, an iOS phone, etc.), a tablet computer, an applause computer, and a mobile Internet device (MID), a PAD, and the like.
图8为图7所示的第二执行单元中样式修改子单元的结构示意图。在一种可能的实施方式中,所述修改样式子单元,如图8所示,包括:FIG. 8 is a schematic structural diagram of a pattern modification subunit in the second execution unit shown in FIG. 7. In a possible implementation manner, the modified style subunit, as shown in FIG. 8, includes:
宽度修改子单元U601,用于修改节点的层叠样式表的宽度值和最大宽度值,使所述层叠样式表的宽度值和最大宽度值小于屏幕宽度; a width modifying subunit U601, configured to modify a width value and a maximum width value of the cascading style sheet of the node, so that the width value and the maximum width value of the cascading style sheet are smaller than the screen width;
边距修改子单元U602,修改节点中层叠样式表元素盒模型的填充属性和边距属性的分辨率,使所述填充属性和所述边距属性的分辨率分别小于或等于自身的预设值。The margin modification subunit U602, the resolution of the padding attribute and the margin attribute of the cascading style sheet element box model in the node is modified, so that the resolutions of the padding attribute and the margin attribute are respectively less than or equal to their preset values. .
此处需要说明的是,上述宽度修改子单元U601和边距修改子单元U602可以作为装置的一部分运行在计算机终端中,可以通过计算机终端中的处理器来执行上述模块实现的功能,计算机终端也可以是智能手机(如Android手机、iOS手机等)、平板电脑、掌声电脑以及移动互联网设备(Mobile Internet Devices,MID)、PAD等终端设备。It should be noted that the width modification subunit U601 and the margin modification subunit U602 may be run in a computer terminal as part of the device, and the functions implemented by the above module may be performed by a processor in the computer terminal, and the computer terminal is also It can be a smart phone (such as Android phone, iOS phone, etc.), tablet computer, applause computer, and mobile Internet devices (MID), PAD and other terminal devices.
图9为图7所示的第二执行单元中适应屏幕规则排版子单元的结构示意图。在一种可能的实施方式中,所述适应屏幕规则排版子单元,如图9所示,包括:FIG. 9 is a schematic structural diagram of a screen-aligning sub-unit adapted to a screen in the second execution unit shown in FIG. 7. In a possible implementation manner, the adapting screen rule typesetting subunit, as shown in FIG. 9, includes:
高度排版子单元U701,用于以修改节点的样式后所述节点的元素内容的高度为所述节点的排版高度,按所述节点的排版高度进行排版;a high typesetting subunit U701, configured to modify a node's style, the height of the element content of the node is a layout height of the node, and typeset according to the typesetting height of the node;
动态拉伸子单元U702,用于动态拉伸浮动元素。Dynamic stretching subunit U702 for dynamically stretching floating elements.
此处需要说明的是,上述高度排版子单元U701和动态拉伸子单元U702可以作为装置的一部分运行在计算机终端中,可以通过计算机终端中的处理器来执行上述模块实现的功能,计算机终端也可以是智能手机(如Android手机、iOS手机等)、平板电脑、掌声电脑以及移动互联网设备(Mobile Internet Devices,MID)、PAD等终端设备。It should be noted that the above-mentioned height type sub-unit U701 and dynamic stretch sub-unit U702 can be run in a computer terminal as part of the device, and the functions implemented by the above modules can be executed by a processor in the computer terminal, and the computer terminal is also It can be a smart phone (such as Android phone, iOS phone, etc.), tablet computer, applause computer, and mobile Internet devices (MID), PAD and other terminal devices.
图10为图9所示适应屏幕规则排版子单元中动态拉伸子单元的结构示意图。在一种可能的实施方式中,所述动态拉伸子单元,如图10所示,包括:FIG. 10 is a schematic structural diagram of a dynamic stretching subunit in the adaptive screen layout type subunit shown in FIG. 9. In a possible implementation manner, the dynamic stretching subunit, as shown in FIG. 10, includes:
第三判断子单元U801,用于判断一行排版n个浮动元素后,所述行的右方是否存在空白区域;The third determining sub-unit U801 is configured to determine whether there is a blank area on the right side of the line after the row of n floating elements is typed;
第六执行子单元U802,与第三判断子单元U801连接,用于当所述行的右方存在空白区域时,将所述浮动元素的宽度值设置为所述浮动元素的最小宽度值;a sixth execution sub-unit U802, connected to the third determining sub-unit U801, configured to set a width value of the floating element to a minimum width value of the floating element when a blank area exists on a right side of the row;
第四判断子单元U803,与第六执行子单元U802连接,用于当所述行的右方存在空白区域时,将所述浮动元素的宽度值设置为所述浮动元素的最小宽度值后,判断所述行的右方的空白区域是否大于一个或多个所述浮动元素的宽度;The fourth determining sub-unit U803 is connected to the sixth executing sub-unit U802, and is configured to set a width value of the floating element to a minimum width value of the floating element when a blank area exists on a right side of the line, Determining whether a blank area on the right side of the line is greater than a width of one or more of the floating elements;
第七执行子单元U804,与第四判断子单元U803连接,用于当所述行的右方的空白区域大于一个或多个所述浮动元素的宽度时,在所述行的右方的空白区域中加入一个或多个所述浮动元素。 The seventh execution subunit U804 is connected to the fourth judging subunit U803 for blanking on the right side of the row when the blank area on the right side of the row is larger than the width of one or more of the floating elements One or more of the floating elements are added to the area.
此处需要说明的是,上述第三判断子单元U801、第六执行子单元U802、第四判断子单元U803和第七执行子单元U804可以作为装置的一部分运行在计算机终端中,可以通过计算机终端中的处理器来执行上述模块实现的功能,计算机终端也可以是智能手机(如Android手机、iOS手机等)、平板电脑、掌声电脑以及移动互联网设备(Mobile Internet Devices,MID)、PAD等终端设备。It should be noted that the third determining subunit U801, the sixth executing subunit U802, the fourth judging subunit U803, and the seventh executing subunit U804 may be run in a computer terminal as part of the device, and may be through a computer terminal. The processor in the above module performs the functions implemented by the above modules, and the computer terminal can also be a smart phone (such as an Android phone, an iOS phone, etc.), a tablet computer, a palm computer, and a mobile Internet device (MID), a PAD, and the like. .
本申请实施例提供的一种网页适应屏幕排版装置,通过计算网页排版树中各个节点的宽度,对节点的宽度小于或等于智能终端屏幕的节点,保留其原样式,并按标准流程排版;对节点的宽度大于智能终端屏幕的节点,则修改所述节点的样式,限制所述节点的宽度,并按适应屏幕规则排版,使所述节点的显示能够适应屏幕,并具有美观的效果和视觉体验。从而在保证网页页面适应屏幕的基础上更多地保留页面原来的布局、样式和风格,而且由于只改动一部分节点,简化了结构,节省了排版资源,总体上不容易与标准流程冲突,适用于各种页面写法的排版。The webpage adapting screen typesetting apparatus provided by the embodiment of the present application, by calculating the width of each node in the webpage layout tree, retaining the original style of the node whose width of the node is less than or equal to the screen of the smart terminal, and formatting according to a standard process; If the width of the node is larger than the node of the smart terminal screen, the style of the node is modified, the width of the node is limited, and the layout is adapted according to the rules of the screen, so that the display of the node can adapt to the screen, and has an aesthetic effect and a visual experience. . Therefore, the original layout, style and style of the page are more reserved on the basis of ensuring that the webpage is adapted to the screen, and since only a part of the nodes are changed, the structure is simplified, the typesetting resources are saved, and the standard process conflict is not easy, and is applicable to Typesetting of various page writing methods.
本申请实施例所提供的各个功能单元可以在移动终端、计算机终端或者类似的运算装置中运行,也可以作为存储介质的一部分进行存储。The various functional units provided by the embodiments of the present application may be operated in a mobile terminal, a computer terminal, or the like, or may be stored as part of a storage medium.
由此,本发明的实施例可以提供一种计算机终端,该计算机终端可以是计算机终端群中的任意一个计算机终端设备。可选地,在本实施例中,上述计算机终端也可以替换为移动终端等终端设备。Thus, embodiments of the present invention may provide a computer terminal, which may be any computer terminal device in a group of computer terminals. Optionally, in this embodiment, the foregoing computer terminal may also be replaced with a terminal device such as a mobile terminal.
可选地,在本实施例中,上述计算机终端可以位于计算机网络的多个网络设备中的至少一个网络设备。Optionally, in this embodiment, the computer terminal may be located in at least one network device of the plurality of network devices of the computer network.
在本实施例中,上述计算机终端可以执行获取立体热力图的方法中以下步骤的程序代码:获取网页页面的平面热力图的数据,平面热力图的数据包括网页页面的点击数据;基于点击获取层建立三维坐标系,获取轴测图;将平面热力图的数据显示在轴测图上,获取立体热力图。In this embodiment, the computer terminal may execute the program code of the following steps in the method for acquiring a stereo heat map: acquiring data of a plane heat map of a webpage page, and the data of the plane heat map includes click data of the webpage page; A three-dimensional coordinate system is established to obtain an axonometric map; the data of the planar thermodynamic map is displayed on the isometric view to obtain a stereoscopic thermogram.
可选地,该计算机终端可以包括:一个或多个处理器、存储器、以及传输装置。Optionally, the computer terminal can include: one or more processors, memory, and transmission means.
其中,存储器可用于存储软件程序以及模块,如本发明实施例中的获取立体热力图的方法及装置对应的程序指令/模块,处理器通过运行存储在存储器内的软件程序以及模块,从而执行各种功能应用以及数据处理,即实现上述的获取立体热力图的方法。存储器可包括高速随机存储器,还可以包括非易失性存储器,如一个或者多个磁性存储装置、闪存、或者其他非易失性固态存储器。在一些实例中,存储器可进一步包括 相对于处理器远程设置的存储器,这些远程存储器可以通过网络连接至终端。上述网络的实例包括但不限于互联网、企业内部网、局域网、移动通信网及其组合。The memory can be used to store the software program and the module, such as the method and device corresponding to the method for acquiring the stereo heat map in the embodiment of the present invention, and the processor executes the software program and the module stored in the memory, thereby executing each A functional application and data processing, that is, the above method of acquiring a stereo heat map. The memory may include a high speed random access memory, and may also include non-volatile memory such as one or more magnetic storage devices, flash memory, or other non-volatile solid state memory. In some examples, the memory can further include These remote memories can be connected to the terminal over a network with respect to the memory remotely set by the processor. Examples of such networks include, but are not limited to, the Internet, intranets, local area networks, mobile communication networks, and combinations thereof.
上述的传输装置用于经由一个网络接收或者发送数据。上述的网络具体实例可包括有线网络及无线网络。在一个实例中,传输装置包括一个网络适配器(Network Interface Controller,NIC),其可通过网线与其他网络设备与路由器相连从而可与互联网或局域网进行通讯。在一个实例中,传输装置为射频(Radio Frequency,RF)模块,其用于通过无线方式与互联网进行通讯。The above transmission device is for receiving or transmitting data via a network. Specific examples of the above network may include a wired network and a wireless network. In one example, the transmission device includes a Network Interface Controller (NIC) that can be connected to other network devices and routers via a network cable to communicate with the Internet or a local area network. In one example, the transmission device is a Radio Frequency (RF) module for communicating with the Internet wirelessly.
其中,具体地,存储器用于存储预设动作条件和预设权限用户的信息、以及应用程序。Specifically, the memory is used to store preset action conditions and information of the preset rights user, and an application.
处理器可以通过传输装置调用存储器存储的信息及应用程序,以执行上述方法实施例中的各个可选或优选实施例的方法步骤的程序代码。The processor can call the memory stored information and the application by the transmitting device to execute the program code of the method steps of each of the alternative or preferred embodiments of the above method embodiments.
本领域普通技术人员可以理解,计算机终端也可以是智能手机(如Android手机、iOS手机等)、平板电脑、掌声电脑以及移动互联网设备(Mobile Internet Devices,MID)、PAD等终端设备。A person skilled in the art can understand that the computer terminal can also be a smart phone (such as an Android phone, an iOS phone, etc.), a tablet computer, an applause computer, and a mobile Internet device (MID), a PAD, and the like.
本领域普通技术人员可以理解上述实施例的各种方法中的全部或部分步骤是可以通过程序来指令终端设备相关的硬件来完成,该程序可以存储于一计算机可读存储介质中,存储介质可以包括:闪存盘、只读存储器(Read-Only Memory,ROM)、随机存取器(Random Access Memory,RAM)、磁盘或光盘等。A person of ordinary skill in the art may understand that all or part of the steps of the foregoing embodiments may be completed by a program to instruct terminal device related hardware, and the program may be stored in a computer readable storage medium, and the storage medium may be Including: flash disk, read-only memory (ROM), random access memory (RAM), disk or optical disk.
本发明的实施例还提供了一种存储介质。可选地,在本实施例中,上述存储介质可以用于保存上述方法实施例和装置实施例所提供的获取立体热力图的方法所执行的程序代码。Embodiments of the present invention also provide a storage medium. Optionally, in this embodiment, the foregoing storage medium may be used to save the program code executed by the method for obtaining a stereo heat map provided by the foregoing method embodiment and the device embodiment.
可选地,在本实施例中,上述存储介质可以位于计算机网络中计算机终端群中的任意一个计算机终端中,或者位于移动终端群中的任意一个移动终端中。Optionally, in this embodiment, the foregoing storage medium may be located in any one of the computer terminal groups in the computer network, or in any one of the mobile terminal groups.
可选地,在本实施例中,存储介质被设置为存储用于执行以下步骤的程序代码:获取网页页面的平面热力图的数据,平面热力图的数据包括网页页面的点击数据;基于点击获取层建立三维坐标系,获取轴测图;将平面热力图的数据显示在轴测图上,获取立体热力图。Optionally, in this embodiment, the storage medium is configured to store program code for performing the following steps: acquiring data of a plane heat map of the webpage page, the data of the plane heat map including click data of the webpage page; The layer establishes a three-dimensional coordinate system to obtain an axonometric map; the data of the planar thermodynamic map is displayed on the isometric view to obtain a stereoscopic thermogram.
可选地,在本实施例中,存储介质还可以被设置为存储获取立体热力图的方法提供的各种优选地或可选的方法步骤的程序代码。 Alternatively, in the present embodiment, the storage medium may also be configured to store program code of various preferred or optional method steps provided by the method of acquiring a stereo heat map.
如上参照附图以示例的方式描述了根据本发明的获取立体热力图的方法及装置。但是,本领域技术人员应当理解,对于上述本发明所提出的获取立体热力图的方法及装置,还可以在不脱离本发明内容的基础上做出各种改进。因此,本发明的保护范围应当由所附的权利要求书的内容确定。A method and apparatus for acquiring a stereo heat map according to the present invention is described above by way of example with reference to the accompanying drawings. However, it should be understood by those skilled in the art that various improvements can be made to the method and apparatus for obtaining a three-dimensional heat map proposed by the present invention without departing from the scope of the present invention. Therefore, the scope of the invention should be determined by the content of the appended claims.
为了描述的方便,描述以上装置时以功能分为各种单元分别描述。当然,在实施本申请时可以把各单元的功能在同一个或多个软件和/或硬件中实现。For the convenience of description, the above devices are described separately by function into various units. Of course, the functions of each unit may be implemented in the same software or software and/or hardware when implementing the present application.
本说明书中的各个实施例均采用递进的方式描述,各个实施例之间相同相似的部分互相参见即可,每个实施例重点说明的都是与其他实施例的不同之处。尤其,对于装置实施例而言,由于其基本相似于方法实施例,所以描述得比较简单,相关之处参见方法实施例的部分说明即可。以上所描述的装置实施例仅仅是示意性的,其中所述作为分离部件说明的单元可以是或者也可以不是物理上分开的,作为单元显示的部件可以是或者也可以不是物理单元,即可以位于一个地方,或者也可以分布到多个网络单元上。可以根据实际的需要选择其中的部分或者全部模块来实现本实施例方案的目的。本领域普通技术人员在不付出创造性劳动的情况下,即可以理解并实施。The various embodiments in the specification are described in a progressive manner, and the same or similar parts between the various embodiments may be referred to each other, and each embodiment focuses on the differences from the other embodiments. In particular, for the device embodiment, since it is basically similar to the method embodiment, the description is relatively simple, and the relevant parts can be referred to the description of the method embodiment. The device embodiments described above are merely illustrative, wherein the units described as separate components may or may not be physically separate, and the components displayed as units may or may not be physical units, ie may be located A place, or it can be distributed to multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the solution of the embodiment. Those of ordinary skill in the art can understand and implement without any creative effort.
本申请可以在由计算机执行的计算机可执行指令的一般上下文中描述,例如程序模块。一般地,程序模块包括执行特定任务或实现特定抽象数据类型的例程、程序、对象、组件、数据结构等等。也可以在分布式计算环境中实践本申请,在这些分布式计算环境中,由通过通信网络而被连接的远程处理设备来执行任务。在分布式计算环境中,程序模块可以位于包括存储设备在内的本地和远程计算机存储介质中。The application can be described in the general context of computer-executable instructions executed by a computer, such as a program module. Generally, program modules include routines, programs, objects, components, data structures, and the like that perform particular tasks or implement particular abstract data types. The present application can also be practiced in distributed computing environments where tasks are performed by remote processing devices that are connected through a communication network. In a distributed computing environment, program modules can be located in both local and remote computer storage media including storage devices.
需要说明的是,在本文中,诸如“第一”和“第二”等之类的关系术语仅仅用来将一个实体或者操作与另一个实体或操作区分开来,而不一定要求或者暗示这些实体或操作之间存在任何这种实际的关系或者顺序。而且,术语“包括”、“包含”或者其任何其他变体意在涵盖非排他性的包含,从而使得包括一系列要素的过程、方法、装置、单元或者设备不仅包括那些要素,而且还包括没有明确列出的其他要素,或者是还包括为这种过程、方法、装置、单元或者设备所固有的要素。在没有更多限制的情况下,由语句“包括一个……”限定的要素,并不排除在包括所述要素的过程、方法、装置、单元或者设备中还存在另外的相同要素。It should be noted that, in this context, relational terms such as "first" and "second" are used merely to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply these There is any such actual relationship or order between entities or operations. Rather, the term "comprises" or "comprises" or "comprises" or "comprising" or "comprising" or "comprises" Other elements listed, or elements that are inherent to such a process, method, device, unit, or device. An element that is defined by the phrase "comprising a singular" or "an" or "an"
以上所述仅是本申请的具体实施方式,使本领域技术人员能够理解或实现本申请。对这些实施例的多种修改对本领域的技术人员来说将是显而易见的,本文中所定义的一般原理可以在不脱离本申请的精神或范围的情况下,在其它实施例中实现。因此, 本申请将不会被限制于本文所示的这些实施例,而是要符合与本文所公开的原理和新颖特点相一致的最宽的范围。 The above description is only a specific embodiment of the present application, so that those skilled in the art can understand or implement the present application. Various modifications to these embodiments are obvious to those skilled in the art, and the general principles defined herein may be implemented in other embodiments without departing from the spirit or scope of the application. Therefore, The application is not limited to the embodiments shown herein, but rather the broadest scope consistent with the principles and novel features disclosed herein.

Claims (15)

  1. 一种网页适应屏幕排版方法,其特征在于,包括:A webpage adapting screen typesetting method, comprising:
    计算网页排版树中各个节点的宽度;Calculating the width of each node in the web page layout tree;
    判断各个节点的宽度是否小于或等于屏幕宽度;以及Determine whether the width of each node is less than or equal to the screen width;
    如果节点的宽度小于或等于屏幕宽度,则保留所述节点的原样式,并对所述节点按标准流程排版,否则,修改所述节点的样式,并对所述节点按适应屏幕规则排版。If the width of the node is less than or equal to the screen width, the original style of the node is retained, and the node is typeset according to a standard flow; otherwise, the style of the node is modified, and the node is typeset according to the adaptive screen rules.
  2. 如权利要求1所述的网页适应屏幕排版方法,其特征在于,所述计算网页排版树中各个节点的宽度,包括:The webpage adaptation screen layout method according to claim 1, wherein the calculating the width of each node in the webpage layout tree comprises:
    遍历网页排版树的节点;Traversing the nodes of the web page layout tree;
    判断各个节点的层叠样式表中是否设置了宽度值;Determine whether the width value is set in the cascading style sheet of each node;
    如果节点的层叠样式表中设置了宽度值,以所述节点的层叠样式表的宽度为节点的宽度;If the width value is set in the cascading style sheet of the node, the width of the cascading style sheet of the node is the width of the node;
    如果节点的层叠样式表中未设置宽度值,则查找所述节点的所有子节点,以宽度最大的子节点的宽度为所述节点的宽度,所述子节点的宽度为所述子节点的层叠样式表的宽度;If the width value is not set in the cascading style sheet of the node, all child nodes of the node are searched, and the width of the child node having the largest width is the width of the node, and the width of the child node is a cascading of the child nodes. The width of the style sheet;
    如果节点的层叠样式表中未设置宽度值,且所述节点的所有子节点中的层叠样式表中未设置宽度值,则设置所述节点的宽度小于或等于屏幕的宽度。If the width value is not set in the cascading style sheet of the node, and the width value is not set in the cascading style sheet in all the child nodes of the node, the width of the node is set to be less than or equal to the width of the screen.
  3. 如权利要求1所述的网页适应屏幕排版方法,其特征在于,所述修改节点的样式,包括:The method for modifying a web page according to claim 1, wherein the modifying the style of the node comprises:
    修改节点的层叠样式表的宽度值和最大宽度值,使所述层叠样式表的宽度值和最大宽度值小于屏幕宽度;Modifying the width value and the maximum width value of the cascading style sheet of the node such that the width value and the maximum width value of the cascading style sheet are smaller than the screen width;
    修改节点中层叠样式表元素盒模型的填充属性和边距属性的分辨率,使所述填充属性和所述边距属性的分辨率分别小于或等于自身的预设值。Modifying the resolution of the padding attribute and the margin attribute of the cascading style sheet element box model in the node such that the resolution of the padding attribute and the margin attribute are respectively less than or equal to their preset values.
  4. 如权利要求1所述的网页适应屏幕排版方法,其特征在于,所述适应屏幕规则排版,包括: The web page adaptation screen layout method according to claim 1, wherein the adapting to the screen rule layout comprises:
    以修改节点的样式后所述节点的元素内容的高度为所述节点的排版高度,按所述节点的排版高度进行排版;After modifying the style of the node, the height of the element content of the node is the layout height of the node, and the typesetting is performed according to the layout height of the node;
    动态拉伸浮动元素,其中,所述浮动元素为排列在所述网页上的所述节点的显示内容。The floating element is dynamically stretched, wherein the floating element is display content of the node arranged on the webpage.
  5. 如权利要求4所述的网页适应屏幕排版方法,其特征在于,所述动态拉伸浮动元素,包括:The webpage adaptation screen layout method according to claim 4, wherein the dynamically stretching the floating element comprises:
    判断一行在进行排版n个所述浮动元素之后,所述行的右方是否存在空白区域,其中,所述n为按标准流程排版时,所述行中排版的所述浮动元素的个数;Determining whether a row has a blank area on the right side of the line after the n-th floating element is being typed, wherein the n is the number of the floating elements in the line when the typesetting is performed according to a standard process;
    当所述行的右方存在所述空白区域时,将所述浮动元素的宽度值设置为所述浮动元素的最小宽度值。When the blank area exists on the right side of the line, the width value of the floating element is set to the minimum width value of the floating element.
  6. 如权利要求5所述的网页适应屏幕排版方法,其特征在于,在所述判断一行在进行排版n个所述浮动元素之后,所述行的右方是否存在空白区域之后,方法还包括:The web page adaptation screen layout method according to claim 5, wherein after the determining whether a row has n types of the floating elements, whether there is a blank area on the right side of the line, the method further comprises:
    判断所述行的右方的所述空白区域是否大于一个或多个所述浮动元素的宽度;Determining whether the blank area on the right side of the row is greater than the width of one or more of the floating elements;
    当所述行的右方的所述空白区域大于一个或多个所述浮动元素的宽度时,在所述行的右方的所述空白区域中加入一个或多个所述浮动元素。When the blank area to the right of the row is larger than the width of one or more of the floating elements, one or more of the floating elements are added to the blank area to the right of the row.
  7. 一种网页适应屏幕排版装置,其特征在于,包括:A webpage adaptation screen layout apparatus, comprising:
    计算单元,用于计算网页排版树中各个节点的宽度;a calculation unit, configured to calculate a width of each node in the webpage layout tree;
    第一判断单元,用于判断各个节点的宽度是否小于或等于屏幕宽度;a first determining unit, configured to determine whether a width of each node is less than or equal to a screen width;
    第一执行单元,用于当节点的宽度小于或等于屏幕宽度时,保留所述节点的原样式,并对所述节点按标准流程排版;a first execution unit, configured to reserve an original style of the node when the width of the node is less than or equal to a screen width, and typeset the node according to a standard process;
    第二执行单元,用于当节点的宽度大于屏幕宽度时,修改所述节点的样式,并对所述节点按适应屏幕规则排版。a second execution unit, configured to modify a style of the node when the width of the node is greater than a width of the screen, and format the node according to an adaptive screen rule.
  8. 如权利要求7所述的网页适应屏幕排版装置,其特征在于,所述计算单元,包括:The webpage adaptation screen layout apparatus according to claim 7, wherein the calculation unit comprises:
    第一执行子单元,用于遍历网页排版树的节点;a first execution subunit, configured to traverse a node of a webpage layout tree;
    第一判断子单元,用于判断各个节点的层叠样式表中是否设置了宽度值; a first determining subunit, configured to determine whether a width value is set in a cascading style sheet of each node;
    第二执行子单元,用于当节点的层叠样式表中设置了宽度值时,以所述节点的层叠样式表的宽度为节点的宽度;a second execution subunit, configured to use a width of the cascading style sheet of the node as a width of a node when a width value is set in a cascading style sheet of the node;
    第三执行子单元,用于当节点的层叠样式表中未设置宽度值时,查找所述节点的所有子节点;a third execution subunit, configured to find all child nodes of the node when a width value is not set in the cascading style sheet of the node;
    第二判断子单元,用于判断所述节点的所有子节点的层叠样式表中是否都未设置宽度值;a second determining subunit, configured to determine whether a width value is not set in a cascading style sheet of all child nodes of the node;
    第四执行子单元,用于当所述节点的所有子节点的层叠样式表中都未设置宽度值时,设置所述节点的宽度小于或等于屏幕的宽度;a fourth execution subunit, configured to set a width of the node to be less than or equal to a width of the screen when a width value is not set in a cascading style sheet of all child nodes of the node;
    第五执行子单元,用于当有所述节点的子节点的层叠样式表中设置了宽度值时,以宽度最大的所述子节点的宽度为所述节点的宽度。And a fifth execution subunit, configured to: when a width value is set in the cascading style sheet of the child node having the node, the width of the child node having the largest width is the width of the node.
  9. 如权利要求7所述的网页适应屏幕排版装置,其特征在于,所述第二执行单元包括:The webpage adaptation screen layout apparatus according to claim 7, wherein the second execution unit comprises:
    样式修改子单元,用于修改节点的样式;A style modification subunit for modifying the style of a node;
    适应屏幕规则排版子单元,用于对节点按适应屏幕规则排版。Adapt to the screen rule layout sub-unit, used to format the nodes according to the rules of the screen.
  10. 如权利要求9所述的网页适应屏幕排版装置,其特征在于,所述修改样式子单元包括:The webpage adaptation screen layout apparatus according to claim 9, wherein the modification style subunit comprises:
    宽度修改子单元,用于修改节点的层叠样式表的宽度值和最大宽度值,使所述层叠样式表的宽度值和最大宽度值小于屏幕宽度;a width modification sub-unit, configured to modify a width value and a maximum width value of the cascading style sheet of the node, so that the width value and the maximum width value of the cascading style sheet are smaller than the screen width;
    边距修改子单元,修改节点中层叠样式表元素盒模型的填充属性和边距属性的分辨率,使所述填充属性和所述边距属性的分辨率分别小于或等于自身的预设值。The margin modification subunit modifies the resolution of the padding attribute and the margin attribute of the cascading style sheet element box model in the node, so that the resolution of the padding attribute and the margin attribute are respectively less than or equal to their preset values.
  11. 如权利要求10所述的网页适应屏幕排版装置,其特征在于,所述适应屏幕规则排版子单元,包括:The screen adaptation screen layout device according to claim 10, wherein the adaptation screen rule layout subunit comprises:
    高度排版子单元,用于以修改节点的样式后所述节点的元素内容的高度为所述节点的排版高度,按所述节点的排版高度进行排版;a high typesetting subunit, configured to modify a node's style, the height of the element content of the node is a layout height of the node, and typeset according to a layout height of the node;
    动态拉伸子单元,用于动态拉伸浮动元素,其中,所述浮动元素为排列在所述网页上的所述节点的显示内容。Dynamically stretching the subunits for dynamically stretching the floating elements, wherein the floating elements are display contents of the nodes arranged on the webpage.
  12. 如权利要求11所述的网页适应屏幕排版装置,其特征在于,所述动态拉伸子单元,包括: The webpage adaptation screen layout apparatus according to claim 11, wherein the dynamic stretching subunit comprises:
    第三判断子单元,用于判断当一行在进行排版n个所述浮动元素后,所述行的右方是否存在空白区域,其中,所述n为按标准流程排版时,所述行中排版的所述浮动元素的个数;a third determining subunit, configured to determine whether there is a blank area on the right side of the line after the row is n types of the floating elements, wherein the n is a typesetting in a standard process, and the line is typeset The number of said floating elements;
    第六执行子单元,用于当所述行的右方存在所述空白区域时,将所述浮动元素的宽度值设置为所述浮动元素的最小宽度值。And a sixth execution subunit, configured to set a width value of the floating element to a minimum width value of the floating element when the blank area exists on a right side of the row.
  13. 如权利要求12所述的网页适应屏幕排版装置,其特征在于,所述动态拉伸子单元,还包括:The webpage adaptation screen layout apparatus according to claim 12, wherein the dynamic stretching subunit further comprises:
    第四判断子单元,用于当所述行的右方存在所述空白区域时,将所述浮动元素的宽度值设置为所述浮动元素的最小宽度值后,判断所述行的右方的所述空白区域是否大于一个或多个所述浮动元素的宽度;a fourth determining subunit, configured to: when the blank area exists on the right side of the row, set a width value of the floating element to a minimum width value of the floating element, and determine a right side of the row Whether the blank area is greater than a width of one or more of the floating elements;
    第七执行子单元,用于当所述行的右方的所述空白区域大于一个或多个所述浮动元素的宽度时,在所述行的右方的所述空白区域中加入一个或多个所述浮动元素。a seventh execution subunit, configured to add one or more of the blank area to the right of the row when the blank area to the right of the row is greater than the width of one or more of the floating elements The floating elements.
  14. 一种网页适应屏幕排版装置,其特征在于,包括处理器,所述处理器用于执行以下程序单元:A webpage adaptation screen layout apparatus, comprising: a processor, wherein the processor is configured to execute the following program unit:
    计算单元,用于计算网页排版树中各个节点的宽度;a calculation unit, configured to calculate a width of each node in the webpage layout tree;
    第一判断单元,用于判断各个节点的宽度是否小于或等于屏幕宽度;a first determining unit, configured to determine whether a width of each node is less than or equal to a screen width;
    第一执行单元,用于当节点的宽度小于或等于屏幕宽度时,保留所述节点的原样式,并对所述节点按标准流程排版;a first execution unit, configured to reserve an original style of the node when the width of the node is less than or equal to a screen width, and typeset the node according to a standard process;
    第二执行单元,用于当节点的宽度大于屏幕宽度时,修改所述节点的样式,并对所述节点按适应屏幕规则排版。a second execution unit, configured to modify a style of the node when the width of the node is greater than a width of the screen, and format the node according to an adaptive screen rule.
  15. 一种具有处理器可执行的程序代码的计算机可读介质,其特征在于,在被执行时,所述程序代码使得处理器执行下述步骤:A computer readable medium having processor-executable program code, wherein, when executed, the program code causes a processor to perform the steps of:
    计算网页排版树中各个节点的宽度;Calculating the width of each node in the web page layout tree;
    判断各个节点的宽度是否小于或等于屏幕宽度;以及Determine whether the width of each node is less than or equal to the screen width;
    如果节点的宽度小于或等于屏幕宽度,则保留所述节点的原样式,并对所述节点按标准流程排版,否则,修改所述节点的样式,并对所述节点按适应屏幕规则排版。 If the width of the node is less than or equal to the screen width, the original style of the node is retained, and the node is typeset according to a standard flow; otherwise, the style of the node is modified, and the node is typeset according to the adaptive screen rules.
PCT/CN2015/072948 2014-06-25 2015-02-12 Method and device for adapting webpage to screen layout WO2015196822A1 (en)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN201410290310.1A CN105224564B (en) 2014-06-25 2014-06-25 A kind of webpage adapts to screen composition method and device
CN201410290310.1 2014-06-25

Publications (1)

Publication Number Publication Date
WO2015196822A1 true WO2015196822A1 (en) 2015-12-30

Family

ID=54936710

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2015/072948 WO2015196822A1 (en) 2014-06-25 2015-02-12 Method and device for adapting webpage to screen layout

Country Status (2)

Country Link
CN (1) CN105224564B (en)
WO (1) WO2015196822A1 (en)

Cited By (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN107632970A (en) * 2017-09-29 2018-01-26 彩讯科技股份有限公司 A kind of Mail Contents code-transferring method and device
CN108415703A (en) * 2018-02-08 2018-08-17 武汉斗鱼网络科技有限公司 A kind of quick interface arrangement method, device, electronic equipment and storage medium
CN108804102A (en) * 2018-05-24 2018-11-13 武汉斗鱼网络科技有限公司 Extended method and system, the server and storage medium of direct broadcasting room styles
CN108874371A (en) * 2018-05-24 2018-11-23 武汉斗鱼网络科技有限公司 Extended method and system, the server and storage medium of direct broadcasting room pattern
CN111581570A (en) * 2020-04-01 2020-08-25 车智互联(北京)科技有限公司 Page layout method and computing device
CN113553122A (en) * 2021-07-08 2021-10-26 北京奇艺世纪科技有限公司 Floating layer control method, device, equipment and computer readable medium

Families Citing this family (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN105718594A (en) * 2016-01-29 2016-06-29 四川长虹电器股份有限公司 Self-adaptive interface display method for intelligent terminal
CN106168978B (en) * 2016-07-25 2020-12-15 腾讯科技(深圳)有限公司 Method and device for processing popup in webpage
CN107562455B (en) * 2017-08-15 2019-11-05 武汉斗鱼网络科技有限公司 A kind of HTML list self-adaptive layout method and device
CN109782983B (en) * 2017-11-13 2021-05-25 腾讯科技(深圳)有限公司 View layout adjustment method and device for application program interface
CN111274772A (en) * 2018-12-03 2020-06-12 阿里巴巴集团控股有限公司 Method and device for deleting empty row, terminal equipment and computer storage medium
CN113778436A (en) * 2021-07-19 2021-12-10 福建野小兽健康科技有限公司 Page width adaptation method and device based on H5

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2004031994A1 (en) * 2002-09-30 2004-04-15 Embedded Internet Solutions, Inc. Methods for optimizing display and navigation of web contents on wireless devices
US20070157081A1 (en) * 2004-07-06 2007-07-05 Fujitsu Limited Browser with screen-reading function and browsing processing method
CN102663126A (en) * 2012-04-23 2012-09-12 奇智软件(北京)有限公司 Method and device for displaying webpage in mobile terminal
CN103412928A (en) * 2013-08-16 2013-11-27 北京乐动卓越科技有限公司 Method and device for realizing browser page intelligent response-type layout on mobile terminal
CN103605783A (en) * 2013-11-29 2014-02-26 优视科技有限公司 Webpage display method and device

Family Cites Families (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101833586A (en) * 2010-05-26 2010-09-15 卓望数码技术(深圳)有限公司 HTML (Hypertext Markup Language) small screen self-adaption typesetting method and typesetting server
CN102184249B (en) * 2011-05-23 2016-01-06 广州市动景计算机科技有限公司 Based on webpage layout method and the device of mobile terminal
CN102779167B (en) * 2012-06-21 2016-01-06 北京奇虎科技有限公司 The method and system of display web page in the terminal

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2004031994A1 (en) * 2002-09-30 2004-04-15 Embedded Internet Solutions, Inc. Methods for optimizing display and navigation of web contents on wireless devices
US20070157081A1 (en) * 2004-07-06 2007-07-05 Fujitsu Limited Browser with screen-reading function and browsing processing method
CN102663126A (en) * 2012-04-23 2012-09-12 奇智软件(北京)有限公司 Method and device for displaying webpage in mobile terminal
CN103412928A (en) * 2013-08-16 2013-11-27 北京乐动卓越科技有限公司 Method and device for realizing browser page intelligent response-type layout on mobile terminal
CN103605783A (en) * 2013-11-29 2014-02-26 优视科技有限公司 Webpage display method and device

Cited By (10)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN107632970A (en) * 2017-09-29 2018-01-26 彩讯科技股份有限公司 A kind of Mail Contents code-transferring method and device
CN108415703A (en) * 2018-02-08 2018-08-17 武汉斗鱼网络科技有限公司 A kind of quick interface arrangement method, device, electronic equipment and storage medium
CN108415703B (en) * 2018-02-08 2022-01-04 武汉斗鱼网络科技有限公司 Interface layout method and device, electronic equipment and storage medium
CN108804102A (en) * 2018-05-24 2018-11-13 武汉斗鱼网络科技有限公司 Extended method and system, the server and storage medium of direct broadcasting room styles
CN108874371A (en) * 2018-05-24 2018-11-23 武汉斗鱼网络科技有限公司 Extended method and system, the server and storage medium of direct broadcasting room pattern
CN108804102B (en) * 2018-05-24 2022-02-22 武汉斗鱼网络科技有限公司 Method and system for expanding interface style of live broadcast room, server and storage medium
CN108874371B (en) * 2018-05-24 2022-02-22 武汉斗鱼网络科技有限公司 Method and system for extending style of live broadcast room, server and storage medium
CN111581570A (en) * 2020-04-01 2020-08-25 车智互联(北京)科技有限公司 Page layout method and computing device
CN111581570B (en) * 2020-04-01 2023-05-30 车智互联(北京)科技有限公司 Page layout method and computing device
CN113553122A (en) * 2021-07-08 2021-10-26 北京奇艺世纪科技有限公司 Floating layer control method, device, equipment and computer readable medium

Also Published As

Publication number Publication date
CN105224564A (en) 2016-01-06
CN105224564B (en) 2019-02-15

Similar Documents

Publication Publication Date Title
WO2015196822A1 (en) Method and device for adapting webpage to screen layout
US10210144B2 (en) Creation and display of a webpage with alternative layouts for different webpage widths
CN105975576B (en) Terminal content adaptive display method and device and terminal
US10339209B2 (en) Webpage display method and device
US9311422B2 (en) Dynamic simulation of a responsive web page
US9460062B2 (en) Local rendering of an object as an image
Jiang et al. Responsive web design mode and application
CN109683978B (en) Stream type layout interface rendering method and device and electronic equipment
US9152619B2 (en) System and method for constructing markup language templates and input data structure specifications
CN104915186B (en) A kind of method and apparatus making the page
CN105094930A (en) Image positioning system and method
US9886465B2 (en) System and method for rendering of hierarchical data structures
JP2014524623A (en) Template file processing method and apparatus
US20140164911A1 (en) Preserving layout of region of content during modification
JP2014524623A5 (en)
US20160232151A1 (en) Responsive course design system and method
KR102574306B1 (en) dynamic typesetting
CN111694493B (en) Webpage screenshot method, computer equipment and readable storage medium
CN113655999A (en) Rendering method, device and equipment of page control and storage medium
CN110262749B (en) Webpage operation method, device, container, equipment and medium
CN106488298B (en) Method and device for drawing image in UI (user interface) and television
CN115659087B (en) Page rendering method, equipment and storage medium
CN111143749A (en) Webpage display method, device, equipment and storage medium
US11604849B2 (en) Rendering method, electronic device and storage medium
US20210073458A1 (en) Comic data display system, method, and program

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 15812638

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE

122 Ep: pct application non-entry in european phase

Ref document number: 15812638

Country of ref document: EP

Kind code of ref document: A1