nsCOMPtr<nsIAtom> tag; pContent->GetTag(getter_AddRefs(tag));
nsIAtom *tag = pContent->Tag();
PRBool GetBGColorForHTMLElement( nsIPresContext *aPresContext,                                   const nsStyleBackground *&aBGColor ){  NS_ASSERTION(aPresContext, "null params not allowed");  PRBool result = PR_FALSE; // assume we did not find the HTML element  nsIPresShell* shell = nsnull;  aPresContext->GetShell(&shell);  if (shell) {    nsIDocument *doc = nsnull;    if (NS_SUCCEEDED(shell->GetDocument(&doc)) && doc) {      nsIContent *pContent;      if ((pContent = doc->GetRootContent())) {        // make sure that this is the HTML element        nsCOMPtr<nsIAtom> tag;        pContent->GetTag(getter_AddRefs(tag));        NS_ASSERTION(tag, "Tag could not be retrieved from root content element");        if (tag) {          if (tag == nsHTMLAtoms::html ||              tag == nsHTMLAtoms::body) {            // use this guy's color            nsIFrame *pFrame = nsnull;            if (NS_SUCCEEDED(shell->GetPrimaryFrameFor(pContent, &pFrame)) && pFrame) {              nsStyleContext *pContext = pFrame->GetStyleContext();              if (pContext) {                const nsStyleBackground* color = pContext->GetStyleBackground();                if (0 == (color->mBackgroundFlags & NS_STYLE_BG_COLOR_TRANSPARENT)) {                  aBGColor = color;                  // set the reslt to TRUE to indicate we mapped the color                  result = PR_TRUE;                }              }// if context            }// if frame          }// if tag == html or body#ifdef DEBUG          else {            printf( "Root Content is not HTML or BODY: cannot get bgColor of HTML or BODY\n");          }#endif        }// if tag      }// if content      NS_RELEASE(doc);    }// if doc    NS_RELEASE(shell);  } // if shell  return result;}