nsCOMPtr<nsIDocument> doc; aContainer->GetDocument(*getter_AddRefs(doc)); NS_ASSERTION(doc, "null document from content element in FindNextAnonymousSibling"); if (doc) { nsCOMPtr<nsIDOMDocumentXBL> xblDoc(do_QueryInterface(doc)); NS_ASSERTION(xblDoc, "null xblDoc for content element in FindNextAnonymousSibling"); if (xblDoc) { nsCOMPtr<nsIDOMElement> elt(do_QueryInterface(aContainer)); xblDoc->GetAnonymousNodes(elt, getter_AddRefs(nodeList)); }
nsCOMPtr<nsIDOMDocumentXBL> xblDoc(do_QueryInterface(aDocument)); NS_ASSERTION(xblDoc, "null xblDoc for content element in FindNextAnonymousSibling"); if (xblDoc) { nsCOMPtr<nsIDOMElement> elt(do_QueryInterface(aContainer)); xblDoc->GetAnonymousNodes(elt, getter_AddRefs(nodeList));
FindNextAnonymousSibling(nsIPresShell* aPresShell,                         nsIContent* aContainer,                         nsIContent* aChild){  nsIFrame* nextSibling = nsnull;  nsCOMPtr<nsIDOMNodeList> nodeList;    nsCOMPtr<nsIDocument> doc;  aContainer->GetDocument(*getter_AddRefs(doc));  NS_ASSERTION(doc, "null document from content element in FindNextAnonymousSibling");  if (doc) {    nsCOMPtr<nsIDOMDocumentXBL> xblDoc(do_QueryInterface(doc));    NS_ASSERTION(xblDoc, "null xblDoc for content element in FindNextAnonymousSibling");    if (xblDoc) {      nsCOMPtr<nsIDOMElement> elt(do_QueryInterface(aContainer));      xblDoc->GetAnonymousNodes(elt, getter_AddRefs(nodeList));    }  }  if (nodeList) {    PRUint32 ctr,listLength;    nsCOMPtr<nsIDOMNode> node;    nodeList->GetLength(&listLength);    PRBool found = PR_FALSE;    for (ctr = 0; ctr < listLength; ctr++) {      nodeList->Item(ctr, getter_AddRefs(node));      nsCOMPtr<nsIContent> childContent(do_QueryInterface(node));      if (childContent.get() == aChild) {        found = PR_TRUE;        continue;      }      if (found) {        aPresShell->GetPrimaryFrameFor(childContent, &nextSibling);        if (nsnull != nextSibling) {          // The frame may have a next-in-flow. Get the first-in-flow          nsIFrame* prevInFlow;          do {            nextSibling->GetPrevInFlow(&prevInFlow);            if (nsnull != prevInFlow) {              nextSibling = prevInFlow;            }          } while (nsnull != prevInFlow);          // Did we really get the *right* frame?          const nsStyleDisplay* display;          nextSibling->GetStyleData(eStyleStruct_Display,                                    (const nsStyleStruct*&)display);          if (display->IsFloating() || display->IsPositioned()) {            // Nope. Get the place-holder instead            nsIFrame* placeholderFrame;            aPresShell->GetPlaceholderFrameFor(nextSibling, &placeholderFrame);            NS_ASSERTION(nsnull != placeholderFrame, "yikes");            nextSibling = placeholderFrame;          }          break;        }      }    }  }  return nextSibling;}