internal void UpdateTextNode(HtmlElement parentElement, HtmlTextNode textnode, bool isblockContext) { var parentSpec = parentElement.Spec; char[] originalBuffer = textnode.GetOriginalBuffer(); List <CssRun> runlist = new List <CssRun>(); bool hasSomeCharacter; _contentTextSplitter.ParseWordContent(originalBuffer, parentSpec, isblockContext, runlist, out hasSomeCharacter); textnode.SetSplitParts(runlist, hasSomeCharacter); }
void PrepareStylesAndContentOfChildNodes( HtmlElement parentElement, TopDownActiveCssTemplate activeCssTemplate) { //recursive CssBox principalCssBox = parentElement.CurrentPrincipalBox; bool isblockContext = true;//default if (principalCssBox != null) { isblockContext = principalCssBox.IsBlock; } foreach (WebDom.DomNode node in parentElement.GetChildNodeIterForward()) { activeCssTemplate.EnterLevel(); switch (node.NodeKind) { case WebDom.HtmlNodeKind.OpenElement: case WebDom.HtmlNodeKind.ShortElement: { HtmlElement htmlElement = (HtmlElement)node; htmlElement.WellknownElementName = WellKnownDomNodeMap.EvaluateTagName(htmlElement.LocalName); switch (htmlElement.WellknownElementName) { case WellKnownDomNodeName.style: { //style element should have textnode child int j = htmlElement.ChildrenCount; for (int i = 0; i < j; ++i) { var ch = htmlElement.GetChildNode(i); switch (ch.NodeKind) { case HtmlNodeKind.TextNode: { HtmlTextNode textNode = (HtmlTextNode)htmlElement.GetChildNode(0); activeCssTemplate.LoadRawStyleElementContent(new string(textNode.GetOriginalBuffer())); //break i = j; } break; } } activeCssTemplate.ExitLevel(); continue; } case WellKnownDomNodeName.link: { //<link rel="stylesheet" DomAttribute relAttr; if (htmlElement.TryGetAttribute(WellknownName.Rel, out relAttr)) { //switch link type switch (relAttr.Value.ToLower()) { case "stylesheet": { //if found DomAttribute hrefAttr; if (htmlElement.TryGetAttribute(WellknownName.Href, out hrefAttr)) { string stylesheet = RaiseRequestStyleSheet(hrefAttr.Value); if (stylesheet != null) { activeCssTemplate.LoadRawStyleElementContent(stylesheet); } } } break; case "import": { //load data canbe sync or async DomAttribute hrefAttr; if (htmlElement.TryGetAttribute(WellknownName.Href, out hrefAttr)) { //import other html, reuseable html component //TODO: implement import request algo here } } break; } } activeCssTemplate.ExitLevel(); continue; } } //----------------------------- //apply style for this node ApplyStyleSheetForSingleHtmlElement(htmlElement, parentElement.Spec, activeCssTemplate); //----------------------------- //recursive PrepareStylesAndContentOfChildNodes(htmlElement, activeCssTemplate); //----------------------------- } break; case WebDom.HtmlNodeKind.TextNode: { UpdateTextNode(parentElement, (HtmlTextNode)node, isblockContext); } break; } activeCssTemplate.ExitLevel(); } }
public static void AddRunList(CssBox toBox, BoxSpec spec, HtmlTextNode textnode) { AddRunList(toBox, spec, textnode.InternalGetRuns(), textnode.GetOriginalBuffer(), textnode.IsWhiteSpace); }