if (eStyleUnit_Inherit == heightUnit) { mComputedHeight = containingBlockHeight; } else if (eStyleUnit_Auto == heightUnit) { mComputedHeight = NS_AUTOHEIGHT; } else { ComputeVerticalValue(containingBlockHeight, heightUnit, mStylePosition->mHeight, mComputedHeight); }   mComputedMinWidth = mComputedMinHeight = 0; mComputedMaxWidth = mComputedMaxHeight = NS_UNCONSTRAINEDSIZE;  } else if (NS_FRAME_GET_TYPE(mFrameType) == NS_CSS_FRAME_TYPE_ABSOLUTE) {   nsIAtom* targetFrameType; frame->GetFrameType(&targetFrameType); if (nsLayoutAtoms::htmlFrameInnerFrame != targetFrameType) { InitAbsoluteConstraints(aPresContext, cbrs, containingBlockWidth, containingBlockHeight); } NS_IF_RELEASE(targetFrameType); } else if (NS_CSS_FRAME_TYPE_INLINE == mFrameType) {   mComputedWidth = NS_UNCONSTRAINEDSIZE; mComputedHeight = NS_UNCONSTRAINEDSIZE; mComputedMargin.top = 0; mComputedMargin.bottom = 0; mComputedMinWidth = mComputedMinHeight = 0; mComputedMaxWidth = mComputedMaxHeight = NS_UNCONSTRAINEDSIZE;
if (eStyleUnit_Auto == heightUnit) { computedHeight = NS_AUTOHEIGHT; } else { ComputeVerticalValue(containingBlockHeight, heightUnit, pos->mHeight, computedHeight); }  } else if (NS_FRAME_GET_TYPE(frameType) == NS_CSS_FRAME_TYPE_ABSOLUTE) { InitAbsoluteConstraints(aPresContext, cbrs, pos, containingBlockWidth, containingBlockHeight);
nsHTMLReflowState::InitConstraints(nsIPresContext& aPresContext){  // If this is the root frame, then set the computed width and  // height equal to the available space  if (nsnull == parentReflowState) {    mComputedWidth = availableWidth;    mComputedHeight = availableHeight;    mComputedMargin.SizeTo(0, 0, 0, 0);    mComputedPadding.SizeTo(0, 0, 0, 0);    mComputedBorderPadding.SizeTo(0, 0, 0, 0);    mComputedOffsets.SizeTo(0, 0, 0, 0);    mComputedMinWidth = mComputedMinHeight = 0;    mComputedMaxWidth = mComputedMaxHeight = NS_UNCONSTRAINEDSIZE;  } else {    // Get the containing block reflow state    const nsHTMLReflowState* cbrs =      GetContainingBlockReflowState(parentReflowState);    NS_ASSERTION(nsnull != cbrs, "no containing block");    // Compute the containing block rectangle for the element    nscoord containingBlockWidth;    nscoord containingBlockHeight;    ComputeContainingBlockRectangle(cbrs, containingBlockWidth, containingBlockHeight);    // See if the element is relatively positioned    if (NS_STYLE_POSITION_RELATIVE == mStylePosition->mPosition) {      ComputeRelativeOffsets(cbrs, containingBlockWidth, containingBlockHeight);    } else {      // Initialize offsets to 0      mComputedOffsets.SizeTo(0, 0, 0, 0);    }#if 0    nsFrame::ListTag(stdout, frame); printf(": cb=");    nsFrame::ListTag(stdout, cbrs->frame); printf(" size=%d,%d\n", containingBlockWidth, containingBlockHeight);#endif    // See if the containing block height is based on the size of the    // content    if (NS_AUTOHEIGHT == containingBlockHeight) {      // See if the containing block is a scrolled frame, i.e. its      // parent is a scroll frame. The prescence of the interveening      // frame (that the scroll frame scrolls) needs to be hidden from      // the containingBlockHeight calcuation.      if (cbrs->parentReflowState) {        nsIFrame* f = cbrs->parentReflowState->frame;        nsIAtom*  cbFrameType;        f->GetFrameType(&cbFrameType);        if (nsLayoutAtoms::scrollFrame == cbFrameType) {          // Use the scroll frame's computed height instead          containingBlockHeight =            ((nsHTMLReflowState*)cbrs->parentReflowState)->mComputedHeight;        }        NS_IF_RELEASE(cbFrameType);      }    }    // Compute margins from the specified margin style information. These    // become the default computed values, and may be adjusted below    // XXX fix to provide 0,0 for the top&bottom margins for    // inline-non-replaced elements    ComputeMargin(containingBlockWidth, cbrs);    ComputePadding(containingBlockWidth, cbrs);    if (!mStyleSpacing->GetBorder(mComputedBorderPadding)) {      // CSS2 has no percentage borders      mComputedBorderPadding.SizeTo(0, 0, 0, 0);    }    mComputedBorderPadding += mComputedPadding;    nsStyleUnit widthUnit = mStylePosition->mWidth.GetUnit();    nsStyleUnit heightUnit = mStylePosition->mHeight.GetUnit();    // Check for a percentage based width and an unconstrained containing    // block width    if (eStyleUnit_Percent == widthUnit) {      if (NS_UNCONSTRAINEDSIZE == containingBlockWidth) {        // Interpret the width like 'auto'        widthUnit = eStyleUnit_Auto;      }    }    // Check for a percentage based height and a containing block height    // that depends on the content height    if (eStyleUnit_Percent == heightUnit) {      if (NS_AUTOHEIGHT == containingBlockHeight) {        // Interpret the height like 'auto'        heightUnit = eStyleUnit_Auto;      }    }    // Calculate the computed values for min and max properties    ComputeMinMaxValues(containingBlockWidth, containingBlockHeight, cbrs);    // Calculate the computed width and height. This varies by frame type    if ((NS_FRAME_REPLACED(NS_CSS_FRAME_TYPE_INLINE) == mFrameType) ||        (NS_FRAME_REPLACED(NS_CSS_FRAME_TYPE_FLOATING) == mFrameType)) {      // Inline replaced element and floating replaced element are basically      // treated the same. First calculate the computed width      if (eStyleUnit_Inherit == widthUnit) {        mComputedWidth = containingBlockWidth;      } else if (eStyleUnit_Auto == widthUnit) {        // A specified value of 'auto' uses the element's intrinsic width        mComputedWidth = NS_INTRINSICSIZE;      } else {        ComputeHorizontalValue(containingBlockWidth, widthUnit,                               mStylePosition->mWidth,                               mComputedWidth);      }      if (mComputedWidth > mComputedMaxWidth) {        mComputedWidth = mComputedMaxWidth;      } else if (mComputedWidth < mComputedMinWidth) {        mComputedWidth = mComputedMinWidth;      }      // Now calculate the computed height      if (eStyleUnit_Inherit == heightUnit) {        mComputedHeight = containingBlockHeight;      } else if (eStyleUnit_Auto == heightUnit) {        // A specified value of 'auto' uses the element's intrinsic height        mComputedHeight = NS_INTRINSICSIZE;      } else {        ComputeVerticalValue(containingBlockHeight, heightUnit,                             mStylePosition->mHeight,                             mComputedHeight);      }      if (mComputedHeight > mComputedMaxHeight) {        mComputedHeight = mComputedMaxHeight;      } else if (mComputedHeight < mComputedMinHeight) {        mComputedHeight = mComputedMinHeight;      }        } else if (NS_CSS_FRAME_TYPE_FLOATING == mFrameType) {      // Floating non-replaced element. First calculate the computed width      if (eStyleUnit_Inherit == widthUnit) {        mComputedWidth = containingBlockWidth;      } else if (eStyleUnit_Auto == widthUnit) {        // A specified value of 'auto' becomes a computed width of 0        mComputedWidth = 0;      } else {        ComputeHorizontalValue(containingBlockWidth, widthUnit,                               mStylePosition->mWidth,                               mComputedWidth);      }      if (mComputedWidth > mComputedMaxWidth) {        mComputedWidth = mComputedMaxWidth;      } else if (mComputedWidth < mComputedMinWidth) {        mComputedWidth = mComputedMinWidth;      }      // Now calculate the computed height      if (eStyleUnit_Inherit == heightUnit) {        mComputedHeight = containingBlockHeight;      } else if (eStyleUnit_Auto == heightUnit) {        mComputedHeight = NS_AUTOHEIGHT;  // let it choose its height      } else {        ComputeVerticalValue(containingBlockHeight, heightUnit,                             mStylePosition->mHeight,                             mComputedHeight);      }      if (mComputedHeight > mComputedMaxHeight) {        mComputedHeight = mComputedMaxHeight;      } else if (mComputedHeight < mComputedMinHeight) {        mComputedHeight = mComputedMinHeight;      }        } else if (NS_CSS_FRAME_TYPE_INTERNAL_TABLE == mFrameType) {      // Internal table elements. The rules vary depending on the type.      // Calculate the computed width      if ((NS_STYLE_DISPLAY_TABLE_ROW == mStyleDisplay->mDisplay) ||          (NS_STYLE_DISPLAY_TABLE_ROW_GROUP == mStyleDisplay->mDisplay)) {        // 'width' property doesn't apply to table rows and row groups        widthUnit = eStyleUnit_Auto;      }      if (eStyleUnit_Inherit == widthUnit) {        mComputedWidth = containingBlockWidth;      } else if (eStyleUnit_Auto == widthUnit) {        mComputedWidth = availableWidth;        if (mComputedWidth != NS_UNCONSTRAINEDSIZE) {          // Internal table elements don't have margins, but they have border          // and padding          mComputedWidth -= mComputedBorderPadding.left +            mComputedBorderPadding.right;        }            } else {        ComputeHorizontalValue(containingBlockWidth, widthUnit,                               mStylePosition->mWidth,                               mComputedWidth);      }      // Calculate the computed height      if ((NS_STYLE_DISPLAY_TABLE_COLUMN == mStyleDisplay->mDisplay) ||          (NS_STYLE_DISPLAY_TABLE_COLUMN_GROUP == mStyleDisplay->mDisplay)) {        // 'height' property doesn't apply to table columns and column groups        heightUnit = eStyleUnit_Auto;      }      if (eStyleUnit_Inherit == heightUnit) {        mComputedHeight = containingBlockHeight;      } else if (eStyleUnit_Auto == heightUnit) {        mComputedHeight = NS_AUTOHEIGHT;      } else {        ComputeVerticalValue(containingBlockHeight, heightUnit,                             mStylePosition->mHeight,                             mComputedHeight);      }      // Doesn't apply to table elements      mComputedMinWidth = mComputedMinHeight = 0;      mComputedMaxWidth = mComputedMaxHeight = NS_UNCONSTRAINEDSIZE;    } else if (NS_FRAME_GET_TYPE(mFrameType) == NS_CSS_FRAME_TYPE_ABSOLUTE) {      // XXX not sure if this belongs here or somewhere else - cwk      // an nsHTMLFrameInnerFrame doesn't get a placeholder frame, the nsHTMLFrameOuterFrame does      nsIAtom* targetFrameType;      frame->GetFrameType(&targetFrameType);      if (nsLayoutAtoms::htmlFrameInnerFrame != targetFrameType) {        InitAbsoluteConstraints(aPresContext, cbrs, containingBlockWidth,                                containingBlockHeight);      }      NS_IF_RELEASE(targetFrameType);    } else if (NS_CSS_FRAME_TYPE_INLINE == mFrameType) {      // Inline non-replaced elements do not have computed widths or heights      // XXX add this check to HaveFixedContentHeight/Width too      mComputedWidth = NS_UNCONSTRAINEDSIZE;      mComputedHeight = NS_UNCONSTRAINEDSIZE;      mComputedMargin.top = 0;      mComputedMargin.bottom = 0;      mComputedMinWidth = mComputedMinHeight = 0;      mComputedMaxWidth = mComputedMaxHeight = NS_UNCONSTRAINEDSIZE;    } else {      ComputeBlockBoxData(aPresContext, cbrs, widthUnit, heightUnit,                          containingBlockWidth,                          containingBlockHeight);    }  }}