Class BoxBuilder
java.lang.Object
org.openpdf.layout.BoxBuilder
This class is responsible for creating the box tree from the DOM. This is
mostly just a one-to-one translation from the
Element to an
InlineBox or a BlockBox (or some subclass of
BlockBox), but the tree is reorganized according to the CSS rules.
This includes inserting anonymous block and inline boxes, anonymous table
content, and :before and :after content. White
space is also normalized at this point. Table columns and table column groups
are added to the table which owns them, but are not created as regular boxes.
Floated and absolutely positioned content is always treated as inline
content for purposes of inserting anonymous block boxes and calculating
the kind of content contained in a given block box.-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprivate static classstatic enum -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final intprivate static final intprivate static final org.slf4j.Logger -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate static voidaddColumnOrColumnGroup(LayoutContext c, TableBox table, Element e, CalculatedStyle style) private static voidaddColumns(LayoutContext c, TableBox table, TableColumn parent) private static booleancontainsOrphanedTableContent(List<Styleable> children) private static voidprivate static voidcreateAnonymousTableContent(LayoutContext c, BlockBox source, IdentValue next, List<Styleable> childrenForAnonymous, List<Styleable> childrenWithAnonymous) private static BlockBoxcreateBlockBox(Element source, CalculatedStyle style, BoxBuilder.ChildBoxInfo info, boolean generated, boolean anonymous) static voidcreateChildren(LayoutContext c, BlockBox parent) private static voidcreateChildren(LayoutContext c, BlockBox blockParent, Element parent, List<Styleable> children, BoxBuilder.ChildBoxInfo info, boolean inline) createGeneratedContent(LayoutContext c, Element element, String peName, CalculatedStyle style, PropertyValue property, BoxBuilder.ChildBoxInfo info) createGeneratedContentList(LayoutContext c, Element element, PropertyValue propValue, @Nullable String peName, CalculatedStyle style, int mode, @Nullable BoxBuilder.ChildBoxInfo info) createGeneratedMarginBoxContent(LayoutContext c, Element element, PropertyValue property, CalculatedStyle style, BoxBuilder.ChildBoxInfo info) private static InlineBoxcreateInlineBox(String text, Element parent, CalculatedStyle parentStyle, @Nullable Text node) private static @Nullable TableCellBoxcreateMarginBox(LayoutContext c, CascadedStyle cascadedStyle, boolean alwaysCreate) static @Nullable TableBoxcreateMarginTable(LayoutContext c, PageInfo pageInfo, MarginBoxName[] names, int height, BoxBuilder.MarginDirection direction) static BlockBoxcreateRootBox(LayoutContext c, Document document) private static StringgetAttributeValue(FSFunction attrFunc, Element e) private static @Nullable IdentValuegetNextTableNestingLevel(IdentValue display) private static @Nullable IdentValuegetPreviousTableNestingLevel(IdentValue display) static @Nullable BlockBoxgetRunningBlock(LayoutContext c, PropertyValue value) private static voidinsertAnonymousBlocks(Box parent, List<Styleable> children, boolean layoutRunningBlocks) private static voidinsertGeneratedContent(LayoutContext c, Element element, CalculatedStyle parentStyle, String peName, List<Styleable> children, BoxBuilder.ChildBoxInfo info) private static booleanisAllProperTableNesting(IdentValue parentDisplay, List<Styleable> children) private static booleanisAttrFunction(FSFunction function) static booleanisElementFunction(FSFunction function) private static booleanisNestingTableContent(IdentValue display) private static booleanisParentInline(BlockBox box) private static booleanisProperTableNesting(IdentValue parent, IdentValue child) private static BoxBuilder.ChildBoxInfolookForBlockContent(List<Styleable> styleables) private static @Nullable CounterFunctionmakeCounterFunction(FSFunction function, LayoutContext c, CalculatedStyle style) private static booleanmatchesTableLevel(IdentValue target, IdentValue value) private static @Nullable IntegerparseAttribute(Node node, String attributeName) private static @Nullable IntegerparseStartIndex(Node node) private static voidrebalanceInlineContent(List<Styleable> content) Makes sure that anyInlineBoxincontentboth starts and ends withincontent.private static BlockBoxreorderTableContent(LayoutContext c, TableBox table) Reorganizes a table so that the header is the first row group and the footer the last.private static voidresolveChildren(BlockBox owner, List<Styleable> children, BoxBuilder.ChildBoxInfo info) private static voidresolveChildTableContent(LayoutContext c, BlockBox parent, List<Styleable> children, BoxBuilder.ChildBoxInfo info, IdentValue target) Handles the situation when we find table content, but our parent is not table related.private static voidresolveTableContent(LayoutContext c, BlockBox parent, List<Styleable> children, BoxBuilder.ChildBoxInfo info) Handles the situation when our current parent is table related.private static voidstripAllWhitespace(List<Styleable> content)
-
Field Details
-
log
private static final org.slf4j.Logger log -
CONTENT_LIST_DOCUMENT
private static final int CONTENT_LIST_DOCUMENT- See Also:
-
CONTENT_LIST_MARGIN_BOX
private static final int CONTENT_LIST_MARGIN_BOX- See Also:
-
-
Constructor Details
-
BoxBuilder
public BoxBuilder()
-
-
Method Details
-
createRootBox
-
createChildren
-
createMarginTable
public static @Nullable TableBox createMarginTable(LayoutContext c, PageInfo pageInfo, MarginBoxName[] names, int height, BoxBuilder.MarginDirection direction) -
createMarginBox
private static @Nullable TableCellBox createMarginBox(LayoutContext c, CascadedStyle cascadedStyle, boolean alwaysCreate) -
resolveChildren
private static void resolveChildren(BlockBox owner, List<Styleable> children, BoxBuilder.ChildBoxInfo info) -
isAllProperTableNesting
-
resolveChildTableContent
private static void resolveChildTableContent(LayoutContext c, BlockBox parent, List<Styleable> children, BoxBuilder.ChildBoxInfo info, IdentValue target) Handles the situation when we find table content, but our parent is not table related. For example,div->td</td>. Anonymous tables are then constructed by repeatedly pulling together consecutive same-table-level siblings and wrapping them in the next highest table level (e.g. consecutivetdelements will be wrapped in an anonymoustr, then atbody, and finally atable). -
matchesTableLevel
-
rebalanceInlineContent
-
stripAllWhitespace
-
resolveTableContent
private static void resolveTableContent(LayoutContext c, BlockBox parent, List<Styleable> children, BoxBuilder.ChildBoxInfo info) Handles the situation when our current parent is table related. If everything is properly nested (e.g. atrcontains onlytdelements), nothing is done. Otherwise, anonymous boxes are inserted to ensure the integrity of the table model. -
containsOrphanedTableContent
-
isParentInline
-
createAnonymousTableContent
private static void createAnonymousTableContent(LayoutContext c, BlockBox source, IdentValue next, List<Styleable> childrenForAnonymous, List<Styleable> childrenWithAnonymous) -
reorderTableContent
Reorganizes a table so that the header is the first row group and the footer the last. If the table has caption boxes, they will be pulled out and added to an anonymous block box along with the table itself. If not, the table is returned. -
lookForBlockContent
-
getNextTableNestingLevel
-
getPreviousTableNestingLevel
-
isProperTableNesting
-
isNestingTableContent
-
isAttrFunction
-
isElementFunction
-
makeCounterFunction
private static @Nullable CounterFunction makeCounterFunction(FSFunction function, LayoutContext c, CalculatedStyle style) -
getAttributeValue
-
createGeneratedContentList
@CheckReturnValue private static List<Styleable> createGeneratedContentList(LayoutContext c, Element element, PropertyValue propValue, @Nullable String peName, CalculatedStyle style, int mode, @Nullable BoxBuilder.ChildBoxInfo info) -
getRunningBlock
@CheckReturnValue public static @Nullable BlockBox getRunningBlock(LayoutContext c, PropertyValue value) -
insertGeneratedContent
private static void insertGeneratedContent(LayoutContext c, Element element, CalculatedStyle parentStyle, String peName, List<Styleable> children, BoxBuilder.ChildBoxInfo info) -
createGeneratedContent
private static List<Styleable> createGeneratedContent(LayoutContext c, Element element, String peName, CalculatedStyle style, PropertyValue property, BoxBuilder.ChildBoxInfo info) -
createGeneratedMarginBoxContent
private static List<Styleable> createGeneratedMarginBoxContent(LayoutContext c, Element element, PropertyValue property, CalculatedStyle style, BoxBuilder.ChildBoxInfo info) -
createBlockBox
private static BlockBox createBlockBox(Element source, CalculatedStyle style, BoxBuilder.ChildBoxInfo info, boolean generated, boolean anonymous) -
addColumns
-
addColumnOrColumnGroup
private static void addColumnOrColumnGroup(LayoutContext c, TableBox table, Element e, CalculatedStyle style) -
createInlineBox
private static InlineBox createInlineBox(String text, Element parent, CalculatedStyle parentStyle, @Nullable Text node) -
createChildren
private static void createChildren(LayoutContext c, BlockBox blockParent, Element parent, List<Styleable> children, BoxBuilder.ChildBoxInfo info, boolean inline) -
parseStartIndex
-
parseAttribute
-
insertAnonymousBlocks
-
createAnonymousBlock
-