CalcQuirkContainingBlockHeight(const nsHTMLReflowState& aReflowState)
CalcQuirkContainingBlockHeight(const nsHTMLReflowState& aReflowState, PRBool aRestrictToFirstLevel)
CalcQuirkContainingBlockHeight(const nsHTMLReflowState& aReflowState){  nsHTMLReflowState* firstBlockRS = nsnull; // a candidate for body frame  nsHTMLReflowState* firstAreaRS  = nsnull; // a candidate for html frame  nscoord result = 0;  const nsHTMLReflowState* rs = &aReflowState;  for (; rs; rs = (nsHTMLReflowState *)(rs->parentReflowState)) {     nsCOMPtr<nsIAtom> frameType;    rs->frame->GetFrameType(getter_AddRefs(frameType));    // if the ancestor is auto height then skip it and continue up if it     // is the first block/area frame and possibly the body/html    if (nsLayoutAtoms::blockFrame == frameType.get()) {      // special hack for bug 50695, skip form frames      nsIFrame* formFrame;      if (NS_OK == rs->frame->QueryInterface(NS_GET_IID(nsIFormManager), (void **)&formFrame)) {        continue;      }      firstBlockRS = (nsHTMLReflowState*)rs;      if (NS_AUTOHEIGHT == rs->mComputedHeight) {        continue;      }    }    else if (nsLayoutAtoms::areaFrame == frameType.get()) {      firstAreaRS = (nsHTMLReflowState*)rs;      if (NS_AUTOHEIGHT == rs->mComputedHeight) {        continue;      }    }    else if (nsLayoutAtoms::canvasFrame == frameType.get()) {      // Use scroll frames' computed height if we have one, this will      // allow us to get viewport height for native scrollbars.      nsHTMLReflowState* scrollState = (nsHTMLReflowState *)rs->parentReflowState;      nsCOMPtr<nsIAtom> scrollFrameType;      scrollState->frame->GetFrameType(getter_AddRefs(scrollFrameType));      if (nsLayoutAtoms::scrollFrame == scrollFrameType.get()) {        rs = scrollState;      }    }    else {      break;    }    // if the ancestor has a computed height, it is the percent base    result = rs->mComputedHeight;    // if unconstrained - don't sutract borders - would result in huge height    if (NS_AUTOHEIGHT == result) return result;    // if we got to the canvas frame, then subtract out     // margin/border/padding for the BODY and HTML elements    if (nsLayoutAtoms::canvasFrame == frameType.get()) {      result -= GetVerticalMarginBorderPadding(firstBlockRS);       result -= GetVerticalMarginBorderPadding(firstAreaRS); #ifdef DEBUG      // make sure the Area is the HTML and the Block is the BODY      nsCOMPtr<nsIContent> frameContent;      nsCOMPtr<nsIAtom> contentTag;      if(firstBlockRS) {        firstBlockRS->frame->GetContent(getter_AddRefs(frameContent));        if (frameContent) {          frameContent->GetTag(*getter_AddRefs(contentTag));          NS_ASSERTION(contentTag.get() == nsHTMLAtoms::body, "block is not BODY");        }      }      if(firstAreaRS) {        firstAreaRS->frame->GetContent(getter_AddRefs(frameContent));        if (frameContent) {          frameContent->GetTag(*getter_AddRefs(contentTag));          NS_ASSERTION(contentTag.get() == nsHTMLAtoms::html, "Area frame is not HTML element");        }      }#endif          }    // if we got to the html frame, then subtract out     // margin/border/padding for the BODY element    else if (nsLayoutAtoms::areaFrame == frameType.get()) {      // make sure it is the body      nsCOMPtr<nsIAtom> fType;      rs->parentReflowState->frame->GetFrameType(getter_AddRefs(fType));      if (nsLayoutAtoms::canvasFrame == fType.get()) {        result -= GetVerticalMarginBorderPadding(firstBlockRS);      }    }    break;  }  return result;}