public void Load(EditableTextFlowLayer flowLayer)
 {
     this.flowLayer = flowLayer;
     this.feeder    = FlowFeeder.GetNewFlowFeeder();
     this.feeder.Load(flowLayer);
     if ((flowLayer.layerFlags & FLOWLAYER_HAS_MULTILINE) != 0)
     {
         Load((List <EditableTextLine>)flowLayer.lineCollection);
     }
     else
     {
         Load((EditableTextLine)flowLayer.lineCollection);
     }
 }
        static Size ReCalculateContentSizeHorizontalFlow(EditableTextFlowLayer layer)
        {
            if (layer.lineCollection == null)
            {
                return(Size.Empty);
            }

            FlowFeeder flowFeeder = FlowFeeder.GetNewFlowFeeder();

            flowFeeder.Load(layer);
            int         curX               = 0;
            int         curY               = 0;
            bool        lastestIsBlock     = false;
            int         maxHeightInRow     = 0;
            int         maxWidth           = 0;
            int         curY_fromTop       = 0;
            bool        isFirstRunOfLine   = true;
            int         childCount         = 0;
            EditableRun lastNotNullElement = null;

            while (flowFeeder.Read())
            {
                EditableRun currentRun = flowFeeder.CurrentRun;
                if (currentRun != null)
                {
#if DEBUG
                    vinv_dbug_BeginSetElementBound(currentRun);
#endif

                    lastNotNullElement = currentRun;
                    childCount++;
                    if (lastestIsBlock || currentRun.IsBlockElement)
                    {
                        curX = 0;
                        if (!isFirstRunOfLine)
                        {
                            if (maxWidth < curX)
                            {
                                maxWidth = curX;
                            }

                            curY           = curY_fromTop + maxHeightInRow;
                            curY_fromTop   = curY;
                            maxHeightInRow = 0;
                        }
                        lastestIsBlock = currentRun.IsBlockElement;
                        if (lastestIsBlock)
                        {
                        }
                        if (!currentRun.HasCalculatedSize)
                        {
                            EditableRun.InnerTextRunTopDownReCalculateContentSize(currentRun);
                        }
#if DEBUG
                        else
                        {
                            vinv_dbug_WriteInfo(dbugVisitorMessage.SKIP, currentRun);
                        }
#endif
                        int v_ds_height = currentRun.Height;
                        if (v_ds_height > maxHeightInRow)
                        {
                            maxHeightInRow = v_ds_height;
                        }
                        curX += currentRun.Width;
                        if (curX > maxWidth)
                        {
                            maxWidth = curX;
                        }
                        isFirstRunOfLine = false;
                    }
                    else
                    {
                        lastestIsBlock = currentRun.IsBlockElement;
                        if (!currentRun.HasCalculatedSize)
                        {
                            EditableRun.InnerTextRunTopDownReCalculateContentSize(currentRun);
                        }
#if DEBUG
                        else
                        {
                            vinv_dbug_WriteInfo(dbugVisitorMessage.SKIP, currentRun);
                        }
#endif
                        int v_ds_height = currentRun.Height;
                        if (v_ds_height > maxHeightInRow)
                        {
                            maxHeightInRow = v_ds_height;
                        }
                        curX += currentRun.Width;
                        if (curX > maxWidth)
                        {
                            maxWidth = curX;
                        }
                        isFirstRunOfLine = false;
                    }
#if DEBUG
                    vinv_dbug_EndSetElementBound(currentRun);
#endif
                }
                else
                {
                    if (flowFeeder.ReadState == 1)
                    {
                        curX           = 0;
                        curY           = curY_fromTop + maxHeightInRow;
                        curY_fromTop   = curY;
                        maxHeightInRow = 0;
                    }
                    else
                    {
                    }
                }
            }


            if (curX > maxWidth)
            {
                maxWidth = curX;
            }

            int finalHeight = curY_fromTop + maxHeightInRow;
            FlowFeeder.FreeFlowFeeder(flowFeeder);
            return(new Size(maxWidth, finalHeight));
        }