gecko-dev/layout/build/nsLayoutModule.cpp

315 lines
9.6 KiB
C++
Raw Normal View History

1999-09-28 00:44:47 +00: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.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 00:44:47 +00: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 00:44:47 +00:00
*
* The Original Code is Mozilla Communicator client code.
*
* The Initial Developer of the Original Code is Netscape Communications
* Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
* Pierre Phaneuf <pp@ludusdesign.com>
1999-09-28 00:44:47 +00:00
*/
#include "nsIGenericFactory.h"
1999-09-28 00:44:47 +00:00
#include "nsLayoutCID.h"
#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 00:44:47 +00: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
1999-09-28 00:44:47 +00:00
#ifdef INCLUDE_XUL
#include "nsXULAtoms.h"
#include "nsBulletinBoardLayout.h"
#include "nsRepeatService.h"
#include "nsSprocketLayout.h"
#include "nsStackLayout.h"
1999-09-28 00:44:47 +00:00
#endif
1999-10-02 11:01:41 +00:00
//MathML Mod - RBS
#ifdef MOZ_MATHML
#include "nsMathMLAtoms.h"
#include "nsMathMLOperators.h"
#endif
// SVG
#ifdef MOZ_SVG
#include "nsSVGAtoms.h"
#endif
1999-09-28 00:44:47 +00:00
//----------------------------------------------------------------------
// Perform our one-time intialization for this module
static PRBool gInitialized = PR_FALSE;
2001-08-08 03:47:56 +00:00
PR_STATIC_CALLBACK(nsresult)
Initialize(nsIModule* self)
{
NS_PRECONDITION(!gInitialized, "module already initialized");
if (gInitialized)
1999-09-28 00:44:47 +00:00
return NS_OK;
gInitialized = PR_TRUE;
1999-09-28 00:44:47 +00:00
// Register all of our atoms once
nsCSSAtoms::AddRefAtoms();
nsCSSKeywords::AddRefTable();
nsCSSProps::AddRefTable();
nsColorNames::AddRefTable();
nsHTMLAtoms::AddRefAtoms();
1999-09-30 21:14:14 +00:00
nsLayoutAtoms::AddRefAtoms();
1999-09-28 00:44:47 +00:00
#ifdef INCLUDE_XUL
nsXULAtoms::AddRefAtoms();
#endif
1999-10-02 11:01:41 +00:00
//MathML Mod - RBS
#ifdef MOZ_MATHML
nsMathMLOperators::AddRefTable();
nsMathMLAtoms::AddRefAtoms();
#endif
1999-09-28 00:44:47 +00:00
// SVG
#ifdef MOZ_SVG
nsSVGAtoms::AddRefAtoms();
#endif
return nsTextTransformer::Initialize();
1999-09-28 00:44:47 +00:00
}
// Shutdown this module, releasing all of the module resources
2001-08-08 03:47:56 +00:00
PR_STATIC_CALLBACK(void)
Shutdown(nsIModule* self)
1999-09-28 00:44:47 +00:00
{
NS_PRECONDITION(gInitialized, "module not initialized");
if (! gInitialized)
return;
gInitialized = PR_FALSE;
#ifdef INCLUDE_XUL
nsBulletinBoardLayout::Shutdown();
nsRepeatService::Shutdown();
nsSprocketLayout::Shutdown();
nsStackLayout::Shutdown();
#endif
1999-09-28 00:44:47 +00:00
// Release all of our atoms
nsColorNames::ReleaseTable();
nsCSSProps::ReleaseTable();
nsCSSKeywords::ReleaseTable();
nsCSSAtoms::ReleaseAtoms();
nsHTMLAtoms::ReleaseAtoms();
1999-09-30 21:14:14 +00:00
nsLayoutAtoms::ReleaseAtoms();
1999-09-28 00:44:47 +00:00
#ifdef INCLUDE_XUL
nsXULAtoms::ReleaseAtoms();
#endif
1999-10-02 11:01:41 +00:00
//MathML Mod - RBS
#ifdef MOZ_MATHML
nsMathMLOperators::ReleaseTable();
nsMathMLAtoms::ReleaseAtoms();
#endif
// SVG
#ifdef MOZ_SVG
nsSVGAtoms::ReleaseAtoms();
#endif
1999-09-28 00:44:47 +00:00
nsTextTransformer::Shutdown();
1999-09-28 00:44:47 +00:00
}
#ifdef NS_DEBUG
extern nsresult NS_NewFrameUtil(nsIFrameUtil** aResult);
extern nsresult NS_NewLayoutDebugger(nsILayoutDebugger** aResult);
#endif
1999-09-28 00:44:47 +00: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);
extern nsresult NS_NewPopupSetBoxObject(nsIBoxObject** aResult);
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 00:44:47 +00:00
}
#ifdef DEBUG
MAKE_CTOR(CreateNewFrameUtil, nsIFrameUtil, NS_NewFrameUtil)
MAKE_CTOR(CreateNewLayoutDebugger, nsILayoutDebugger, NS_NewLayoutDebugger)
#endif
1999-09-28 00:44:47 +00: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)
MAKE_CTOR(CreateNewPopupSetBoxObject, nsIBoxObject, NS_NewPopupSetBoxObject)
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)
1999-09-28 00:44:47 +00:00
// The list of components we register
static nsModuleComponentInfo gComponents[] = {
#ifdef DEBUG
{ "Frame utility",
NS_FRAME_UTIL_CID,
nsnull,
CreateNewFrameUtil },
{ "Layout debugger",
NS_LAYOUT_DEBUGGER_CID,
nsnull,
CreateNewLayoutDebugger },
#endif
1999-09-28 00:44:47 +00:00
{ "Print preview context",
NS_PRINT_PREVIEW_CONTEXT_CID,
nsnull,
CreateNewPrintPreviewContext },
1999-09-28 00:44:47 +00:00
{ "CSS Frame Constructor",
NS_CSSFRAMECONSTRUCTOR_CID,
nsnull,
CreateNewCSSFrameConstructor },
1999-09-28 00:44:47 +00:00
{ "Frame Traversal",
NS_FRAMETRAVERSAL_CID,
nsnull,
CreateNewFrameTraversal },
1999-09-28 00:44:47 +00:00
{ "Layout History State",
NS_LAYOUT_HISTORY_STATE_CID,
nsnull,
CreateNewLayoutHistoryState },
1999-09-28 00:44:47 +00: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 00:44:47 +00: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 },
{ "XUL PopupSet Box Object",
NS_POPUPSETBOXOBJECT_CID,
"@mozilla.org/layout/xul-boxobject-popupset;1",
CreateNewPopupSetBoxObject },
{ "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 00:44:47 +00:00
NS_IMPL_NSGETMODULE_WITH_CTOR_DTOR(nsLayoutModule, gComponents, Initialize, Shutdown)