public TElement(IElement htmlElement, TElement parent) { NormalFlowChildren = new List <TElement>(); FloatFlowChildren = new List <TElement>(); AbsoluteFlowChildren = new List <TElement>(); DefaultBackgroundColor = new Color(255, 255, 255, 255); DefaultBorderColor = new Color(0, 0, 0, 255); DefaultForegroundColor = new Color(0, 0, 0, 255); Parent = parent; Children = new List <TElement>(); Canvas = GfxFactory.Create <IGfxCanvas>(); InitHtml(htmlElement); InitCss(htmlElement); ComputeBoundingBox(); var elementFactory = new TElementFactory(); foreach (IElement htmlChild in htmlElement.Children) { var child = elementFactory.Create(htmlChild, this); Children.Add(child); ComputeBoundingBox(child); AddToFlowList(child); } }
public void Parse(string html) { var config = new Configuration().WithCss(); var parser = new HtmlParser(config ?? Configuration.Default); var document = parser.Parse(html); var factory = new TElementFactory(); Body = factory.Create(document.Body, null); }
public void Parse(AngleSharp.Dom.IElement htmlElement) { InitHtml(htmlElement); InitCss(htmlElement); ComputeBoundingBox(); var elementFactory = new TElementFactory(); foreach (AngleSharp.Dom.IElement htmlChild in htmlElement.Children) { var element = elementFactory.Create(htmlChild); element.Parent = this; element.Parse(htmlChild); Children.Add(element); ComputeBoundingBox(element); AddToFlowList(element); } }