parser-gcobjects
author Benjamin Smedberg <benjamin@smedbergs.us>
Sat, 26 Jul 2008 22:49:39 -0400
changeset 167 a4da40849f5436e629c5732f4368c6c48189637f
parent 68 49c5ee4b50b4e29f7da5e637a83b47436455034d
permissions -rw-r--r--
State as of now

diff --git a/parser/htmlparser/src/CParserContext.cpp b/parser/htmlparser/src/CParserContext.cpp
--- a/parser/htmlparser/src/CParserContext.cpp
+++ b/parser/htmlparser/src/CParserContext.cpp
@@ -65,14 +65,7 @@ CParserContext::CParserContext(nsScanner
     mCopyUnused(aCopyUnused),
     mTransferBufferSize(eTransferBufferSize)
 { 
-  MOZ_COUNT_CTOR(CParserContext); 
 } 
-
-CParserContext::~CParserContext()
-{
-  // It's ok to simply ingore the PrevContext.
-  MOZ_COUNT_DTOR(CParserContext);
-}
 
 void
 CParserContext::SetMimeType(const nsACString& aMimeType)
diff --git a/parser/htmlparser/src/CParserContext.h b/parser/htmlparser/src/CParserContext.h
--- a/parser/htmlparser/src/CParserContext.h
+++ b/parser/htmlparser/src/CParserContext.h
@@ -59,7 +59,8 @@
  * data in a parsercontext. Hey, that what it's for!
  */
 
-class CParserContext {
+class CParserContext : public XPCOMGCObject
+{
 
 public:
 
@@ -74,8 +75,6 @@ public:
                     eAutoDetectResult aStatus=eUnknownDetect, 
                     PRBool aCopyUnused=PR_FALSE); 
     
-    ~CParserContext();
-
     nsresult GetTokenizer(PRInt32 aType,
                           nsIContentSink* aSink,
                           nsITokenizer*& aTokenizer);
diff --git a/parser/htmlparser/src/nsParser.cpp b/parser/htmlparser/src/nsParser.cpp
--- a/parser/htmlparser/src/nsParser.cpp
+++ b/parser/htmlparser/src/nsParser.cpp
@@ -276,12 +276,6 @@ nsParser::~nsParser()
     NS_WARNING("Extra parser contexts still on the parser stack");
   }
 #endif
-
-  while (mParserContext) {
-    CParserContext *pc = mParserContext->mPrevContext;
-    delete mParserContext;
-    mParserContext = pc;
-  }
 
   // It should not be possible for this flag to be set when we are getting
   // destroyed since this flag implies a pending nsParserContinueEvent, which
@@ -1071,7 +1065,7 @@ nsParser::Terminate(void)
     CParserContext *prev = mParserContext->mPrevContext;
     NS_ASSERTION(prev->mPrevContext || prev->mDTD, "How is there no root DTD?");
 
-    delete mParserContext;
+    NS_GetGC()->Free(mParserContext);
     mParserContext = prev;
   }
 
@@ -1663,7 +1657,7 @@ nsParser::ResumeParse(PRBool allowIterat
                   theContext->mScanner->CopyUnusedData(mUnusedInput);
                 }
 
-                delete theContext;
+                NS_GetGC()->Free(theContext);
               }
 
               result = mInternalState;