nsIFrame* formFrame; if (NS_OK == rs->frame->QueryInterface(NS_GET_IID(nsIFormManager), (void **)&formFrame)) { continue; }
CalcQuirkContainingBlockHeight(const nsHTMLReflowState& aReflowState,                               PRBool aRestrictToFirstLevel){  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->frame; 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;      }      if (aRestrictToFirstLevel && firstBlockRS) {        break;      }      firstBlockRS = (nsHTMLReflowState*)rs;      if (NS_AUTOHEIGHT == rs->mComputedHeight) {        continue;      }    }    else if (nsLayoutAtoms::areaFrame == frameType.get()) {      if (aRestrictToFirstLevel && firstAreaRS) {        break;      }      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 if (nsLayoutAtoms::pageContentFrame == frameType.get()) {      nsIFrame* prevInFlow;      rs->frame->GetPrevInFlow(&prevInFlow);      // only use the page content frame for a height basis if it is the first in flow      if (prevInFlow)         break;    }    else {      break;    }    // if the ancestor is the page content frame then the percent base is     // the avail height, otherwise it is the computed height    result = (nsLayoutAtoms::pageContentFrame == frameType.get())             ? rs->availableHeight : 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 or page content frame, then subtract out     // margin/border/padding for the BODY and HTML elements    if ((nsLayoutAtoms::canvasFrame == frameType.get()) ||         (nsLayoutAtoms::pageContentFrame == 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;}