LayoutFarm.HtmlBoxes.RunListHelper.AddRunList C# (CSharp) Method

AddRunList() public static method

public static AddRunList ( CssBox toBox, BoxSpec spec, HtmlTextNode textnode ) : void
toBox CssBox
spec LayoutFarm.Css.BoxSpec
textnode LayoutFarm.Composers.HtmlTextNode
return void
        public static void AddRunList(CssBox toBox, BoxSpec spec, HtmlTextNode textnode)
        {
            AddRunList(toBox, spec, textnode.InternalGetRuns(), textnode.GetOriginalBuffer(), textnode.IsWhiteSpace);
        }
        //---------------------------------------------------------------------------------------

Same methods

RunListHelper::AddRunList ( CssBox toBox, BoxSpec spec, List runlist, char buffer, bool isAllWhitespace ) : void

Usage Example

Example #1
0
        /// update some or generate all cssbox
        /// </summary>
        /// <param name="parentElement"></param>
        /// <param name="fullmode">update all nodes (true) or somenode (false)</param>
        internal void UpdateChildBoxes(HtmlElement parentElement, bool fullmode)
        {
            //recursive ***
            //first just generate into primary pricipal box
            //layout process  will correct it later

            switch (parentElement.ChildrenCount)
            {
            case 0: { } break;

            case 1:
            {
                CssBox hostBox = HtmlElement.InternalGetPrincipalBox(parentElement);
                //only one child -- easy
                DomNode child  = parentElement.GetChildNode(0);
                int     newBox = 0;
                switch (child.NodeType)
                {
                case HtmlNodeType.TextNode:
                {
                    HtmlTextNode singleTextNode = (HtmlTextNode)child;
                    RunListHelper.AddRunList(hostBox, parentElement.Spec, singleTextNode);
                }
                break;

                case HtmlNodeType.ShortElement:
                case HtmlNodeType.OpenElement:
                {
                    HtmlElement childElement = (HtmlElement)child;
                    var         spec         = childElement.Spec;
                    if (spec.CssDisplay == CssDisplay.None)
                    {
                        return;
                    }

                    newBox++;
                    //--------------------------------------------------
                    if (fullmode)
                    {
                        CssBox newbox = CreateBox(hostBox, childElement, fullmode);
                        childElement.SetPrincipalBox(newbox);
                    }
                    else
                    {
                        CssBox existing = HtmlElement.InternalGetPrincipalBox(childElement);
                        if (existing == null)
                        {
                            CssBox box = CreateBox(hostBox, childElement, fullmode);
                            childElement.SetPrincipalBox(box);
                        }
                        else
                        {
                            //just insert
                            hostBox.AppendChild(existing);
                            if (!childElement.SkipPrincipalBoxEvalulation)
                            {
                                existing.Clear();
                                UpdateChildBoxes(childElement, fullmode);
                                childElement.SkipPrincipalBoxEvalulation = true;
                            }
                        }
                    }
                }
                break;
                }
            }
            break;

            default:
            {
                CssBox        hostBox    = HtmlElement.InternalGetPrincipalBox(parentElement);
                CssWhiteSpace ws         = parentElement.Spec.WhiteSpace;
                int           childCount = parentElement.ChildrenCount;
                int           newBox     = 0;
                for (int i = 0; i < childCount; ++i)
                {
                    var childNode = parentElement.GetChildNode(i);
                    switch (childNode.NodeType)
                    {
                    case HtmlNodeType.TextNode:
                    {
                        HtmlTextNode textNode = (HtmlTextNode)childNode;
                        switch (ws)
                        {
                        case CssWhiteSpace.Pre:
                        case CssWhiteSpace.PreWrap:
                        {
                            RunListHelper.AddRunList(
                                CssBox.AddNewAnonInline(hostBox),
                                parentElement.Spec, textNode);
                        }
                        break;

                        case CssWhiteSpace.PreLine:
                        {
                            if (newBox == 0 && textNode.IsWhiteSpace)
                            {
                                continue;                        //skip
                            }

                            RunListHelper.AddRunList(
                                CssBox.AddNewAnonInline(hostBox),
                                parentElement.Spec, textNode);
                        }
                        break;

                        default:
                        {
                            if (textNode.IsWhiteSpace)
                            {
                                continue;                        //skip
                            }
                            RunListHelper.AddRunList(
                                CssBox.AddNewAnonInline(hostBox),
                                parentElement.Spec, textNode);
                        }
                        break;
                        }

                        newBox++;
                    }
                    break;

                    case HtmlNodeType.ShortElement:
                    case HtmlNodeType.OpenElement:
                    {
                        HtmlElement childElement = (HtmlElement)childNode;
                        var         spec         = childElement.Spec;
                        if (spec.CssDisplay == CssDisplay.None)
                        {
                            continue;
                        }

                        if (fullmode)
                        {
                            CssBox box = CreateBox(hostBox, childElement, fullmode);
                        }
                        else
                        {
                            CssBox existingCssBox = HtmlElement.InternalGetPrincipalBox(childElement);
                            if (existingCssBox == null)
                            {
                                CssBox box = CreateBox(hostBox, childElement, fullmode);
                            }
                            else
                            {
                                //just insert
                                hostBox.AppendChild(existingCssBox);
                                if (!childElement.SkipPrincipalBoxEvalulation)
                                {
                                    existingCssBox.Clear();
                                    UpdateChildBoxes(childElement, fullmode);
                                    childElement.SkipPrincipalBoxEvalulation = true;
                                }
                            }
                        }
                        newBox++;
                    }
                    break;

                    default:
                    {
                    }
                    break;
                    }
                }
            }
            break;
            }
            //----------------------------------
            //summary formatting context
            //that will be used on layout process
            //----------------------------------
        }
All Usage Examples Of LayoutFarm.HtmlBoxes.RunListHelper::AddRunList
RunListHelper