public static LayoutBox LayoutTree(Style.StyledNode node, Dimensions containingBlock) { containingBlock.Content.Height = 0; var rootBox = BuildLayoutTree(node); rootBox.Layout(containingBlock); return(rootBox); }
private static LayoutBox BuildLayoutTree(Style.StyledNode styleNode) { var display = styleNode.GetDisplay(); BoxType boxType; switch (display) { case Style.Display.Block: boxType = new BlockNode(styleNode); break; case Style.Display.Inline: boxType = new InlineNode(styleNode); break; default: throw new LayoutException("Root node has display: none."); } var root = new LayoutBox(boxType); foreach (var child in styleNode.Children) { switch (child.GetDisplay()) { case Style.Display.Block: root.Children.Add(BuildLayoutTree(child)); break; case Style.Display.Inline: root.GetInlineContainer().Children.Add(BuildLayoutTree(child)); break; } } return(root); }
public BlockNode(Style.StyledNode styledNode) : base(styledNode) { }
public InlineNode(Style.StyledNode styledNode) : base(styledNode) { }
public BoxType(Style.StyledNode styledNode) { StyledNode = styledNode; }