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:
parent
faaade74cb
commit
3bbbb03a41
@ -50,14 +50,14 @@
|
||||
|
||||
DHASH_WRAPPER(txLoadedDocumentsBase, txLoadedDocumentEntry, nsAString&)
|
||||
|
||||
txLoadedDocumentsHash::txLoadedDocumentsHash(Document* aSourceDocument,
|
||||
Document* aStyleDocument)
|
||||
: mSourceDocument(aSourceDocument),
|
||||
mStyleDocument(aStyleDocument)
|
||||
nsresult txLoadedDocumentsHash::init(Document* aSourceDocument,
|
||||
Document* aStyleDocument)
|
||||
{
|
||||
if (NS_FAILED(Init(8))) {
|
||||
return;
|
||||
}
|
||||
nsresult rv = Init(8);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
mSourceDocument = aSourceDocument;
|
||||
mStyleDocument = aStyleDocument;
|
||||
|
||||
if (mSourceDocument) {
|
||||
Add(mSourceDocument);
|
||||
@ -122,22 +122,30 @@ Document* txLoadedDocumentsHash::Get(const nsAString& aURI)
|
||||
/**
|
||||
* Creates a new ProcessorState for the given XSL document
|
||||
**/
|
||||
ProcessorState::ProcessorState(Document* aSourceDocument,
|
||||
Document* aXslDocument)
|
||||
ProcessorState::ProcessorState(Node* aSourceNode, Document* aXslDocument)
|
||||
: mOutputHandler(0),
|
||||
mResultHandler(0),
|
||||
mOutputHandlerFactory(0),
|
||||
mLoadedDocuments(aSourceDocument, aXslDocument),
|
||||
mXslKeys(MB_TRUE),
|
||||
mDecimalFormats(MB_TRUE),
|
||||
mEvalContext(0),
|
||||
mLocalVariables(0),
|
||||
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");
|
||||
|
||||
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) */
|
||||
mExprHashes[SelectAttr].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
|
||||
txVariableMap *oldVars = mLocalVariables;
|
||||
mLocalVariables = 0;
|
||||
txSingleNodeContext evalContext(mLoadedDocuments.mSourceDocument, this);
|
||||
txSingleNodeContext evalContext(mSourceNode, this);
|
||||
txIEvalContext* priorEC = setEvalContext(&evalContext);
|
||||
// Compute the variable value
|
||||
globVar->mFlags = GlobalVariableValue::evaluating;
|
||||
|
||||
@ -62,8 +62,8 @@ DECL_DHASH_WRAPPER(txLoadedDocumentsBase, txLoadedDocumentEntry, nsAString&)
|
||||
class txLoadedDocumentsHash : public txLoadedDocumentsBase
|
||||
{
|
||||
public:
|
||||
txLoadedDocumentsHash(Document* aSourceDocument, Document* aStyleDocument);
|
||||
~txLoadedDocumentsHash();
|
||||
nsresult init(Document* aSourceDocument, Document* aStyleDocument);
|
||||
void Add(Document* aDocument);
|
||||
Document* Get(const nsAString& aURI);
|
||||
|
||||
@ -83,8 +83,7 @@ public:
|
||||
* Creates a new ProcessorState for the given XSL document
|
||||
* And result Document
|
||||
*/
|
||||
ProcessorState(Document* aSourceDocument,
|
||||
Document* aXslDocument);
|
||||
ProcessorState(Node* aSourceNode, Document* aXslDocument);
|
||||
|
||||
/**
|
||||
* Destroys this ProcessorState
|
||||
@ -498,6 +497,11 @@ private:
|
||||
* Document used to create RTFs
|
||||
*/
|
||||
Document* mRTFDocument;
|
||||
|
||||
/**
|
||||
* Source-node where processing started
|
||||
*/
|
||||
Node* mSourceNode;
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
@ -281,12 +281,12 @@ txMozillaXSLTProcessor::TransformDocument(nsIDOMNode* aSourceDOM,
|
||||
|
||||
// Create a new ProcessorState. Must be done after creating 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
|
||||
|
||||
// Set current txIEvalContext
|
||||
txSingleNodeContext evalContext(&sourceDocument, &ps);
|
||||
txSingleNodeContext evalContext(sourceNode, &ps);
|
||||
ps.setEvalContext(&evalContext);
|
||||
|
||||
// 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
|
||||
// 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
|
||||
|
||||
// Set current txIEvalContext
|
||||
txSingleNodeContext evalContext(&sourceDocument, &ps);
|
||||
txSingleNodeContext evalContext(sourceNode, &ps);
|
||||
ps.setEvalContext(&evalContext);
|
||||
|
||||
// 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
|
||||
// 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
|
||||
|
||||
// Set current txIEvalContext
|
||||
txSingleNodeContext evalContext(&sourceDocument, &ps);
|
||||
txSingleNodeContext evalContext(sourceNode, &ps);
|
||||
ps.setEvalContext(&evalContext);
|
||||
|
||||
// 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
|
||||
// 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
|
||||
|
||||
// Set current txIEvalContext
|
||||
txSingleNodeContext evalContext(&sourceDocument, &ps);
|
||||
txSingleNodeContext evalContext(sourceNode, &ps);
|
||||
ps.setEvalContext(&evalContext);
|
||||
|
||||
// Index templates and process top level xslt elements
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user