2006-05-19 09:31:57 +00:00
|
|
|
/* ***** BEGIN LICENSE BLOCK *****
|
|
|
|
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
|
|
|
*
|
|
|
|
* The contents of this file are subject to the Mozilla 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/MPL/
|
|
|
|
*
|
|
|
|
* 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.
|
|
|
|
*
|
|
|
|
* The Original Code is the Mozilla platform.
|
|
|
|
*
|
|
|
|
* The Initial Developer of the Original Code is
|
|
|
|
* Benjamin Smedberg <benjamin@smedbergs.us>.
|
|
|
|
*
|
|
|
|
* Portions created by the Initial Developer are Copyright (C) 2006
|
|
|
|
* the Mozilla Foundation <http://www.mozilla.org/>. All Rights Reserved.
|
|
|
|
*
|
|
|
|
* Contributor(s):
|
|
|
|
*
|
|
|
|
* 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 MPL, 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 MPL, the GPL or the LGPL.
|
|
|
|
*
|
|
|
|
* ***** END LICENSE BLOCK ***** */
|
|
|
|
|
|
|
|
#include "nsLayoutStatics.h"
|
|
|
|
#include "nscore.h"
|
|
|
|
|
|
|
|
#include "nsAttrValue.h"
|
|
|
|
#include "nsAutoCopyListener.h"
|
|
|
|
#include "nsColorNames.h"
|
|
|
|
#include "nsComputedDOMStyle.h"
|
|
|
|
#include "nsContentDLF.h"
|
|
|
|
#include "nsContentUtils.h"
|
|
|
|
#include "nsCSSAnonBoxes.h"
|
|
|
|
#include "nsCSSFrameConstructor.h"
|
|
|
|
#include "nsCSSKeywords.h"
|
|
|
|
#include "nsCSSLoader.h"
|
|
|
|
#include "nsCSSProps.h"
|
|
|
|
#include "nsCSSPseudoClasses.h"
|
|
|
|
#include "nsCSSPseudoElements.h"
|
2007-03-14 19:48:51 +00:00
|
|
|
#include "nsCSSRendering.h"
|
2006-05-19 09:31:57 +00:00
|
|
|
#include "nsCSSScanner.h"
|
|
|
|
#include "nsICSSStyleSheet.h"
|
|
|
|
#include "nsDOMAttribute.h"
|
|
|
|
#include "nsDOMClassInfo.h"
|
|
|
|
#include "nsEventListenerManager.h"
|
|
|
|
#include "nsFrame.h"
|
|
|
|
#include "nsGenericElement.h" // for nsDOMEventRTTearoff
|
2007-08-06 15:27:19 +00:00
|
|
|
#include "nsStyledElement.h"
|
2006-05-19 09:31:57 +00:00
|
|
|
#include "nsGlobalWindow.h"
|
2007-01-30 00:06:41 +00:00
|
|
|
#include "nsGkAtoms.h"
|
2006-05-19 09:31:57 +00:00
|
|
|
#include "nsImageFrame.h"
|
|
|
|
#include "nsLayoutStylesheetCache.h"
|
|
|
|
#include "nsNodeInfo.h"
|
|
|
|
#include "nsRange.h"
|
|
|
|
#include "nsRepeatService.h"
|
|
|
|
#include "nsSpaceManager.h"
|
|
|
|
#include "nsSprocketLayout.h"
|
|
|
|
#include "nsStackLayout.h"
|
|
|
|
#include "nsStyleSet.h"
|
|
|
|
#include "nsTextControlFrame.h"
|
|
|
|
#include "nsXBLWindowKeyHandler.h"
|
2006-12-22 17:22:18 +00:00
|
|
|
#include "txMozillaXSLTProcessor.h"
|
2006-09-15 21:28:48 +00:00
|
|
|
#include "nsDOMStorage.h"
|
2007-02-13 16:23:19 +00:00
|
|
|
#include "nsCellMap.h"
|
2007-05-09 22:02:29 +00:00
|
|
|
#include "nsTextFrameTextRunCache.h"
|
2007-05-10 20:21:12 +00:00
|
|
|
#include "nsCCUncollectableMarker.h"
|
2007-07-02 23:36:59 +00:00
|
|
|
#include "nsTextFragment.h"
|
2007-11-19 20:08:20 +00:00
|
|
|
#include "nsCSSRuleProcessor.h"
|
2008-01-30 06:35:33 +00:00
|
|
|
#include "nsXMLHttpRequest.h"
|
2008-03-20 20:24:36 +00:00
|
|
|
#include "nsIFocusEventSuppressor.h"
|
2008-08-17 01:25:01 +00:00
|
|
|
#include "nsDOMThreadService.h"
|
2006-05-19 09:31:57 +00:00
|
|
|
|
|
|
|
#ifdef MOZ_XUL
|
2007-07-24 00:04:36 +00:00
|
|
|
#include "nsXULPopupManager.h"
|
2006-05-19 09:31:57 +00:00
|
|
|
#include "nsXULContentUtils.h"
|
|
|
|
#include "nsXULElement.h"
|
2007-03-12 05:53:33 +00:00
|
|
|
#include "nsXULPrototypeCache.h"
|
2007-04-12 20:59:01 +00:00
|
|
|
#include "nsXULTooltipListener.h"
|
2007-07-18 05:41:40 +00:00
|
|
|
|
|
|
|
#ifndef MOZ_NO_INSPECTOR_APIS
|
|
|
|
#include "inDOMView.h"
|
|
|
|
#endif
|
2006-05-19 09:31:57 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef MOZ_MATHML
|
|
|
|
#include "nsMathMLAtoms.h"
|
|
|
|
#include "nsMathMLOperators.h"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef MOZ_SVG
|
2006-09-11 15:26:19 +00:00
|
|
|
PRBool NS_SVGEnabled();
|
2006-05-19 09:31:57 +00:00
|
|
|
#endif
|
|
|
|
|
2007-02-24 20:07:06 +00:00
|
|
|
#ifndef MOZILLA_PLAINTEXT_EDITOR_ONLY
|
|
|
|
#include "nsHTMLEditor.h"
|
|
|
|
#include "nsTextServicesDocument.h"
|
|
|
|
#endif
|
|
|
|
|
2008-07-09 08:22:20 +00:00
|
|
|
#ifdef MOZ_MEDIA
|
2008-10-19 07:39:21 +00:00
|
|
|
#include "nsMediaDecoder.h"
|
2008-07-09 08:22:20 +00:00
|
|
|
#endif
|
|
|
|
|
2008-07-30 06:50:14 +00:00
|
|
|
#ifdef MOZ_OGG
|
|
|
|
#include "nsAudioStream.h"
|
|
|
|
#endif
|
|
|
|
|
2006-05-19 09:31:57 +00:00
|
|
|
#include "nsError.h"
|
|
|
|
#include "nsTraceRefcnt.h"
|
|
|
|
|
2008-02-20 19:00:10 +00:00
|
|
|
#include "nsCycleCollector.h"
|
2008-09-11 13:20:56 +00:00
|
|
|
#include "nsJSEnvironment.h"
|
2008-02-20 19:00:10 +00:00
|
|
|
|
2006-05-19 09:31:57 +00:00
|
|
|
static nsrefcnt sLayoutStaticRefcnt;
|
|
|
|
|
|
|
|
nsresult
|
|
|
|
nsLayoutStatics::Initialize()
|
|
|
|
{
|
|
|
|
NS_ASSERTION(sLayoutStaticRefcnt == 0,
|
|
|
|
"nsLayoutStatics isn't zero!");
|
|
|
|
|
|
|
|
sLayoutStaticRefcnt = 1;
|
|
|
|
NS_LOG_ADDREF(&sLayoutStaticRefcnt, sLayoutStaticRefcnt,
|
2006-07-20 21:32:22 +00:00
|
|
|
"nsLayoutStatics", 1);
|
2006-05-19 09:31:57 +00:00
|
|
|
|
|
|
|
nsresult rv;
|
|
|
|
|
2007-04-02 17:17:36 +00:00
|
|
|
// Register all of our atoms once
|
|
|
|
nsCSSAnonBoxes::AddRefAtoms();
|
|
|
|
nsCSSPseudoClasses::AddRefAtoms();
|
|
|
|
nsCSSPseudoElements::AddRefAtoms();
|
|
|
|
nsCSSKeywords::AddRefTable();
|
|
|
|
nsCSSProps::AddRefTable();
|
|
|
|
nsColorNames::AddRefTable();
|
|
|
|
nsGkAtoms::AddRefAtoms();
|
|
|
|
|
2008-09-11 13:20:56 +00:00
|
|
|
nsJSRuntime::Startup();
|
2006-05-19 09:31:57 +00:00
|
|
|
rv = nsContentUtils::Init();
|
|
|
|
if (NS_FAILED(rv)) {
|
|
|
|
NS_ERROR("Could not initialize nsContentUtils");
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
|
|
|
rv = nsAttrValue::Init();
|
|
|
|
if (NS_FAILED(rv)) {
|
|
|
|
NS_ERROR("Could not initialize nsAttrValue");
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
|
|
|
rv = nsTextFragment::Init();
|
|
|
|
if (NS_FAILED(rv)) {
|
|
|
|
NS_ERROR("Could not initialize nsTextFragment");
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
2007-02-13 16:23:19 +00:00
|
|
|
rv = nsCellMap::Init();
|
|
|
|
if (NS_FAILED(rv)) {
|
|
|
|
NS_ERROR("Could not initialize nsCellMap");
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
2007-03-14 19:48:51 +00:00
|
|
|
rv = nsCSSRendering::Init();
|
|
|
|
if (NS_FAILED(rv)) {
|
|
|
|
NS_ERROR("Could not initialize nsCSSRendering");
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
2007-05-09 22:02:29 +00:00
|
|
|
rv = nsTextFrameTextRunCache::Init();
|
|
|
|
if (NS_FAILED(rv)) {
|
|
|
|
NS_ERROR("Could not initialize textframe textrun cache");
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
2006-05-19 09:31:57 +00:00
|
|
|
#ifdef MOZ_XUL
|
|
|
|
rv = nsXULContentUtils::Init();
|
|
|
|
if (NS_FAILED(rv)) {
|
|
|
|
NS_ERROR("Could not initialize nsXULContentUtils");
|
|
|
|
return rv;
|
|
|
|
}
|
2007-07-18 05:35:23 +00:00
|
|
|
|
|
|
|
#ifndef MOZ_NO_INSPECTOR_APIS
|
|
|
|
inDOMView::InitAtoms();
|
|
|
|
#endif
|
|
|
|
|
2006-05-19 09:31:57 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef MOZ_MATHML
|
|
|
|
nsMathMLOperators::AddRefTable();
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef MOZ_SVG
|
2006-09-11 15:26:19 +00:00
|
|
|
if (NS_SVGEnabled())
|
2006-05-19 09:31:57 +00:00
|
|
|
nsContentDLF::RegisterSVG();
|
|
|
|
#endif
|
|
|
|
|
2007-02-24 20:07:06 +00:00
|
|
|
#ifndef MOZILLA_PLAINTEXT_EDITOR_ONLY
|
|
|
|
nsEditProperty::RegisterAtoms();
|
|
|
|
nsTextServicesDocument::RegisterAtoms();
|
|
|
|
#endif
|
|
|
|
|
2006-05-19 09:31:57 +00:00
|
|
|
#ifdef DEBUG
|
|
|
|
nsFrame::DisplayReflowStartup();
|
|
|
|
#endif
|
|
|
|
nsDOMAttribute::Initialize();
|
|
|
|
|
2007-07-17 21:15:49 +00:00
|
|
|
rv = txMozillaXSLTProcessor::Startup();
|
2006-12-22 17:22:18 +00:00
|
|
|
if (NS_FAILED(rv)) {
|
|
|
|
NS_ERROR("Could not initialize txMozillaXSLTProcessor");
|
|
|
|
return rv;
|
2006-05-19 09:31:57 +00:00
|
|
|
}
|
|
|
|
|
2006-09-15 21:28:48 +00:00
|
|
|
rv = nsDOMStorageManager::Initialize();
|
|
|
|
if (NS_FAILED(rv)) {
|
|
|
|
NS_ERROR("Could not initialize nsDOMStorageManager");
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
2008-02-20 19:00:10 +00:00
|
|
|
#ifndef DEBUG_CC
|
2007-05-10 20:21:12 +00:00
|
|
|
rv = nsCCUncollectableMarker::Init();
|
|
|
|
if (NS_FAILED(rv)) {
|
|
|
|
NS_ERROR("Could not initialize nsCCUncollectableMarker");
|
|
|
|
return rv;
|
|
|
|
}
|
2008-02-20 19:00:10 +00:00
|
|
|
#endif
|
2007-05-10 20:21:12 +00:00
|
|
|
|
2007-07-24 00:04:36 +00:00
|
|
|
#ifdef MOZ_XUL
|
2007-07-04 15:49:38 +00:00
|
|
|
rv = nsXULPopupManager::Init();
|
|
|
|
if (NS_FAILED(rv)) {
|
|
|
|
NS_ERROR("Could not initialize nsXULPopupManager");
|
|
|
|
return rv;
|
|
|
|
}
|
2007-07-24 00:04:36 +00:00
|
|
|
#endif
|
2007-07-04 15:49:38 +00:00
|
|
|
|
2008-07-09 08:22:20 +00:00
|
|
|
#ifdef MOZ_MEDIA
|
2008-10-19 07:39:21 +00:00
|
|
|
rv = nsMediaDecoder::InitLogger();
|
2008-07-09 08:22:20 +00:00
|
|
|
if (NS_FAILED(rv)) {
|
2008-10-19 07:39:21 +00:00
|
|
|
NS_ERROR("Could not initialize nsMediaDecoder");
|
2008-07-09 08:22:20 +00:00
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
2008-07-30 06:50:14 +00:00
|
|
|
#ifdef MOZ_OGG
|
|
|
|
rv = nsAudioStream::InitLibrary();
|
|
|
|
if (NS_FAILED(rv)) {
|
|
|
|
NS_ERROR("Could not initialize nsAudioStream");
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2006-05-19 09:31:57 +00:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
nsLayoutStatics::Shutdown()
|
|
|
|
{
|
2007-07-24 00:04:36 +00:00
|
|
|
#ifdef MOZ_XUL
|
2007-07-04 15:49:38 +00:00
|
|
|
nsXULPopupManager::Shutdown();
|
2007-07-24 00:04:36 +00:00
|
|
|
#endif
|
2006-09-21 13:55:27 +00:00
|
|
|
nsDOMStorageManager::Shutdown();
|
2006-12-22 17:22:18 +00:00
|
|
|
txMozillaXSLTProcessor::Shutdown();
|
2006-05-19 09:31:57 +00:00
|
|
|
nsDOMAttribute::Shutdown();
|
|
|
|
nsDOMEventRTTearoff::Shutdown();
|
|
|
|
nsEventListenerManager::Shutdown();
|
|
|
|
nsContentList::Shutdown();
|
|
|
|
nsComputedDOMStyle::Shutdown();
|
|
|
|
CSSLoaderImpl::Shutdown();
|
2008-08-05 20:02:43 +00:00
|
|
|
nsCSSRuleProcessor::FreeSystemMetrics();
|
2007-05-09 22:02:29 +00:00
|
|
|
nsTextFrameTextRunCache::Shutdown();
|
2007-03-14 19:48:51 +00:00
|
|
|
nsCSSRendering::Shutdown();
|
2006-05-19 09:31:57 +00:00
|
|
|
#ifdef DEBUG
|
|
|
|
nsFrame::DisplayReflowShutdown();
|
|
|
|
#endif
|
2007-02-13 16:23:19 +00:00
|
|
|
nsCellMap::Shutdown();
|
2006-05-19 09:31:57 +00:00
|
|
|
|
|
|
|
// Release all of our atoms
|
|
|
|
nsColorNames::ReleaseTable();
|
|
|
|
nsCSSProps::ReleaseTable();
|
|
|
|
nsCSSKeywords::ReleaseTable();
|
|
|
|
nsRepeatService::Shutdown();
|
|
|
|
nsStackLayout::Shutdown();
|
|
|
|
nsBox::Shutdown();
|
|
|
|
|
|
|
|
#ifdef MOZ_XUL
|
|
|
|
nsXULContentUtils::Finish();
|
|
|
|
nsXULElement::ReleaseGlobals();
|
2007-03-12 05:53:33 +00:00
|
|
|
nsXULPrototypeCache::ReleaseGlobals();
|
2006-05-19 09:31:57 +00:00
|
|
|
nsXULPrototypeElement::ReleaseGlobals();
|
|
|
|
nsSprocketLayout::Shutdown();
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef MOZ_MATHML
|
|
|
|
nsMathMLOperators::ReleaseTable();
|
|
|
|
#endif
|
|
|
|
|
|
|
|
nsCSSFrameConstructor::ReleaseGlobals();
|
|
|
|
nsSpaceManager::Shutdown();
|
|
|
|
nsImageFrame::ReleaseGlobals();
|
|
|
|
|
|
|
|
nsCSSScanner::ReleaseGlobals();
|
|
|
|
|
|
|
|
NS_IF_RELEASE(nsContentDLF::gUAStyleSheet);
|
|
|
|
NS_IF_RELEASE(nsRuleNode::gLangService);
|
2007-08-06 15:27:19 +00:00
|
|
|
nsStyledElement::Shutdown();
|
2006-05-19 09:31:57 +00:00
|
|
|
|
|
|
|
nsTextFragment::Shutdown();
|
|
|
|
|
|
|
|
nsAttrValue::Shutdown();
|
|
|
|
nsContentUtils::Shutdown();
|
2008-01-21 09:58:58 +00:00
|
|
|
nsNodeInfo::ClearCache();
|
2006-05-19 09:31:57 +00:00
|
|
|
nsLayoutStylesheetCache::Shutdown();
|
|
|
|
NS_NameSpaceManagerShutdown();
|
|
|
|
nsStyleSet::FreeGlobals();
|
|
|
|
|
2008-09-11 13:20:56 +00:00
|
|
|
nsJSRuntime::Shutdown();
|
2006-05-19 09:31:57 +00:00
|
|
|
nsGlobalWindow::ShutDown();
|
|
|
|
nsDOMClassInfo::ShutDown();
|
|
|
|
nsTextControlFrame::ShutDown();
|
|
|
|
nsXBLWindowKeyHandler::ShutDown();
|
|
|
|
nsAutoCopyListener::Shutdown();
|
2007-01-23 05:24:21 +00:00
|
|
|
|
2007-02-24 20:07:06 +00:00
|
|
|
#ifndef MOZILLA_PLAINTEXT_EDITOR_ONLY
|
|
|
|
nsHTMLEditor::Shutdown();
|
|
|
|
nsTextServicesDocument::Shutdown();
|
|
|
|
#endif
|
2008-01-30 06:35:33 +00:00
|
|
|
|
2008-08-17 01:25:01 +00:00
|
|
|
nsDOMThreadService::Shutdown();
|
|
|
|
|
2008-03-20 20:24:36 +00:00
|
|
|
NS_ShutdownFocusSuppressor();
|
2008-07-30 06:50:14 +00:00
|
|
|
|
|
|
|
#ifdef MOZ_OGG
|
|
|
|
nsAudioStream::ShutdownLibrary();
|
|
|
|
#endif
|
2008-10-01 06:17:15 +00:00
|
|
|
|
2008-10-15 00:12:28 +00:00
|
|
|
nsXMLHttpRequest::ShutdownACCache();
|
2006-05-19 09:31:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
nsLayoutStatics::AddRef()
|
|
|
|
{
|
|
|
|
NS_ASSERTION(sLayoutStaticRefcnt,
|
|
|
|
"nsLayoutStatics already dropped to zero!");
|
|
|
|
|
|
|
|
++sLayoutStaticRefcnt;
|
|
|
|
NS_LOG_ADDREF(&sLayoutStaticRefcnt, sLayoutStaticRefcnt,
|
|
|
|
"nsLayoutStatics", 1);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
nsLayoutStatics::Release()
|
|
|
|
{
|
|
|
|
--sLayoutStaticRefcnt;
|
|
|
|
NS_LOG_RELEASE(&sLayoutStaticRefcnt, sLayoutStaticRefcnt,
|
|
|
|
"nsLayoutStatics");
|
|
|
|
|
|
|
|
if (!sLayoutStaticRefcnt)
|
|
|
|
Shutdown();
|
|
|
|
}
|