1998-09-17 05:53:52 +04:00
|
|
|
/* -*- 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 "nslayout.h"
|
1999-10-01 01:14:14 +04:00
|
|
|
#include "nsLayoutModule.h"
|
1998-09-17 05:53:52 +04:00
|
|
|
#include "nsIFactory.h"
|
|
|
|
#include "nsISupports.h"
|
|
|
|
#include "nsLayoutCID.h"
|
|
|
|
#include "nsIDocument.h"
|
|
|
|
#include "nsIHTMLContent.h"
|
1999-01-15 02:14:02 +03:00
|
|
|
#include "nsITextContent.h"
|
1998-12-03 23:21:40 +03:00
|
|
|
#include "nsIPresShell.h"
|
1999-05-06 23:26:13 +04:00
|
|
|
#include "nsIPresContext.h"
|
1999-02-12 02:12:28 +03:00
|
|
|
#include "nsIDOMSelection.h"
|
1998-12-10 21:04:37 +03:00
|
|
|
#include "nsIFrameUtil.h"
|
1998-09-17 05:53:52 +04:00
|
|
|
|
|
|
|
#include "nsHTMLAtoms.h"
|
|
|
|
#include "nsHTMLParts.h"
|
|
|
|
#include "nsDOMCID.h"
|
|
|
|
#include "nsIServiceManager.h"
|
1998-12-02 02:29:16 +03:00
|
|
|
#include "nsICSSParser.h"
|
1998-12-03 23:21:40 +03:00
|
|
|
#include "nsIHTMLStyleSheet.h"
|
1999-03-05 03:06:31 +03:00
|
|
|
#include "nsIHTMLCSSStyleSheet.h"
|
1999-05-19 03:04:12 +04:00
|
|
|
#include "nsICSSLoader.h"
|
1998-12-04 00:44:12 +03:00
|
|
|
#include "nsIDOMRange.h"
|
1999-02-12 08:28:12 +03:00
|
|
|
#include "nsIContentIterator.h"
|
1998-12-11 05:35:54 +03:00
|
|
|
#include "nsINameSpaceManager.h"
|
1998-12-23 01:03:20 +03:00
|
|
|
#include "nsIScriptNameSetRegistry.h"
|
|
|
|
#include "nsIScriptNameSpaceManager.h"
|
|
|
|
#include "nsIScriptExternalNameSet.h"
|
1999-01-27 03:58:49 +03:00
|
|
|
#include "nsIEventListenerManager.h"
|
1999-05-06 23:26:13 +04:00
|
|
|
#include "nsILayoutDebugger.h"
|
|
|
|
#include "nsIHTMLElementFactory.h"
|
1999-10-05 04:12:21 +04:00
|
|
|
#include "nsIXMLElementFactory.h"
|
1999-06-05 02:22:53 +04:00
|
|
|
#include "nsIDocumentEncoder.h"
|
1999-05-06 23:26:13 +04:00
|
|
|
#include "nsCOMPtr.h"
|
1999-07-18 06:27:19 +04:00
|
|
|
#include "nsIFrameSelection.h"
|
1998-09-17 05:53:52 +04:00
|
|
|
|
1999-05-06 23:26:13 +04:00
|
|
|
class nsIDocumentLoaderFactory;
|
|
|
|
|
|
|
|
static NS_DEFINE_CID(kComponentManagerCID, NS_COMPONENTMANAGER_CID);
|
|
|
|
|
|
|
|
static NS_DEFINE_IID(kHTMLDocumentCID, NS_HTMLDOCUMENT_CID);
|
|
|
|
static NS_DEFINE_IID(kXMLDocumentCID, NS_XMLDOCUMENT_CID);
|
1999-10-05 04:12:21 +04:00
|
|
|
static NS_DEFINE_CID(kXMLElementFactoryCID, NS_XML_ELEMENT_FACTORY_CID);
|
1999-05-06 23:26:13 +04:00
|
|
|
static NS_DEFINE_IID(kImageDocumentCID, NS_IMAGEDOCUMENT_CID);
|
|
|
|
static NS_DEFINE_IID(kCSSParserCID, NS_CSSPARSER_CID);
|
1998-12-03 23:21:40 +03:00
|
|
|
static NS_DEFINE_CID(kHTMLStyleSheetCID, NS_HTMLSTYLESHEET_CID);
|
1999-03-05 03:06:31 +03:00
|
|
|
static NS_DEFINE_CID(kHTMLCSSStyleSheetCID, NS_HTML_CSS_STYLESHEET_CID);
|
1999-05-19 03:04:12 +04:00
|
|
|
static NS_DEFINE_CID(kCSSLoaderCID, NS_CSS_LOADER_CID);
|
1999-05-06 23:26:13 +04:00
|
|
|
static NS_DEFINE_IID(kHTMLImageElementCID, NS_HTMLIMAGEELEMENT_CID);
|
|
|
|
static NS_DEFINE_IID(kHTMLOptionElementCID, NS_HTMLOPTIONELEMENT_CID);
|
|
|
|
|
|
|
|
static NS_DEFINE_CID(kSelectionCID, NS_SELECTION_CID);
|
1999-07-18 06:27:19 +04:00
|
|
|
static NS_DEFINE_IID(kFrameSelectionCID, NS_FRAMESELECTION_CID);
|
1999-05-06 23:26:13 +04:00
|
|
|
static NS_DEFINE_IID(kRangeCID, NS_RANGE_CID);
|
|
|
|
static NS_DEFINE_IID(kContentIteratorCID, NS_CONTENTITERATOR_CID);
|
|
|
|
static NS_DEFINE_IID(kSubtreeIteratorCID, NS_SUBTREEITERATOR_CID);
|
|
|
|
|
1998-12-03 23:21:40 +03:00
|
|
|
static NS_DEFINE_CID(kPresShellCID, NS_PRESSHELL_CID);
|
|
|
|
static NS_DEFINE_CID(kTextNodeCID, NS_TEXTNODE_CID);
|
1998-12-11 05:35:54 +03:00
|
|
|
static NS_DEFINE_CID(kNameSpaceManagerCID, NS_NAMESPACEMANAGER_CID);
|
1998-12-10 21:04:37 +03:00
|
|
|
static NS_DEFINE_CID(kFrameUtilCID, NS_FRAME_UTIL_CID);
|
1999-01-27 03:58:49 +03:00
|
|
|
static NS_DEFINE_CID(kEventListenerManagerCID, NS_EVENTLISTENERMANAGER_CID);
|
1999-05-06 23:26:13 +04:00
|
|
|
static NS_DEFINE_CID(kPrintPreviewContextCID, NS_PRINT_PREVIEW_CONTEXT_CID);
|
1998-11-30 01:11:06 +03:00
|
|
|
|
1999-05-06 23:26:13 +04:00
|
|
|
static NS_DEFINE_CID(kLayoutDocumentLoaderFactoryCID, NS_LAYOUT_DOCUMENT_LOADER_FACTORY_CID);
|
|
|
|
static NS_DEFINE_CID(kLayoutDebuggerCID, NS_LAYOUT_DEBUGGER_CID);
|
|
|
|
static NS_DEFINE_CID(kHTMLElementFactoryCID, NS_HTML_ELEMENT_FACTORY_CID);
|
1999-06-10 04:35:02 +04:00
|
|
|
static NS_DEFINE_CID(kTextEncoderCID, NS_TEXT_ENCODER_CID);
|
1998-11-30 01:11:06 +03:00
|
|
|
|
1999-07-18 06:27:19 +04:00
|
|
|
extern nsresult NS_NewRangeList(nsIFrameSelection** aResult);
|
1999-05-06 23:26:13 +04:00
|
|
|
extern nsresult NS_NewRange(nsIDOMRange** aResult);
|
|
|
|
extern nsresult NS_NewContentIterator(nsIContentIterator** aResult);
|
|
|
|
extern nsresult NS_NewContentSubtreeIterator(nsIContentIterator** aResult);
|
1998-12-10 21:04:37 +03:00
|
|
|
extern nsresult NS_NewFrameUtil(nsIFrameUtil** aResult);
|
1998-09-17 05:53:52 +04:00
|
|
|
|
1999-05-06 23:26:13 +04:00
|
|
|
extern nsresult NS_NewLayoutDocumentLoaderFactory(nsIDocumentLoaderFactory** aResult);
|
|
|
|
extern nsresult NS_NewLayoutDebugger(nsILayoutDebugger** aResult);
|
|
|
|
extern nsresult NS_NewHTMLElementFactory(nsIHTMLElementFactory** aResult);
|
1999-06-05 02:22:53 +04:00
|
|
|
extern nsresult NS_NewHTMLEncoder(nsIDocumentEncoder** aResult);
|
1999-06-10 04:35:02 +04:00
|
|
|
extern nsresult NS_NewTextEncoder(nsIDocumentEncoder** aResult);
|
1998-09-17 05:53:52 +04:00
|
|
|
|
1999-10-01 01:14:14 +04:00
|
|
|
//----------------------------------------------------------------------
|
1998-09-17 05:53:52 +04:00
|
|
|
|
|
|
|
static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID);
|
|
|
|
static NS_DEFINE_IID(kIFactoryIID, NS_IFACTORY_IID);
|
|
|
|
|
1999-10-05 18:50:30 +04:00
|
|
|
nsLayoutFactory::nsLayoutFactory(const nsCID &aClass)
|
|
|
|
{
|
1998-09-17 05:53:52 +04:00
|
|
|
mRefCnt = 0;
|
|
|
|
mClassID = aClass;
|
1999-10-05 18:50:30 +04:00
|
|
|
#if 0
|
1999-10-01 01:14:14 +04:00
|
|
|
char* cs = aClass.ToString();
|
|
|
|
printf("+++ Creating layout factory for %s\n", cs);
|
|
|
|
nsCRT::free(cs);
|
1999-09-02 22:01:32 +04:00
|
|
|
#endif
|
1999-10-05 18:50:30 +04:00
|
|
|
}
|
1998-09-17 05:53:52 +04:00
|
|
|
|
1999-10-05 18:50:30 +04:00
|
|
|
nsLayoutFactory::~nsLayoutFactory()
|
|
|
|
{
|
|
|
|
#if 0
|
1999-10-01 01:14:14 +04:00
|
|
|
char* cs = mClassID.ToString();
|
|
|
|
printf("+++ Destroying layout factory for %s\n", cs);
|
|
|
|
nsCRT::free(cs);
|
1999-09-02 22:01:32 +04:00
|
|
|
#endif
|
1999-10-05 18:50:30 +04:00
|
|
|
}
|
1998-09-17 05:53:52 +04:00
|
|
|
|
1999-05-06 23:26:13 +04:00
|
|
|
nsresult
|
1999-10-05 18:50:30 +04:00
|
|
|
nsLayoutFactory::QueryInterface(const nsIID &aIID, void **aResult)
|
|
|
|
{
|
|
|
|
if (aResult == NULL) {
|
|
|
|
return NS_ERROR_NULL_POINTER;
|
|
|
|
}
|
1998-09-17 05:53:52 +04:00
|
|
|
|
1999-10-05 18:50:30 +04:00
|
|
|
// Always NULL result, in case of failure
|
|
|
|
*aResult = NULL;
|
1998-09-17 05:53:52 +04:00
|
|
|
|
1999-10-05 18:50:30 +04:00
|
|
|
if (aIID.Equals(kISupportsIID)) {
|
|
|
|
*aResult = (void *)(nsISupports*)this;
|
|
|
|
} else if (aIID.Equals(kIFactoryIID)) {
|
|
|
|
*aResult = (void *)(nsIFactory*)this;
|
|
|
|
}
|
1998-09-17 05:53:52 +04:00
|
|
|
|
1999-10-05 18:50:30 +04:00
|
|
|
if (*aResult == NULL) {
|
|
|
|
return NS_NOINTERFACE;
|
|
|
|
}
|
1998-09-17 05:53:52 +04:00
|
|
|
|
1999-10-05 18:50:30 +04:00
|
|
|
AddRef(); // Increase reference count for caller
|
|
|
|
return NS_OK;
|
|
|
|
}
|
1998-09-17 05:53:52 +04:00
|
|
|
|
1999-05-06 23:26:13 +04:00
|
|
|
nsrefcnt
|
1999-10-05 18:50:30 +04:00
|
|
|
nsLayoutFactory::AddRef()
|
|
|
|
{
|
|
|
|
return ++mRefCnt;
|
|
|
|
}
|
1998-09-17 05:53:52 +04:00
|
|
|
|
1999-05-06 23:26:13 +04:00
|
|
|
nsrefcnt
|
1999-10-05 18:50:30 +04:00
|
|
|
nsLayoutFactory::Release()
|
|
|
|
{
|
|
|
|
if (--mRefCnt == 0) {
|
|
|
|
delete this;
|
|
|
|
return 0; // Don't access mRefCnt after deleting!
|
|
|
|
}
|
|
|
|
return mRefCnt;
|
|
|
|
}
|
1998-09-17 05:53:52 +04:00
|
|
|
|
1999-05-06 23:26:13 +04:00
|
|
|
#ifdef DEBUG
|
|
|
|
#define LOG_NEW_FAILURE(_msg,_ec) \
|
|
|
|
printf("nsLayoutFactory::CreateInstance failed for %s: error=%d(0x%x)\n", \
|
|
|
|
_msg, _ec, _ec)
|
|
|
|
#else
|
|
|
|
#define LOG_NEW_FAILURE(_msg,_ec)
|
|
|
|
#endif
|
|
|
|
|
|
|
|
nsresult
|
1999-10-05 18:50:30 +04:00
|
|
|
nsLayoutFactory::CreateInstance(nsISupports *aOuter,
|
|
|
|
const nsIID &aIID,
|
|
|
|
void **aResult)
|
|
|
|
{
|
1998-09-17 05:53:52 +04:00
|
|
|
nsresult res;
|
1999-10-24 20:19:42 +04:00
|
|
|
PRBool refCounted = PR_TRUE; // XXX What is it with this? It is always PR_TRUE???
|
1998-09-17 05:53:52 +04:00
|
|
|
|
1999-10-05 18:50:30 +04:00
|
|
|
if (aResult == NULL) {
|
|
|
|
return NS_ERROR_NULL_POINTER;
|
|
|
|
}
|
|
|
|
|
|
|
|
*aResult = NULL;
|
1998-09-17 05:53:52 +04:00
|
|
|
|
|
|
|
nsISupports *inst = nsnull;
|
|
|
|
|
|
|
|
// XXX ClassID check happens here
|
1999-05-06 23:26:13 +04:00
|
|
|
if (mClassID.Equals(kHTMLDocumentCID)) {
|
1998-09-17 05:53:52 +04:00
|
|
|
res = NS_NewHTMLDocument((nsIDocument **)&inst);
|
1999-05-06 23:26:13 +04:00
|
|
|
if (NS_FAILED(res)) {
|
|
|
|
LOG_NEW_FAILURE("NS_NewHTMLDocument", res);
|
1998-09-17 05:53:52 +04:00
|
|
|
return res;
|
|
|
|
}
|
|
|
|
refCounted = PR_TRUE;
|
|
|
|
}
|
1999-05-06 23:26:13 +04:00
|
|
|
else if (mClassID.Equals(kXMLDocumentCID)) {
|
1998-11-12 01:06:16 +03:00
|
|
|
res = NS_NewXMLDocument((nsIDocument **)&inst);
|
1999-05-06 23:26:13 +04:00
|
|
|
if (NS_FAILED(res)) {
|
|
|
|
LOG_NEW_FAILURE("NS_NewXMLDocument", res);
|
1998-11-12 01:06:16 +03:00
|
|
|
return res;
|
|
|
|
}
|
|
|
|
refCounted = PR_TRUE;
|
|
|
|
}
|
1999-05-06 23:26:13 +04:00
|
|
|
else if (mClassID.Equals(kImageDocumentCID)) {
|
1998-09-17 05:53:52 +04:00
|
|
|
res = NS_NewImageDocument((nsIDocument **)&inst);
|
1999-05-06 23:26:13 +04:00
|
|
|
if (NS_FAILED(res)) {
|
|
|
|
LOG_NEW_FAILURE("NS_NewImageDocument", res);
|
1998-09-17 05:53:52 +04:00
|
|
|
return res;
|
|
|
|
}
|
|
|
|
refCounted = PR_TRUE;
|
|
|
|
}
|
1999-05-06 23:26:13 +04:00
|
|
|
#if 1
|
|
|
|
// XXX replace these with nsIHTMLElementFactory calls
|
|
|
|
else if (mClassID.Equals(kHTMLImageElementCID)) {
|
1998-12-23 01:03:20 +03:00
|
|
|
res = NS_NewHTMLImageElement((nsIHTMLContent**)&inst, nsHTMLAtoms::img);
|
|
|
|
if (NS_FAILED(res)) {
|
1999-05-06 23:26:13 +04:00
|
|
|
LOG_NEW_FAILURE("NS_NewHTMLImageElement", res);
|
1998-12-23 01:03:20 +03:00
|
|
|
return res;
|
|
|
|
}
|
|
|
|
refCounted = PR_TRUE;
|
1998-09-17 05:53:52 +04:00
|
|
|
}
|
1999-05-06 23:26:13 +04:00
|
|
|
else if (mClassID.Equals(kHTMLOptionElementCID)) {
|
1999-05-05 00:52:03 +04:00
|
|
|
res = NS_NewHTMLOptionElement((nsIHTMLContent**)&inst, nsHTMLAtoms::option);
|
|
|
|
if (NS_FAILED(res)) {
|
1999-05-06 23:26:13 +04:00
|
|
|
LOG_NEW_FAILURE("NS_NewHTMLOptionElement", res);
|
1999-05-05 00:52:03 +04:00
|
|
|
return res;
|
|
|
|
}
|
|
|
|
refCounted = PR_TRUE;
|
|
|
|
}
|
1999-05-06 23:26:13 +04:00
|
|
|
// XXX why the heck is this exported???? bad bad bad bad
|
1998-12-03 23:21:40 +03:00
|
|
|
else if (mClassID.Equals(kPresShellCID)) {
|
|
|
|
res = NS_NewPresShell((nsIPresShell**) &inst);
|
|
|
|
if (NS_FAILED(res)) {
|
1999-05-06 23:26:13 +04:00
|
|
|
LOG_NEW_FAILURE("NS_NewPresShell", res);
|
1998-12-03 23:21:40 +03:00
|
|
|
return res;
|
|
|
|
}
|
|
|
|
refCounted = PR_TRUE;
|
|
|
|
}
|
1999-05-06 23:26:13 +04:00
|
|
|
#endif
|
1999-07-18 06:27:19 +04:00
|
|
|
else if (mClassID.Equals(kFrameSelectionCID)) {
|
|
|
|
res = NS_NewRangeList((nsIFrameSelection**)&inst);
|
1999-05-06 23:26:13 +04:00
|
|
|
if (NS_FAILED(res)) {
|
|
|
|
LOG_NEW_FAILURE("NS_NewRangeList", res);
|
1998-11-30 01:11:06 +03:00
|
|
|
return res;
|
|
|
|
}
|
|
|
|
refCounted = PR_TRUE;
|
|
|
|
}
|
1999-05-06 23:26:13 +04:00
|
|
|
else if (mClassID.Equals(kRangeCID)) {
|
1998-12-04 00:44:12 +03:00
|
|
|
res = NS_NewRange((nsIDOMRange **)&inst);
|
1999-05-06 23:26:13 +04:00
|
|
|
if (NS_FAILED(res)) {
|
|
|
|
LOG_NEW_FAILURE("NS_NewRange", res);
|
1998-12-04 00:44:12 +03:00
|
|
|
return res;
|
|
|
|
}
|
|
|
|
refCounted = PR_TRUE;
|
1999-10-05 18:50:30 +04:00
|
|
|
}
|
1999-05-06 23:26:13 +04:00
|
|
|
else if (mClassID.Equals(kContentIteratorCID)) {
|
1999-02-12 08:28:12 +03:00
|
|
|
res = NS_NewContentIterator((nsIContentIterator **)&inst);
|
1999-05-06 23:26:13 +04:00
|
|
|
if (NS_FAILED(res)) {
|
|
|
|
LOG_NEW_FAILURE("NS_NewContentIterator", res);
|
1999-02-12 08:28:12 +03:00
|
|
|
return res;
|
|
|
|
}
|
|
|
|
refCounted = PR_TRUE;
|
1999-10-05 18:50:30 +04:00
|
|
|
}
|
1999-05-06 23:26:13 +04:00
|
|
|
else if (mClassID.Equals(kSubtreeIteratorCID)) {
|
1999-02-14 12:15:13 +03:00
|
|
|
res = NS_NewContentSubtreeIterator((nsIContentIterator **)&inst);
|
1999-05-06 23:26:13 +04:00
|
|
|
if (NS_FAILED(res)) {
|
|
|
|
LOG_NEW_FAILURE("NS_NewContentSubtreeIterator", res);
|
1999-02-14 12:15:13 +03:00
|
|
|
return res;
|
|
|
|
}
|
|
|
|
refCounted = PR_TRUE;
|
1999-10-05 18:50:30 +04:00
|
|
|
}
|
1999-05-06 23:26:13 +04:00
|
|
|
else if (mClassID.Equals(kCSSParserCID)) {
|
|
|
|
res = NS_NewCSSParser((nsICSSParser**)&inst);
|
|
|
|
if (NS_FAILED(res)) {
|
|
|
|
LOG_NEW_FAILURE("NS_NewCSSParser", res);
|
1998-12-02 02:29:16 +03:00
|
|
|
return res;
|
1999-05-06 23:26:13 +04:00
|
|
|
}
|
1998-12-02 02:29:16 +03:00
|
|
|
refCounted = PR_TRUE;
|
|
|
|
}
|
1998-12-03 23:21:40 +03:00
|
|
|
else if (mClassID.Equals(kHTMLStyleSheetCID)) {
|
1999-05-06 23:26:13 +04:00
|
|
|
res = NS_NewHTMLStyleSheet((nsIHTMLStyleSheet**)&inst);
|
|
|
|
if (NS_FAILED(res)) {
|
|
|
|
LOG_NEW_FAILURE("NS_NewHTMLStyleSheet", res);
|
1998-12-03 23:21:40 +03:00
|
|
|
return res;
|
1999-05-06 23:26:13 +04:00
|
|
|
}
|
1998-12-03 23:21:40 +03:00
|
|
|
refCounted = PR_TRUE;
|
1999-03-05 03:06:31 +03:00
|
|
|
}
|
|
|
|
else if (mClassID.Equals(kHTMLCSSStyleSheetCID)) {
|
1999-05-06 23:26:13 +04:00
|
|
|
res = NS_NewHTMLCSSStyleSheet((nsIHTMLCSSStyleSheet**)&inst);
|
|
|
|
if (NS_FAILED(res)) {
|
|
|
|
LOG_NEW_FAILURE("NS_NewHTMLCSSStyleSheet", res);
|
1999-03-05 03:06:31 +03:00
|
|
|
return res;
|
1999-05-06 23:26:13 +04:00
|
|
|
}
|
1999-03-05 03:06:31 +03:00
|
|
|
refCounted = PR_TRUE;
|
1998-12-03 23:21:40 +03:00
|
|
|
}
|
1999-05-19 03:04:12 +04:00
|
|
|
else if (mClassID.Equals(kCSSLoaderCID)) {
|
|
|
|
res = NS_NewCSSLoader((nsICSSLoader**)&inst);
|
|
|
|
if (NS_FAILED(res)) {
|
|
|
|
LOG_NEW_FAILURE("NS_NewCSSLoader", res);
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
refCounted = PR_TRUE;
|
|
|
|
}
|
1998-12-03 23:21:40 +03:00
|
|
|
else if (mClassID.Equals(kTextNodeCID)) {
|
1999-05-06 23:26:13 +04:00
|
|
|
res = NS_NewTextNode((nsIContent**) &inst);
|
|
|
|
if (NS_FAILED(res)) {
|
|
|
|
LOG_NEW_FAILURE("NS_NewTextNode", res);
|
1998-12-03 23:21:40 +03:00
|
|
|
return res;
|
1999-05-06 23:26:13 +04:00
|
|
|
}
|
1998-12-03 23:21:40 +03:00
|
|
|
refCounted = PR_TRUE;
|
|
|
|
}
|
1998-12-11 05:35:54 +03:00
|
|
|
else if (mClassID.Equals(kNameSpaceManagerCID)) {
|
1999-05-06 23:26:13 +04:00
|
|
|
res = NS_NewNameSpaceManager((nsINameSpaceManager**)&inst);
|
|
|
|
if (NS_FAILED(res)) {
|
|
|
|
LOG_NEW_FAILURE("NS_NewNameSpaceManager", res);
|
1998-12-11 05:35:54 +03:00
|
|
|
return res;
|
1999-05-06 23:26:13 +04:00
|
|
|
}
|
1998-12-11 05:35:54 +03:00
|
|
|
refCounted = PR_TRUE;
|
|
|
|
}
|
1998-12-10 21:04:37 +03:00
|
|
|
else if (mClassID.Equals(kFrameUtilCID)) {
|
1999-05-06 23:26:13 +04:00
|
|
|
res = NS_NewFrameUtil((nsIFrameUtil**) &inst);
|
|
|
|
if (NS_FAILED(res)) {
|
|
|
|
LOG_NEW_FAILURE("NS_NewFrameUtil", res);
|
1998-12-10 21:04:37 +03:00
|
|
|
return res;
|
1999-05-06 23:26:13 +04:00
|
|
|
}
|
1998-12-10 21:04:37 +03:00
|
|
|
refCounted = PR_TRUE;
|
|
|
|
}
|
1999-01-27 03:58:49 +03:00
|
|
|
else if (mClassID.Equals(kEventListenerManagerCID)) {
|
1999-05-06 23:26:13 +04:00
|
|
|
res = NS_NewEventListenerManager((nsIEventListenerManager**) &inst);
|
|
|
|
if (NS_FAILED(res)) {
|
|
|
|
LOG_NEW_FAILURE("NS_NewEventListenerManager", res);
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
refCounted = PR_TRUE;
|
|
|
|
}
|
|
|
|
else if (mClassID.Equals(kPrintPreviewContextCID)) {
|
|
|
|
res = NS_NewPrintPreviewContext((nsIPresContext**) &inst);
|
|
|
|
if (NS_FAILED(res)) {
|
|
|
|
LOG_NEW_FAILURE("NS_NewPrintPreviewContext", res);
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
refCounted = PR_TRUE;
|
|
|
|
}
|
|
|
|
else if (mClassID.Equals(kLayoutDocumentLoaderFactoryCID)) {
|
|
|
|
res = NS_NewLayoutDocumentLoaderFactory((nsIDocumentLoaderFactory**)&inst);
|
|
|
|
if (NS_FAILED(res)) {
|
|
|
|
LOG_NEW_FAILURE("NS_NewLayoutDocumentLoaderFactory", res);
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
refCounted = PR_TRUE;
|
|
|
|
}
|
|
|
|
else if (mClassID.Equals(kLayoutDebuggerCID)) {
|
|
|
|
res = NS_NewLayoutDebugger((nsILayoutDebugger**) &inst);
|
|
|
|
if (NS_FAILED(res)) {
|
|
|
|
LOG_NEW_FAILURE("NS_NewLayoutDebugger", res);
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
refCounted = PR_TRUE;
|
|
|
|
}
|
|
|
|
else if (mClassID.Equals(kHTMLElementFactoryCID)) {
|
|
|
|
res = NS_NewHTMLElementFactory((nsIHTMLElementFactory**) &inst);
|
|
|
|
if (NS_FAILED(res)) {
|
|
|
|
LOG_NEW_FAILURE("NS_NewHTMLElementFactory", res);
|
1999-01-27 03:58:49 +03:00
|
|
|
return res;
|
1999-05-06 23:26:13 +04:00
|
|
|
}
|
1999-01-27 03:58:49 +03:00
|
|
|
refCounted = PR_TRUE;
|
|
|
|
}
|
1999-10-05 04:12:21 +04:00
|
|
|
else if (mClassID.Equals(kXMLElementFactoryCID)) {
|
|
|
|
res = NS_NewXMLElementFactory((nsIXMLElementFactory**) &inst);
|
|
|
|
if (NS_FAILED(res)) {
|
|
|
|
LOG_NEW_FAILURE("NS_NewXMLElementFactory", res);
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
refCounted = PR_TRUE;
|
|
|
|
}
|
1999-06-10 04:35:02 +04:00
|
|
|
else if (mClassID.Equals(kTextEncoderCID)) {
|
|
|
|
res = NS_NewTextEncoder((nsIDocumentEncoder**) &inst);
|
|
|
|
if (NS_FAILED(res)) {
|
|
|
|
LOG_NEW_FAILURE("NS_NewTextEncoder", res);
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
refCounted = PR_TRUE;
|
|
|
|
}
|
1999-05-06 23:26:13 +04:00
|
|
|
else {
|
1998-11-30 01:11:06 +03:00
|
|
|
return NS_NOINTERFACE;
|
|
|
|
}
|
1999-05-06 23:26:13 +04:00
|
|
|
|
1999-10-05 18:50:30 +04:00
|
|
|
if (inst == NULL) {
|
|
|
|
return NS_ERROR_OUT_OF_MEMORY;
|
|
|
|
}
|
1998-09-17 05:53:52 +04:00
|
|
|
|
1999-10-24 20:19:42 +04:00
|
|
|
if (!refCounted) {
|
|
|
|
NS_ADDREF(inst);
|
|
|
|
}
|
|
|
|
|
1998-09-17 05:53:52 +04:00
|
|
|
res = inst->QueryInterface(aIID, aResult);
|
|
|
|
|
1999-10-24 20:19:42 +04:00
|
|
|
NS_RELEASE(inst);
|
|
|
|
if (res != NS_OK) {
|
1999-10-05 18:50:30 +04:00
|
|
|
// We didn't get the right interface, so clean up
|
1999-05-06 23:26:13 +04:00
|
|
|
LOG_NEW_FAILURE("final QueryInterface", res);
|
1999-10-05 18:50:30 +04:00
|
|
|
}
|
1998-09-17 05:53:52 +04:00
|
|
|
|
1999-10-05 18:50:30 +04:00
|
|
|
return res;
|
|
|
|
}
|
1998-09-17 05:53:52 +04:00
|
|
|
|
1999-10-05 18:50:30 +04:00
|
|
|
nsresult nsLayoutFactory::LockFactory(PRBool aLock)
|
|
|
|
{
|
|
|
|
// Not implemented in simplest case.
|
1998-09-17 05:53:52 +04:00
|
|
|
return NS_OK;
|
1999-10-05 18:50:30 +04:00
|
|
|
}
|