if (aInlineContext && (0 == childsCarriedOutTopMargin) && (0 == childsCarriedOutBottomMargin)) {     aTopMarginResult = 0; aBottomMarginResult = 0;
if (childsCarriedOutTopMargin || childsCarriedOutBottomMargin) { result |= HAVE_CARRIED_MARGIN; }    nscoord collapsedTopMargin = nsInlineReflow::MaxMargin(childsCarriedOutBottomMargin, childsTopMargin);   collapsedTopMargin = nsInlineReflow::MaxMargin(aState.mPrevBottomMargin, collapsedTopMargin); PRBool topMarginIsAuto = PR_FALSE; if (NS_CARRIED_TOP_MARGIN_IS_AUTO & marginFlags) { if (aInlineContext) { topMarginIsAuto = collapsedTopMargin == childsCarriedOutTopMargin; } else { topMarginIsAuto = collapsedTopMargin == childsTopMargin; } }    nscoord collapsedBottomMargin = nsInlineReflow::MaxMargin(childsCarriedOutBottomMargin, childsBottomMargin); if (NS_CARRIED_BOTTOM_MARGIN_IS_AUTO & marginFlags) { if (aInlineContext) { if (collapsedBottomMargin == childsCarriedOutBottomMargin) { result |= NS_CARRIED_BOTTOM_MARGIN_IS_AUTO; } } else if (collapsedBottomMargin == childsBottomMargin) { result |= NS_CARRIED_BOTTOM_MARGIN_IS_AUTO; } }    if (0 == aLine->mBounds.height) {    collapsedBottomMargin = nsInlineReflow::MaxMargin(collapsedTopMargin, collapsedBottomMargin); collapsedTopMargin = 0;
nsBlockFrame::CalculateMargins(nsBlockReflowState& aState,                               LineData* aLine,                               PRBool aInlineContext,                               nscoord& aTopMarginResult,                               nscoord& aBottomMarginResult){  PRBool haveCarriedMargins = PR_FALSE;  nsInlineReflow& ir = *aState.mInlineReflow;  PRBool isFirstNonEmptyLine = (aState.mY == aState.mBorderPadding.top);  nscoord childsCarriedOutTopMargin = ir.GetCarriedOutTopMargin();  nscoord childsCarriedOutBottomMargin = ir.GetCarriedOutBottomMargin();  if (aInlineContext &&      (0 == childsCarriedOutTopMargin) &&      (0 == childsCarriedOutBottomMargin)) {    // In an inline context, when there are no carried out margins we    // do not collapse the childs margins with the carried out    // margins; the childs margins are applied in a different manner    // in inline contexts.    aTopMarginResult = 0;    aBottomMarginResult = 0;  }  else {    haveCarriedMargins = PR_TRUE;    // Compute the collapsed top margin value from the childs margin and    // its carried out top margin.    nscoord childsTopMargin = aInlineContext ? 0 : ir.GetTopMargin();    nscoord collapsedTopMargin =      nsInlineReflow::MaxMargin(childsCarriedOutBottomMargin, childsTopMargin);    if (isFirstNonEmptyLine) {      // If this block is a root for margins then we will apply the      // collapsed top margin value ourselves. Otherwise, we pass it out      // to our parent to apply.      if (!aState.mIsMarginRoot) {        // We are not a root for margin collapsing and this is our first        // non-empty-line (with a block child presumably). Keep the        // collapsed margin value around to pass out to our parent. We        // don't apply the margin (our parent will) so zero it out.        aState.mCollapsedTopMargin = collapsedTopMargin;        collapsedTopMargin = 0;      }    }    else {      // For secondary lines we also collpase the sibling margins. The      // previous lines bottom margin is collapsed with the current      // lines collapsed top margin.      collapsedTopMargin = nsInlineReflow::MaxMargin(aState.mPrevBottomMargin,                                                     collapsedTopMargin);    }    aTopMarginResult = collapsedTopMargin;    // Compute the collapsed bottom margin value. This collapsed value    // will end up in aState.mPrevBottomMargin if the child frame ends    // up being placed in this block frame.    nscoord childsBottomMargin = aInlineContext ? 0 : ir.GetBottomMargin();    nscoord collapsedBottomMargin =      nsInlineReflow::MaxMargin(childsCarriedOutBottomMargin,                                childsBottomMargin);    aBottomMarginResult = collapsedBottomMargin;  }//ListTag(stdout); printf(": line=%p topMargin=%d bottomMargin=%d [%s,%s]\n", aLine, aTopMarginResult, aBottomMarginResult, isFirstNonEmptyLine ? "first" : "!first", aState.mIsMarginRoot ? "root" : "!root");  return haveCarriedMargins;}