xslt-stack-objects
author Benjamin Smedberg <benjamin@smedbergs.us>
Sat, 26 Jul 2008 22:49:39 -0400
changeset 167 a4da40849f5436e629c5732f4368c6c48189637f
parent 137 5861968fe0b97c85e06eec5f472320db6c4e6877
permissions -rw-r--r--
State as of now

diff --git a/content/xslt/src/xpath/nsXPathExpression.h b/content/xslt/src/xpath/nsXPathExpression.h
--- a/content/xslt/src/xpath/nsXPathExpression.h
+++ b/content/xslt/src/xpath/nsXPathExpression.h
@@ -52,7 +52,8 @@ class txXPathNode;
 /**
  * A class for evaluating an XPath expression string
  */
-class nsXPathExpression : public nsIDOMXPathExpression,
+class nsXPathExpression : public XPCOMGCFinalizedObject,
+                          public nsIDOMXPathExpression,
                           public nsIDOMNSXPathExpression
 {
 public:
@@ -75,7 +76,9 @@ private:
     nsRefPtr<txResultRecycler> mRecycler;
     nsCOMPtr<nsIDOMDocument> mDocument;
 
-    class EvalContextImpl : public txIEvalContext
+    class
+        NS_STACK_CLASS
+    EvalContextImpl : public txIEvalContext
     {
     public:
         EvalContextImpl(const txXPathNode& aContextNode,
@@ -101,7 +104,7 @@ private:
         PRUint32 mContextPosition;
         PRUint32 mContextSize;
         nsresult mLastError;
-        nsRefPtr<txResultRecycler> mRecycler;
+        txResultRecycler* mRecycler;
     };
 };
 
diff --git a/content/xslt/src/xpath/txPathExpr.cpp b/content/xslt/src/xpath/txPathExpr.cpp
--- a/content/xslt/src/xpath/txPathExpr.cpp
+++ b/content/xslt/src/xpath/txPathExpr.cpp
@@ -107,7 +107,7 @@ PathExpr::evaluate(txIEvalContext* aCont
     for (i = 1; i < len; ++i) {
         PathExprItem& pxi = mItems[i];
         nsRefPtr<txNodeSet> tmpNodes;
-        txNodeSetContext eContext(nodes, aContext);
+        txNodeSetContext &eContext = *new txNodeSetContext(nodes, aContext);
         while (eContext.hasNext()) {
             eContext.next();
 
diff --git a/content/xslt/src/xpath/txPredicateList.cpp b/content/xslt/src/xpath/txPredicateList.cpp
--- a/content/xslt/src/xpath/txPredicateList.cpp
+++ b/content/xslt/src/xpath/txPredicateList.cpp
@@ -54,7 +54,7 @@ PredicateList::evaluatePredicates(txNode
 
     PRUint32 i, len = mPredicates.Length();
     for (i = 0; i < len && !nodes->isEmpty(); ++i) {
-        txNodeSetContext predContext(nodes, aContext);
+        txNodeSetContext &predContext = *new txNodeSetContext(nodes, aContext);
         /*
          * add nodes to newNodes that match the expression
          * or, if the result is a number, add the node with the right
diff --git a/content/xslt/src/xpath/txRelationalExpr.cpp b/content/xslt/src/xpath/txRelationalExpr.cpp
--- a/content/xslt/src/xpath/txRelationalExpr.cpp
+++ b/content/xslt/src/xpath/txRelationalExpr.cpp
@@ -57,7 +57,8 @@ RelationalExpr::compareResults(txIEvalCo
     // Handle case for just Left NodeSet or Both NodeSets
     if (ltype == txAExprResult::NODESET) {
         if (rtype == txAExprResult::BOOLEAN) {
-            BooleanResult leftBool(aLeft->booleanValue());
+            BooleanResult &leftBool =
+                *new BooleanResult(aLeft->booleanValue());
             return compareResults(aContext, &leftBool, aRight);
         }
 
@@ -82,7 +83,8 @@ RelationalExpr::compareResults(txIEvalCo
     // Handle case for Just Right NodeSet
     if (rtype == txAExprResult::NODESET) {
         if (ltype == txAExprResult::BOOLEAN) {
-            BooleanResult rightBool(aRight->booleanValue());
+            BooleanResult &rightBool =
+                *new BooleanResult(aRight->booleanValue());
             return compareResults(aContext, aLeft, &rightBool);
         }
 
diff --git a/content/xslt/src/xslt/txEXSLTFunctions.cpp b/content/xslt/src/xslt/txEXSLTFunctions.cpp
--- a/content/xslt/src/xslt/txEXSLTFunctions.cpp
+++ b/content/xslt/src/xslt/txEXSLTFunctions.cpp
@@ -86,7 +86,8 @@ convertRtfToNode(txIEvalContext *aContex
     NS_ENSURE_SUCCESS(rv, rv);
 
     txOutputFormat format;
-    txMozillaXMLOutput mozHandler(&format, domFragment, PR_TRUE);
+    txMozillaXMLOutput &mozHandler =
+        *new txMozillaXMLOutput(&format, domFragment, PR_TRUE);
 
     txAXMLEventHandler* handler = &mozHandler;
     rv = aRtf->flushToHandler(&handler);
diff --git a/content/xslt/src/xslt/txMozillaXSLTProcessor.cpp b/content/xslt/src/xslt/txMozillaXSLTProcessor.cpp
--- a/content/xslt/src/xslt/txMozillaXSLTProcessor.cpp
+++ b/content/xslt/src/xslt/txMozillaXSLTProcessor.cpp
@@ -652,13 +652,15 @@ txMozillaXSLTProcessor::TransformToDoc(n
         sourceDOMDocument = do_QueryInterface(mSource);
     }
 
-    txExecutionState es(mStylesheet, IsLoadDisabled());
+    txExecutionState &es =
+        *new txExecutionState(mStylesheet, IsLoadDisabled());
 
     // XXX Need to add error observers
 
-    txToDocHandlerFactory handlerFactory(&es, sourceDOMDocument, aOutputDoc,
-                                         mObserver);
-    es.mOutputHandlerFactory = &handlerFactory;
+    es.mOutputHandlerFactory =
+        new txToDocHandlerFactory(&es, sourceDOMDocument, aOutputDoc,
+                                  mObserver);
+
 
     es.init(*sourceNode, &mVariables);
 
@@ -708,14 +710,14 @@ txMozillaXSLTProcessor::TransformToFragm
         return NS_ERROR_OUT_OF_MEMORY;
     }
 
-    txExecutionState es(mStylesheet, IsLoadDisabled());
+    txExecutionState &es =
+        *new txExecutionState(mStylesheet, IsLoadDisabled());
 
     // XXX Need to add error observers
 
     rv = aOutput->CreateDocumentFragment(aResult);
     NS_ENSURE_SUCCESS(rv, rv);
-    txToFragmentHandlerFactory handlerFactory(*aResult);
-    es.mOutputHandlerFactory = &handlerFactory;
+    es.mOutputHandlerFactory = new txToFragmentHandlerFactory(*aResult);
 
     es.init(*sourceNode, &mVariables);
 
diff --git a/content/xslt/src/xslt/txXSLTPatterns.cpp b/content/xslt/src/xslt/txXSLTPatterns.cpp
--- a/content/xslt/src/xslt/txXSLTPatterns.cpp
+++ b/content/xslt/src/xslt/txXSLTPatterns.cpp
@@ -477,7 +477,7 @@ MBool txStepPattern::matches(const txXPa
     for (i = 1; i < predLen; ++i) {
         newNodes->clear();
         MBool contextIsInPredicate = MB_FALSE;
-        txNodeSetContext predContext(nodes, aContext);
+        txNodeSetContext &predContext = *new txNodeSetContext(nodes, aContext);
         while (predContext.hasNext()) {
             predContext.next();
             nsRefPtr<txAExprResult> exprResult;
@@ -513,7 +513,8 @@ MBool txStepPattern::matches(const txXPa
         }
         predicate = mPredicates[i];
     }
-    txForwardContext evalContext(aContext, aNode, nodes);
+    txForwardContext &evalContext =
+        *new txForwardContext(aContext, aNode, nodes);
     nsRefPtr<txAExprResult> exprResult;
     rv = predicate->evaluate(&evalContext, getter_AddRefs(exprResult));
     NS_ENSURE_SUCCESS(rv, PR_FALSE);