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++; }
//-----------------------
}