Bug 186979: Start transformation at actual node passed in.

r=Pike sr=peterv a=asa


git-svn-id: svn://10.0.0.236/trunk@137027 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
sicking%bigfoot.com 2003-01-28 15:21:52 +00:00
parent faaade74cb
commit 3bbbb03a41
3 changed files with 36 additions and 24 deletions

View File

@ -50,14 +50,14 @@
DHASH_WRAPPER(txLoadedDocumentsBase, txLoadedDocumentEntry, nsAString&) DHASH_WRAPPER(txLoadedDocumentsBase, txLoadedDocumentEntry, nsAString&)
txLoadedDocumentsHash::txLoadedDocumentsHash(Document* aSourceDocument, nsresult txLoadedDocumentsHash::init(Document* aSourceDocument,
Document* aStyleDocument) Document* aStyleDocument)
: mSourceDocument(aSourceDocument),
mStyleDocument(aStyleDocument)
{ {
if (NS_FAILED(Init(8))) { nsresult rv = Init(8);
return; NS_ENSURE_SUCCESS(rv, rv);
}
mSourceDocument = aSourceDocument;
mStyleDocument = aStyleDocument;
if (mSourceDocument) { if (mSourceDocument) {
Add(mSourceDocument); Add(mSourceDocument);
@ -122,22 +122,30 @@ Document* txLoadedDocumentsHash::Get(const nsAString& aURI)
/** /**
* Creates a new ProcessorState for the given XSL document * Creates a new ProcessorState for the given XSL document
**/ **/
ProcessorState::ProcessorState(Document* aSourceDocument, ProcessorState::ProcessorState(Node* aSourceNode, Document* aXslDocument)
Document* aXslDocument)
: mOutputHandler(0), : mOutputHandler(0),
mResultHandler(0), mResultHandler(0),
mOutputHandlerFactory(0), mOutputHandlerFactory(0),
mLoadedDocuments(aSourceDocument, aXslDocument),
mXslKeys(MB_TRUE), mXslKeys(MB_TRUE),
mDecimalFormats(MB_TRUE), mDecimalFormats(MB_TRUE),
mEvalContext(0), mEvalContext(0),
mLocalVariables(0), mLocalVariables(0),
mGlobalVariableValues(MB_TRUE), mGlobalVariableValues(MB_TRUE),
mRTFDocument(0) mRTFDocument(0),
mSourceNode(aSourceNode)
{ {
NS_ASSERTION(aSourceDocument, "missing source document"); NS_ASSERTION(aSourceNode, "missing source node");
NS_ASSERTION(aXslDocument, "missing xslt document"); NS_ASSERTION(aXslDocument, "missing xslt document");
Document* sourceDoc;
if (mSourceNode->getNodeType() == Node::DOCUMENT_NODE) {
sourceDoc = (Document*)mSourceNode;
}
else {
sourceDoc = mSourceNode->getOwnerDocument();
}
mLoadedDocuments.init(sourceDoc, aXslDocument);
/* turn object deletion on for some of the Maps (NamedMap) */ /* turn object deletion on for some of the Maps (NamedMap) */
mExprHashes[SelectAttr].setOwnership(Map::eOwnsItems); mExprHashes[SelectAttr].setOwnership(Map::eOwnsItems);
mExprHashes[TestAttr].setOwnership(Map::eOwnsItems); mExprHashes[TestAttr].setOwnership(Map::eOwnsItems);
@ -1068,7 +1076,7 @@ nsresult ProcessorState::getVariable(PRInt32 aNamespace, nsIAtom* aLName,
// Set up the state we have at the beginning of the transformation // Set up the state we have at the beginning of the transformation
txVariableMap *oldVars = mLocalVariables; txVariableMap *oldVars = mLocalVariables;
mLocalVariables = 0; mLocalVariables = 0;
txSingleNodeContext evalContext(mLoadedDocuments.mSourceDocument, this); txSingleNodeContext evalContext(mSourceNode, this);
txIEvalContext* priorEC = setEvalContext(&evalContext); txIEvalContext* priorEC = setEvalContext(&evalContext);
// Compute the variable value // Compute the variable value
globVar->mFlags = GlobalVariableValue::evaluating; globVar->mFlags = GlobalVariableValue::evaluating;

View File

@ -62,8 +62,8 @@ DECL_DHASH_WRAPPER(txLoadedDocumentsBase, txLoadedDocumentEntry, nsAString&)
class txLoadedDocumentsHash : public txLoadedDocumentsBase class txLoadedDocumentsHash : public txLoadedDocumentsBase
{ {
public: public:
txLoadedDocumentsHash(Document* aSourceDocument, Document* aStyleDocument);
~txLoadedDocumentsHash(); ~txLoadedDocumentsHash();
nsresult init(Document* aSourceDocument, Document* aStyleDocument);
void Add(Document* aDocument); void Add(Document* aDocument);
Document* Get(const nsAString& aURI); Document* Get(const nsAString& aURI);
@ -83,8 +83,7 @@ public:
* Creates a new ProcessorState for the given XSL document * Creates a new ProcessorState for the given XSL document
* And result Document * And result Document
*/ */
ProcessorState(Document* aSourceDocument, ProcessorState(Node* aSourceNode, Document* aXslDocument);
Document* aXslDocument);
/** /**
* Destroys this ProcessorState * Destroys this ProcessorState
@ -498,6 +497,11 @@ private:
* Document used to create RTFs * Document used to create RTFs
*/ */
Document* mRTFDocument; Document* mRTFDocument;
/**
* Source-node where processing started
*/
Node* mSourceNode;
}; };
/** /**

View File

@ -281,12 +281,12 @@ txMozillaXSLTProcessor::TransformDocument(nsIDOMNode* aSourceDOM,
// Create a new ProcessorState. Must be done after creating the documents // Create a new ProcessorState. Must be done after creating the documents
// so that C++ will ensure that it is destroyed before the documents. // so that C++ will ensure that it is destroyed before the documents.
ProcessorState ps(&sourceDocument, &xslDocument); ProcessorState ps(sourceNode, &xslDocument);
// XXX Need to add error observers // XXX Need to add error observers
// Set current txIEvalContext // Set current txIEvalContext
txSingleNodeContext evalContext(&sourceDocument, &ps); txSingleNodeContext evalContext(sourceNode, &ps);
ps.setEvalContext(&evalContext); ps.setEvalContext(&evalContext);
// Index templates and process top level xslt elements // Index templates and process top level xslt elements
@ -348,12 +348,12 @@ txMozillaXSLTProcessor::TransformDocument(nsIDOMNode* aSourceDOM,
// Create a new ProcessorState. Must be done after creating the documents // Create a new ProcessorState. Must be done after creating the documents
// so that C++ will ensure that it is destroyed before the documents. // so that C++ will ensure that it is destroyed before the documents.
ProcessorState ps(&sourceDocument, &xslDocument); ProcessorState ps(sourceNode, &xslDocument);
// XXX Need to add error observers // XXX Need to add error observers
// Set current txIEvalContext // Set current txIEvalContext
txSingleNodeContext evalContext(&sourceDocument, &ps); txSingleNodeContext evalContext(sourceNode, &ps);
ps.setEvalContext(&evalContext); ps.setEvalContext(&evalContext);
// Index templates and process top level xslt elements // Index templates and process top level xslt elements
@ -444,12 +444,12 @@ txMozillaXSLTProcessor::TransformToDocument(nsIDOMNode *aSource,
// Create a new ProcessorState. Must be done after creating the documents // Create a new ProcessorState. Must be done after creating the documents
// so that C++ will ensure that it is destroyed before the documents. // so that C++ will ensure that it is destroyed before the documents.
ProcessorState ps(&sourceDocument, &xslDocument); ProcessorState ps(sourceNode, &xslDocument);
// XXX Need to add error observers // XXX Need to add error observers
// Set current txIEvalContext // Set current txIEvalContext
txSingleNodeContext evalContext(&sourceDocument, &ps); txSingleNodeContext evalContext(sourceNode, &ps);
ps.setEvalContext(&evalContext); ps.setEvalContext(&evalContext);
// Index templates and process top level xslt elements // Index templates and process top level xslt elements
@ -512,12 +512,12 @@ txMozillaXSLTProcessor::TransformToFragment(nsIDOMNode *aSource,
// Create a new ProcessorState. Must be done after creating the documents // Create a new ProcessorState. Must be done after creating the documents
// so that C++ will ensure that it is destroyed before the documents. // so that C++ will ensure that it is destroyed before the documents.
ProcessorState ps(&sourceDocument, &xslDocument); ProcessorState ps(sourceNode, &xslDocument);
// XXX Need to add error observers // XXX Need to add error observers
// Set current txIEvalContext // Set current txIEvalContext
txSingleNodeContext evalContext(&sourceDocument, &ps); txSingleNodeContext evalContext(sourceNode, &ps);
ps.setEvalContext(&evalContext); ps.setEvalContext(&evalContext);
// Index templates and process top level xslt elements // Index templates and process top level xslt elements