void nsScanner::AppendToBuffer(nsScannerString::Buffer* aBuf, nsIRequest *aRequest) { if (nsParser::sParserDataListeners && mParser && NS_FAILED(mParser->DataAdded(Substring(aBuf->DataStart(), aBuf->DataEnd()), aRequest))) {   return; }  if (!mSlidingBuffer) { mSlidingBuffer = new nsScannerString(aBuf); mSlidingBuffer->BeginReading(mCurrentPosition); mMarkPosition = mCurrentPosition; mSlidingBuffer->EndReading(mEndPosition); mCountRemaining = aBuf->DataLength(); } else { mSlidingBuffer->AppendBuffer(aBuf); if (mCurrentPosition == mEndPosition) { mSlidingBuffer->BeginReading(mCurrentPosition); } mSlidingBuffer->EndReading(mEndPosition); mCountRemaining += aBuf->DataLength(); }  if (mFirstNonWhitespacePosition == -1) { nsScannerIterator iter(mCurrentPosition); nsScannerIterator end(mEndPosition);  while (iter != end) { if (!nsCRT::IsAsciiSpace(*iter)) { mFirstNonWhitespacePosition = Distance(mCurrentPosition, iter);  break; }  ++iter; } } }
void AppendToBuffer(const nsAString& aStr) { AppendToBuffer(nsScannerString::AllocBufferFromString(aStr)); }
void nsScanner::AppendToBuffer(nsScannerString::Buffer* aBuf,                               nsIRequest *aRequest){  if (nsParser::sParserDataListeners && mParser &&      NS_FAILED(mParser->DataAdded(Substring(aBuf->DataStart(),                                             aBuf->DataEnd()), aRequest))) {    // Don't actually append on failure.    return;  }  if (!mSlidingBuffer) {    mSlidingBuffer = new nsScannerString(aBuf);    mSlidingBuffer->BeginReading(mCurrentPosition);    mMarkPosition = mCurrentPosition;    mSlidingBuffer->EndReading(mEndPosition);    mCountRemaining = aBuf->DataLength();  }  else {    mSlidingBuffer->AppendBuffer(aBuf);    if (mCurrentPosition == mEndPosition) {      mSlidingBuffer->BeginReading(mCurrentPosition);    }    mSlidingBuffer->EndReading(mEndPosition);    mCountRemaining += aBuf->DataLength();  }  if (mFirstNonWhitespacePosition == -1) {    nsScannerIterator iter(mCurrentPosition);    nsScannerIterator end(mEndPosition);    while (iter != end) {      if (!nsCRT::IsAsciiSpace(*iter)) {        mFirstNonWhitespacePosition = Distance(mCurrentPosition, iter);        break;      }      ++iter;    }  }}