2006-05-19 13:31:57 +04: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 22:48:51 +03:00
|
|
|
#include "nsCSSRendering.h"
|
2006-05-19 13:31:57 +04:00
|
|
|
#include "nsCSSScanner.h"
|
|
|
|
#include "nsICSSStyleSheet.h"
|
|
|
|
#include "nsDOMAttribute.h"
|
|
|
|
#include "nsDOMClassInfo.h"
|
2006-06-13 07:07:47 +04:00
|
|
|
#include "nsDOMScriptObjectFactory.h"
|
2006-05-19 13:31:57 +04:00
|
|
|
#include "nsEventListenerManager.h"
|
|
|
|
#include "nsFrame.h"
|
|
|
|
#include "nsGenericElement.h" // for nsDOMEventRTTearoff
|
2007-08-06 19:27:19 +04:00
|
|
|
#include "nsStyledElement.h"
|
2006-05-19 13:31:57 +04:00
|
|
|
#include "nsGlobalWindow.h"
|
2007-01-30 03:06:41 +03:00
|
|
|
#include "nsGkAtoms.h"
|
2006-05-19 13:31:57 +04: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 20:22:18 +03:00
|
|
|
#include "txMozillaXSLTProcessor.h"
|
2006-09-16 01:28:48 +04:00
|
|
|
#include "nsDOMStorage.h"
|
2007-02-13 19:23:19 +03:00
|
|
|
#include "nsCellMap.h"
|
2007-05-10 02:02:29 +04:00
|
|
|
#include "nsTextFrameTextRunCache.h"
|
2007-05-11 00:21:12 +04:00
|
|
|
#include "nsCCUncollectableMarker.h"
|
2007-07-03 03:36:59 +04:00
|
|
|
#include "nsTextFragment.h"
|
2007-11-19 23:08:20 +03:00
|
|
|
#include "nsCSSRuleProcessor.h"
|
2008-01-30 09:35:33 +03:00
|
|
|
#include "nsXMLHttpRequest.h"
|
2008-03-20 23:24:36 +03:00
|
|
|
#include "nsIFocusEventSuppressor.h"
|
2006-05-19 13:31:57 +04:00
|
|
|
|
|
|
|
#ifdef MOZ_XUL
|
2007-07-24 04:04:36 +04:00
|
|
|
#include "nsXULPopupManager.h"
|
2006-05-19 13:31:57 +04:00
|
|
|
#include "nsXULContentUtils.h"
|
|
|
|
#include "nsXULElement.h"
|
2007-03-12 08:53:33 +03:00
|
|
|
#include "nsXULPrototypeCache.h"
|
2007-04-13 00:59:01 +04:00
|
|
|
#include "nsXULTooltipListener.h"
|
2007-07-18 09:41:40 +04:00
|
|
|
|
|
|
|
#ifndef MOZ_NO_INSPECTOR_APIS
|
|
|
|
#include "inDOMView.h"
|
|
|
|
#endif
|
2006-05-19 13:31:57 +04:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef MOZ_MATHML
|
|
|
|
#include "nsMathMLAtoms.h"
|
|
|
|
#include "nsMathMLOperators.h"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef MOZ_SVG
|
2006-09-11 19:26:19 +04:00
|
|
|
PRBool NS_SVGEnabled();
|
2006-05-19 13:31:57 +04:00
|
|
|
#endif
|
|
|
|
|
2007-02-24 23:07:06 +03:00
|
|
|
#ifndef MOZILLA_PLAINTEXT_EDITOR_ONLY
|
|
|
|
#include "nsHTMLEditor.h"
|
|
|
|
#include "nsTextServicesDocument.h"
|
|
|
|
#endif
|
|
|
|
|
2008-07-09 12:22:20 +04:00
|
|
|
#ifdef MOZ_MEDIA
|
|
|
|
#include "nsVideoDecoder.h"
|
|
|
|
#endif
|
|
|
|
|
2008-07-30 10:50:14 +04:00
|
|
|
#ifdef MOZ_OGG
|
|
|
|
#include "nsAudioStream.h"
|
|
|
|
#include "nsVideoDecoder.h"
|
|
|
|
#endif
|
|
|
|
|
2006-05-19 13:31:57 +04:00
|
|
|
#include "nsError.h"
|
|
|
|
#include "nsTraceRefcnt.h"
|
|
|
|
|
2008-02-20 22:00:10 +03:00
|
|
|
#include "nsCycleCollector.h"
|
|
|
|
|
2006-05-19 13:31:57 +04:00
|
|
|
static nsrefcnt sLayoutStaticRefcnt;
|
|
|
|
|
|
|
|
nsresult
|
|
|
|
nsLayoutStatics::Initialize()
|
|
|
|
{
|
|
|
|
NS_ASSERTION(sLayoutStaticRefcnt == 0,
|
|
|
|
"nsLayoutStatics isn't zero!");
|
|
|
|
|
|
|
|
sLayoutStaticRefcnt = 1;
|
|
|
|
NS_LOG_ADDREF(&sLayoutStaticRefcnt, sLayoutStaticRefcnt,
|
2006-07-21 01:32:22 +04:00
|
|
|
"nsLayoutStatics", 1);
|
2006-05-19 13:31:57 +04:00
|
|
|
|
|
|
|
nsresult rv;
|
|
|
|
|
2007-04-02 21:17:36 +04:00
|
|
|
// Register all of our atoms once
|
|
|
|
nsCSSAnonBoxes::AddRefAtoms();
|
|
|
|
nsCSSPseudoClasses::AddRefAtoms();
|
|
|
|
nsCSSPseudoElements::AddRefAtoms();
|
|
|
|
nsCSSKeywords::AddRefTable();
|
|
|
|
nsCSSProps::AddRefTable();
|
|
|
|
nsColorNames::AddRefTable();
|
|
|
|
nsGkAtoms::AddRefAtoms();
|
|
|
|
|
2006-06-13 07:07:47 +04:00
|
|
|
nsDOMScriptObjectFactory::Startup();
|
2006-05-19 13:31:57 +04: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 19:23:19 +03:00
|
|
|
rv = nsCellMap::Init();
|
|
|
|
if (NS_FAILED(rv)) {
|
|
|
|
NS_ERROR("Could not initialize nsCellMap");
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
2007-03-14 22:48:51 +03:00
|
|
|
rv = nsCSSRendering::Init();
|
|
|
|
if (NS_FAILED(rv)) {
|
|
|
|
NS_ERROR("Could not initialize nsCSSRendering");
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
2007-05-10 02:02:29 +04:00
|
|
|
rv = nsTextFrameTextRunCache::Init();
|
|
|
|
if (NS_FAILED(rv)) {
|
|
|
|
NS_ERROR("Could not initialize textframe textrun cache");
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
2006-05-19 13:31:57 +04:00
|
|
|
#ifdef MOZ_XUL
|
|
|
|
rv = nsXULContentUtils::Init();
|
|
|
|
if (NS_FAILED(rv)) {
|
|
|
|
NS_ERROR("Could not initialize nsXULContentUtils");
|
|
|
|
return rv;
|
|
|
|
}
|
2007-07-18 09:35:23 +04:00
|
|
|
|
|
|
|
#ifndef MOZ_NO_INSPECTOR_APIS
|
|
|
|
inDOMView::InitAtoms();
|
|
|
|
#endif
|
|
|
|
|
2006-05-19 13:31:57 +04:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef MOZ_MATHML
|
|
|
|
nsMathMLOperators::AddRefTable();
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef MOZ_SVG
|
2006-09-11 19:26:19 +04:00
|
|
|
if (NS_SVGEnabled())
|
2006-05-19 13:31:57 +04:00
|
|
|
nsContentDLF::RegisterSVG();
|
|
|
|
#endif
|
|
|
|
|
2007-02-24 23:07:06 +03:00
|
|
|
#ifndef MOZILLA_PLAINTEXT_EDITOR_ONLY
|
|
|
|
nsEditProperty::RegisterAtoms();
|
|
|
|
nsTextServicesDocument::RegisterAtoms();
|
|
|
|
#endif
|
|
|
|
|
2006-05-19 13:31:57 +04:00
|
|
|
#ifdef DEBUG
|
|
|
|
nsFrame::DisplayReflowStartup();
|
|
|
|
#endif
|
|
|
|
nsDOMAttribute::Initialize();
|
|
|
|
|
2007-07-18 01:15:49 +04:00
|
|
|
rv = txMozillaXSLTProcessor::Startup();
|
2006-12-22 20:22:18 +03:00
|
|
|
if (NS_FAILED(rv)) {
|
|
|
|
NS_ERROR("Could not initialize txMozillaXSLTProcessor");
|
|
|
|
return rv;
|
2006-05-19 13:31:57 +04:00
|
|
|
}
|
|
|
|
|
2006-09-16 01:28:48 +04:00
|
|
|
rv = nsDOMStorageManager::Initialize();
|
|
|
|
if (NS_FAILED(rv)) {
|
|
|
|
NS_ERROR("Could not initialize nsDOMStorageManager");
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
2008-02-20 22:00:10 +03:00
|
|
|
#ifndef DEBUG_CC
|
2007-05-11 00:21:12 +04:00
|
|
|
rv = nsCCUncollectableMarker::Init();
|
|
|
|
if (NS_FAILED(rv)) {
|
|
|
|
NS_ERROR("Could not initialize nsCCUncollectableMarker");
|
|
|
|
return rv;
|
|
|
|
}
|
2008-02-20 22:00:10 +03:00
|
|
|
#endif
|
2007-05-11 00:21:12 +04:00
|
|
|
|
2007-07-24 04:04:36 +04:00
|
|
|
#ifdef MOZ_XUL
|
2007-07-04 19:49:38 +04:00
|
|
|
rv = nsXULPopupManager::Init();
|
|
|
|
if (NS_FAILED(rv)) {
|
|
|
|
NS_ERROR("Could not initialize nsXULPopupManager");
|
|
|
|
return rv;
|
|
|
|
}
|
2007-07-24 04:04:36 +04:00
|
|
|
#endif
|
2007-07-04 19:49:38 +04:00
|
|
|
|
2008-07-09 12:22:20 +04:00
|
|
|
#ifdef MOZ_MEDIA
|
|
|
|
rv = nsVideoDecoder::InitLogger();
|
|
|
|
if (NS_FAILED(rv)) {
|
|
|
|
NS_ERROR("Could not initialize nsVideoDecoder");
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
2008-07-30 10:50:14 +04:00
|
|
|
#ifdef MOZ_OGG
|
|
|
|
rv = nsAudioStream::InitLibrary();
|
|
|
|
if (NS_FAILED(rv)) {
|
|
|
|
NS_ERROR("Could not initialize nsAudioStream");
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2006-05-19 13:31:57 +04:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
nsLayoutStatics::Shutdown()
|
|
|
|
{
|
2007-07-24 04:04:36 +04:00
|
|
|
#ifdef MOZ_XUL
|
2007-07-04 19:49:38 +04:00
|
|
|
nsXULPopupManager::Shutdown();
|
2007-07-24 04:04:36 +04:00
|
|
|
#endif
|
2006-09-21 17:55:27 +04:00
|
|
|
nsDOMStorageManager::Shutdown();
|
2006-12-22 20:22:18 +03:00
|
|
|
txMozillaXSLTProcessor::Shutdown();
|
2006-05-19 13:31:57 +04:00
|
|
|
nsDOMAttribute::Shutdown();
|
|
|
|
nsDOMEventRTTearoff::Shutdown();
|
|
|
|
nsEventListenerManager::Shutdown();
|
|
|
|
nsContentList::Shutdown();
|
|
|
|
nsComputedDOMStyle::Shutdown();
|
|
|
|
CSSLoaderImpl::Shutdown();
|
2008-08-06 00:02:43 +04:00
|
|
|
nsCSSRuleProcessor::FreeSystemMetrics();
|
2007-05-10 02:02:29 +04:00
|
|
|
nsTextFrameTextRunCache::Shutdown();
|
2007-03-14 22:48:51 +03:00
|
|
|
nsCSSRendering::Shutdown();
|
2006-05-19 13:31:57 +04:00
|
|
|
#ifdef DEBUG
|
|
|
|
nsFrame::DisplayReflowShutdown();
|
|
|
|
#endif
|
2007-02-13 19:23:19 +03:00
|
|
|
nsCellMap::Shutdown();
|
2006-05-19 13:31:57 +04: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 08:53:33 +03:00
|
|
|
nsXULPrototypeCache::ReleaseGlobals();
|
2006-05-19 13:31:57 +04: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 19:27:19 +04:00
|
|
|
nsStyledElement::Shutdown();
|
2006-05-19 13:31:57 +04:00
|
|
|
|
|
|
|
nsTextFragment::Shutdown();
|
|
|
|
|
|
|
|
nsAttrValue::Shutdown();
|
|
|
|
nsContentUtils::Shutdown();
|
2008-01-21 12:58:58 +03:00
|
|
|
nsNodeInfo::ClearCache();
|
2006-05-19 13:31:57 +04:00
|
|
|
nsLayoutStylesheetCache::Shutdown();
|
|
|
|
NS_NameSpaceManagerShutdown();
|
|
|
|
nsStyleSet::FreeGlobals();
|
|
|
|
|
|
|
|
nsGlobalWindow::ShutDown();
|
|
|
|
nsDOMClassInfo::ShutDown();
|
|
|
|
nsTextControlFrame::ShutDown();
|
|
|
|
nsXBLWindowKeyHandler::ShutDown();
|
|
|
|
nsAutoCopyListener::Shutdown();
|
2007-01-23 08:24:21 +03:00
|
|
|
|
2007-02-24 23:07:06 +03:00
|
|
|
#ifndef MOZILLA_PLAINTEXT_EDITOR_ONLY
|
|
|
|
nsHTMLEditor::Shutdown();
|
|
|
|
nsTextServicesDocument::Shutdown();
|
|
|
|
#endif
|
2008-01-30 09:35:33 +03:00
|
|
|
|
2008-03-20 23:24:36 +03:00
|
|
|
NS_ShutdownFocusSuppressor();
|
2008-07-30 10:50:14 +04:00
|
|
|
|
|
|
|
#ifdef MOZ_OGG
|
|
|
|
nsAudioStream::ShutdownLibrary();
|
|
|
|
#endif
|
2006-05-19 13:31:57 +04: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();
|
|
|
|
}
|