Back to index

lightning-sunbird  0.9+nobinonly
nsLayoutModule.cpp
Go to the documentation of this file.
00001 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
00002 /* ***** BEGIN LICENSE BLOCK *****
00003  * Version: MPL 1.1/GPL 2.0/LGPL 2.1
00004  *
00005  * The contents of this file are subject to the Mozilla Public License Version
00006  * 1.1 (the "License"); you may not use this file except in compliance with
00007  * the License. You may obtain a copy of the License at
00008  * http://www.mozilla.org/MPL/
00009  *
00010  * Software distributed under the License is distributed on an "AS IS" basis,
00011  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
00012  * for the specific language governing rights and limitations under the
00013  * License.
00014  *
00015  * The Original Code is Mozilla Communicator client code.
00016  *
00017  * The Initial Developer of the Original Code is
00018  * Netscape Communications Corporation.
00019  * Portions created by the Initial Developer are Copyright (C) 1998
00020  * the Initial Developer. All Rights Reserved.
00021  *
00022  * Contributor(s):
00023  *   Pierre Phaneuf <pp@ludusdesign.com>
00024  *
00025  * Alternatively, the contents of this file may be used under the terms of
00026  * either of the GNU General Public License Version 2 or later (the "GPL"),
00027  * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
00028  * in which case the provisions of the GPL or the LGPL are applicable instead
00029  * of those above. If you wish to allow use of your version of this file only
00030  * under the terms of either the GPL or the LGPL, and not to allow others to
00031  * use your version of this file under the terms of the MPL, indicate your
00032  * decision by deleting the provisions above and replace them with the notice
00033  * and other provisions required by the GPL or the LGPL. If you do not delete
00034  * the provisions above, a recipient may use your version of this file under
00035  * the terms of any one of the MPL, the GPL or the LGPL.
00036  *
00037  * ***** END LICENSE BLOCK ***** */
00038 
00039 #include "nsLayoutStatics.h"
00040 #include "nsContentCID.h"
00041 #include "nsContentHTTPStartup.h"
00042 #include "nsContentDLF.h"
00043 #include "nsContentPolicyUtils.h"
00044 #include "nsDataDocumentContentPolicy.h"
00045 #include "nsDOMCID.h"
00046 #include "nsCSSOMFactory.h"
00047 #include "nsInspectorCSSUtils.h"
00048 #include "nsHTMLContentSerializer.h"
00049 #include "nsHTMLParts.h"
00050 #include "nsGenericHTMLElement.h"
00051 #include "nsICSSLoader.h"
00052 #include "nsICSSParser.h"
00053 #include "nsICSSStyleSheet.h"
00054 #include "nsICategoryManager.h"
00055 #include "nsIComponentManager.h"
00056 #include "nsIComputedDOMStyle.h"
00057 #include "nsIContentIterator.h"
00058 #include "nsIContentSerializer.h"
00059 #include "nsIController.h"
00060 #include "nsIControllers.h"
00061 #include "nsIDOMDOMImplementation.h"
00062 #include "nsIDOMEventGroup.h"
00063 #include "nsIDOMRange.h"
00064 #include "nsIDocument.h"
00065 #include "nsIDocumentEncoder.h"
00066 #include "nsIDocumentViewer.h"
00067 #include "nsIEventListenerManager.h"
00068 #include "nsIFactory.h"
00069 #include "nsIFrameSelection.h"
00070 #include "nsIFrameUtil.h"
00071 #include "nsIGenericFactory.h"
00072 #include "nsIHTMLCSSStyleSheet.h"
00073 #include "nsIFragmentContentSink.h"
00074 #include "nsHTMLStyleSheet.h"
00075 #include "nsIHTMLToTextSink.h"
00076 #include "nsILayoutDebugger.h"
00077 #include "nsINameSpaceManager.h"
00078 #include "nsINodeInfo.h"
00079 #include "nsIObserver.h"
00080 #include "nsIObserverService.h"
00081 #include "nsPresContext.h"
00082 #include "nsIPresShell.h"
00083 #include "nsIPrivateDOMImplementation.h"
00084 #include "nsIRangeUtils.h"
00085 #include "nsIScriptNameSpaceManager.h"
00086 #include "nsISelection.h"
00087 #include "nsIXBLService.h"
00088 #include "nsICaret.h"
00089 #include "nsPlainTextSerializer.h"
00090 #include "mozSanitizingSerializer.h"
00091 #include "nsXMLContentSerializer.h"
00092 #include "nsRuleNode.h"
00093 #include "nsWyciwygProtocolHandler.h"
00094 #include "nsContentAreaDragDrop.h"
00095 #include "nsContentList.h"
00096 #include "nsISyncLoadDOMService.h"
00097 #include "nsBox.h"
00098 #include "nsIFrameTraversal.h"
00099 #include "nsISelectionImageService.h"
00100 #include "nsLayoutCID.h"
00101 #include "nsStyleSheetService.h"
00102 #include "nsNoDataProtocolContentPolicy.h"
00103 
00104 #include "nsDOMParser.h"
00105 #include "nsDOMSerializer.h"
00106 #include "nsXMLHttpRequest.h"
00107 
00108 // view stuff
00109 #include "nsViewsCID.h"
00110 #include "nsViewManager.h"
00111 #include "nsContentCreatorFunctions.h"
00112 
00113 // DOM includes
00114 #include "nsDOMException.h"
00115 #include "nsGlobalWindowCommands.h"
00116 #include "nsIControllerCommandTable.h"
00117 #include "nsJSProtocolHandler.h"
00118 #include "nsScriptNameSpaceManager.h"
00119 #include "nsIControllerContext.h"
00120 #include "nsDOMScriptObjectFactory.h"
00121 #include "nsDOMStorage.h"
00122 
00123 #include "nsHTMLCanvasFrame.h"
00124 
00125 #ifdef MOZ_ENABLE_CANVAS
00126 #include "nsIDOMCanvasRenderingContext2D.h"
00127 #endif
00128 
00129 #ifndef MOZ_NO_INSPECTOR_APIS
00130 #include "inDOMView.h"
00131 #include "inDeepTreeWalker.h"
00132 #include "inFlasher.h"
00133 #include "inCSSValueSearch.h"
00134 #include "inFileSearch.h"
00135 #include "inDOMUtils.h"
00136 #endif
00137 
00138 class nsIDocumentLoaderFactory;
00139 
00140 #define PRODUCT_NAME "Gecko"
00141 
00142 #define NS_HTMLIMGELEMENT_CONTRACTID \
00143   "@mozilla.org/content/element/html;1?name=img"
00144 
00145 #define NS_HTMLOPTIONELEMENT_CONTRACTID \
00146   "@mozilla.org/content/element/html;1?name=option"
00147 
00148 /* 0ddf4df8-4dbb-4133-8b79-9afb966514f5 */
00149 #define NS_PLUGINDOCLOADERFACTORY_CID \
00150 { 0x0ddf4df8, 0x4dbb, 0x4133, { 0x8b, 0x79, 0x9a, 0xfb, 0x96, 0x65, 0x14, 0xf5 } }
00151 
00152 #define NS_WINDOWCOMMANDTABLE_CID \
00153  { /* 0DE2FBFA-6B7F-11D7-BBBA-0003938A9D96 */        \
00154   0x0DE2FBFA, 0x6B7F, 0x11D7, {0xBB, 0xBA, 0x00, 0x03, 0x93, 0x8A, 0x9D, 0x96} }
00155 
00156 static NS_DEFINE_CID(kWindowCommandTableCID, NS_WINDOWCOMMANDTABLE_CID);
00157 
00158 #ifdef MOZ_XUL
00159 #include "nsIBoxObject.h"
00160 #include "nsIXULDocument.h"
00161 #include "nsIXULPopupListener.h"
00162 #include "nsIXULPrototypeCache.h"
00163 #include "nsIXULPrototypeDocument.h"
00164 #include "nsIXULPrototypeDocument.h"
00165 #include "nsIXULSortService.h"
00166 
00167 NS_IMETHODIMP
00168 NS_NewXULContentBuilder(nsISupports* aOuter, REFNSIID aIID, void** aResult);
00169 
00170 NS_IMETHODIMP
00171 NS_NewXULTreeBuilder(nsISupports* aOuter, REFNSIID aIID, void** aResult);
00172 #endif
00173 
00174 PR_STATIC_CALLBACK(nsresult) Initialize(nsIModule* aSelf);
00175 static void Shutdown();
00176 
00177 #ifdef MOZ_XTF
00178 #include "nsIXTFService.h"
00179 #include "nsIXMLContentBuilder.h"
00180 #endif
00181 
00182 #ifdef MOZ_SVG
00183 #include "nsISVGRenderer.h"
00184 #include "nsSVGRect.h"
00185 #include "nsSVGUtils.h"
00186 #include "nsSVGTypeCIDs.h"
00187 
00188 #ifdef MOZ_SVG_RENDERER_LIBART
00189 void NS_InitSVGRendererLibartGlobals();
00190 void NS_FreeSVGRendererLibartGlobals();
00191 #endif
00192 #ifdef MOZ_SVG_RENDERER_GDIPLUS
00193 void NS_InitSVGRendererGDIPlusGlobals();
00194 void NS_FreeSVGRendererGDIPlusGlobals();
00195 #endif
00196 #endif // MOZ_SVG
00197 
00198 NS_GENERIC_FACTORY_CONSTRUCTOR(nsDOMSerializer)
00199 NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nsXMLHttpRequest, Init)
00200 NS_GENERIC_FACTORY_CONSTRUCTOR(nsDOMParser)
00201 
00202 //-----------------------------------------------------------------------------
00203 
00204 // Per bug 209804, it is necessary to observe the "xpcom-shutdown" event and
00205 // perform shutdown of the layout modules at that time instead of waiting for
00206 // our module destructor to run.  If we do not do this, then we risk holding
00207 // references to objects in other component libraries that have already been
00208 // shutdown (and possibly unloaded if 60709 is ever fixed).
00209 
00210 class LayoutShutdownObserver : public nsIObserver
00211 {
00212 public:
00213   NS_DECL_ISUPPORTS
00214   NS_DECL_NSIOBSERVER
00215 };
00216 
00217 NS_IMPL_ISUPPORTS1(LayoutShutdownObserver, nsIObserver)
00218 
00219 NS_IMETHODIMP
00220 LayoutShutdownObserver::Observe(nsISupports *aSubject,
00221                                 const char *aTopic,
00222                                 const PRUnichar *someData)
00223 {
00224   if (!strcmp(aTopic, NS_XPCOM_SHUTDOWN_OBSERVER_ID))
00225     Shutdown();
00226   return NS_OK;
00227 }
00228 
00229 //-----------------------------------------------------------------------------
00230 
00231 static PRBool gInitialized = PR_FALSE;
00232 
00233 // Perform our one-time intialization for this module
00234 
00235 // static
00236 nsresult PR_CALLBACK
00237 Initialize(nsIModule* aSelf)
00238 {
00239   NS_PRECONDITION(!gInitialized, "module already initialized");
00240   if (gInitialized) {
00241     return NS_OK;
00242   }
00243 
00244   gInitialized = PR_TRUE;
00245 
00246   nsresult rv = nsLayoutStatics::Initialize();
00247   if (NS_FAILED(rv)) {
00248     Shutdown();
00249     return rv;
00250   }
00251 
00252   // Add our shutdown observer.
00253   nsCOMPtr<nsIObserverService> observerService =
00254     do_GetService("@mozilla.org/observer-service;1");
00255 
00256   if (observerService) {
00257     LayoutShutdownObserver* observer =
00258       new LayoutShutdownObserver();
00259 
00260     if (!observer) {
00261       Shutdown();
00262 
00263       return NS_ERROR_OUT_OF_MEMORY;
00264     }
00265 
00266     observerService->AddObserver(observer, NS_XPCOM_SHUTDOWN_OBSERVER_ID, PR_FALSE);
00267   } else {
00268     NS_WARNING("Could not get an observer service.  We will leak on shutdown.");
00269   }
00270 
00271   return NS_OK;
00272 }
00273 
00274 // Shutdown this module, releasing all of the module resources
00275 
00276 // static
00277 void
00278 Shutdown()
00279 {
00280   NS_PRECONDITION(gInitialized, "module not initialized");
00281   if (!gInitialized)
00282     return;
00283 
00284   gInitialized = PR_FALSE;
00285 
00286   nsLayoutStatics::Release();
00287 }
00288 
00289 #ifdef NS_DEBUG
00290 nsresult NS_NewFrameUtil(nsIFrameUtil** aResult);
00291 nsresult NS_NewLayoutDebugger(nsILayoutDebugger** aResult);
00292 #endif
00293 
00294 #ifdef MOZ_XUL
00295 nsresult NS_NewBoxObject(nsIBoxObject** aResult);
00296 nsresult NS_NewListBoxObject(nsIBoxObject** aResult);
00297 nsresult NS_NewScrollBoxObject(nsIBoxObject** aResult);
00298 nsresult NS_NewMenuBoxObject(nsIBoxObject** aResult);
00299 nsresult NS_NewEditorBoxObject(nsIBoxObject** aResult);
00300 nsresult NS_NewPopupBoxObject(nsIBoxObject** aResult);
00301 nsresult NS_NewBrowserBoxObject(nsIBoxObject** aResult);
00302 nsresult NS_NewIFrameBoxObject(nsIBoxObject** aResult);
00303 nsresult NS_NewTreeBoxObject(nsIBoxObject** aResult);
00304 #endif
00305 
00306 #ifdef MOZ_ENABLE_CANVAS
00307 nsresult NS_NewCanvasRenderingContext2D(nsIDOMCanvasRenderingContext2D** aResult);
00308 #endif
00309 
00310 nsresult NS_CreateFrameTraversal(nsIFrameTraversal** aResult);
00311 nsresult NS_NewSelectionImageService(nsISelectionImageService** aResult);
00312 
00313 nsresult NS_NewSelection(nsIFrameSelection** aResult);
00314 nsresult NS_NewDomSelection(nsISelection** aResult);
00315 nsresult NS_NewDocumentViewer(nsIDocumentViewer** aResult);
00316 nsresult NS_NewRange(nsIDOMRange** aResult);
00317 nsresult NS_NewRangeUtils(nsIRangeUtils** aResult);
00318 nsresult NS_NewContentIterator(nsIContentIterator** aResult);
00319 nsresult NS_NewPreContentIterator(nsIContentIterator** aResult);
00320 nsresult NS_NewGenRegularIterator(nsIContentIterator** aResult);
00321 nsresult NS_NewContentSubtreeIterator(nsIContentIterator** aResult);
00322 nsresult NS_NewGenSubtreeIterator(nsIContentIterator** aInstancePtrResult);
00323 nsresult NS_NewContentDocumentLoaderFactory(nsIDocumentLoaderFactory** aResult);
00324 nsresult NS_NewHTMLCopyTextEncoder(nsIDocumentEncoder** aResult);
00325 nsresult NS_NewTextEncoder(nsIDocumentEncoder** aResult);
00326 nsresult NS_NewXBLService(nsIXBLService** aResult);
00327 nsresult NS_NewContentPolicy(nsIContentPolicy** aResult);
00328 nsresult NS_NewSyncLoadDOMService(nsISyncLoadDOMService** aResult);
00329 nsresult NS_NewDOMEventGroup(nsIDOMEventGroup** aResult);
00330 
00331 NS_IMETHODIMP NS_NewXULControllers(nsISupports* aOuter, REFNSIID aIID, void** aResult);
00332 
00333 #ifdef MOZ_SVG
00334 #ifdef MOZ_SVG_RENDERER_GDIPLUS
00335 nsresult NS_NewSVGRendererGDIPlus(nsISVGRenderer** aResult);
00336 #endif // MOZ_SVG_RENDERER_GDIPLUS
00337 #ifdef MOZ_SVG_RENDERER_LIBART
00338 nsresult NS_NewSVGRendererLibart(nsISVGRenderer** aResult);
00339 #endif // MOZ_SVG_RENDERER_LIBART
00340 #ifdef MOZ_SVG_RENDERER_CAIRO
00341 nsresult NS_NewSVGRendererCairo(nsISVGRenderer** aResult);
00342 #endif // MOZ_SVG_RENDERER_CAIRO
00343 #endif
00344 
00345 #define MAKE_CTOR(ctor_, iface_, func_)                   \
00346 static NS_IMETHODIMP                                      \
00347 ctor_(nsISupports* aOuter, REFNSIID aIID, void** aResult) \
00348 {                                                         \
00349   *aResult = nsnull;                                      \
00350   if (aOuter)                                             \
00351     return NS_ERROR_NO_AGGREGATION;                       \
00352   iface_* inst;                                           \
00353   nsresult rv = func_(&inst);                             \
00354   if (NS_SUCCEEDED(rv)) {                                 \
00355     rv = inst->QueryInterface(aIID, aResult);             \
00356     NS_RELEASE(inst);                                     \
00357   }                                                       \
00358   return rv;                                              \
00359 }
00360 
00361 #ifdef DEBUG
00362 MAKE_CTOR(CreateNewFrameUtil,             nsIFrameUtil,                NS_NewFrameUtil)
00363 MAKE_CTOR(CreateNewLayoutDebugger,        nsILayoutDebugger,           NS_NewLayoutDebugger)
00364 #endif
00365 
00366 MAKE_CTOR(CreateNewFrameTraversal,      nsIFrameTraversal,      NS_CreateFrameTraversal)
00367 MAKE_CTOR(CreateNewPresShell,           nsIPresShell,           NS_NewPresShell)
00368 #ifdef MOZ_XUL
00369 MAKE_CTOR(CreateNewBoxObject,           nsIBoxObject,           NS_NewBoxObject)
00370 MAKE_CTOR(CreateNewListBoxObject,       nsIBoxObject,           NS_NewListBoxObject)
00371 MAKE_CTOR(CreateNewMenuBoxObject,       nsIBoxObject,           NS_NewMenuBoxObject)
00372 MAKE_CTOR(CreateNewPopupBoxObject,      nsIBoxObject,           NS_NewPopupBoxObject)
00373 MAKE_CTOR(CreateNewBrowserBoxObject,    nsIBoxObject,           NS_NewBrowserBoxObject)
00374 MAKE_CTOR(CreateNewEditorBoxObject,     nsIBoxObject,           NS_NewEditorBoxObject)
00375 MAKE_CTOR(CreateNewIFrameBoxObject,     nsIBoxObject,           NS_NewIFrameBoxObject)
00376 MAKE_CTOR(CreateNewScrollBoxObject,     nsIBoxObject,           NS_NewScrollBoxObject)
00377 MAKE_CTOR(CreateNewTreeBoxObject,       nsIBoxObject,           NS_NewTreeBoxObject)
00378 #endif
00379 MAKE_CTOR(CreateSelectionImageService,  nsISelectionImageService,NS_NewSelectionImageService)
00380 #ifdef MOZ_SVG
00381 #ifdef MOZ_SVG_RENDERER_GDIPLUS
00382 MAKE_CTOR(CreateNewSVGRendererGDIPlus,  nsISVGRenderer,         NS_NewSVGRendererGDIPlus)
00383 #endif // MOZ_SVG_RENDERER_GDIPLUS
00384 #ifdef MOZ_SVG_RENDERER_LIBART
00385 MAKE_CTOR(CreateNewSVGRendererLibart,   nsISVGRenderer,         NS_NewSVGRendererLibart)
00386 #endif // MOZ_SVG_RENDERER_LIBART
00387 #ifdef MOZ_SVG_RENDERER_CAIRO
00388 MAKE_CTOR(CreateNewSVGRendererCairo,   nsISVGRenderer,         NS_NewSVGRendererCairo)
00389 #endif // MOZ_SVG_RENDERER_CAIRO
00390 #endif
00391 MAKE_CTOR(CreateCaret,                  nsICaret,               NS_NewCaret)
00392 
00393 MAKE_CTOR(CreateNameSpaceManager,         nsINameSpaceManager,         NS_GetNameSpaceManager)
00394 MAKE_CTOR(CreateEventListenerManager,     nsIEventListenerManager,     NS_NewEventListenerManager)
00395 MAKE_CTOR(CreateDOMEventGroup,            nsIDOMEventGroup,            NS_NewDOMEventGroup)
00396 MAKE_CTOR(CreateDocumentViewer,           nsIDocumentViewer,           NS_NewDocumentViewer)
00397 MAKE_CTOR(CreateCSSStyleSheet,            nsICSSStyleSheet,            NS_NewCSSStyleSheet)
00398 MAKE_CTOR(CreateHTMLDocument,             nsIDocument,                 NS_NewHTMLDocument)
00399 MAKE_CTOR(CreateHTMLCSSStyleSheet,        nsIHTMLCSSStyleSheet,        NS_NewHTMLCSSStyleSheet)
00400 MAKE_CTOR(CreateDOMImplementation,        nsIDOMDOMImplementation,     NS_NewDOMImplementation)
00401 MAKE_CTOR(CreateXMLDocument,              nsIDocument,                 NS_NewXMLDocument)
00402 #ifdef MOZ_SVG
00403 MAKE_CTOR(CreateSVGDocument,              nsIDocument,                 NS_NewSVGDocument)
00404 #endif
00405 MAKE_CTOR(CreateImageDocument,            nsIDocument,                 NS_NewImageDocument)
00406 MAKE_CTOR(CreateCSSParser,                nsICSSParser,                NS_NewCSSParser)
00407 MAKE_CTOR(CreateCSSLoader,                nsICSSLoader,                NS_NewCSSLoader)
00408 MAKE_CTOR(CreateDOMSelection,             nsISelection,                NS_NewDomSelection)
00409 MAKE_CTOR(CreateSelection,                nsIFrameSelection,           NS_NewSelection)
00410 MAKE_CTOR(CreateRange,                    nsIDOMRange,                 NS_NewRange)
00411 MAKE_CTOR(CreateRangeUtils,               nsIRangeUtils,               NS_NewRangeUtils)
00412 MAKE_CTOR(CreateContentIterator,          nsIContentIterator,          NS_NewContentIterator)
00413 MAKE_CTOR(CreatePreContentIterator,       nsIContentIterator,          NS_NewPreContentIterator)
00414 MAKE_CTOR(CreateGeneratedContentIterator, nsIContentIterator,          NS_NewGenRegularIterator)
00415 MAKE_CTOR(CreateGeneratedSubtreeIterator, nsIContentIterator,          NS_NewGenSubtreeIterator)
00416 MAKE_CTOR(CreateSubtreeIterator,          nsIContentIterator,          NS_NewContentSubtreeIterator)
00417 // CreateHTMLImgElement, see below
00418 // CreateHTMLOptionElement, see below
00419 MAKE_CTOR(CreateTextEncoder,              nsIDocumentEncoder,          NS_NewTextEncoder)
00420 MAKE_CTOR(CreateHTMLCopyTextEncoder,      nsIDocumentEncoder,          NS_NewHTMLCopyTextEncoder)
00421 MAKE_CTOR(CreateXMLContentSerializer,     nsIContentSerializer,        NS_NewXMLContentSerializer)
00422 MAKE_CTOR(CreateHTMLContentSerializer,    nsIContentSerializer,        NS_NewHTMLContentSerializer)
00423 MAKE_CTOR(CreatePlainTextSerializer,      nsIContentSerializer,        NS_NewPlainTextSerializer)
00424 MAKE_CTOR(CreateHTMLFragmentSink,         nsIFragmentContentSink,      NS_NewHTMLFragmentContentSink)
00425 MAKE_CTOR(CreateHTMLFragmentSink2,        nsIFragmentContentSink,      NS_NewHTMLFragmentContentSink2)
00426 MAKE_CTOR(CreateHTMLParanoidFragmentSink, nsIFragmentContentSink,      NS_NewHTMLParanoidFragmentSink)
00427 MAKE_CTOR(CreateXMLFragmentSink,          nsIFragmentContentSink,      NS_NewXMLFragmentContentSink)
00428 MAKE_CTOR(CreateXMLFragmentSink2,         nsIFragmentContentSink,      NS_NewXMLFragmentContentSink2)
00429 MAKE_CTOR(CreateXHTMLParanoidFragmentSink,nsIFragmentContentSink,      NS_NewXHTMLParanoidFragmentSink)
00430 MAKE_CTOR(CreateSanitizingHTMLSerializer, nsIContentSerializer,        NS_NewSanitizingHTMLSerializer)
00431 MAKE_CTOR(CreateXBLService,               nsIXBLService,               NS_NewXBLService)
00432 MAKE_CTOR(CreateContentPolicy,            nsIContentPolicy,            NS_NewContentPolicy)
00433 MAKE_CTOR(CreateComputedDOMStyle,         nsIComputedDOMStyle,         NS_NewComputedDOMStyle)
00434 #ifdef MOZ_XUL
00435 MAKE_CTOR(CreateXULSortService,           nsIXULSortService,           NS_NewXULSortService)
00436 // NS_NewXULContentBuilder
00437 // NS_NewXULTreeBuilder
00438 MAKE_CTOR(CreateXULDocument,              nsIXULDocument,              NS_NewXULDocument)
00439 MAKE_CTOR(CreateXULPopupListener,         nsIXULPopupListener,         NS_NewXULPopupListener)
00440 // NS_NewXULControllers
00441 // NS_NewXULPrototypeCache
00442 #endif
00443 #ifdef MOZ_XTF
00444 MAKE_CTOR(CreateXTFService,               nsIXTFService,               NS_NewXTFService)
00445 MAKE_CTOR(CreateXMLContentBuilder,        nsIXMLContentBuilder,        NS_NewXMLContentBuilder)
00446 #endif
00447 #ifdef MOZ_SVG
00448 MAKE_CTOR(CreateSVGRect,                  nsIDOMSVGRect,               NS_NewSVGRect)
00449 #endif
00450 NS_GENERIC_FACTORY_CONSTRUCTOR(nsContentHTTPStartup)
00451 MAKE_CTOR(CreateContentDLF,               nsIDocumentLoaderFactory,    NS_NewContentDocumentLoaderFactory)
00452 NS_GENERIC_FACTORY_CONSTRUCTOR(nsCSSOMFactory)
00453 NS_GENERIC_FACTORY_CONSTRUCTOR(nsInspectorCSSUtils)
00454 NS_GENERIC_FACTORY_CONSTRUCTOR(nsWyciwygProtocolHandler)
00455 NS_GENERIC_FACTORY_CONSTRUCTOR(nsContentAreaDragDrop)
00456 NS_GENERIC_FACTORY_CONSTRUCTOR(nsDataDocumentContentPolicy)
00457 NS_GENERIC_FACTORY_CONSTRUCTOR(nsNoDataProtocolContentPolicy)
00458 MAKE_CTOR(CreateSyncLoadDOMService,       nsISyncLoadDOMService,       NS_NewSyncLoadDOMService)
00459 MAKE_CTOR(CreatePluginDocument,           nsIDocument,                 NS_NewPluginDocument)
00460 
00461 #ifndef MOZ_NO_INSPECTOR_APIS
00462 NS_GENERIC_FACTORY_CONSTRUCTOR(inDOMView)
00463 NS_GENERIC_FACTORY_CONSTRUCTOR(inDeepTreeWalker)
00464 NS_GENERIC_FACTORY_CONSTRUCTOR(inFlasher)
00465 NS_GENERIC_FACTORY_CONSTRUCTOR(inCSSValueSearch)
00466 NS_GENERIC_FACTORY_CONSTRUCTOR(inFileSearch)
00467 NS_GENERIC_FACTORY_CONSTRUCTOR(inDOMUtils)
00468 #endif
00469 
00470 #ifdef MOZ_ENABLE_CANVAS
00471 MAKE_CTOR(CreateCanvasRenderingContext2D, nsIDOMCanvasRenderingContext2D, NS_NewCanvasRenderingContext2D)
00472 #endif
00473 
00474 NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nsStyleSheetService, Init)
00475 
00476 // views are not refcounted, so this is the same as
00477 // NS_GENERIC_FACTORY_CONSTRUCTOR without the NS_ADDREF/NS_RELEASE
00478 #define NS_GENERIC_FACTORY_CONSTRUCTOR_NOREFS(_InstanceClass)                 \
00479 static NS_IMETHODIMP                                                          \
00480 _InstanceClass##Constructor(nsISupports *aOuter, REFNSIID aIID,               \
00481                             void **aResult)                                   \
00482 {                                                                             \
00483     nsresult rv;                                                              \
00484                                                                               \
00485     _InstanceClass * inst;                                                    \
00486                                                                               \
00487     *aResult = NULL;                                                          \
00488     if (NULL != aOuter) {                                                     \
00489         rv = NS_ERROR_NO_AGGREGATION;                                         \
00490         return rv;                                                            \
00491     }                                                                         \
00492                                                                               \
00493     NS_NEWXPCOM(inst, _InstanceClass);                                        \
00494     if (NULL == inst) {                                                       \
00495         rv = NS_ERROR_OUT_OF_MEMORY;                                          \
00496         return rv;                                                            \
00497     }                                                                         \
00498     rv = inst->QueryInterface(aIID, aResult);                                 \
00499                                                                               \
00500     return rv;                                                                \
00501 }                                                                             \
00502 
00503 NS_GENERIC_FACTORY_CONSTRUCTOR(nsViewManager)
00504 
00505 static NS_IMETHODIMP
00506 CreateHTMLImgElement(nsISupports* aOuter, REFNSIID aIID, void** aResult)
00507 {
00508   *aResult = nsnull;
00509   if (aOuter)
00510     return NS_ERROR_NO_AGGREGATION;
00511   // Note! NS_NewHTMLImageElement is special cased to handle a null nodeinfo
00512   nsIContent* inst = NS_NewHTMLImageElement(nsnull);
00513   nsresult rv = NS_ERROR_OUT_OF_MEMORY;
00514   if (inst) {
00515     NS_ADDREF(inst);
00516     rv = inst->QueryInterface(aIID, aResult);
00517     NS_RELEASE(inst);
00518   }
00519   return rv;
00520 }
00521 
00522 static NS_IMETHODIMP
00523 RegisterHTMLImgElement(nsIComponentManager *aCompMgr,
00524                        nsIFile* aPath,
00525                        const char* aRegistryLocation,
00526                        const char* aComponentType,
00527                        const nsModuleComponentInfo* aInfo)
00528 {
00529   nsCOMPtr<nsICategoryManager> catman =
00530     do_GetService(NS_CATEGORYMANAGER_CONTRACTID);
00531 
00532   if (!catman)
00533     return NS_ERROR_FAILURE;
00534 
00535   nsXPIDLCString previous;
00536   nsresult rv = catman->AddCategoryEntry(JAVASCRIPT_GLOBAL_CONSTRUCTOR_CATEGORY,
00537                                          "Image", NS_HTMLIMGELEMENT_CONTRACTID,
00538                                          PR_TRUE, PR_TRUE, getter_Copies(previous));
00539   NS_ENSURE_SUCCESS(rv, rv);
00540 
00541   return catman->AddCategoryEntry(JAVASCRIPT_GLOBAL_CONSTRUCTOR_PROTO_ALIAS_CATEGORY,
00542                                   "Image", "HTMLImageElement",
00543                                   PR_TRUE, PR_TRUE, getter_Copies(previous));
00544 }
00545 
00546 static NS_IMETHODIMP
00547 UnregisterHTMLImgElement(nsIComponentManager* aCompMgr,
00548                          nsIFile* aPath,
00549                          const char* aRegistryLocation,
00550                          const nsModuleComponentInfo* aInfo)
00551 {
00552   // XXX remove category entry
00553   return NS_OK;
00554 }
00555 
00556 static NS_IMETHODIMP
00557 CreateHTMLOptionElement(nsISupports* aOuter, REFNSIID aIID, void** aResult)
00558 {
00559   *aResult = nsnull;
00560   if (aOuter)
00561     return NS_ERROR_NO_AGGREGATION;
00562   // Note! NS_NewHTMLOptionElement is special cased to handle a null nodeinfo
00563   nsIContent* inst = NS_NewHTMLOptionElement(nsnull);
00564   nsresult rv = NS_ERROR_OUT_OF_MEMORY;
00565   if (inst) {
00566     NS_ADDREF(inst);
00567     rv = inst->QueryInterface(aIID, aResult);
00568     NS_RELEASE(inst);
00569   }
00570   return rv;
00571 }
00572 
00573 static NS_IMETHODIMP
00574 RegisterHTMLOptionElement(nsIComponentManager *aCompMgr,
00575                           nsIFile* aPath,
00576                           const char* aRegistryLocation,
00577                           const char* aComponentType,
00578                           const nsModuleComponentInfo* aInfo)
00579 {
00580   nsCOMPtr<nsICategoryManager> catman =
00581     do_GetService(NS_CATEGORYMANAGER_CONTRACTID);
00582 
00583   if (!catman)
00584     return NS_ERROR_FAILURE;
00585 
00586   nsXPIDLCString previous;
00587   nsresult rv = catman->AddCategoryEntry(JAVASCRIPT_GLOBAL_CONSTRUCTOR_CATEGORY,
00588                                          "Option", NS_HTMLOPTIONELEMENT_CONTRACTID,
00589                                          PR_TRUE, PR_TRUE, getter_Copies(previous));
00590   NS_ENSURE_SUCCESS(rv, rv);
00591 
00592   return catman->AddCategoryEntry(JAVASCRIPT_GLOBAL_CONSTRUCTOR_PROTO_ALIAS_CATEGORY,
00593                                   "Option", "HTMLOptionElement",
00594                                   PR_TRUE, PR_TRUE, getter_Copies(previous));
00595 }
00596 
00597 static NS_IMETHODIMP
00598 UnregisterHTMLOptionElement(nsIComponentManager* aCompMgr,
00599                             nsIFile* aPath,
00600                             const char* aRegistryLocation,
00601                             const nsModuleComponentInfo* aInfo)
00602 {
00603   // XXX remove category entry
00604   return NS_OK;
00605 }
00606 
00607 static NS_METHOD
00608 RegisterDataDocumentContentPolicy(nsIComponentManager *aCompMgr,
00609                                   nsIFile* aPath,
00610                                   const char* aRegistryLocation,
00611                                   const char* aComponentType,
00612                                   const nsModuleComponentInfo* aInfo)
00613 {
00614   nsresult rv;
00615   nsCOMPtr<nsICategoryManager> catman =
00616     do_GetService(NS_CATEGORYMANAGER_CONTRACTID, &rv);
00617   if (NS_FAILED(rv)) {
00618     return rv;
00619   }
00620   nsXPIDLCString previous;
00621   return catman->AddCategoryEntry("content-policy",
00622                                   NS_DATADOCUMENTCONTENTPOLICY_CONTRACTID,
00623                                   NS_DATADOCUMENTCONTENTPOLICY_CONTRACTID,
00624                                   PR_TRUE, PR_TRUE, getter_Copies(previous));
00625 }
00626 
00627 static NS_METHOD
00628 UnregisterDataDocumentContentPolicy(nsIComponentManager *aCompMgr,
00629                                     nsIFile *aPath,
00630                                     const char *registryLocation,
00631                                     const nsModuleComponentInfo *info)
00632 {
00633   nsresult rv;
00634   nsCOMPtr<nsICategoryManager> catman =
00635     do_GetService(NS_CATEGORYMANAGER_CONTRACTID, &rv);
00636   if (NS_FAILED(rv)) {
00637     return rv;
00638   }
00639   
00640   return catman->DeleteCategoryEntry("content-policy",
00641                                      NS_DATADOCUMENTCONTENTPOLICY_CONTRACTID,
00642                                      PR_TRUE);
00643 }
00644 
00645 static NS_METHOD
00646 RegisterNoDataProtocolContentPolicy(nsIComponentManager *aCompMgr,
00647                                     nsIFile* aPath,
00648                                     const char* aRegistryLocation,
00649                                     const char* aComponentType,
00650                                     const nsModuleComponentInfo* aInfo)
00651 {
00652   nsresult rv;
00653   nsCOMPtr<nsICategoryManager> catman =
00654     do_GetService(NS_CATEGORYMANAGER_CONTRACTID, &rv);
00655   if (NS_FAILED(rv)) {
00656     return rv;
00657   }
00658   nsXPIDLCString previous;
00659   return catman->AddCategoryEntry("content-policy",
00660                                   NS_NODATAPROTOCOLCONTENTPOLICY_CONTRACTID,
00661                                   NS_NODATAPROTOCOLCONTENTPOLICY_CONTRACTID,
00662                                   PR_TRUE, PR_TRUE, getter_Copies(previous));
00663 }
00664 
00665 static NS_METHOD
00666 UnregisterNoDataProtocolContentPolicy(nsIComponentManager *aCompMgr,
00667                                       nsIFile *aPath,
00668                                       const char *registryLocation,
00669                                       const nsModuleComponentInfo *info)
00670 {
00671   nsresult rv;
00672   nsCOMPtr<nsICategoryManager> catman =
00673     do_GetService(NS_CATEGORYMANAGER_CONTRACTID, &rv);
00674   if (NS_FAILED(rv)) {
00675     return rv;
00676   }
00677   
00678   return catman->DeleteCategoryEntry("content-policy",
00679                                      NS_NODATAPROTOCOLCONTENTPOLICY_CONTRACTID,
00680                                      PR_TRUE);
00681 }
00682 
00683 static NS_METHOD
00684 CreateWindowCommandTableConstructor(nsISupports *aOuter,
00685                                     REFNSIID aIID, void **aResult)
00686 {
00687   nsresult rv;
00688   nsCOMPtr<nsIControllerCommandTable> commandTable =
00689       do_CreateInstance(NS_CONTROLLERCOMMANDTABLE_CONTRACTID, &rv);
00690   if (NS_FAILED(rv)) return rv;
00691 
00692   rv = nsWindowCommandRegistration::RegisterWindowCommands(commandTable);
00693   if (NS_FAILED(rv)) return rv;
00694 
00695   return commandTable->QueryInterface(aIID, aResult);
00696 }
00697 
00698 static NS_METHOD
00699 CreateWindowControllerWithSingletonCommandTable(nsISupports *aOuter,
00700                                       REFNSIID aIID, void **aResult)
00701 {
00702   nsresult rv;
00703   nsCOMPtr<nsIController> controller =
00704        do_CreateInstance("@mozilla.org/embedcomp/base-command-controller;1", &rv);
00705 
00706  if (NS_FAILED(rv)) return rv;
00707 
00708   nsCOMPtr<nsIControllerCommandTable> windowCommandTable = do_GetService(kWindowCommandTableCID, &rv);
00709   if (NS_FAILED(rv)) return rv;
00710 
00711   // this is a singleton; make it immutable
00712   windowCommandTable->MakeImmutable();
00713 
00714   nsCOMPtr<nsIControllerContext> controllerContext = do_QueryInterface(controller, &rv);
00715   if (NS_FAILED(rv)) return rv;
00716 
00717   controllerContext->Init(windowCommandTable);
00718   if (NS_FAILED(rv)) return rv;
00719 
00720   return controller->QueryInterface(aIID, aResult);
00721 }
00722 
00723 NS_GENERIC_FACTORY_CONSTRUCTOR(nsDOMScriptObjectFactory)
00724 NS_GENERIC_FACTORY_CONSTRUCTOR(nsBaseDOMException)
00725 
00726 // The list of components we register
00727 static const nsModuleComponentInfo gComponents[] = {
00728 #ifdef MOZ_SVG
00729 #ifdef MOZ_SVG_RENDERER_GDIPLUS
00730   { "SVG GdiPlus Renderer",
00731     NS_SVG_RENDERER_GDIPLUS_CID,
00732     NS_SVG_RENDERER_GDIPLUS_CONTRACTID,
00733     CreateNewSVGRendererGDIPlus },
00734 #endif // MOZ_SVG_RENDERER_GDIPLUS
00735 #ifdef MOZ_SVG_RENDERER_LIBART
00736   { "SVG Libart Renderer",
00737     NS_SVG_RENDERER_LIBART_CID,
00738     NS_SVG_RENDERER_LIBART_CONTRACTID,
00739     CreateNewSVGRendererLibart },
00740 #endif // MOZ_SVG_RENDERER_LIBART
00741 #ifdef MOZ_SVG_RENDERER_CAIRO
00742   { "SVG Cairo Renderer",
00743     NS_SVG_RENDERER_CAIRO_CID,
00744     NS_SVG_RENDERER_CAIRO_CONTRACTID,
00745     CreateNewSVGRendererCairo },
00746 #endif // MOZ_SVG_RENDERER_CAIRO
00747 #endif // MOZ_SVG
00748 
00749 #ifdef DEBUG
00750   { "Frame utility",
00751     NS_FRAME_UTIL_CID,
00752     nsnull,
00753     CreateNewFrameUtil },
00754   { "Layout debugger",
00755     NS_LAYOUT_DEBUGGER_CID,
00756     nsnull,
00757     CreateNewLayoutDebugger },
00758 #endif
00759 
00760   { "Frame Traversal",
00761     NS_FRAMETRAVERSAL_CID,
00762     nsnull,
00763     CreateNewFrameTraversal },
00764 
00765   { "selection image storage",
00766     NS_SELECTIONIMAGESERVICE_CID,
00767     nsnull,
00768     CreateSelectionImageService },
00769 
00770   { "caret",
00771     NS_CARET_CID,
00772     "@mozilla.org/layout/caret;1",
00773     CreateCaret },
00774 
00775   // XXX ick
00776   { "Presentation shell",
00777     NS_PRESSHELL_CID,
00778     nsnull,
00779     CreateNewPresShell },
00780 
00781   // XXX end ick
00782 
00783 #ifdef MOZ_XUL
00784   { "XUL Box Object",
00785     NS_BOXOBJECT_CID,
00786     "@mozilla.org/layout/xul-boxobject;1",
00787     CreateNewBoxObject },
00788 
00789   { "XUL Listbox Box Object",
00790     NS_LISTBOXOBJECT_CID,
00791     "@mozilla.org/layout/xul-boxobject-listbox;1",
00792     CreateNewListBoxObject },
00793 
00794   { "XUL Menu Box Object",
00795     NS_MENUBOXOBJECT_CID,
00796     "@mozilla.org/layout/xul-boxobject-menu;1",
00797     CreateNewMenuBoxObject },
00798 
00799   { "XUL Popup Box Object",
00800     NS_POPUPBOXOBJECT_CID,
00801     "@mozilla.org/layout/xul-boxobject-popup;1",
00802     CreateNewPopupBoxObject },
00803 
00804   { "XUL Browser Box Object",
00805     NS_BROWSERBOXOBJECT_CID,
00806     "@mozilla.org/layout/xul-boxobject-browser;1",
00807     CreateNewBrowserBoxObject },
00808 
00809   { "XUL Editor Box Object",
00810     NS_EDITORBOXOBJECT_CID,
00811     "@mozilla.org/layout/xul-boxobject-editor;1",
00812     CreateNewEditorBoxObject },
00813 
00814   { "XUL Iframe Object",
00815     NS_IFRAMEBOXOBJECT_CID,
00816     "@mozilla.org/layout/xul-boxobject-iframe;1",
00817     CreateNewIFrameBoxObject },
00818 
00819   { "XUL ScrollBox Object",
00820     NS_SCROLLBOXOBJECT_CID,
00821     "@mozilla.org/layout/xul-boxobject-scrollbox;1",
00822     CreateNewScrollBoxObject },
00823 
00824   { "XUL Tree Box Object",
00825     NS_TREEBOXOBJECT_CID,
00826     "@mozilla.org/layout/xul-boxobject-tree;1",
00827     CreateNewTreeBoxObject },
00828 
00829 #endif // MOZ_XUL
00830 
00831 #ifndef MOZ_NO_INSPECTOR_APIS
00832 
00833   { "DOM View",
00834     IN_DOMVIEW_CID, 
00835     "@mozilla.org/inspector/dom-view;1",
00836     inDOMViewConstructor },
00837 
00838   { "Deep Tree Walker", 
00839     IN_DEEPTREEWALKER_CID, 
00840     "@mozilla.org/inspector/deep-tree-walker;1",
00841     inDeepTreeWalkerConstructor },
00842 
00843   { "Flasher", 
00844     IN_FLASHER_CID, 
00845     "@mozilla.org/inspector/flasher;1", 
00846     inFlasherConstructor },
00847 
00848   { "CSS Value Search", 
00849     IN_CSSVALUESEARCH_CID, 
00850     "@mozilla.org/inspector/search;1?type=cssvalue", 
00851     inCSSValueSearchConstructor },
00852 
00853   { "File Search", 
00854     IN_FILESEARCH_CID, 
00855     "@mozilla.org/inspector/search;1?type=file", 
00856     inFileSearchConstructor },
00857 
00858   { "DOM Utils", 
00859     IN_DOMUTILS_CID, 
00860     "@mozilla.org/inspector/dom-utils;1", 
00861     inDOMUtilsConstructor },
00862 
00863 #endif
00864 
00865   { "Namespace manager",
00866     NS_NAMESPACEMANAGER_CID,
00867     NS_NAMESPACEMANAGER_CONTRACTID,
00868     CreateNameSpaceManager },
00869 
00870   { "Event listener manager",
00871     NS_EVENTLISTENERMANAGER_CID,
00872     nsnull,
00873     CreateEventListenerManager },
00874 
00875   { "DOM Event group",
00876     NS_DOMEVENTGROUP_CID,
00877     nsnull,
00878     CreateDOMEventGroup },
00879 
00880   { "Document Viewer",
00881     NS_DOCUMENT_VIEWER_CID,
00882     nsnull,
00883     CreateDocumentViewer },
00884 
00885   { "CSS Style Sheet",
00886     NS_CSS_STYLESHEET_CID,
00887     nsnull,
00888     CreateCSSStyleSheet },
00889 
00890   { "HTML document",
00891     NS_HTMLDOCUMENT_CID,
00892     nsnull,
00893     CreateHTMLDocument },
00894 
00895   { "HTML-CSS style sheet",
00896     NS_HTML_CSS_STYLESHEET_CID,
00897     nsnull,
00898     CreateHTMLCSSStyleSheet },
00899 
00900   { "DOM implementation",
00901     NS_DOM_IMPLEMENTATION_CID,
00902     nsnull,
00903     CreateDOMImplementation },
00904 
00905 
00906   { "XML document",
00907     NS_XMLDOCUMENT_CID,
00908     "@mozilla.org/xml/xml-document;1",
00909     CreateXMLDocument },
00910 
00911 #ifdef MOZ_SVG
00912   { "SVG document",
00913     NS_SVGDOCUMENT_CID,
00914     "@mozilla.org/svg/svg-document;1",
00915     CreateSVGDocument },
00916 #endif
00917 
00918   { "Image document",
00919     NS_IMAGEDOCUMENT_CID,
00920     nsnull,
00921     CreateImageDocument },
00922 
00923   { "CSS parser",
00924     NS_CSSPARSER_CID,
00925     "@mozilla.org/content/css-parser;1",
00926     CreateCSSParser },
00927 
00928   { "CSS loader",
00929     NS_CSS_LOADER_CID,
00930     nsnull,
00931     CreateCSSLoader },
00932 
00933   { "Dom selection",
00934     NS_DOMSELECTION_CID,
00935     "@mozilla.org/content/dom-selection;1",
00936     CreateDOMSelection },
00937 
00938   { "Frame selection",
00939     NS_FRAMESELECTION_CID,
00940     nsnull,
00941     CreateSelection },
00942 
00943   { "Range",
00944     NS_RANGE_CID,
00945     "@mozilla.org/content/range;1",
00946     CreateRange },
00947 
00948   { "Range Utils",
00949     NS_RANGEUTILS_CID,
00950     "@mozilla.org/content/range-utils;1",
00951     CreateRangeUtils },
00952 
00953   { "Content iterator",
00954     NS_CONTENTITERATOR_CID,
00955     "@mozilla.org/content/post-content-iterator;1",
00956     CreateContentIterator },
00957 
00958   { "Pre Content iterator",
00959     NS_PRECONTENTITERATOR_CID,
00960     "@mozilla.org/content/pre-content-iterator;1",
00961     CreatePreContentIterator },
00962 
00963   { "Generated Content iterator",
00964     NS_GENERATEDCONTENTITERATOR_CID,
00965     "@mozilla.org/content/generated-content-iterator;1",
00966     CreateGeneratedContentIterator },
00967 
00968   { "Generated Subtree iterator",
00969     NS_GENERATEDSUBTREEITERATOR_CID,
00970     "@mozilla.org/content/generated-subtree-content-iterator;1",
00971     CreateGeneratedSubtreeIterator },
00972 
00973   { "Subtree iterator",
00974     NS_SUBTREEITERATOR_CID,
00975     "@mozilla.org/content/subtree-content-iterator;1",
00976     CreateSubtreeIterator },
00977 
00978   { "CSS Object Model Factory",
00979     NS_CSSOMFACTORY_CID,
00980     nsnull,
00981     nsCSSOMFactoryConstructor },
00982 
00983   { "Inspector CSS Utils",
00984     NS_INSPECTORCSSUTILS_CID,
00985     nsnull,
00986     nsInspectorCSSUtilsConstructor },
00987 
00988   // Needed to support "new Option;" and "new Image;" in JavaScript
00989   { "HTML img element",
00990     NS_HTMLIMAGEELEMENT_CID,
00991     NS_HTMLIMGELEMENT_CONTRACTID,
00992     CreateHTMLImgElement,
00993     RegisterHTMLImgElement, 
00994     UnregisterHTMLImgElement },
00995 
00996   { "HTML option element",
00997     NS_HTMLOPTIONELEMENT_CID,
00998     NS_HTMLOPTIONELEMENT_CONTRACTID,
00999     CreateHTMLOptionElement,
01000     RegisterHTMLOptionElement,
01001     UnregisterHTMLOptionElement },
01002 
01003 #ifdef MOZ_ENABLE_CANVAS
01004   { "Canvas 2D Rendering Context",
01005     NS_CANVASRENDERINGCONTEXT2D_CID,
01006     "@mozilla.org/content/canvas-rendering-context;1?id=2d",
01007     CreateCanvasRenderingContext2D },
01008 #endif
01009 
01010   { "XML document encoder",
01011     NS_TEXT_ENCODER_CID,
01012     NS_DOC_ENCODER_CONTRACTID_BASE "text/xml",
01013     CreateTextEncoder },
01014 
01015   { "XML document encoder",
01016     NS_TEXT_ENCODER_CID,
01017     NS_DOC_ENCODER_CONTRACTID_BASE "application/xml",
01018     CreateTextEncoder },
01019 
01020   { "XML document encoder",
01021     NS_TEXT_ENCODER_CID,
01022     NS_DOC_ENCODER_CONTRACTID_BASE "application/xhtml+xml",
01023     CreateTextEncoder },
01024 
01025 #ifdef MOZ_SVG
01026   { "SVG document encoder",
01027     NS_TEXT_ENCODER_CID,
01028     NS_DOC_ENCODER_CONTRACTID_BASE "image/svg+xml",
01029     CreateTextEncoder },
01030 #endif
01031 
01032   { "HTML document encoder",
01033     NS_TEXT_ENCODER_CID,
01034     NS_DOC_ENCODER_CONTRACTID_BASE "text/html",
01035     CreateTextEncoder },
01036 
01037   { "Plaintext document encoder",
01038     NS_TEXT_ENCODER_CID,
01039     NS_DOC_ENCODER_CONTRACTID_BASE "text/plain",
01040     CreateTextEncoder },
01041 
01042   { "HTML copy encoder",
01043     NS_HTMLCOPY_TEXT_ENCODER_CID,
01044     NS_HTMLCOPY_ENCODER_CONTRACTID,
01045     CreateHTMLCopyTextEncoder },
01046 
01047   { "XML content serializer",
01048     NS_XMLCONTENTSERIALIZER_CID,
01049     NS_CONTENTSERIALIZER_CONTRACTID_PREFIX "text/xml",
01050     CreateXMLContentSerializer },
01051 
01052   { "XML content serializer",
01053     NS_XMLCONTENTSERIALIZER_CID,
01054     NS_CONTENTSERIALIZER_CONTRACTID_PREFIX "application/xml",
01055     CreateXMLContentSerializer },
01056 
01057   { "XML content serializer",
01058     NS_XMLCONTENTSERIALIZER_CID,
01059     NS_CONTENTSERIALIZER_CONTRACTID_PREFIX "application/xhtml+xml",
01060     CreateXMLContentSerializer },
01061 
01062 #ifdef MOZ_SVG
01063   { "SVG content serializer",
01064     NS_XMLCONTENTSERIALIZER_CID,
01065     NS_CONTENTSERIALIZER_CONTRACTID_PREFIX "image/svg+xml",
01066     CreateXMLContentSerializer },
01067 #endif
01068 
01069   { "HTML content serializer",
01070     NS_HTMLCONTENTSERIALIZER_CID,
01071     NS_CONTENTSERIALIZER_CONTRACTID_PREFIX "text/html",
01072     CreateHTMLContentSerializer },
01073 
01074   { "XUL content serializer",
01075     NS_XMLCONTENTSERIALIZER_CID,
01076     NS_CONTENTSERIALIZER_CONTRACTID_PREFIX "application/vnd.mozilla.xul+xml",
01077     CreateXMLContentSerializer },
01078 
01079   { "plaintext content serializer",
01080     NS_PLAINTEXTSERIALIZER_CID,
01081     NS_CONTENTSERIALIZER_CONTRACTID_PREFIX "text/plain",
01082     CreatePlainTextSerializer },
01083 
01084   { "plaintext sink",
01085     NS_PLAINTEXTSERIALIZER_CID,
01086     NS_PLAINTEXTSINK_CONTRACTID,
01087     CreatePlainTextSerializer },
01088 
01089   { "html fragment sink",
01090     NS_HTMLFRAGMENTSINK_CID,
01091     NS_HTMLFRAGMENTSINK_CONTRACTID,
01092     CreateHTMLFragmentSink },
01093 
01094   { "html fragment sink 2",
01095     NS_HTMLFRAGMENTSINK2_CID,
01096     NS_HTMLFRAGMENTSINK2_CONTRACTID,
01097     CreateHTMLFragmentSink2 },
01098 
01099   { "html paranoid fragment sink",
01100     NS_HTMLPARANOIDFRAGMENTSINK_CID,
01101     NS_HTMLPARANOIDFRAGMENTSINK_CONTRACTID,
01102     CreateHTMLParanoidFragmentSink },
01103 
01104   { "HTML sanitizing content serializer",
01105     MOZ_SANITIZINGHTMLSERIALIZER_CID,
01106     MOZ_SANITIZINGHTMLSERIALIZER_CONTRACTID,
01107     CreateSanitizingHTMLSerializer },
01108 
01109   { "xml fragment sink",
01110     NS_XMLFRAGMENTSINK_CID,
01111     NS_XMLFRAGMENTSINK_CONTRACTID,
01112     CreateXMLFragmentSink },
01113 
01114   { "xml fragment sink 2",
01115     NS_XMLFRAGMENTSINK2_CID,
01116     NS_XMLFRAGMENTSINK2_CONTRACTID,
01117     CreateXMLFragmentSink2 },
01118 
01119   { "xhtml paranoid fragment sink",
01120     NS_XHTMLPARANOIDFRAGMENTSINK_CID,
01121     NS_XHTMLPARANOIDFRAGMENTSINK_CONTRACTID,
01122     CreateXHTMLParanoidFragmentSink },
01123 
01124   { "XBL Service",
01125     NS_XBLSERVICE_CID,
01126     "@mozilla.org/xbl;1",
01127     CreateXBLService },
01128 
01129   { "Content policy service",
01130     NS_CONTENTPOLICY_CID,
01131     NS_CONTENTPOLICY_CONTRACTID,
01132     CreateContentPolicy },
01133 
01134   { "Data document content policy",
01135     NS_DATADOCUMENTCONTENTPOLICY_CID,
01136     NS_DATADOCUMENTCONTENTPOLICY_CONTRACTID,
01137     nsDataDocumentContentPolicyConstructor,
01138     RegisterDataDocumentContentPolicy,
01139     UnregisterDataDocumentContentPolicy },
01140 
01141   { "No data protocol content policy",
01142     NS_NODATAPROTOCOLCONTENTPOLICY_CID,
01143     NS_NODATAPROTOCOLCONTENTPOLICY_CONTRACTID,
01144     nsNoDataProtocolContentPolicyConstructor,
01145     RegisterNoDataProtocolContentPolicy,
01146     UnregisterNoDataProtocolContentPolicy },
01147 
01148   { "DOM CSS Computed Style Declaration",
01149     NS_COMPUTEDDOMSTYLE_CID,
01150     "@mozilla.org/DOM/Level2/CSS/computedStyleDeclaration;1",
01151     CreateComputedDOMStyle },
01152 
01153   { "XUL Controllers",
01154     NS_XULCONTROLLERS_CID,
01155     "@mozilla.org/xul/xul-controllers;1",
01156     NS_NewXULControllers },
01157 
01158 #ifdef MOZ_XUL
01159   { "XUL Sort Service",
01160     NS_XULSORTSERVICE_CID,
01161     "@mozilla.org/xul/xul-sort-service;1",
01162     CreateXULSortService },
01163 
01164   { "XUL Template Builder",
01165     NS_XULTEMPLATEBUILDER_CID,
01166     "@mozilla.org/xul/xul-template-builder;1",
01167     NS_NewXULContentBuilder },
01168 
01169   { "XUL Tree Builder",
01170     NS_XULTREEBUILDER_CID,
01171     "@mozilla.org/xul/xul-tree-builder;1",
01172     NS_NewXULTreeBuilder },
01173 
01174   { "XUL Document",
01175     NS_XULDOCUMENT_CID,
01176     "@mozilla.org/xul/xul-document;1",
01177     CreateXULDocument },
01178 
01179   { "XUL PopupListener",
01180     NS_XULPOPUPLISTENER_CID,
01181     "@mozilla.org/xul/xul-popup-listener;1",
01182     CreateXULPopupListener },
01183 
01184   { "XUL Prototype Cache",
01185     NS_XULPROTOTYPECACHE_CID,
01186     "@mozilla.org/xul/xul-prototype-cache;1",
01187     NS_NewXULPrototypeCache },
01188 
01189   { NS_XULPROTOTYPEDOCUMENT_CLASSNAME,
01190     NS_XULPROTOTYPEDOCUMENT_CID,
01191     nsnull,
01192     NS_NewXULPrototypeDocument },
01193 #endif
01194 
01195 #ifdef MOZ_XTF
01196   { "XTF Service",
01197     NS_XTFSERVICE_CID,
01198     NS_XTFSERVICE_CONTRACTID,
01199     CreateXTFService },
01200 
01201   { "XML Content Builder",
01202     NS_XMLCONTENTBUILDER_CID,
01203     NS_XMLCONTENTBUILDER_CONTRACTID,
01204     CreateXMLContentBuilder },
01205 #endif
01206 
01207 #ifdef MOZ_SVG
01208   { "SVG Rect",
01209     NS_SVGRECT_CID,
01210     NS_SVGRECT_CONTRACTID,
01211     CreateSVGRect },
01212 #endif
01213 
01214   { "Content HTTP Startup Listener",
01215     NS_CONTENTHTTPSTARTUP_CID,
01216     NS_CONTENTHTTPSTARTUP_CONTRACTID,
01217     nsContentHTTPStartupConstructor,
01218     nsContentHTTPStartup::RegisterHTTPStartup,
01219     nsContentHTTPStartup::UnregisterHTTPStartup },
01220 
01221   { "Document Loader Factory",
01222     NS_CONTENT_DOCUMENT_LOADER_FACTORY_CID,
01223     "@mozilla.org/content/document-loader-factory;1",
01224     CreateContentDLF,
01225     nsContentDLF::RegisterDocumentFactories,
01226     nsContentDLF::UnregisterDocumentFactories },
01227 
01228   { "Wyciwyg Handler",
01229     NS_WYCIWYGPROTOCOLHANDLER_CID,
01230     NS_NETWORK_PROTOCOL_CONTRACTID_PREFIX "wyciwyg",
01231     nsWyciwygProtocolHandlerConstructor },
01232 
01233   { "Content Area DragDrop",
01234     NS_CONTENTAREADRAGDROP_CID,
01235     NS_CONTENTAREADRAGDROP_CONTRACTID,
01236     nsContentAreaDragDropConstructor },
01237 
01238   { "SyncLoad DOM Service",
01239     NS_SYNCLOADDOMSERVICE_CID,
01240     NS_SYNCLOADDOMSERVICE_CONTRACTID,
01241     CreateSyncLoadDOMService },
01242 
01243   // DOM objects
01244   { "Script Object Factory",
01245     NS_DOM_SCRIPT_OBJECT_FACTORY_CID,
01246     nsnull,
01247     nsDOMScriptObjectFactoryConstructor
01248   },
01249   { "Base DOM Exception",
01250     NS_BASE_DOM_EXCEPTION_CID,
01251     nsnull,
01252     nsBaseDOMExceptionConstructor
01253   },
01254   { "JavaScript Protocol Handler",
01255     NS_JSPROTOCOLHANDLER_CID,
01256     NS_JSPROTOCOLHANDLER_CONTRACTID,
01257     nsJSProtocolHandler::Create },
01258   { "Window Command Table",
01259     NS_WINDOWCOMMANDTABLE_CID,
01260     "",
01261     CreateWindowCommandTableConstructor
01262   },
01263   { "Window Command Controller",
01264     NS_WINDOWCONTROLLER_CID,
01265     NS_WINDOWCONTROLLER_CONTRACTID,
01266     CreateWindowControllerWithSingletonCommandTable
01267   },
01268 
01269   // view stuff
01270   { "View Manager", NS_VIEW_MANAGER_CID, "@mozilla.org/view-manager;1",
01271     nsViewManagerConstructor },
01272 
01273   { "Plugin Document Loader Factory",
01274     NS_PLUGINDOCLOADERFACTORY_CID,
01275     "@mozilla.org/content/plugin/document-loader-factory;1",
01276     CreateContentDLF },
01277 
01278   { "Plugin Document",
01279     NS_PLUGINDOCUMENT_CID,
01280     nsnull,
01281     CreatePluginDocument },
01282 
01283   { "Style sheet service",
01284     NS_STYLESHEETSERVICE_CID,
01285     NS_STYLESHEETSERVICE_CONTRACTID,
01286     nsStyleSheetServiceConstructor },
01287 
01288   { "XML Serializer",
01289     NS_XMLSERIALIZER_CID,
01290     NS_XMLSERIALIZER_CONTRACTID,
01291     nsDOMSerializerConstructor },
01292 
01293   { "XMLHttpRequest",
01294     NS_XMLHTTPREQUEST_CID,
01295     NS_XMLHTTPREQUEST_CONTRACTID,
01296     nsXMLHttpRequestConstructor },
01297 
01298   { "DOM Parser",
01299     NS_DOMPARSER_CID,
01300     NS_DOMPARSER_CONTRACTID,
01301     nsDOMParserConstructor },
01302 
01303   { "DOM Storage",
01304     NS_DOMSTORAGE_CID,
01305     "@mozilla.org/dom/storage;1",
01306     NS_NewDOMStorage }
01307 };
01308 
01309 NS_IMPL_NSGETMODULE_WITH_CTOR(nsLayoutModule, gComponents, Initialize)