diff --git a/mozilla/content/base/src/nsSyncLoadService.cpp b/mozilla/content/base/src/nsSyncLoadService.cpp index ee80d0c2752..d60c04a4f18 100644 --- a/mozilla/content/base/src/nsSyncLoadService.cpp +++ b/mozilla/content/base/src/nsSyncLoadService.cpp @@ -165,7 +165,7 @@ nsSyncLoader::~nsSyncLoader() NS_IMPL_ISUPPORTS3(nsSyncLoader, nsISyncLoader, nsIDOMLoadListener, nsISupportsWeakReference) NS_IMETHODIMP -nsSyncLoader::LoadDocument(nsIURI* documentURI, nsIDocument **_retval) +nsSyncLoader::LoadDocument(nsIURI* documentURI, nsIDOMDocument **_retval) { nsresult rv = NS_OK; @@ -316,7 +316,7 @@ nsSyncLoader::LoadDocument(nsIURI* documentURI, nsIDocument **_retval) if (NS_FAILED(rv)) return NS_ERROR_FAILURE; } - *_retval = document; + *_retval = DOMDocument; NS_ADDREF(*_retval); return rv; } diff --git a/mozilla/extensions/transformiix/source/xml/parser/XMLParser.cpp b/mozilla/extensions/transformiix/source/xml/parser/XMLParser.cpp index 66927c1bd3b..513ecdec4e1 100644 --- a/mozilla/extensions/transformiix/source/xml/parser/XMLParser.cpp +++ b/mozilla/extensions/transformiix/source/xml/parser/XMLParser.cpp @@ -34,7 +34,7 @@ * -- Removed a number of castings of XML_Char to DOM_CHAR since they * were not working on Windows properly * - * $Id: XMLParser.cpp,v 1.11 2001-01-12 20:06:26 axel%pike.org Exp $ + * $Id: XMLParser.cpp,v 1.12 2001-01-19 21:24:39 axel%pike.org Exp $ */ #include "XMLParser.h" @@ -96,12 +96,11 @@ Document* XMLParser::getDocumentFromURI nsCOMPtraLoader = do_CreateInstance( TRANSFORMIIX_SYNCLOADER_CONTRACTID, &rv ); if (NS_FAILED(rv)) return NULL; - nsCOMPtr theDocument; - aLoader->LoadDocument(documentURI, getter_AddRefs(theDocument)); - nsCOMPtr theDOMDocument = do_QueryInterface(theDocument, & rv); + nsCOMPtr theDocument; + rv = aLoader->LoadDocument(documentURI, getter_AddRefs(theDocument)); if (NS_FAILED(rv)) return NULL; - return new Document(theDOMDocument); + return new Document(theDocument); #else istream* xslInput = URIUtils::getInputStream(href, documentBase, errMsg); diff --git a/mozilla/extensions/transformiix/source/xml/parser/nsSyncLoader.cpp b/mozilla/extensions/transformiix/source/xml/parser/nsSyncLoader.cpp index ee80d0c2752..d60c04a4f18 100644 --- a/mozilla/extensions/transformiix/source/xml/parser/nsSyncLoader.cpp +++ b/mozilla/extensions/transformiix/source/xml/parser/nsSyncLoader.cpp @@ -165,7 +165,7 @@ nsSyncLoader::~nsSyncLoader() NS_IMPL_ISUPPORTS3(nsSyncLoader, nsISyncLoader, nsIDOMLoadListener, nsISupportsWeakReference) NS_IMETHODIMP -nsSyncLoader::LoadDocument(nsIURI* documentURI, nsIDocument **_retval) +nsSyncLoader::LoadDocument(nsIURI* documentURI, nsIDOMDocument **_retval) { nsresult rv = NS_OK; @@ -316,7 +316,7 @@ nsSyncLoader::LoadDocument(nsIURI* documentURI, nsIDocument **_retval) if (NS_FAILED(rv)) return NS_ERROR_FAILURE; } - *_retval = document; + *_retval = DOMDocument; NS_ADDREF(*_retval); return rv; } diff --git a/mozilla/extensions/transformiix/source/xpath/Makefile.in b/mozilla/extensions/transformiix/source/xpath/Makefile.in index 253ccac02c5..79fadf7e504 100644 --- a/mozilla/extensions/transformiix/source/xpath/Makefile.in +++ b/mozilla/extensions/transformiix/source/xpath/Makefile.in @@ -45,6 +45,7 @@ CPPSRCS = AdditiveExpr.cpp \ MultiplicativeExpr.cpp \ NodeSet.cpp \ NodeSetFunctionCall.cpp \ + nsNodeSet.cpp \ NumberExpr.cpp \ NumberFunctionCall.cpp \ NumberResult.cpp \ diff --git a/mozilla/extensions/transformiix/source/xpath/NodeSet.cpp b/mozilla/extensions/transformiix/source/xpath/NodeSet.cpp index 9505c4ca328..a8ee0b8178e 100644 --- a/mozilla/extensions/transformiix/source/xpath/NodeSet.cpp +++ b/mozilla/extensions/transformiix/source/xpath/NodeSet.cpp @@ -27,36 +27,23 @@ * Olivier Gerardin, ogerardin@vo.lu * -- fixed numberValue() * - * $Id: NodeSet.cpp,v 1.4 2001-01-12 20:06:35 axel%pike.org Exp $ + * $Id: NodeSet.cpp,v 1.5 2001-01-19 21:24:41 axel%pike.org Exp $ */ #include "NodeSet.h" #include "XMLDOMUtils.h" #ifndef MOZ_XSL #include -#else -#include "nsDOMCID.h" -#include "nsIDOMScriptObjectFactory.h" -#include "nsIScriptGlobalObject.h" -#include "nsIServiceManager.h" #endif /** * NodeSet
* This class was ported from XSL:P.
* @author Keith Visco - * @version $Revision: 1.4 $ $Date: 2001-01-12 20:06:35 $ + * @version $Revision: 1.5 $ $Date: 2001-01-19 21:24:41 $ **/ -#ifdef MOZ_XSL -static NS_DEFINE_CID(kDOMScriptObjectFactoryCID, NS_DOM_SCRIPT_OBJECT_FACTORY_CID); - -NS_IMPL_ISUPPORTS2(NodeSet, - nsIDOMNodeList, - nsIScriptObjectOwner) -#endif - //-------------/ //- Constants -/ //-------------/ @@ -94,11 +81,6 @@ NodeSet::NodeSet(const NodeSet& source) { * Helper method for Constructors **/ void NodeSet::initialize(int size) { -#ifdef MOZ_XSL - NS_INIT_ISUPPORTS(); - - mScriptObject = nsnull; -#endif elements = new Node*[size]; for ( int i = 0; i < size; i++ ) elements[i] = 0; elementCount = 0; @@ -211,19 +193,6 @@ Node* NodeSet::get(int index) { return elements[index]; } //-- get - -#ifdef MOZ_XSL -NS_IMETHODIMP NodeSet::Item(PRUint32 aIndex, nsIDOMNode** aReturn) -{ - if ((aIndex < 0) || aIndex >= (UInt32)elementCount) return NS_ERROR_INVALID_ARG; - Node* aNode = elements[aIndex]; - if (!aNode) return NS_ERROR_INVALID_ARG; - *aReturn = aNode->getNSNode(); - return NS_OK; -} //-- Item -#endif - - /** * Returns the index of the specified Node, * or -1 if the Node is not contained in the NodeSet @@ -283,15 +252,6 @@ int NodeSet::size() const{ return elementCount; } //-- size -#ifdef MOZ_XSL -NS_IMETHODIMP NodeSet::GetLength(PRUint32* aLength) -{ - *aLength = elementCount; - return NS_OK; -} //-- GetLength -#endif - - /** * Creates a String representation of this NodeSet * @param str the destination string to append the String representation to. @@ -392,42 +352,3 @@ void NodeSet::stringValue(String& str) { XMLDOMUtils::getNodeValue(get(0), &str); } } //-- stringValue - -#ifdef MOZ_XSL -/* - * nsIScriptObjectOwner - */ - -NS_IMETHODIMP -NodeSet::GetScriptObject(nsIScriptContext *aContext, void** aScriptObject) -{ - nsresult rv = NS_OK; - nsIScriptGlobalObject* global = aContext->GetGlobalObject(); - - if (nsnull == mScriptObject) { - nsIDOMScriptObjectFactory *factory; - - if (NS_SUCCEEDED(rv = nsServiceManager::GetService(kDOMScriptObjectFactoryCID, - NS_GET_IID(nsIDOMScriptObjectFactory), - (nsISupports **)&factory))) { - rv = factory->NewScriptNodeList(aContext, - (nsISupports*)(nsIDOMNodeList*)this, - global, - (void**)&mScriptObject); - - nsServiceManager::ReleaseService(kDOMScriptObjectFactoryCID, factory); - } - } - *aScriptObject = mScriptObject; - - NS_RELEASE(global); - return rv; -} - -NS_IMETHODIMP -NodeSet::SetScriptObject(void* aScriptObject) -{ - mScriptObject = aScriptObject; - return NS_OK; -} -#endif diff --git a/mozilla/extensions/transformiix/source/xpath/NodeSet.h b/mozilla/extensions/transformiix/source/xpath/NodeSet.h index 188d3a42b06..da68de02d6d 100644 --- a/mozilla/extensions/transformiix/source/xpath/NodeSet.h +++ b/mozilla/extensions/transformiix/source/xpath/NodeSet.h @@ -24,13 +24,13 @@ * Larry Fitzpatrick, OpenText, lef@opentext.com * -- moved initialization of DEFAULT_SIZE to NodeSet.cpp * - * $Id: NodeSet.h,v 1.4 2001-01-12 20:06:35 axel%pike.org Exp $ + * $Id: NodeSet.h,v 1.5 2001-01-19 21:24:41 axel%pike.org Exp $ */ /** * NodeSet * @author Keith Visco - * @version $Revision: 1.4 $ $Date: 2001-01-12 20:06:35 $ + * @version $Revision: 1.5 $ $Date: 2001-01-19 21:24:41 $ **/ #ifndef TRANSFRMX_NODESET_H @@ -40,16 +40,7 @@ #include "dom.h" #include "ExprResult.h" -#ifdef MOZ_XSL -#include "nsIDOMNodeList.h" -#include "nsIScriptObjectOwner.h" - -class NodeSet : public ExprResult, - public nsIDOMNodeList, - public nsIScriptObjectOwner -#else class NodeSet : public ExprResult -#endif { public: @@ -78,17 +69,6 @@ public: **/ virtual ~NodeSet(); -#ifdef MOZ_XSL - // nsISupports interface - NS_DECL_ISUPPORTS - - // nsIDocumentTransformer interface - NS_DECL_IDOMNODELIST - - // nsIScriptObjectOwner interface - NS_IMETHOD GetScriptObject(nsIScriptContext *aContext, void** aScriptObject); - NS_IMETHOD SetScriptObject(void* aScriptObject); -#endif /** * Adds the specified Node to this NodeSet if it is not already * contained within in this NodeSet. @@ -219,10 +199,6 @@ private: //- Private Members -/ //-------------------/ -#ifdef MOZ_XSL - void* mScriptObject; -#endif - static const int DEFAULT_SIZE; Node** elements; diff --git a/mozilla/extensions/transformiix/source/xpath/XPathProcessor.cpp b/mozilla/extensions/transformiix/source/xpath/XPathProcessor.cpp index d0f84037f3f..19605f7fa3e 100644 --- a/mozilla/extensions/transformiix/source/xpath/XPathProcessor.cpp +++ b/mozilla/extensions/transformiix/source/xpath/XPathProcessor.cpp @@ -27,6 +27,7 @@ #include "dom.h" #include "ProcessorState.h" #include "Expr.h" +#include "nsNodeSet.h" NS_IMPL_ISUPPORTS2(XPathProcessor, nsIXPathNodeSelector, @@ -53,24 +54,27 @@ NS_IMETHODIMP XPathProcessor::SelectNodes(nsIDOMNode *aContextNode, const char * aContextNode->GetOwnerDocument(getter_AddRefs(aOwnerDOMDocument)); nsCOMPtr aOwnerDocument = do_QueryInterface(aOwnerDOMDocument); Document* aDocument = new Document(aOwnerDOMDocument); - Node* aNode = new Node(aContextNode, aDocument); + Node* aNode = aDocument->createWrapper(aContextNode); - ProcessorState* aProcessorState = new ProcessorState(*aDocument, *aDocument); - ExprParser* aParser = new ExprParser; + ProcessorState* aProcessorState = new ProcessorState(); + ExprParser aParser; - Expr* aExpression = aParser->createExpr(aPattern); + Expr* aExpression = aParser.createExpr(aPattern); ExprResult* exprResult = aExpression->evaluate(aNode, aProcessorState); + nsNodeSet* resultSet; if ( exprResult->getResultType() == ExprResult::NODESET ) { - *_retval = (NodeSet*)exprResult; + resultSet = new nsNodeSet((NodeSet*)exprResult); } else { // Return an empty nodeset - *_retval = new NodeSet(0); + resultSet = new nsNodeSet(nsnull); } + *_retval = resultSet; NS_ADDREF(*_retval); + delete aProcessorState; + delete exprResult; delete aExpression; - delete aNode; delete aDocument; return NS_OK; diff --git a/mozilla/extensions/transformiix/source/xpath/makefile.win b/mozilla/extensions/transformiix/source/xpath/makefile.win index b3bfdfd5a79..0677752666c 100644 --- a/mozilla/extensions/transformiix/source/xpath/makefile.win +++ b/mozilla/extensions/transformiix/source/xpath/makefile.win @@ -43,8 +43,9 @@ CPPSRCS= \ IdentityExpr.cpp \ LocationStep.cpp \ MultiplicativeExpr.cpp \ - NodeSet.cpp \ + NodeSet.cpp \ NodeSetFunctionCall.cpp \ + nsNodeSet.cpp \ NumberExpr.cpp \ NumberFunctionCall.cpp \ NumberResult.cpp \ @@ -86,6 +87,7 @@ CPP_OBJS= \ .\$(OBJDIR)\MultiplicativeExpr.obj \ .\$(OBJDIR)\NodeSet.obj \ .\$(OBJDIR)\NodeSetFunctionCall.obj \ + .\$(OBJDIR)\nsNodeSet.obj \ .\$(OBJDIR)\NumberExpr.obj \ .\$(OBJDIR)\NumberFunctionCall.obj \ .\$(OBJDIR)\NumberResult.obj \ diff --git a/mozilla/extensions/transformiix/source/xpath/nsNodeSet.cpp b/mozilla/extensions/transformiix/source/xpath/nsNodeSet.cpp new file mode 100644 index 00000000000..1195cfbfb6b --- /dev/null +++ b/mozilla/extensions/transformiix/source/xpath/nsNodeSet.cpp @@ -0,0 +1,102 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- + * + * The contents of this file are subject to the Netscape 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/NPL/ + * + * 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 Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * Peter Van der Beken, peterv@netscape.com + * -- original author. + * + */ + +#include "nsNodeSet.h" +#include "nsDOMCID.h" +#include "nsIDOMScriptObjectFactory.h" +#include "nsIScriptGlobalObject.h" +#include "nsIServiceManager.h" + +static NS_DEFINE_CID(kDOMScriptObjectFactoryCID, NS_DOM_SCRIPT_OBJECT_FACTORY_CID); + +NS_IMPL_ISUPPORTS2(nsNodeSet, + nsIDOMNodeList, + nsIScriptObjectOwner) + +nsNodeSet::nsNodeSet(NodeSet* aNodeSet) { + NS_INIT_ISUPPORTS(); + mScriptObject = nsnull; + + if (aNodeSet) { + for (int i=0; i < aNodeSet->size(); i++) { + mNodes.AppendElement(aNodeSet->get(i)->getNSNode()); + } + } +} + +nsNodeSet::~nsNodeSet() { +} + +NS_IMETHODIMP +nsNodeSet::Item(PRUint32 aIndex, nsIDOMNode** aReturn) +{ + *aReturn = nsnull; + mNodes.QueryElementAt(aIndex, NS_GET_IID(nsIDOMNode), (void**)aReturn); + return NS_OK; +} + +NS_IMETHODIMP +nsNodeSet::GetLength(PRUint32* aLength) +{ + mNodes.Count(aLength); + return NS_OK; +} + +/* + * nsIScriptObjectOwner + */ + +NS_IMETHODIMP +nsNodeSet::GetScriptObject(nsIScriptContext *aContext, void** aScriptObject) +{ + nsresult rv = NS_OK; + nsIScriptGlobalObject* global = aContext->GetGlobalObject(); + + if (nsnull == mScriptObject) { + nsIDOMScriptObjectFactory *factory; + + if (NS_SUCCEEDED(rv = nsServiceManager::GetService(kDOMScriptObjectFactoryCID, + NS_GET_IID(nsIDOMScriptObjectFactory), + (nsISupports **)&factory))) { + rv = factory->NewScriptNodeList(aContext, + (nsISupports*)(nsIDOMNodeList*)this, + global, + (void**)&mScriptObject); + + nsServiceManager::ReleaseService(kDOMScriptObjectFactoryCID, factory); + } + } + *aScriptObject = mScriptObject; + + NS_RELEASE(global); + return rv; +} + +NS_IMETHODIMP +nsNodeSet::SetScriptObject(void* aScriptObject) +{ + mScriptObject = aScriptObject; + return NS_OK; +} diff --git a/mozilla/extensions/transformiix/source/xpath/nsNodeSet.h b/mozilla/extensions/transformiix/source/xpath/nsNodeSet.h new file mode 100644 index 00000000000..a0dc422bff9 --- /dev/null +++ b/mozilla/extensions/transformiix/source/xpath/nsNodeSet.h @@ -0,0 +1,63 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- + * + * The contents of this file are subject to the Netscape 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/NPL/ + * + * 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 Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * Peter Van der Beken, peterv@netscape.com + * -- original author. + * + */ + +#ifndef TRANSFRMX_NS_NODESET_H +#define TRANSFRMX_NS_NODESET_H + +#include "NodeSet.h" +#include "nsIDOMNodeList.h" +#include "nsIScriptObjectOwner.h" +#include "nsSupportsArray.h" + +class nsNodeSet : public nsIDOMNodeList, + public nsIScriptObjectOwner +{ +public: + /** + * Creates a new Mozilla NodeSet from a Transformiix NodeSet + **/ + nsNodeSet(NodeSet* aNodeSet); + + /** + * Default destructor for nsNodeSet + **/ + virtual ~nsNodeSet(); + + // nsISupports interface + NS_DECL_ISUPPORTS + + // nsIDocumentTransformer interface + NS_DECL_IDOMNODELIST + + // nsIScriptObjectOwner interface + NS_IMETHOD GetScriptObject(nsIScriptContext *aContext, void** aScriptObject); + NS_IMETHOD SetScriptObject(void* aScriptObject); + +private: + void* mScriptObject; + nsSupportsArray mNodes; +}; + +#endif \ No newline at end of file diff --git a/mozilla/extensions/transformiix/source/xslt/ProcessorState.cpp b/mozilla/extensions/transformiix/source/xslt/ProcessorState.cpp index 993b0ee340d..bed15053f88 100644 --- a/mozilla/extensions/transformiix/source/xslt/ProcessorState.cpp +++ b/mozilla/extensions/transformiix/source/xslt/ProcessorState.cpp @@ -25,13 +25,13 @@ * -- added code in ::resolveFunctionCall to support the * document() function. * - * $Id: ProcessorState.cpp,v 1.13 2001-01-12 20:06:42 axel%pike.org Exp $ + * $Id: ProcessorState.cpp,v 1.14 2001-01-19 21:24:44 axel%pike.org Exp $ */ /** * Implementation of ProcessorState * Much of this code was ported from XSL:P - * @version $Revision: 1.13 $ $Date: 2001-01-12 20:06:42 $ + * @version $Revision: 1.14 $ $Date: 2001-01-19 21:24:44 $ **/ #include "ProcessorState.h" @@ -43,6 +43,15 @@ const String ProcessorState::wrapperNSPrefix = "transformiix"; const String ProcessorState::wrapperName = "transformiix:result"; const String ProcessorState::wrapperNS = "http://www.mitre.org/TransforMiix"; +/** + * Creates a new ProcessorState +**/ +ProcessorState::ProcessorState() { + this->xslDocument = NULL; + this->resultDocument = NULL; + initialize(); +} //-- ProcessorState + /** * Creates a new ProcessorState for the given XSL document * and resultDocument @@ -57,8 +66,10 @@ ProcessorState::ProcessorState(Document& xslDocument, Document& resultDocument) * Destroys this ProcessorState **/ ProcessorState::~ProcessorState() { - delete dfWildCardTemplate; - delete dfTextTemplate; + if (dfWildCardTemplate) + delete dfWildCardTemplate; + if (dfTextTemplate) + delete dfTextTemplate; delete nodeStack; while ( ! variableSets.empty() ) { @@ -788,6 +799,8 @@ ProcessorState::XMLSpaceMode ProcessorState::getXMLSpaceMode(Node* node) { * Initializes this ProcessorState **/ void ProcessorState::initialize() { + dfWildCardTemplate = 0; + dfTextTemplate = 0; //-- initialize default-space defaultSpace = PRESERVE; @@ -815,7 +828,9 @@ void ProcessorState::initialize() { setDefaultNameSpaceURI(""); //-- determine xsl properties - Element* element = xslDocument->getDocumentElement(); + Element* element = NULL; + if (xslDocument) + element = xslDocument->getDocumentElement(); if ( element ) { //-- process namespace nodes NamedNodeMap* atts = element->getAttributes(); diff --git a/mozilla/extensions/transformiix/source/xslt/ProcessorState.h b/mozilla/extensions/transformiix/source/xslt/ProcessorState.h index adb22d70190..7ee8968c6f3 100644 --- a/mozilla/extensions/transformiix/source/xslt/ProcessorState.h +++ b/mozilla/extensions/transformiix/source/xslt/ProcessorState.h @@ -21,7 +21,7 @@ * Keith Visco, kvisco@ziplink.net * -- original author. * - * $Id: ProcessorState.h,v 1.7 2000-11-07 10:46:03 kvisco%ziplink.net Exp $ + * $Id: ProcessorState.h,v 1.8 2001-01-19 21:24:44 axel%pike.org Exp $ */ @@ -50,7 +50,7 @@ /** * Class used for keeping the current state of the XSL Processor * @author Keith Visco - * @version $Revision: 1.7 $ $Date: 2000-11-07 10:46:03 $ + * @version $Revision: 1.8 $ $Date: 2001-01-19 21:24:44 $ **/ class ProcessorState : public ContextState { @@ -60,6 +60,11 @@ public: static const String wrapperName; static const String wrapperNS; + /** + * Creates a new ProcessorState + **/ + ProcessorState(); + /** * Creates a new ProcessorState for the given XSL document * And result Document