mLastTextNode->SetDocument(mSink->mDocument, PR_FALSE, PR_TRUE);
SinkContext::FlushText(PRBool* aDidFlush, PRBool aReleaseLast){  nsresult rv = NS_OK;  PRBool didFlush = PR_FALSE;  if (mTextLength != 0) {    if (mLastTextNode) {      if ((mLastTextNodeSize + mTextLength) > mSink->mMaxTextRun) {        mLastTextNodeSize = 0;        mLastTextNode = nsnull;        FlushText(aDidFlush, aReleaseLast);      } else {        nsCOMPtr<nsIDOMCharacterData> cdata(do_QueryInterface(mLastTextNode));        if (cdata) {          rv = cdata->AppendData(Substring(mText, mText + mTextLength));          mLastTextNodeSize += mTextLength;          mTextLength = 0;          didFlush = PR_TRUE;        }      }    } else {      nsCOMPtr<nsITextContent> textContent;      rv = NS_NewTextNode(getter_AddRefs(textContent));      NS_ENSURE_SUCCESS(rv, rv);      mLastTextNode = textContent;      // Set the text in the text node      mLastTextNode->SetText(mText, mTextLength, PR_FALSE);      // Eat up the rest of the text up in state.      mLastTextNodeSize += mTextLength;      mTextLength = 0;      // Add text to its parent      NS_ASSERTION(mStackPos > 0, "leaf w/o container");      if (mStackPos <= 0) {        return NS_ERROR_FAILURE;      }      nsIHTMLContent* parent = mStack[mStackPos - 1].mContent;      if (mStack[mStackPos - 1].mInsertionPoint != -1) {        parent->InsertChildAt(mLastTextNode,                              mStack[mStackPos - 1].mInsertionPoint++,                              PR_FALSE, PR_FALSE);      } else {        parent->AppendChildTo(mLastTextNode, PR_FALSE, PR_FALSE);      }      didFlush = PR_TRUE;      DidAddContent(mLastTextNode, PR_FALSE);    }  }  if (aDidFlush) {    *aDidFlush = didFlush;  }  if (aReleaseLast) {    mLastTextNodeSize = 0;    mLastTextNode = nsnull;  }#ifdef DEBUG  if (mPreAppend && didFlush &&      SINK_LOG_TEST(gSinkLogModuleInfo, SINK_ALWAYS_REFLOW)) {    mSink->ForceReflow();  }#endif  return rv;}