2001-09-29 00:14:13 +04:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* ***** BEGIN LICENSE BLOCK *****
|
|
|
|
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
|
1999-09-28 04:44:47 +04:00
|
|
|
*
|
2001-09-29 00:14:13 +04: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/
|
1999-09-28 04:44:47 +04:00
|
|
|
*
|
2001-09-29 00:14:13 +04: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.
|
1999-09-28 04:44:47 +04:00
|
|
|
*
|
|
|
|
* The Original Code is Mozilla Communicator client code.
|
|
|
|
*
|
2001-09-29 00:14:13 +04:00
|
|
|
* The Initial Developer of the Original Code is
|
|
|
|
* Netscape Communications Corporation.
|
|
|
|
* Portions created by the Initial Developer are Copyright (C) 1998
|
|
|
|
* the Initial Developer. All Rights Reserved.
|
1999-11-06 06:40:37 +03:00
|
|
|
*
|
2001-09-29 00:14:13 +04:00
|
|
|
* Contributor(s):
|
2000-02-03 01:24:56 +03:00
|
|
|
* Pierre Phaneuf <pp@ludusdesign.com>
|
2001-09-29 00:14:13 +04:00
|
|
|
*
|
|
|
|
* Alternatively, the contents of this file may be used under the terms of
|
|
|
|
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
|
|
|
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
|
|
|
* in which case the provisions of the GPL or the LGPL are applicable instead
|
|
|
|
* of those above. If you wish to allow use of your version of this file only
|
|
|
|
* under the terms of either the GPL or the LGPL, and not to allow others to
|
|
|
|
* use your version of this file under the terms of the NPL, indicate your
|
|
|
|
* decision by deleting the provisions above and replace them with the notice
|
|
|
|
* and other provisions required by the GPL or the LGPL. If you do not delete
|
|
|
|
* the provisions above, a recipient may use your version of this file under
|
|
|
|
* the terms of any one of the NPL, the GPL or the LGPL.
|
|
|
|
*
|
|
|
|
* ***** END LICENSE BLOCK ***** */
|
2001-08-07 06:55:54 +04:00
|
|
|
|
|
|
|
#include "nsIGenericFactory.h"
|
|
|
|
|
1999-09-28 04:44:47 +04:00
|
|
|
#include "nsLayoutCID.h"
|
2001-08-07 06:55:54 +04:00
|
|
|
#include "nsIAutoCopy.h"
|
|
|
|
#include "nsIBoxObject.h"
|
|
|
|
#include "nsICSSFrameConstructor.h"
|
|
|
|
#include "nsIFrameTraversal.h"
|
|
|
|
#include "nsIFrameUtil.h"
|
|
|
|
#include "nsILayoutDebugger.h"
|
|
|
|
#include "nsILayoutHistoryState.h"
|
|
|
|
#include "nsIPresContext.h"
|
|
|
|
#include "nsIPresShell.h"
|
|
|
|
#include "nsIPresState.h"
|
|
|
|
#include "nsIPrintContext.h"
|
|
|
|
#include "nsTextTransformer.h"
|
|
|
|
|
|
|
|
#include "nsHTMLAtoms.h" // to addref/release table
|
|
|
|
#include "nsLayoutAtoms.h" // to addref/release table
|
1999-09-28 04:44:47 +04:00
|
|
|
#include "nsCSSKeywords.h" // to addref/release table
|
|
|
|
#include "nsCSSProps.h" // to addref/release table
|
|
|
|
#include "nsCSSAtoms.h" // to addref/release table
|
|
|
|
#include "nsColorNames.h" // to addref/release table
|
2001-08-24 00:07:10 +04:00
|
|
|
#include "nsCSSFrameConstructor.h"
|
2001-09-11 04:55:05 +04:00
|
|
|
#include "nsSpaceManager.h"
|
2001-08-07 06:55:54 +04:00
|
|
|
|
1999-09-28 04:44:47 +04:00
|
|
|
#ifdef INCLUDE_XUL
|
|
|
|
#include "nsXULAtoms.h"
|
2001-08-07 06:55:54 +04:00
|
|
|
#include "nsRepeatService.h"
|
|
|
|
#include "nsSprocketLayout.h"
|
|
|
|
#include "nsStackLayout.h"
|
1999-09-28 04:44:47 +04:00
|
|
|
#endif
|
2001-08-07 06:55:54 +04:00
|
|
|
|
1999-10-02 15:01:41 +04:00
|
|
|
//MathML Mod - RBS
|
|
|
|
#ifdef MOZ_MATHML
|
|
|
|
#include "nsMathMLAtoms.h"
|
|
|
|
#include "nsMathMLOperators.h"
|
|
|
|
#endif
|
2001-06-21 00:21:49 +04:00
|
|
|
|
2000-04-02 02:31:45 +04:00
|
|
|
// SVG
|
|
|
|
#ifdef MOZ_SVG
|
|
|
|
#include "nsSVGAtoms.h"
|
|
|
|
#endif
|
|
|
|
|
1999-09-28 04:44:47 +04:00
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
|
|
|
|
// Perform our one-time intialization for this module
|
2001-08-07 06:55:54 +04:00
|
|
|
static PRBool gInitialized = PR_FALSE;
|
2000-03-21 13:34:56 +03:00
|
|
|
|
2001-08-08 07:47:56 +04:00
|
|
|
PR_STATIC_CALLBACK(nsresult)
|
2001-08-07 06:55:54 +04:00
|
|
|
Initialize(nsIModule* self)
|
|
|
|
{
|
|
|
|
NS_PRECONDITION(!gInitialized, "module already initialized");
|
|
|
|
if (gInitialized)
|
1999-09-28 04:44:47 +04:00
|
|
|
return NS_OK;
|
|
|
|
|
2001-08-07 06:55:54 +04:00
|
|
|
gInitialized = PR_TRUE;
|
1999-10-02 04:55:57 +04:00
|
|
|
|
1999-09-28 04:44:47 +04:00
|
|
|
// Register all of our atoms once
|
|
|
|
nsCSSAtoms::AddRefAtoms();
|
|
|
|
nsCSSKeywords::AddRefTable();
|
|
|
|
nsCSSProps::AddRefTable();
|
|
|
|
nsColorNames::AddRefTable();
|
|
|
|
nsHTMLAtoms::AddRefAtoms();
|
1999-10-01 01:14:14 +04:00
|
|
|
nsLayoutAtoms::AddRefAtoms();
|
1999-09-28 04:44:47 +04:00
|
|
|
#ifdef INCLUDE_XUL
|
|
|
|
nsXULAtoms::AddRefAtoms();
|
|
|
|
#endif
|
1999-10-02 15:01:41 +04:00
|
|
|
//MathML Mod - RBS
|
|
|
|
#ifdef MOZ_MATHML
|
|
|
|
nsMathMLOperators::AddRefTable();
|
|
|
|
nsMathMLAtoms::AddRefAtoms();
|
|
|
|
#endif
|
1999-09-28 04:44:47 +04:00
|
|
|
|
2000-04-02 02:31:45 +04:00
|
|
|
// SVG
|
|
|
|
#ifdef MOZ_SVG
|
|
|
|
nsSVGAtoms::AddRefAtoms();
|
|
|
|
#endif
|
|
|
|
|
2001-08-24 00:07:10 +04:00
|
|
|
nsCSSFrameConstructor::InitGlobals();
|
|
|
|
|
2001-08-07 06:55:54 +04:00
|
|
|
return nsTextTransformer::Initialize();
|
1999-09-28 04:44:47 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
// Shutdown this module, releasing all of the module resources
|
2001-08-08 07:47:56 +04:00
|
|
|
PR_STATIC_CALLBACK(void)
|
2001-08-07 06:55:54 +04:00
|
|
|
Shutdown(nsIModule* self)
|
1999-09-28 04:44:47 +04:00
|
|
|
{
|
2001-08-07 06:55:54 +04:00
|
|
|
NS_PRECONDITION(gInitialized, "module not initialized");
|
|
|
|
if (! gInitialized)
|
2000-02-16 10:42:00 +03:00
|
|
|
return;
|
2001-08-07 06:55:54 +04:00
|
|
|
|
|
|
|
gInitialized = PR_FALSE;
|
2000-11-08 06:22:03 +03:00
|
|
|
|
|
|
|
#ifdef INCLUDE_XUL
|
|
|
|
nsRepeatService::Shutdown();
|
|
|
|
nsSprocketLayout::Shutdown();
|
|
|
|
nsStackLayout::Shutdown();
|
|
|
|
#endif
|
|
|
|
|
1999-09-28 04:44:47 +04:00
|
|
|
// Release all of our atoms
|
|
|
|
nsColorNames::ReleaseTable();
|
|
|
|
nsCSSProps::ReleaseTable();
|
|
|
|
nsCSSKeywords::ReleaseTable();
|
|
|
|
nsCSSAtoms::ReleaseAtoms();
|
|
|
|
nsHTMLAtoms::ReleaseAtoms();
|
1999-10-01 01:14:14 +04:00
|
|
|
nsLayoutAtoms::ReleaseAtoms();
|
2001-08-07 06:55:54 +04:00
|
|
|
|
1999-09-28 04:44:47 +04:00
|
|
|
#ifdef INCLUDE_XUL
|
|
|
|
nsXULAtoms::ReleaseAtoms();
|
2001-02-20 00:50:04 +03:00
|
|
|
#endif
|
2001-08-07 06:55:54 +04:00
|
|
|
|
1999-10-02 15:01:41 +04:00
|
|
|
//MathML Mod - RBS
|
|
|
|
#ifdef MOZ_MATHML
|
|
|
|
nsMathMLOperators::ReleaseTable();
|
|
|
|
nsMathMLAtoms::ReleaseAtoms();
|
|
|
|
#endif
|
2001-08-07 06:55:54 +04:00
|
|
|
|
2000-04-02 02:31:45 +04:00
|
|
|
// SVG
|
|
|
|
#ifdef MOZ_SVG
|
|
|
|
nsSVGAtoms::ReleaseAtoms();
|
|
|
|
#endif
|
1999-09-28 04:44:47 +04:00
|
|
|
|
2001-08-24 00:07:10 +04:00
|
|
|
nsCSSFrameConstructor::ReleaseGlobals();
|
|
|
|
|
1999-10-20 03:01:23 +04:00
|
|
|
nsTextTransformer::Shutdown();
|
2001-09-11 04:55:05 +04:00
|
|
|
|
|
|
|
nsSpaceManager::Shutdown();
|
1999-09-28 04:44:47 +04:00
|
|
|
}
|
|
|
|
|
2001-08-07 06:55:54 +04:00
|
|
|
#ifdef NS_DEBUG
|
|
|
|
extern nsresult NS_NewFrameUtil(nsIFrameUtil** aResult);
|
|
|
|
extern nsresult NS_NewLayoutDebugger(nsILayoutDebugger** aResult);
|
|
|
|
#endif
|
1999-09-28 04:44:47 +04:00
|
|
|
|
2001-08-07 06:55:54 +04:00
|
|
|
extern nsresult NS_NewBoxObject(nsIBoxObject** aResult);
|
|
|
|
extern nsresult NS_NewTreeBoxObject(nsIBoxObject** aResult);
|
|
|
|
extern nsresult NS_NewScrollBoxObject(nsIBoxObject** aResult);
|
|
|
|
extern nsresult NS_NewMenuBoxObject(nsIBoxObject** aResult);
|
|
|
|
extern nsresult NS_NewEditorBoxObject(nsIBoxObject** aResult);
|
2001-08-18 05:04:47 +04:00
|
|
|
extern nsresult NS_NewPopupBoxObject(nsIBoxObject** aResult);
|
2001-08-07 06:55:54 +04:00
|
|
|
extern nsresult NS_NewBrowserBoxObject(nsIBoxObject** aResult);
|
|
|
|
extern nsresult NS_NewIFrameBoxObject(nsIBoxObject** aResult);
|
|
|
|
extern nsresult NS_NewOutlinerBoxObject(nsIBoxObject** aResult);
|
|
|
|
extern nsresult NS_CreateFrameTraversal(nsIFrameTraversal** aResult);
|
|
|
|
extern nsresult NS_CreateCSSFrameConstructor(nsICSSFrameConstructor** aResult);
|
|
|
|
extern nsresult NS_NewLayoutHistoryState(nsILayoutHistoryState** aResult);
|
|
|
|
extern nsresult NS_NewAutoCopyService(nsIAutoCopyService** aResult);
|
|
|
|
|
|
|
|
#define MAKE_CTOR(ctor_, iface_, func_) \
|
|
|
|
static NS_IMETHODIMP \
|
|
|
|
ctor_(nsISupports* aOuter, REFNSIID aIID, void** aResult) \
|
|
|
|
{ \
|
|
|
|
*aResult = nsnull; \
|
|
|
|
if (aOuter) \
|
|
|
|
return NS_ERROR_NO_AGGREGATION; \
|
|
|
|
iface_* inst; \
|
|
|
|
nsresult rv = func_(&inst); \
|
|
|
|
if (NS_SUCCEEDED(rv)) { \
|
|
|
|
rv = inst->QueryInterface(aIID, aResult); \
|
|
|
|
NS_RELEASE(inst); \
|
|
|
|
} \
|
|
|
|
return rv; \
|
1999-09-28 04:44:47 +04:00
|
|
|
}
|
2001-08-07 06:55:54 +04:00
|
|
|
|
|
|
|
#ifdef DEBUG
|
|
|
|
MAKE_CTOR(CreateNewFrameUtil, nsIFrameUtil, NS_NewFrameUtil)
|
|
|
|
MAKE_CTOR(CreateNewLayoutDebugger, nsILayoutDebugger, NS_NewLayoutDebugger)
|
|
|
|
#endif
|
1999-09-28 04:44:47 +04:00
|
|
|
|
2001-08-07 06:55:54 +04:00
|
|
|
MAKE_CTOR(CreateNewPrintPreviewContext, nsIPresContext, NS_NewPrintPreviewContext)
|
|
|
|
MAKE_CTOR(CreateNewCSSFrameConstructor, nsICSSFrameConstructor, NS_CreateCSSFrameConstructor)
|
|
|
|
MAKE_CTOR(CreateNewFrameTraversal, nsIFrameTraversal, NS_CreateFrameTraversal)
|
|
|
|
MAKE_CTOR(CreateNewLayoutHistoryState, nsILayoutHistoryState, NS_NewLayoutHistoryState)
|
|
|
|
MAKE_CTOR(CreateNewPresShell, nsIPresShell, NS_NewPresShell)
|
|
|
|
MAKE_CTOR(CreateNewPresState, nsIPresState, NS_NewPresState)
|
|
|
|
MAKE_CTOR(CreateNewGalleyContext, nsIPresContext, NS_NewGalleyContext)
|
|
|
|
MAKE_CTOR(CreateNewPrintContext, nsIPrintContext, NS_NewPrintContext)
|
|
|
|
MAKE_CTOR(CreateNewBoxObject, nsIBoxObject, NS_NewBoxObject)
|
|
|
|
MAKE_CTOR(CreateNewTreeBoxObject, nsIBoxObject, NS_NewTreeBoxObject)
|
|
|
|
MAKE_CTOR(CreateNewMenuBoxObject, nsIBoxObject, NS_NewMenuBoxObject)
|
2001-08-18 05:04:47 +04:00
|
|
|
MAKE_CTOR(CreateNewPopupBoxObject, nsIBoxObject, NS_NewPopupBoxObject)
|
2001-08-07 06:55:54 +04:00
|
|
|
MAKE_CTOR(CreateNewBrowserBoxObject, nsIBoxObject, NS_NewBrowserBoxObject)
|
|
|
|
MAKE_CTOR(CreateNewEditorBoxObject, nsIBoxObject, NS_NewEditorBoxObject)
|
|
|
|
MAKE_CTOR(CreateNewIFrameBoxObject, nsIBoxObject, NS_NewIFrameBoxObject)
|
|
|
|
MAKE_CTOR(CreateNewScrollBoxObject, nsIBoxObject, NS_NewScrollBoxObject)
|
|
|
|
MAKE_CTOR(CreateNewOutlinerBoxObject, nsIBoxObject, NS_NewOutlinerBoxObject)
|
|
|
|
MAKE_CTOR(CreateNewAutoCopyService, nsIAutoCopyService, NS_NewAutoCopyService)
|
2000-01-19 07:11:23 +03:00
|
|
|
|
1999-09-28 04:44:47 +04:00
|
|
|
// The list of components we register
|
2001-08-07 06:55:54 +04:00
|
|
|
static nsModuleComponentInfo gComponents[] = {
|
2000-10-29 02:17:53 +04:00
|
|
|
#ifdef DEBUG
|
2001-08-07 06:55:54 +04:00
|
|
|
{ "Frame utility",
|
|
|
|
NS_FRAME_UTIL_CID,
|
|
|
|
nsnull,
|
|
|
|
CreateNewFrameUtil },
|
|
|
|
|
|
|
|
{ "Layout debugger",
|
|
|
|
NS_LAYOUT_DEBUGGER_CID,
|
|
|
|
nsnull,
|
|
|
|
CreateNewLayoutDebugger },
|
2000-10-29 02:17:53 +04:00
|
|
|
#endif
|
1999-09-28 04:44:47 +04:00
|
|
|
|
2001-08-07 06:55:54 +04:00
|
|
|
{ "Print preview context",
|
|
|
|
NS_PRINT_PREVIEW_CONTEXT_CID,
|
|
|
|
nsnull,
|
|
|
|
CreateNewPrintPreviewContext },
|
1999-09-28 04:44:47 +04:00
|
|
|
|
2001-08-07 06:55:54 +04:00
|
|
|
{ "CSS Frame Constructor",
|
|
|
|
NS_CSSFRAMECONSTRUCTOR_CID,
|
|
|
|
nsnull,
|
|
|
|
CreateNewCSSFrameConstructor },
|
1999-09-28 04:44:47 +04:00
|
|
|
|
2001-08-07 06:55:54 +04:00
|
|
|
{ "Frame Traversal",
|
|
|
|
NS_FRAMETRAVERSAL_CID,
|
|
|
|
nsnull,
|
|
|
|
CreateNewFrameTraversal },
|
1999-09-28 04:44:47 +04:00
|
|
|
|
2001-08-07 06:55:54 +04:00
|
|
|
{ "Layout History State",
|
|
|
|
NS_LAYOUT_HISTORY_STATE_CID,
|
|
|
|
nsnull,
|
|
|
|
CreateNewLayoutHistoryState },
|
1999-09-28 04:44:47 +04:00
|
|
|
|
2001-08-07 06:55:54 +04:00
|
|
|
// XXX ick
|
|
|
|
{ "Presentation shell",
|
|
|
|
NS_PRESSHELL_CID,
|
|
|
|
nsnull,
|
|
|
|
CreateNewPresShell },
|
|
|
|
|
|
|
|
{ "Presentation state",
|
|
|
|
NS_PRESSTATE_CID,
|
|
|
|
nsnull,
|
|
|
|
CreateNewPresState },
|
|
|
|
|
|
|
|
{ "Galley context",
|
|
|
|
NS_GALLEYCONTEXT_CID,
|
|
|
|
nsnull,
|
|
|
|
CreateNewGalleyContext },
|
|
|
|
|
|
|
|
{ "Print context",
|
|
|
|
NS_PRINTCONTEXT_CID,
|
|
|
|
nsnull,
|
|
|
|
CreateNewPrintContext },
|
|
|
|
// XXX end ick
|
1999-09-28 04:44:47 +04:00
|
|
|
|
2001-08-07 06:55:54 +04:00
|
|
|
{ "XUL Box Object",
|
|
|
|
NS_BOXOBJECT_CID,
|
|
|
|
"@mozilla.org/layout/xul-boxobject;1",
|
|
|
|
CreateNewBoxObject },
|
|
|
|
|
|
|
|
{ "XUL Tree Box Object",
|
|
|
|
NS_TREEBOXOBJECT_CID,
|
|
|
|
"@mozilla.org/layout/xul-boxobject-tree;1",
|
|
|
|
CreateNewTreeBoxObject },
|
|
|
|
|
|
|
|
{ "XUL Menu Box Object",
|
|
|
|
NS_MENUBOXOBJECT_CID,
|
|
|
|
"@mozilla.org/layout/xul-boxobject-menu;1",
|
|
|
|
CreateNewMenuBoxObject },
|
|
|
|
|
2001-08-18 05:04:47 +04:00
|
|
|
{ "XUL Popup Box Object",
|
|
|
|
NS_POPUPBOXOBJECT_CID,
|
|
|
|
"@mozilla.org/layout/xul-boxobject-popup;1",
|
|
|
|
CreateNewPopupBoxObject },
|
2001-08-07 06:55:54 +04:00
|
|
|
|
|
|
|
{ "XUL Browser Box Object",
|
|
|
|
NS_BROWSERBOXOBJECT_CID,
|
|
|
|
"@mozilla.org/layout/xul-boxobject-browser;1",
|
|
|
|
CreateNewBrowserBoxObject },
|
|
|
|
|
|
|
|
{ "XUL Editor Box Object",
|
|
|
|
NS_EDITORBOXOBJECT_CID,
|
|
|
|
"@mozilla.org/layout/xul-boxobject-editor;1",
|
|
|
|
CreateNewEditorBoxObject },
|
|
|
|
|
|
|
|
{ "XUL Iframe Object",
|
|
|
|
NS_IFRAMEBOXOBJECT_CID,
|
|
|
|
"@mozilla.org/layout/xul-boxobject-iframe;1",
|
|
|
|
CreateNewIFrameBoxObject },
|
|
|
|
|
|
|
|
{ "XUL ScrollBox Object",
|
|
|
|
NS_SCROLLBOXOBJECT_CID,
|
|
|
|
"@mozilla.org/layout/xul-boxobject-scrollbox;1",
|
|
|
|
CreateNewScrollBoxObject },
|
|
|
|
|
|
|
|
{ "XUL Outliner Box Object",
|
|
|
|
NS_OUTLINERBOXOBJECT_CID,
|
|
|
|
"@mozilla.org/layout/xul-boxobject-outliner;1",
|
|
|
|
CreateNewOutlinerBoxObject },
|
|
|
|
|
|
|
|
{ "AutoCopy Service",
|
|
|
|
NS_AUTOCOPYSERVICE_CID,
|
|
|
|
"@mozilla.org/autocopy;1",
|
|
|
|
CreateNewAutoCopyService }
|
|
|
|
};
|
1999-09-28 04:44:47 +04:00
|
|
|
|
2001-08-07 06:55:54 +04:00
|
|
|
NS_IMPL_NSGETMODULE_WITH_CTOR_DTOR(nsLayoutModule, gComponents, Initialize, Shutdown)
|