NS_ASSERTION(aPresContext, "Pointer is null!"); NS_ASSERTION(aParentFrame, "Pointer is null!"); NS_ASSERTION(aType, "Pointer is null!");
static nsIFrame * FindFrameByType(nsIPresContext* aPresContext,                                  nsIFrame *      aParentFrame,                                  nsIAtom *       aType,                                  nsRect&         aRect,                                  nsRect&         aChildRect) {  nsIFrame * child;  nsRect rect;  aParentFrame->GetRect(rect);  aRect.x += rect.x;  aRect.y += rect.y;  aParentFrame->FirstChild(aPresContext, nsnull, &child);  while (child != nsnull) {    nsCOMPtr<nsIContent> content;    child->GetContent(getter_AddRefs(content));    if (content) {      nsCOMPtr<nsIAtom> type;      content->GetTag(*getter_AddRefs(type));      if (type.get() == aType) {        nsRect r;        child->GetRect(r);        aChildRect.SetRect(aRect.x + r.x, aRect.y + r.y, r.width, r.height);        aRect.x -= rect.x;        aRect.y -= rect.y;        return child;      }    }    nsIFrame * fndFrame = FindFrameByType(aPresContext, child, aType, aRect, aChildRect);    if (fndFrame != nsnull) {      return fndFrame;    }    child->GetNextSibling(&child);  }  aRect.x -= rect.x;  aRect.y -= rect.y;  return nsnull;}