nsCOMPtr<nsIAtom> contentTag; frameContent->GetTag(getter_AddRefs(contentTag));
nsIAtom *contentTag = frameContent->Tag();
CalcQuirkContainingBlockHeight(const nsHTMLReflowState& aReflowState){  nsHTMLReflowState* firstAncestorRS = nsnull; // a candidate for html frame  nsHTMLReflowState* secondAncestorRS = nsnull; // a candidate for body frame    // initialize the default to NS_AUTOHEIGHT as this is the containings block  // computed height when this function is called. It is possible that we   // don't alter this height especially if we are restricted to one level  nscoord result = NS_AUTOHEIGHT;                                const nsHTMLReflowState* rs = &aReflowState;  for (; rs && rs->frame; rs = (nsHTMLReflowState *)(rs->parentReflowState)) {     nsIAtom* frameType = rs->frame->GetType();    // 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 ||        nsLayoutAtoms::areaFrame == frameType ||        nsLayoutAtoms::scrollFrame == frameType) {            if (nsLayoutAtoms::areaFrame == frameType) {        // Skip over scrolled-content area frames        if (rs->frame->GetStyleContext()->GetPseudoType() ==            nsCSSAnonBoxes::scrolledContent) {          continue;        }      }      secondAncestorRS = firstAncestorRS;      firstAncestorRS = (nsHTMLReflowState*)rs;      // If the current frame we're looking at is positioned, we don't want to      // go any further (see bug 221784).  The behavior we want here is: 1) If      // not auto-height, use this as the percentage base.  2) If auto-height,      // keep looking, unless the frame is positioned.      if (NS_AUTOHEIGHT == rs->mComputedHeight) {        if (rs->frame->GetStyleDisplay()->IsAbsolutelyPositioned()) {          break;        } else {          continue;        }      }    }    else if (nsLayoutAtoms::canvasFrame == frameType) {      // 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;      if (nsLayoutAtoms::scrollFrame == scrollState->frame->GetType()) {        rs = scrollState;      }    }    else if (nsLayoutAtoms::pageContentFrame == frameType) {      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)             ? 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) ||         (nsLayoutAtoms::pageContentFrame == frameType)) {      result -= GetVerticalMarginBorderPadding(firstAncestorRS);       result -= GetVerticalMarginBorderPadding(secondAncestorRS); #ifdef DEBUG      // make sure the first ancestor is the HTML and the second is the BODY      if (firstAncestorRS) {        nsIContent* frameContent = firstAncestorRS->frame->GetContent();        if (frameContent) {          nsCOMPtr<nsIAtom> contentTag;          frameContent->GetTag(getter_AddRefs(contentTag));          NS_ASSERTION(contentTag == nsHTMLAtoms::html, "First ancestor is not HTML");        }      }      if (secondAncestorRS) {        nsIContent* frameContent = secondAncestorRS->frame->GetContent();        if (frameContent) {          nsCOMPtr<nsIAtom> contentTag;          frameContent->GetTag(getter_AddRefs(contentTag));          NS_ASSERTION(contentTag == nsHTMLAtoms::body, "Second ancestor is not BODY");        }      }#endif          }    // if we got to the html frame, then subtract out     // margin/border/padding for the BODY element    else if (nsLayoutAtoms::areaFrame == frameType) {      // make sure it is the body      if (nsLayoutAtoms::canvasFrame == rs->parentReflowState->frame->GetType()) {        result -= GetVerticalMarginBorderPadding(secondAncestorRS);      }    }    break;  }  return result;}