PerformLayout() публичный Метод

Measures the bounds of box and children, recursively.
Performs layout of the DOM structure creating lines by set bounds restrictions.
public PerformLayout ( LayoutVisitor lay ) : void
lay LayoutVisitor
Результат void
Пример #1
0
 protected override void PerformContentLayout(LayoutVisitor lay)
 {
     base.PerformContentLayout(lay);
     if (_listItemBulletBox != null)
     {
         //layout list item
         var prevSibling = lay.LatestSiblingBox;
         lay.LatestSiblingBox = null;//reset
         _listItemBulletBox.PerformLayout(lay);
         lay.LatestSiblingBox = prevSibling;
         var fRun = _listItemBulletBox.FirstRun;
         _listItemBulletBox.FirstRun.SetSize(fRun.Width, fRun.Height);
         _listItemBulletBox.FirstRun.SetLocation(_listItemBulletBox.VisualWidth - 5, this.ActualPaddingTop);
     }
 }
Пример #2
0
        public void PerformLayout(LayoutVisitor lay)
        {
            if (this._rootBox == null)
            {
                return;
            }
            //-----------------------
            //reset
            _actualWidth = _actualHeight = 0;
            // if width is not restricted we set it to large value to get the actual later
            _rootBox.SetLocation(0, 0);
            _rootBox.SetVisualSize(this._maxWidth > 0 ? this._maxWidth : MAX_WIDTH, 0);
            CssBox.ValidateComputeValues(_rootBox);
            //-----------------------
            //LayoutVisitor layoutArgs = new LayoutVisitor(this.GraphicsPlatform, this);
            lay.PushContaingBlock(_rootBox);
            //-----------------------

            _rootBox.PerformLayout(lay);
            if (this._maxWidth <= 0.1)
            {
                // in case the width is not restricted we need to double layout, first will find the width so second can layout by it (center alignment)
                _rootBox.SetVisualWidth((int)Math.Ceiling(this._actualWidth));
                _actualWidth = _actualHeight = 0;
                _rootBox.PerformLayout(lay);
            }
            lay.PopContainingBlock();
            //-----------------------
            //TODO: review here again
            FloatingContextStack   floatStack    = lay.GetFloatingContextStack();
            List <FloatingContext> totalContexts = floatStack.GetTotalContexts();
            int j = totalContexts.Count;

            for (int i = 0; i < j; ++i)
            {
                FloatingContext floatingContext = totalContexts[i];
                int             floatBoxCount   = floatingContext.FloatBoxCount;
                if (floatBoxCount == 0)
                {
                    continue;
                }


                CssBox floatingOwner = floatingContext.Owner;
                float  rfx, rfy;
                floatingOwner.GetGlobalLocation(out rfx, out rfy);
                CssBox prevParent = null;
                //TODO: review here again
                float extraAdjustX = 0; //temp fixed
                for (int n = 0; n < floatBoxCount; ++n)
                {
                    float  bfx, bfy;
                    CssBox box = floatingContext.GetBox(n);
                    box.GetGlobalLocation(out bfx, out bfy);
                    //diff
                    float nx = bfx - rfx;
                    float ny = bfy - rfy;
                    if (prevParent != null && prevParent != box.ParentBox)
                    {
                        if (n > 0)
                        {
                            CssBox prevFloatChild = floatingContext.GetBox(n - 1);
                            //TODO: review here again
                            //temp fix
                            extraAdjustX = prevFloatChild.ActualMarginRight + box.ActualMarginLeft;
                            ny          += box.ActualMarginTop;
                        }
                    }
                    box.SetLocation(nx + extraAdjustX, ny);
                    prevParent = box.ParentBox;
                    floatingOwner.AppendToAbsoluteLayer(box);
                }
            }

            OnLayoutFinished();
            //-----------------------
            unchecked { layoutVersion++; }
            //-----------------------
        }