DomParser
Handle css DOM tree generation from raw html and stylesheet.
构造函数
方法
ApplyTableBorder(CssBox, string)
Cascades to the TD's the border spacified in the TABLE tag.
- table
- border
ApplyTablePadding(CssBox, string)
Cascades to the TD's the border spacified in the TABLE tag.
- table
- padding
AssignClassCssBlocks(CssBox, CssData)
Assigns the given css classes to the given css box checking if matching. Support multiple classes in single attribute separated by whitespace.
- box
- the css box to assign css to
- cssData
- the css data to use to get the matching css blocks
AssignCssBlock(CssBox, CssBlock)
Assigns the given css style block properties to the given css box.
- box
- the css box to assign css to
- block
- the css block to assign
AssignCssBlocks(CssBox, CssData, string)
Assigns the given css style blocks to the given css box checking if matching.
- box
- the css box to assign css to
- cssData
- the css data to use to get the matching css blocks
- className
- the class selector to search for css blocks
CascadeApplyStyles(CssBox, CssData)
Applies style to all boxes in the tree. If the html tag has style defined for each apply that style to the css box of the tag. If the html tag has "class" attribute and the class name has style defined apply that style on the tag css box. If the html tag has "style" attribute parse it and apply the parsed style on the tag css box.
- box
- the box to apply the style to
- cssData
- the style data for the html
CascadeParseStyles(CssBox, HtmlContainerInt, CssData, bool)
Read styles defined inside the dom structure in links and style elements. If the html tag is "style" tag parse it content and add to the css data for all future tags parsing. If the html tag is "link" that point to style data parse it content and add to the css data for all future tags parsing.
- box
- the box to parse style data in
- htmlContainer
- the html container to use for reference resolve
- cssData
- the style data to fill with found styles
- cssDataChanged
- check if the css data has been modified by the handled html not to change the base css data
CloneCssData(CssData, bool)
Clone css data if it has not already been cloned. Used to preserve the base css data used when changed by style inside html.
ContainsInlinesOnlyDeep(CssBox) : bool
Check if the given box contains only inline child boxes in all subtree.
- box
- the box to check
返回值: true - only inline child boxes, false - otherwise
ContainsVariantBoxes(CssBox) : bool
Check if the given box contains inline and block child boxes.
- box
- the box to check
返回值: true - has variant child boxes, false - otherwise
CorrectBlockInsideInline(CssBox)
Correct DOM tree if there is block boxes that are inside inline blocks. Need to rearrange the tree so block box will be only the child of other block box.
- box
- the current box to correct its sub-tree
CorrectBlockInsideInlineImp(CssBox) : CssBox
Rearrange the DOM of the box to have block box with boxes before the inner block box and after.
- box
- the box that has the problem
CorrectBlockSplitBadBox(CssBox, CssBox, CssBox)
Split bad box that has inline and block boxes into two parts, the left - before the block box and right - after the block box.
- parentBox
- the parent box that has the problem
- badBox
- the box to split into different boxes
- leftBlock
- the left block box that is created for the split
CorrectImgBoxes(CssBox)
Go over all image boxes and if its display style is set to block, put it inside another block but set the image to inline.
- box
- the current box to correct its sub-tree
CorrectInlineBoxesParent(CssBox)
Makes block boxes be among only block boxes and all inline boxes have block parent box. Inline boxes should live in a pool of Inline boxes only so they will define a single block. At the end of this process a block box will have only block siblings and inline box will have only inline siblings.
- box
- the current box to correct its sub-tree
CorrectLineBreaksBlocks(CssBox, bool)
Correct the DOM tree recursively by replacing "br" html boxes with anonymous blocks that respect br spec. If the "br" tag is after inline box then the anon block will have zero height only acting as newline, but if it is after block box then it will have min-height of the font size so it will create empty line.
- box
- the current box to correct its sub-tree
- followingBlock
- used to know if the br is following a box so it should create an empty line or not so it only move to a new line
CorrectTextBoxes(CssBox)
Go over all the text boxes (boxes that have some text that will be rendered) and remove all boxes that have only white-spaces but are not 'preformatted' so they do not effect the rendered html.
- box
- the current box to correct its sub-tree
GenerateCssTree(string, HtmlContainerInt, CssData) : CssBox
Generate css tree by parsing the given html and applying the given css style data on it.
- html
- the html to parse
- htmlContainer
- the html container to use for reference resolve
- cssData
- the css data to use
返回值: the root of the generated tree
IsBlockAssignableToBox(CssBox, CssBlock) : bool
Check if the given css block is assignable to the given css box. the block is assignable if it has no hierarchical selectors or if the hierarchy matches. Special handling for ":hover" pseudo-class.
- box
- the box to check assign to
- block
- the block to check assign of
返回值: true - the block is assignable to the box, false - otherwise
IsBlockAssignableToBoxWithSelector(CssBox, CssBlock) : bool
Check if the given css block is assignable to the given css box by validating the selector.
- box
- the box to check assign to
- block
- the block to check assign of
返回值: true - the block is assignable to the box, false - otherwise
IsStyleOnElementAllowed(CssBox, string, string) : bool
Check if the given style is allowed to be set on the given css box. Used to prevent invalid CssBoxes creation like table with inline display style.
- box
- the css box to assign css to
- key
- the style key to cehck
- value
- the style value to check
返回值: true - style allowed, false - not allowed
SetForAllCells(CssBox, ActionInt<CssBox>)
Execute action on all the "td" cells of the table. Handle if there is "theader" or "tbody" exists.
- table
- the table element
- action
- the action to execute
SetTextSelectionStyle(HtmlContainerInt, CssData)
Set the selected text style (selection text color and background color).
- htmlContainer
- cssData
- the style data
TranslateAttributes(HtmlTag, CssBox)
- tag
- box
字段
_cssParser : CssParser
Parser for CSS