Fix for bug 649534 (Remove nsIXSLTProcessorObsolete). r=sicking.

--HG--
extra : rebase_source : 48d37254b6f50ac74b285fb0f765c159877e7d03
This commit is contained in:
Peter Van der Beken 2011-04-08 10:50:51 -07:00
parent c39b2c4375
commit e9a0c2e1a1
10 changed files with 45 additions and 172 deletions

View File

@ -53,7 +53,6 @@ EXPORTS = \
XPIDLSRCS = \
nsIXSLTException.idl \
nsIXSLTProcessor.idl \
nsIXSLTProcessorObsolete.idl \
nsIXSLTProcessorPrivate.idl \
txIFunctionEvaluationContext.idl \
txINodeSet.idl \

View File

@ -1,57 +0,0 @@
/* -*- Mode: IDL; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 2002
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Nisheeth Ranjan <nisheeth@netscape.com> (original author)
* Peter Van der Beken <peterv@netscape.com>
*
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#include "nsISupports.idl"
interface nsIDOMNode;
interface nsIDOMDocument;
/**
* @deprecated Use nsIXSLTProcessor instead!!
*/
[deprecated, scriptable, uuid(3fbff728-2d20-11d3-aef3-00108300ff91)]
interface nsIXSLTProcessorObsolete : nsISupports
{
void transformDocument(in nsIDOMNode aSourceDOM,
in nsIDOMNode aStyleDOM,
in nsIDOMDocument aOutputDOC,
in nsISupports aObserver);
};

View File

@ -150,11 +150,8 @@ txMozillaTextOutput::startDocument()
}
nsresult
txMozillaTextOutput::createResultDocument(nsIDOMDocument* aSourceDocument,
nsIDOMDocument* aResultDocument)
txMozillaTextOutput::createResultDocument(nsIDOMDocument* aSourceDocument)
{
nsresult rv = NS_OK;
/*
* Create an XHTML document to hold the text.
*
@ -171,21 +168,16 @@ txMozillaTextOutput::createResultDocument(nsIDOMDocument* aSourceDocument,
* <transformiix:result> * The text comes here * </transformiix:result>
*/
if (!aResultDocument) {
// Create the document
rv = NS_NewXMLDocument(getter_AddRefs(mDocument));
NS_ENSURE_SUCCESS(rv, rv);
nsCOMPtr<nsIDocument> source = do_QueryInterface(aSourceDocument);
NS_ENSURE_STATE(source);
PRBool hasHadScriptObject = PR_FALSE;
nsIScriptGlobalObject* sgo =
source->GetScriptHandlingObject(hasHadScriptObject);
NS_ENSURE_STATE(sgo || !hasHadScriptObject);
mDocument->SetScriptHandlingObject(sgo);
}
else {
mDocument = do_QueryInterface(aResultDocument);
}
// Create the document
nsresult rv = NS_NewXMLDocument(getter_AddRefs(mDocument));
NS_ENSURE_SUCCESS(rv, rv);
nsCOMPtr<nsIDocument> source = do_QueryInterface(aSourceDocument);
NS_ENSURE_STATE(source);
PRBool hasHadScriptObject = PR_FALSE;
nsIScriptGlobalObject* sgo =
source->GetScriptHandlingObject(hasHadScriptObject);
NS_ENSURE_STATE(sgo || !hasHadScriptObject);
mDocument->SetScriptHandlingObject(sgo);
NS_ASSERTION(mDocument, "Need document");
@ -217,9 +209,7 @@ txMozillaTextOutput::createResultDocument(nsIDOMDocument* aSourceDocument,
// When transforming into a non-displayed document (i.e. when there is no
// observer) we only create a transformiix:result root element.
// Don't do this when called through nsIXSLTProcessorObsolete (i.e. when
// aResultDocument is set) for compability reasons
if (!aResultDocument && !observer) {
if (!observer) {
PRInt32 namespaceID;
rv = nsContentUtils::NameSpaceManager()->
RegisterNameSpace(NS_LITERAL_STRING(kTXNameSpaceURI), namespaceID);

View File

@ -61,8 +61,7 @@ public:
TX_DECL_TXAXMLEVENTHANDLER
TX_DECL_TXAOUTPUTXMLEVENTHANDLER
nsresult createResultDocument(nsIDOMDocument* aSourceDocument,
nsIDOMDocument* aResultDocument);
nsresult createResultDocument(nsIDOMDocument* aSourceDocument);
private:
nsresult createXHTMLElement(nsIAtom* aName, nsIContent** aResult);

View File

@ -821,36 +821,30 @@ void txMozillaXMLOutput::processHTTPEquiv(nsIAtom* aHeader, const nsString& aVal
nsresult
txMozillaXMLOutput::createResultDocument(const nsSubstring& aName, PRInt32 aNsID,
nsIDOMDocument* aSourceDocument,
nsIDOMDocument* aResultDocument)
nsIDOMDocument* aSourceDocument)
{
nsresult rv;
if (!aResultDocument) {
// Create the document
if (mOutputFormat.mMethod == eHTMLOutput) {
rv = NS_NewHTMLDocument(getter_AddRefs(mDocument));
NS_ENSURE_SUCCESS(rv, rv);
}
else {
// We should check the root name/namespace here and create the
// appropriate document
rv = NS_NewXMLDocument(getter_AddRefs(mDocument));
NS_ENSURE_SUCCESS(rv, rv);
}
// This should really be handled by nsIDocument::BeginLoad
mDocument->SetReadyStateInternal(nsIDocument::READYSTATE_LOADING);
nsCOMPtr<nsIDocument> source = do_QueryInterface(aSourceDocument);
NS_ENSURE_STATE(source);
PRBool hasHadScriptObject = PR_FALSE;
nsIScriptGlobalObject* sgo =
source->GetScriptHandlingObject(hasHadScriptObject);
NS_ENSURE_STATE(sgo || !hasHadScriptObject);
mDocument->SetScriptHandlingObject(sgo);
// Create the document
if (mOutputFormat.mMethod == eHTMLOutput) {
rv = NS_NewHTMLDocument(getter_AddRefs(mDocument));
NS_ENSURE_SUCCESS(rv, rv);
}
else {
mDocument = do_QueryInterface(aResultDocument);
// We should check the root name/namespace here and create the
// appropriate document
rv = NS_NewXMLDocument(getter_AddRefs(mDocument));
NS_ENSURE_SUCCESS(rv, rv);
}
// This should really be handled by nsIDocument::BeginLoad
mDocument->SetReadyStateInternal(nsIDocument::READYSTATE_LOADING);
nsCOMPtr<nsIDocument> source = do_QueryInterface(aSourceDocument);
NS_ENSURE_STATE(source);
PRBool hasHadScriptObject = PR_FALSE;
nsIScriptGlobalObject* sgo =
source->GetScriptHandlingObject(hasHadScriptObject);
NS_ENSURE_STATE(sgo || !hasHadScriptObject);
mDocument->SetScriptHandlingObject(sgo);
mCurrentNode = mDocument;
mNodeInfoManager = mDocument->NodeInfoManager();

View File

@ -106,8 +106,7 @@ public:
nsresult closePrevious(PRBool aFlushText);
nsresult createResultDocument(const nsSubstring& aName, PRInt32 aNsID,
nsIDOMDocument* aSourceDocument,
nsIDOMDocument* aResultDocument);
nsIDOMDocument* aSourceDocument);
private:
nsresult createTxWrapper();

View File

@ -81,10 +81,8 @@ class txToDocHandlerFactory : public txAOutputHandlerFactory
public:
txToDocHandlerFactory(txExecutionState* aEs,
nsIDOMDocument* aSourceDocument,
nsIDOMDocument* aResultDocument,
nsITransformObserver* aObserver)
: mEs(aEs), mSourceDocument(aSourceDocument),
mResultDocument(aResultDocument), mObserver(aObserver)
: mEs(aEs), mSourceDocument(aSourceDocument), mObserver(aObserver)
{
}
@ -93,7 +91,6 @@ public:
private:
txExecutionState* mEs;
nsCOMPtr<nsIDOMDocument> mSourceDocument;
nsCOMPtr<nsIDOMDocument> mResultDocument;
nsCOMPtr<nsITransformObserver> mObserver;
};
@ -131,8 +128,7 @@ txToDocHandlerFactory::createHandlerWith(txOutputFormat* aFormat,
nsresult rv = handler->createResultDocument(EmptyString(),
kNameSpaceID_None,
mSourceDocument,
mResultDocument);
mSourceDocument);
if (NS_SUCCEEDED(rv)) {
*aHandler = handler.forget();
}
@ -145,8 +141,7 @@ txToDocHandlerFactory::createHandlerWith(txOutputFormat* aFormat,
nsAutoPtr<txMozillaTextOutput> handler(
new txMozillaTextOutput(mObserver));
nsresult rv = handler->createResultDocument(mSourceDocument,
mResultDocument);
nsresult rv = handler->createResultDocument(mSourceDocument);
if (NS_SUCCEEDED(rv)) {
*aHandler = handler.forget();
}
@ -181,8 +176,7 @@ txToDocHandlerFactory::createHandlerWith(txOutputFormat* aFormat,
new txMozillaXMLOutput(aFormat, mObserver));
nsresult rv = handler->createResultDocument(aName, aNsID,
mSourceDocument,
mResultDocument);
mSourceDocument);
if (NS_SUCCEEDED(rv)) {
*aHandler = handler.forget();
}
@ -195,8 +189,7 @@ txToDocHandlerFactory::createHandlerWith(txOutputFormat* aFormat,
nsAutoPtr<txMozillaTextOutput> handler(
new txMozillaTextOutput(mObserver));
nsresult rv = handler->createResultDocument(mSourceDocument,
mResultDocument);
nsresult rv = handler->createResultDocument(mSourceDocument);
if (NS_SUCCEEDED(rv)) {
*aHandler = handler.forget();
}
@ -348,7 +341,6 @@ DOMCI_DATA(XSLTProcessor, txMozillaXSLTProcessor)
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(txMozillaXSLTProcessor)
NS_INTERFACE_MAP_ENTRY(nsIXSLTProcessor)
NS_INTERFACE_MAP_ENTRY(nsIXSLTProcessorObsolete)
NS_INTERFACE_MAP_ENTRY(nsIXSLTProcessorPrivate)
NS_INTERFACE_MAP_ENTRY(nsIDocumentTransformer)
NS_INTERFACE_MAP_ENTRY(nsIMutationObserver)
@ -371,39 +363,6 @@ txMozillaXSLTProcessor::~txMozillaXSLTProcessor()
}
}
NS_IMETHODIMP
txMozillaXSLTProcessor::TransformDocument(nsIDOMNode* aSourceDOM,
nsIDOMNode* aStyleDOM,
nsIDOMDocument* aOutputDoc,
nsISupports* aObserver)
{
NS_ENSURE_ARG(aSourceDOM);
NS_ENSURE_ARG(aStyleDOM);
NS_ENSURE_ARG(aOutputDoc);
NS_ENSURE_FALSE(aObserver, NS_ERROR_NOT_IMPLEMENTED);
if (!nsContentUtils::CanCallerAccess(aSourceDOM) ||
!nsContentUtils::CanCallerAccess(aStyleDOM) ||
!nsContentUtils::CanCallerAccess(aOutputDoc)) {
return NS_ERROR_DOM_SECURITY_ERR;
}
PRUint16 type = 0;
aStyleDOM->GetNodeType(&type);
NS_ENSURE_TRUE(type == nsIDOMNode::ELEMENT_NODE ||
type == nsIDOMNode::DOCUMENT_NODE,
NS_ERROR_INVALID_ARG);
nsCOMPtr<nsINode> styleNode = do_QueryInterface(aStyleDOM);
nsresult rv = TX_CompileStylesheet(styleNode, this, mPrincipal,
getter_AddRefs(mStylesheet));
NS_ENSURE_SUCCESS(rv, rv);
mSource = aSourceDOM;
return TransformToDoc(aOutputDoc, nsnull);
}
NS_IMETHODIMP
txMozillaXSLTProcessor::SetTransformObserver(nsITransformObserver* aObserver)
{
@ -596,7 +555,7 @@ public:
NS_IMETHOD Run()
{
mProcessor->TransformToDoc(nsnull, nsnull);
mProcessor->TransformToDoc(nsnull);
return NS_OK;
}
};
@ -686,12 +645,11 @@ txMozillaXSLTProcessor::TransformToDocument(nsIDOMNode *aSource,
mSource = aSource;
return TransformToDoc(nsnull, aResult);
return TransformToDoc(aResult);
}
nsresult
txMozillaXSLTProcessor::TransformToDoc(nsIDOMDocument *aOutputDoc,
nsIDOMDocument **aResult)
txMozillaXSLTProcessor::TransformToDoc(nsIDOMDocument **aResult)
{
nsAutoPtr<txXPathNode> sourceNode(txXPathNativeNode::createXPathNode(mSource));
if (!sourceNode) {
@ -708,8 +666,7 @@ txMozillaXSLTProcessor::TransformToDoc(nsIDOMDocument *aOutputDoc,
// XXX Need to add error observers
txToDocHandlerFactory handlerFactory(&es, sourceDOMDocument, aOutputDoc,
mObserver);
txToDocHandlerFactory handlerFactory(&es, sourceDOMDocument, mObserver);
es.mOutputHandlerFactory = &handlerFactory;
nsresult rv = es.init(*sourceNode, &mVariables);

View File

@ -43,7 +43,6 @@
#include "nsStubMutationObserver.h"
#include "nsIDocumentTransformer.h"
#include "nsIXSLTProcessor.h"
#include "nsIXSLTProcessorObsolete.h"
#include "nsIXSLTProcessorPrivate.h"
#include "txExpandedNameMap.h"
#include "txNamespaceMap.h"
@ -71,7 +70,6 @@ class txIGlobalParameter;
* txMozillaXSLTProcessor is a front-end to the XSLT Processor.
*/
class txMozillaXSLTProcessor : public nsIXSLTProcessor,
public nsIXSLTProcessorObsolete,
public nsIXSLTProcessorPrivate,
public nsIDocumentTransformer,
public nsStubMutationObserver,
@ -96,9 +94,6 @@ public:
// nsIXSLTProcessor interface
NS_DECL_NSIXSLTPROCESSOR
// nsIXSLTProcessorObsolete interface
NS_DECL_NSIXSLTPROCESSOROBSOLETE
// nsIXSLTProcessorPrivate interface
NS_DECL_NSIXSLTPROCESSORPRIVATE
@ -133,8 +128,7 @@ public:
return mSource;
}
nsresult TransformToDoc(nsIDOMDocument *aOutputDoc,
nsIDOMDocument **aResult);
nsresult TransformToDoc(nsIDOMDocument **aResult);
PRBool IsLoadDisabled()
{

View File

@ -37,7 +37,6 @@
* ***** END LICENSE BLOCK ***** */
var gParser = new DOMParser;
var gProc = new XSLTProcessor;
var gTimeout;
function Test(aTitle, aSourceURL, aStyleURL, aNumber, aObserver)
@ -61,9 +60,10 @@ function runTest(aTitle, aSourceURL, aStyleURL, aNumber, aObserver)
function onNextTransform(aTest, aNumber)
{
res = document.implementation.createDocument('', '', null);
var proc = new XSLTProcessor;
var startTime = Date.now();
gProc.transformDocument(aTest.mSource, aTest.mStyle, res, null);
proc.importStylesheet(aTest.mStyle);
var res = proc.transformToDocument(aTest.mSource);
var endTime = Date.now();
aNumber++;
var progress = aNumber / aTest.mTotal * 100;

View File

@ -202,7 +202,6 @@
// Tranformiix
#include "nsIDOMXPathEvaluator.h"
#include "nsIXSLTProcessor.h"
#include "nsIXSLTProcessorObsolete.h"
#include "nsIXSLTProcessorPrivate.h"
#include "nsIDOMLSProgressEvent.h"
@ -3798,7 +3797,6 @@ nsDOMClassInfo::Init()
DOM_CLASSINFO_MAP_BEGIN(XSLTProcessor, nsIXSLTProcessor)
DOM_CLASSINFO_MAP_ENTRY(nsIXSLTProcessor)
DOM_CLASSINFO_MAP_ENTRY(nsIXSLTProcessorObsolete) // XXX DEPRECATED
DOM_CLASSINFO_MAP_ENTRY(nsIXSLTProcessorPrivate)
DOM_CLASSINFO_MAP_END