2007-03-22 10:30:00 -07: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"
|
2010-03-02 12:59:32 -08:00
|
|
|
#include "nsCSSParser.h"
|
2007-03-22 10:30:00 -07:00
|
|
|
#include "nsCSSProps.h"
|
|
|
|
#include "nsCSSPseudoClasses.h"
|
|
|
|
#include "nsCSSPseudoElements.h"
|
|
|
|
#include "nsCSSRendering.h"
|
|
|
|
#include "nsCSSScanner.h"
|
|
|
|
#include "nsDOMAttribute.h"
|
|
|
|
#include "nsDOMClassInfo.h"
|
|
|
|
#include "nsEventListenerManager.h"
|
|
|
|
#include "nsFrame.h"
|
|
|
|
#include "nsGlobalWindow.h"
|
|
|
|
#include "nsGkAtoms.h"
|
|
|
|
#include "nsImageFrame.h"
|
|
|
|
#include "nsLayoutStylesheetCache.h"
|
|
|
|
#include "nsNodeInfo.h"
|
|
|
|
#include "nsRange.h"
|
2009-09-09 18:22:03 -07:00
|
|
|
#include "nsRegion.h"
|
2007-03-22 10:30:00 -07:00
|
|
|
#include "nsRepeatService.h"
|
2009-01-04 16:39:54 -08:00
|
|
|
#include "nsFloatManager.h"
|
2007-03-22 10:30:00 -07:00
|
|
|
#include "nsSprocketLayout.h"
|
|
|
|
#include "nsStackLayout.h"
|
|
|
|
#include "nsStyleSet.h"
|
|
|
|
#include "nsTextControlFrame.h"
|
|
|
|
#include "nsXBLWindowKeyHandler.h"
|
|
|
|
#include "txMozillaXSLTProcessor.h"
|
|
|
|
#include "nsDOMStorage.h"
|
|
|
|
#include "nsCellMap.h"
|
2007-05-09 15:02:29 -07:00
|
|
|
#include "nsTextFrameTextRunCache.h"
|
2007-05-10 13:21:12 -07:00
|
|
|
#include "nsCCUncollectableMarker.h"
|
2007-07-02 16:36:59 -07:00
|
|
|
#include "nsTextFragment.h"
|
2007-11-19 12:08:20 -08:00
|
|
|
#include "nsCSSRuleProcessor.h"
|
2011-03-28 13:11:09 -07:00
|
|
|
#include "nsCrossSiteListenerProxy.h"
|
2011-07-18 15:14:59 -07:00
|
|
|
#include "nsDOMThreadService.h"
|
2008-11-07 15:00:26 -08:00
|
|
|
#include "nsHTMLDNSPrefetch.h"
|
2009-06-28 15:44:22 -07:00
|
|
|
#include "nsHtml5Module.h"
|
2009-05-20 16:07:18 -07:00
|
|
|
#include "nsCrossSiteListenerProxy.h"
|
Bug 178324, refactor focus by moving all focus handling into one place and simplifying it, add many tests, fixes many other bugs too numerous to mention in this small checkin comment, r=josh,smichaud,ere,dbaron,marco,neil,gavin,smaug,sr=smaug (CLOSED TREE)
2009-06-10 11:00:39 -07:00
|
|
|
#include "nsFocusManager.h"
|
2009-07-28 05:51:09 -07:00
|
|
|
#include "nsFrameList.h"
|
2009-08-08 15:00:26 -07:00
|
|
|
#include "nsListControlFrame.h"
|
2010-08-27 08:49:06 -07:00
|
|
|
#include "nsHTMLInputElement.h"
|
2010-06-18 02:21:13 -07:00
|
|
|
#include "nsSVGUtils.h"
|
2011-06-02 04:11:33 -07:00
|
|
|
#include "nsMathMLAtoms.h"
|
|
|
|
#include "nsMathMLOperators.h"
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
#ifdef MOZ_XUL
|
2007-07-23 17:04:36 -07:00
|
|
|
#include "nsXULPopupManager.h"
|
2007-03-22 10:30:00 -07:00
|
|
|
#include "nsXULContentUtils.h"
|
|
|
|
#include "nsXULElement.h"
|
|
|
|
#include "nsXULPrototypeCache.h"
|
2007-04-12 13:59:01 -07:00
|
|
|
#include "nsXULTooltipListener.h"
|
2007-07-17 22:41:40 -07:00
|
|
|
|
|
|
|
#include "inDOMView.h"
|
|
|
|
#endif
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
#include "nsHTMLEditor.h"
|
|
|
|
#include "nsTextServicesDocument.h"
|
|
|
|
|
2008-07-09 01:22:20 -07:00
|
|
|
#ifdef MOZ_MEDIA
|
2008-10-19 00:39:21 -07:00
|
|
|
#include "nsMediaDecoder.h"
|
2008-10-29 22:20:08 -07:00
|
|
|
#include "nsHTMLMediaElement.h"
|
2008-07-09 01:22:20 -07:00
|
|
|
#endif
|
|
|
|
|
2008-11-06 12:53:20 -08:00
|
|
|
#ifdef MOZ_SYDNEYAUDIO
|
2008-07-29 23:50:14 -07:00
|
|
|
#include "nsAudioStream.h"
|
|
|
|
#endif
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
#include "nsError.h"
|
|
|
|
|
2008-02-20 11:00:10 -08:00
|
|
|
#include "nsCycleCollector.h"
|
2008-09-11 06:20:56 -07:00
|
|
|
#include "nsJSEnvironment.h"
|
2010-04-27 02:57:32 -07:00
|
|
|
#include "nsContentSink.h"
|
2010-08-10 10:18:26 -07:00
|
|
|
#include "nsFrameMessageManager.h"
|
2011-03-07 08:58:48 -08:00
|
|
|
#include "nsRefreshDriver.h"
|
2008-02-20 11:00:10 -08:00
|
|
|
|
2011-05-04 04:29:56 -07:00
|
|
|
#include "nsHyphenationManager.h"
|
2011-06-29 04:01:07 -07:00
|
|
|
#include "nsDOMMemoryReporter.h"
|
2011-05-04 04:29:56 -07:00
|
|
|
|
2009-06-16 02:15:46 -07:00
|
|
|
extern void NS_ShutdownChainItemPool();
|
|
|
|
|
2011-03-23 20:13:56 -07:00
|
|
|
using namespace mozilla;
|
|
|
|
|
2010-04-19 08:41:39 -07:00
|
|
|
nsrefcnt nsLayoutStatics::sLayoutStaticRefcnt = 0;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
nsresult
|
|
|
|
nsLayoutStatics::Initialize()
|
|
|
|
{
|
|
|
|
NS_ASSERTION(sLayoutStaticRefcnt == 0,
|
|
|
|
"nsLayoutStatics isn't zero!");
|
|
|
|
|
|
|
|
sLayoutStaticRefcnt = 1;
|
|
|
|
NS_LOG_ADDREF(&sLayoutStaticRefcnt, sLayoutStaticRefcnt,
|
|
|
|
"nsLayoutStatics", 1);
|
|
|
|
|
|
|
|
nsresult rv;
|
|
|
|
|
2007-04-02 10:17:36 -07:00
|
|
|
// Register all of our atoms once
|
|
|
|
nsCSSAnonBoxes::AddRefAtoms();
|
|
|
|
nsCSSPseudoClasses::AddRefAtoms();
|
|
|
|
nsCSSPseudoElements::AddRefAtoms();
|
|
|
|
nsCSSKeywords::AddRefTable();
|
|
|
|
nsCSSProps::AddRefTable();
|
|
|
|
nsColorNames::AddRefTable();
|
|
|
|
nsGkAtoms::AddRefAtoms();
|
|
|
|
|
2008-09-11 06:20:56 -07:00
|
|
|
nsJSRuntime::Startup();
|
2009-09-09 18:22:03 -07:00
|
|
|
rv = nsRegion::InitStatic();
|
|
|
|
if (NS_FAILED(rv)) {
|
|
|
|
NS_ERROR("Could not initialize nsRegion");
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
2007-03-22 10:30:00 -07: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;
|
|
|
|
}
|
|
|
|
|
2011-07-15 03:18:33 -07:00
|
|
|
nsCellMap::Init();
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2011-06-02 05:56:46 -07:00
|
|
|
nsCSSRendering::Init();
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2011-05-02 00:11:34 -07:00
|
|
|
nsTextFrameTextRunCache::Init();
|
2007-05-09 15:02:29 -07:00
|
|
|
|
2008-11-07 15:00:26 -08:00
|
|
|
rv = nsHTMLDNSPrefetch::Initialize();
|
|
|
|
if (NS_FAILED(rv)) {
|
|
|
|
NS_ERROR("Could not initialize HTML DNS prefetch");
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
#ifdef MOZ_XUL
|
|
|
|
rv = nsXULContentUtils::Init();
|
|
|
|
if (NS_FAILED(rv)) {
|
|
|
|
NS_ERROR("Could not initialize nsXULContentUtils");
|
|
|
|
return rv;
|
|
|
|
}
|
2007-07-17 22:35:23 -07:00
|
|
|
|
|
|
|
inDOMView::InitAtoms();
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
#endif
|
|
|
|
|
|
|
|
nsMathMLOperators::AddRefTable();
|
|
|
|
|
|
|
|
nsEditProperty::RegisterAtoms();
|
|
|
|
nsTextServicesDocument::RegisterAtoms();
|
|
|
|
|
|
|
|
#ifdef DEBUG
|
|
|
|
nsFrame::DisplayReflowStartup();
|
|
|
|
#endif
|
|
|
|
nsDOMAttribute::Initialize();
|
|
|
|
|
2007-07-17 14:15:49 -07:00
|
|
|
rv = txMozillaXSLTProcessor::Startup();
|
2007-03-22 10:30:00 -07:00
|
|
|
if (NS_FAILED(rv)) {
|
|
|
|
NS_ERROR("Could not initialize txMozillaXSLTProcessor");
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
|
|
|
rv = nsDOMStorageManager::Initialize();
|
|
|
|
if (NS_FAILED(rv)) {
|
|
|
|
NS_ERROR("Could not initialize nsDOMStorageManager");
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
2007-05-10 13:21:12 -07:00
|
|
|
rv = nsCCUncollectableMarker::Init();
|
|
|
|
if (NS_FAILED(rv)) {
|
|
|
|
NS_ERROR("Could not initialize nsCCUncollectableMarker");
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
2010-04-07 10:29:10 -07:00
|
|
|
rv = nsCSSRuleProcessor::Startup();
|
|
|
|
if (NS_FAILED(rv)) {
|
|
|
|
NS_ERROR("Could not initialize nsCSSRuleProcessor");
|
|
|
|
return rv;
|
|
|
|
}
|
2008-10-21 00:15:03 -07:00
|
|
|
|
2007-07-23 17:04:36 -07:00
|
|
|
#ifdef MOZ_XUL
|
2007-07-04 08:49:38 -07:00
|
|
|
rv = nsXULPopupManager::Init();
|
|
|
|
if (NS_FAILED(rv)) {
|
|
|
|
NS_ERROR("Could not initialize nsXULPopupManager");
|
|
|
|
return rv;
|
|
|
|
}
|
2007-07-23 17:04:36 -07:00
|
|
|
#endif
|
2007-07-04 08:49:38 -07:00
|
|
|
|
Bug 178324, refactor focus by moving all focus handling into one place and simplifying it, add many tests, fixes many other bugs too numerous to mention in this small checkin comment, r=josh,smichaud,ere,dbaron,marco,neil,gavin,smaug,sr=smaug (CLOSED TREE)
2009-06-10 11:00:39 -07:00
|
|
|
rv = nsFocusManager::Init();
|
|
|
|
if (NS_FAILED(rv)) {
|
|
|
|
NS_ERROR("Could not initialize nsFocusManager");
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
2008-11-06 12:53:20 -08:00
|
|
|
#ifdef MOZ_SYDNEYAUDIO
|
2008-10-28 09:17:59 -07:00
|
|
|
nsAudioStream::InitLibrary();
|
2008-07-29 23:50:14 -07:00
|
|
|
#endif
|
|
|
|
|
2010-04-27 02:57:32 -07:00
|
|
|
nsContentSink::InitializeStatics();
|
2009-06-28 15:44:22 -07:00
|
|
|
nsHtml5Module::InitializeStatics();
|
2010-05-31 19:19:35 -07:00
|
|
|
nsIPresShell::InitializeStatics();
|
2011-03-07 08:58:48 -08:00
|
|
|
nsRefreshDriver::InitializeStatics();
|
2010-05-31 19:19:35 -07:00
|
|
|
|
2011-03-28 13:18:45 -07:00
|
|
|
nsCORSListenerProxy::Startup();
|
2009-05-20 16:07:18 -07:00
|
|
|
|
2011-05-01 23:32:59 -07:00
|
|
|
nsFrameList::Init();
|
2009-07-28 05:51:09 -07:00
|
|
|
|
2009-09-18 08:13:10 -07:00
|
|
|
NS_SealStaticAtomTable();
|
|
|
|
|
2011-06-29 04:01:07 -07:00
|
|
|
// TODO: DOM_MEMORY_REPORTER should not be defined in a regular build for the
|
|
|
|
// moment. This protection will be removed when bug 663271 will be close enough
|
|
|
|
// to a shippable state.
|
|
|
|
#ifdef DOM_MEMORY_REPORTER
|
|
|
|
nsDOMMemoryReporter::Init();
|
|
|
|
#endif
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
nsLayoutStatics::Shutdown()
|
|
|
|
{
|
2011-06-29 04:01:07 -07:00
|
|
|
// Don't need to shutdown nsDOMMemoryReporter, that will be done by the memory
|
|
|
|
// reporter manager.
|
|
|
|
|
2010-08-10 10:18:26 -07:00
|
|
|
nsFrameScriptExecutor::Shutdown();
|
Bug 178324, refactor focus by moving all focus handling into one place and simplifying it, add many tests, fixes many other bugs too numerous to mention in this small checkin comment, r=josh,smichaud,ere,dbaron,marco,neil,gavin,smaug,sr=smaug (CLOSED TREE)
2009-06-10 11:00:39 -07:00
|
|
|
nsFocusManager::Shutdown();
|
2007-07-23 17:04:36 -07:00
|
|
|
#ifdef MOZ_XUL
|
2007-07-04 08:49:38 -07:00
|
|
|
nsXULPopupManager::Shutdown();
|
2007-07-23 17:04:36 -07:00
|
|
|
#endif
|
2007-03-22 10:30:00 -07:00
|
|
|
nsDOMStorageManager::Shutdown();
|
|
|
|
txMozillaXSLTProcessor::Shutdown();
|
|
|
|
nsDOMAttribute::Shutdown();
|
|
|
|
nsEventListenerManager::Shutdown();
|
|
|
|
nsComputedDOMStyle::Shutdown();
|
2010-03-02 12:59:32 -08:00
|
|
|
nsCSSParser::Shutdown();
|
2010-04-07 10:29:10 -07:00
|
|
|
nsCSSRuleProcessor::Shutdown();
|
2007-05-09 15:02:29 -07:00
|
|
|
nsTextFrameTextRunCache::Shutdown();
|
2008-11-07 15:00:26 -08:00
|
|
|
nsHTMLDNSPrefetch::Shutdown();
|
2007-03-22 10:30:00 -07:00
|
|
|
nsCSSRendering::Shutdown();
|
|
|
|
#ifdef DEBUG
|
|
|
|
nsFrame::DisplayReflowShutdown();
|
|
|
|
#endif
|
|
|
|
nsCellMap::Shutdown();
|
2010-07-15 14:08:06 -07:00
|
|
|
nsFrame::ShutdownLayerActivityTimer();
|
2007-03-22 10:30:00 -07: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();
|
|
|
|
nsXULPrototypeCache::ReleaseGlobals();
|
|
|
|
nsSprocketLayout::Shutdown();
|
|
|
|
#endif
|
|
|
|
|
|
|
|
nsMathMLOperators::ReleaseTable();
|
|
|
|
|
|
|
|
nsCSSFrameConstructor::ReleaseGlobals();
|
2009-01-04 16:39:54 -08:00
|
|
|
nsFloatManager::Shutdown();
|
2007-03-22 10:30:00 -07:00
|
|
|
nsImageFrame::ReleaseGlobals();
|
|
|
|
|
|
|
|
nsCSSScanner::ReleaseGlobals();
|
|
|
|
|
|
|
|
nsTextFragment::Shutdown();
|
|
|
|
|
|
|
|
nsAttrValue::Shutdown();
|
|
|
|
nsContentUtils::Shutdown();
|
2008-01-21 01:58:58 -08:00
|
|
|
nsNodeInfo::ClearCache();
|
2007-03-22 10:30:00 -07:00
|
|
|
nsLayoutStylesheetCache::Shutdown();
|
|
|
|
NS_NameSpaceManagerShutdown();
|
|
|
|
|
2008-09-11 06:20:56 -07:00
|
|
|
nsJSRuntime::Shutdown();
|
2007-03-22 10:30:00 -07:00
|
|
|
nsGlobalWindow::ShutDown();
|
|
|
|
nsDOMClassInfo::ShutDown();
|
2009-08-08 15:00:26 -07:00
|
|
|
nsListControlFrame::Shutdown();
|
2007-03-22 10:30:00 -07:00
|
|
|
nsXBLWindowKeyHandler::ShutDown();
|
|
|
|
nsAutoCopyListener::Shutdown();
|
|
|
|
|
|
|
|
nsHTMLEditor::Shutdown();
|
|
|
|
nsTextServicesDocument::Shutdown();
|
2008-01-29 22:35:33 -08:00
|
|
|
|
2011-07-18 15:14:59 -07:00
|
|
|
nsDOMThreadService::Shutdown();
|
|
|
|
|
2008-11-06 12:53:20 -08:00
|
|
|
#ifdef MOZ_SYDNEYAUDIO
|
2008-07-29 23:50:14 -07:00
|
|
|
nsAudioStream::ShutdownLibrary();
|
|
|
|
#endif
|
2008-09-30 23:17:15 -07:00
|
|
|
|
2011-03-28 13:18:45 -07:00
|
|
|
nsCORSListenerProxy::Shutdown();
|
2009-06-28 15:44:22 -07:00
|
|
|
|
2010-05-31 19:19:35 -07:00
|
|
|
nsIPresShell::ReleaseStatics();
|
|
|
|
|
2009-06-28 15:44:22 -07:00
|
|
|
nsHtml5Module::ReleaseStatics();
|
2009-06-16 02:15:46 -07:00
|
|
|
|
2009-09-09 18:22:03 -07:00
|
|
|
nsRegion::ShutdownStatic();
|
|
|
|
|
2009-06-16 02:15:46 -07:00
|
|
|
NS_ShutdownChainItemPool();
|
2009-07-28 05:51:09 -07:00
|
|
|
|
|
|
|
nsFrameList::Shutdown();
|
2010-02-11 00:35:49 -08:00
|
|
|
|
2010-08-27 08:49:06 -07:00
|
|
|
nsHTMLInputElement::DestroyUploadLastDir();
|
2011-01-13 09:45:14 -08:00
|
|
|
|
|
|
|
nsLayoutUtils::Shutdown();
|
2011-05-04 04:29:56 -07:00
|
|
|
|
|
|
|
nsHyphenationManager::Shutdown();
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|