mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-25 13:51:41 +00:00
Bug 812744 part 1. Set XSLT result documents to be data documents when we plan to return them to script. r=sicking
This commit is contained in:
parent
26b63d0f22
commit
07cd537a7d
@ -2060,10 +2060,10 @@ private:
|
|||||||
|
|
||||||
// XXX These belong somewhere else
|
// XXX These belong somewhere else
|
||||||
nsresult
|
nsresult
|
||||||
NS_NewHTMLDocument(nsIDocument** aInstancePtrResult);
|
NS_NewHTMLDocument(nsIDocument** aInstancePtrResult, bool aLoadedAsData = false);
|
||||||
|
|
||||||
nsresult
|
nsresult
|
||||||
NS_NewXMLDocument(nsIDocument** aInstancePtrResult);
|
NS_NewXMLDocument(nsIDocument** aInstancePtrResult, bool aLoadedAsData = false);
|
||||||
|
|
||||||
nsresult
|
nsresult
|
||||||
NS_NewSVGDocument(nsIDocument** aInstancePtrResult);
|
NS_NewSVGDocument(nsIDocument** aInstancePtrResult);
|
||||||
|
@ -172,7 +172,7 @@ RemoveFromAgentSheets(nsCOMArray<nsIStyleSheet> &aAgentSheets, const nsAString&
|
|||||||
}
|
}
|
||||||
|
|
||||||
nsresult
|
nsresult
|
||||||
NS_NewHTMLDocument(nsIDocument** aInstancePtrResult)
|
NS_NewHTMLDocument(nsIDocument** aInstancePtrResult, bool aLoadedAsData)
|
||||||
{
|
{
|
||||||
nsHTMLDocument* doc = new nsHTMLDocument();
|
nsHTMLDocument* doc = new nsHTMLDocument();
|
||||||
NS_ENSURE_TRUE(doc, NS_ERROR_OUT_OF_MEMORY);
|
NS_ENSURE_TRUE(doc, NS_ERROR_OUT_OF_MEMORY);
|
||||||
@ -185,6 +185,7 @@ NS_NewHTMLDocument(nsIDocument** aInstancePtrResult)
|
|||||||
}
|
}
|
||||||
|
|
||||||
*aInstancePtrResult = doc;
|
*aInstancePtrResult = doc;
|
||||||
|
doc->SetLoadedAsData(aLoadedAsData);
|
||||||
|
|
||||||
return rv;
|
return rv;
|
||||||
}
|
}
|
||||||
|
@ -168,7 +168,7 @@ NS_NewDOMDocument(nsIDOMDocument** aInstancePtrResult,
|
|||||||
|
|
||||||
|
|
||||||
nsresult
|
nsresult
|
||||||
NS_NewXMLDocument(nsIDocument** aInstancePtrResult)
|
NS_NewXMLDocument(nsIDocument** aInstancePtrResult, bool aLoadedAsData)
|
||||||
{
|
{
|
||||||
nsXMLDocument* doc = new nsXMLDocument();
|
nsXMLDocument* doc = new nsXMLDocument();
|
||||||
NS_ENSURE_TRUE(doc, NS_ERROR_OUT_OF_MEMORY);
|
NS_ENSURE_TRUE(doc, NS_ERROR_OUT_OF_MEMORY);
|
||||||
@ -181,6 +181,7 @@ NS_NewXMLDocument(nsIDocument** aInstancePtrResult)
|
|||||||
}
|
}
|
||||||
|
|
||||||
*aInstancePtrResult = doc;
|
*aInstancePtrResult = doc;
|
||||||
|
doc->SetLoadedAsData(aLoadedAsData);
|
||||||
|
|
||||||
return rv;
|
return rv;
|
||||||
}
|
}
|
||||||
|
@ -113,7 +113,8 @@ txMozillaTextOutput::startDocument()
|
|||||||
}
|
}
|
||||||
|
|
||||||
nsresult
|
nsresult
|
||||||
txMozillaTextOutput::createResultDocument(nsIDOMDocument* aSourceDocument)
|
txMozillaTextOutput::createResultDocument(nsIDOMDocument* aSourceDocument,
|
||||||
|
bool aLoadedAsData)
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
* Create an XHTML document to hold the text.
|
* Create an XHTML document to hold the text.
|
||||||
@ -132,7 +133,8 @@ txMozillaTextOutput::createResultDocument(nsIDOMDocument* aSourceDocument)
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
// Create the document
|
// Create the document
|
||||||
nsresult rv = NS_NewXMLDocument(getter_AddRefs(mDocument));
|
nsresult rv = NS_NewXMLDocument(getter_AddRefs(mDocument),
|
||||||
|
aLoadedAsData);
|
||||||
NS_ENSURE_SUCCESS(rv, rv);
|
NS_ENSURE_SUCCESS(rv, rv);
|
||||||
nsCOMPtr<nsIDocument> source = do_QueryInterface(aSourceDocument);
|
nsCOMPtr<nsIDocument> source = do_QueryInterface(aSourceDocument);
|
||||||
NS_ENSURE_STATE(source);
|
NS_ENSURE_STATE(source);
|
||||||
|
@ -28,7 +28,8 @@ public:
|
|||||||
TX_DECL_TXAXMLEVENTHANDLER
|
TX_DECL_TXAXMLEVENTHANDLER
|
||||||
TX_DECL_TXAOUTPUTXMLEVENTHANDLER
|
TX_DECL_TXAOUTPUTXMLEVENTHANDLER
|
||||||
|
|
||||||
nsresult createResultDocument(nsIDOMDocument* aSourceDocument);
|
nsresult createResultDocument(nsIDOMDocument* aSourceDocument,
|
||||||
|
bool aLoadedAsData);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
nsresult createXHTMLElement(nsIAtom* aName, nsIContent** aResult);
|
nsresult createXHTMLElement(nsIAtom* aName, nsIContent** aResult);
|
||||||
|
@ -791,19 +791,22 @@ void txMozillaXMLOutput::processHTTPEquiv(nsIAtom* aHeader, const nsString& aVal
|
|||||||
|
|
||||||
nsresult
|
nsresult
|
||||||
txMozillaXMLOutput::createResultDocument(const nsSubstring& aName, int32_t aNsID,
|
txMozillaXMLOutput::createResultDocument(const nsSubstring& aName, int32_t aNsID,
|
||||||
nsIDOMDocument* aSourceDocument)
|
nsIDOMDocument* aSourceDocument,
|
||||||
|
bool aLoadedAsData)
|
||||||
{
|
{
|
||||||
nsresult rv;
|
nsresult rv;
|
||||||
|
|
||||||
// Create the document
|
// Create the document
|
||||||
if (mOutputFormat.mMethod == eHTMLOutput) {
|
if (mOutputFormat.mMethod == eHTMLOutput) {
|
||||||
rv = NS_NewHTMLDocument(getter_AddRefs(mDocument));
|
rv = NS_NewHTMLDocument(getter_AddRefs(mDocument),
|
||||||
|
aLoadedAsData);
|
||||||
NS_ENSURE_SUCCESS(rv, rv);
|
NS_ENSURE_SUCCESS(rv, rv);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
// We should check the root name/namespace here and create the
|
// We should check the root name/namespace here and create the
|
||||||
// appropriate document
|
// appropriate document
|
||||||
rv = NS_NewXMLDocument(getter_AddRefs(mDocument));
|
rv = NS_NewXMLDocument(getter_AddRefs(mDocument),
|
||||||
|
aLoadedAsData);
|
||||||
NS_ENSURE_SUCCESS(rv, rv);
|
NS_ENSURE_SUCCESS(rv, rv);
|
||||||
}
|
}
|
||||||
// This should really be handled by nsIDocument::BeginLoad
|
// This should really be handled by nsIDocument::BeginLoad
|
||||||
|
@ -74,7 +74,8 @@ public:
|
|||||||
nsresult closePrevious(bool aFlushText);
|
nsresult closePrevious(bool aFlushText);
|
||||||
|
|
||||||
nsresult createResultDocument(const nsSubstring& aName, int32_t aNsID,
|
nsresult createResultDocument(const nsSubstring& aName, int32_t aNsID,
|
||||||
nsIDOMDocument* aSourceDocument);
|
nsIDOMDocument* aSourceDocument,
|
||||||
|
bool aLoadedAsData);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
nsresult createTxWrapper();
|
nsresult createTxWrapper();
|
||||||
|
@ -48,8 +48,10 @@ class txToDocHandlerFactory : public txAOutputHandlerFactory
|
|||||||
public:
|
public:
|
||||||
txToDocHandlerFactory(txExecutionState* aEs,
|
txToDocHandlerFactory(txExecutionState* aEs,
|
||||||
nsIDOMDocument* aSourceDocument,
|
nsIDOMDocument* aSourceDocument,
|
||||||
nsITransformObserver* aObserver)
|
nsITransformObserver* aObserver,
|
||||||
: mEs(aEs), mSourceDocument(aSourceDocument), mObserver(aObserver)
|
bool aDocumentIsData)
|
||||||
|
: mEs(aEs), mSourceDocument(aSourceDocument), mObserver(aObserver),
|
||||||
|
mDocumentIsData(aDocumentIsData)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -59,6 +61,7 @@ private:
|
|||||||
txExecutionState* mEs;
|
txExecutionState* mEs;
|
||||||
nsCOMPtr<nsIDOMDocument> mSourceDocument;
|
nsCOMPtr<nsIDOMDocument> mSourceDocument;
|
||||||
nsCOMPtr<nsITransformObserver> mObserver;
|
nsCOMPtr<nsITransformObserver> mObserver;
|
||||||
|
bool mDocumentIsData;
|
||||||
};
|
};
|
||||||
|
|
||||||
class txToFragmentHandlerFactory : public txAOutputHandlerFactory
|
class txToFragmentHandlerFactory : public txAOutputHandlerFactory
|
||||||
@ -95,7 +98,8 @@ txToDocHandlerFactory::createHandlerWith(txOutputFormat* aFormat,
|
|||||||
|
|
||||||
nsresult rv = handler->createResultDocument(EmptyString(),
|
nsresult rv = handler->createResultDocument(EmptyString(),
|
||||||
kNameSpaceID_None,
|
kNameSpaceID_None,
|
||||||
mSourceDocument);
|
mSourceDocument,
|
||||||
|
mDocumentIsData);
|
||||||
if (NS_SUCCEEDED(rv)) {
|
if (NS_SUCCEEDED(rv)) {
|
||||||
*aHandler = handler.forget();
|
*aHandler = handler.forget();
|
||||||
}
|
}
|
||||||
@ -108,7 +112,8 @@ txToDocHandlerFactory::createHandlerWith(txOutputFormat* aFormat,
|
|||||||
nsAutoPtr<txMozillaTextOutput> handler(
|
nsAutoPtr<txMozillaTextOutput> handler(
|
||||||
new txMozillaTextOutput(mObserver));
|
new txMozillaTextOutput(mObserver));
|
||||||
|
|
||||||
nsresult rv = handler->createResultDocument(mSourceDocument);
|
nsresult rv = handler->createResultDocument(mSourceDocument,
|
||||||
|
mDocumentIsData);
|
||||||
if (NS_SUCCEEDED(rv)) {
|
if (NS_SUCCEEDED(rv)) {
|
||||||
*aHandler = handler.forget();
|
*aHandler = handler.forget();
|
||||||
}
|
}
|
||||||
@ -143,7 +148,8 @@ txToDocHandlerFactory::createHandlerWith(txOutputFormat* aFormat,
|
|||||||
new txMozillaXMLOutput(aFormat, mObserver));
|
new txMozillaXMLOutput(aFormat, mObserver));
|
||||||
|
|
||||||
nsresult rv = handler->createResultDocument(aName, aNsID,
|
nsresult rv = handler->createResultDocument(aName, aNsID,
|
||||||
mSourceDocument);
|
mSourceDocument,
|
||||||
|
mDocumentIsData);
|
||||||
if (NS_SUCCEEDED(rv)) {
|
if (NS_SUCCEEDED(rv)) {
|
||||||
*aHandler = handler.forget();
|
*aHandler = handler.forget();
|
||||||
}
|
}
|
||||||
@ -156,7 +162,8 @@ txToDocHandlerFactory::createHandlerWith(txOutputFormat* aFormat,
|
|||||||
nsAutoPtr<txMozillaTextOutput> handler(
|
nsAutoPtr<txMozillaTextOutput> handler(
|
||||||
new txMozillaTextOutput(mObserver));
|
new txMozillaTextOutput(mObserver));
|
||||||
|
|
||||||
nsresult rv = handler->createResultDocument(mSourceDocument);
|
nsresult rv = handler->createResultDocument(mSourceDocument,
|
||||||
|
mDocumentIsData);
|
||||||
if (NS_SUCCEEDED(rv)) {
|
if (NS_SUCCEEDED(rv)) {
|
||||||
*aHandler = handler.forget();
|
*aHandler = handler.forget();
|
||||||
}
|
}
|
||||||
@ -522,7 +529,7 @@ public:
|
|||||||
|
|
||||||
NS_IMETHOD Run()
|
NS_IMETHOD Run()
|
||||||
{
|
{
|
||||||
mProcessor->TransformToDoc(nullptr);
|
mProcessor->TransformToDoc(nullptr, false);
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@ -612,11 +619,12 @@ txMozillaXSLTProcessor::TransformToDocument(nsIDOMNode *aSource,
|
|||||||
|
|
||||||
mSource = aSource;
|
mSource = aSource;
|
||||||
|
|
||||||
return TransformToDoc(aResult);
|
return TransformToDoc(aResult, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
nsresult
|
nsresult
|
||||||
txMozillaXSLTProcessor::TransformToDoc(nsIDOMDocument **aResult)
|
txMozillaXSLTProcessor::TransformToDoc(nsIDOMDocument **aResult,
|
||||||
|
bool aCreateDataDocument)
|
||||||
{
|
{
|
||||||
nsAutoPtr<txXPathNode> sourceNode(txXPathNativeNode::createXPathNode(mSource));
|
nsAutoPtr<txXPathNode> sourceNode(txXPathNativeNode::createXPathNode(mSource));
|
||||||
if (!sourceNode) {
|
if (!sourceNode) {
|
||||||
@ -633,7 +641,9 @@ txMozillaXSLTProcessor::TransformToDoc(nsIDOMDocument **aResult)
|
|||||||
|
|
||||||
// XXX Need to add error observers
|
// XXX Need to add error observers
|
||||||
|
|
||||||
txToDocHandlerFactory handlerFactory(&es, sourceDOMDocument, mObserver);
|
// If aResult is non-null, we're a data document
|
||||||
|
txToDocHandlerFactory handlerFactory(&es, sourceDOMDocument, mObserver,
|
||||||
|
aCreateDataDocument);
|
||||||
es.mOutputHandlerFactory = &handlerFactory;
|
es.mOutputHandlerFactory = &handlerFactory;
|
||||||
|
|
||||||
nsresult rv = es.init(*sourceNode, &mVariables);
|
nsresult rv = es.init(*sourceNode, &mVariables);
|
||||||
|
@ -96,7 +96,8 @@ public:
|
|||||||
return mSource;
|
return mSource;
|
||||||
}
|
}
|
||||||
|
|
||||||
nsresult TransformToDoc(nsIDOMDocument **aResult);
|
nsresult TransformToDoc(nsIDOMDocument **aResult,
|
||||||
|
bool aCreateDataDocument);
|
||||||
|
|
||||||
bool IsLoadDisabled()
|
bool IsLoadDisabled()
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user