NS_ASSERTION(mStackPos > 0, "leaf w/o container");
if (mStackPos<= 0) { return NS_ERROR_FAILURE; }
SinkContext::FlushText(PRBool* aDidFlush, PRBool aReleaseLast){  nsresult rv = NS_OK;  PRBool didFlush = PR_FALSE;  if (0 != mTextLength) {    if (mLastTextNode) {      nsCOMPtr<nsIDOMCharacterData> cdata = do_QueryInterface(mLastTextNode, &rv);      if (NS_SUCCEEDED(rv)) {        CBufDescriptor bd(mText, PR_TRUE, mTextSize+1, mTextLength);        bd.mIsConst = PR_TRUE;        nsAutoString str(bd);        rv = cdata->AppendData(str);      }    }    else {      nsIContent* content;      rv = NS_NewTextNode(&content);      if (NS_OK == rv) {        // Set the content's document        content->SetDocument(mSink->mDocument, PR_FALSE);                // Set the text in the text node        nsITextContent* text = nsnull;        content->QueryInterface(kITextContentIID, (void**) &text);        text->SetText(mText, mTextLength, PR_FALSE);        NS_RELEASE(text);        // Add text to its parent        NS_ASSERTION(mStackPos > 0, "leaf w/o container");        nsIHTMLContent* parent = mStack[mStackPos - 1].mContent;        if (mStack[mStackPos-1].mInsertionPoint != -1) {          parent->InsertChildAt(content,                                 mStack[mStackPos-1].mInsertionPoint++,                                 mSink->IsInScript());        }        else {          parent->AppendChildTo(content, mSink->IsInScript());        }        mLastTextNode = content;        DidAddContent(content, mSink->IsInScript());      }    }    mTextLength = 0;    didFlush = PR_TRUE;  }  if (nsnull != aDidFlush) {    *aDidFlush = didFlush;  }  if (aReleaseLast && mLastTextNode) {    NS_RELEASE(mLastTextNode);  }#ifdef DEBUG  if (mPreAppend && didFlush &&      SINK_LOG_TEST(gSinkLogModuleInfo,SINK_ALWAYS_REFLOW)) {    mSink->ForceReflow();  }#endif  return rv;}