Exemple #1
0
        public static LayoutBox LayoutTree(Style.StyledNode node, Dimensions containingBlock)
        {
            containingBlock.Content.Height = 0;
            var rootBox = BuildLayoutTree(node);

            rootBox.Layout(containingBlock);
            return(rootBox);
        }
Exemple #2
0
        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);
        }
Exemple #3
0
 public BlockNode(Style.StyledNode styledNode) : base(styledNode)
 {
 }
Exemple #4
0
 public InlineNode(Style.StyledNode styledNode) : base(styledNode)
 {
 }
Exemple #5
0
 public BoxType(Style.StyledNode styledNode)
 {
     StyledNode = styledNode;
 }