result = parent->AppendChildTo(child, sync);
result = parent->AppendChildTo(child, sync, PR_FALSE);
SinkContext::DemoteContainer(const nsIParserNode& aNode){  nsresult result = NS_OK;  nsHTMLTag nodeType = nsHTMLTag(aNode.GetNodeType());    // Search for the nearest container on the stack of the  // specified type  PRInt32 stackPos = mStackPos-1;  while ((stackPos > 0) && (nodeType != mStack[stackPos].mType)) {    stackPos--;  }    // If we find such a container...  if (stackPos > 0) {    nsIHTMLContent* container = mStack[stackPos].mContent;    PRBool sync = PR_FALSE;        // See if it has a parent on the stack. It should for all the    // cases for which this is called, but put in a check anyway    if (stackPos > 1) {      nsIHTMLContent* parent = mStack[stackPos-1].mContent;      PRInt32 parentCount;      // If we've already flushed the demoted container, flush      // what we have and do everything synchronously. If not,      // the children that will be promoted will just be dealt      // with later.      parent->ChildCount(parentCount);      if (mStack[stackPos-1].mNumFlushed == parentCount) {        FlushTags(PR_TRUE);        sync = PR_TRUE;      }      // Otherwise just append the container to the parent without      // notification (it the container hasn't already been appended)      else if (!(mStack[stackPos].mFlags & APPENDED)) {        mSink->mInNotification++;        parent->AppendChildTo(container, PR_FALSE);        mSink->mInNotification--;      }            if (NS_SUCCEEDED(result)) {        // Move all of the demoted containers children to its parent        PRInt32 i, count;        container->ChildCount(count);                for (i = 0; i < count && NS_SUCCEEDED(result); i++) {          nsIContent* child;                    // Since we're removing as we go along, always get the          // first child          result = container->ChildAt(0, child);          if (NS_SUCCEEDED(result)) {            // Remove it from its old parent (the demoted container)                        // If the child is a form control, cache the form that contains it.            // After the form control is removed from it's container, restore            // it's form.            nsIFormControl* childFormControl = nsnull;            result = child->QueryInterface(NS_GET_IID(nsIFormControl), (void**)&childFormControl);            if (NS_SUCCEEDED(result)) {              // It is a form control, so get it's form and cache it.              nsIDOMHTMLFormElement* formElem = nsnull;              childFormControl->GetForm(&formElem);              // Removing the child will set it's form control to nsnull.              result = container->RemoveChildAt(0, sync);              // Restore the child's form control using the cache'd pointer.              childFormControl->SetForm(formElem);                            NS_RELEASE(childFormControl);              NS_IF_RELEASE(formElem);            } else {              result = container->RemoveChildAt(0, sync);            }                        if (NS_SUCCEEDED(result)) {              SetDocumentInChildrenOf(child, mSink->mDocument);              // Note that we're doing synchronous notifications here              // since we already did notifications for all content              // that's come through with the FlushTags() call so far.              mSink->mInNotification++;              result = parent->AppendChildTo(child, sync);              mSink->mInNotification--;            }            NS_RELEASE(child);          }        }                // Remove the demoted element from the context stack.        while (stackPos < mStackPos-1) {          mStack[stackPos].mType = mStack[stackPos+1].mType;          mStack[stackPos].mContent = mStack[stackPos+1].mContent;          mStack[stackPos].mFlags = mStack[stackPos+1].mFlags;          stackPos++;        }        mStackPos--;      }    }    NS_RELEASE(container);    if (sync) {      // Update child counts for everything on the stack, since      // we've moved around content in the hierarchy      UpdateChildCounts();    }  }    return result;}