mBoundElement->GetDocument(*getter_AddRefs(doc));
mBoundElement->GetDocument(getter_AddRefs(doc));
  void DocumentLoaded(nsIDocument* aBindingDoc)  {    nsCOMPtr<nsIDocument> doc;    mBoundElement->GetDocument(*getter_AddRefs(doc));    if (!doc)      return;    // Get the binding.    PRBool ready = PR_FALSE;    gXBLService->BindingReady(mBoundElement, mBindingURL, &ready);    if (!ready)      return;    // XXX Deal with layered bindings.    // Now do a ContentInserted notification to cause the frames to get installed finally,    nsCOMPtr<nsIContent> parent;    mBoundElement->GetParent(*getter_AddRefs(parent));    PRInt32 index = 0;    if (parent)      parent->IndexOf(mBoundElement, index);            // If |mBoundElement| is (in addition to having binding |mBinding|)    // also a descendant of another element with binding |mBinding|,    // then we might have just constructed it due to the    // notification of its parent.  (We can know about both if the    // binding loads were triggered from the DOM rather than frame    // construction.)  So we have to check both whether the element    // has a primary frame and whether it's in the undisplayed map    // before sending a ContentInserted notification, or bad things    // will happen.    nsCOMPtr<nsIPresShell> shell;    doc->GetShellAt(0, getter_AddRefs(shell));    if (shell) {      nsIFrame* childFrame;      shell->GetPrimaryFrameFor(mBoundElement, &childFrame);      if (!childFrame) {        // Check to see if it's in the undisplayed content map.        nsCOMPtr<nsIFrameManager> frameManager;        shell->GetFrameManager(getter_AddRefs(frameManager));        nsStyleContext* sc = frameManager->GetUndisplayedContent(mBoundElement);        if (!sc) {          nsCOMPtr<nsIDocumentObserver> obs(do_QueryInterface(shell));          obs->ContentInserted(doc, parent, mBoundElement, index);        }      }    }  }