Bug 384898: Cleanup nsScanner. r=mrbkap, sr=jst
authorsharparrow1@yahoo.com
Tue, 26 Jun 2007 17:21:47 -0700
changeset 2814 a9472085446f4a6431b35bb8c73fbf90baa3cf31
parent 2813 64e43155343284dcb81d15cbebaf941eb740dc66
child 2815 63edce654440c1dd8bd0ead329ae9c97b65b5718
push idunknown
push userunknown
push dateunknown
reviewersmrbkap, jst
bugs384898
milestone1.9a6pre
Bug 384898: Cleanup nsScanner. r=mrbkap, sr=jst
parser/htmlparser/public/nsIParser.h
parser/htmlparser/src/nsExpatDriver.cpp
parser/htmlparser/src/nsParser.cpp
parser/htmlparser/src/nsParser.h
parser/htmlparser/src/nsScanner.cpp
parser/htmlparser/src/nsScanner.h
--- a/parser/htmlparser/public/nsIParser.h
+++ b/parser/htmlparser/public/nsIParser.h
@@ -45,17 +45,16 @@
  *  This class defines the iparser interface. This XPCOM
  *  inteface is all that parser clients ever need to see.
  *
  **/
 
 #include "nsISupports.h"
 #include "nsIStreamListener.h"
 #include "nsIDTD.h"
-#include "nsIInputStream.h"
 #include "nsStringGlue.h"
 #include "nsVoidArray.h"
 
 // {26C4ABBE-A462-4110-A0A6-244BF39AE7D4}
 #define NS_IPARSER_IID \
 { 0x26c4abbe, 0xa462, 0x4110, \
   { 0xa0, 0xa6, 0x24, 0x4b, 0xf3, 0x9a, 0xe7, 0xd4 } }
 
@@ -223,20 +222,16 @@ class nsIParser : public nsISupports {
 
     NS_IMETHOD_(PRBool) IsParserEnabled() = 0;
     NS_IMETHOD_(PRBool) IsComplete() = 0;
     
     NS_IMETHOD Parse(nsIURI* aURL,
                      nsIRequestObserver* aListener = nsnull,
                      void* aKey = 0,
                      nsDTDMode aMode = eDTDMode_autodetect) = 0;
-    NS_IMETHOD Parse(nsIInputStream* aStream,
-                     const nsACString& aMimeType,
-                     void* aKey = 0,
-                     nsDTDMode aMode = eDTDMode_autodetect) = 0;
     NS_IMETHOD Parse(const nsAString& aSourceBuffer,
                      void* aKey,
                      const nsACString& aMimeType,
                      PRBool aLastCall,
                      nsDTDMode aMode = eDTDMode_autodetect) = 0;
 
     // Return a key, suitable for passing into one of the Parse methods above,
     // that will cause this parser to use the root context.
--- a/parser/htmlparser/src/nsExpatDriver.cpp
+++ b/parser/htmlparser/src/nsExpatDriver.cpp
@@ -1172,17 +1172,17 @@ nsExpatDriver::ConsumeToken(nsScanner& a
 
   aScanner.SetPosition(currentExpatPosition, PR_TRUE);
   aScanner.Mark();
 
   PR_LOG(gExpatDriverLog, PR_LOG_DEBUG,
          ("Remaining in expat's buffer: %i, remaining in scanner: %i.",
           mExpatBuffered, Distance(currentExpatPosition, end)));
 
-  return NS_SUCCEEDED(mInternalState) ? aScanner.FillBuffer() : NS_OK;
+  return NS_SUCCEEDED(mInternalState) ? kEOF : NS_OK;
 }
 
 NS_IMETHODIMP
 nsExpatDriver::WillBuildModel(const CParserContext& aParserContext,
                               nsITokenizer* aTokenizer,
                               nsIContentSink* aSink)
 {
   mSink = do_QueryInterface(aSink);
--- a/parser/htmlparser/src/nsParser.cpp
+++ b/parser/htmlparser/src/nsParser.cpp
@@ -1275,53 +1275,16 @@ nsParser::Parse(nsIURI* aURL,
       result = NS_OK;
     } else {
       result = mInternalState = NS_ERROR_HTMLPARSER_BADCONTEXT;
     }
   }
   return result;
 }
 
-
-/**
- * Cause parser to parse input from given stream
- */
-NS_IMETHODIMP
-nsParser::Parse(nsIInputStream* aStream,
-                const nsACString& aMimeType,
-                void* aKey,
-                nsDTDMode aMode)
-{
-  nsresult  result = NS_ERROR_OUT_OF_MEMORY;
-
-  // Ok, time to create our tokenizer and begin the process
-  nsAutoString theUnknownFilename(NS_LITERAL_STRING("unknown"));
-
-  nsScanner* theScanner = new nsScanner(theUnknownFilename, aStream, mCharset,
-                                        mCharsetSource);
-
-  CParserContext* pc = new CParserContext(theScanner, aKey, mCommand, 0);
-  if (pc && theScanner) {
-    PushContext(*pc);
-    pc->SetMimeType(aMimeType);
-    pc->mStreamListenerState = eOnStart;
-    pc->mMultipart = PR_FALSE;
-    pc->mContextType = CParserContext::eCTStream;
-    pc->mDTDMode = aMode;
-    mParserContext->mScanner->FillBuffer();
-    result = ResumeParse();
-    pc = PopContext();
-    delete pc;
-  } else {
-    result = mInternalState = NS_ERROR_HTMLPARSER_BADCONTEXT;
-  }
-
-  return result;
-}
-
 /**
  * Call this method if all you want to do is parse 1 string full of HTML text.
  * In particular, this method should be called by the DOM when it has an HTML
  * string to feed to the parser in real-time.
  *
  * @param   aSourceBuffer contains a string-full of real content
  * @param   aMimeType tells us what type of content to expect in the given string
  */
--- a/parser/htmlparser/src/nsParser.h
+++ b/parser/htmlparser/src/nsParser.h
@@ -195,27 +195,16 @@ class nsParser : public nsIParser,
      * @return  TRUE if all went well -- FALSE otherwise
      */
     NS_IMETHOD Parse(nsIURI* aURL,
                      nsIRequestObserver* aListener = nsnull,
                      void* aKey = 0,
                      nsDTDMode aMode = eDTDMode_autodetect);
 
     /**
-     * Cause parser to parse input from given stream 
-     * @update	gess5/11/98
-     * @param   aStream is the i/o source
-     * @return  TRUE if all went well -- FALSE otherwise
-     */
-    NS_IMETHOD Parse(nsIInputStream* aStream,
-                     const nsACString& aMimeType,
-                     void* aKey = 0,
-                     nsDTDMode aMode = eDTDMode_autodetect);
-
-    /**
      * @update	gess5/11/98
      * @param   anHTMLString contains a string-full of real HTML
      * @param   appendTokens tells us whether we should insert tokens inline, or append them.
      * @return  TRUE if all went well -- FALSE otherwise
      */
     NS_IMETHOD Parse(const nsAString& aSourceBuffer,
                      void* aKey,
                      const nsACString& aContentType,
--- a/parser/htmlparser/src/nsScanner.cpp
+++ b/parser/htmlparser/src/nsScanner.cpp
@@ -89,17 +89,16 @@ const int   kBufsize=64;
  *  @return  
  */
 nsScanner::nsScanner(const nsAString& anHTMLString, const nsACString& aCharset,
                      PRInt32 aSource)
   : mParser(nsnull)
 {
   MOZ_COUNT_CTOR(nsScanner);
 
-  mTotalRead = anHTMLString.Length();
   mSlidingBuffer = nsnull;
   mCountRemaining = 0;
   mFirstNonWhitespacePosition = -1;
   AppendToBuffer(anHTMLString);
   mSlidingBuffer->BeginReading(mCurrentPosition);
   mMarkPosition = mCurrentPosition;
   mIncremental = PR_FALSE;
   mUnicodeDecoder = 0;
@@ -116,84 +115,38 @@ nsScanner::nsScanner(const nsAString& an
  *  @param   aFilename --
  *  @return  
  */
 nsScanner::nsScanner(nsString& aFilename,PRBool aCreateStream,
                      const nsACString& aCharset, PRInt32 aSource)
   : mFilename(aFilename), mParser(nsnull)
 {
   MOZ_COUNT_CTOR(nsScanner);
+  NS_ASSERTION(!aCreateStream, "This is always true.");
 
   mSlidingBuffer = nsnull;
 
   // XXX This is a big hack.  We need to initialize the iterators to something.
   // What matters is that mCurrentPosition == mEndPosition, so that our methods
   // believe that we are at EOF (see bug 182067).  We null out mCurrentPosition
   // so that we have some hope of catching null pointer dereferences associated
   // with this hack. --darin
   memset(&mCurrentPosition, 0, sizeof(mCurrentPosition));
   mMarkPosition = mCurrentPosition;
   mEndPosition = mCurrentPosition;
 
   mIncremental = PR_TRUE;
   mFirstNonWhitespacePosition = -1;
   mCountRemaining = 0;
-  mTotalRead=0;
 
-  if(aCreateStream) {
-    nsCOMPtr<nsILocalFile> file;
-    nsCOMPtr<nsIInputStream> fileStream;
-    
-    NS_NewLocalFile(aFilename, PR_TRUE, getter_AddRefs(file));
-    if (file)
-      NS_NewLocalFileInputStream(getter_AddRefs(mInputStream), file);
-
-  } //if
   mUnicodeDecoder = 0;
   mCharsetSource = kCharsetUninitialized;
   SetDocumentCharset(aCharset, aSource);
 }
 
-/**
- *  Use this constructor if you want i/o to be stream based.
- *
- *  @update  gess 5/12/98
- *  @param   aStream --
- *  @param   assumeOwnership --
- *  @param   aFilename --
- *  @return  
- */
-nsScanner::nsScanner(const nsAString& aFilename, nsIInputStream* aStream,
-                     const nsACString& aCharset, PRInt32 aSource)
-  : mFilename(aFilename), mParser(nsnull)
-{  
-  MOZ_COUNT_CTOR(nsScanner);
-
-  mSlidingBuffer = nsnull;
-
-  // XXX This is a big hack.  We need to initialize the iterators to something.
-  // What matters is that mCurrentPosition == mEndPosition, so that our methods
-  // believe that we are at EOF (see bug 182067).  We null out mCurrentPosition
-  // so that we have some hope of catching null pointer dereferences associated
-  // with this hack. --darin
-  memset(&mCurrentPosition, 0, sizeof(mCurrentPosition));
-  mMarkPosition = mCurrentPosition;
-  mEndPosition = mCurrentPosition;
-
-  mIncremental = PR_FALSE;
-  mFirstNonWhitespacePosition = -1;
-  mCountRemaining = 0;
-  mTotalRead=0;
-  mInputStream=aStream;
-  mUnicodeDecoder = 0;
-  mCharsetSource = kCharsetUninitialized;
-  SetDocumentCharset(aCharset, aSource);
-}
-
-
 nsresult nsScanner::SetDocumentCharset(const nsACString& aCharset , PRInt32 aSource) {
 
   nsresult res = NS_OK;
 
   if( aSource < mCharsetSource) // priority is lower the the current one , just
     return res;
 
   nsCOMPtr<nsICharsetAlias> calias(do_GetService(NS_CHARSETALIAS_CONTRACTID, &res));
@@ -246,21 +199,16 @@ nsresult nsScanner::SetDocumentCharset(c
 nsScanner::~nsScanner() {
 
   if (mSlidingBuffer) {
     delete mSlidingBuffer;
   }
 
   MOZ_COUNT_DTOR(nsScanner);
 
-  if(mInputStream) {
-    mInputStream->Close();
-    mInputStream = 0;
-  }
-
   NS_IF_RELEASE(mUnicodeDecoder);
 }
 
 /**
  *  Resets current offset position of input stream to marked position. 
  *  This allows us to back up to this point if the need should arise, 
  *  such as when tokenization gets interrupted.
  *  NOTE: IT IS REALLY BAD FORM TO CALL RELEASE WITHOUT CALLING MARK FIRST!
@@ -308,46 +256,44 @@ PRBool nsScanner::UngetReadable(const ns
   }
 
   mSlidingBuffer->UngetReadable(aBuffer,mCurrentPosition);
   mSlidingBuffer->BeginReading(mCurrentPosition); // Insertion invalidated our iterators
   mSlidingBuffer->EndReading(mEndPosition);
  
   PRUint32 length = aBuffer.Length();
   mCountRemaining += length; // Ref. bug 117441
-  mTotalRead += length;
   return PR_TRUE;
 }
 
 /** 
  * Append data to our underlying input buffer as
  * if it were read from an input stream.
  *
  * @update  gess4/3/98
  * @return  error code 
  */
 nsresult nsScanner::Append(const nsAString& aBuffer) {
-  mTotalRead += aBuffer.Length();
   AppendToBuffer(aBuffer);
   return NS_OK;
 }
 
 /**
  *  
  *  
  *  @update  gess 5/21/98
  *  @param   
  *  @return  
  */
 nsresult nsScanner::Append(const char* aBuffer, PRUint32 aLen,
                            nsIRequest *aRequest)
 {
   nsresult res=NS_OK;
   PRUnichar *unichars, *start;
-  if(mUnicodeDecoder) {
+  if (mUnicodeDecoder) {
     PRInt32 unicharBufLen = 0;
     mUnicodeDecoder->GetMaxLength(aBuffer, aLen, &unicharBufLen);
     nsScannerString::Buffer* buffer = nsScannerString::AllocBuffer(unicharBufLen + 1);
     NS_ENSURE_TRUE(buffer,NS_ERROR_OUT_OF_MEMORY);
     start = unichars = buffer->DataStart();
 
     PRInt32 totalChars = 0;
     PRInt32 unicharLength = unicharBufLen;
@@ -384,142 +330,86 @@ nsresult nsScanner::Append(const char* a
 
         aBuffer += srcLength;
         aLen -= srcLength;
       }
     } while (NS_FAILED(res) && (aLen > 0));
 
     buffer->SetDataLength(totalChars);
     AppendToBuffer(buffer, aRequest);
-    mTotalRead += totalChars;
 
     // Don't propagate return code of unicode decoder
     // since it doesn't reflect on our success or failure
     // - Ref. bug 87110
     res = NS_OK; 
   }
   else {
-    AppendASCIItoBuffer(aBuffer, aLen, aRequest);
-    mTotalRead+=aLen;
+    NS_WARNING("No decoder found.");
+    res = NS_ERROR_FAILURE;
   }
 
   return res;
 }
 
-
-/** 
- * Grab data from underlying stream.
- *
- * @update  gess4/3/98
- * @return  error code
- */
-nsresult nsScanner::FillBuffer(void) {
-  nsresult result=NS_OK;
-
-  if(!mInputStream) {
-    result=kEOF;
-  }
-  else {
-    PRUint32 numread=0;
-    char buf[kBufsize+1];
-    buf[kBufsize]=0;
-
-    // XXX use ReadSegments to avoid extra buffer copy? --darin
-
-    result = mInputStream->Read(buf, kBufsize, &numread);
-    if (0 == numread) {
-      return kEOF;
-    }
-
-    if((0<numread) && NS_SUCCEEDED(result)) {
-      AppendASCIItoBuffer(buf, numread, nsnull);
-    }
-    mTotalRead+=numread;
-  }
-
-  return result;
-}
-
 /**
  *  retrieve next char from scanners internal input stream
  *  
  *  @update  gess 3/25/98
  *  @param   
  *  @return  error code reflecting read status
  */
 nsresult nsScanner::GetChar(PRUnichar& aChar) {
-  nsresult result=NS_OK;
-  aChar=0;  
-
-  if (!mSlidingBuffer) {
+  if (!mSlidingBuffer || mCurrentPosition == mEndPosition) {
+    aChar = 0;
     return kEOF;
   }
 
-  if (mCurrentPosition == mEndPosition) {
-    result = FillBuffer();
-  }
+  aChar = *mCurrentPosition++;
+  --mCountRemaining;
 
-  if(NS_OK == result){
-    aChar = *mCurrentPosition++;
-    --mCountRemaining;
-  }
-  return result;
+  return NS_OK;
 }
 
 
 /**
  *  peek ahead to consume next char from scanner's internal
  *  input buffer
  *  
  *  @update  gess 3/25/98
  *  @param   
  *  @return  
  */
 nsresult nsScanner::Peek(PRUnichar& aChar, PRUint32 aOffset) {
-  nsresult result=NS_OK;
-  aChar=0;  
-  
-  if (!mSlidingBuffer) {
+  aChar = 0;
+
+  if (!mSlidingBuffer || mCurrentPosition == mEndPosition) {
     return kEOF;
   }
 
-  if (mCurrentPosition == mEndPosition) {
-    result = FillBuffer();
+  if (aOffset > 0) {
+    if (mCountRemaining <= aOffset)
+      return kEOF;
+
+    nsScannerIterator pos = mCurrentPosition;
+    pos.advance(aOffset);
+    aChar=*pos;
+  }
+  else {
+    aChar=*mCurrentPosition;
   }
 
-  if(NS_OK == result){
-    if (aOffset) {
-      while ((NS_OK == result) && (mCountRemaining <= aOffset)) {
-        result = FillBuffer();
-      }
-
-      if (NS_OK == result) {
-        nsScannerIterator pos = mCurrentPosition;
-        pos.advance(aOffset);
-        aChar=*pos;
-      }
-    }
-    else {
-      aChar=*mCurrentPosition;
-    }
-  }
-
-  return result;
+  return NS_OK;
 }
 
 nsresult nsScanner::Peek(nsAString& aStr, PRInt32 aNumChars, PRInt32 aOffset)
 {
-  if (!mSlidingBuffer) {
+  if (!mSlidingBuffer || mCurrentPosition == mEndPosition) {
     return kEOF;
   }
 
-  if (mCurrentPosition == mEndPosition) {
-    return FillBuffer();
-  }    
-  
   nsScannerIterator start, end;
 
   start = mCurrentPosition;
 
   if ((PRInt32)mCountRemaining <= aOffset) {
     return kEOF;
   }
 
@@ -586,17 +476,17 @@ nsresult nsScanner::SkipWhitespace(PRInt
         done = PR_TRUE;
         break;
     }
   }
 
   if (skipped) {
     SetPosition(current);
     if (current == mEndPosition) {
-      result = FillBuffer();
+      result = kEOF;
     }
   }
 
   return result;
 }
 
 /**
  *  Skip over chars as long as they equal given char
@@ -623,78 +513,16 @@ nsresult nsScanner::SkipOver(PRUnichar a
       GetChar(ch);
     } 
     else break;
   } //while
   return result;
 
 }
 
-/**
- *  Skip over chars as long as they're in aSkipSet
- *  
- *  @update  gess 3/25/98
- *  @param   aSkipSet is an ordered string.
- *  @return  error code
- */
-nsresult nsScanner::SkipOver(nsString& aSkipSet){
-
-  if (!mSlidingBuffer) {
-    return kEOF;
-  }
-
-  PRUnichar theChar=0;
-  nsresult  result=NS_OK;
-
-  while(NS_OK==result) {
-    result=Peek(theChar);
-    if(NS_OK == result) {
-      PRInt32 pos=aSkipSet.FindChar(theChar);
-      if(kNotFound==pos) {
-        break;
-      }
-      GetChar(theChar);
-    } 
-    else break;
-  } //while
-  return result;
-
-}
-
-
-/**
- *  Skip over chars until they're in aValidSet
- *  
- *  @update  gess 3/25/98
- *  @param   aValid set is an ordered string that 
- *           contains chars you're looking for
- *  @return  error code
- */
-nsresult nsScanner::SkipTo(nsString& aValidSet){
-  if (!mSlidingBuffer) {
-    return kEOF;
-  }
-
-  PRUnichar ch=0;
-  nsresult  result=NS_OK;
-
-  while(NS_OK==result) {
-    result=Peek(ch);
-    if(NS_OK == result) {
-      PRInt32 pos=aValidSet.FindChar(ch);
-      if(kNotFound!=pos) {
-        break;
-      }
-      GetChar(ch);
-    } 
-    else break;
-  } //while
-  return result;
-}
-
 #if 0
 void DoErrTest(nsString& aString) {
   PRInt32 pos=aString.FindChar(0);
   if(kNotFound<pos) {
     if(aString.Length()-1!=pos) {
     }
   }
 }
@@ -704,29 +532,16 @@ void DoErrTest(nsCString& aString) {
   if(kNotFound<pos) {
     if(aString.Length()-1!=pos) {
     }
   }
 }
 #endif
 
 /**
- *  Skip over chars as long as they're in aValidSet
- *  
- *  @update  gess 3/25/98
- *  @param   aValidSet is an ordered string containing the 
- *           characters you want to skip
- *  @return  error code
- */
-nsresult nsScanner::SkipPast(nsString& aValidSet){
-  NS_NOTYETIMPLEMENTED("Error: SkipPast not yet implemented.");
-  return NS_OK;
-}
-
-/**
  *  Consume characters until you run into space, a '<', a '>', or a '/'.
  *  
  *  @param   aString - receives new data from stream
  *  @return  error code
  */
 nsresult nsScanner::ReadTagIdentifier(nsScannerSharedSubstring& aString) {
 
   if (!mSlidingBuffer) {
@@ -775,17 +590,17 @@ nsresult nsScanner::ReadTagIdentifier(ns
 
   // Don't bother appending nothing.
   if (current != mCurrentPosition) {
     AppendUnicodeTo(mCurrentPosition, current, aString);
   }
 
   SetPosition(current);  
   if (current == end) {
-    result = FillBuffer();
+    result = kEOF;
   }
 
   //DoErrTest(aString);
 
   return result;
 }
 
 /**
@@ -835,17 +650,17 @@ nsresult nsScanner::ReadEntityIdentifier
       }
     }
     ++current;
   }
   
   SetPosition(current);
   if (current == end) {
     AppendUnicodeTo(origin, current, aString);
-    return FillBuffer();
+    return kEOF;
   }
 
   //DoErrTest(aString);
 
   return result;
 }
 
 /**
@@ -884,17 +699,17 @@ nsresult nsScanner::ReadNumber(nsString&
       }
     }
     ++current;
   }
 
   SetPosition(current);
   if (current == end) {
     AppendUnicodeTo(origin, current, aString);
-    return FillBuffer();
+    return kEOF;
   }
 
   //DoErrTest(aString);
 
   return result;
 }
 
 /**
@@ -962,17 +777,17 @@ nsresult nsScanner::ReadWhitespace(nsSca
         AppendUnicodeTo(origin, current, aString);
         break;
     }
   }
 
   SetPosition(current);
   if (current == end) {
     AppendUnicodeTo(origin, current, aString);
-    result = FillBuffer();
+    result = kEOF;
   }
 
   aHaveCR = haveCR;
   return result;
 }
 
 //XXXbz callers of this have to manage their lone '\r' themselves if they want
 //it to work.  Good thing they're all in view-source and it deals.
@@ -1021,80 +836,23 @@ nsresult nsScanner::ReadWhitespace(nsSca
         break;
     }
   }
 
   SetPosition(current);
   if (current == end) {
     aStart = origin;
     aEnd = current;
-    result = FillBuffer();
+    result = kEOF;
   }
 
   return result;
 }
 
 /**
- *  Consume chars as long as they are <i>in</i> the 
- *  given validSet of input chars.
- *  
- *  @update  gess 3/25/98
- *  @param   aString will contain the result of this method
- *  @param   aValidSet is an ordered string that contains the
- *           valid characters
- *  @return  error code
- */
-nsresult nsScanner::ReadWhile(nsString& aString,
-                             nsString& aValidSet,
-                             PRBool addTerminal){
-
-  if (!mSlidingBuffer) {
-    return kEOF;
-  }
-
-  PRUnichar         theChar=0;
-  nsresult          result=Peek(theChar);
-  nsScannerIterator origin, current, end;
-
-  origin = mCurrentPosition;
-  current = origin;
-  end = mEndPosition;
-
-  while(current != end) {
- 
-    theChar=*current;
-    if (theChar == '\0') {
-      ReplaceCharacter(current, sInvalid);
-      theChar = sInvalid;
-    }
-    if(theChar) {
-      PRInt32 pos=aValidSet.FindChar(theChar);
-      if(kNotFound==pos) {
-        if(addTerminal)
-          ++current;
-        AppendUnicodeTo(origin, current, aString);
-        break;
-      }
-    }
-    ++current;
-  }
-
-  SetPosition(current);
-  if (current == end) {
-    AppendUnicodeTo(origin, current, aString);
-    return FillBuffer();
-  }
-
-  //DoErrTest(aString);
-
-  return result;
-
-}
-
-/**
  *  Consume characters until you encounter one contained in given
  *  input set.
  *  
  *  @update  gess 3/25/98
  *  @param   aString will contain the result of this method
  *  @param   aTerminalSet is an ordered string that contains
  *           the set of INVALID characters
  *  @return  error code
@@ -1151,17 +909,17 @@ nsresult nsScanner::ReadUntil(nsAString&
     
     ++current;
   }
 
   // If we are here, we didn't find any terminator in the string and
   // current = mEndPosition
   SetPosition(current);
   AppendUnicodeTo(origin, current, aString);
-  return FillBuffer();
+  return kEOF;
 }
 
 nsresult nsScanner::ReadUntil(nsScannerSharedSubstring& aString,
                               const nsReadEndCondition& aEndCondition,
                               PRBool addTerminal)
 {  
   if (!mSlidingBuffer) {
     return kEOF;
@@ -1211,17 +969,17 @@ nsresult nsScanner::ReadUntil(nsScannerS
     
     ++current;
   }
 
   // If we are here, we didn't find any terminator in the string and
   // current = mEndPosition
   SetPosition(current);
   AppendUnicodeTo(origin, current, aString);
-  return FillBuffer();
+  return kEOF;
 }
 
 nsresult nsScanner::ReadUntil(nsScannerIterator& aStart, 
                               nsScannerIterator& aEnd,
                               const nsReadEndCondition &aEndCondition,
                               PRBool addTerminal)
 {
   if (!mSlidingBuffer) {
@@ -1272,17 +1030,17 @@ nsresult nsScanner::ReadUntil(nsScannerI
     theChar = *current;
   }
 
   // If we are here, we didn't find any terminator in the string and
   // current = mEndPosition
   SetPosition(current);
   aStart = origin;
   aEnd = current;
-  return FillBuffer();
+  return kEOF;
 }
 
 /**
  *  Consumes chars until you see the given terminalChar
  *  
  *  @update  gess 3/25/98
  *  @param   
  *  @return  error code
@@ -1323,17 +1081,17 @@ nsresult nsScanner::ReadUntil(nsAString&
     ++current;
     theChar = *current;
   }
 
   // If we are here, we didn't find any terminator in the string and
   // current = mEndPosition
   AppendUnicodeTo(origin, current, aString);
   SetPosition(current);
-  return FillBuffer();
+  return kEOF;
 
 }
 
 void nsScanner::BindSubstring(nsScannerSubstring& aSubstring, const nsScannerIterator& aStart, const nsScannerIterator& aEnd)
 {
   aSubstring.Rebind(*mSlidingBuffer, aStart, aEnd);
 }
 
@@ -1420,29 +1178,16 @@ void nsScanner::AppendToBuffer(nsScanner
         break;
       }
 
       ++iter;
     }
   }
 }
 
-void nsScanner::AppendASCIItoBuffer(const char* aData, PRUint32 aLen,
-                                    nsIRequest *aRequest)
-{
-  nsScannerString::Buffer* buf = nsScannerString::AllocBuffer(aLen);
-  if (buf)
-  {
-    LossyConvertEncoding<char, PRUnichar> converter(buf->DataStart());
-    converter.write(aData, aLen);
-    converter.write_terminator();
-    AppendToBuffer(buf, aRequest);
-  }
-}
-
 /**
  *  call this to copy bytes out of the scanner that have not yet been consumed
  *  by the tokenization process.
  *  
  *  @update  gess 5/12/98
  *  @param   aCopyBuffer is where the scanner buffer will be copied to
  *  @return  nada
  */
--- a/parser/htmlparser/src/nsScanner.h
+++ b/parser/htmlparser/src/nsScanner.h
@@ -38,31 +38,30 @@
 
 /**
  * MODULE NOTES:
  * @update  gess 4/1/98
  * 
  * The scanner is a low-level service class that knows
  * how to consume characters out of an (internal) stream.
  * This class also offers a series of utility methods
- * that most tokenizers want, such as readUntil(), 
- * readWhile() and SkipWhitespace().
+ * that most tokenizers want, such as readUntil()
+ * and SkipWhitespace().
  */
 
 
 #ifndef SCANNER
 #define SCANNER
 
 #include "nsCOMPtr.h"
 #include "nsString.h"
 #include "nsIParser.h"
 #include "prtypes.h"
 #include "nsIUnicodeDecoder.h"
 #include "nsScannerString.h"
-#include "nsIInputStream.h"
 
 class nsParser;
 
 class nsReadEndCondition {
 public:
   const PRUnichar *mChars;
   PRUnichar mFilter;
   explicit nsReadEndCondition(const PRUnichar* aTerminateChars);
@@ -94,28 +93,16 @@ class nsScanner {
        *  @update  ftang 3/02/99
        *  @param   aCharset charset
        *  @param   aCharsetSource - where the charset info came from 
        *  @param   aMode represents the parser mode (nav, other)
        *  @return  
        */
       nsScanner(nsString& aFilename,PRBool aCreateStream, const nsACString& aCharset, PRInt32 aSource);
 
-      /**
-       *  Use this constructor if you want i/o to be stream based.
-       *
-       *  @update  ftang 3/02/99
-       *  @param   aCharset charset
-       *  @param   aCharsetSource - where the charset info came from 
-       *  @param   aMode represents the parser mode (nav, other)
-       *  @return  
-       */
-      nsScanner(const nsAString& aFilename, nsIInputStream* aStream, const nsACString& aCharset, PRInt32 aSource);
-
-
       ~nsScanner();
 
       /**
        *  retrieve next char from internal input stream
        *  
        *  @update  gess 3/25/98
        *  @param   ch is the char to accept new value
        *  @return  error code reflecting read status
@@ -130,52 +117,25 @@ class nsScanner {
        *  @param   ch is the char to accept new value
        *  @return  error code reflecting read status
        */
       nsresult Peek(PRUnichar& ch, PRUint32 aOffset=0);
 
       nsresult Peek(nsAString& aStr, PRInt32 aNumChars, PRInt32 aOffset = 0);
 
       /**
-       *  Skip over chars as long as they're in aSkipSet
-       *  
-       *  @update  gess 3/25/98
-       *  @param   set of chars to be skipped
-       *  @return  error code
-       */
-      nsresult SkipOver(nsString& SkipChars);
-
-      /**
        *  Skip over chars as long as they equal given char
        *  
        *  @update  gess 3/25/98
        *  @param   char to be skipped
        *  @return  error code
        */
       nsresult SkipOver(PRUnichar aSkipChar);
 
       /**
-       *  Skip over chars until they're in aValidSet
-       *  
-       *  @update  gess 3/25/98
-       *  @param   aValid set contains chars you're looking for
-       *  @return  error code
-       */
-      nsresult SkipTo(nsString& aValidSet);
-
-      /**
-       *  Skip over chars as long as they're in aSequence
-       *  
-       *  @update  gess 3/25/98
-       *  @param   contains sequence to be skipped
-       *  @return  error code
-       */
-      nsresult SkipPast(nsString& aSequence);
-
-      /**
        *  Skip whitespace on scanner input stream
        *  
        *  @update  gess 3/25/98
        *  @return  error status
        */
       nsresult SkipWhitespace(PRInt32& aNewlinesSkipped);
 
       /**
@@ -233,28 +193,16 @@ class nsScanner {
                          const nsReadEndCondition& aEndCondition,
                          PRBool addTerminal);
 
       nsresult ReadUntil(nsScannerIterator& aStart,
                          nsScannerIterator& aEnd,
                          const nsReadEndCondition& aEndCondition, 
                          PRBool addTerminal);
 
-
-      /**
-       *  Consume characters while they're members of anInputSet
-       *  
-       *  @update  gess 3/25/98
-       *  @param   aString receives new data from stream
-       *  @param   anInputSet contains valid chars
-       *  @param   addTerminal tells us whether to append terminal to aString
-       *  @return  error code
-       */
-      nsresult ReadWhile(nsString& aString,nsString& anInputSet,PRBool addTerminal);
-
       /**
        *  Records current offset position in input stream. This allows us
        *  to back up to this point if the need should arise, such as when
        *  tokenization gets interrupted.
        *  
        *  @update  gess 5/12/98
        *  @param   
        *  @return  
@@ -362,46 +310,31 @@ class nsScanner {
         return mFirstNonWhitespacePosition;
       }
 
       void SetParser(nsParser *aParser)
       {
         mParser = aParser;
       }
 
-
-      /**
-       * Fill internal buffer with new data, returns an error if
-       * no new data is read.
-       *
-       * @update  gess4/3/98
-       */
-      nsresult FillBuffer(void);
-
   protected:
 
-      enum {eBufferSizeThreshold=0x1000};  //4K
-
       void AppendToBuffer(nsScannerString::Buffer *, nsIRequest *aRequest);
       void AppendToBuffer(const nsAString& aStr)
       {
         AppendToBuffer(nsScannerString::AllocBufferFromString(aStr), nsnull);
       }
-      void AppendASCIItoBuffer(const char* aData, PRUint32 aLen,
-                               nsIRequest *aRequest);
 
-      nsCOMPtr<nsIInputStream>     mInputStream;
       nsScannerString*             mSlidingBuffer;
       nsScannerIterator            mCurrentPosition; // The position we will next read from in the scanner buffer
       nsScannerIterator            mMarkPosition;    // The position last marked (we may rewind to here)
       nsScannerIterator            mEndPosition;     // The current end of the scanner buffer
       nsString        mFilename;
       PRUint32        mCountRemaining; // The number of bytes still to be read
                                        // from the scanner buffer
-      PRUint32        mTotalRead;
       PRPackedBool    mIncremental;
       PRInt32         mFirstNonWhitespacePosition;
       PRInt32         mCharsetSource;
       nsCString       mCharset;
       nsIUnicodeDecoder *mUnicodeDecoder;
       nsParser        *mParser;
 };