1998-09-17 05:53:52 +04:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
|
|
|
*
|
1999-11-06 06:40:37 +03:00
|
|
|
* 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/
|
1998-09-17 05:53:52 +04:00
|
|
|
*
|
1999-11-06 06:40:37 +03:00
|
|
|
* 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.
|
1998-09-17 05:53:52 +04:00
|
|
|
*
|
1999-11-06 06:40:37 +03:00
|
|
|
* The Original Code is mozilla.org code.
|
|
|
|
*
|
|
|
|
* The Initial Developer of the Original Code is Netscape
|
1998-09-17 05:53:52 +04:00
|
|
|
* Communications Corporation. Portions created by Netscape are
|
1999-11-06 06:40:37 +03:00
|
|
|
* Copyright (C) 1998 Netscape Communications Corporation. All
|
|
|
|
* Rights Reserved.
|
|
|
|
*
|
|
|
|
* Contributor(s):
|
1998-09-17 05:53:52 +04:00
|
|
|
*/
|
|
|
|
#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"
|
2000-09-14 15:45:01 +04:00
|
|
|
#include "nsISelection.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"
|
2000-01-19 07:11:23 +03:00
|
|
|
#include "nsIElementFactory.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"
|
2000-05-11 03:02:32 +04:00
|
|
|
#include "nsIDOMDOMImplementation.h"
|
|
|
|
#include "nsIPrivateDOMImplementation.h"
|
1998-09-17 05:53:52 +04:00
|
|
|
|
2000-01-12 12:25:48 +03:00
|
|
|
#include "nsIXBLService.h"
|
2000-05-10 01:42:40 +04:00
|
|
|
#include "nsIBindingManager.h"
|
2000-01-12 12:25:48 +03:00
|
|
|
|
2000-05-30 12:00:40 +04:00
|
|
|
#include "nsIBoxObject.h"
|
|
|
|
|
2000-04-14 15:21:19 +04:00
|
|
|
#include "nsIAutoCopy.h"
|
2000-05-15 07:40:40 +04:00
|
|
|
#include "nsContentPolicyUtils.h"
|
Checking in for bug 50742, this change removes the use of XIF in mozilla and replaces the XIF converter with a HTML (and XML) serializer.
Contextual information added to HTML copy and intelligence added to HTML paste in the editor (fixes bugs 47014, 50568 and 46554, and partly (at least) fixes bug 53188).
Code written by vidur, jfrancis, jst, akkana. Tested by jfrancis, akkana, vidur, jst, kin. Reviwed (and super reviewed) by waterson, vidur, kin, jfrancis, jst
2000-10-07 14:57:30 +04:00
|
|
|
|
|
|
|
#include "nsXMLContentSerializer.h"
|
|
|
|
#include "nsHTMLContentSerializer.h"
|
|
|
|
#include "nsPlainTextSerializer.h"
|
2000-04-14 15:21:19 +04:00
|
|
|
|
2000-05-10 17:13:39 +04:00
|
|
|
#include "nsINodeInfo.h"
|
2000-05-17 10:14:19 +04:00
|
|
|
#include "nsIComputedDOMStyle.h"
|
2000-04-14 15:21:19 +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);
|
2000-05-11 08:25:43 +04:00
|
|
|
static NS_DEFINE_IID(kDOMSelectionCID, NS_DOMSELECTION_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);
|
2000-03-31 11:18:45 +04:00
|
|
|
static NS_DEFINE_IID(kGeneratedContentIteratorCID, NS_GENERATEDCONTENTITERATOR_CID);
|
|
|
|
static NS_DEFINE_IID(kGeneratedSubtreeIteratorCID, NS_GENERATEDSUBTREEITERATOR_CID);
|
1999-05-06 23:26:13 +04:00
|
|
|
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);
|
Checking in for bug 50742, this change removes the use of XIF in mozilla and replaces the XIF converter with a HTML (and XML) serializer.
Contextual information added to HTML copy and intelligence added to HTML paste in the editor (fixes bugs 47014, 50568 and 46554, and partly (at least) fixes bug 53188).
Code written by vidur, jfrancis, jst, akkana. Tested by jfrancis, akkana, vidur, jst, kin. Reviwed (and super reviewed) by waterson, vidur, kin, jfrancis, jst
2000-10-07 14:57:30 +04:00
|
|
|
static NS_DEFINE_CID(kHTMLCopyTextEncoderCID, NS_HTMLCOPY_TEXT_ENCODER_CID);
|
|
|
|
|
|
|
|
static NS_DEFINE_CID(kXMLContentSerializerCID, NS_XMLCONTENTSERIALIZER_CID);
|
|
|
|
static NS_DEFINE_CID(kHTMLContentSerializerCID, NS_HTMLCONTENTSERIALIZER_CID);
|
|
|
|
static NS_DEFINE_CID(kPlainTextSerializerCID, NS_PLAINTEXTSERIALIZER_CID);
|
1998-11-30 01:11:06 +03:00
|
|
|
|
2000-01-12 12:25:48 +03:00
|
|
|
static NS_DEFINE_CID(kXBLServiceCID, NS_XBLSERVICE_CID);
|
2000-05-10 01:42:40 +04:00
|
|
|
static NS_DEFINE_CID(kBindingManagerCID, NS_BINDINGMANAGER_CID);
|
2000-01-12 12:25:48 +03:00
|
|
|
|
2000-05-30 12:00:40 +04:00
|
|
|
static NS_DEFINE_CID(kBoxObjectCID, NS_BOXOBJECT_CID);
|
|
|
|
static NS_DEFINE_CID(kTreeBoxObjectCID, NS_TREEBOXOBJECT_CID);
|
2000-06-23 09:15:04 +04:00
|
|
|
static NS_DEFINE_CID(kScrollBoxObjectCID, NS_SCROLLBOXOBJECT_CID);
|
2000-05-30 12:00:40 +04:00
|
|
|
static NS_DEFINE_CID(kMenuBoxObjectCID, NS_MENUBOXOBJECT_CID);
|
|
|
|
static NS_DEFINE_CID(kPopupSetBoxObjectCID, NS_POPUPSETBOXOBJECT_CID);
|
|
|
|
static NS_DEFINE_CID(kBrowserBoxObjectCID, NS_BROWSERBOXOBJECT_CID);
|
|
|
|
static NS_DEFINE_CID(kEditorBoxObjectCID, NS_EDITORBOXOBJECT_CID);
|
|
|
|
static NS_DEFINE_CID(kIFrameBoxObjectCID, NS_IFRAMEBOXOBJECT_CID);
|
|
|
|
|
2000-05-11 03:02:32 +04:00
|
|
|
static NS_DEFINE_CID(kDOMImplementationCID, NS_DOM_IMPLEMENTATION_CID);
|
2000-05-10 17:13:39 +04:00
|
|
|
static NS_DEFINE_CID(kNodeInfoManagerCID, NS_NODEINFOMANAGER_CID);
|
2000-04-14 15:21:19 +04:00
|
|
|
static NS_DEFINE_CID(kAutoCopyServiceCID, NS_AUTOCOPYSERVICE_CID);
|
2000-05-15 07:40:40 +04:00
|
|
|
static NS_DEFINE_CID(kContentPolicyCID, NS_CONTENTPOLICY_CID);
|
2000-05-17 10:14:19 +04:00
|
|
|
static NS_DEFINE_CID(kComputedDOMStyleCID, NS_COMPUTEDDOMSTYLE_CID);
|
2000-04-14 15:21:19 +04:00
|
|
|
|
2000-05-11 03:02:32 +04:00
|
|
|
|
2000-03-22 02:58:02 +03:00
|
|
|
extern nsresult NS_NewSelection(nsIFrameSelection** aResult);
|
2000-09-14 15:45:01 +04:00
|
|
|
extern nsresult NS_NewDomSelection(nsISelection** aResult);
|
1999-05-06 23:26:13 +04:00
|
|
|
extern nsresult NS_NewRange(nsIDOMRange** aResult);
|
|
|
|
extern nsresult NS_NewContentIterator(nsIContentIterator** aResult);
|
2000-03-31 11:18:45 +04:00
|
|
|
extern nsresult NS_NewGenRegularIterator(nsIContentIterator** aResult);
|
1999-05-06 23:26:13 +04:00
|
|
|
extern nsresult NS_NewContentSubtreeIterator(nsIContentIterator** aResult);
|
2000-03-31 11:18:45 +04:00
|
|
|
extern nsresult NS_NewGenSubtreeIterator(nsIContentIterator** aInstancePtrResult);
|
1998-09-17 05:53:52 +04:00
|
|
|
|
1999-05-06 23:26:13 +04:00
|
|
|
extern nsresult NS_NewLayoutDocumentLoaderFactory(nsIDocumentLoaderFactory** aResult);
|
1999-11-02 01:12:45 +03:00
|
|
|
#ifdef NS_DEBUG
|
|
|
|
extern nsresult NS_NewFrameUtil(nsIFrameUtil** aResult);
|
1999-05-06 23:26:13 +04:00
|
|
|
extern nsresult NS_NewLayoutDebugger(nsILayoutDebugger** aResult);
|
1999-11-02 01:12:45 +03:00
|
|
|
#endif
|
2000-01-19 07:11:23 +03:00
|
|
|
extern nsresult NS_NewHTMLElementFactory(nsIElementFactory** aResult);
|
|
|
|
extern nsresult NS_NewXMLElementFactory(nsIElementFactory** aResult);
|
|
|
|
|
Checking in for bug 50742, this change removes the use of XIF in mozilla and replaces the XIF converter with a HTML (and XML) serializer.
Contextual information added to HTML copy and intelligence added to HTML paste in the editor (fixes bugs 47014, 50568 and 46554, and partly (at least) fixes bug 53188).
Code written by vidur, jfrancis, jst, akkana. Tested by jfrancis, akkana, vidur, jst, kin. Reviwed (and super reviewed) by waterson, vidur, kin, jfrancis, jst
2000-10-07 14:57:30 +04:00
|
|
|
extern nsresult NS_NewHTMLCopyTextEncoder(nsIDocumentEncoder** aResult);
|
1999-06-10 04:35:02 +04:00
|
|
|
extern nsresult NS_NewTextEncoder(nsIDocumentEncoder** aResult);
|
1998-09-17 05:53:52 +04:00
|
|
|
|
2000-01-12 12:25:48 +03:00
|
|
|
extern nsresult NS_NewXBLService(nsIXBLService** aResult);
|
2000-05-10 17:13:39 +04:00
|
|
|
|
2000-05-10 01:42:40 +04:00
|
|
|
extern nsresult NS_NewBindingManager(nsIBindingManager** aResult);
|
2000-01-12 12:25:48 +03:00
|
|
|
|
2000-05-30 12:00:40 +04:00
|
|
|
extern nsresult NS_NewBoxObject(nsIBoxObject** aResult);
|
|
|
|
extern nsresult NS_NewTreeBoxObject(nsIBoxObject** aResult);
|
2000-06-23 09:15:04 +04:00
|
|
|
extern nsresult NS_NewScrollBoxObject(nsIBoxObject** aResult);
|
2000-05-30 12:00:40 +04:00
|
|
|
extern nsresult NS_NewMenuBoxObject(nsIBoxObject** aResult);
|
|
|
|
extern nsresult NS_NewEditorBoxObject(nsIBoxObject** aResult);
|
|
|
|
extern nsresult NS_NewPopupSetBoxObject(nsIBoxObject** aResult);
|
|
|
|
extern nsresult NS_NewBrowserBoxObject(nsIBoxObject** aResult);
|
|
|
|
extern nsresult NS_NewIFrameBoxObject(nsIBoxObject** aResult);
|
|
|
|
|
2000-05-10 17:13:39 +04:00
|
|
|
extern nsresult NS_NewNodeInfoManager(nsINodeInfoManager** aResult);
|
|
|
|
|
2000-04-14 15:21:19 +04:00
|
|
|
extern nsresult NS_NewAutoCopyService(nsIAutoCopyService** aResult);
|
2000-05-15 07:40:40 +04:00
|
|
|
extern nsresult NS_NewContentPolicy(nsIContentPolicy** aResult);
|
2000-04-14 15:21:19 +04:00
|
|
|
|
2000-05-13 12:08:04 +04:00
|
|
|
|
1999-10-01 01:14:14 +04:00
|
|
|
//----------------------------------------------------------------------
|
1998-09-17 05:53:52 +04:00
|
|
|
|
1999-10-05 18:50:30 +04:00
|
|
|
nsLayoutFactory::nsLayoutFactory(const nsCID &aClass)
|
|
|
|
{
|
1999-10-28 15:42:15 +04:00
|
|
|
NS_INIT_ISUPPORTS();
|
1998-09-17 05:53:52 +04:00
|
|
|
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-10-28 15:42:15 +04:00
|
|
|
NS_IMPL_ISUPPORTS(nsLayoutFactory, NS_GET_IID(nsIFactory))
|
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-05 18:50:30 +04:00
|
|
|
if (aResult == NULL) {
|
|
|
|
return NS_ERROR_NULL_POINTER;
|
|
|
|
}
|
|
|
|
|
|
|
|
*aResult = NULL;
|
1998-09-17 05:53:52 +04:00
|
|
|
|
1999-10-28 15:42:15 +04:00
|
|
|
if (aOuter) {
|
|
|
|
return NS_ERROR_NO_AGGREGATION;
|
|
|
|
}
|
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
}
|
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;
|
|
|
|
}
|
|
|
|
}
|
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;
|
|
|
|
}
|
|
|
|
}
|
1999-05-06 23:26:13 +04:00
|
|
|
#if 1
|
2000-01-19 07:11:23 +03:00
|
|
|
// XXX replace these with nsIElementFactory calls
|
1999-05-06 23:26:13 +04:00
|
|
|
else if (mClassID.Equals(kHTMLImageElementCID)) {
|
2000-05-10 17:13:39 +04:00
|
|
|
// Note! NS_NewHTMLImageElement is special cased to handle a null nodeinfo
|
|
|
|
res = NS_NewHTMLImageElement((nsIHTMLContent**)&inst, nsnull);
|
1998-12-23 01:03:20 +03:00
|
|
|
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;
|
|
|
|
}
|
1998-09-17 05:53:52 +04:00
|
|
|
}
|
1999-05-06 23:26:13 +04:00
|
|
|
else if (mClassID.Equals(kHTMLOptionElementCID)) {
|
2000-05-10 17:13:39 +04:00
|
|
|
// Note! NS_NewHTMLOptionElement is special cased to handle a null nodeinfo
|
|
|
|
res = NS_NewHTMLOptionElement((nsIHTMLContent**)&inst, nsnull);
|
1999-05-05 00:52:03 +04:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
}
|
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;
|
|
|
|
}
|
|
|
|
}
|
1999-05-06 23:26:13 +04:00
|
|
|
#endif
|
1999-07-18 06:27:19 +04:00
|
|
|
else if (mClassID.Equals(kFrameSelectionCID)) {
|
2000-03-22 02:58:02 +03:00
|
|
|
res = NS_NewSelection((nsIFrameSelection**)&inst);
|
1999-05-06 23:26:13 +04:00
|
|
|
if (NS_FAILED(res)) {
|
2000-03-22 02:58:02 +03:00
|
|
|
LOG_NEW_FAILURE("NS_NewSelection", res);
|
1998-11-30 01:11:06 +03:00
|
|
|
return res;
|
|
|
|
}
|
|
|
|
}
|
2000-05-11 08:25:43 +04:00
|
|
|
else if (mClassID.Equals(kDOMSelectionCID)) {
|
2000-09-14 15:45:01 +04:00
|
|
|
res = NS_NewDomSelection((nsISelection**)&inst);
|
2000-05-11 08:25:43 +04:00
|
|
|
if (NS_FAILED(res)) {
|
|
|
|
LOG_NEW_FAILURE("NS_NewDomSelection", res);
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
}
|
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;
|
|
|
|
}
|
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;
|
|
|
|
}
|
1999-10-05 18:50:30 +04:00
|
|
|
}
|
2000-03-31 11:18:45 +04:00
|
|
|
else if (mClassID.Equals(kGeneratedContentIteratorCID)) {
|
|
|
|
res = NS_NewGenRegularIterator((nsIContentIterator **)&inst);
|
|
|
|
if (NS_FAILED(res)) {
|
|
|
|
LOG_NEW_FAILURE("NS_NewGenRegularIterator", res);
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
}
|
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;
|
|
|
|
}
|
1999-10-05 18:50:30 +04:00
|
|
|
}
|
2000-03-31 11:18:45 +04:00
|
|
|
else if (mClassID.Equals(kGeneratedSubtreeIteratorCID)) {
|
|
|
|
res = NS_NewGenSubtreeIterator((nsIContentIterator **)&inst);
|
|
|
|
if (NS_FAILED(res)) {
|
|
|
|
LOG_NEW_FAILURE("NS_NewGenSubtreeIterator", res);
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
}
|
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
|
|
|
}
|
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
|
|
|
}
|
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
|
|
|
}
|
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;
|
|
|
|
}
|
|
|
|
}
|
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
|
|
|
}
|
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
|
|
|
}
|
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;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (mClassID.Equals(kPrintPreviewContextCID)) {
|
|
|
|
res = NS_NewPrintPreviewContext((nsIPresContext**) &inst);
|
|
|
|
if (NS_FAILED(res)) {
|
|
|
|
LOG_NEW_FAILURE("NS_NewPrintPreviewContext", res);
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (mClassID.Equals(kLayoutDocumentLoaderFactoryCID)) {
|
|
|
|
res = NS_NewLayoutDocumentLoaderFactory((nsIDocumentLoaderFactory**)&inst);
|
|
|
|
if (NS_FAILED(res)) {
|
|
|
|
LOG_NEW_FAILURE("NS_NewLayoutDocumentLoaderFactory", res);
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
}
|
1999-11-02 01:12:45 +03:00
|
|
|
#ifdef DEBUG
|
|
|
|
else if (mClassID.Equals(kFrameUtilCID)) {
|
|
|
|
res = NS_NewFrameUtil((nsIFrameUtil**) &inst);
|
|
|
|
if (NS_FAILED(res)) {
|
|
|
|
LOG_NEW_FAILURE("NS_NewFrameUtil", res);
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
}
|
1999-05-06 23:26:13 +04:00
|
|
|
else if (mClassID.Equals(kLayoutDebuggerCID)) {
|
|
|
|
res = NS_NewLayoutDebugger((nsILayoutDebugger**) &inst);
|
|
|
|
if (NS_FAILED(res)) {
|
|
|
|
LOG_NEW_FAILURE("NS_NewLayoutDebugger", res);
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
}
|
1999-11-02 01:12:45 +03:00
|
|
|
#endif
|
1999-05-06 23:26:13 +04:00
|
|
|
else if (mClassID.Equals(kHTMLElementFactoryCID)) {
|
2000-01-19 07:11:23 +03:00
|
|
|
res = NS_NewHTMLElementFactory((nsIElementFactory**) &inst);
|
1999-05-06 23:26:13 +04:00
|
|
|
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
|
|
|
}
|
1999-10-05 04:12:21 +04:00
|
|
|
else if (mClassID.Equals(kXMLElementFactoryCID)) {
|
2000-01-19 07:11:23 +03:00
|
|
|
res = NS_NewXMLElementFactory((nsIElementFactory**) &inst);
|
1999-10-05 04:12:21 +04:00
|
|
|
if (NS_FAILED(res)) {
|
|
|
|
LOG_NEW_FAILURE("NS_NewXMLElementFactory", res);
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
}
|
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;
|
|
|
|
}
|
|
|
|
}
|
Checking in for bug 50742, this change removes the use of XIF in mozilla and replaces the XIF converter with a HTML (and XML) serializer.
Contextual information added to HTML copy and intelligence added to HTML paste in the editor (fixes bugs 47014, 50568 and 46554, and partly (at least) fixes bug 53188).
Code written by vidur, jfrancis, jst, akkana. Tested by jfrancis, akkana, vidur, jst, kin. Reviwed (and super reviewed) by waterson, vidur, kin, jfrancis, jst
2000-10-07 14:57:30 +04:00
|
|
|
else if (mClassID.Equals(kHTMLCopyTextEncoderCID)) {
|
|
|
|
res = NS_NewHTMLCopyTextEncoder((nsIDocumentEncoder**) &inst);
|
|
|
|
if (NS_FAILED(res)) {
|
|
|
|
LOG_NEW_FAILURE("NS_NewHTMLCopyTextEncoder", res);
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (mClassID.Equals(kXMLContentSerializerCID)) {
|
|
|
|
res = NS_NewXMLContentSerializer((nsIContentSerializer**) &inst);
|
|
|
|
if (NS_FAILED(res)) {
|
|
|
|
LOG_NEW_FAILURE("NS_NewXMLContentSerializer", res);
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (mClassID.Equals(kHTMLContentSerializerCID)) {
|
|
|
|
res = NS_NewHTMLContentSerializer((nsIContentSerializer**) &inst);
|
|
|
|
if (NS_FAILED(res)) {
|
|
|
|
LOG_NEW_FAILURE("NS_NewHTMLContentSerializer", res);
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (mClassID.Equals(kPlainTextSerializerCID)) {
|
|
|
|
res = NS_NewPlainTextSerializer((nsIContentSerializer**) &inst);
|
|
|
|
if (NS_FAILED(res)) {
|
|
|
|
LOG_NEW_FAILURE("NS_NewPlainTextSerializer", res);
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
}
|
2000-01-12 12:25:48 +03:00
|
|
|
else if (mClassID.Equals(kXBLServiceCID)) {
|
|
|
|
res = NS_NewXBLService((nsIXBLService**) &inst);
|
|
|
|
if (NS_FAILED(res)) {
|
|
|
|
LOG_NEW_FAILURE("NS_NewXBLService", res);
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
}
|
2000-05-10 01:42:40 +04:00
|
|
|
else if (mClassID.Equals(kBindingManagerCID)) {
|
|
|
|
res = NS_NewBindingManager((nsIBindingManager**) &inst);
|
|
|
|
if (NS_FAILED(res)) {
|
|
|
|
LOG_NEW_FAILURE("NS_NewBindingManager", res);
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
}
|
2000-05-30 12:00:40 +04:00
|
|
|
else if (mClassID.Equals(kBoxObjectCID)) {
|
|
|
|
res = NS_NewBoxObject((nsIBoxObject**) &inst);
|
|
|
|
if (NS_FAILED(res)) {
|
|
|
|
LOG_NEW_FAILURE("NS_NewBoxObject", res);
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (mClassID.Equals(kMenuBoxObjectCID)) {
|
|
|
|
res = NS_NewMenuBoxObject((nsIBoxObject**) &inst);
|
|
|
|
if (NS_FAILED(res)) {
|
|
|
|
LOG_NEW_FAILURE("NS_NewMenuBoxObject", res);
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (mClassID.Equals(kTreeBoxObjectCID)) {
|
|
|
|
res = NS_NewTreeBoxObject((nsIBoxObject**) &inst);
|
|
|
|
if (NS_FAILED(res)) {
|
|
|
|
LOG_NEW_FAILURE("NS_NewTreeBoxObject", res);
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (mClassID.Equals(kPopupSetBoxObjectCID)) {
|
|
|
|
res = NS_NewPopupSetBoxObject((nsIBoxObject**) &inst);
|
|
|
|
if (NS_FAILED(res)) {
|
|
|
|
LOG_NEW_FAILURE("NS_NewPopupSetBoxObject", res);
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (mClassID.Equals(kBrowserBoxObjectCID)) {
|
|
|
|
res = NS_NewBrowserBoxObject((nsIBoxObject**) &inst);
|
|
|
|
if (NS_FAILED(res)) {
|
|
|
|
LOG_NEW_FAILURE("NS_NewBrowserBoxObject", res);
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (mClassID.Equals(kEditorBoxObjectCID)) {
|
|
|
|
res = NS_NewEditorBoxObject((nsIBoxObject**) &inst);
|
|
|
|
if (NS_FAILED(res)) {
|
|
|
|
LOG_NEW_FAILURE("NS_NewEditorBoxObject", res);
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (mClassID.Equals(kIFrameBoxObjectCID)) {
|
|
|
|
res = NS_NewIFrameBoxObject((nsIBoxObject**) &inst);
|
|
|
|
if (NS_FAILED(res)) {
|
|
|
|
LOG_NEW_FAILURE("NS_NewIFrameBoxObject", res);
|
|
|
|
return res;
|
|
|
|
}
|
2000-05-31 11:22:20 +04:00
|
|
|
}
|
2000-05-10 17:13:39 +04:00
|
|
|
else if (mClassID.Equals(kNodeInfoManagerCID)) {
|
|
|
|
res = NS_NewNodeInfoManager((nsINodeInfoManager**) &inst);
|
|
|
|
if (NS_FAILED(res)) {
|
|
|
|
LOG_NEW_FAILURE("NS_NewNodeInfoManager", res);
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
}
|
2000-04-14 15:21:19 +04:00
|
|
|
else if (mClassID.Equals(kAutoCopyServiceCID)) {
|
|
|
|
res = NS_NewAutoCopyService((nsIAutoCopyService**) &inst);
|
|
|
|
if (NS_FAILED(res)) {
|
|
|
|
LOG_NEW_FAILURE("NS_NewAutoCopyService", res);
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
}
|
2000-05-11 03:02:32 +04:00
|
|
|
else if (mClassID.Equals(kDOMImplementationCID)) {
|
|
|
|
res = NS_NewDOMImplementation((nsIDOMDOMImplementation**) &inst);
|
2000-05-15 07:40:40 +04:00
|
|
|
if (NS_FAILED(res)) {
|
2000-05-11 03:02:32 +04:00
|
|
|
LOG_NEW_FAILURE("NS_NewDOMImplementation", res);
|
|
|
|
return res;
|
2000-05-15 07:40:40 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (mClassID.Equals(kContentPolicyCID)) {
|
|
|
|
res = NS_NewContentPolicy((nsIContentPolicy**) &inst);
|
|
|
|
if (NS_FAILED(res)) {
|
|
|
|
LOG_NEW_FAILURE("NS_NewContentPolicy", res);
|
|
|
|
return res;
|
|
|
|
}
|
2000-05-11 03:02:32 +04:00
|
|
|
}
|
2000-05-17 10:14:19 +04:00
|
|
|
else if (mClassID.Equals(kComputedDOMStyleCID)) {
|
|
|
|
res = NS_NewComputedDOMStyle((nsIComputedDOMStyle**) &inst);
|
|
|
|
if (NS_FAILED(res)) {
|
|
|
|
LOG_NEW_FAILURE("NS_NewComputedDOMStyle", res);
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
}
|
2000-06-23 09:15:04 +04:00
|
|
|
else if (mClassID.Equals(kScrollBoxObjectCID)) {
|
|
|
|
res = NS_NewScrollBoxObject((nsIBoxObject**) &inst);
|
|
|
|
if (NS_FAILED(res)) {
|
|
|
|
LOG_NEW_FAILURE("NS_NewScrollBoxObject", res);
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
}
|
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-28 15:42:15 +04:00
|
|
|
if (NS_FAILED(res)) return res;
|
1999-10-24 20:19:42 +04:00
|
|
|
|
1998-09-17 05:53:52 +04:00
|
|
|
res = inst->QueryInterface(aIID, aResult);
|
|
|
|
|
1999-10-24 20:19:42 +04:00
|
|
|
NS_RELEASE(inst);
|
1999-10-28 15:42:15 +04:00
|
|
|
|
|
|
|
if (NS_FAILED(res)) {
|
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
|
|
|
}
|