public virtual MarginsCollapseInfo StartChildMarginsHandling(IRenderer child, Rectangle layoutBox) { if (backupLayoutBox != null) { // this should happen only if previous kid was floated RestoreLayoutBoxAfterFailedLayoutAttempt(layoutBox); RemoveRendererChild(--processedChildrenNum); childMarginInfo = null; } rendererChildren.Add(child); int childIndex = processedChildrenNum++; // If renderer is floated, prepare layout box as if it was inline, // however it will be restored from backup when next kid processing will start. bool childIsBlockElement = !RendererIsFloated(child) && IsBlockElement(child); backupLayoutBox = layoutBox.Clone(); backupCollapseInfo = new MarginsCollapseInfo(); collapseInfo.CopyTo(backupCollapseInfo); PrepareBoxForLayoutAttempt(layoutBox, childIndex, childIsBlockElement); if (childIsBlockElement) { childMarginInfo = CreateMarginsInfoForBlockChild(childIndex); } return(this.childMarginInfo); }
private void RestoreLayoutBoxAfterFailedLayoutAttempt(Rectangle layoutBox) { layoutBox.SetX(backupLayoutBox.GetX()).SetY(backupLayoutBox.GetY()).SetWidth(backupLayoutBox.GetWidth()).SetHeight (backupLayoutBox.GetHeight()); backupCollapseInfo.CopyTo(collapseInfo); backupLayoutBox = null; backupCollapseInfo = null; }