diff --git a/mozilla/content/html/document/src/nsHTMLDocument.cpp b/mozilla/content/html/document/src/nsHTMLDocument.cpp
index 872ce5d1716..244522739f2 100644
--- a/mozilla/content/html/document/src/nsHTMLDocument.cpp
+++ b/mozilla/content/html/document/src/nsHTMLDocument.cpp
@@ -40,6 +40,8 @@
#include "nsIScriptGlobalObject.h"
#include "nsContentList.h"
#include "nsINetService.h"
+#include "nsRepository.h"
+#include "nsParserCIID.h"
//#define rickgdebug 1
#ifdef rickgdebug
@@ -142,7 +144,14 @@ nsHTMLDocument::StartDocumentLoad(nsIURL *aURL,
mDocumentURL = aURL;
NS_ADDREF(aURL);
- rv = NS_NewParser(&mParser);
+ static NS_DEFINE_IID(kCParserIID, NS_IPARSER_IID);
+ static NS_DEFINE_IID(kCParserCID, NS_PARSER_IID);
+
+ rv = NSRepository::CreateInstance(kCParserCID,
+ nsnull,
+ kCParserIID,
+ (void **)&mParser);
+
if (NS_OK == rv) {
nsIHTMLContentSink* sink;
diff --git a/mozilla/htmlparser/robot/nsDebugRobot.cpp b/mozilla/htmlparser/robot/nsDebugRobot.cpp
index 8d3d9dfc73a..d11eb72a92b 100644
--- a/mozilla/htmlparser/robot/nsDebugRobot.cpp
+++ b/mozilla/htmlparser/robot/nsDebugRobot.cpp
@@ -24,6 +24,8 @@
#include "nsIURL.h"
#include "nsIStreamListener.h"
#include "nsIDTDDebug.h"
+#include "nsRepository.h"
+#include "nsParserCIID.h"
static NS_DEFINE_IID(kIRobotSinkObserverIID, NS_IROBOTSINKOBSERVER_IID);
@@ -210,7 +212,15 @@ extern "C" NS_EXPORT int DebugRobot(
delete urlName;
nsIParser* parser;
- rv = NS_NewParser(&parser);
+
+ static NS_DEFINE_IID(kCParserIID, NS_IPARSER_IID);
+ static NS_DEFINE_IID(kCParserCID, NS_PARSER_IID);
+
+ rv = NSRepository::CreateInstance(kCParserCID,
+ nsnull,
+ kCParserIID,
+ (void **)&parser);
+
if (NS_OK != rv) {
printf("can't make parser\n");
NS_RELEASE(myObserver);
diff --git a/mozilla/htmlparser/robot/test/RobotMain.cpp b/mozilla/htmlparser/robot/test/RobotMain.cpp
index a8d973859ad..be5db4989c0 100644
--- a/mozilla/htmlparser/robot/test/RobotMain.cpp
+++ b/mozilla/htmlparser/robot/test/RobotMain.cpp
@@ -2,6 +2,14 @@
#include "nsVoidArray.h"
#include "nsIWebShell.h"
#include "nsString.h"
+#include "nsRepository.h"
+#include "nsParserCIID.h"
+
+#ifdef XP_PC
+#define PARSER_DLL "raptorhtmlpars.dll"
+#else
+#define PARSER_DLL "libraptorhtmlpars.so"
+#endif
extern "C" NS_EXPORT int DebugRobot(nsVoidArray * workList, nsIWebShell * ww);
@@ -12,6 +20,10 @@ int main(int argc, char **argv)
for (i = 1; i < argc; i++) {
gWorkList->AppendElement(new nsString(argv[i]));
}
+
+ static NS_DEFINE_IID(kCParserCID, NS_PARSER_IID);
+ NSRepository::RegisterFactory(kCParserCID, PARSER_DLL, PR_FALSE, PR_FALSE);
+
return DebugRobot(gWorkList, nsnull);
}
diff --git a/mozilla/htmlparser/src/Makefile b/mozilla/htmlparser/src/Makefile
index 51e490da6f2..74a1d848ad9 100644
--- a/mozilla/htmlparser/src/Makefile
+++ b/mozilla/htmlparser/src/Makefile
@@ -40,6 +40,7 @@ CPPSRCS = \
prstrm.cpp \
nsHTMLContentSinkStream.cpp \
nsXIFDTD.cpp \
+ nsParserFactory.cpp \
$(NULL)
EXPORTS = \
@@ -59,6 +60,7 @@ EXPORTS = \
nsValidDTD.h \
CRtfDTD.h \
nsXIFDTD.h \
+ nsParserCIID.h \
$(NULL)
EXTRA_EXPORTS = \
diff --git a/mozilla/htmlparser/src/SelfTest.cpp b/mozilla/htmlparser/src/SelfTest.cpp
index 31186bc3760..5be0cb72f3f 100644
--- a/mozilla/htmlparser/src/SelfTest.cpp
+++ b/mozilla/htmlparser/src/SelfTest.cpp
@@ -28,6 +28,14 @@
#include "nsHTMLDelegate.h"
#include "nsIParser.h"
#include "nsHTMLContentSink.h"
+#include "nsRepository.h"
+#include "nsParserCIID.h"
+
+#ifdef XP_PC
+#define PARSER_DLL "raptorhtmlpars.dll"
+#else
+#define PARSER_DLL "libraptorhtmlpars.so"
+#endif
ofstream filelist("filelist.out");
@@ -99,8 +107,15 @@ void parseFile (const char* aFilename,int size)
strcat(filename,".tokens");
{
nsIParser* parser;
- nsresult rv = NS_NewParser(&parser);
- nsresult r=NS_NewParser(&parser);
+
+ static NS_DEFINE_IID(kCParserIID, NS_IPARSER_IID);
+ static NS_DEFINE_IID(kCParserCID, NS_PARSER_IID);
+
+ nsresult rv = NSRepository::CreateInstance(kCParserCID,
+ nsnull,
+ kCParserIID,
+ (void **)&parser);
+
CHTMLContentSink theSink;
parser->setContentSink(&theSink);
parser->parse(aFilename);
@@ -180,6 +195,10 @@ int main(int argc, char* argv [])
if(argc==2)
strcpy(buffer,argv[1]);
else _getcwd(buffer,_MAX_PATH);
+
+ static NS_DEFINE_IID(kCParserCID, NS_PARSER_IID);
+ NSRepository::RegisterFactory(kCParserCID, PARSER_DLL, PR_FALSE, PR_FALSE);
+
walkDirectoryTree(buffer);
return 0;
}
diff --git a/mozilla/htmlparser/src/makefile.win b/mozilla/htmlparser/src/makefile.win
index 2a37992d70b..59c1dd96e67 100644
--- a/mozilla/htmlparser/src/makefile.win
+++ b/mozilla/htmlparser/src/makefile.win
@@ -42,6 +42,7 @@ CPPSRCS= \
nsWellFormed.cpp \
nsXIFDTD.cpp \
prstrm.cpp \
+ nsParserFactory.cpp \
$(NULL)
CPP_OBJS= \
@@ -63,6 +64,7 @@ CPP_OBJS= \
.\$(OBJDIR)\nsWellFormedDTD.obj \
.\$(OBJDIR)\nsXIFDTD.obj \
.\$(OBJDIR)\prstrm.obj \
+ .\$(OBJDIR)\nsParserFactory.obj \
$(NULL)
EXPORTS= \
@@ -83,6 +85,7 @@ EXPORTS= \
COtherDTD.h \
nsIDTD.h \
nsXIFDTD.h \
+ nsParserCIID.h \
$(NULL)
EXTRA_EXPORTS= \
diff --git a/mozilla/htmlparser/src/nsIParser.h b/mozilla/htmlparser/src/nsIParser.h
index f841dc14b53..176a6a147d2 100644
--- a/mozilla/htmlparser/src/nsIParser.h
+++ b/mozilla/htmlparser/src/nsIParser.h
@@ -106,6 +106,4 @@ class nsIParser : public nsISupports {
};
-extern NS_HTMLPARS nsresult NS_NewParser(nsIParser** aInstancePtrResult);
-
#endif
diff --git a/mozilla/htmlparser/src/nsIParserFilter.h b/mozilla/htmlparser/src/nsIParserFilter.h
index ef3912af04d..b6fc986ee77 100644
--- a/mozilla/htmlparser/src/nsIParserFilter.h
+++ b/mozilla/htmlparser/src/nsIParserFilter.h
@@ -48,7 +48,6 @@ class nsIParserFilter : public nsISupports {
NS_IMETHOD ProcessTokens( /* dont know what goes here yet */ void ) = 0;
};
-extern nsresult NS_NewParserFilter(nsIParserFilter** aInstancePtrResult);
#endif
diff --git a/mozilla/htmlparser/src/nsIParserNode.h b/mozilla/htmlparser/src/nsIParserNode.h
index 0ea87656edf..5c30aeabc84 100644
--- a/mozilla/htmlparser/src/nsIParserNode.h
+++ b/mozilla/htmlparser/src/nsIParserNode.h
@@ -36,10 +36,19 @@
#ifndef NS_IPARSERNODE__
#define NS_IPARSERNODE__
+#include "nshtmlpars.h"
+#include "nsISupports.h"
#include "prtypes.h"
#include "nsString.h"
#include "nsDebug.h"
+class CToken;
+
+// 6e59f160-2717-11d2-9246-00805f8a7ab6
+#define NS_IPARSER_NODE_IID \
+ {0x6e59f160, 0x2717, 0x11d1, \
+ {0x92, 0x46, 0x00, 0x80, 0x5f, 0x8a, 0x7a, 0xb6}}
+
/**
* Parser nodes are the unit of exchange between the
* parser and the content sink. Nodes offer access to
@@ -48,7 +57,7 @@
*
* @update gess 3/25/98
*/
-class nsIParserNode {
+class nsIParserNode : public nsISupports {
public:
@@ -130,6 +139,10 @@ class nsIParserNode {
};
+extern NS_HTMLPARS nsresult NS_NewParserNode(nsIParserNode** aInstancePtrResult,
+ CToken* aToken,
+ PRInt32 aLineNumber);
+
#endif
diff --git a/mozilla/htmlparser/src/nsParser.cpp b/mozilla/htmlparser/src/nsParser.cpp
index 8239c9ed615..7c8a901712f 100644
--- a/mozilla/htmlparser/src/nsParser.cpp
+++ b/mozilla/htmlparser/src/nsParser.cpp
@@ -50,26 +50,6 @@ static nsString kEmptyString("unknown");
static const int gTransferBufferSize=4096; //size of the buffer used in moving data from iistream
-
-/**
- * This method is defined in nsIParser. It is used to
- * cause the COM-like construction of an nsParser.
- *
- * @update gess 3/25/98
- * @param nsIParser** ptr to newly instantiated parser
- * @return NS_xxx error result
- */
-NS_HTMLPARS nsresult NS_NewParser(nsIParser** aInstancePtrResult)
-{
- nsParser *it = new nsParser();
-
- if (it == 0) {
- return NS_ERROR_OUT_OF_MEMORY;
- }
-
- return it->QueryInterface(kIParserIID, (void **) aInstancePtrResult);
-}
-
class CTokenDeallocator: public nsDequeFunctor{
public:
virtual void* operator()(void* anObject) {
diff --git a/mozilla/htmlparser/src/nsParser.h b/mozilla/htmlparser/src/nsParser.h
index 1970349a952..50eab8e6032 100644
--- a/mozilla/htmlparser/src/nsParser.h
+++ b/mozilla/htmlparser/src/nsParser.h
@@ -61,11 +61,7 @@
#include "nsParserTypes.h"
#include "nsIURL.h"
#include "CParserContext.h"
-
-#define NS_PARSER_IID \
- {0x2ce606b0, 0xbee6, 0x11d1, \
- {0xaa, 0xd9, 0x00, 0x80, 0x5f, 0x8a, 0x3e, 0x14}}
-
+#include "nsParserCIID.h"
class IContentSink;
class nsIHTMLContentSink;
diff --git a/mozilla/htmlparser/src/nsParserCIID.h b/mozilla/htmlparser/src/nsParserCIID.h
new file mode 100644
index 00000000000..1e870fd8b10
--- /dev/null
+++ b/mozilla/htmlparser/src/nsParserCIID.h
@@ -0,0 +1,38 @@
+/* -*- 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.0 (the "NPL"); you may not use this file except in
+ * compliance with the NPL. You may obtain a copy of the NPL at
+ * http://www.mozilla.org/NPL/
+ *
+ * Software distributed under the NPL is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
+ * for the specific language governing rights and limitations under the
+ * NPL.
+ *
+ * The Initial Developer of this code under the NPL is Netscape
+ * Communications Corporation. Portions created by Netscape are
+ * Copyright (C) 1998 Netscape Communications Corporation. All Rights
+ * Reserved.
+ */
+
+#ifndef nsParserCIID_h__
+#define nsParserCIID_h__
+
+#include "nsISupports.h"
+#include "nsIFactory.h"
+#include "nsRepository.h"
+
+#define NS_PARSER_IID \
+ {0x2ce606b0, 0xbee6, 0x11d1, \
+ {0xaa, 0xd9, 0x00, 0x80, 0x5f, 0x8a, 0x3e, 0x14}}
+
+// XXX: This object should not be exposed outside of the parser.
+// Remove when CNavDTD subclasses do not need access
+#define NS_PARSER_NODE_IID \
+ {0x9039c670, 0x2717, 0x11d2, \
+ {0x92, 0x46, 0x00, 0x80, 0x5f, 0x8a, 0x7a, 0xb6}}
+
+
+
+#endif
diff --git a/mozilla/htmlparser/src/nsParserFactory.cpp b/mozilla/htmlparser/src/nsParserFactory.cpp
new file mode 100644
index 00000000000..5c4c96d9631
--- /dev/null
+++ b/mozilla/htmlparser/src/nsParserFactory.cpp
@@ -0,0 +1,160 @@
+/* -*- 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.0 (the "NPL"); you may not use this file except in
+ * compliance with the NPL. You may obtain a copy of the NPL at
+ * http://www.mozilla.org/NPL/
+ *
+ * Software distributed under the NPL is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
+ * for the specific language governing rights and limitations under the
+ * NPL.
+ *
+ * The Initial Developer of this code under the NPL is Netscape
+ * Communications Corporation. Portions created by Netscape are
+ * Copyright (C) 1998 Netscape Communications Corporation. All Rights
+ * Reserved.
+ */
+
+#include "nscore.h"
+#include "nsIFactory.h"
+#include "nsISupports.h"
+#include "nsParserCIID.h"
+
+#include "nsParser.h"
+#include "nsParserNode.h"
+
+static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID);
+static NS_DEFINE_IID(kIFactoryIID, NS_IFACTORY_IID);
+
+static NS_DEFINE_IID(kCParser, NS_PARSER_IID);
+static NS_DEFINE_IID(kCParserNode, NS_PARSER_NODE_IID);
+
+class nsParserFactory : public nsIFactory
+{
+ public:
+ // nsISupports methods
+ NS_IMETHOD QueryInterface(const nsIID &aIID,
+ void **aResult);
+ NS_IMETHOD_(nsrefcnt) AddRef(void);
+ NS_IMETHOD_(nsrefcnt) Release(void);
+
+ // nsIFactory methods
+ NS_IMETHOD CreateInstance(nsISupports *aOuter,
+ const nsIID &aIID,
+ void **aResult);
+
+ NS_IMETHOD LockFactory(PRBool aLock);
+
+ nsParserFactory(const nsCID &aClass);
+ ~nsParserFactory();
+
+ private:
+ nsrefcnt mRefCnt;
+ nsCID mClassID;
+};
+
+nsParserFactory::nsParserFactory(const nsCID &aClass)
+{
+ mRefCnt = 0;
+ mClassID = aClass;
+}
+
+nsParserFactory::~nsParserFactory()
+{
+ NS_ASSERTION(mRefCnt == 0, "non-zero refcnt at destruction");
+}
+
+nsresult nsParserFactory::QueryInterface(const nsIID &aIID,
+ void **aResult)
+{
+ if (aResult == NULL) {
+ return NS_ERROR_NULL_POINTER;
+ }
+
+ // Always NULL result, in case of failure
+ *aResult = NULL;
+
+ if (aIID.Equals(kISupportsIID)) {
+ *aResult = (void *)(nsISupports*)this;
+ } else if (aIID.Equals(kIFactoryIID)) {
+ *aResult = (void *)(nsIFactory*)this;
+ }
+
+ if (*aResult == NULL) {
+ return NS_NOINTERFACE;
+ }
+
+ AddRef(); // Increase reference count for caller
+ return NS_OK;
+}
+
+nsrefcnt nsParserFactory::AddRef()
+{
+ return ++mRefCnt;
+}
+
+nsrefcnt nsParserFactory::Release()
+{
+ if (--mRefCnt == 0) {
+ delete this;
+ return 0; // Don't access mRefCnt after deleting!
+ }
+ return mRefCnt;
+}
+
+nsresult nsParserFactory::CreateInstance(nsISupports *aOuter,
+ const nsIID &aIID,
+ void **aResult)
+{
+ if (aResult == NULL) {
+ return NS_ERROR_NULL_POINTER;
+ }
+
+ *aResult = NULL;
+
+ nsISupports *inst = nsnull;
+
+ if (mClassID.Equals(kCParser)) {
+ inst = (nsISupports *)(nsIParser *)new nsParser();
+ }
+ else if (mClassID.Equals(kCParserNode)) {
+ inst = (nsISupports *)(nsIParserNode *)new nsCParserNode();
+ }
+
+ if (inst == NULL) {
+ return NS_ERROR_OUT_OF_MEMORY;
+ }
+
+ nsresult res = inst->QueryInterface(aIID, aResult);
+
+ if (res != NS_OK) {
+ // We didn't get the right interface, so clean up
+ delete inst;
+ }
+
+ return res;
+}
+
+nsresult nsParserFactory::LockFactory(PRBool aLock)
+{
+ // Not implemented in simplest case.
+ return NS_OK;
+}
+
+// return the proper factory to the caller
+extern "C" NS_EXPORT nsresult NSGetFactory(const nsCID &aClass, nsIFactory **aFactory)
+{
+ if (nsnull == aFactory) {
+ return NS_ERROR_NULL_POINTER;
+ }
+
+ *aFactory = new nsParserFactory(aClass);
+
+ if (nsnull == aFactory) {
+ return NS_ERROR_OUT_OF_MEMORY;
+ }
+
+ return (*aFactory)->QueryInterface(kIFactoryIID, (void**)aFactory);
+}
+
diff --git a/mozilla/htmlparser/src/nsParserNode.cpp b/mozilla/htmlparser/src/nsParserNode.cpp
index 670d31bc292..73e57512868 100644
--- a/mozilla/htmlparser/src/nsParserNode.cpp
+++ b/mozilla/htmlparser/src/nsParserNode.cpp
@@ -20,9 +20,33 @@
#include "nsParserNode.h"
#include "string.h"
#include "nsHTMLTokens.h"
+#include "nshtmlpars.h"
const nsAutoString nsCParserNode::mEmptyString("");
+static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID);
+static NS_DEFINE_IID(kClassIID, NS_PARSER_NODE_IID);
+static NS_DEFINE_IID(kIParserNodeIID, NS_IPARSER_NODE_IID);
+
+/**
+ * This method is defined in nsIParser. It is used to
+ * cause the COM-like construction of an nsParser.
+ *
+ * @update gess 3/25/98
+ * @param nsIParser** ptr to newly instantiated parser
+ * @return NS_xxx error result
+ */
+NS_HTMLPARS nsresult NS_NewParserNode(nsIParserNode** aInstancePtrResult,CToken* aToken,PRInt32 aLineNumber)
+{
+ nsCParserNode *it = new nsCParserNode(aToken,aLineNumber);
+
+ if (it == 0) {
+ return NS_ERROR_OUT_OF_MEMORY;
+ }
+
+ return it->QueryInterface(kIParserNodeIID, (void **) aInstancePtrResult);
+}
+
/**
* Default constructor
*
@@ -31,7 +55,7 @@ const nsAutoString nsCParserNode::mEmptyString("");
* @return
*/
nsCParserNode::nsCParserNode(CToken* aToken,PRInt32 aLineNumber): nsIParserNode() {
- NS_PRECONDITION(0!=aToken, "Null Token");
+ NS_INIT_REFCNT();
mAttributeCount=0;
mLineNumber=aLineNumber;
mToken=aToken;
@@ -49,6 +73,57 @@ nsCParserNode::nsCParserNode(CToken* aToken,PRInt32 aLineNumber): nsIParserNode(
nsCParserNode::~nsCParserNode() {
}
+NS_IMPL_ADDREF(nsCParserNode)
+NS_IMPL_RELEASE(nsCParserNode)
+
+/**
+ * Init
+ *
+ * @update gess 3/25/98
+ * @param
+ * @return
+ */
+
+nsresult nsCParserNode::Init(CToken* aToken,PRInt32 aLineNumber)
+{
+ mLineNumber=aLineNumber;
+ mToken=aToken;
+ return NS_OK;
+}
+
+/**
+ * This method gets called as part of our COM-like interfaces.
+ * Its purpose is to create an interface to parser object
+ * of some type.
+ *
+ * @update gess 3/25/98
+ * @param nsIID id of object to discover
+ * @param aInstancePtr ptr to newly discovered interface
+ * @return NS_xxx result code
+ */
+nsresult nsCParserNode::QueryInterface(const nsIID& aIID, void** aInstancePtr)
+{
+ if (NULL == aInstancePtr) {
+ return NS_ERROR_NULL_POINTER;
+ }
+
+ if(aIID.Equals(kISupportsIID)) { //do IUnknown...
+ *aInstancePtr = (nsIParserNode*)(this);
+ }
+ else if(aIID.Equals(kIParserNodeIID)) { //do IParser base class...
+ *aInstancePtr = (nsIParserNode*)(this);
+ }
+ else if(aIID.Equals(kClassIID)) { //do this class...
+ *aInstancePtr = (nsCParserNode*)(this);
+ }
+ else {
+ *aInstancePtr=0;
+ return NS_NOINTERFACE;
+ }
+ ((nsISupports*) *aInstancePtr)->AddRef();
+ return NS_OK;
+}
+
/**
* Causes the given attribute to be added to internal
diff --git a/mozilla/htmlparser/src/nsParserNode.h b/mozilla/htmlparser/src/nsParserNode.h
index 50ca3707cd1..919a7c5df91 100644
--- a/mozilla/htmlparser/src/nsParserNode.h
+++ b/mozilla/htmlparser/src/nsParserNode.h
@@ -39,20 +39,22 @@
#include "nsIParserNode.h"
#include "nsToken.h"
#include "nsString.h"
+#include "nsParserCIID.h"
-//class nsParser;
class nsCParserNode : public nsIParserNode {
enum {eMaxAttr=20};
public:
+ NS_DECL_ISUPPORTS
+
/**
* Default constructor
* @update gess5/11/98
* @param aToken is the token this node "refers" to
*/
- nsCParserNode(CToken* aToken,PRInt32 aLineNumber=1);
+ nsCParserNode(CToken* aToken=nsnull,PRInt32 aLineNumber=1);
/**
* Destructor
@@ -60,6 +62,12 @@ class nsCParserNode : public nsIParserNode {
*/
virtual ~nsCParserNode();
+ /**
+ * Init
+ * @update gess5/11/98
+ */
+ virtual nsresult Init(CToken* aToken=nsnull,PRInt32 aLineNumber=1);
+
/**
* Retrieve the name of the node
* @update gess5/11/98
diff --git a/mozilla/layout/html/document/src/nsHTMLDocument.cpp b/mozilla/layout/html/document/src/nsHTMLDocument.cpp
index 872ce5d1716..244522739f2 100644
--- a/mozilla/layout/html/document/src/nsHTMLDocument.cpp
+++ b/mozilla/layout/html/document/src/nsHTMLDocument.cpp
@@ -40,6 +40,8 @@
#include "nsIScriptGlobalObject.h"
#include "nsContentList.h"
#include "nsINetService.h"
+#include "nsRepository.h"
+#include "nsParserCIID.h"
//#define rickgdebug 1
#ifdef rickgdebug
@@ -142,7 +144,14 @@ nsHTMLDocument::StartDocumentLoad(nsIURL *aURL,
mDocumentURL = aURL;
NS_ADDREF(aURL);
- rv = NS_NewParser(&mParser);
+ static NS_DEFINE_IID(kCParserIID, NS_IPARSER_IID);
+ static NS_DEFINE_IID(kCParserCID, NS_PARSER_IID);
+
+ rv = NSRepository::CreateInstance(kCParserCID,
+ nsnull,
+ kCParserIID,
+ (void **)&mParser);
+
if (NS_OK == rv) {
nsIHTMLContentSink* sink;
diff --git a/mozilla/parser/htmlparser/robot/nsDebugRobot.cpp b/mozilla/parser/htmlparser/robot/nsDebugRobot.cpp
index 8d3d9dfc73a..d11eb72a92b 100644
--- a/mozilla/parser/htmlparser/robot/nsDebugRobot.cpp
+++ b/mozilla/parser/htmlparser/robot/nsDebugRobot.cpp
@@ -24,6 +24,8 @@
#include "nsIURL.h"
#include "nsIStreamListener.h"
#include "nsIDTDDebug.h"
+#include "nsRepository.h"
+#include "nsParserCIID.h"
static NS_DEFINE_IID(kIRobotSinkObserverIID, NS_IROBOTSINKOBSERVER_IID);
@@ -210,7 +212,15 @@ extern "C" NS_EXPORT int DebugRobot(
delete urlName;
nsIParser* parser;
- rv = NS_NewParser(&parser);
+
+ static NS_DEFINE_IID(kCParserIID, NS_IPARSER_IID);
+ static NS_DEFINE_IID(kCParserCID, NS_PARSER_IID);
+
+ rv = NSRepository::CreateInstance(kCParserCID,
+ nsnull,
+ kCParserIID,
+ (void **)&parser);
+
if (NS_OK != rv) {
printf("can't make parser\n");
NS_RELEASE(myObserver);
diff --git a/mozilla/parser/htmlparser/robot/test/RobotMain.cpp b/mozilla/parser/htmlparser/robot/test/RobotMain.cpp
index a8d973859ad..be5db4989c0 100644
--- a/mozilla/parser/htmlparser/robot/test/RobotMain.cpp
+++ b/mozilla/parser/htmlparser/robot/test/RobotMain.cpp
@@ -2,6 +2,14 @@
#include "nsVoidArray.h"
#include "nsIWebShell.h"
#include "nsString.h"
+#include "nsRepository.h"
+#include "nsParserCIID.h"
+
+#ifdef XP_PC
+#define PARSER_DLL "raptorhtmlpars.dll"
+#else
+#define PARSER_DLL "libraptorhtmlpars.so"
+#endif
extern "C" NS_EXPORT int DebugRobot(nsVoidArray * workList, nsIWebShell * ww);
@@ -12,6 +20,10 @@ int main(int argc, char **argv)
for (i = 1; i < argc; i++) {
gWorkList->AppendElement(new nsString(argv[i]));
}
+
+ static NS_DEFINE_IID(kCParserCID, NS_PARSER_IID);
+ NSRepository::RegisterFactory(kCParserCID, PARSER_DLL, PR_FALSE, PR_FALSE);
+
return DebugRobot(gWorkList, nsnull);
}
diff --git a/mozilla/parser/htmlparser/src/Makefile b/mozilla/parser/htmlparser/src/Makefile
index 51e490da6f2..74a1d848ad9 100644
--- a/mozilla/parser/htmlparser/src/Makefile
+++ b/mozilla/parser/htmlparser/src/Makefile
@@ -40,6 +40,7 @@ CPPSRCS = \
prstrm.cpp \
nsHTMLContentSinkStream.cpp \
nsXIFDTD.cpp \
+ nsParserFactory.cpp \
$(NULL)
EXPORTS = \
@@ -59,6 +60,7 @@ EXPORTS = \
nsValidDTD.h \
CRtfDTD.h \
nsXIFDTD.h \
+ nsParserCIID.h \
$(NULL)
EXTRA_EXPORTS = \
diff --git a/mozilla/parser/htmlparser/src/SelfTest.cpp b/mozilla/parser/htmlparser/src/SelfTest.cpp
index 31186bc3760..5be0cb72f3f 100644
--- a/mozilla/parser/htmlparser/src/SelfTest.cpp
+++ b/mozilla/parser/htmlparser/src/SelfTest.cpp
@@ -28,6 +28,14 @@
#include "nsHTMLDelegate.h"
#include "nsIParser.h"
#include "nsHTMLContentSink.h"
+#include "nsRepository.h"
+#include "nsParserCIID.h"
+
+#ifdef XP_PC
+#define PARSER_DLL "raptorhtmlpars.dll"
+#else
+#define PARSER_DLL "libraptorhtmlpars.so"
+#endif
ofstream filelist("filelist.out");
@@ -99,8 +107,15 @@ void parseFile (const char* aFilename,int size)
strcat(filename,".tokens");
{
nsIParser* parser;
- nsresult rv = NS_NewParser(&parser);
- nsresult r=NS_NewParser(&parser);
+
+ static NS_DEFINE_IID(kCParserIID, NS_IPARSER_IID);
+ static NS_DEFINE_IID(kCParserCID, NS_PARSER_IID);
+
+ nsresult rv = NSRepository::CreateInstance(kCParserCID,
+ nsnull,
+ kCParserIID,
+ (void **)&parser);
+
CHTMLContentSink theSink;
parser->setContentSink(&theSink);
parser->parse(aFilename);
@@ -180,6 +195,10 @@ int main(int argc, char* argv [])
if(argc==2)
strcpy(buffer,argv[1]);
else _getcwd(buffer,_MAX_PATH);
+
+ static NS_DEFINE_IID(kCParserCID, NS_PARSER_IID);
+ NSRepository::RegisterFactory(kCParserCID, PARSER_DLL, PR_FALSE, PR_FALSE);
+
walkDirectoryTree(buffer);
return 0;
}
diff --git a/mozilla/parser/htmlparser/src/makefile.win b/mozilla/parser/htmlparser/src/makefile.win
index 2a37992d70b..59c1dd96e67 100644
--- a/mozilla/parser/htmlparser/src/makefile.win
+++ b/mozilla/parser/htmlparser/src/makefile.win
@@ -42,6 +42,7 @@ CPPSRCS= \
nsWellFormed.cpp \
nsXIFDTD.cpp \
prstrm.cpp \
+ nsParserFactory.cpp \
$(NULL)
CPP_OBJS= \
@@ -63,6 +64,7 @@ CPP_OBJS= \
.\$(OBJDIR)\nsWellFormedDTD.obj \
.\$(OBJDIR)\nsXIFDTD.obj \
.\$(OBJDIR)\prstrm.obj \
+ .\$(OBJDIR)\nsParserFactory.obj \
$(NULL)
EXPORTS= \
@@ -83,6 +85,7 @@ EXPORTS= \
COtherDTD.h \
nsIDTD.h \
nsXIFDTD.h \
+ nsParserCIID.h \
$(NULL)
EXTRA_EXPORTS= \
diff --git a/mozilla/parser/htmlparser/src/nsIParser.h b/mozilla/parser/htmlparser/src/nsIParser.h
index f841dc14b53..176a6a147d2 100644
--- a/mozilla/parser/htmlparser/src/nsIParser.h
+++ b/mozilla/parser/htmlparser/src/nsIParser.h
@@ -106,6 +106,4 @@ class nsIParser : public nsISupports {
};
-extern NS_HTMLPARS nsresult NS_NewParser(nsIParser** aInstancePtrResult);
-
#endif
diff --git a/mozilla/parser/htmlparser/src/nsIParserFilter.h b/mozilla/parser/htmlparser/src/nsIParserFilter.h
index ef3912af04d..b6fc986ee77 100644
--- a/mozilla/parser/htmlparser/src/nsIParserFilter.h
+++ b/mozilla/parser/htmlparser/src/nsIParserFilter.h
@@ -48,7 +48,6 @@ class nsIParserFilter : public nsISupports {
NS_IMETHOD ProcessTokens( /* dont know what goes here yet */ void ) = 0;
};
-extern nsresult NS_NewParserFilter(nsIParserFilter** aInstancePtrResult);
#endif
diff --git a/mozilla/parser/htmlparser/src/nsIParserNode.h b/mozilla/parser/htmlparser/src/nsIParserNode.h
index 0ea87656edf..5c30aeabc84 100644
--- a/mozilla/parser/htmlparser/src/nsIParserNode.h
+++ b/mozilla/parser/htmlparser/src/nsIParserNode.h
@@ -36,10 +36,19 @@
#ifndef NS_IPARSERNODE__
#define NS_IPARSERNODE__
+#include "nshtmlpars.h"
+#include "nsISupports.h"
#include "prtypes.h"
#include "nsString.h"
#include "nsDebug.h"
+class CToken;
+
+// 6e59f160-2717-11d2-9246-00805f8a7ab6
+#define NS_IPARSER_NODE_IID \
+ {0x6e59f160, 0x2717, 0x11d1, \
+ {0x92, 0x46, 0x00, 0x80, 0x5f, 0x8a, 0x7a, 0xb6}}
+
/**
* Parser nodes are the unit of exchange between the
* parser and the content sink. Nodes offer access to
@@ -48,7 +57,7 @@
*
* @update gess 3/25/98
*/
-class nsIParserNode {
+class nsIParserNode : public nsISupports {
public:
@@ -130,6 +139,10 @@ class nsIParserNode {
};
+extern NS_HTMLPARS nsresult NS_NewParserNode(nsIParserNode** aInstancePtrResult,
+ CToken* aToken,
+ PRInt32 aLineNumber);
+
#endif
diff --git a/mozilla/parser/htmlparser/src/nsParser.cpp b/mozilla/parser/htmlparser/src/nsParser.cpp
index 8239c9ed615..7c8a901712f 100644
--- a/mozilla/parser/htmlparser/src/nsParser.cpp
+++ b/mozilla/parser/htmlparser/src/nsParser.cpp
@@ -50,26 +50,6 @@ static nsString kEmptyString("unknown");
static const int gTransferBufferSize=4096; //size of the buffer used in moving data from iistream
-
-/**
- * This method is defined in nsIParser. It is used to
- * cause the COM-like construction of an nsParser.
- *
- * @update gess 3/25/98
- * @param nsIParser** ptr to newly instantiated parser
- * @return NS_xxx error result
- */
-NS_HTMLPARS nsresult NS_NewParser(nsIParser** aInstancePtrResult)
-{
- nsParser *it = new nsParser();
-
- if (it == 0) {
- return NS_ERROR_OUT_OF_MEMORY;
- }
-
- return it->QueryInterface(kIParserIID, (void **) aInstancePtrResult);
-}
-
class CTokenDeallocator: public nsDequeFunctor{
public:
virtual void* operator()(void* anObject) {
diff --git a/mozilla/parser/htmlparser/src/nsParser.h b/mozilla/parser/htmlparser/src/nsParser.h
index 1970349a952..50eab8e6032 100644
--- a/mozilla/parser/htmlparser/src/nsParser.h
+++ b/mozilla/parser/htmlparser/src/nsParser.h
@@ -61,11 +61,7 @@
#include "nsParserTypes.h"
#include "nsIURL.h"
#include "CParserContext.h"
-
-#define NS_PARSER_IID \
- {0x2ce606b0, 0xbee6, 0x11d1, \
- {0xaa, 0xd9, 0x00, 0x80, 0x5f, 0x8a, 0x3e, 0x14}}
-
+#include "nsParserCIID.h"
class IContentSink;
class nsIHTMLContentSink;
diff --git a/mozilla/parser/htmlparser/src/nsParserCIID.h b/mozilla/parser/htmlparser/src/nsParserCIID.h
new file mode 100644
index 00000000000..1e870fd8b10
--- /dev/null
+++ b/mozilla/parser/htmlparser/src/nsParserCIID.h
@@ -0,0 +1,38 @@
+/* -*- 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.0 (the "NPL"); you may not use this file except in
+ * compliance with the NPL. You may obtain a copy of the NPL at
+ * http://www.mozilla.org/NPL/
+ *
+ * Software distributed under the NPL is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
+ * for the specific language governing rights and limitations under the
+ * NPL.
+ *
+ * The Initial Developer of this code under the NPL is Netscape
+ * Communications Corporation. Portions created by Netscape are
+ * Copyright (C) 1998 Netscape Communications Corporation. All Rights
+ * Reserved.
+ */
+
+#ifndef nsParserCIID_h__
+#define nsParserCIID_h__
+
+#include "nsISupports.h"
+#include "nsIFactory.h"
+#include "nsRepository.h"
+
+#define NS_PARSER_IID \
+ {0x2ce606b0, 0xbee6, 0x11d1, \
+ {0xaa, 0xd9, 0x00, 0x80, 0x5f, 0x8a, 0x3e, 0x14}}
+
+// XXX: This object should not be exposed outside of the parser.
+// Remove when CNavDTD subclasses do not need access
+#define NS_PARSER_NODE_IID \
+ {0x9039c670, 0x2717, 0x11d2, \
+ {0x92, 0x46, 0x00, 0x80, 0x5f, 0x8a, 0x7a, 0xb6}}
+
+
+
+#endif
diff --git a/mozilla/parser/htmlparser/src/nsParserFactory.cpp b/mozilla/parser/htmlparser/src/nsParserFactory.cpp
new file mode 100644
index 00000000000..5c4c96d9631
--- /dev/null
+++ b/mozilla/parser/htmlparser/src/nsParserFactory.cpp
@@ -0,0 +1,160 @@
+/* -*- 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.0 (the "NPL"); you may not use this file except in
+ * compliance with the NPL. You may obtain a copy of the NPL at
+ * http://www.mozilla.org/NPL/
+ *
+ * Software distributed under the NPL is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
+ * for the specific language governing rights and limitations under the
+ * NPL.
+ *
+ * The Initial Developer of this code under the NPL is Netscape
+ * Communications Corporation. Portions created by Netscape are
+ * Copyright (C) 1998 Netscape Communications Corporation. All Rights
+ * Reserved.
+ */
+
+#include "nscore.h"
+#include "nsIFactory.h"
+#include "nsISupports.h"
+#include "nsParserCIID.h"
+
+#include "nsParser.h"
+#include "nsParserNode.h"
+
+static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID);
+static NS_DEFINE_IID(kIFactoryIID, NS_IFACTORY_IID);
+
+static NS_DEFINE_IID(kCParser, NS_PARSER_IID);
+static NS_DEFINE_IID(kCParserNode, NS_PARSER_NODE_IID);
+
+class nsParserFactory : public nsIFactory
+{
+ public:
+ // nsISupports methods
+ NS_IMETHOD QueryInterface(const nsIID &aIID,
+ void **aResult);
+ NS_IMETHOD_(nsrefcnt) AddRef(void);
+ NS_IMETHOD_(nsrefcnt) Release(void);
+
+ // nsIFactory methods
+ NS_IMETHOD CreateInstance(nsISupports *aOuter,
+ const nsIID &aIID,
+ void **aResult);
+
+ NS_IMETHOD LockFactory(PRBool aLock);
+
+ nsParserFactory(const nsCID &aClass);
+ ~nsParserFactory();
+
+ private:
+ nsrefcnt mRefCnt;
+ nsCID mClassID;
+};
+
+nsParserFactory::nsParserFactory(const nsCID &aClass)
+{
+ mRefCnt = 0;
+ mClassID = aClass;
+}
+
+nsParserFactory::~nsParserFactory()
+{
+ NS_ASSERTION(mRefCnt == 0, "non-zero refcnt at destruction");
+}
+
+nsresult nsParserFactory::QueryInterface(const nsIID &aIID,
+ void **aResult)
+{
+ if (aResult == NULL) {
+ return NS_ERROR_NULL_POINTER;
+ }
+
+ // Always NULL result, in case of failure
+ *aResult = NULL;
+
+ if (aIID.Equals(kISupportsIID)) {
+ *aResult = (void *)(nsISupports*)this;
+ } else if (aIID.Equals(kIFactoryIID)) {
+ *aResult = (void *)(nsIFactory*)this;
+ }
+
+ if (*aResult == NULL) {
+ return NS_NOINTERFACE;
+ }
+
+ AddRef(); // Increase reference count for caller
+ return NS_OK;
+}
+
+nsrefcnt nsParserFactory::AddRef()
+{
+ return ++mRefCnt;
+}
+
+nsrefcnt nsParserFactory::Release()
+{
+ if (--mRefCnt == 0) {
+ delete this;
+ return 0; // Don't access mRefCnt after deleting!
+ }
+ return mRefCnt;
+}
+
+nsresult nsParserFactory::CreateInstance(nsISupports *aOuter,
+ const nsIID &aIID,
+ void **aResult)
+{
+ if (aResult == NULL) {
+ return NS_ERROR_NULL_POINTER;
+ }
+
+ *aResult = NULL;
+
+ nsISupports *inst = nsnull;
+
+ if (mClassID.Equals(kCParser)) {
+ inst = (nsISupports *)(nsIParser *)new nsParser();
+ }
+ else if (mClassID.Equals(kCParserNode)) {
+ inst = (nsISupports *)(nsIParserNode *)new nsCParserNode();
+ }
+
+ if (inst == NULL) {
+ return NS_ERROR_OUT_OF_MEMORY;
+ }
+
+ nsresult res = inst->QueryInterface(aIID, aResult);
+
+ if (res != NS_OK) {
+ // We didn't get the right interface, so clean up
+ delete inst;
+ }
+
+ return res;
+}
+
+nsresult nsParserFactory::LockFactory(PRBool aLock)
+{
+ // Not implemented in simplest case.
+ return NS_OK;
+}
+
+// return the proper factory to the caller
+extern "C" NS_EXPORT nsresult NSGetFactory(const nsCID &aClass, nsIFactory **aFactory)
+{
+ if (nsnull == aFactory) {
+ return NS_ERROR_NULL_POINTER;
+ }
+
+ *aFactory = new nsParserFactory(aClass);
+
+ if (nsnull == aFactory) {
+ return NS_ERROR_OUT_OF_MEMORY;
+ }
+
+ return (*aFactory)->QueryInterface(kIFactoryIID, (void**)aFactory);
+}
+
diff --git a/mozilla/parser/htmlparser/src/nsParserNode.cpp b/mozilla/parser/htmlparser/src/nsParserNode.cpp
index 670d31bc292..73e57512868 100644
--- a/mozilla/parser/htmlparser/src/nsParserNode.cpp
+++ b/mozilla/parser/htmlparser/src/nsParserNode.cpp
@@ -20,9 +20,33 @@
#include "nsParserNode.h"
#include "string.h"
#include "nsHTMLTokens.h"
+#include "nshtmlpars.h"
const nsAutoString nsCParserNode::mEmptyString("");
+static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID);
+static NS_DEFINE_IID(kClassIID, NS_PARSER_NODE_IID);
+static NS_DEFINE_IID(kIParserNodeIID, NS_IPARSER_NODE_IID);
+
+/**
+ * This method is defined in nsIParser. It is used to
+ * cause the COM-like construction of an nsParser.
+ *
+ * @update gess 3/25/98
+ * @param nsIParser** ptr to newly instantiated parser
+ * @return NS_xxx error result
+ */
+NS_HTMLPARS nsresult NS_NewParserNode(nsIParserNode** aInstancePtrResult,CToken* aToken,PRInt32 aLineNumber)
+{
+ nsCParserNode *it = new nsCParserNode(aToken,aLineNumber);
+
+ if (it == 0) {
+ return NS_ERROR_OUT_OF_MEMORY;
+ }
+
+ return it->QueryInterface(kIParserNodeIID, (void **) aInstancePtrResult);
+}
+
/**
* Default constructor
*
@@ -31,7 +55,7 @@ const nsAutoString nsCParserNode::mEmptyString("");
* @return
*/
nsCParserNode::nsCParserNode(CToken* aToken,PRInt32 aLineNumber): nsIParserNode() {
- NS_PRECONDITION(0!=aToken, "Null Token");
+ NS_INIT_REFCNT();
mAttributeCount=0;
mLineNumber=aLineNumber;
mToken=aToken;
@@ -49,6 +73,57 @@ nsCParserNode::nsCParserNode(CToken* aToken,PRInt32 aLineNumber): nsIParserNode(
nsCParserNode::~nsCParserNode() {
}
+NS_IMPL_ADDREF(nsCParserNode)
+NS_IMPL_RELEASE(nsCParserNode)
+
+/**
+ * Init
+ *
+ * @update gess 3/25/98
+ * @param
+ * @return
+ */
+
+nsresult nsCParserNode::Init(CToken* aToken,PRInt32 aLineNumber)
+{
+ mLineNumber=aLineNumber;
+ mToken=aToken;
+ return NS_OK;
+}
+
+/**
+ * This method gets called as part of our COM-like interfaces.
+ * Its purpose is to create an interface to parser object
+ * of some type.
+ *
+ * @update gess 3/25/98
+ * @param nsIID id of object to discover
+ * @param aInstancePtr ptr to newly discovered interface
+ * @return NS_xxx result code
+ */
+nsresult nsCParserNode::QueryInterface(const nsIID& aIID, void** aInstancePtr)
+{
+ if (NULL == aInstancePtr) {
+ return NS_ERROR_NULL_POINTER;
+ }
+
+ if(aIID.Equals(kISupportsIID)) { //do IUnknown...
+ *aInstancePtr = (nsIParserNode*)(this);
+ }
+ else if(aIID.Equals(kIParserNodeIID)) { //do IParser base class...
+ *aInstancePtr = (nsIParserNode*)(this);
+ }
+ else if(aIID.Equals(kClassIID)) { //do this class...
+ *aInstancePtr = (nsCParserNode*)(this);
+ }
+ else {
+ *aInstancePtr=0;
+ return NS_NOINTERFACE;
+ }
+ ((nsISupports*) *aInstancePtr)->AddRef();
+ return NS_OK;
+}
+
/**
* Causes the given attribute to be added to internal
diff --git a/mozilla/parser/htmlparser/src/nsParserNode.h b/mozilla/parser/htmlparser/src/nsParserNode.h
index 50ca3707cd1..919a7c5df91 100644
--- a/mozilla/parser/htmlparser/src/nsParserNode.h
+++ b/mozilla/parser/htmlparser/src/nsParserNode.h
@@ -39,20 +39,22 @@
#include "nsIParserNode.h"
#include "nsToken.h"
#include "nsString.h"
+#include "nsParserCIID.h"
-//class nsParser;
class nsCParserNode : public nsIParserNode {
enum {eMaxAttr=20};
public:
+ NS_DECL_ISUPPORTS
+
/**
* Default constructor
* @update gess5/11/98
* @param aToken is the token this node "refers" to
*/
- nsCParserNode(CToken* aToken,PRInt32 aLineNumber=1);
+ nsCParserNode(CToken* aToken=nsnull,PRInt32 aLineNumber=1);
/**
* Destructor
@@ -60,6 +62,12 @@ class nsCParserNode : public nsIParserNode {
*/
virtual ~nsCParserNode();
+ /**
+ * Init
+ * @update gess5/11/98
+ */
+ virtual nsresult Init(CToken* aToken=nsnull,PRInt32 aLineNumber=1);
+
/**
* Retrieve the name of the node
* @update gess5/11/98
diff --git a/mozilla/webshell/tests/viewer/nsBrowserWindow.cpp b/mozilla/webshell/tests/viewer/nsBrowserWindow.cpp
index bd43ff36bea..c1efb7e6349 100644
--- a/mozilla/webshell/tests/viewer/nsBrowserWindow.cpp
+++ b/mozilla/webshell/tests/viewer/nsBrowserWindow.cpp
@@ -40,6 +40,8 @@
#include "nsWidgetsCID.h"
#include "nsViewerApp.h"
#include "prprf.h"
+#include "nsRepository.h"
+#include "nsParserCIID.h"
#include "resources.h"
@@ -1295,7 +1297,15 @@ nsBrowserWindow::DoDebugSave()
doc->CreateXIF(buffer,PR_FALSE);
nsIParser* parser;
- nsresult rv = NS_NewParser(&parser);
+
+ static NS_DEFINE_IID(kCParserIID, NS_IPARSER_IID);
+ static NS_DEFINE_IID(kCParserCID, NS_PARSER_IID);
+
+ nsresult rv = NSRepository::CreateInstance(kCParserCID,
+ nsnull,
+ kCParserIID,
+ (void **)&parser);
+
if (NS_OK == rv) {
nsIHTMLContentSink* sink = nsnull;
@@ -1346,7 +1356,15 @@ nsBrowserWindow::DoCopy()
doc->CreateXIF(buffer,PR_TRUE);
nsIParser* parser;
- nsresult rv = NS_NewParser(&parser);
+
+ static NS_DEFINE_IID(kCParserIID, NS_IPARSER_IID);
+ static NS_DEFINE_IID(kCParserCID, NS_PARSER_IID);
+
+ nsresult rv = NSRepository::CreateInstance(kCParserCID,
+ nsnull,
+ kCParserIID,
+ (void **)&parser);
+
if (NS_OK == rv) {
nsIHTMLContentSink* sink = nsnull;
diff --git a/mozilla/webshell/tests/viewer/nsSetupRegistry.cpp b/mozilla/webshell/tests/viewer/nsSetupRegistry.cpp
index 798b4ae4b68..bf3440ddfa1 100644
--- a/mozilla/webshell/tests/viewer/nsSetupRegistry.cpp
+++ b/mozilla/webshell/tests/viewer/nsSetupRegistry.cpp
@@ -35,6 +35,8 @@
#include "nsIDocumentLoader.h"
#include "nsIThrobber.h"
+#include "nsParserCIID.h"
+
#ifdef XP_PC
#define WIDGET_DLL "raptorwidget.dll"
#define GFXWIN_DLL "raptorgfxwin.dll"
@@ -42,6 +44,7 @@
#define WEB_DLL "raptorweb.dll"
#define PLUGIN_DLL "raptorplugin.dll"
#define PREF_DLL "xppref32.dll"
+#define PARSER_DLL "raptorhtmlpars.dll"
#else
#define WIDGET_DLL "libwidgetunix.so"
#define GFXWIN_DLL "libgfxunix.so"
@@ -49,6 +52,7 @@
#define WEB_DLL "libraptorwebwidget.so"
#define PLUGIN_DLL "raptorplugin.so"
#define PREF_DLL "libpref.so"
+#define PARSER_DLL "libraptorhtmlpars.so"
#endif
// Class ID's
@@ -78,6 +82,7 @@ static NS_DEFINE_IID(kWebShellCID, NS_WEB_SHELL_CID);
static NS_DEFINE_IID(kCDocumentLoaderCID, NS_DOCUMENTLOADER_CID);
static NS_DEFINE_IID(kThrobberCID, NS_THROBBER_CID);
static NS_DEFINE_IID(kCPluginHostCID, NS_PLUGIN_HOST_CID);
+static NS_DEFINE_IID(kCParserCID, NS_PARSER_IID);
extern "C" void
NS_SetupRegistry()
@@ -108,4 +113,5 @@ NS_SetupRegistry()
NSRepository::RegisterFactory(kThrobberCID, WEB_DLL, PR_FALSE, PR_FALSE);
NSRepository::RegisterFactory(kPrefCID, PREF_DLL, PR_FALSE, PR_FALSE);
NSRepository::RegisterFactory(kCPluginHostCID, PLUGIN_DLL, PR_FALSE, PR_FALSE);
+ NSRepository::RegisterFactory(kCParserCID, PARSER_DLL, PR_FALSE, PR_FALSE);
}