--- a/accessible/src/base/DocManager.cpp
+++ b/accessible/src/base/DocManager.cpp
@@ -33,16 +33,21 @@
using namespace mozilla;
using namespace mozilla::a11y;
using namespace mozilla::dom;
////////////////////////////////////////////////////////////////////////////////
// DocManager
////////////////////////////////////////////////////////////////////////////////
+DocManager::DocManager()
+ : mDocAccessibleCache(4)
+{
+}
+
////////////////////////////////////////////////////////////////////////////////
// DocManager public
DocAccessible*
DocManager::GetDocAccessible(nsIDocument* aDocument)
{
if (!aDocument)
return nullptr;
@@ -83,18 +88,16 @@ DocManager::IsProcessingRefreshDriverNot
////////////////////////////////////////////////////////////////////////////////
// DocManager protected
bool
DocManager::Init()
{
- mDocAccessibleCache.Init(4);
-
nsCOMPtr<nsIWebProgress> progress =
do_GetService(NS_DOCUMENTLOADER_SERVICE_CONTRACTID);
if (!progress)
return false;
progress->AddProgressListener(static_cast<nsIWebProgressListener*>(this),
nsIWebProgress::NOTIFY_STATE_DOCUMENT);
--- a/accessible/src/base/DocManager.h
+++ b/accessible/src/base/DocManager.h
@@ -68,17 +68,17 @@ public:
RemoveListeners(aDocument);
}
#ifdef DEBUG
bool IsProcessingRefreshDriverNotification() const;
#endif
protected:
- DocManager() { }
+ DocManager();
/**
* Initialize the manager.
*/
bool Init();
/**
* Shutdown the manager.
--- a/accessible/src/base/NotificationController.cpp
+++ b/accessible/src/base/NotificationController.cpp
@@ -24,18 +24,16 @@ const unsigned int kSelChangeCountToPack
// NotificationCollector
////////////////////////////////////////////////////////////////////////////////
NotificationController::NotificationController(DocAccessible* aDocument,
nsIPresShell* aPresShell) :
EventQueue(aDocument), mObservingState(eNotObservingRefresh),
mPresShell(aPresShell)
{
- mTextHash.Init();
-
// Schedule initial accessible tree construction.
ScheduleProcessing();
}
NotificationController::~NotificationController()
{
NS_ASSERTION(!mDocument, "Controller wasn't shutdown properly!");
if (mDocument)
--- a/accessible/src/generic/DocAccessible.cpp
+++ b/accessible/src/generic/DocAccessible.cpp
@@ -69,31 +69,29 @@ static const uint32_t kRelationAttrsLen
////////////////////////////////////////////////////////////////////////////////
// Constructor/desctructor
DocAccessible::
DocAccessible(nsIDocument* aDocument, nsIContent* aRootContent,
nsIPresShell* aPresShell) :
HyperTextAccessibleWrap(aRootContent, this),
mDocumentNode(aDocument), mScrollPositionChangedTicks(0),
+ // XXX aaronl should we use an algorithm for the initial cache size?
+ mAccessibleCache(kDefaultCacheSize),
+ mNodeToAccessibleMap(kDefaultCacheSize),
mLoadState(eTreeConstructionPending), mDocFlags(0), mLoadEventType(0),
mVirtualCursor(nullptr),
mPresShell(aPresShell)
{
mGenericTypes |= eDocument;
mStateFlags |= eNotNodeMapEntry;
MOZ_ASSERT(mPresShell, "should have been given a pres shell");
mPresShell->SetDocAccessible(this);
- mDependentIDsHash.Init();
- // XXX aaronl should we use an algorithm for the initial cache size?
- mAccessibleCache.Init(kDefaultCacheSize);
- mNodeToAccessibleMap.Init(kDefaultCacheSize);
-
// If this is a XUL Document, it should not implement nsHyperText
if (mDocumentNode && mDocumentNode->IsXUL())
mGenericTypes &= ~eHyperText;
}
DocAccessible::~DocAccessible()
{
NS_ASSERTION(!mPresShell, "LastRelease was never called!?!");
--- a/accessible/src/windows/msaa/DocAccessibleWrap.cpp
+++ b/accessible/src/windows/msaa/DocAccessibleWrap.cpp
@@ -243,17 +243,17 @@ DocAccessibleWrap::get_accValue(
void
DocAccessibleWrap::Shutdown()
{
// Do window emulation specific shutdown if emulation was started.
if (nsWinUtils::IsWindowEmulationStarted()) {
// Destroy window created for root document.
if (mDocFlags & eTabDocument) {
- nsWinUtils::sHWNDCache.Remove(mHWND);
+ nsWinUtils::sHWNDCache->Remove(mHWND);
::DestroyWindow(static_cast<HWND>(mHWND));
}
mHWND = nullptr;
}
DocAccessible::Shutdown();
}
@@ -303,17 +303,17 @@ DocAccessibleWrap::DoInitialUpdate()
nsCOMPtr<nsIDocShell> docShell = do_QueryInterface(container);
docShell->GetIsActive(&isActive);
}
HWND parentWnd = reinterpret_cast<HWND>(nativeData);
mHWND = nsWinUtils::CreateNativeWindow(kClassNameTabContent, parentWnd,
x, y, width, height, isActive);
- nsWinUtils::sHWNDCache.Put(mHWND, this);
+ nsWinUtils::sHWNDCache->Put(mHWND, this);
} else {
DocAccessible* parentDocument = ParentDocument();
if (parentDocument)
mHWND = parentDocument->GetNativeWindow();
}
}
}
--- a/accessible/src/windows/msaa/nsWinUtils.cpp
+++ b/accessible/src/windows/msaa/nsWinUtils.cpp
@@ -25,17 +25,17 @@ using namespace mozilla::a11y;
const PRUnichar* kPropNameTabContent = L"AccessibleTabWindow";
/**
* WindowProc to process WM_GETOBJECT messages, used in windows emulation mode.
*/
static LRESULT CALLBACK WindowProc(HWND hWnd, UINT msg,
WPARAM wParam, LPARAM lParam);
-nsRefPtrHashtable<nsPtrHashKey<void>, DocAccessible> nsWinUtils::sHWNDCache;
+nsRefPtrHashtable<nsPtrHashKey<void>, DocAccessible>* nsWinUtils::sHWNDCache = nullptr;
already_AddRefed<nsIDOMCSSStyleDeclaration>
nsWinUtils::GetComputedStyleDeclaration(nsIContent* aContent)
{
nsIContent* elm = nsCoreUtils::GetDOMElementFor(aContent);
if (!elm)
return nullptr;
@@ -55,17 +55,17 @@ bool
nsWinUtils::MaybeStartWindowEmulation()
{
// Register window class that'll be used for document accessibles associated
// with tabs.
if (Compatibility::IsJAWS() || Compatibility::IsWE() ||
Compatibility::IsDolphin() ||
Preferences::GetBool("browser.tabs.remote")) {
RegisterNativeWindow(kClassNameTabContent);
- sHWNDCache.Init(4);
+ sHWNDCache = new nsRefPtrHashtable<nsPtrHashKey<void>, DocAccessible>(4);
return true;
}
return false;
}
void
nsWinUtils::ShutdownWindowEmulation()
@@ -74,17 +74,17 @@ nsWinUtils::ShutdownWindowEmulation()
// with tabs.
if (IsWindowEmulationStarted())
::UnregisterClassW(kClassNameTabContent, GetModuleHandle(nullptr));
}
bool
nsWinUtils::IsWindowEmulationStarted()
{
- return sHWNDCache.IsInitialized();
+ return sHWNDCache != nullptr;
}
void
nsWinUtils::RegisterNativeWindow(LPCWSTR aWindowClass)
{
WNDCLASSW wc;
wc.style = CS_GLOBALCLASS;
wc.lpfnWndProc = WindowProc;
@@ -140,17 +140,17 @@ WindowProc(HWND hWnd, UINT msg, WPARAM w
// may result in a cross-process ipc call. Doing so may violate RPC
// message semantics.
switch (msg) {
case WM_GETOBJECT:
{
if (lParam == OBJID_CLIENT) {
DocAccessible* document =
- nsWinUtils::sHWNDCache.GetWeak(static_cast<void*>(hWnd));
+ nsWinUtils::sHWNDCache->GetWeak(static_cast<void*>(hWnd));
if (document) {
IAccessible* msaaAccessible = nullptr;
document->GetNativeInterface((void**)&msaaAccessible); // does an addref
if (msaaAccessible) {
LRESULT result = ::LresultFromObject(IID_IAccessible, wParam,
msaaAccessible); // does an addref
msaaAccessible->Release(); // release extra addref
return result;
--- a/accessible/src/windows/msaa/nsWinUtils.h
+++ b/accessible/src/windows/msaa/nsWinUtils.h
@@ -73,15 +73,15 @@ public:
* Helper to hide window.
*/
static void HideNativeWindow(HWND aWnd);
/**
* Cache for HWNDs of windows created for document accessibles in windows
* emulation mode.
*/
- static nsRefPtrHashtable<nsPtrHashKey<void>, DocAccessible> sHWNDCache;
+ static nsRefPtrHashtable<nsPtrHashKey<void>, DocAccessible>* sHWNDCache;
};
} // namespace a11y
} // namespace mozilla
#endif
--- a/accessible/src/xul/XULTreeAccessible.cpp
+++ b/accessible/src/xul/XULTreeAccessible.cpp
@@ -35,17 +35,18 @@ using namespace mozilla::a11y;
////////////////////////////////////////////////////////////////////////////////
// XULTreeAccessible
////////////////////////////////////////////////////////////////////////////////
XULTreeAccessible::
XULTreeAccessible(nsIContent* aContent, DocAccessible* aDoc,
nsTreeBodyFrame* aTreeFrame) :
- AccessibleWrap(aContent, aDoc)
+ AccessibleWrap(aContent, aDoc),
+ mAccessibleCache(kDefaultTreeCacheSize)
{
mType = eXULTreeType;
mGenericTypes |= eSelect;
nsCOMPtr<nsITreeView> view = aTreeFrame->GetExistingView();
mTreeView = view;
mTree = nsCoreUtils::GetTreeBoxObject(aContent);
@@ -53,18 +54,16 @@ XULTreeAccessible::
nsIContent* parentContent = mContent->GetParent();
if (parentContent) {
nsCOMPtr<nsIAutoCompletePopup> autoCompletePopupElm =
do_QueryInterface(parentContent);
if (autoCompletePopupElm)
mGenericTypes |= eAutoCompletePopup;
}
-
- mAccessibleCache.Init(kDefaultTreeCacheSize);
}
////////////////////////////////////////////////////////////////////////////////
// XULTreeAccessible: nsISupports and cycle collection implementation
NS_IMPL_CYCLE_COLLECTION_INHERITED_2(XULTreeAccessible, Accessible,
mTree, mAccessibleCache)
--- a/accessible/src/xul/XULTreeGridAccessible.cpp
+++ b/accessible/src/xul/XULTreeGridAccessible.cpp
@@ -262,21 +262,20 @@ XULTreeGridAccessible::CreateTreeItemAcc
////////////////////////////////////////////////////////////////////////////////
// XULTreeGridRowAccessible
////////////////////////////////////////////////////////////////////////////////
XULTreeGridRowAccessible::
XULTreeGridRowAccessible(nsIContent* aContent, DocAccessible* aDoc,
Accessible* aTreeAcc, nsITreeBoxObject* aTree,
nsITreeView* aTreeView, int32_t aRow) :
- XULTreeItemAccessibleBase(aContent, aDoc, aTreeAcc, aTree, aTreeView, aRow)
+ XULTreeItemAccessibleBase(aContent, aDoc, aTreeAcc, aTree, aTreeView, aRow),
+ mAccessibleCache(kDefaultTreeCacheSize)
{
mGenericTypes |= eTableRow;
-
- mAccessibleCache.Init(kDefaultTreeCacheSize);
}
////////////////////////////////////////////////////////////////////////////////
// XULTreeGridRowAccessible: nsISupports and cycle collection implementation
NS_IMPL_CYCLE_COLLECTION_INHERITED_1(XULTreeGridRowAccessible,
XULTreeItemAccessibleBase,
mAccessibleCache)
--- a/chrome/src/nsChromeRegistry.cpp
+++ b/chrome/src/nsChromeRegistry.cpp
@@ -135,18 +135,16 @@ nsChromeRegistry::GetService()
}
nsCOMPtr<nsIChromeRegistry> registry = gChromeRegistry;
return registry.forget();
}
nsresult
nsChromeRegistry::Init()
{
- mOverrideTable.Init();
-
// This initialization process is fairly complicated and may cause reentrant
// getservice calls to resolve chrome URIs (especially locale files). We
// don't want that, so we inform the protocol handler about our existence
// before we are actually fully initialized.
gChromeRegistry = this;
mInitialized = true;
--- a/chrome/src/nsChromeRegistryChrome.cpp
+++ b/chrome/src/nsChromeRegistryChrome.cpp
@@ -119,19 +119,16 @@ nsChromeRegistryChrome::~nsChromeRegistr
nsresult
nsChromeRegistryChrome::Init()
{
nsresult rv = nsChromeRegistry::Init();
if (NS_FAILED(rv))
return rv;
- mOverlayHash.Init();
- mStyleHash.Init();
-
mSelectedLocale = NS_LITERAL_CSTRING("en-US");
mSelectedSkin = NS_LITERAL_CSTRING("classic/1.0");
if (!PL_DHashTableInit(&mPackagesHash, &kTableOps,
nullptr, sizeof(PackageEntry), 16))
return NS_ERROR_FAILURE;
bool safeMode = false;
--- a/chrome/src/nsChromeRegistryChrome.h
+++ b/chrome/src/nsChromeRegistryChrome.h
@@ -137,17 +137,16 @@ class nsChromeRegistryChrome : public ns
};
class OverlayListHash
{
public:
OverlayListHash() { }
~OverlayListHash() { }
- void Init() { mTable.Init(); }
void Add(nsIURI* aBase, nsIURI* aOverlay);
void Clear() { mTable.Clear(); }
const nsCOMArray<nsIURI>* GetArray(nsIURI* aBase);
private:
nsTHashtable<OverlayListEntry> mTable;
};
--- a/chrome/src/nsChromeRegistryContent.cpp
+++ b/chrome/src/nsChromeRegistryContent.cpp
@@ -7,17 +7,16 @@
#include "nsChromeRegistry.h"
#include "nsChromeRegistryContent.h"
#include "nsString.h"
#include "nsNetUtil.h"
#include "nsResProtocolHandler.h"
nsChromeRegistryContent::nsChromeRegistryContent()
{
- mPackagesHash.Init();
}
void
nsChromeRegistryContent::RegisterRemoteChrome(
const InfallibleTArray<ChromePackage>& aPackages,
const InfallibleTArray<ResourceMapping>& aResources,
const InfallibleTArray<OverrideMapping>& aOverrides,
const nsACString& aLocale)
--- a/content/base/src/nsContentUtils.cpp
+++ b/content/base/src/nsContentUtils.cpp
@@ -569,21 +569,21 @@ nsContentUtils::InitializeEventTable() {
#define WINDOW_ONLY_EVENT EVENT
#define NON_IDL_EVENT EVENT
#include "nsEventNameList.h"
#undef WINDOW_ONLY_EVENT
#undef EVENT
{ nullptr }
};
- sAtomEventTable = new nsDataHashtable<nsISupportsHashKey, EventNameMapping>;
- sStringEventTable = new nsDataHashtable<nsStringHashKey, EventNameMapping>;
+ sAtomEventTable = new nsDataHashtable<nsISupportsHashKey, EventNameMapping>(
+ int(ArrayLength(eventArray) / 0.75) + 1);
+ sStringEventTable = new nsDataHashtable<nsStringHashKey, EventNameMapping>(
+ int(ArrayLength(eventArray) / 0.75) + 1);
sUserDefinedEvents = new nsCOMArray<nsIAtom>(64);
- sAtomEventTable->Init(int(ArrayLength(eventArray) / 0.75) + 1);
- sStringEventTable->Init(int(ArrayLength(eventArray) / 0.75) + 1);
// Subtract one from the length because of the trailing null
for (uint32_t i = 0; i < ArrayLength(eventArray) - 1; ++i) {
sAtomEventTable->Put(eventArray[i].mAtom, eventArray[i]);
sStringEventTable->Put(Substring(nsDependentAtomString(eventArray[i].mAtom), 2),
eventArray[i]);
}
--- a/content/base/src/nsCrossSiteListenerProxy.cpp
+++ b/content/base/src/nsCrossSiteListenerProxy.cpp
@@ -77,17 +77,16 @@ public:
~nsPreflightCache()
{
Clear();
MOZ_COUNT_DTOR(nsPreflightCache);
}
bool Initialize()
{
- mTable.Init();
return true;
}
CacheEntry* GetEntry(nsIURI* aURI, nsIPrincipal* aPrincipal,
bool aWithCredentials, bool aCreate);
void RemoveEntries(nsIURI* aURI, nsIPrincipal* aPrincipal);
void Clear();
--- a/content/base/src/nsDOMAttributeMap.cpp
+++ b/content/base/src/nsDOMAttributeMap.cpp
@@ -28,17 +28,16 @@ using namespace mozilla::dom;
//----------------------------------------------------------------------
nsDOMAttributeMap::nsDOMAttributeMap(Element* aContent)
: mContent(aContent)
{
// We don't add a reference to our content. If it goes away,
// we'll be told to drop our reference
- mAttributeCache.Init();
SetIsDOMBinding();
}
/**
* Clear map pointer for attributes.
*/
PLDHashOperator
RemoveMapRef(nsAttrHashKey::KeyType aKey, nsRefPtr<Attr>& aData,
--- a/content/base/src/nsDOMMutationObserver.h
+++ b/content/base/src/nsDOMMutationObserver.h
@@ -342,17 +342,16 @@ NS_DEFINE_STATIC_IID_ACCESSOR(nsMutation
class nsDOMMutationObserver : public nsISupports,
public nsWrapperCache
{
public:
nsDOMMutationObserver(already_AddRefed<nsPIDOMWindow> aOwner,
mozilla::dom::MutationCallback& aCb)
: mOwner(aOwner), mCallback(&aCb), mWaitingForRun(false), mId(++sCount)
{
- mTransientReceivers.Init();
SetIsDOMBinding();
}
virtual ~nsDOMMutationObserver();
NS_DECL_CYCLE_COLLECTING_ISUPPORTS
NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(nsDOMMutationObserver)
static already_AddRefed<nsDOMMutationObserver>
Constructor(const mozilla::dom::GlobalObject& aGlobal,
--- a/content/base/src/nsDocument.cpp
+++ b/content/base/src/nsDocument.cpp
@@ -277,17 +277,16 @@ nsIdentifierMapEntry::AppendAllIdContent
void
nsIdentifierMapEntry::AddContentChangeCallback(nsIDocument::IDTargetObserver aCallback,
void* aData, bool aForImage)
{
if (!mChangeCallbacks) {
mChangeCallbacks = new nsTHashtable<ChangeCallbackEntry>;
if (!mChangeCallbacks)
return;
- mChangeCallbacks->Init();
}
ChangeCallback cc = { aCallback, aData, aForImage };
mChangeCallbacks->PutEntry(cc);
}
void
nsIdentifierMapEntry::RemoveContentChangeCallback(nsIDocument::IDTargetObserver aCallback,
@@ -692,18 +691,16 @@ nsOnloadBlocker::SetLoadFlags(nsLoadFlag
return NS_OK;
}
// ==================================================================
nsExternalResourceMap::nsExternalResourceMap()
: mHaveShutDown(false)
{
- mMap.Init();
- mPendingLoads.Init();
}
nsIDocument*
nsExternalResourceMap::RequestResource(nsIURI* aURI,
nsINode* aRequestingNode,
nsDocument* aDisplayDocument,
ExternalResourceLoad** aPendingLoad)
{
@@ -1389,18 +1386,16 @@ nsDocument::nsDocument(const char* aCont
("DOCUMENT %p created", this));
if (!gCspPRLog)
gCspPRLog = PR_NewLogModule("CSP");
#endif
// Start out mLastStyleSheetSet as null, per spec
SetDOMStringToNull(mLastStyleSheetSet);
-
- mLinksToUpdate.Init();
}
static PLDHashOperator
ClearAllBoxObjects(nsIContent* aKey, nsPIBoxObject* aBoxObject, void* aUserArg)
{
if (aBoxObject) {
aBoxObject->Clear();
}
@@ -1929,21 +1924,16 @@ nsDocument::Init()
return NS_ERROR_ALREADY_INITIALIZED;
}
if (!sPrefsInitialized) {
sPrefsInitialized = true;
Preferences::AddUintVarCache(&sOnloadDecodeLimit, "image.onload.decode.limit", 0);
}
- mIdentifierMap.Init();
- mStyledLinks.Init();
- mRadioGroups.Init();
- mCustomPrototypes.Init();
-
// Force initialization.
nsINode::nsSlots* slots = Slots();
// Prepend self as mutation-observer whether we need it or not (some
// subclasses currently do, other don't). This is because the code in
// nsNodeUtils always notifies the first observer first, expecting the
// first observer to be the document.
NS_ENSURE_TRUE(slots->mMutationObservers.PrependElementUnlessExists(static_cast<nsIMutationObserver*>(this)),
@@ -1975,19 +1965,16 @@ nsDocument::Init()
// via some events.
nsCOMPtr<nsIGlobalObject> global = xpc::GetJunkScopeGlobal();
NS_ENSURE_TRUE(global, NS_ERROR_FAILURE);
mScopeObject = do_GetWeakReference(global);
MOZ_ASSERT(mScopeObject);
mScriptLoader = new nsScriptLoader(this);
- mImageTracker.Init();
- mPlugins.Init();
-
mozilla::HoldJSObjects(this);
return NS_OK;
}
void
nsIDocument::DeleteAllProperties()
{
@@ -6139,18 +6126,17 @@ nsDocument::GetBoxObjectFor(Element* aEl
mHasWarnedAboutBoxObjects = true;
nsContentUtils::ReportToConsole(nsIScriptError::warningFlag,
NS_LITERAL_CSTRING("BoxObjects"), this,
nsContentUtils::eDOM_PROPERTIES,
"UseOfGetBoxObjectForWarning");
}
if (!mBoxObjectTable) {
- mBoxObjectTable = new nsInterfaceHashtable<nsPtrHashKey<nsIContent>, nsPIBoxObject>;
- mBoxObjectTable->Init(12);
+ mBoxObjectTable = new nsInterfaceHashtable<nsPtrHashKey<nsIContent>, nsPIBoxObject>(12);
} else {
nsCOMPtr<nsPIBoxObject> boxObject = mBoxObjectTable->Get(aElement);
if (boxObject) {
return boxObject.forget();
}
}
int32_t namespaceID;
@@ -8758,17 +8744,16 @@ nsDocument::SetChangeScrollPosWhenScroll
void
nsIDocument::RegisterFreezableElement(nsIContent* aContent)
{
if (!mFreezableElements) {
mFreezableElements = new nsTHashtable<nsPtrHashKey<nsIContent> >();
if (!mFreezableElements)
return;
- mFreezableElements->Init();
}
mFreezableElements->PutEntry(aContent);
}
bool
nsIDocument::UnregisterFreezableElement(nsIContent* aContent)
{
if (!mFreezableElements)
--- a/content/base/src/nsFrameMessageManager.cpp
+++ b/content/base/src/nsFrameMessageManager.cpp
@@ -983,17 +983,16 @@ nsScriptCacheCleaner* nsFrameScriptExecu
void
nsFrameScriptExecutor::DidCreateGlobal()
{
NS_ASSERTION(mGlobal, "Should have mGlobal!");
if (!sCachedScripts) {
sCachedScripts =
new nsDataHashtable<nsStringHashKey, nsFrameJSScriptExecutorHolder*>;
- sCachedScripts->Init();
nsRefPtr<nsScriptCacheCleaner> scriptCacheCleaner =
new nsScriptCacheCleaner();
scriptCacheCleaner.forget(&sScriptCacheCleaner);
}
}
static PLDHashOperator
--- a/content/base/src/nsHostObjectProtocolHandler.cpp
+++ b/content/base/src/nsHostObjectProtocolHandler.cpp
@@ -29,17 +29,16 @@ nsHostObjectProtocolHandler::AddDataEntr
nsIPrincipal* aPrincipal,
nsACString& aUri)
{
nsresult rv = GenerateURIString(aScheme, aUri);
NS_ENSURE_SUCCESS(rv, rv);
if (!gDataTable) {
gDataTable = new nsClassHashtable<nsCStringHashKey, DataInfo>;
- gDataTable->Init();
}
DataInfo* info = new DataInfo;
info->mObject = aObject;
info->mPrincipal = aPrincipal;
gDataTable->Put(aUri, info);
--- a/content/base/src/nsNameSpaceManager.cpp
+++ b/content/base/src/nsNameSpaceManager.cpp
@@ -69,16 +69,20 @@ public:
};
private:
const nsAString* mKey;
};
class NameSpaceManagerImpl : public nsINameSpaceManager {
public:
+ NameSpaceManagerImpl()
+ : mURIToIDTable(32)
+ {
+ }
virtual ~NameSpaceManagerImpl()
{
}
NS_DECL_ISUPPORTS
nsresult Init();
@@ -97,18 +101,16 @@ private:
};
static NameSpaceManagerImpl* sNameSpaceManager = nullptr;
NS_IMPL_ISUPPORTS1(NameSpaceManagerImpl, nsINameSpaceManager)
nsresult NameSpaceManagerImpl::Init()
{
- mURIToIDTable.Init(32);
-
nsresult rv;
#define REGISTER_NAMESPACE(uri, id) \
rv = AddNameSpace(NS_LITERAL_STRING(uri), id); \
NS_ENSURE_SUCCESS(rv, rv)
// Need to be ordered according to ID.
REGISTER_NAMESPACE(kXMLNSNameSpaceURI, kNameSpaceID_XMLNS);
REGISTER_NAMESPACE(kXMLNameSpaceURI, kNameSpaceID_XML);
--- a/content/base/src/nsRange.cpp
+++ b/content/base/src/nsRange.cpp
@@ -359,17 +359,16 @@ nsRange::RegisterCommonAncestor(nsINode*
NS_ASSERTION(IsInSelection(), "registering range not in selection");
MarkDescendants(aNode);
RangeHashTable* ranges =
static_cast<RangeHashTable*>(aNode->GetProperty(nsGkAtoms::range));
if (!ranges) {
ranges = new RangeHashTable;
- ranges->Init();
aNode->SetProperty(nsGkAtoms::range, ranges, RangeHashTableDtor, true);
}
ranges->PutEntry(this);
aNode->SetCommonAncestorForRangeInSelection();
}
void
nsRange::UnregisterCommonAncestor(nsINode* aNode)
--- a/content/base/src/nsTreeSanitizer.cpp
+++ b/content/base/src/nsTreeSanitizer.cpp
@@ -1492,54 +1492,47 @@ nsTreeSanitizer::RemoveAllAttributes(nsI
}
}
void
nsTreeSanitizer::InitializeStatics()
{
NS_PRECONDITION(!sElementsHTML, "Initializing a second time.");
- sElementsHTML = new nsTHashtable<nsISupportsHashKey> ();
- sElementsHTML->Init(ArrayLength(kElementsHTML));
+ sElementsHTML = new nsTHashtable<nsISupportsHashKey>(ArrayLength(kElementsHTML));
for (uint32_t i = 0; kElementsHTML[i]; i++) {
sElementsHTML->PutEntry(*kElementsHTML[i]);
}
- sAttributesHTML = new nsTHashtable<nsISupportsHashKey> ();
- sAttributesHTML->Init(ArrayLength(kAttributesHTML));
+ sAttributesHTML = new nsTHashtable<nsISupportsHashKey>(ArrayLength(kAttributesHTML));
for (uint32_t i = 0; kAttributesHTML[i]; i++) {
sAttributesHTML->PutEntry(*kAttributesHTML[i]);
}
- sPresAttributesHTML = new nsTHashtable<nsISupportsHashKey> ();
- sPresAttributesHTML->Init(ArrayLength(kPresAttributesHTML));
+ sPresAttributesHTML = new nsTHashtable<nsISupportsHashKey>(ArrayLength(kPresAttributesHTML));
for (uint32_t i = 0; kPresAttributesHTML[i]; i++) {
sPresAttributesHTML->PutEntry(*kPresAttributesHTML[i]);
}
- sElementsSVG = new nsTHashtable<nsISupportsHashKey> ();
- sElementsSVG->Init(ArrayLength(kElementsSVG));
+ sElementsSVG = new nsTHashtable<nsISupportsHashKey>(ArrayLength(kElementsSVG));
for (uint32_t i = 0; kElementsSVG[i]; i++) {
sElementsSVG->PutEntry(*kElementsSVG[i]);
}
- sAttributesSVG = new nsTHashtable<nsISupportsHashKey> ();
- sAttributesSVG->Init(ArrayLength(kAttributesSVG));
+ sAttributesSVG = new nsTHashtable<nsISupportsHashKey>(ArrayLength(kAttributesSVG));
for (uint32_t i = 0; kAttributesSVG[i]; i++) {
sAttributesSVG->PutEntry(*kAttributesSVG[i]);
}
- sElementsMathML = new nsTHashtable<nsISupportsHashKey> ();
- sElementsMathML->Init(ArrayLength(kElementsMathML));
+ sElementsMathML = new nsTHashtable<nsISupportsHashKey>(ArrayLength(kElementsMathML));
for (uint32_t i = 0; kElementsMathML[i]; i++) {
sElementsMathML->PutEntry(*kElementsMathML[i]);
}
- sAttributesMathML = new nsTHashtable<nsISupportsHashKey> ();
- sAttributesMathML->Init(ArrayLength(kAttributesMathML));
+ sAttributesMathML = new nsTHashtable<nsISupportsHashKey>(ArrayLength(kAttributesMathML));
for (uint32_t i = 0; kAttributesMathML[i]; i++) {
sAttributesMathML->PutEntry(*kAttributesMathML[i]);
}
nsCOMPtr<nsIPrincipal> principal =
do_CreateInstance(NS_NULLPRINCIPAL_CONTRACTID);
principal.forget(&sNullPrincipal);
}
--- a/content/base/src/nsXMLHttpRequest.cpp
+++ b/content/base/src/nsXMLHttpRequest.cpp
@@ -296,18 +296,16 @@ nsXMLHttpRequest::nsXMLHttpRequest()
mIsSystem(false),
mIsAnon(false),
mFirstStartRequestSeen(false),
mInLoadProgressEvent(false),
mResultJSON(JSVAL_VOID),
mResultArrayBuffer(nullptr),
mXPCOMifier(nullptr)
{
- mAlreadySetHeaders.Init();
-
SetIsDOMBinding();
#ifdef DEBUG
StaticAssertions();
#endif
}
nsXMLHttpRequest::~nsXMLHttpRequest()
{
--- a/content/canvas/src/CanvasImageCache.cpp
+++ b/content/canvas/src/CanvasImageCache.cpp
@@ -92,17 +92,16 @@ public:
ImageCache()
: nsExpirationTracker<ImageCacheEntryData,4>(GENERATION_MS)
, mTotal(0)
{
if (!sPrefsInitialized) {
sPrefsInitialized = true;
Preferences::AddIntVarCache(&sCanvasImageCacheLimit, "canvas.image.cache.limit", 0);
}
- mCache.Init();
}
~ImageCache() {
AgeAllGenerations();
}
virtual void NotifyExpired(ImageCacheEntryData* aObject)
{
mTotal -= aObject->SizeInBytes();
--- a/content/canvas/src/WebGLContextValidate.cpp
+++ b/content/canvas/src/WebGLContextValidate.cpp
@@ -72,17 +72,16 @@ WebGLProgram::UpdateInfo()
mContext->GenerateWarning("program exceeds MAX_VERTEX_ATTRIBS");
return false;
}
}
}
if (!mUniformInfoMap) {
mUniformInfoMap = new CStringToUniformInfoMap;
- mUniformInfoMap->Init();
for (size_t i = 0; i < mAttachedShaders.Length(); i++) {
for (size_t j = 0; j < mAttachedShaders[i]->mUniforms.Length(); j++) {
const WebGLMappedIdentifier& uniform = mAttachedShaders[i]->mUniforms[j];
const WebGLUniformInfo& info = mAttachedShaders[i]->mUniformInfos[j];
mUniformInfoMap->Put(uniform.mapped, info);
}
}
}
--- a/content/canvas/src/WebGLProgram.cpp
+++ b/content/canvas/src/WebGLProgram.cpp
@@ -131,17 +131,16 @@ WebGLProgram::UpperBoundNumSamplerUnifor
return numSamplerUniforms;
}
void
WebGLProgram::MapIdentifier(const nsACString& name, nsCString *mappedName) {
if (!mIdentifierMap) {
// if the identifier map doesn't exist yet, build it now
mIdentifierMap = new CStringMap;
- mIdentifierMap->Init();
for (size_t i = 0; i < mAttachedShaders.Length(); i++) {
for (size_t j = 0; j < mAttachedShaders[i]->mAttributes.Length(); j++) {
const WebGLMappedIdentifier& attrib = mAttachedShaders[i]->mAttributes[j];
mIdentifierMap->Put(attrib.original, attrib.mapped);
}
for (size_t j = 0; j < mAttachedShaders[i]->mUniforms.Length(); j++) {
const WebGLMappedIdentifier& uniform = mAttachedShaders[i]->mUniforms[j];
mIdentifierMap->Put(uniform.original, uniform.mapped);
@@ -177,17 +176,16 @@ WebGLProgram::MapIdentifier(const nsACSt
mappedName->Assign(name);
}
void
WebGLProgram::ReverseMapIdentifier(const nsACString& name, nsCString *reverseMappedName) {
if (!mIdentifierReverseMap) {
// if the identifier reverse map doesn't exist yet, build it now
mIdentifierReverseMap = new CStringMap;
- mIdentifierReverseMap->Init();
for (size_t i = 0; i < mAttachedShaders.Length(); i++) {
for (size_t j = 0; j < mAttachedShaders[i]->mAttributes.Length(); j++) {
const WebGLMappedIdentifier& attrib = mAttachedShaders[i]->mAttributes[j];
mIdentifierReverseMap->Put(attrib.mapped, attrib.original);
}
for (size_t j = 0; j < mAttachedShaders[i]->mUniforms.Length(); j++) {
const WebGLMappedIdentifier& uniform = mAttachedShaders[i]->mUniforms[j];
mIdentifierReverseMap->Put(uniform.mapped, uniform.original);
--- a/content/events/src/nsDOMDataContainerEvent.cpp
+++ b/content/events/src/nsDOMDataContainerEvent.cpp
@@ -8,25 +8,23 @@
#include "nsIXPConnect.h"
nsDOMDataContainerEvent::nsDOMDataContainerEvent(
mozilla::dom::EventTarget* aOwner,
nsPresContext* aPresContext,
nsEvent* aEvent)
: nsDOMEvent(aOwner, aPresContext, aEvent)
{
- mData.Init();
}
NS_IMPL_CYCLE_COLLECTION_CLASS(nsDOMDataContainerEvent)
NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN_INHERITED(nsDOMDataContainerEvent,
nsDOMEvent)
- if (tmp->mData.IsInitialized())
- tmp->mData.Clear();
+ tmp->mData.Clear();
NS_IMPL_CYCLE_COLLECTION_UNLINK_END
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INHERITED(nsDOMDataContainerEvent,
nsDOMEvent)
tmp->mData.EnumerateRead(TraverseEntry, &cb);
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
NS_IMPL_ADDREF_INHERITED(nsDOMDataContainerEvent, nsDOMEvent)
@@ -36,30 +34,27 @@ NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION_
NS_INTERFACE_MAP_ENTRY(nsIDOMDataContainerEvent)
NS_INTERFACE_MAP_END_INHERITING(nsDOMEvent)
NS_IMETHODIMP
nsDOMDataContainerEvent::GetData(const nsAString& aKey, nsIVariant **aData)
{
NS_ENSURE_ARG_POINTER(aData);
- NS_ENSURE_STATE(mData.IsInitialized());
-
mData.Get(aKey, aData);
return NS_OK;
}
NS_IMETHODIMP
nsDOMDataContainerEvent::SetData(const nsAString& aKey, nsIVariant *aData)
{
NS_ENSURE_ARG(aData);
// Make sure this event isn't already being dispatched.
NS_ENSURE_STATE(!mEvent->mFlags.mIsBeingDispatched);
- NS_ENSURE_STATE(mData.IsInitialized());
mData.Put(aKey, aData);
return NS_OK;
}
void
nsDOMDataContainerEvent::SetData(JSContext* aCx, const nsAString& aKey,
JS::Handle<JS::Value> aVal,
mozilla::ErrorResult& aRv)
@@ -96,9 +91,8 @@ nsDOMDataContainerEvent::TraverseEntry(c
void* aUserArg)
{
nsCycleCollectionTraversalCallback *cb =
static_cast<nsCycleCollectionTraversalCallback*>(aUserArg);
cb->NoteXPCOMChild(aDataItem);
return PL_DHASH_NEXT;
}
-
--- a/content/html/content/src/HTMLFormElement.cpp
+++ b/content/html/content/src/HTMLFormElement.cpp
@@ -100,18 +100,16 @@ bool HTMLFormElement::gPasswordManagerIn
// nsFormControlList
class nsFormControlList : public nsIHTMLCollection,
public nsWrapperCache
{
public:
nsFormControlList(HTMLFormElement* aForm);
virtual ~nsFormControlList();
- nsresult Init();
-
void DropFormReference();
NS_DECL_CYCLE_COLLECTING_ISUPPORTS
// nsIDOMHTMLCollection interface
NS_DECL_NSIDOMHTMLCOLLECTION
virtual Element* GetElementAt(uint32_t index);
@@ -227,62 +225,52 @@ ShouldBeInElements(nsIFormControl* aForm
return false;
}
// HTMLFormElement implementation
HTMLFormElement::HTMLFormElement(already_AddRefed<nsINodeInfo> aNodeInfo)
: nsGenericHTMLElement(aNodeInfo),
+ mSelectedRadioButtons(4),
+ mRequiredRadioButtonCounts(4),
+ mValueMissingRadioGroups(4),
mGeneratingSubmit(false),
mGeneratingReset(false),
mIsSubmitting(false),
mDeferSubmission(false),
mNotifiedObservers(false),
mNotifiedObserversResult(false),
mSubmitPopupState(openAbused),
mSubmitInitiatedFromUserInput(false),
mPendingSubmission(nullptr),
mSubmittingRequest(nullptr),
mDefaultSubmitElement(nullptr),
mFirstSubmitInElements(nullptr),
mFirstSubmitNotInElements(nullptr),
+ mImageNameLookupTable(NS_FORM_CONTROL_LIST_HASHTABLE_SIZE),
+ mPastNameLookupTable(NS_FORM_CONTROL_LIST_HASHTABLE_SIZE),
mInvalidElementsCount(0),
mEverTriedInvalidSubmit(false)
{
- mImageNameLookupTable.Init(NS_FORM_CONTROL_LIST_HASHTABLE_SIZE);
- mPastNameLookupTable.Init(NS_FORM_CONTROL_LIST_HASHTABLE_SIZE);
}
HTMLFormElement::~HTMLFormElement()
{
if (mControls) {
mControls->DropFormReference();
}
Clear();
}
nsresult
HTMLFormElement::Init()
{
mControls = new nsFormControlList(this);
-
- nsresult rv = mControls->Init();
-
- if (NS_FAILED(rv))
- {
- mControls = nullptr;
- return rv;
- }
-
- mSelectedRadioButtons.Init(4);
- mRequiredRadioButtonCounts.Init(4);
- mValueMissingRadioGroups.Init(4);
-
return NS_OK;
}
// nsISupports
static PLDHashOperator
ElementTraverser(const nsAString& key, HTMLInputElement* element,
@@ -2346,33 +2334,28 @@ HTMLFormElement::Clear()
//----------------------------------------------------------------------
// nsFormControlList implementation, this could go away if there were
// a lightweight collection implementation somewhere
nsFormControlList::nsFormControlList(HTMLFormElement* aForm) :
mForm(aForm),
// Initialize the elements list to have an initial capacity
// of 8 to reduce allocations on small forms.
- mElements(8)
+ mElements(8),
+ mNameLookupTable(NS_FORM_CONTROL_LIST_HASHTABLE_SIZE)
{
SetIsDOMBinding();
}
nsFormControlList::~nsFormControlList()
{
mForm = nullptr;
Clear();
}
-nsresult nsFormControlList::Init()
-{
- mNameLookupTable.Init(NS_FORM_CONTROL_LIST_HASHTABLE_SIZE);
- return NS_OK;
-}
-
void
nsFormControlList::DropFormReference()
{
mForm = nullptr;
Clear();
}
void
--- a/content/html/content/src/HTMLMediaElement.cpp
+++ b/content/html/content/src/HTMLMediaElement.cpp
@@ -1840,17 +1840,16 @@ MediaElementTableCount(HTMLMediaElement*
void
HTMLMediaElement::AddMediaElementToURITable()
{
NS_ASSERTION(mDecoder && mDecoder->GetResource(), "Call this only with decoder Load called");
NS_ASSERTION(MediaElementTableCount(this, mLoadingSrc) == 0,
"Should not have entry for element in element table before addition");
if (!gElementTable) {
gElementTable = new MediaElementURITable();
- gElementTable->Init();
}
MediaElementSetForURI* entry = gElementTable->PutEntry(mLoadingSrc);
entry->mElements.AppendElement(this);
NS_ASSERTION(MediaElementTableCount(this, mLoadingSrc) == 1,
"Should have a single entry for element in element table after addition");
}
void
--- a/content/html/content/src/HTMLPropertiesCollection.cpp
+++ b/content/html/content/src/HTMLPropertiesCollection.cpp
@@ -45,17 +45,16 @@ HTMLPropertiesCollection::HTMLProperties
, mDoc(aRoot->GetCurrentDoc())
, mIsDirty(true)
{
SetIsDOMBinding();
mNames = new PropertyStringList(this);
if (mDoc) {
mDoc->AddMutationObserver(this);
}
- mNamedItemEntries.Init();
}
HTMLPropertiesCollection::~HTMLPropertiesCollection()
{
if (mDoc) {
mDoc->RemoveMutationObserver(this);
}
}
--- a/content/media/MediaCache.cpp
+++ b/content/media/MediaCache.cpp
@@ -845,17 +845,16 @@ MediaCache::SwapBlocks(int32_t aBlockInd
b->mStream->mBlocks[b->mStreamBlock] = blockIndices[i];
}
}
// Now update references to blocks in block lists.
mFreeBlocks.NotifyBlockSwapped(aBlockIndex1, aBlockIndex2);
nsTHashtable<nsPtrHashKey<MediaCacheStream> > visitedStreams;
- visitedStreams.Init();
for (int32_t i = 0; i < 2; ++i) {
for (uint32_t j = 0; j < blocks[i]->mOwners.Length(); ++j) {
MediaCacheStream* stream = blocks[i]->mOwners[j].mStream;
// Make sure that we don't update the same stream twice --- that
// would result in swapping the block references back again!
if (visitedStreams.GetEntry(stream))
continue;
--- a/content/media/MediaCache.h
+++ b/content/media/MediaCache.h
@@ -358,17 +358,17 @@ private:
* BlockList of its read-ahead blocks. Blocks are referred to by index
* into the MediaCache::mIndex array.
*
* Blocks can belong to more than one list at the same time, because
* the next/prev pointers are not stored in the block.
*/
class BlockList {
public:
- BlockList() : mFirstBlock(-1), mCount(0) { mEntries.Init(); }
+ BlockList() : mFirstBlock(-1), mCount(0) {}
~BlockList() {
NS_ASSERTION(mFirstBlock == -1 && mCount == 0,
"Destroying non-empty block list");
}
void AddFirstBlock(int32_t aBlock);
void AddAfter(int32_t aBlock, int32_t aBefore);
void RemoveBlock(int32_t aBlock);
// Returns the first block in the list, or -1 if empty
--- a/content/media/ogg/OggCodecState.cpp
+++ b/content/media/ogg/OggCodecState.cpp
@@ -659,17 +659,16 @@ VorbisState::IsHeader(ogg_packet* aPacke
MetadataTags*
VorbisState::GetTags()
{
MetadataTags* tags;
NS_ASSERTION(mComment.user_comments, "no vorbis comment strings!");
NS_ASSERTION(mComment.comment_lengths, "no vorbis comment lengths!");
tags = new MetadataTags;
- tags->Init();
for (int i = 0; i < mComment.comments; i++) {
AddVorbisComment(tags, mComment.user_comments[i],
mComment.comment_lengths[i]);
}
return tags;
}
nsresult
@@ -1061,17 +1060,16 @@ bool OpusState::DecodeHeader(ogg_packet*
}
/* Construct and return a tags hashmap from our internal array */
MetadataTags* OpusState::GetTags()
{
MetadataTags* tags;
tags = new MetadataTags;
- tags->Init();
for (uint32_t i = 0; i < mTags.Length(); i++) {
AddVorbisComment(tags, mTags[i].Data(), mTags[i].Length());
}
return tags;
}
/* Return the timestamp (in microseconds) equivalent to a granulepos. */
@@ -1538,17 +1536,16 @@ bool SkeletonState::DecodeHeader(ogg_pac
return false;
// Extract the segment length.
mLength = LEInt64(aPacket->packet + SKELETON_FILE_LENGTH_OFFSET);
LOG(PR_LOG_DEBUG, ("Skeleton segment length: %lld", mLength));
// Initialize the serialno-to-index map.
- mIndex.Init();
return true;
} else if (IsSkeletonIndex(aPacket) && mVersion >= SKELETON_VERSION(4,0)) {
return DecodeIndex(aPacket);
} else if (aPacket->e_o_s) {
mDoneReadingHeaders = true;
return true;
}
return true;
--- a/content/media/ogg/OggCodecState.h
+++ b/content/media/ogg/OggCodecState.h
@@ -442,17 +442,17 @@ public:
// Determines from the seek index the keyframe which you must seek back to
// in order to get all keyframes required to render all streams with
// serialnos in aTracks, at time aTarget.
nsresult IndexedSeekTarget(int64_t aTarget,
nsTArray<uint32_t>& aTracks,
nsSeekTarget& aResult);
bool HasIndex() const {
- return mIndex.IsInitialized() && mIndex.Count() > 0;
+ return mIndex.Count() > 0;
}
// Returns the duration of the active tracks in the media, if we have
// an index. aTracks must be filled with the serialnos of the active tracks.
// The duration is calculated as the greatest end time of all active tracks,
// minus the smalled start time of all the active tracks.
nsresult GetDuration(const nsTArray<uint32_t>& aTracks, int64_t& aDuration);
--- a/content/media/ogg/OggReader.cpp
+++ b/content/media/ogg/OggReader.cpp
@@ -1871,17 +1871,16 @@ nsresult OggReader::GetBuffered(TimeRang
return NS_OK;
#endif
}
OggCodecStore::OggCodecStore()
: mMonitor("CodecStore")
{
- mCodecStates.Init();
}
void OggCodecStore::Add(uint32_t serial, OggCodecState* codecState)
{
MonitorAutoLock mon(mMonitor);
mCodecStates.Put(serial, codecState);
}
--- a/content/media/wave/WaveReader.cpp
+++ b/content/media/wave/WaveReader.cpp
@@ -572,17 +572,16 @@ WaveReader::LoadListChunk(uint32_t aChun
{ 0x49434d54, NS_LITERAL_CSTRING("comments") }, // ICMT
{ 0x49474e52, NS_LITERAL_CSTRING("genre") }, // IGNR
{ 0x494e414d, NS_LITERAL_CSTRING("name") }, // INAM
};
const char* const end = chunk.get() + aChunkSize;
aTags = new HTMLMediaElement::MetadataTags;
- aTags->Init();
while (p + 8 < end) {
uint32_t id = ReadUint32BE(&p);
// Uppercase tag id, inspired by GStreamer's Wave parser.
id &= 0xDFDFDFDF;
uint32_t length = ReadUint32LE(&p);
--- a/content/media/webaudio/AudioContext.cpp
+++ b/content/media/webaudio/AudioContext.cpp
@@ -57,21 +57,16 @@ AudioContext::AudioContext(nsPIDOMWindow
aLength, aSampleRate))
, mNumberOfChannels(aNumberOfChannels)
, mIsOffline(aIsOffline)
{
// Actually play audio
mDestination->Stream()->AddAudioOutput(&gWebAudioOutputKey);
nsDOMEventTargetHelper::BindToOwner(aWindow);
SetIsDOMBinding();
-
- mPannerNodes.Init();
- mAudioBufferSourceNodes.Init();
- mOscillatorNodes.Init();
- mScriptProcessorNodes.Init();
}
AudioContext::~AudioContext()
{
}
JSObject*
AudioContext::WrapObject(JSContext* aCx, JS::Handle<JSObject*> aScope)
--- a/content/media/webaudio/blink/HRTFDatabaseLoader.cpp
+++ b/content/media/webaudio/blink/HRTFDatabaseLoader.cpp
@@ -40,17 +40,16 @@ nsTHashtable<HRTFDatabaseLoader::LoaderB
TemporaryRef<HRTFDatabaseLoader> HRTFDatabaseLoader::createAndLoadAsynchronouslyIfNecessary(float sampleRate)
{
MOZ_ASSERT(NS_IsMainThread());
RefPtr<HRTFDatabaseLoader> loader;
if (!s_loaderMap) {
s_loaderMap = new nsTHashtable<LoaderByRateEntry>();
- s_loaderMap->Init();
}
LoaderByRateEntry* entry = s_loaderMap->PutEntry(sampleRate);
loader = entry->mLoader;
if (loader) { // existing entry
MOZ_ASSERT(sampleRate == loader->databaseSampleRate());
return loader;
}
--- a/content/media/webrtc/MediaEngineWebRTC.h
+++ b/content/media/webrtc/MediaEngineWebRTC.h
@@ -350,29 +350,25 @@ public:
: mMutex("mozilla::MediaEngineWebRTC")
, mVideoEngine(nullptr)
, mVoiceEngine(nullptr)
, mVideoEngineInit(false)
, mAudioEngineInit(false)
, mCameraManager(aCameraManager)
, mWindowId(aWindowId)
{
- mVideoSources.Init();
- mAudioSources.Init();
}
#else
MediaEngineWebRTC()
: mMutex("mozilla::MediaEngineWebRTC")
, mVideoEngine(nullptr)
, mVoiceEngine(nullptr)
, mVideoEngineInit(false)
, mAudioEngineInit(false)
{
- mVideoSources.Init();
- mAudioSources.Init();
}
#endif
~MediaEngineWebRTC() { Shutdown(); }
// Clients should ensure to clean-up sources video/audio sources
// before invoking Shutdown on this class.
void Shutdown();
--- a/content/media/webspeech/synth/SpeechSynthesis.cpp
+++ b/content/media/webspeech/synth/SpeechSynthesis.cpp
@@ -72,22 +72,20 @@ NS_INTERFACE_MAP_END
NS_IMPL_CYCLE_COLLECTING_ADDREF(SpeechSynthesis)
NS_IMPL_CYCLE_COLLECTING_RELEASE(SpeechSynthesis)
SpeechSynthesis::SpeechSynthesis(nsPIDOMWindow* aParent)
: mParent(aParent)
{
SetIsDOMBinding();
- mVoiceCache.Init();
}
SpeechSynthesis::~SpeechSynthesis()
{
- mVoiceCache.Clear();
}
JSObject*
SpeechSynthesis::WrapObject(JSContext* aCx, JS::Handle<JSObject*> aScope)
{
return SpeechSynthesisBinding::Wrap(aCx, aScope, this);
}
--- a/content/media/webspeech/synth/nsSynthVoiceRegistry.cpp
+++ b/content/media/webspeech/synth/nsSynthVoiceRegistry.cpp
@@ -97,18 +97,16 @@ public:
static StaticRefPtr<nsSynthVoiceRegistry> gSynthVoiceRegistry;
NS_IMPL_ISUPPORTS1(nsSynthVoiceRegistry, nsISynthVoiceRegistry)
nsSynthVoiceRegistry::nsSynthVoiceRegistry()
: mSpeechSynthChild(nullptr)
{
- mUriVoiceMap.Init();
-
if (XRE_GetProcessType() == GeckoProcessType_Content) {
mSpeechSynthChild = new SpeechSynthesisChild();
ContentChild::GetSingleton()->SendPSpeechSynthesisConstructor(mSpeechSynthChild);
InfallibleTArray<RemoteVoice> voices;
InfallibleTArray<nsString> defaults;
--- a/content/smil/nsSMILAnimationController.cpp
+++ b/content/smil/nsSMILAnimationController.cpp
@@ -28,19 +28,16 @@ nsSMILAnimationController::nsSMILAnimati
: mAvgTimeBetweenSamples(0),
mResampleNeeded(false),
mDeferredStartSampling(false),
mRunningSample(false),
mDocument(aDoc)
{
NS_ABORT_IF_FALSE(aDoc, "need a non-null document");
- mAnimationElementTable.Init();
- mChildContainerTable.Init();
-
nsRefreshDriver* refreshDriver = GetRefreshDriver();
if (refreshDriver) {
mStartTime = refreshDriver->MostRecentRefresh();
} else {
mStartTime = mozilla::TimeStamp::Now();
}
mCurrentSampleTime = mStartTime;
@@ -376,18 +373,17 @@ nsSMILAnimationController::DoSample(bool
// (ii) Run milestone samples
RewindElements();
DoMilestoneSamples();
// STEP 2: Sample the child time containers
//
// When we sample the child time containers they will simply record the sample
// time in document time.
- TimeContainerHashtable activeContainers;
- activeContainers.Init(mChildContainerTable.Count());
+ TimeContainerHashtable activeContainers(mChildContainerTable.Count());
SampleTimeContainerParams tcParams = { &activeContainers,
aSkipUnchangedContainers };
mChildContainerTable.EnumerateEntries(SampleTimeContainer, &tcParams);
// STEP 3: (i) Sample the timed elements AND
// (ii) Create a table of compositors
//
// (i) Here we sample the timed elements (fetched from the
@@ -404,18 +400,17 @@ nsSMILAnimationController::DoSample(bool
// animated in sample 'n-1' but not in sample 'n' (and hence need to have
// their animation effects removed in sample 'n').
//
// Parts (i) and (ii) are not functionally related but we combine them here to
// save iterating over the animation elements twice.
// Create the compositor table
nsAutoPtr<nsSMILCompositorTable>
- currentCompositorTable(new nsSMILCompositorTable());
- currentCompositorTable->Init(0);
+ currentCompositorTable(new nsSMILCompositorTable(0));
SampleAnimationParams saParams = { &activeContainers,
currentCompositorTable };
mAnimationElementTable.EnumerateEntries(SampleAnimation,
&saParams);
activeContainers.Clear();
// STEP 4: Compare previous sample's compositors against this sample's.
--- a/content/smil/nsSMILTimedElement.cpp
+++ b/content/smil/nsSMILTimedElement.cpp
@@ -227,17 +227,16 @@ nsSMILTimedElement::nsSMILTimedElement()
mDeferIntervalUpdates(false),
mDoDeferredUpdate(false),
mDeleteCount(0),
mUpdateIntervalRecursionDepth(0)
{
mSimpleDur.SetIndefinite();
mMin.SetMillis(0L);
mMax.SetIndefinite();
- mTimeDependents.Init();
}
nsSMILTimedElement::~nsSMILTimedElement()
{
// Unlink all instance times from dependent intervals
for (uint32_t i = 0; i < mBeginInstances.Length(); ++i) {
mBeginInstances[i]->Unlink();
}
--- a/content/svg/content/src/nsSVGAttrTearoffTable.h
+++ b/content/svg/content/src/nsSVGAttrTearoffTable.h
@@ -17,80 +17,85 @@
*
* We don't keep an owning reference to the tear-off objects so they are
* responsible for removing themselves from this table when they die.
*/
template<class SimpleType, class TearoffType>
class nsSVGAttrTearoffTable
{
public:
+#ifdef DEBUG
~nsSVGAttrTearoffTable()
{
- NS_ABORT_IF_FALSE(mTable.Count() == 0,
- "Tear-off objects remain in hashtable at shutdown.");
+ NS_ABORT_IF_FALSE(!mTable, "Tear-off objects remain in hashtable at shutdown.");
}
+#endif
TearoffType* GetTearoff(SimpleType* aSimple);
void AddTearoff(SimpleType* aSimple, TearoffType* aTearoff);
void RemoveTearoff(SimpleType* aSimple);
private:
typedef nsPtrHashKey<SimpleType> SimpleTypePtrKey;
typedef nsDataHashtable<SimpleTypePtrKey, TearoffType* > TearoffTable;
- TearoffTable mTable;
+ TearoffTable* mTable;
};
template<class SimpleType, class TearoffType>
TearoffType*
nsSVGAttrTearoffTable<SimpleType, TearoffType>::GetTearoff(SimpleType* aSimple)
{
- if (!mTable.IsInitialized())
+ if (!mTable)
return nullptr;
TearoffType *tearoff = nullptr;
#ifdef DEBUG
bool found =
#endif
- mTable.Get(aSimple, &tearoff);
+ mTable->Get(aSimple, &tearoff);
NS_ABORT_IF_FALSE(!found || tearoff,
"NULL pointer stored in attribute tear-off map");
return tearoff;
}
template<class SimpleType, class TearoffType>
void
nsSVGAttrTearoffTable<SimpleType, TearoffType>::AddTearoff(SimpleType* aSimple,
TearoffType* aTearoff)
{
- if (!mTable.IsInitialized()) {
- mTable.Init();
+ if (!mTable) {
+ mTable = new TearoffTable;
}
// We shouldn't be adding a tear-off if there already is one. If that happens,
// something is wrong.
- if (mTable.Get(aSimple, nullptr)) {
+ if (mTable->Get(aSimple, nullptr)) {
NS_ABORT_IF_FALSE(false, "There is already a tear-off for this object.");
return;
}
- mTable.Put(aSimple, aTearoff);
+ mTable->Put(aSimple, aTearoff);
}
template<class SimpleType, class TearoffType>
void
nsSVGAttrTearoffTable<SimpleType, TearoffType>::RemoveTearoff(
SimpleType* aSimple)
{
- if (!mTable.IsInitialized()) {
+ if (!mTable) {
// Perhaps something happened in between creating the SimpleType object and
// registering it
return;
}
- mTable.Remove(aSimple);
+ mTable->Remove(aSimple);
+ if (mTable->Count() == 0) {
+ delete mTable;
+ mTable = nullptr;
+ }
}
#endif // NS_SVGATTRTEAROFFTABLE_H_
--- a/content/xbl/src/nsBindingManager.cpp
+++ b/content/xbl/src/nsBindingManager.cpp
@@ -185,24 +185,24 @@ SetOrRemoveObject(PLDHashTable& table, n
// Implement our nsISupports methods
NS_IMPL_CYCLE_COLLECTION_CLASS(nsBindingManager)
NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(nsBindingManager)
tmp->mDestroyed = true;
- if (tmp->mBoundContentSet.IsInitialized())
- tmp->mBoundContentSet.Clear();
+ if (tmp->mBoundContentSet)
+ tmp->mBoundContentSet->Clear();
- if (tmp->mDocumentTable.IsInitialized())
- tmp->mDocumentTable.Clear();
+ if (tmp->mDocumentTable)
+ tmp->mDocumentTable->Clear();
- if (tmp->mLoadingDocTable.IsInitialized())
- tmp->mLoadingDocTable.Clear();
+ if (tmp->mLoadingDocTable)
+ tmp->mLoadingDocTable->Clear();
if (tmp->mWrapperTable.ops)
PL_DHashTableFinish(&(tmp->mWrapperTable));
tmp->mWrapperTable.ops = nullptr;
NS_IMPL_CYCLE_COLLECTION_UNLINK(mAttachedStack)
if (tmp->mProcessAttachedQueueEvent) {
@@ -232,20 +232,20 @@ LoadingDocHashtableTraverser(nsIURI* key
static_cast<nsCycleCollectionTraversalCallback*>(userArg);
NS_CYCLE_COLLECTION_NOTE_EDGE_NAME(*cb, "mLoadingDocTable value");
cb->NoteXPCOMChild(sl);
return PL_DHASH_NEXT;
}
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN(nsBindingManager)
// The hashes keyed on nsIContent are traversed from the nsIContent itself.
- if (tmp->mDocumentTable.IsInitialized())
- tmp->mDocumentTable.EnumerateRead(&DocumentInfoHashtableTraverser, &cb);
- if (tmp->mLoadingDocTable.IsInitialized())
- tmp->mLoadingDocTable.EnumerateRead(&LoadingDocHashtableTraverser, &cb);
+ if (tmp->mDocumentTable)
+ tmp->mDocumentTable->EnumerateRead(&DocumentInfoHashtableTraverser, &cb);
+ if (tmp->mLoadingDocTable)
+ tmp->mLoadingDocTable->EnumerateRead(&LoadingDocHashtableTraverser, &cb);
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mAttachedStack)
// No need to traverse mProcessAttachedQueueEvent, since it'll just
// fire at some point or become revoke and drop its ref to us.
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(nsBindingManager)
NS_INTERFACE_MAP_ENTRY(nsIMutationObserver)
NS_INTERFACE_MAP_ENTRY(nsISupports)
@@ -277,28 +277,27 @@ nsBindingManager::GetBindingWithContent(
{
nsXBLBinding* binding = aContent ? aContent->GetXBLBinding() : nullptr;
return binding ? binding->GetBindingWithContent() : nullptr;
}
void
nsBindingManager::AddBoundContent(nsIContent* aContent)
{
- if (!mBoundContentSet.IsInitialized()) {
- mBoundContentSet.Init();
+ if (!mBoundContentSet) {
+ mBoundContentSet = new nsTHashtable<nsRefPtrHashKey<nsIContent> >;
}
-
- mBoundContentSet.PutEntry(aContent);
+ mBoundContentSet->PutEntry(aContent);
}
void
nsBindingManager::RemoveBoundContent(nsIContent* aContent)
{
- if (mBoundContentSet.IsInitialized()) {
- mBoundContentSet.RemoveEntry(aContent);
+ if (mBoundContentSet) {
+ mBoundContentSet->RemoveEntry(aContent);
}
// The death of the bindings means the death of the JS wrapper.
SetWrappedJS(aContent, nullptr);
}
nsIXPConnectWrappedJS*
nsBindingManager::GetWrappedJS(nsIContent* aContent)
@@ -551,84 +550,84 @@ AccumulateBindingsToDetach(nsRefPtrHashK
}
return PL_DHASH_NEXT;
}
void
nsBindingManager::ExecuteDetachedHandlers()
{
// Walk our hashtable of bindings.
- if (mBoundContentSet.IsInitialized()) {
+ if (mBoundContentSet) {
BindingTableReadClosure closure;
- mBoundContentSet.EnumerateEntries(AccumulateBindingsToDetach, &closure);
+ mBoundContentSet->EnumerateEntries(AccumulateBindingsToDetach, &closure);
uint32_t i, count = closure.mBindings.Length();
for (i = 0; i < count; ++i) {
closure.mBindings[i]->ExecuteDetachedHandler();
}
}
}
nsresult
nsBindingManager::PutXBLDocumentInfo(nsXBLDocumentInfo* aDocumentInfo)
{
NS_PRECONDITION(aDocumentInfo, "Must have a non-null documentinfo!");
- if (!mDocumentTable.IsInitialized())
- mDocumentTable.Init(16);
+ if (!mDocumentTable) {
+ mDocumentTable = new nsRefPtrHashtable<nsURIHashKey,nsXBLDocumentInfo>(16);
+ }
- mDocumentTable.Put(aDocumentInfo->DocumentURI(),
- aDocumentInfo);
+ mDocumentTable->Put(aDocumentInfo->DocumentURI(), aDocumentInfo);
return NS_OK;
}
void
nsBindingManager::RemoveXBLDocumentInfo(nsXBLDocumentInfo* aDocumentInfo)
{
- if (mDocumentTable.IsInitialized()) {
- mDocumentTable.Remove(aDocumentInfo->DocumentURI());
+ if (mDocumentTable) {
+ mDocumentTable->Remove(aDocumentInfo->DocumentURI());
}
}
nsXBLDocumentInfo*
nsBindingManager::GetXBLDocumentInfo(nsIURI* aURL)
{
- if (!mDocumentTable.IsInitialized())
+ if (!mDocumentTable)
return nullptr;
- return mDocumentTable.GetWeak(aURL);
+ return mDocumentTable->GetWeak(aURL);
}
nsresult
nsBindingManager::PutLoadingDocListener(nsIURI* aURL, nsIStreamListener* aListener)
{
NS_PRECONDITION(aListener, "Must have a non-null listener!");
- if (!mLoadingDocTable.IsInitialized())
- mLoadingDocTable.Init(16);
-
- mLoadingDocTable.Put(aURL, aListener);
+ if (!mLoadingDocTable) {
+ mLoadingDocTable = new nsInterfaceHashtable<nsURIHashKey,nsIStreamListener>(16);
+ }
+ mLoadingDocTable->Put(aURL, aListener);
return NS_OK;
}
nsIStreamListener*
nsBindingManager::GetLoadingDocListener(nsIURI* aURL)
{
- if (!mLoadingDocTable.IsInitialized())
+ if (!mLoadingDocTable)
return nullptr;
- return mLoadingDocTable.GetWeak(aURL);
+ return mLoadingDocTable->GetWeak(aURL);
}
void
nsBindingManager::RemoveLoadingDocListener(nsIURI* aURL)
{
- if (mLoadingDocTable.IsInitialized()) {
- mLoadingDocTable.Remove(aURL);
+ if (mLoadingDocTable) {
+ mLoadingDocTable->Remove(aURL);
}
}
static PLDHashOperator
MarkForDeath(nsRefPtrHashKey<nsIContent> *aKey, void* aClosure)
{
nsXBLBinding *binding = aKey->GetKey()->GetXBLBinding();
@@ -642,18 +641,18 @@ MarkForDeath(nsRefPtrHashKey<nsIContent>
binding->MarkForDeath();
return PL_DHASH_NEXT;
}
void
nsBindingManager::FlushSkinBindings()
{
- if (mBoundContentSet.IsInitialized()) {
- mBoundContentSet.EnumerateEntries(MarkForDeath, nullptr);
+ if (mBoundContentSet) {
+ mBoundContentSet->EnumerateEntries(MarkForDeath, nullptr);
}
}
// Used below to protect from recurring in QI calls through XPConnect.
struct AntiRecursionData {
nsIContent* element;
REFNSIID iid;
AntiRecursionData* next;
@@ -807,26 +806,26 @@ nsBindingManager::WalkRules(nsIStyleRule
}
typedef nsTHashtable<nsPtrHashKey<nsIStyleRuleProcessor> > RuleProcessorSet;
static PLDHashOperator
EnumRuleProcessors(nsRefPtrHashKey<nsIContent> *aKey, void* aClosure)
{
nsIContent *boundContent = aKey->GetKey();
- RuleProcessorSet *set = static_cast<RuleProcessorSet*>(aClosure);
+ nsAutoPtr<RuleProcessorSet> *set = static_cast<nsAutoPtr<RuleProcessorSet>*>(aClosure);
for (nsXBLBinding *binding = boundContent->GetXBLBinding(); binding;
binding = binding->GetBaseBinding()) {
nsIStyleRuleProcessor *ruleProc =
binding->PrototypeBinding()->GetRuleProcessor();
if (ruleProc) {
- if (!set->IsInitialized()) {
- set->Init(16);
+ if (!(*set)) {
+ *set = new RuleProcessorSet;
}
- set->PutEntry(ruleProc);
+ (*set)->PutEntry(ruleProc);
}
}
return PL_DHASH_NEXT;
}
struct WalkAllRulesData {
nsIStyleRuleProcessor::EnumFunc mFunc;
ElementDependentRuleProcessorData* mData;
@@ -843,27 +842,27 @@ EnumWalkAllRules(nsPtrHashKey<nsIStyleRu
return PL_DHASH_NEXT;
}
void
nsBindingManager::WalkAllRules(nsIStyleRuleProcessor::EnumFunc aFunc,
ElementDependentRuleProcessorData* aData)
{
- if (!mBoundContentSet.IsInitialized()) {
+ if (!mBoundContentSet) {
return;
}
- RuleProcessorSet set;
- mBoundContentSet.EnumerateEntries(EnumRuleProcessors, &set);
- if (!set.IsInitialized())
+ nsAutoPtr<RuleProcessorSet> set;
+ mBoundContentSet->EnumerateEntries(EnumRuleProcessors, &set);
+ if (!set)
return;
WalkAllRulesData data = { aFunc, aData };
- set.EnumerateEntries(EnumWalkAllRules, &data);
+ set->EnumerateEntries(EnumWalkAllRules, &data);
}
struct MediumFeaturesChangedData {
nsPresContext *mPresContext;
bool *mRulesChanged;
};
static PLDHashOperator
@@ -880,27 +879,28 @@ EnumMediumFeaturesChanged(nsPtrHashKey<n
return PL_DHASH_NEXT;
}
nsresult
nsBindingManager::MediumFeaturesChanged(nsPresContext* aPresContext,
bool* aRulesChanged)
{
*aRulesChanged = false;
- if (!mBoundContentSet.IsInitialized()) {
+ if (!mBoundContentSet) {
return NS_OK;
}
- RuleProcessorSet set;
- mBoundContentSet.EnumerateEntries(EnumRuleProcessors, &set);
- if (!set.IsInitialized())
+ nsAutoPtr<RuleProcessorSet> set;
+ mBoundContentSet->EnumerateEntries(EnumRuleProcessors, &set);
+ if (!set) {
return NS_OK;
+ }
MediumFeaturesChangedData data = { aPresContext, aRulesChanged };
- set.EnumerateEntries(EnumMediumFeaturesChanged, &data);
+ set->EnumerateEntries(EnumMediumFeaturesChanged, &data);
return NS_OK;
}
static PLDHashOperator
EnumAppendAllSheets(nsRefPtrHashKey<nsIContent> *aKey, void* aClosure)
{
nsIContent *boundContent = aKey->GetKey();
nsTArray<nsCSSStyleSheet*>* array =
@@ -916,18 +916,18 @@ EnumAppendAllSheets(nsRefPtrHashKey<nsIC
}
}
return PL_DHASH_NEXT;
}
void
nsBindingManager::AppendAllSheets(nsTArray<nsCSSStyleSheet*>& aArray)
{
- if (mBoundContentSet.IsInitialized()) {
- mBoundContentSet.EnumerateEntries(EnumAppendAllSheets, &aArray);
+ if (mBoundContentSet) {
+ mBoundContentSet->EnumerateEntries(EnumAppendAllSheets, &aArray);
}
}
static void
InsertAppendedContent(XBLChildrenElement* aPoint,
nsIContent* aFirstNewContent)
{
uint32_t insertionIndex;
@@ -1090,18 +1090,18 @@ nsBindingManager::DropDocumentReference(
mDestroyed = true;
// Make sure to not run any more XBL constructors
mProcessingAttachedStack = true;
if (mProcessAttachedQueueEvent) {
mProcessAttachedQueueEvent->Revoke();
}
- if (mBoundContentSet.IsInitialized()) {
- mBoundContentSet.Clear();
+ if (mBoundContentSet) {
+ mBoundContentSet->Clear();
}
mDocument = nullptr;
}
void
nsBindingManager::Traverse(nsIContent *aContent,
nsCycleCollectionTraversalCallback &cb)
@@ -1111,17 +1111,17 @@ nsBindingManager::Traverse(nsIContent *a
// Don't traverse if content is not in this binding manager.
// We also don't traverse non-elements because there should not
// be bindings (checking the flag alone is not sufficient because
// the flag is also set on children of insertion points that may be
// non-elements).
return;
}
- if (mBoundContentSet.IsInitialized() && mBoundContentSet.Contains(aContent)) {
+ if (mBoundContentSet && mBoundContentSet->Contains(aContent)) {
NS_CYCLE_COLLECTION_NOTE_EDGE_NAME(cb, "[via binding manager] mBoundContentSet entry");
cb.NoteXPCOMChild(aContent);
}
nsISupports *value;
if (mWrapperTable.ops &&
(value = LookupObject(mWrapperTable, aContent))) {
NS_CYCLE_COLLECTION_NOTE_EDGE_NAME(cb, "[via binding manager] mWrapperTable key");
--- a/content/xbl/src/nsBindingManager.h
+++ b/content/xbl/src/nsBindingManager.h
@@ -155,36 +155,36 @@ protected:
void DoProcessAttachedQueue();
// Post an event to process the attached queue.
void PostProcessAttachedQueueEvent();
// MEMBER VARIABLES
protected:
// A set of nsIContent that currently have a binding installed.
- nsTHashtable<nsRefPtrHashKey<nsIContent> > mBoundContentSet;
+ nsAutoPtr<nsTHashtable<nsRefPtrHashKey<nsIContent> > > mBoundContentSet;
// A mapping from nsIContent* to nsIXPWrappedJS* (an XPConnect
// wrapper for JS objects). For XBL bindings that implement XPIDL
// interfaces, and that get referred to from C++, this table caches
// the XPConnect wrapper for the binding. By caching it, I control
// its lifetime, and I prevent a re-wrap of the same script object
// (in the case where multiple bindings in an XBL inheritance chain
// both implement an XPIDL interface).
PLDHashTable mWrapperTable;
// A mapping from a URL (a string) to nsXBLDocumentInfo*. This table
// is the cache of all binding documents that have been loaded by a
// given bound document.
- nsRefPtrHashtable<nsURIHashKey,nsXBLDocumentInfo> mDocumentTable;
+ nsAutoPtr<nsRefPtrHashtable<nsURIHashKey,nsXBLDocumentInfo> > mDocumentTable;
// A mapping from a URL (a string) to a nsIStreamListener. This
// table is the currently loading binding docs. If they're in this
// table, they have not yet finished loading.
- nsInterfaceHashtable<nsURIHashKey,nsIStreamListener> mLoadingDocTable;
+ nsAutoPtr<nsInterfaceHashtable<nsURIHashKey,nsIStreamListener> > mLoadingDocTable;
// A queue of binding attached event handlers that are awaiting execution.
nsBindingList mAttachedStack;
bool mProcessingAttachedStack;
bool mDestroyed;
uint32_t mAttachedStackSizeOnOutermost;
// Our posted event to process the attached queue, if any
--- a/content/xbl/src/nsXBLPrototypeBinding.cpp
+++ b/content/xbl/src/nsXBLPrototypeBinding.cpp
@@ -99,17 +99,16 @@ nsXBLPrototypeBinding::nsXBLPrototypeBin
mCheckedBaseProto(false),
mKeyHandlersRegistered(false),
mChromeOnlyContent(false),
mResources(nullptr),
mAttributeTable(nullptr),
mBaseNameSpaceID(kNameSpaceID_None)
{
MOZ_COUNT_CTOR(nsXBLPrototypeBinding);
- mInterfaceTable.Init();
}
nsresult
nsXBLPrototypeBinding::Init(const nsACString& aID,
nsXBLDocumentInfo* aInfo,
nsIContent* aElement,
bool aFirstBinding)
{
--- a/content/xslt/src/xslt/txEXSLTFunctions.cpp
+++ b/content/xslt/src/xslt/txEXSLTFunctions.cpp
@@ -363,17 +363,16 @@ txEXSLTFunctionCall::evaluate(txIEvalCon
getter_AddRefs(nodes));
NS_ENSURE_SUCCESS(rv, rv);
nsRefPtr<txNodeSet> resultSet;
rv = aContext->recycler()->getNodeSet(getter_AddRefs(resultSet));
NS_ENSURE_SUCCESS(rv, rv);
nsTHashtable<nsStringHashKey> hash;
- hash.Init();
int32_t i, len = nodes->size();
for (i = 0; i < len; ++i) {
nsAutoString str;
const txXPathNode& node = nodes->get(i);
txXPathNodeUtils::appendNodeValue(node, str);
if (!hash.GetEntry(str)) {
hash.PutEntry(str);
--- a/content/xslt/src/xslt/txExecutionState.cpp
+++ b/content/xslt/src/xslt/txExecutionState.cpp
@@ -13,18 +13,16 @@
#include "txLog.h"
#include "txURIUtils.h"
#include "txXMLParser.h"
const int32_t txExecutionState::kMaxRecursionDepth = 20000;
nsresult txLoadedDocumentsHash::init(txXPathNode* aSourceDocument)
{
- Init(8);
-
mSourceDocument = aSourceDocument;
nsAutoString baseURI;
txXPathNodeUtils::getBaseURI(*mSourceDocument, baseURI);
txLoadedDocumentEntry* entry = PutEntry(baseURI);
if (!entry) {
return NS_ERROR_FAILURE;
@@ -32,20 +30,16 @@ nsresult txLoadedDocumentsHash::init(txX
entry->mDocument = mSourceDocument;
return NS_OK;
}
txLoadedDocumentsHash::~txLoadedDocumentsHash()
{
- if (!IsInitialized()) {
- return;
- }
-
nsAutoString baseURI;
txXPathNodeUtils::getBaseURI(*mSourceDocument, baseURI);
txLoadedDocumentEntry* entry = GetEntry(baseURI);
if (entry) {
delete entry->mDocument.forget();
}
}
--- a/content/xslt/src/xslt/txExecutionState.h
+++ b/content/xslt/src/xslt/txExecutionState.h
@@ -51,16 +51,20 @@ public:
nsAutoPtr<txXPathNode> mDocument;
nsresult mLoadResult;
};
class txLoadedDocumentsHash : public nsTHashtable<txLoadedDocumentEntry>
{
public:
+ txLoadedDocumentsHash()
+ : nsTHashtable<txLoadedDocumentEntry>(8)
+ {
+ }
~txLoadedDocumentsHash();
nsresult init(txXPathNode* aSourceDocument);
private:
friend class txExecutionState;
txXPathNode* mSourceDocument;
};
--- a/content/xslt/src/xslt/txKey.h
+++ b/content/xslt/src/xslt/txKey.h
@@ -174,17 +174,19 @@ private:
txExpandedName mName;
};
class txKeyHash
{
public:
txKeyHash(const txOwningExpandedNameMap<txXSLKey>& aKeys)
- : mKeys(aKeys)
+ : mKeyValues(8)
+ , mIndexedKeys(1)
+ , mKeys(aKeys)
{
}
nsresult init();
nsresult getKeyNodes(const txExpandedName& aKeyName,
const txXPathNode& aRoot,
const nsAString& aKeyValue,
--- a/content/xslt/src/xslt/txKeyFunctionCall.cpp
+++ b/content/xslt/src/xslt/txKeyFunctionCall.cpp
@@ -234,18 +234,16 @@ txKeyHash::getKeyNodes(const txExpandedN
}
return NS_OK;
}
nsresult
txKeyHash::init()
{
- mKeyValues.Init(8);
- mIndexedKeys.Init(1);
mEmptyNodeSet = new txNodeSet(nullptr);
return NS_OK;
}
/**
* Adds a match/use pair.
--- a/content/xul/document/src/XULDocument.cpp
+++ b/content/xul/document/src/XULDocument.cpp
@@ -327,20 +327,22 @@ NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_
tmp->mTemplateBuilderTable->EnumerateRead(TraverseTemplateBuilders, &cb);
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mCurrentPrototype)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mMasterPrototype)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mCommandDispatcher)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mPrototypes);
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mLocalStore)
- if (tmp->mOverlayLoadObservers.IsInitialized())
- tmp->mOverlayLoadObservers.EnumerateRead(TraverseObservers, &cb);
- if (tmp->mPendingOverlayLoadNotifications.IsInitialized())
- tmp->mPendingOverlayLoadNotifications.EnumerateRead(TraverseObservers, &cb);
+ if (tmp->mOverlayLoadObservers) {
+ tmp->mOverlayLoadObservers->EnumerateRead(TraverseObservers, &cb);
+ }
+ if (tmp->mPendingOverlayLoadNotifications) {
+ tmp->mPendingOverlayLoadNotifications->EnumerateRead(TraverseObservers, &cb);
+ }
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN_INHERITED(XULDocument, XMLDocument)
delete tmp->mTemplateBuilderTable;
tmp->mTemplateBuilderTable = nullptr;
NS_IMPL_CYCLE_COLLECTION_UNLINK(mCommandDispatcher)
//XXX We should probably unlink all the objects we traverse.
@@ -1889,17 +1891,16 @@ NS_IMETHODIMP
XULDocument::SetTemplateBuilderFor(nsIContent* aContent,
nsIXULTemplateBuilder* aBuilder)
{
if (! mTemplateBuilderTable) {
if (!aBuilder) {
return NS_OK;
}
mTemplateBuilderTable = new BuilderTable;
- mTemplateBuilderTable->Init();
}
if (aBuilder) {
mTemplateBuilderTable->Put(aContent, aBuilder);
}
else {
mTemplateBuilderTable->Remove(aContent);
}
@@ -1980,18 +1981,16 @@ XULDocument::Clone(nsINodeInfo *aNodeInf
//----------------------------------------------------------------------
//
// Implementation methods
//
nsresult
XULDocument::Init()
{
- mRefMap.Init();
-
nsresult rv = XMLDocument::Init();
NS_ENSURE_SUCCESS(rv, rv);
// Create our command dispatcher and hook it up.
mCommandDispatcher = new nsXULCommandDispatcher(this);
NS_ENSURE_TRUE(mCommandDispatcher, NS_ERROR_OUT_OF_MEMORY);
// this _could_ fail; e.g., if we've tried to grab the local store
@@ -2668,32 +2667,32 @@ XULDocument::LoadOverlay(const nsAString
nsresult rv;
nsCOMPtr<nsIURI> uri;
rv = NS_NewURI(getter_AddRefs(uri), aURL, nullptr);
if (NS_FAILED(rv)) return rv;
if (aObserver) {
nsIObserver* obs = nullptr;
- if (!mOverlayLoadObservers.IsInitialized()) {
- mOverlayLoadObservers.Init();
+ if (!mOverlayLoadObservers) {
+ mOverlayLoadObservers = new nsInterfaceHashtable<nsURIHashKey,nsIObserver>;
}
- obs = mOverlayLoadObservers.GetWeak(uri);
+ obs = mOverlayLoadObservers->GetWeak(uri);
if (obs) {
// We don't support loading the same overlay twice into the same
// document - that doesn't make sense anyway.
return NS_ERROR_FAILURE;
}
- mOverlayLoadObservers.Put(uri, aObserver);
+ mOverlayLoadObservers->Put(uri, aObserver);
}
bool shouldReturn, failureFromContent;
rv = LoadOverlayInternal(uri, true, &shouldReturn, &failureFromContent);
- if (NS_FAILED(rv) && mOverlayLoadObservers.IsInitialized())
- mOverlayLoadObservers.Remove(uri); // remove the observer if LoadOverlayInternal generated an error
+ if (NS_FAILED(rv) && mOverlayLoadObservers)
+ mOverlayLoadObservers->Remove(uri); // remove the observer if LoadOverlayInternal generated an error
return rv;
}
nsresult
XULDocument::LoadOverlayInternal(nsIURI* aURI, bool aIsDynamic,
bool* aShouldReturn,
bool* aFailureFromContent)
{
@@ -2874,17 +2873,19 @@ XULDocument::LoadOverlayInternal(nsIURI*
static PLDHashOperator
FirePendingMergeNotification(nsIURI* aKey, nsCOMPtr<nsIObserver>& aObserver, void* aClosure)
{
aObserver->Observe(aKey, "xul-overlay-merged", EmptyString().get());
typedef nsInterfaceHashtable<nsURIHashKey,nsIObserver> table;
table* observers = static_cast<table*>(aClosure);
- observers->Remove(aKey);
+ if (observers) {
+ observers->Remove(aKey);
+ }
return PL_DHASH_REMOVE;
}
nsresult
XULDocument::ResumeWalk()
{
// Walk the prototype and build the delegate content model. The
@@ -3120,26 +3121,26 @@ XULDocument::ResumeWalk()
&failureFromContent);
if (failureFromContent)
// The failure |rv| was the result of a problem in the content
// rather than an unexpected problem in our implementation, so
// just continue with the next overlay.
continue;
if (NS_FAILED(rv))
return rv;
- if (mOverlayLoadObservers.IsInitialized()) {
- nsIObserver *obs = mOverlayLoadObservers.GetWeak(overlayURI);
+ if (mOverlayLoadObservers) {
+ nsIObserver *obs = mOverlayLoadObservers->GetWeak(overlayURI);
if (obs) {
// This overlay has an unloaded overlay, so it will never
// notify. The best we can do is to notify for the unloaded
// overlay instead, assuming nobody is already notifiable
// for it. Note that this will confuse the observer.
- if (!mOverlayLoadObservers.GetWeak(uri))
- mOverlayLoadObservers.Put(uri, obs);
- mOverlayLoadObservers.Remove(overlayURI);
+ if (!mOverlayLoadObservers->GetWeak(uri))
+ mOverlayLoadObservers->Put(uri, obs);
+ mOverlayLoadObservers->Remove(overlayURI);
}
}
if (shouldReturn)
return NS_OK;
overlayURI.swap(uri);
}
// If we get here, there is nothing left for us to walk. The content
@@ -3221,29 +3222,30 @@ XULDocument::DoneWalking()
// DispatchContentLoadedEvents undoes the onload-blocking we
// did in PrepareToWalk().
DispatchContentLoadedEvents();
mInitialLayoutComplete = true;
// Walk the set of pending load notifications and notify any observers.
// See below for detail.
- if (mPendingOverlayLoadNotifications.IsInitialized())
- mPendingOverlayLoadNotifications.Enumerate(FirePendingMergeNotification, (void*)&mOverlayLoadObservers);
+ if (mPendingOverlayLoadNotifications)
+ mPendingOverlayLoadNotifications->Enumerate(
+ FirePendingMergeNotification, mOverlayLoadObservers.get());
}
else {
- if (mOverlayLoadObservers.IsInitialized()) {
+ if (mOverlayLoadObservers) {
nsCOMPtr<nsIURI> overlayURI = mCurrentPrototype->GetURI();
nsCOMPtr<nsIObserver> obs;
if (mInitialLayoutComplete) {
// We have completed initial layout, so just send the notification.
- mOverlayLoadObservers.Get(overlayURI, getter_AddRefs(obs));
+ mOverlayLoadObservers->Get(overlayURI, getter_AddRefs(obs));
if (obs)
obs->Observe(overlayURI, "xul-overlay-merged", EmptyString().get());
- mOverlayLoadObservers.Remove(overlayURI);
+ mOverlayLoadObservers->Remove(overlayURI);
}
else {
// If we have not yet displayed the document for the first time
// (i.e. we came in here as the result of a dynamic overlay load
// which was spawned by a binding-attached event caused by
// StartLayout() on the master prototype - we must remember that
// this overlay has been merged and tell the listeners after
// StartLayout() is completely finished rather than doing so
@@ -3253,25 +3255,26 @@ XULDocument::DoneWalking()
// yet been attached. This can be a race condition because dynamic
// overlay loading can take varying amounts of time depending on
// whether or not the overlay prototype is in the XUL cache. The
// most likely effect of this bug is odd UI initialization due to
// methods and properties that do not work.
// XXXbz really, we shouldn't be firing binding constructors
// until after StartLayout returns!
- if (!mPendingOverlayLoadNotifications.IsInitialized()) {
- mPendingOverlayLoadNotifications.Init();
+ if (!mPendingOverlayLoadNotifications) {
+ mPendingOverlayLoadNotifications =
+ new nsInterfaceHashtable<nsURIHashKey,nsIObserver>;
}
- mPendingOverlayLoadNotifications.Get(overlayURI, getter_AddRefs(obs));
+ mPendingOverlayLoadNotifications->Get(overlayURI, getter_AddRefs(obs));
if (!obs) {
- mOverlayLoadObservers.Get(overlayURI, getter_AddRefs(obs));
+ mOverlayLoadObservers->Get(overlayURI, getter_AddRefs(obs));
NS_ASSERTION(obs, "null overlay load observer?");
- mPendingOverlayLoadNotifications.Put(overlayURI, obs);
+ mPendingOverlayLoadNotifications->Put(overlayURI, obs);
}
}
}
}
return NS_OK;
}
--- a/content/xul/document/src/XULDocument.h
+++ b/content/xul/document/src/XULDocument.h
@@ -714,19 +714,19 @@ protected:
friend class ParserObserver;
/**
* A map from a broadcaster element to a list of listener elements.
*/
PLDHashTable* mBroadcasterMap;
- nsInterfaceHashtable<nsURIHashKey,nsIObserver> mOverlayLoadObservers;
- nsInterfaceHashtable<nsURIHashKey,nsIObserver> mPendingOverlayLoadNotifications;
-
+ nsAutoPtr<nsInterfaceHashtable<nsURIHashKey,nsIObserver> > mOverlayLoadObservers;
+ nsAutoPtr<nsInterfaceHashtable<nsURIHashKey,nsIObserver> > mPendingOverlayLoadNotifications;
+
bool mInitialLayoutComplete;
class nsDelayedBroadcastUpdate
{
public:
nsDelayedBroadcastUpdate(Element* aBroadcaster,
Element* aListener,
const nsAString &aAttr)
--- a/content/xul/document/src/nsXULPrototypeCache.cpp
+++ b/content/xul/document/src/nsXULPrototypeCache.cpp
@@ -85,25 +85,16 @@ nsXULPrototypeCache::~nsXULPrototypeCach
NS_IMPL_ISUPPORTS1(nsXULPrototypeCache, nsIObserver)
/* static */ nsXULPrototypeCache*
nsXULPrototypeCache::GetInstance()
{
if (!sInstance) {
NS_ADDREF(sInstance = new nsXULPrototypeCache());
- sInstance->mPrototypeTable.Init();
- sInstance->mStyleSheetTable.Init();
- sInstance->mScriptTable.Init();
- sInstance->mXBLDocTable.Init();
-
- sInstance->mCacheURITable.Init();
- sInstance->mInputStreamTable.Init();
- sInstance->mOutputStreamTable.Init();
-
UpdategDisableXULCache();
Preferences::RegisterCallback(DisableXULCacheChangedCallback,
kDisableXULCachePref);
nsCOMPtr<nsIObserverService> obsSvc =
mozilla::services::GetObserverService();
if (obsSvc) {
--- a/content/xul/templates/src/nsXULTemplateBuilder.cpp
+++ b/content/xul/templates/src/nsXULTemplateBuilder.cpp
@@ -166,19 +166,16 @@ nsXULTemplateBuilder::InitGlobals()
return rv;
}
#ifdef PR_LOGGING
if (! gXULTemplateLog)
gXULTemplateLog = PR_NewLogModule("nsXULTemplateBuilder");
#endif
- if (!mMatchMap.IsInitialized())
- mMatchMap.Init();
-
return NS_OK;
}
void
nsXULTemplateBuilder::CleanUp(bool aIsFinal)
{
for (int32_t q = mQuerySets.Length() - 1; q >= 0; q--) {
nsTemplateQuerySet* qs = mQuerySets[q];
@@ -239,19 +236,17 @@ NS_IMPL_CYCLE_COLLECTION_CLASS(nsXULTemp
NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(nsXULTemplateBuilder)
NS_IMPL_CYCLE_COLLECTION_UNLINK(mDataSource)
NS_IMPL_CYCLE_COLLECTION_UNLINK(mDB)
NS_IMPL_CYCLE_COLLECTION_UNLINK(mCompDB)
NS_IMPL_CYCLE_COLLECTION_UNLINK(mRoot)
NS_IMPL_CYCLE_COLLECTION_UNLINK(mRootResult)
NS_IMPL_CYCLE_COLLECTION_UNLINK(mListeners)
NS_IMPL_CYCLE_COLLECTION_UNLINK(mQueryProcessor)
- if (tmp->mMatchMap.IsInitialized()) {
- tmp->mMatchMap.Enumerate(DestroyMatchList, nullptr);
- }
+ tmp->mMatchMap.Enumerate(DestroyMatchList, nullptr);
for (uint32_t i = 0; i < tmp->mQuerySets.Length(); ++i) {
nsTemplateQuerySet* qs = tmp->mQuerySets[i];
delete qs;
}
tmp->mQuerySets.Clear();
NS_IMPL_CYCLE_COLLECTION_UNLINK_END
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN(nsXULTemplateBuilder)
if (tmp->mObservedDocument && !cb.WantAllTraces()) {
@@ -261,18 +256,17 @@ NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN(
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mDataSource)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mDB)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mCompDB)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mRoot)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mRootResult)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mListeners)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mQueryProcessor)
- if (tmp->mMatchMap.IsInitialized())
- tmp->mMatchMap.EnumerateRead(TraverseMatchList, &cb);
+ tmp->mMatchMap.EnumerateRead(TraverseMatchList, &cb);
{
uint32_t i, count = tmp->mQuerySets.Length();
for (i = 0; i < count; ++i) {
nsTemplateQuerySet *set = tmp->mQuerySets[i];
cb.NoteXPCOMChild(set->mQueryNode);
cb.NoteXPCOMChild(set->mCompiledQuery);
uint16_t j, rulesCount = set->RuleCount();
for (j = 0; j < rulesCount; ++j) {
--- a/content/xul/templates/src/nsXULTemplateQueryProcessorRDF.cpp
+++ b/content/xul/templates/src/nsXULTemplateQueryProcessorRDF.cpp
@@ -94,27 +94,21 @@ RuleToBindingTraverser(nsISupports* key,
cb->NoteXPCOMChild(key);
return PL_DHASH_NEXT;
}
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN(nsXULTemplateQueryProcessorRDF)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mDB)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mLastRef)
- if (tmp->mBindingDependencies.IsInitialized()) {
- tmp->mBindingDependencies.EnumerateRead(BindingDependenciesTraverser,
- &cb);
- }
- if (tmp->mMemoryElementToResultMap.IsInitialized()) {
- tmp->mMemoryElementToResultMap.EnumerateRead(MemoryElementTraverser,
- &cb);
- }
- if (tmp->mRuleToBindingsMap.IsInitialized()) {
- tmp->mRuleToBindingsMap.EnumerateRead(RuleToBindingTraverser, &cb);
- }
+ tmp->mBindingDependencies.EnumerateRead(BindingDependenciesTraverser,
+ &cb);
+ tmp->mMemoryElementToResultMap.EnumerateRead(MemoryElementTraverser,
+ &cb);
+ tmp->mRuleToBindingsMap.EnumerateRead(RuleToBindingTraverser, &cb);
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mQueries)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
NS_IMPL_CYCLE_COLLECTING_ADDREF(nsXULTemplateQueryProcessorRDF)
NS_IMPL_CYCLE_COLLECTING_RELEASE(nsXULTemplateQueryProcessorRDF)
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(nsXULTemplateQueryProcessorRDF)
NS_INTERFACE_MAP_ENTRY(nsIXULTemplateQueryProcessor)
NS_INTERFACE_MAP_ENTRY(nsIRDFObserver)
@@ -300,23 +294,16 @@ nsXULTemplateQueryProcessorRDF::Initiali
nsIXULTemplateBuilder* aBuilder,
nsIDOMNode* aRootNode)
{
if (!mQueryProcessorRDFInited) {
nsresult rv = InitGlobals();
if (NS_FAILED(rv))
return rv;
- if (!mMemoryElementToResultMap.IsInitialized())
- mMemoryElementToResultMap.Init();
- if (!mBindingDependencies.IsInitialized())
- mBindingDependencies.Init();
- if (!mRuleToBindingsMap.IsInitialized())
- mRuleToBindingsMap.Init();
-
mQueryProcessorRDFInited = true;
}
// don't do anything if generation has already been done
if (mGenerationStarted)
return NS_ERROR_UNEXPECTED;
mDB = do_QueryInterface(aDatasource);
--- a/content/xul/templates/src/nsXULTemplateQueryProcessorXML.cpp
+++ b/content/xul/templates/src/nsXULTemplateQueryProcessorXML.cpp
@@ -84,28 +84,24 @@ TraverseRuleToBindingsMap(nsISupports* a
NS_CYCLE_COLLECTION_NOTE_EDGE_NAME(*cb, "mRuleToBindingsMap value");
cb->NoteNativeChild(aMatch, NS_CYCLE_COLLECTION_PARTICIPANT(nsXMLBindingSet));
return PL_DHASH_NEXT;
}
NS_IMPL_CYCLE_COLLECTION_CLASS(nsXULTemplateQueryProcessorXML)
NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(nsXULTemplateQueryProcessorXML)
- if (tmp->mRuleToBindingsMap.IsInitialized()) {
- tmp->mRuleToBindingsMap.Clear();
- }
+ tmp->mRuleToBindingsMap.Clear();
NS_IMPL_CYCLE_COLLECTION_UNLINK(mRoot)
NS_IMPL_CYCLE_COLLECTION_UNLINK(mEvaluator)
NS_IMPL_CYCLE_COLLECTION_UNLINK(mTemplateBuilder)
NS_IMPL_CYCLE_COLLECTION_UNLINK(mRequest)
NS_IMPL_CYCLE_COLLECTION_UNLINK_END
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN(nsXULTemplateQueryProcessorXML)
- if (tmp->mRuleToBindingsMap.IsInitialized()) {
- tmp->mRuleToBindingsMap.EnumerateRead(TraverseRuleToBindingsMap, &cb);
- }
+ tmp->mRuleToBindingsMap.EnumerateRead(TraverseRuleToBindingsMap, &cb);
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mRoot)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mEvaluator)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mTemplateBuilder)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mRequest)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
NS_IMPL_CYCLE_COLLECTING_ADDREF(nsXULTemplateQueryProcessorXML)
NS_IMPL_CYCLE_COLLECTING_RELEASE(nsXULTemplateQueryProcessorXML)
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(nsXULTemplateQueryProcessorXML)
@@ -218,29 +214,25 @@ nsXULTemplateQueryProcessorXML::Initiali
doc->GetDocumentElement(getter_AddRefs(mRoot));
else
mRoot = do_QueryInterface(aDatasource);
NS_ENSURE_STATE(mRoot);
mEvaluator = do_CreateInstance("@mozilla.org/dom/xpath-evaluator;1");
NS_ENSURE_TRUE(mEvaluator, NS_ERROR_OUT_OF_MEMORY);
- if (!mRuleToBindingsMap.IsInitialized())
- mRuleToBindingsMap.Init();
-
return NS_OK;
}
NS_IMETHODIMP
nsXULTemplateQueryProcessorXML::Done()
{
mGenerationStarted = false;
- if (mRuleToBindingsMap.IsInitialized())
- mRuleToBindingsMap.Clear();
+ mRuleToBindingsMap.Clear();
return NS_OK;
}
NS_IMETHODIMP
nsXULTemplateQueryProcessorXML::CompileQuery(nsIXULTemplateBuilder* aBuilder,
nsIDOMNode* aQueryNode,
nsIAtom* aRefVariable,
--- a/dom/audiochannel/AudioChannelService.cpp
+++ b/dom/audiochannel/AudioChannelService.cpp
@@ -69,19 +69,16 @@ AudioChannelService::Shutdown()
NS_IMPL_ISUPPORTS2(AudioChannelService, nsIObserver, nsITimerCallback)
AudioChannelService::AudioChannelService()
: mCurrentHigherChannel(AUDIO_CHANNEL_LAST)
, mCurrentVisibleHigherChannel(AUDIO_CHANNEL_LAST)
, mActiveContentChildIDsFrozen(false)
{
- // Creation of the hash table.
- mAgents.Init();
-
if (XRE_GetProcessType() == GeckoProcessType_Default) {
nsCOMPtr<nsIObserverService> obs = mozilla::services::GetObserverService();
if (obs) {
obs->AddObserver(this, "ipc:content-shutdown", false);
#ifdef MOZ_WIDGET_GONK
// To monitor the volume settings based on audio channel.
obs->AddObserver(this, "mozsettings-changed", false);
#endif
@@ -308,17 +305,16 @@ AudioChannelService::ProcessContentOrNor
void
AudioChannelService::SendAudioChannelChangedNotification(uint64_t aChildID)
{
if (XRE_GetProcessType() != GeckoProcessType_Default) {
return;
}
nsRefPtr<nsHashPropertyBag> props = new nsHashPropertyBag();
- props->Init();
props->SetPropertyAsUint64(NS_LITERAL_STRING("childID"), aChildID);
nsCOMPtr<nsIObserverService> obs = mozilla::services::GetObserverService();
obs->NotifyObservers(static_cast<nsIWritablePropertyBag*>(props),
"audio-channel-process-changed", nullptr);
// Calculating the most important active channel.
AudioChannelType higher = AUDIO_CHANNEL_LAST;
--- a/dom/base/nsGlobalWindow.cpp
+++ b/dom/base/nsGlobalWindow.cpp
@@ -1028,20 +1028,16 @@ nsGlobalWindow::nsGlobalWindow(nsGlobalW
#endif
mCleanedUp(false),
mDialogAbuseCount(0),
mStopAbuseDialogs(false),
mDialogsPermanentlyDisabled(false)
{
nsLayoutStatics::AddRef();
-#ifdef MOZ_GAMEPAD
- mGamepads.Init();
-#endif
-
// Initialize the PRCList (this).
PR_INIT_CLIST(this);
if (aOuterWindow) {
// |this| is an inner window, add this inner window to the outer
// window list of inners.
PR_INSERT_AFTER(this, aOuterWindow);
@@ -1119,35 +1115,32 @@ nsGlobalWindow::nsGlobalWindow(nsGlobalW
NS_ASSERTION(sWindowsById, "Windows hash table must be created!");
NS_ASSERTION(!sWindowsById->Get(mWindowID),
"This window shouldn't be in the hash table yet!");
// We seem to see crashes in release builds because of null |sWindowsById|.
if (sWindowsById) {
sWindowsById->Put(mWindowID, this);
}
-
- mEventTargetObjects.Init();
}
/* static */
void
nsGlobalWindow::Init()
{
CallGetService(NS_ENTROPYCOLLECTOR_CONTRACTID, &gEntropyCollector);
NS_ASSERTION(gEntropyCollector,
"gEntropyCollector should have been initialized!");
#ifdef PR_LOGGING
gDOMLeakPRLog = PR_NewLogModule("DOMLeak");
NS_ASSERTION(gDOMLeakPRLog, "gDOMLeakPRLog should have been initialized!");
#endif
sWindowsById = new WindowByIdTable();
- sWindowsById->Init();
}
static PLDHashOperator
DisconnectEventTargetObjects(nsPtrHashKey<nsDOMEventTargetHelper>* aKey,
void* aClosure)
{
nsRefPtr<nsDOMEventTargetHelper> target = aKey->GetKey();
target->DisconnectFromOwner();
@@ -1278,19 +1271,19 @@ nsGlobalWindow::ShutDown()
delete sWindowsById;
sWindowsById = nullptr;
}
// static
void
nsGlobalWindow::CleanupCachedXBLHandlers(nsGlobalWindow* aWindow)
{
- if (aWindow->mCachedXBLPrototypeHandlers.IsInitialized() &&
- aWindow->mCachedXBLPrototypeHandlers.Count() > 0) {
- aWindow->mCachedXBLPrototypeHandlers.Clear();
+ if (aWindow->mCachedXBLPrototypeHandlers &&
+ aWindow->mCachedXBLPrototypeHandlers->Count() > 0) {
+ aWindow->mCachedXBLPrototypeHandlers->Clear();
mozilla::DropJSObjects(aWindow);
}
}
void
nsGlobalWindow::MaybeForgiveSpamCount()
{
if (IsOuterWindow() &&
@@ -1567,18 +1560,18 @@ static PLDHashOperator
MarkXBLHandlers(nsXBLPrototypeHandler* aKey, JS::Heap<JSObject*>& aData, void* aClosure)
{
xpc_UnmarkGrayObject(aData);
return PL_DHASH_NEXT;
}
NS_IMPL_CYCLE_COLLECTION_CAN_SKIP_BEGIN(nsGlobalWindow)
if (tmp->IsBlackForCC()) {
- if (tmp->mCachedXBLPrototypeHandlers.IsInitialized()) {
- tmp->mCachedXBLPrototypeHandlers.Enumerate(MarkXBLHandlers, nullptr);
+ if (tmp->mCachedXBLPrototypeHandlers) {
+ tmp->mCachedXBLPrototypeHandlers->Enumerate(MarkXBLHandlers, nullptr);
}
nsEventListenerManager* elm = tmp->GetListenerManager(false);
if (elm) {
elm->MarkForCC();
}
tmp->UnmarkGrayTimers();
return true;
}
@@ -1734,19 +1727,19 @@ static PLDHashOperator
TraceXBLHandlers(nsXBLPrototypeHandler* aKey, JS::Heap<JSObject*>& aData, void* aClosure)
{
TraceData* data = static_cast<TraceData*>(aClosure);
data->callbacks.Trace(&aData, "Cached XBL prototype handler", data->closure);
return PL_DHASH_NEXT;
}
NS_IMPL_CYCLE_COLLECTION_TRACE_BEGIN(nsGlobalWindow)
- if (tmp->mCachedXBLPrototypeHandlers.IsInitialized()) {
+ if (tmp->mCachedXBLPrototypeHandlers) {
TraceData data = { aCallbacks, aClosure };
- tmp->mCachedXBLPrototypeHandlers.Enumerate(TraceXBLHandlers, &data);
+ tmp->mCachedXBLPrototypeHandlers->Enumerate(TraceXBLHandlers, &data);
}
NS_IMPL_CYCLE_COLLECTION_TRACE_END
bool
nsGlobalWindow::IsBlackForCC()
{
return
(mDoc &&
@@ -7606,35 +7599,35 @@ nsGlobalWindow::NotifyDOMWindowThawed(ns
}
}
JSObject*
nsGlobalWindow::GetCachedXBLPrototypeHandler(nsXBLPrototypeHandler* aKey)
{
AutoSafeJSContext cx;
JS::Rooted<JSObject*> handler(cx);
- if (mCachedXBLPrototypeHandlers.IsInitialized()) {
- mCachedXBLPrototypeHandlers.Get(aKey, handler.address());
+ if (mCachedXBLPrototypeHandlers) {
+ mCachedXBLPrototypeHandlers->Get(aKey, handler.address());
}
return handler;
}
void
nsGlobalWindow::CacheXBLPrototypeHandler(nsXBLPrototypeHandler* aKey,
JS::Handle<JSObject*> aHandler)
{
- if (!mCachedXBLPrototypeHandlers.IsInitialized()) {
- mCachedXBLPrototypeHandlers.Init();
- }
-
- if (!mCachedXBLPrototypeHandlers.Count()) {
+ if (!mCachedXBLPrototypeHandlers) {
+ mCachedXBLPrototypeHandlers = new nsJSThingHashtable<nsPtrHashKey<nsXBLPrototypeHandler>, JSObject*>();
+ }
+
+ if (!mCachedXBLPrototypeHandlers->Count()) {
mozilla::HoldJSObjects(this);
}
- mCachedXBLPrototypeHandlers.Put(aKey, aHandler);
+ mCachedXBLPrototypeHandlers->Put(aKey, aHandler);
}
/**
* GetScriptableFrameElement is called when script reads
* nsIGlobalWindow::frameElement.
*
* In contrast to GetRealFrameElement, GetScriptableFrameElement says that the
* window contained by an <iframe mozbrowser> or <iframe mozapp> has no frame
--- a/dom/base/nsGlobalWindow.h
+++ b/dom/base/nsGlobalWindow.h
@@ -1234,17 +1234,17 @@ protected:
bool mNetworkUploadObserverEnabled;
bool mNetworkDownloadObserverEnabled;
#endif // MOZ_B2G
bool mCleanedUp;
nsCOMPtr<nsIDOMOfflineResourceList> mApplicationCache;
- nsJSThingHashtable<nsPtrHashKey<nsXBLPrototypeHandler>, JSObject*> mCachedXBLPrototypeHandlers;
+ nsAutoPtr<nsJSThingHashtable<nsPtrHashKey<nsXBLPrototypeHandler>, JSObject*> > mCachedXBLPrototypeHandlers;
nsCOMPtr<nsIDocument> mSuspendedDoc;
nsRefPtr<mozilla::dom::indexedDB::IDBFactory> mIndexedDB;
// This counts the number of windows that have been opened in rapid succession
// (i.e. within dom.successive_dialog_time_limit of each other). It is reset
// to 0 once a dialog is opened after dom.successive_dialog_time_limit seconds
--- a/dom/base/nsWindowMemoryReporter.cpp
+++ b/dom/base/nsWindowMemoryReporter.cpp
@@ -17,17 +17,16 @@
#include "js/MemoryMetrics.h"
#include "nsServiceManagerUtils.h"
using namespace mozilla;
nsWindowMemoryReporter::nsWindowMemoryReporter()
: mCheckForGhostWindowsCallbackPending(false)
{
- mDetachedWindows.Init();
}
NS_IMPL_ISUPPORTS3(nsWindowMemoryReporter, nsIMemoryMultiReporter, nsIObserver,
nsSupportsWeakReference)
/* static */
void
nsWindowMemoryReporter::Init()
@@ -329,24 +328,21 @@ nsWindowMemoryReporter::CollectReports(n
// Hold on to every window in memory so that window objects can't be
// destroyed while we're calling the memory reporter callback.
WindowArray windows;
windowsById->Enumerate(GetWindows, &windows);
// Get the IDs of all the "ghost" windows.
nsTHashtable<nsUint64HashKey> ghostWindows;
- ghostWindows.Init();
CheckForGhostWindows(&ghostWindows);
WindowPaths windowPaths;
- windowPaths.Init();
WindowPaths topWindowPaths;
- topWindowPaths.Init();
// Collect window memory usage.
nsWindowSizes windowTotalSizes(NULL);
nsCOMPtr<amIAddonManager> addonManager =
do_GetService("@mozilla.org/addons/integration;1");
for (uint32_t i = 0; i < windows.Length(); i++) {
nsresult rv = CollectWindowReports(windows[i], addonManager,
&windowTotalSizes, &ghostWindows,
@@ -645,17 +641,16 @@ nsWindowMemoryReporter::CheckForGhostWin
nsGlobalWindow::WindowByIdTable *windowsById =
nsGlobalWindow::GetWindowsTable();
if (!windowsById) {
NS_WARNING("GetWindowsTable returned null");
return;
}
nsTHashtable<nsCStringHashKey> nonDetachedWindowDomains;
- nonDetachedWindowDomains.Init();
// Populate nonDetachedWindowDomains.
GetNonDetachedWindowDomainsEnumeratorData nonDetachedEnumData =
{ &nonDetachedWindowDomains, tldService };
windowsById->EnumerateRead(GetNonDetachedWindowDomainsEnumerator,
&nonDetachedEnumData);
// Update mDetachedWindows and write the ghost window IDs into aOutGhostIDs,
@@ -734,17 +729,16 @@ ReportGhostWindowsEnumerator(nsUint64Has
NS_IMETHODIMP
nsWindowMemoryReporter::
GhostURLsReporter::CollectReports(
nsIMemoryMultiReporterCallback* aCb,
nsISupports* aClosure)
{
// Get the IDs of all the ghost windows in existance.
nsTHashtable<nsUint64HashKey> ghostWindows;
- ghostWindows.Init();
mWindowReporter->CheckForGhostWindows(&ghostWindows);
ReportGhostWindowsEnumeratorData reportGhostWindowsEnumData =
{ aCb, aClosure, NS_OK };
// Call aCb->Callback() for each ghost window.
ghostWindows.EnumerateEntries(ReportGhostWindowsEnumerator,
&reportGhostWindowsEnumData);
@@ -770,12 +764,11 @@ in the browser or add-ons.",
aDesc.Assign(str);
return NS_OK;
}
int64_t
nsWindowMemoryReporter::NumGhostsReporter::Amount()
{
nsTHashtable<nsUint64HashKey> ghostWindows;
- ghostWindows.Init();
mWindowReporter->CheckForGhostWindows(&ghostWindows);
return ghostWindows.Count();
}
--- a/dom/bluetooth/BluetoothService.h
+++ b/dom/bluetooth/BluetoothService.h
@@ -306,17 +306,16 @@ public:
void
RemoveObserverFromTable(const nsAString& key);
protected:
BluetoothService()
: mEnabled(false)
{
- mBluetoothSignalObserverTable.Init();
}
virtual ~BluetoothService();
bool
Init();
void
--- a/dom/bluetooth/linux/BluetoothDBusService.cpp
+++ b/dom/bluetooth/linux/BluetoothDBusService.cpp
@@ -168,17 +168,17 @@ static const char* sBluetoothDBusSignals
};
/**
* DBus Connection held for the BluetoothCommandThread to use. Should never be
* used by any other thread.
*
*/
static nsRefPtr<RawDBusConnection> gThreadConnection;
-static nsDataHashtable<nsStringHashKey, DBusMessage* > sPairingReqTable;
+static nsDataHashtable<nsStringHashKey, DBusMessage* >* sPairingReqTable;
static nsTArray<uint32_t> sAuthorizedServiceClass;
static nsString sAdapterPath;
static Atomic<int32_t> sIsPairing(0);
static int sConnectedDeviceCount = 0;
static StaticAutoPtr<Monitor> sStopBluetoothMonitor;
typedef void (*UnpackFunc)(DBusMessage*, DBusError*, BluetoothValue&, nsAString&);
typedef bool (*FilterFunc)(const BluetoothValue&);
@@ -1088,17 +1088,17 @@ AgentEventFilter(DBusConnection *conn, D
BT_WARNING(NS_ConvertUTF16toUTF8(errorStr).get());
return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
}
// Update value after parsing DBus message
signal.value() = v;
if (isPairingReq) {
- sPairingReqTable.Put(
+ sPairingReqTable->Put(
GetAddressFromObjectPath(NS_ConvertUTF8toUTF16(objectPath)), msg);
// Increase ref count here because we need this message later.
// It'll be unrefed when set*Internal() is called.
dbus_message_ref(msg);
AppendDeviceName(signal);
} else {
@@ -1664,18 +1664,18 @@ BluetoothDBusService::StartInternal()
// Add a filter for all incoming messages_base
if (!dbus_connection_add_filter(mConnection, EventFilter,
NULL, NULL)) {
NS_WARNING("Cannot create DBus Event Filter for DBus Thread!");
return NS_ERROR_FAILURE;
}
- if (!sPairingReqTable.IsInitialized()) {
- sPairingReqTable.Init();
+ if (!sPairingReqTable) {
+ sPairingReqTable = new nsDataHashtable<nsStringHashKey, DBusMessage* >;
}
BluetoothValue v;
nsAutoString replyError;
if (!GetDefaultAdapterPath(v, replyError)) {
// Adapter path is not ready yet
// Let's do PrepareAdapterRunnable when we receive signal 'AdapterAdded'
} else {
@@ -1739,18 +1739,18 @@ BluetoothDBusService::StopInternal()
BT_WARNING("%s: Can't unregister object path %s for agent!",
__FUNCTION__, KEY_REMOTE_AGENT);
}
mConnection = nullptr;
gThreadConnection = nullptr;
// unref stored DBusMessages before clear the hashtable
- sPairingReqTable.EnumerateRead(UnrefDBusMessages, nullptr);
- sPairingReqTable.Clear();
+ sPairingReqTable->EnumerateRead(UnrefDBusMessages, nullptr);
+ sPairingReqTable->Clear();
sIsPairing = 0;
sConnectedDeviceCount = 0;
sAuthorizedServiceClass.Clear();
StopDBus();
return NS_OK;
@@ -2453,17 +2453,17 @@ BluetoothDBusService::RemoveDeviceIntern
bool
BluetoothDBusService::SetPinCodeInternal(const nsAString& aDeviceAddress,
const nsAString& aPinCode,
BluetoothReplyRunnable* aRunnable)
{
nsAutoString errorStr;
BluetoothValue v = true;
DBusMessage *msg;
- if (!sPairingReqTable.Get(aDeviceAddress, &msg)) {
+ if (!sPairingReqTable->Get(aDeviceAddress, &msg)) {
BT_WARNING("%s: Couldn't get original request message.", __FUNCTION__);
errorStr.AssignLiteral("Couldn't get original request message.");
DispatchBluetoothReply(aRunnable, v, errorStr);
return false;
}
DBusMessage *reply = dbus_message_new_method_return(msg);
@@ -2488,30 +2488,30 @@ BluetoothDBusService::SetPinCodeInternal
result = false;
} else {
result = dbus_func_send(mConnection, nullptr, reply);
}
dbus_message_unref(msg);
dbus_message_unref(reply);
- sPairingReqTable.Remove(aDeviceAddress);
+ sPairingReqTable->Remove(aDeviceAddress);
DispatchBluetoothReply(aRunnable, v, errorStr);
return result;
}
bool
BluetoothDBusService::SetPasskeyInternal(const nsAString& aDeviceAddress,
uint32_t aPasskey,
BluetoothReplyRunnable* aRunnable)
{
nsAutoString errorStr;
BluetoothValue v = true;
DBusMessage *msg;
- if (!sPairingReqTable.Get(aDeviceAddress, &msg)) {
+ if (!sPairingReqTable->Get(aDeviceAddress, &msg)) {
BT_WARNING("%s: Couldn't get original request message.", __FUNCTION__);
errorStr.AssignLiteral("Couldn't get original request message.");
DispatchBluetoothReply(aRunnable, v, errorStr);
return false;
}
DBusMessage *reply = dbus_message_new_method_return(msg);
@@ -2534,31 +2534,31 @@ BluetoothDBusService::SetPasskeyInternal
result = false;
} else {
result = dbus_func_send(mConnection, nullptr, reply);
}
dbus_message_unref(msg);
dbus_message_unref(reply);
- sPairingReqTable.Remove(aDeviceAddress);
+ sPairingReqTable->Remove(aDeviceAddress);
DispatchBluetoothReply(aRunnable, v, errorStr);
return result;
}
bool
BluetoothDBusService::SetPairingConfirmationInternal(
const nsAString& aDeviceAddress,
bool aConfirm,
BluetoothReplyRunnable* aRunnable)
{
nsAutoString errorStr;
BluetoothValue v = true;
DBusMessage *msg;
- if (!sPairingReqTable.Get(aDeviceAddress, &msg)) {
+ if (!sPairingReqTable->Get(aDeviceAddress, &msg)) {
BT_WARNING("%s: Couldn't get original request message.", __FUNCTION__);
errorStr.AssignLiteral("Couldn't get original request message.");
DispatchBluetoothReply(aRunnable, v, errorStr);
return false;
}
DBusMessage *reply;
@@ -2579,17 +2579,17 @@ BluetoothDBusService::SetPairingConfirma
bool result = dbus_func_send(mConnection, nullptr, reply);
if (!result) {
errorStr.AssignLiteral("Can't send message!");
}
dbus_message_unref(msg);
dbus_message_unref(reply);
- sPairingReqTable.Remove(aDeviceAddress);
+ sPairingReqTable->Remove(aDeviceAddress);
DispatchBluetoothReply(aRunnable, v, errorStr);
return result;
}
void
BluetoothDBusService::Connect(const nsAString& aDeviceAddress,
const uint16_t aProfileId,
BluetoothReplyRunnable* aRunnable)
--- a/dom/camera/DOMCameraManager.cpp
+++ b/dom/camera/DOMCameraManager.cpp
@@ -44,18 +44,17 @@ GetCameraLog()
}
/**
* nsDOMCameraManager::GetListOfCameras
* is implementation-specific, and can be found in (e.g.)
* GonkCameraManager.cpp and FallbackCameraManager.cpp.
*/
-WindowTable nsDOMCameraManager::sActiveWindows;
-bool nsDOMCameraManager::sActiveWindowsInitialized = false;
+WindowTable* nsDOMCameraManager::sActiveWindows = nullptr;
nsDOMCameraManager::nsDOMCameraManager(nsPIDOMWindow* aWindow)
: mWindowId(aWindow->WindowID())
, mCameraThread(nullptr)
, mWindow(aWindow)
{
/* member initializers and constructor code */
DOM_CAMERA_LOGT("%s:%d : this=%p, windowId=%llx\n", __func__, __LINE__, this, mWindowId);
@@ -86,19 +85,18 @@ nsDOMCameraManager::CheckPermission(nsPI
return true;
}
// static creator
already_AddRefed<nsDOMCameraManager>
nsDOMCameraManager::CreateInstance(nsPIDOMWindow* aWindow)
{
// Initialize the shared active window tracker
- if (!sActiveWindowsInitialized) {
- sActiveWindows.Init();
- sActiveWindowsInitialized = true;
+ if (!sActiveWindows) {
+ sActiveWindows = new WindowTable();
}
nsRefPtr<nsDOMCameraManager> cameraManager =
new nsDOMCameraManager(aWindow);
nsCOMPtr<nsIObserverService> obs = services::GetObserverService();
obs->AddObserver(cameraManager, "xpcom-shutdown", true);
@@ -136,55 +134,56 @@ nsDOMCameraManager::GetCamera(const Came
void
nsDOMCameraManager::Register(nsDOMCameraControl* aDOMCameraControl)
{
DOM_CAMERA_LOGI(">>> Register( aDOMCameraControl = %p ) mWindowId = 0x%llx\n", aDOMCameraControl, mWindowId);
MOZ_ASSERT(NS_IsMainThread());
// Put the camera control into the hash table
- CameraControls* controls = sActiveWindows.Get(mWindowId);
+ CameraControls* controls = sActiveWindows->Get(mWindowId);
if (!controls) {
controls = new CameraControls;
- sActiveWindows.Put(mWindowId, controls);
+ sActiveWindows->Put(mWindowId, controls);
}
controls->AppendElement(aDOMCameraControl);
}
void
nsDOMCameraManager::Shutdown(uint64_t aWindowId)
{
DOM_CAMERA_LOGI(">>> Shutdown( aWindowId = 0x%llx )\n", aWindowId);
MOZ_ASSERT(NS_IsMainThread());
- CameraControls* controls = sActiveWindows.Get(aWindowId);
+ CameraControls* controls = sActiveWindows->Get(aWindowId);
if (!controls) {
return;
}
uint32_t length = controls->Length();
for (uint32_t i = 0; i < length; i++) {
nsRefPtr<nsDOMCameraControl> cameraControl = controls->ElementAt(i);
cameraControl->Shutdown();
}
controls->Clear();
- sActiveWindows.Remove(aWindowId);
+ sActiveWindows->Remove(aWindowId);
}
void
nsDOMCameraManager::XpComShutdown()
{
DOM_CAMERA_LOGI(">>> XPCOM Shutdown\n");
MOZ_ASSERT(NS_IsMainThread());
nsCOMPtr<nsIObserverService> obs = services::GetObserverService();
obs->RemoveObserver(this, "xpcom-shutdown");
- sActiveWindows.Clear();
+ delete sActiveWindows;
+ sActiveWindows = nullptr;
}
nsresult
nsDOMCameraManager::Observe(nsISupports* aSubject, const char* aTopic, const PRUnichar* aData)
{
if (strcmp(aTopic, "xpcom-shutdown") == 0) {
XpComShutdown();
}
@@ -198,20 +197,20 @@ nsDOMCameraManager::OnNavigation(uint64_
Shutdown(aWindowId);
}
bool
nsDOMCameraManager::IsWindowStillActive(uint64_t aWindowId)
{
MOZ_ASSERT(NS_IsMainThread());
- if (!sActiveWindowsInitialized) {
+ if (!sActiveWindows) {
return false;
}
- return !!sActiveWindows.Get(aWindowId);
+ return !!sActiveWindows->Get(aWindowId);
}
JSObject*
nsDOMCameraManager::WrapObject(JSContext* aCx, JS::Handle<JSObject*> aScope)
{
return CameraManagerBinding::Wrap(aCx, aScope, this);
}
--- a/dom/camera/DOMCameraManager.h
+++ b/dom/camera/DOMCameraManager.h
@@ -80,18 +80,17 @@ private:
protected:
uint64_t mWindowId;
nsCOMPtr<nsIThread> mCameraThread;
nsCOMPtr<nsPIDOMWindow> mWindow;
/**
* 'mActiveWindows' is only ever accessed while in the main thread,
* so it is not otherwise protected.
*/
- static WindowTable sActiveWindows;
- static bool sActiveWindowsInitialized;
+ static WindowTable* sActiveWindows;
};
class GetCameraTask : public nsRunnable
{
public:
GetCameraTask(uint32_t aCameraId, nsICameraGetCameraCallback* onSuccess, nsICameraErrorCallback* onError, nsIThread* aCameraThread)
: mCameraId(aCameraId)
, mOnSuccessCb(onSuccess)
--- a/dom/file/FileService.cpp
+++ b/dom/file/FileService.cpp
@@ -35,18 +35,16 @@ FileService::~FileService()
{
NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");
NS_ASSERTION(!gInstance, "More than one instance!");
}
nsresult
FileService::Init()
{
- mFileStorageInfos.Init();
-
nsresult rv;
mStreamTransportTarget =
do_GetService(NS_STREAMTRANSPORTSERVICE_CONTRACTID, &rv);
return rv;
}
nsresult
--- a/dom/file/FileService.h
+++ b/dom/file/FileService.h
@@ -154,18 +154,16 @@ private:
IsFileLockedForWriting(const nsAString& aFileName)
{
return mFilesWriting.Contains(aFileName);
}
private:
FileStorageInfo()
{
- mFilesReading.Init();
- mFilesWriting.Init();
}
nsTArray<nsRefPtr<LockedFileQueue> > mLockedFileQueues;
nsTArray<DelayedEnqueueInfo> mDelayedEnqueueInfos;
nsTHashtable<nsStringHashKey> mFilesReading;
nsTHashtable<nsStringHashKey> mFilesWriting;
};
--- a/dom/indexedDB/Client.cpp
+++ b/dom/indexedDB/Client.cpp
@@ -54,18 +54,17 @@ Client::InitOrigin(const nsACString& aOr
NS_ENSURE_SUCCESS(rv, rv);
// We need to see if there are any files in the directory already. If they
// are database files then we need to cleanup stored files (if it's needed)
// and also get the usage.
nsAutoTArray<nsString, 20> subdirsToProcess;
nsAutoTArray<nsCOMPtr<nsIFile> , 20> unknownFiles;
- nsTHashtable<nsStringHashKey> validSubdirs;
- validSubdirs.Init(20);
+ nsTHashtable<nsStringHashKey> validSubdirs(20);
nsCOMPtr<nsISimpleEnumerator> entries;
rv = directory->GetDirectoryEntries(getter_AddRefs(entries));
NS_ENSURE_SUCCESS(rv, rv);
bool hasMore;
while (NS_SUCCEEDED((rv = entries->HasMoreElements(&hasMore))) &&
hasMore && (!aUsageRunnable || !aUsageRunnable->Canceled())) {
--- a/dom/indexedDB/DatabaseInfo.cpp
+++ b/dom/indexedDB/DatabaseInfo.cpp
@@ -146,17 +146,16 @@ DatabaseInfo::Get(nsIAtom* aId,
bool
DatabaseInfo::Put(DatabaseInfo* aInfo)
{
NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");
NS_ASSERTION(aInfo, "Null pointer!");
if (!gDatabaseHash) {
nsAutoPtr<DatabaseHash> databaseHash(new DatabaseHash());
- databaseHash->Init();
gDatabaseHash = databaseHash.forget();
}
if (gDatabaseHash->Get(aInfo->id, nullptr)) {
NS_ERROR("Already know about this database!");
return false;
}
@@ -216,17 +215,16 @@ DatabaseInfo::GetObjectStore(const nsASt
bool
DatabaseInfo::PutObjectStore(ObjectStoreInfo* aInfo)
{
NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");
NS_ASSERTION(aInfo, "Null pointer!");
if (!objectStoreHash) {
nsAutoPtr<ObjectStoreInfoHash> hash(new ObjectStoreInfoHash());
- hash->Init();
objectStoreHash = hash.forget();
}
if (objectStoreHash->Get(aInfo->name, nullptr)) {
NS_ERROR("Already have an entry for this objectstore!");
return false;
}
@@ -256,15 +254,14 @@ DatabaseInfo::Clone()
dbInfo->version = version;
dbInfo->id = id;
dbInfo->filePath = filePath;
dbInfo->nextObjectStoreId = nextObjectStoreId;
dbInfo->nextIndexId = nextIndexId;
if (objectStoreHash) {
dbInfo->objectStoreHash = new ObjectStoreInfoHash();
- dbInfo->objectStoreHash->Init();
objectStoreHash->EnumerateRead(CloneObjectStoreInfo,
dbInfo->objectStoreHash);
}
return dbInfo.forget();
}
--- a/dom/indexedDB/FileManager.cpp
+++ b/dom/indexedDB/FileManager.cpp
@@ -62,18 +62,16 @@ GetDirectoryFor(const nsAString& aDirect
nsresult
FileManager::Init(nsIFile* aDirectory,
mozIStorageConnection* aConnection)
{
AssertIsOnIOThread();
NS_ASSERTION(aDirectory, "Null directory!");
NS_ASSERTION(aConnection, "Null connection!");
- mFileInfos.Init();
-
bool exists;
nsresult rv = aDirectory->Exists(&exists);
NS_ENSURE_SUCCESS(rv, rv);
if (exists) {
bool isDirectory;
rv = aDirectory->IsDirectory(&isDirectory);
NS_ENSURE_SUCCESS(rv, rv);
--- a/dom/indexedDB/IDBTransaction.cpp
+++ b/dom/indexedDB/IDBTransaction.cpp
@@ -112,21 +112,17 @@ IDBTransaction::CreateInternal(IDBDataba
transaction->mDatabase = aDatabase;
transaction->mMode = aMode;
transaction->mDatabaseInfo = aDatabase->Info();
transaction->mObjectStoreNames.AppendElements(aObjectStoreNames);
transaction->mObjectStoreNames.Sort();
IndexedDBTransactionChild* actor = nullptr;
- transaction->mCreatedFileInfos.Init();
-
if (IndexedDatabaseManager::IsMainProcess()) {
- transaction->mCachedStatements.Init();
-
if (aMode != IDBTransaction::VERSION_CHANGE) {
TransactionThreadPool* pool = TransactionThreadPool::GetOrCreate();
NS_ENSURE_TRUE(pool, nullptr);
static StartTransactionRunnable sStartTransactionRunnable;
pool->Dispatch(transaction, &sStartTransactionRunnable, false, nullptr);
}
}
@@ -372,19 +368,16 @@ IDBTransaction::GetOrCreateConnection(mo
nsresult rv;
nsRefPtr<UpdateRefcountFunction> function;
nsCString beginTransaction;
if (mMode != IDBTransaction::READ_ONLY) {
function = new UpdateRefcountFunction(Database()->Manager());
NS_ENSURE_TRUE(function, NS_ERROR_OUT_OF_MEMORY);
- rv = function->Init();
- NS_ENSURE_SUCCESS(rv, rv);
-
rv = connection->CreateFunction(
NS_LITERAL_CSTRING("update_refcount"), 2, function);
NS_ENSURE_SUCCESS(rv, rv);
beginTransaction.AssignLiteral("BEGIN IMMEDIATE TRANSACTION;");
}
else {
beginTransaction.AssignLiteral("BEGIN TRANSACTION;");
@@ -982,24 +975,16 @@ void
CommitHelper::RevertAutoIncrementCounts()
{
for (uint32_t i = 0; i < mAutoIncrementObjectStores.Length(); i++) {
ObjectStoreInfo* info = mAutoIncrementObjectStores[i]->Info();
info->nextAutoIncrementId = info->comittedAutoIncrementId;
}
}
-nsresult
-UpdateRefcountFunction::Init()
-{
- mFileInfoEntries.Init();
-
- return NS_OK;
-}
-
NS_IMPL_ISUPPORTS1(UpdateRefcountFunction, mozIStorageFunction)
NS_IMETHODIMP
UpdateRefcountFunction::OnFunctionCall(mozIStorageValueArray* aValues,
nsIVariant** _retval)
{
*_retval = nullptr;
--- a/dom/indexedDB/IDBTransaction.h
+++ b/dom/indexedDB/IDBTransaction.h
@@ -368,18 +368,16 @@ public:
UpdateRefcountFunction(FileManager* aFileManager)
: mFileManager(aFileManager)
{ }
~UpdateRefcountFunction()
{ }
- nsresult Init();
-
void ClearFileInfoEntries()
{
mFileInfoEntries.Clear();
}
nsresult WillCommit(mozIStorageConnection* aConnection);
void DidCommit();
void DidAbort();
--- a/dom/indexedDB/IndexedDatabaseManager.cpp
+++ b/dom/indexedDB/IndexedDatabaseManager.cpp
@@ -125,18 +125,16 @@ InvalidateAndRemoveFileManagers(
}
} // anonymous namespace
IndexedDatabaseManager::IndexedDatabaseManager()
: mFileMutex("IndexedDatabaseManager.mFileMutex")
{
NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");
-
- mFileManagers.Init();
}
IndexedDatabaseManager::~IndexedDatabaseManager()
{
NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");
}
bool IndexedDatabaseManager::sIsMainProcess = false;
--- a/dom/indexedDB/TransactionThreadPool.cpp
+++ b/dom/indexedDB/TransactionThreadPool.cpp
@@ -117,18 +117,16 @@ TransactionThreadPool::Shutdown()
}
}
nsresult
TransactionThreadPool::Init()
{
NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");
- mTransactionsInProgress.Init();
-
nsresult rv;
mThreadPool = do_CreateInstance(NS_THREADPOOL_CONTRACTID, &rv);
NS_ENSURE_SUCCESS(rv, rv);
rv = mThreadPool->SetName(NS_LITERAL_CSTRING("IndexedDB Trans"));
NS_ENSURE_SUCCESS(rv, rv);
rv = mThreadPool->SetThreadLimit(kThreadLimit);
--- a/dom/indexedDB/TransactionThreadPool.h
+++ b/dom/indexedDB/TransactionThreadPool.h
@@ -81,19 +81,16 @@ protected:
friend class TransactionQueue;
struct TransactionInfo
{
TransactionInfo(IDBTransaction* aTransaction)
{
MOZ_COUNT_CTOR(TransactionInfo);
- blockedOn.Init();
- blocking.Init();
-
transaction = aTransaction;
queue = new TransactionQueue(aTransaction);
}
~TransactionInfo()
{
MOZ_COUNT_DTOR(TransactionInfo);
}
@@ -122,19 +119,16 @@ protected:
TransactionInfo* lastBlockingReads;
};
struct DatabaseTransactionInfo
{
DatabaseTransactionInfo()
{
MOZ_COUNT_CTOR(DatabaseTransactionInfo);
-
- transactions.Init();
- blockingTransactions.Init();
}
~DatabaseTransactionInfo()
{
MOZ_COUNT_DTOR(DatabaseTransactionInfo);
}
typedef nsClassHashtable<nsPtrHashKey<IDBTransaction>, TransactionInfo >
--- a/dom/ipc/ContentChild.cpp
+++ b/dom/ipc/ContentChild.cpp
@@ -1331,17 +1331,16 @@ ContentChild::RecvFileSystemUpdate(const
bool
ContentChild::RecvNotifyProcessPriorityChanged(
const hal::ProcessPriority& aPriority)
{
nsCOMPtr<nsIObserverService> os = services::GetObserverService();
NS_ENSURE_TRUE(os, true);
nsRefPtr<nsHashPropertyBag> props = new nsHashPropertyBag();
- props->Init();
props->SetPropertyAsInt32(NS_LITERAL_STRING("priority"),
static_cast<int32_t>(aPriority));
os->NotifyObservers(static_cast<nsIPropertyBag2*>(props),
"ipc:process-priority-changed", nullptr);
return true;
}
--- a/dom/ipc/ContentParent.cpp
+++ b/dom/ipc/ContentParent.cpp
@@ -545,17 +545,16 @@ ContentParent::CreateBrowserOrApp(const
// If we got here, we have an app and we're not a browser element. ownApp
// shouldn't be null, because we otherwise would have gone into the
// !HasOwnApp() branch above.
nsCOMPtr<mozIApplication> ownApp = aContext.GetOwnApp();
if (!sAppContentParents) {
sAppContentParents =
new nsDataHashtable<nsStringHashKey, ContentParent*>();
- sAppContentParents->Init();
}
// Each app gets its own ContentParent instance.
nsAutoString manifestURL;
if (NS_FAILED(ownApp->GetManifestURL(manifestURL))) {
NS_ERROR("Failed to get manifest URL");
return nullptr;
}
@@ -1041,17 +1040,16 @@ ContentParent::ActorDestroy(ActorDestroy
threadInt(do_QueryInterface(NS_GetCurrentThread()));
if (threadInt)
threadInt->RemoveObserver(this);
MarkAsDead();
if (obs) {
nsRefPtr<nsHashPropertyBag> props = new nsHashPropertyBag();
- props->Init();
props->SetPropertyAsUint64(NS_LITERAL_STRING("childID"), mChildID);
if (AbnormalShutdown == why) {
props->SetPropertyAsBool(NS_LITERAL_STRING("abnormal"), true);
#ifdef MOZ_CRASHREPORTER
// There's a window in which child processes can crash
--- a/dom/ipc/CrashReporterParent.cpp
+++ b/dom/ipc/CrashReporterParent.cpp
@@ -26,24 +26,24 @@ CrashReporterParent::AnnotateCrashReport
bool
CrashReporterParent::RecvAppendAppNotes(const nsCString& data)
{
mAppNotes.Append(data);
return true;
}
CrashReporterParent::CrashReporterParent()
-: mStartTime(time(NULL))
-, mInitialized(false)
+ :
+#ifdef MOZ_CRASHREPORTER
+ mNotes(4),
+#endif
+ mStartTime(time(NULL))
+ , mInitialized(false)
{
MOZ_COUNT_CTOR(CrashReporterParent);
-
-#ifdef MOZ_CRASHREPORTER
- mNotes.Init(4);
-#endif
}
CrashReporterParent::~CrashReporterParent()
{
MOZ_COUNT_DTOR(CrashReporterParent);
}
void
--- a/dom/ipc/ProcessPriorityManager.cpp
+++ b/dom/ipc/ProcessPriorityManager.cpp
@@ -368,18 +368,16 @@ ProcessPriorityManagerImpl::GetSingleton
}
return sSingleton;
}
ProcessPriorityManagerImpl::ProcessPriorityManagerImpl()
{
MOZ_ASSERT(XRE_GetProcessType() == GeckoProcessType_Default);
- mParticularManagers.Init();
- mHighPriorityChildIDs.Init();
}
void
ProcessPriorityManagerImpl::Init()
{
LOG("Starting up. This is the master process.");
// The master process's priority never changes; set it here and then forget
--- a/dom/ipc/TabChild.cpp
+++ b/dom/ipc/TabChild.cpp
@@ -1096,51 +1096,55 @@ TabChild::BrowserFrameProvideWindow(nsID
already_AddRefed<nsIDOMWindowUtils>
TabChild::GetDOMWindowUtils()
{
nsCOMPtr<nsPIDOMWindow> window = do_GetInterface(mWebNav);
nsCOMPtr<nsIDOMWindowUtils> utils = do_GetInterface(window);
return utils.forget();
}
-static nsInterfaceHashtable<nsPtrHashKey<PContentDialogChild>, nsIDialogParamBlock> gActiveDialogs;
+static nsInterfaceHashtable<nsPtrHashKey<PContentDialogChild>, nsIDialogParamBlock>* gActiveDialogs;
NS_IMETHODIMP
TabChild::OpenDialog(uint32_t aType, const nsACString& aName,
const nsACString& aFeatures,
nsIDialogParamBlock* aArguments,
nsIDOMElement* aFrameElement)
{
- if (!gActiveDialogs.IsInitialized()) {
- gActiveDialogs.Init();
+ if (!gActiveDialogs) {
+ gActiveDialogs = new nsInterfaceHashtable<nsPtrHashKey<PContentDialogChild>, nsIDialogParamBlock>;
}
InfallibleTArray<int32_t> intParams;
InfallibleTArray<nsString> stringParams;
ParamsToArrays(aArguments, intParams, stringParams);
PContentDialogChild* dialog =
SendPContentDialogConstructor(aType, nsCString(aName),
nsCString(aFeatures), intParams, stringParams);
- gActiveDialogs.Put(dialog, aArguments);
+ gActiveDialogs->Put(dialog, aArguments);
nsIThread *thread = NS_GetCurrentThread();
- while (gActiveDialogs.GetWeak(dialog)) {
+ while (gActiveDialogs && gActiveDialogs->GetWeak(dialog)) {
if (!NS_ProcessNextEvent(thread)) {
break;
}
}
return NS_OK;
}
bool
ContentDialogChild::Recv__delete__(const InfallibleTArray<int>& aIntParams,
const InfallibleTArray<nsString>& aStringParams)
{
nsCOMPtr<nsIDialogParamBlock> params;
- if (gActiveDialogs.Get(this, getter_AddRefs(params))) {
+ if (gActiveDialogs && gActiveDialogs->Get(this, getter_AddRefs(params))) {
TabChild::ArraysToParams(aIntParams, aStringParams, params);
- gActiveDialogs.Remove(this);
+ gActiveDialogs->Remove(this);
+ if (gActiveDialogs->Count() == 0) {
+ delete gActiveDialogs;
+ gActiveDialogs = nullptr;
+ }
}
return true;
}
void
TabChild::ParamsToArrays(nsIDialogParamBlock* aParams,
InfallibleTArray<int>& aIntParams,
InfallibleTArray<nsString>& aStringParams)
--- a/dom/media/MediaManager.cpp
+++ b/dom/media/MediaManager.cpp
@@ -914,19 +914,16 @@ MediaManager::MediaManager()
if (NS_SUCCEEDED(rv)) {
nsCOMPtr<nsIPrefBranch> branch = do_QueryInterface(prefs);
if (branch) {
GetPrefs(branch, nullptr);
}
}
LOG(("%s: default prefs: %dx%d @%dfps (min %d)", __FUNCTION__,
mPrefs.mWidth, mPrefs.mHeight, mPrefs.mFPS, mPrefs.mMinFPS));
-
- mActiveWindows.Init();
- mActiveCallbacks.Init();
}
NS_IMPL_ISUPPORTS2(MediaManager, nsIMediaManagerService, nsIObserver)
/* static */ StaticRefPtr<MediaManager> MediaManager::sSingleton;
// NOTE: never Dispatch(....,NS_DISPATCH_SYNC) to the MediaManager
// thread from the MainThread, as we NS_DISPATCH_SYNC to MainThread
--- a/dom/plugins/base/nsPluginInstanceOwner.cpp
+++ b/dom/plugins/base/nsPluginInstanceOwner.cpp
@@ -937,20 +937,19 @@ NS_IMETHODIMP nsPluginInstanceOwner::Get
if (charset.EqualsLiteral("us-ascii")) {
*result = PL_strdup("US_ASCII");
} else if (charset.EqualsLiteral("ISO-8859-1") ||
!nsCRT::strncmp(charset.get(), "UTF", 3)) {
*result = ToNewCString(charset);
} else {
if (!gCharsetMap) {
const int NUM_CHARSETS = sizeof(charsets) / sizeof(moz2javaCharset);
- gCharsetMap = new nsDataHashtable<nsDepCharHashKey, const char*>();
+ gCharsetMap = new nsDataHashtable<nsDepCharHashKey, const char*>(NUM_CHARSETS);
if (!gCharsetMap)
return NS_ERROR_OUT_OF_MEMORY;
- gCharsetMap->Init(NUM_CHARSETS);
for (uint16_t i = 0; i < NUM_CHARSETS; i++) {
gCharsetMap->Put(charsets[i].mozName, charsets[i].javaName);
}
}
// if found mapping, return it; otherwise return original charset
const char *mapping;
*result = gCharsetMap->Get(charset.get(), &mapping) ? PL_strdup(mapping) :
ToNewCString(charset);
--- a/dom/plugins/ipc/PluginInstanceChild.cpp
+++ b/dom/plugins/ipc/PluginInstanceChild.cpp
@@ -142,17 +142,16 @@ PluginInstanceChild::PluginInstanceChild
, mDoAlphaExtraction(false)
, mHasPainted(false)
, mSurfaceDifferenceRect(0,0,0,0)
{
memset(&mWindow, 0, sizeof(mWindow));
mWindow.type = NPWindowTypeWindow;
mData.ndata = (void*) this;
mData.pdata = nullptr;
- mAsyncBitmaps.Init();
#if defined(MOZ_X11) && defined(XP_UNIX) && !defined(XP_MACOSX)
mWindow.ws_info = &mWsInfo;
memset(&mWsInfo, 0, sizeof(mWsInfo));
#if (MOZ_WIDGET_GTK == 2)
mWsInfo.display = NULL;
mXtClient.top_widget = NULL;
#else
mWsInfo.display = DefaultXDisplay();
@@ -3954,17 +3953,16 @@ PluginInstanceChild::AnswerNPP_Destroy(N
mAsyncInvalidateTask->Cancel();
mAsyncInvalidateTask = nullptr;
}
}
ClearAllSurfaces();
mDeletingHash = new nsTHashtable<DeletingObjectEntry>;
- mDeletingHash->Init();
PluginModuleChild::current()->FindNPObjectsForInstance(this);
mDeletingHash->EnumerateEntries(InvalidateObject, NULL);
mDeletingHash->EnumerateEntries(DeleteObject, NULL);
// Null out our cached actors as they should have been killed in the
// PluginInstanceDestroyed call above.
mCachedWindowActor = nullptr;
--- a/dom/plugins/ipc/PluginInstanceParent.cpp
+++ b/dom/plugins/ipc/PluginInstanceParent.cpp
@@ -75,19 +75,16 @@ PluginInstanceParent::PluginInstancePare
, mNestedEventState(false)
#endif // defined(XP_WIN)
#if defined(XP_MACOSX)
, mShWidth(0)
, mShHeight(0)
, mShColorSpace(nullptr)
#endif
{
-#ifdef OS_WIN
- mTextureMap.Init();
-#endif
}
PluginInstanceParent::~PluginInstanceParent()
{
if (mNPP)
mNPP->pdata = NULL;
#if defined(OS_WIN)
@@ -108,17 +105,16 @@ PluginInstanceParent::~PluginInstancePar
}
DeallocShmem(mRemoteImageDataShmem);
}
}
bool
PluginInstanceParent::Init()
{
- mScriptableObjects.Init();
return true;
}
void
PluginInstanceParent::ActorDestroy(ActorDestroyReason why)
{
#if defined(OS_WIN)
if (why == AbnormalShutdown) {
@@ -1532,27 +1528,25 @@ PluginInstanceParent::NPP_URLNotify(cons
}
bool
PluginInstanceParent::RegisterNPObjectForActor(
NPObject* aObject,
PluginScriptableObjectParent* aActor)
{
NS_ASSERTION(aObject && aActor, "Null pointers!");
- NS_ASSERTION(mScriptableObjects.IsInitialized(), "Hash not initialized!");
NS_ASSERTION(!mScriptableObjects.Get(aObject, nullptr), "Duplicate entry!");
mScriptableObjects.Put(aObject, aActor);
return true;
}
void
PluginInstanceParent::UnregisterNPObject(NPObject* aObject)
{
NS_ASSERTION(aObject, "Null pointer!");
- NS_ASSERTION(mScriptableObjects.IsInitialized(), "Hash not initialized!");
NS_ASSERTION(mScriptableObjects.Get(aObject, nullptr), "Unknown entry!");
mScriptableObjects.Remove(aObject);
}
PluginScriptableObjectParent*
PluginInstanceParent::GetActorForNPObject(NPObject* aObject)
{
NS_ASSERTION(aObject, "Null pointer!");
--- a/dom/plugins/ipc/PluginModuleChild.cpp
+++ b/dom/plugins/ipc/PluginModuleChild.cpp
@@ -145,20 +145,16 @@ PluginModuleChild::Init(const std::strin
PLUGIN_LOG_DEBUG_METHOD;
#ifdef XP_WIN
COMMessageFilter::Initialize(this);
#endif
NS_ASSERTION(aChannel, "need a channel");
- mObjectMap.Init();
- mStringIdentifiers.Init();
- mIntIdentifiers.Init();
-
if (!InitGraphics())
return false;
mPluginFilename = aPluginFilename.c_str();
nsCOMPtr<nsIFile> localFile;
NS_NewLocalFile(NS_ConvertUTF8toUTF16(mPluginFilename),
true,
getter_AddRefs(localFile));
@@ -721,48 +717,45 @@ PluginModuleChild::GetUserAgent()
return NullableStringGet(mUserAgent);
}
bool
PluginModuleChild::RegisterActorForNPObject(NPObject* aObject,
PluginScriptableObjectChild* aActor)
{
AssertPluginThread();
- NS_ASSERTION(mObjectMap.IsInitialized(), "Not initialized!");
NS_ASSERTION(aObject && aActor, "Null pointer!");
NPObjectData* d = mObjectMap.GetEntry(aObject);
if (!d) {
NS_ERROR("NPObject not in object table");
return false;
}
d->actor = aActor;
return true;
}
void
PluginModuleChild::UnregisterActorForNPObject(NPObject* aObject)
{
AssertPluginThread();
- NS_ASSERTION(mObjectMap.IsInitialized(), "Not initialized!");
NS_ASSERTION(aObject, "Null pointer!");
NPObjectData* d = mObjectMap.GetEntry(aObject);
NS_ASSERTION(d, "NPObject not in object table");
if (d) {
d->actor = NULL;
}
}
PluginScriptableObjectChild*
PluginModuleChild::GetActorForNPObject(NPObject* aObject)
{
AssertPluginThread();
- NS_ASSERTION(mObjectMap.IsInitialized(), "Not initialized!");
NS_ASSERTION(aObject, "Null pointer!");
NPObjectData* d = mObjectMap.GetEntry(aObject);
if (!d) {
NS_ERROR("Plugin using object not created with NPN_CreateObject?");
return NULL;
}
--- a/dom/plugins/ipc/PluginModuleParent.cpp
+++ b/dom/plugins/ipc/PluginModuleParent.cpp
@@ -132,18 +132,16 @@ PluginModuleParent::PluginModuleParent(c
#endif
#ifdef MOZ_CRASHREPORTER_INJECTOR
, mFlashProcess1(0)
, mFlashProcess2(0)
#endif
{
NS_ASSERTION(mSubprocess, "Out of memory!");
- mIdentifiers.Init();
-
Preferences::RegisterCallback(TimeoutChanged, kChildTimeoutPref, this);
Preferences::RegisterCallback(TimeoutChanged, kParentTimeoutPref, this);
#ifdef XP_WIN
Preferences::RegisterCallback(TimeoutChanged, kHangUITimeoutPref, this);
Preferences::RegisterCallback(TimeoutChanged, kHangUIMinDisplayPref, this);
#endif
#ifdef MOZ_ENABLE_PROFILER_SPS
@@ -645,18 +643,17 @@ RemoveMinidump(nsIFile* minidump)
void
PluginModuleParent::ProcessFirstMinidump()
{
CrashReporterParent* crashReporter = CrashReporter();
if (!crashReporter)
return;
- AnnotationTable notes;
- notes.Init(4);
+ AnnotationTable notes(4);
WriteExtraDataForMinidump(notes);
if (!mPluginDumpID.IsEmpty()) {
crashReporter->GenerateChildData(¬es);
return;
}
uint32_t sequence = UINT32_MAX;
--- a/dom/quota/QuotaManager.cpp
+++ b/dom/quota/QuotaManager.cpp
@@ -474,20 +474,16 @@ QuotaManager::Init()
if (NS_FAILED(Preferences::AddIntVarCache(&gStorageQuotaMB,
PREF_STORAGE_QUOTA,
DEFAULT_QUOTA_MB))) {
NS_WARNING("Unable to respond to quota pref changes!");
gStorageQuotaMB = DEFAULT_QUOTA_MB;
}
- mOriginInfos.Init();
- mCheckQuotaHelpers.Init();
- mLiveStorages.Init();
-
static_assert(Client::IDB == 0 && Client::TYPE_MAX == 1,
"Fix the registration!");
NS_ASSERTION(mClients.Capacity() == Client::TYPE_MAX,
"Should be using an auto array with correct capacity!");
// Register IndexedDB
mClients.AppendElement(new indexedDB::Client());
--- a/dom/quota/QuotaObject.h
+++ b/dom/quota/QuotaObject.h
@@ -53,17 +53,16 @@ class OriginInfo
{
friend class QuotaManager;
friend class QuotaObject;
public:
OriginInfo(const nsACString& aOrigin, int64_t aLimit, int64_t aUsage)
: mOrigin(aOrigin), mLimit(aLimit), mUsage(aUsage)
{
- mQuotaObjects.Init();
}
NS_INLINE_DECL_THREADSAFE_REFCOUNTING(OriginInfo)
private:
void
#ifdef DEBUG
LockedClearOriginInfos();
--- a/dom/src/storage/DOMStorageCache.h
+++ b/dom/src/storage/DOMStorageCache.h
@@ -117,17 +117,17 @@ public:
virtual void LoadWait();
// Cache keeps 3 sets of data: regular, private and session-only.
// This class keeps keys and values for a set and also caches
// size of the data for quick per-origin quota checking.
class Data
{
public:
- Data() : mOriginQuotaUsage(0) { mKeys.Init(); }
+ Data() : mOriginQuotaUsage(0) {}
int64_t mOriginQuotaUsage;
nsDataHashtable<nsStringHashKey, nsString> mKeys;
};
public:
// Number of data sets we keep: default, private, session
static const uint32_t kDataSetCount = 3;
--- a/dom/src/storage/DOMStorageDBThread.cpp
+++ b/dom/src/storage/DOMStorageDBThread.cpp
@@ -30,17 +30,16 @@
// Write Ahead Log's maximum size is 512KB
#define MAX_WAL_SIZE_BYTES 512 * 1024
namespace mozilla {
namespace dom {
DOMStorageDBBridge::DOMStorageDBBridge()
{
- mUsages.Init();
}
DOMStorageUsage*
DOMStorageDBBridge::GetScopeUsage(const nsACString& aScope)
{
DOMStorageUsage* usage;
if (mUsages.Get(aScope, &usage)) {
return usage;
@@ -61,17 +60,16 @@ DOMStorageDBThread::DOMStorageDBThread()
, mDBReady(false)
, mStatus(NS_OK)
, mWorkerStatements(mWorkerConnection)
, mReaderStatements(mReaderConnection)
, mDirtyEpoch(0)
, mFlushImmediately(false)
, mPriorityCounter(0)
{
- mScopesHavingData.Init();
}
nsresult
DOMStorageDBThread::Init()
{
nsresult rv;
// Need to determine location on the main thread, since
@@ -1021,18 +1019,16 @@ DOMStorageDBThread::DBOperation::Finaliz
}
}
// DOMStorageDBThread::PendingOperations
DOMStorageDBThread::PendingOperations::PendingOperations()
: mFlushFailureCount(0)
{
- mClears.Init();
- mUpdates.Init();
}
bool
DOMStorageDBThread::PendingOperations::HasTasks()
{
return !!mUpdates.Count() || !!mClears.Count();
}
--- a/dom/src/storage/DOMStorageIPC.cpp
+++ b/dom/src/storage/DOMStorageIPC.cpp
@@ -53,31 +53,30 @@ DOMStorageDBChild::ReleaseIPDLReference(
Release();
}
DOMStorageDBChild::DOMStorageDBChild(DOMLocalStorageManager* aManager)
: mManager(aManager)
, mStatus(NS_OK)
, mIPCOpen(false)
{
- mLoadingCaches.Init();
}
DOMStorageDBChild::~DOMStorageDBChild()
{
}
nsTHashtable<nsCStringHashKey>&
DOMStorageDBChild::ScopesHavingData()
{
- if (!mScopesHavingData.IsInitialized()) {
- mScopesHavingData.Init();
+ if (!mScopesHavingData) {
+ mScopesHavingData = new nsTHashtable<nsCStringHashKey>;
}
- return mScopesHavingData;
+ return *mScopesHavingData;
}
nsresult
DOMStorageDBChild::Init()
{
ContentChild* child = ContentChild::GetSingleton();
AddIPDLReference();
child->SendPStorageConstructor(this);
@@ -196,18 +195,17 @@ DOMStorageDBChild::AsyncClear(DOMStorage
}
bool
DOMStorageDBChild::ShouldPreloadScope(const nsACString& aScope)
{
// Return true if we didn't receive the aScope list yet.
// I tend to rather preserve a bit of early-after-start performance
// then a bit of memory here.
- return !mScopesHavingData.IsInitialized() ||
- mScopesHavingData.Contains(aScope);
+ return !mScopesHavingData || mScopesHavingData->Contains(aScope);
}
bool
DOMStorageDBChild::RecvObserve(const nsCString& aTopic,
const nsCString& aScopePrefix)
{
DOMStorageObserver::Self()->Notify(aTopic.get(), aScopePrefix);
return true;
--- a/dom/src/storage/DOMStorageIPC.h
+++ b/dom/src/storage/DOMStorageIPC.h
@@ -44,17 +44,21 @@ public:
virtual void SyncPreload(DOMStorageCacheBridge* aCache, bool aForceSync = false);
virtual nsresult AsyncAddItem(DOMStorageCacheBridge* aCache, const nsAString& aKey, const nsAString& aValue);
virtual nsresult AsyncUpdateItem(DOMStorageCacheBridge* aCache, const nsAString& aKey, const nsAString& aValue);
virtual nsresult AsyncRemoveItem(DOMStorageCacheBridge* aCache, const nsAString& aKey);
virtual nsresult AsyncClear(DOMStorageCacheBridge* aCache);
virtual void AsyncClearAll()
- { mScopesHavingData.Clear(); /* NO-OP on the child process otherwise */ }
+ {
+ if (mScopesHavingData) {
+ mScopesHavingData->Clear(); /* NO-OP on the child process otherwise */
+ }
+ }
virtual void AsyncClearMatchingScope(const nsACString& aScope)
{ /* NO-OP on the child process */ }
virtual void AsyncFlush()
{ SendAsyncFlush(); }
virtual bool ShouldPreloadScope(const nsACString& aScope);
@@ -78,17 +82,17 @@ private:
ThreadSafeAutoRefCnt mRefCnt;
NS_DECL_OWNINGTHREAD
// Held to get caches to forward answers to.
nsRefPtr<DOMLocalStorageManager> mManager;
// Scopes having data hash, for optimization purposes only
- nsTHashtable<nsCStringHashKey> mScopesHavingData;
+ nsAutoPtr<nsTHashtable<nsCStringHashKey> > mScopesHavingData;
// List of caches waiting for preload. This ensures the contract that
// AsyncPreload call references the cache for time of the preload.
nsTHashtable<nsRefPtrHashKey<DOMStorageCacheBridge> > mLoadingCaches;
// Status of the remote database
nsresult mStatus;
--- a/dom/src/storage/DOMStorageManager.cpp
+++ b/dom/src/storage/DOMStorageManager.cpp
@@ -103,20 +103,20 @@ PrincipalsEqual(nsIPrincipal* aObjectPri
return true;
}
NS_IMPL_ISUPPORTS1(DOMStorageManager,
nsIDOMStorageManager)
DOMStorageManager::DOMStorageManager(nsPIDOMStorage::StorageType aType)
- : mType(aType)
+ : mCaches(10)
+ , mType(aType)
, mLowDiskSpace(false)
{
- mCaches.Init(10);
DOMStorageObserver* observer = DOMStorageObserver::Self();
NS_ASSERTION(observer, "No DOMStorageObserver, cannot observe private data delete notifications!");
if (observer) {
observer->AddSink(this);
}
}
--- a/dom/workers/RuntimeService.cpp
+++ b/dom/workers/RuntimeService.cpp
@@ -1487,19 +1487,16 @@ RuntimeService::Init()
SetDefaultJSGCSettings(JSGC_MAX_BYTES, WORKER_DEFAULT_RUNTIME_HEAPSIZE);
SetDefaultJSGCSettings(JSGC_ALLOCATION_THRESHOLD,
WORKER_DEFAULT_ALLOCATION_THRESHOLD);
}
mIdleThreadTimer = do_CreateInstance(NS_TIMER_CONTRACTID);
NS_ENSURE_STATE(mIdleThreadTimer);
- mDomainMap.Init();
- mWindowMap.Init();
-
nsCOMPtr<nsIObserverService> obs = services::GetObserverService();
NS_ENSURE_TRUE(obs, NS_ERROR_FAILURE);
nsresult rv =
obs->AddObserver(this, NS_XPCOM_SHUTDOWN_THREADS_OBSERVER_ID, false);
NS_ENSURE_SUCCESS(rv, rv);
mObserved = true;
@@ -1610,17 +1607,17 @@ RuntimeService::Cleanup()
if (mIdleThreadTimer) {
if (NS_FAILED(mIdleThreadTimer->Cancel())) {
NS_WARNING("Failed to cancel idle timer!");
}
mIdleThreadTimer = nullptr;
}
- if (mDomainMap.IsInitialized()) {
+ {
MutexAutoLock lock(mMutex);
nsAutoTArray<WorkerPrivate*, 100> workers;
mDomainMap.EnumerateRead(AddAllTopLevelWorkersToArray, &workers);
if (!workers.IsEmpty()) {
nsIThread* currentThread;
@@ -1672,19 +1669,17 @@ RuntimeService::Cleanup()
if (!NS_ProcessNextEvent(currentThread)) {
NS_WARNING("Something bad happened!");
break;
}
}
}
}
- if (mWindowMap.IsInitialized()) {
- NS_ASSERTION(!mWindowMap.Count(), "All windows should have been released!");
- }
+ NS_ASSERTION(!mWindowMap.Count(), "All windows should have been released!");
if (mObserved) {
if (NS_FAILED(Preferences::UnregisterCallback(LoadJSContextOptions,
PREF_JS_OPTIONS_PREFIX,
nullptr)) ||
NS_FAILED(Preferences::UnregisterCallback(LoadJSContextOptions,
PREF_WORKERS_OPTIONS_PREFIX,
nullptr)) ||
--- a/embedding/components/commandhandler/src/nsCommandManager.cpp
+++ b/embedding/components/commandhandler/src/nsCommandManager.cpp
@@ -78,17 +78,16 @@ NS_INTERFACE_MAP_END
/* void init (in nsIDOMWindow aWindow); */
NS_IMETHODIMP
nsCommandManager::Init(nsIDOMWindow *aWindow)
{
NS_ENSURE_ARG_POINTER(aWindow);
NS_ASSERTION(aWindow, "Need non-null window here");
mWindow = aWindow; // weak ptr
- mObserversTable.Init();
return NS_OK;
}
/* void commandStatusChanged (in DOMString aCommandName, in long aChangeFlags); */
NS_IMETHODIMP
nsCommandManager::CommandStatusChanged(const char * aCommandName)
{
ObserverList* commandObservers;
--- a/extensions/cookie/nsPermissionManager.cpp
+++ b/extensions/cookie/nsPermissionManager.cpp
@@ -366,18 +366,16 @@ nsPermissionManager::GetXPCOMSingleton()
return gPermissionManager;
}
nsresult
nsPermissionManager::Init()
{
nsresult rv;
- mPermissionTable.Init();
-
mObserverService = do_GetService("@mozilla.org/observer-service;1", &rv);
if (NS_SUCCEEDED(rv)) {
mObserverService->AddObserver(this, "profile-before-change", true);
mObserverService->AddObserver(this, "profile-do-change", true);
}
if (IsChildProcess()) {
// Get the permissions from the parent process
--- a/extensions/spellcheck/hunspell/src/mozHunspell.cpp
+++ b/extensions/spellcheck/hunspell/src/mozHunspell.cpp
@@ -130,17 +130,16 @@ void HunspellReportMemoryAllocation(void
}
void HunspellReportMemoryDeallocation(void* ptr) {
SpellCheckReporter::OnFree(ptr);
}
nsresult
mozHunspell::Init()
{
- mDictionaries.Init();
LoadDictionaryList();
nsCOMPtr<nsIObserverService> obs = mozilla::services::GetObserverService();
if (obs) {
obs->AddObserver(this, "profile-do-change", true);
obs->AddObserver(this, "profile-after-change", true);
}
--- a/extensions/spellcheck/src/mozPersonalDictionary.cpp
+++ b/extensions/spellcheck/src/mozPersonalDictionary.cpp
@@ -53,19 +53,16 @@ mozPersonalDictionary::mozPersonalDictio
}
mozPersonalDictionary::~mozPersonalDictionary()
{
}
nsresult mozPersonalDictionary::Init()
{
- mDictionaryTable.Init();
- mIgnoreTable.Init();
-
nsresult rv;
nsCOMPtr<nsIObserverService> svc =
do_GetService("@mozilla.org/observer-service;1", &rv);
if (NS_SUCCEEDED(rv) && svc)
rv = svc->AddObserver(this, "profile-do-change", true); // we want to reload the dictionary if the profile switches
if (NS_FAILED(rv)) return rv;
--- a/extensions/spellcheck/src/mozSpellChecker.cpp
+++ b/extensions/spellcheck/src/mozSpellChecker.cpp
@@ -274,17 +274,16 @@ mozSpellChecker::GetPersonalDictionary(n
NS_IMETHODIMP
mozSpellChecker::GetDictionaryList(nsTArray<nsString> *aDictionaryList)
{
nsresult rv;
// For catching duplicates
nsClassHashtable<nsStringHashKey, nsCString> dictionaries;
- dictionaries.Init();
nsCOMArray<mozISpellCheckingEngine> spellCheckingEngines;
rv = GetEngineList(&spellCheckingEngines);
NS_ENSURE_SUCCESS(rv, rv);
for (int32_t i = 0; i < spellCheckingEngines.Count(); i++) {
nsCOMPtr<mozISpellCheckingEngine> engine = spellCheckingEngines[i];
--- a/gfx/gl/GLContext.h
+++ b/gfx/gl/GLContext.h
@@ -2309,17 +2309,16 @@ protected:
mLockedSurface(nullptr),
mMaxTextureSize(0),
mMaxCubeMapTextureSize(0),
mMaxTextureImageSize(0),
mMaxRenderbufferSize(0),
mNeedsTextureSizeChecks(false),
mWorkAroundDriverBugs(true)
{
- mUserData.Init();
mOwningThread = NS_GetCurrentThread();
mTexBlit_UseDrawNotCopy = Preferences::GetBool("gl.blit-draw-not-copy", false);
}
// -----------------------------------------------------------------------------
// Destructor
--- a/gfx/layers/LayerTreeInvalidation.cpp
+++ b/gfx/layers/LayerTreeInvalidation.cpp
@@ -226,18 +226,17 @@ struct ContainerLayerProperties : public
// particularly want to avoid unnecessary invalidation at that time. For us
// here, that means avoiding unnecessary invalidation of child items when
// other children are added to or removed from our container layer, since
// that may be caused by children being scrolled in or out of view. We are
// less concerned with children changing order.
// TODO: Consider how we could avoid unnecessary invalidation when children
// change order, and whether the overhead would be worth it.
- nsDataHashtable<nsPtrHashKey<Layer>, uint32_t> oldIndexMap;
- oldIndexMap.Init(mChildren.Length());
+ nsDataHashtable<nsPtrHashKey<Layer>, uint32_t> oldIndexMap(mChildren.Length());
for (uint32_t i = 0; i < mChildren.Length(); ++i) {
oldIndexMap.Put(mChildren[i]->mLayer, i);
}
uint32_t i = 0; // cursor into the old child list mChildren
for (Layer* child = container->GetFirstChild(); child; child = child->GetNextSibling()) {
bool invalidateChildsCurrentArea = false;
if (i < mChildren.Length()) {
--- a/gfx/thebes/gfxDWriteFontList.cpp
+++ b/gfx/thebes/gfxDWriteFontList.cpp
@@ -573,17 +573,16 @@ gfxDWriteFontEntry::SizeOfIncludingThis(
}
////////////////////////////////////////////////////////////////////////////////
// gfxDWriteFontList
gfxDWriteFontList::gfxDWriteFontList()
: mInitialized(false), mForceGDIClassicMaxFontSize(0.0)
{
- mFontSubstitutes.Init();
}
// bug 602792 - CJK systems default to large CJK fonts which cause excessive
// I/O strain during cold startup due to dwrite caching bugs. Default to
// Arial to avoid this.
gfxFontFamily *
gfxDWriteFontList::GetDefaultFont(const gfxFontStyle *aStyle)
@@ -617,18 +616,18 @@ gfxDWriteFontList::LookupLocalFont(const
gfxFontEntry *lookup;
// initialize name lookup tables if needed
if (!mFaceNamesInitialized) {
InitFaceNameLists();
}
// lookup in name lookup tables, return null if not found
- if (!(lookup = mPostscriptNames.GetWeak(aFullname)) &&
- !(lookup = mFullnames.GetWeak(aFullname)))
+ if (!(lookup = mExtraNames->mPostscriptNames.GetWeak(aFullname)) &&
+ !(lookup = mExtraNames->mFullnames.GetWeak(aFullname)))
{
return nullptr;
}
gfxDWriteFontEntry* dwriteLookup = static_cast<gfxDWriteFontEntry*>(lookup);
gfxDWriteFontEntry *fe =
new gfxDWriteFontEntry(lookup->Name(),
dwriteLookup->mFont,
aProxyEntry->Weight(),
--- a/gfx/thebes/gfxDWriteFonts.cpp
+++ b/gfx/thebes/gfxDWriteFonts.cpp
@@ -599,27 +599,27 @@ gfxDWriteFont::ProvidesGlyphWidths()
{
return !mUseSubpixelPositions ||
(mFontFace->GetSimulations() & DWRITE_FONT_SIMULATIONS_BOLD);
}
int32_t
gfxDWriteFont::GetGlyphWidth(gfxContext *aCtx, uint16_t aGID)
{
- if (!mGlyphWidths.IsInitialized()) {
- mGlyphWidths.Init(200);
+ if (!mGlyphWidths) {
+ mGlyphWidths = new nsDataHashtable<nsUint32HashKey,int32_t>(200);
}
int32_t width = -1;
- if (mGlyphWidths.Get(aGID, &width)) {
+ if (mGlyphWidths->Get(aGID, &width)) {
return width;
}
width = NS_lround(MeasureGlyphWidth(aGID) * 65536.0);
- mGlyphWidths.Put(aGID, width);
+ mGlyphWidths->Put(aGID, width);
return width;
}
TemporaryRef<GlyphRenderingOptions>
gfxDWriteFont::GetGlyphRenderingOptions()
{
if (UsingClearType()) {
return Factory::CreateDWriteGlyphRenderingOptions(
@@ -670,18 +670,21 @@ gfxDWriteFont::MeasureGlyphWidth(uint16_
return 0;
}
void
gfxDWriteFont::SizeOfExcludingThis(MallocSizeOf aMallocSizeOf,
FontCacheSizes* aSizes) const
{
gfxFont::SizeOfExcludingThis(aMallocSizeOf, aSizes);
- aSizes->mFontInstances += aMallocSizeOf(mMetrics) +
- mGlyphWidths.SizeOfExcludingThis(nullptr, aMallocSizeOf);
+ aSizes->mFontInstances += aMallocSizeOf(mMetrics);
+ if (mGlyphWidths) {
+ aSizes->mFontInstances +=
+ mGlyphWidths->SizeOfExcludingThis(nullptr, aMallocSizeOf);
+ }
}
void
gfxDWriteFont::SizeOfIncludingThis(MallocSizeOf aMallocSizeOf,
FontCacheSizes* aSizes) const
{
aSizes->mFontInstances += aMallocSizeOf(this);
SizeOfExcludingThis(aMallocSizeOf, aSizes);
--- a/gfx/thebes/gfxDWriteFonts.h
+++ b/gfx/thebes/gfxDWriteFonts.h
@@ -89,17 +89,17 @@ protected:
bool GetForceGDIClassic();
nsRefPtr<IDWriteFontFace> mFontFace;
cairo_font_face_t *mCairoFontFace;
gfxFont::Metrics *mMetrics;
// cache of glyph widths in 16.16 fixed-point pixels
- nsDataHashtable<nsUint32HashKey,int32_t> mGlyphWidths;
+ nsAutoPtr<nsDataHashtable<nsUint32HashKey,int32_t> > mGlyphWidths;
bool mNeedsOblique;
bool mNeedsBold;
bool mUseSubpixelPositions;
bool mAllowManualShowGlyphs;
bool mAzureScaledFontIsCairo;
};
--- a/gfx/thebes/gfxFT2Fonts.cpp
+++ b/gfx/thebes/gfxFT2Fonts.cpp
@@ -543,20 +543,20 @@ gfxFT2Font::AddRange(const PRUnichar *aT
}
}
gfxFT2Font::gfxFT2Font(cairo_scaled_font_t *aCairoFont,
FT2FontEntry *aFontEntry,
const gfxFontStyle *aFontStyle,
bool aNeedsBold)
: gfxFT2FontBase(aCairoFont, aFontEntry, aFontStyle)
+ , mCharGlyphCache(64)
{
NS_ASSERTION(mFontEntry, "Unable to find font entry for font. Something is whack.");
mApplySyntheticBold = aNeedsBold;
- mCharGlyphCache.Init(64);
}
gfxFT2Font::~gfxFT2Font()
{
}
/**
* Look up the font in the gfxFont cache. If we don't find it, create one.
--- a/gfx/thebes/gfxFont.cpp
+++ b/gfx/thebes/gfxFont.cpp
@@ -391,53 +391,53 @@ hb_blob_t *
gfxFontEntry::FontTableHashEntry::GetBlob() const
{
return hb_blob_reference(mBlob);
}
bool
gfxFontEntry::GetExistingFontTable(uint32_t aTag, hb_blob_t **aBlob)
{
- if (!mFontTableCache.IsInitialized()) {
+ if (!mFontTableCache) {
// we do this here rather than on fontEntry construction
// because not all shapers will access the table cache at all
- mFontTableCache.Init(10);
- }
-
- FontTableHashEntry *entry = mFontTableCache.GetEntry(aTag);
+ mFontTableCache = new nsTHashtable<FontTableHashEntry>(10);
+ }
+
+ FontTableHashEntry *entry = mFontTableCache->GetEntry(aTag);
if (!entry) {
return false;
}
*aBlob = entry->GetBlob();
return true;
}
hb_blob_t *
gfxFontEntry::ShareFontTableAndGetBlob(uint32_t aTag,
FallibleTArray<uint8_t>* aBuffer)
{
- if (MOZ_UNLIKELY(!mFontTableCache.IsInitialized())) {
+ if (MOZ_UNLIKELY(!mFontTableCache)) {
// we do this here rather than on fontEntry construction
// because not all shapers will access the table cache at all
- mFontTableCache.Init(10);
- }
-
- FontTableHashEntry *entry = mFontTableCache.PutEntry(aTag);
+ mFontTableCache = new nsTHashtable<FontTableHashEntry>(10);
+ }
+
+ FontTableHashEntry *entry = mFontTableCache->PutEntry(aTag);
if (MOZ_UNLIKELY(!entry)) { // OOM
return nullptr;
}
if (!aBuffer) {
// ensure the entry is null
entry->Clear();
return nullptr;
}
- return entry->ShareTableAndGetBlob(*aBuffer, &mFontTableCache);
+ return entry->ShareTableAndGetBlob(*aBuffer, mFontTableCache);
}
static int
DirEntryCmp(const void* aKey, const void* aItem)
{
int32_t tag = *static_cast<const int32_t*>(aKey);
const TableDirEntry* entry = static_cast<const TableDirEntry*>(aItem);
return tag - int32_t(entry->tag);
@@ -560,17 +560,16 @@ gfxFontEntry::GetGrFace()
{
if (!mGrFaceInitialized) {
gr_face_ops faceOps = {
sizeof(gr_face_ops),
GrGetTable,
GrReleaseTable
};
mGrTableMap = new nsDataHashtable<nsPtrHashKey<const void>,void*>;
- mGrTableMap->Init();
mGrFace = gr_make_face_with_ops(this, &faceOps, gr_face_default);
mGrFaceInitialized = true;
}
++mGrFaceRefCnt;
return mGrFace;
}
void
@@ -620,20 +619,22 @@ gfxFontEntry::SizeOfExcludingThis(Malloc
{
aSizes->mFontListSize += mName.SizeOfExcludingThisIfUnshared(aMallocSizeOf);
// cmaps are shared so only non-shared cmaps are included here
if (mCharacterMap && mCharacterMap->mBuildOnTheFly) {
aSizes->mCharMapsSize +=
mCharacterMap->SizeOfIncludingThis(aMallocSizeOf);
}
- aSizes->mFontTableCacheSize +=
- mFontTableCache.SizeOfExcludingThis(
- FontTableHashEntry::SizeOfEntryExcludingThis,
- aMallocSizeOf, aSizes);
+ if (mFontTableCache) {
+ aSizes->mFontTableCacheSize +=
+ mFontTableCache->SizeOfExcludingThis(
+ FontTableHashEntry::SizeOfEntryExcludingThis,
+ aMallocSizeOf, aSizes);
+ }
}
void
gfxFontEntry::SizeOfIncludingThis(MallocSizeOf aMallocSizeOf,
FontListSizes* aSizes) const
{
aSizes->mFontListSize += aMallocSizeOf(this);
SizeOfExcludingThis(aMallocSizeOf, aSizes);
@@ -1345,18 +1346,16 @@ gfxFontCache::Shutdown()
printf("Number of tight glyph extents lazily requested=%d\n", gGlyphExtentsSetupLazyTight);
printf("Number of simple glyph extent setups that fell back to tight=%d\n", gGlyphExtentsSetupFallBackToTight);
#endif
}
gfxFontCache::gfxFontCache()
: nsExpirationTracker<gfxFont,3>(FONT_TIMEOUT_SECONDS * 1000)
{
- mFonts.Init();
-
nsCOMPtr<nsIObserverService> obs = GetObserverService();
if (obs) {
obs->AddObserver(new MemoryPressureObserver, "memory-pressure", false);
}
mWordCacheExpirationTimer = do_CreateInstance("@mozilla.org/timer;1");
if (mWordCacheExpirationTimer) {
mWordCacheExpirationTimer->
@@ -1628,18 +1627,16 @@ gfxFontShaper::MergeFontFeatures(
// bail immediately if nothing to do
if (styleRuleFeatures.IsEmpty() &&
aFontFeatures.IsEmpty() &&
!aDisableLigatures &&
numAlts == 0) {
return false;
}
- aMergedFeatures.Init();
-
// Ligature features are enabled by default in the generic shaper,
// so we explicitly turn them off if necessary (for letter-spacing)
if (aDisableLigatures) {
aMergedFeatures.Put(HB_TAG('l','i','g','a'), 0);
aMergedFeatures.Put(HB_TAG('c','l','i','g'), 0);
}
// add feature values from font
@@ -1881,17 +1878,17 @@ HasLookupRuleWithGlyph(hb_face_t *aFace,
}
}
hb_set_destroy(glyphs);
hb_set_destroy(excludedFeatureLookups);
hb_set_destroy(lookups);
}
-nsDataHashtable<nsUint32HashKey, int32_t> gfxFont::sScriptTagToCode;
+nsDataHashtable<nsUint32HashKey, int32_t> *gfxFont::sScriptTagToCode = nullptr;
void
gfxFont::CheckForFeaturesInvolvingSpace()
{
mFontEntry->mHasSpaceFeaturesInitialized = true;
bool result = false;
@@ -1902,25 +1899,25 @@ gfxFont::CheckForFeaturesInvolvingSpace(
int32_t s;
mFontEntry->mHasSpaceFeaturesSubDefault = false;
// GSUB lookups - examine per script
if (hb_ot_layout_has_substitution(face)) {
// set up the script ==> code hashtable if needed
- if (!sScriptTagToCode.IsInitialized()) {
- sScriptTagToCode.Init(MOZ_NUM_SCRIPT_CODES);
+ if (!sScriptTagToCode) {
+ sScriptTagToCode = new nsDataHashtable<nsUint32HashKey, int32_t>(MOZ_NUM_SCRIPT_CODES);
for (s = MOZ_SCRIPT_ARABIC; s < MOZ_NUM_SCRIPT_CODES; s++) {
hb_script_t scriptTag = hb_script_t(GetScriptTagForCode(s));
hb_tag_t s1, s2;
hb_ot_tags_from_script(scriptTag, &s1, &s2);
- sScriptTagToCode.Put(s1, s);
+ sScriptTagToCode->Put(s1, s);
if (s2 != HB_OT_TAG_DEFAULT_SCRIPT) {
- sScriptTagToCode.Put(s2, s);
+ sScriptTagToCode->Put(s2, s);
}
}
}
// iterate over the scripts in the font
hb_tag_t scriptTags[8];
offset = 0;
@@ -1931,17 +1928,17 @@ gfxFont::CheckForFeaturesInvolvingSpace(
for (i = 0; i < len; i++) {
if (HasLookupRuleWithGlyphByScript(face, HB_OT_TAG_GSUB,
scriptTags[i], spaceGlyph))
{
result = true;
if (scriptTags[i] == HB_TAG('D','F','L','T')) {
mFontEntry->mHasSpaceFeaturesSubDefault = true;
}
- if (sScriptTagToCode.Get(scriptTags[i], &s)) {
+ if (sScriptTagToCode->Get(scriptTags[i], &s)) {
uint32_t index = s >> 5;
uint32_t bit = s & 0x1f;
mFontEntry->mHasSpaceFeaturesSub[index] |= (1 << bit);
}
}
}
offset += len;
} while (len == ArrayLength(scriptTags));
@@ -2956,28 +2953,28 @@ gfxFont::GetShapedWord(gfxContext *aCont
const T *aText,
uint32_t aLength,
uint32_t aHash,
int32_t aRunScript,
int32_t aAppUnitsPerDevUnit,
uint32_t aFlags)
{
// if the cache is getting too big, flush it and start over
- if (mWordCache.Count() > 10000) {
+ if (mWordCache->Count() > 10000) {
NS_WARNING("flushing shaped-word cache");
ClearCachedWords();
}
// if there's a cached entry for this word, just return it
CacheHashKey key(aText, aLength, aHash,
aRunScript,
aAppUnitsPerDevUnit,
aFlags);
- CacheHashEntry *entry = mWordCache.PutEntry(key);
+ CacheHashEntry *entry = mWordCache->PutEntry(key);
if (!entry) {
NS_WARNING("failed to create word cache entry - expect missing text");
return nullptr;
}
gfxShapedWord *sw = entry->mShapedWord;
bool isContent = !mStyle.systemFont;
@@ -3704,19 +3701,21 @@ gfxFont::WordCacheEntrySizeOfExcludingTh
void
gfxFont::SizeOfExcludingThis(MallocSizeOf aMallocSizeOf,
FontCacheSizes* aSizes) const
{
for (uint32_t i = 0; i < mGlyphExtentsArray.Length(); ++i) {
aSizes->mFontInstances +=
mGlyphExtentsArray[i]->SizeOfIncludingThis(aMallocSizeOf);
}
- aSizes->mShapedWords +=
- mWordCache.SizeOfExcludingThis(WordCacheEntrySizeOfExcludingThis,
- aMallocSizeOf);
+ if (mWordCache) {
+ aSizes->mShapedWords +=
+ mWordCache->SizeOfExcludingThis(WordCacheEntrySizeOfExcludingThis,
+ aMallocSizeOf);
+ }
}
void
gfxFont::SizeOfIncludingThis(MallocSizeOf aMallocSizeOf,
FontCacheSizes* aSizes) const
{
aSizes->mFontInstances += aMallocSizeOf(this);
SizeOfExcludingThis(aMallocSizeOf, aSizes);
--- a/gfx/thebes/gfxFont.h
+++ b/gfx/thebes/gfxFont.h
@@ -648,17 +648,17 @@ private:
static void DeleteFontTableBlobData(void *aBlobData);
// not implemented
FontTableHashEntry& operator=(FontTableHashEntry& toCopy);
FontTableBlobData *mSharedBlobData;
hb_blob_t *mBlob;
};
- nsTHashtable<FontTableHashEntry> mFontTableCache;
+ nsAutoPtr<nsTHashtable<FontTableHashEntry> > mFontTableCache;
gfxFontEntry(const gfxFontEntry&);
gfxFontEntry& operator=(const gfxFontEntry&);
};
// used when iterating over all fonts looking for a match for a given character
struct GlobalFontMatch {
@@ -1150,17 +1150,16 @@ public:
* This array always has an entry for the font's space glyph --- the width is
* assumed to be zero.
*/
class gfxGlyphExtents {
public:
gfxGlyphExtents(int32_t aAppUnitsPerDevUnit) :
mAppUnitsPerDevUnit(aAppUnitsPerDevUnit) {
MOZ_COUNT_CTOR(gfxGlyphExtents);
- mTightGlyphExtents.Init();
}
~gfxGlyphExtents();
enum { INVALID_WIDTH = 0xFFFF };
// returns INVALID_WIDTH => not a contained glyph
// Otherwise the glyph has no before-bearing or vertical bearings,
// and the result is its width measured from the baseline origin, in
@@ -1671,33 +1670,33 @@ public:
uint32_t aHash,
int32_t aRunScript,
int32_t aAppUnitsPerDevUnit,
uint32_t aFlags);
// Ensure the ShapedWord cache is initialized. This MUST be called before
// any attempt to use GetShapedWord().
void InitWordCache() {
- if (!mWordCache.IsInitialized()) {
- mWordCache.Init();
+ if (!mWordCache) {
+ mWordCache = new nsTHashtable<CacheHashEntry>;
}
}
// Called by the gfxFontCache timer to increment the age of all the words,
// so that they'll expire after a sufficient period of non-use
void AgeCachedWords() {
- if (mWordCache.IsInitialized()) {
- (void)mWordCache.EnumerateEntries(AgeCacheEntry, this);
+ if (mWordCache) {
+ (void)mWordCache->EnumerateEntries(AgeCacheEntry, this);
}
}
// Discard all cached word records; called on memory-pressure notification.
void ClearCachedWords() {
- if (mWordCache.IsInitialized()) {
- mWordCache.Clear();
+ if (mWordCache) {
+ mWordCache->Clear();
}
}
virtual void SizeOfExcludingThis(mozilla::MallocSizeOf aMallocSizeOf,
FontCacheSizes* aSizes) const;
virtual void SizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf,
FontCacheSizes* aSizes) const;
@@ -1822,17 +1821,17 @@ protected:
gfxTextRun *aTextRun);
void CheckForFeaturesInvolvingSpace();
// whether a given feature is included in feature settings from both the
// font and the style. aFeatureOn set if resolved feature value is non-zero
bool HasFeatureSet(uint32_t aFeature, bool& aFeatureOn);
- static nsDataHashtable<nsUint32HashKey, int32_t> sScriptTagToCode;
+ static nsDataHashtable<nsUint32HashKey, int32_t> *sScriptTagToCode;
nsRefPtr<gfxFontEntry> mFontEntry;
struct CacheHashKey {
union {
const uint8_t *mSingle;
const PRUnichar *mDouble;
} mText;
@@ -1904,17 +1903,17 @@ protected:
nsAutoPtr<gfxShapedWord> mShapedWord;
};
static size_t
WordCacheEntrySizeOfExcludingThis(CacheHashEntry* aHashEntry,
mozilla::MallocSizeOf aMallocSizeOf,
void* aUserArg);
- nsTHashtable<CacheHashEntry> mWordCache;
+ nsAutoPtr<nsTHashtable<CacheHashEntry> > mWordCache;
static PLDHashOperator AgeCacheEntry(CacheHashEntry *aEntry, void *aUserData);
static const uint32_t kShapedWordCacheMaxAge = 3;
bool mIsValid;
// use synthetic bolding for environments where this is not supported
// by the platform
--- a/gfx/thebes/gfxFontFeatures.cpp
+++ b/gfx/thebes/gfxFontFeatures.cpp
@@ -5,18 +5,18 @@
#include "gfxFontFeatures.h"
#include "nsUnicharUtils.h"
#include "nsHashKeys.h"
using namespace mozilla;
gfxFontFeatureValueSet::gfxFontFeatureValueSet()
+ : mFontFeatureValues(10)
{
- mFontFeatureValues.Init(10);
}
bool
gfxFontFeatureValueSet::GetFontFeatureValuesFor(const nsAString& aFamily,
uint32_t aVariantProperty,
const nsAString& aName,
nsTArray<uint32_t>& aValues)
{
--- a/gfx/thebes/gfxFontconfigUtils.cpp
+++ b/gfx/thebes/gfxFontconfigUtils.cpp
@@ -303,21 +303,21 @@ gfxFontconfigUtils::NewPattern(const nsT
AddWeakString(pattern, FC_FAMILY, family.get());
}
}
return pattern.out();
}
gfxFontconfigUtils::gfxFontconfigUtils()
- : mLastConfig(nullptr)
+ : mFontsByFamily(50)
+ , mFontsByFullname(50)
+ , mLangSupportTable(50)
+ , mLastConfig(nullptr)
{
- mFontsByFamily.Init(50);
- mFontsByFullname.Init(50);
- mLangSupportTable.Init(20);
UpdateFontListInternal();
}
nsresult
gfxFontconfigUtils::GetFontList(nsIAtom *aLangGroup,
const nsACString& aGenericFamily,
nsTArray<nsString>& aListOfFonts)
{
--- a/gfx/thebes/gfxGDIFont.cpp
+++ b/gfx/thebes/gfxGDIFont.cpp
@@ -535,46 +535,49 @@ gfxGDIFont::FillLogFont(LOGFONTW& aLogFo
if (aUseGDIFakeItalic) {
aLogFont.lfItalic = 1;
}
}
int32_t
gfxGDIFont::GetGlyphWidth(gfxContext *aCtx, uint16_t aGID)
{
- if (!mGlyphWidths.IsInitialized()) {
- mGlyphWidths.Init(200);
+ if (!mGlyphWidths) {
+ mGlyphWidths = new nsDataHashtable<nsUint32HashKey,int32_t>(200);
}
int32_t width;
- if (mGlyphWidths.Get(aGID, &width)) {
+ if (mGlyphWidths->Get(aGID, &width)) {
return width;
}
DCFromContext dc(aCtx);
AutoSelectFont fs(dc, GetHFONT());
int devWidth;
if (GetCharWidthI(dc, aGID, 1, nullptr, &devWidth)) {
// ensure width is positive, 16.16 fixed-point value
width = (devWidth & 0x7fff) << 16;
- mGlyphWidths.Put(aGID, width);
+ mGlyphWidths->Put(aGID, width);
return width;
}
return -1;
}
void
gfxGDIFont::SizeOfExcludingThis(mozilla::MallocSizeOf aMallocSizeOf,
FontCacheSizes* aSizes) const
{
gfxFont::SizeOfExcludingThis(aMallocSizeOf, aSizes);
- aSizes->mFontInstances += aMallocSizeOf(mMetrics) +
- mGlyphWidths.SizeOfExcludingThis(nullptr, aMallocSizeOf);
+ aSizes->mFontInstances += aMallocSizeOf(mMetrics);
+ if (mGlyphWidths) {
+ aSizes->mFontInstances +=
+ mGlyphWidths->SizeOfExcludingThis(nullptr, aMallocSizeOf);
+ }
}
void
gfxGDIFont::SizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf,
FontCacheSizes* aSizes) const
{
aSizes->mFontInstances += aMallocSizeOf(this);
SizeOfExcludingThis(aMallocSizeOf, aSizes);
--- a/gfx/thebes/gfxGDIFont.h
+++ b/gfx/thebes/gfxGDIFont.h
@@ -88,12 +88,12 @@ protected:
cairo_font_face_t *mFontFace;
Metrics *mMetrics;
uint32_t mSpaceGlyph;
bool mNeedsBold;
// cache of glyph widths in 16.16 fixed-point pixels
- nsDataHashtable<nsUint32HashKey,int32_t> mGlyphWidths;
+ nsAutoPtr<nsDataHashtable<nsUint32HashKey,int32_t> > mGlyphWidths;
};
#endif /* GFX_GDIFONT_H */
--- a/gfx/thebes/gfxGDIFontList.cpp
+++ b/gfx/thebes/gfxGDIFontList.cpp
@@ -560,18 +560,18 @@ GDIFontFamily::FindStyleVariations()
/***************************************************************
*
* gfxGDIFontList
*
*/
gfxGDIFontList::gfxGDIFontList()
+ : mFontSubstitutes(50)
{
- mFontSubstitutes.Init(50);
}
static void
RemoveCharsetFromFontSubstitute(nsAString &aName)
{
int32_t comma = aName.FindChar(PRUnichar(','));
if (comma >= 0)
aName.Truncate(comma);
@@ -720,18 +720,18 @@ gfxGDIFontList::LookupLocalFont(const gf
gfxFontEntry *lookup;
// initialize name lookup tables if needed
if (!mFaceNamesInitialized) {
InitFaceNameLists();
}
// lookup in name lookup tables, return null if not found
- if (!(lookup = mPostscriptNames.GetWeak(aFullname)) &&
- !(lookup = mFullnames.GetWeak(aFullname)))
+ if (!(lookup = mExtraNames->mPostscriptNames.GetWeak(aFullname)) &&
+ !(lookup = mExtraNames->mFullnames.GetWeak(aFullname)))
{
return nullptr;
}
bool isCFF = false; // jtdfix -- need to determine this
// use the face name from the lookup font entry, which will be the localized
// face name which GDI mapping tables use (e.g. with the system locale set to
--- a/gfx/thebes/gfxGraphiteShaper.cpp
+++ b/gfx/thebes/gfxGraphiteShaper.cpp
@@ -346,17 +346,17 @@ gfxGraphiteShaper::SetGlyphsFromSegment(
}
return NS_OK;
}
// for language tag validation - include list of tags from the IANA registry
#include "gfxLanguageTagList.cpp"
-nsTHashtable<nsUint32HashKey> gfxGraphiteShaper::sLanguageTags;
+nsTHashtable<nsUint32HashKey> *gfxGraphiteShaper::sLanguageTags;
/*static*/ uint32_t
gfxGraphiteShaper::GetGraphiteTagForLang(const nsCString& aLang)
{
int len = aLang.Length();
if (len < 2) {
return 0;
}
@@ -381,33 +381,35 @@ gfxGraphiteShaper::GetGraphiteTagForLang
}
}
// valid tags must have length = 2 or 3
if (len < 2 || len > 3) {
return 0;
}
- if (!sLanguageTags.IsInitialized()) {
+ if (!sLanguageTags) {
// store the registered IANA tags in a hash for convenient validation
- sLanguageTags.Init(ArrayLength(sLanguageTagList));
+ sLanguageTags = new nsTHashtable<nsUint32HashKey>(ArrayLength(sLanguageTagList));
for (const uint32_t *tag = sLanguageTagList; *tag != 0; ++tag) {
- sLanguageTags.PutEntry(*tag);
+ sLanguageTags->PutEntry(*tag);
}
}
// only accept tags known in the IANA registry
- if (sLanguageTags.GetEntry(grLang)) {
+ if (sLanguageTags->GetEntry(grLang)) {
return grLang;
}
return 0;
}
/*static*/ void
gfxGraphiteShaper::Shutdown()
{
#ifdef NS_FREE_PERMANENT_DATA
- if (sLanguageTags.IsInitialized()) {
- sLanguageTags.Clear();
+ if (sLanguageTags) {
+ sLanguageTags->Clear();
+ delete sLanguageTags;
+ sLanguageTags = nullptr;
}
#endif
}
--- a/gfx/thebes/gfxGraphiteShaper.h
+++ b/gfx/thebes/gfxGraphiteShaper.h
@@ -48,12 +48,12 @@ protected:
gfxGraphiteShaper *mShaper;
gfxContext *mContext;
};
CallbackData mCallbackData;
// Convert HTML 'lang' (BCP47) to Graphite language code
static uint32_t GetGraphiteTagForLang(const nsCString& aLang);
- static nsTHashtable<nsUint32HashKey> sLanguageTags;
+ static nsTHashtable<nsUint32HashKey> *sLanguageTags;
};
#endif /* GFX_GRAPHITESHAPER_H */
--- a/gfx/thebes/gfxPangoFonts.cpp
+++ b/gfx/thebes/gfxPangoFonts.cpp
@@ -944,18 +944,17 @@ gfxFcFontSet::SortPreferredFonts(bool &a
// FcDefaultSubstitute() ensures a slant on mSortPattern, but, if that ever
// doesn't happen, Roman will be used.
int requestedSlant = FC_SLANT_ROMAN;
FcPatternGetInteger(mSortPattern, FC_SLANT, 0, &requestedSlant);
double requestedSize = -1.0;
FcPatternGetDouble(mSortPattern, FC_PIXEL_SIZE, 0, &requestedSize);
- nsTHashtable<gfxFontconfigUtils::DepFcStrEntry> existingFamilies;
- existingFamilies.Init(50);
+ nsTHashtable<gfxFontconfigUtils::DepFcStrEntry> existingFamilies(50);
FcChar8 *family;
for (int v = 0;
FcPatternGetString(mSortPattern,
FC_FAMILY, v, &family) == FcResultMatch; ++v) {
const nsTArray< nsCountedRef<FcPattern> > *familyFonts = nullptr;
// Is this an @font-face family?
bool isUserFont = false;
--- a/gfx/thebes/gfxPlatformFontList.cpp
+++ b/gfx/thebes/gfxPlatformFontList.cpp
@@ -116,43 +116,36 @@ gfxPlatformFontList::MemoryReporter::Col
NS_LITERAL_CSTRING("Memory used for cached font metrics and layout tables."),
aClosure);
}
return NS_OK;
}
gfxPlatformFontList::gfxPlatformFontList(bool aNeedFullnamePostscriptNames)
- : mNeedFullnamePostscriptNames(aNeedFullnamePostscriptNames),
+ : mFontFamilies(100), mOtherFamilyNames(30),
+ mPrefFonts(10), mBadUnderlineFamilyNames(10), mSharedCmaps(16),
mStartIndex(0), mIncrement(1), mNumFamilies(0)
{
- mFontFamilies.Init(100);
- mOtherFamilyNames.Init(30);
mOtherFamilyNamesInitialized = false;
- if (mNeedFullnamePostscriptNames) {
- mFullnames.Init(100);
- mPostscriptNames.Init(100);
+ if (aNeedFullnamePostscriptNames) {
+ mExtraNames = new ExtraNames();
}
mFaceNamesInitialized = false;
- mPrefFonts.Init(10);
-
- mBadUnderlineFamilyNames.Init(10);
LoadBadUnderlineList();
// pref changes notification setup
NS_ASSERTION(!gFontListPrefObserver,
"There has been font list pref observer already");
gFontListPrefObserver = new gfxFontListPrefObserver();
NS_ADDREF(gFontListPrefObserver);
Preferences::AddStrongObservers(gFontListPrefObserver, kObservedPrefs);
- mSharedCmaps.Init(16);
-
NS_RegisterMemoryMultiReporter(new MemoryReporter);
}
gfxPlatformFontList::~gfxPlatformFontList()
{
mSharedCmaps.Clear();
NS_ASSERTION(gFontListPrefObserver, "There is no font list pref observer");
Preferences::RemoveObservers(gFontListPrefObserver, kObservedPrefs);
@@ -160,19 +153,19 @@ gfxPlatformFontList::~gfxPlatformFontLis
}
nsresult
gfxPlatformFontList::InitFontList()
{
mFontFamilies.Clear();
mOtherFamilyNames.Clear();
mOtherFamilyNamesInitialized = false;
- if (mNeedFullnamePostscriptNames) {
- mFullnames.Clear();
- mPostscriptNames.Clear();
+ if (mExtraNames) {
+ mExtraNames->mFullnames.Clear();
+ mExtraNames->mPostscriptNames.Clear();
}
mFaceNamesInitialized = false;
mPrefFonts.Clear();
mReplacementCharFallbackFamily = nullptr;
CancelLoader();
// initialize ranges of characters for which system-wide font search should be skipped
mCodepointsWithNoFonts.reset();
@@ -622,31 +615,31 @@ gfxPlatformFontList::AddOtherFamilyName(
if (mBadUnderlineFamilyNames.Contains(key))
aFamilyEntry->SetBadUnderlineFamily();
}
}
void
gfxPlatformFontList::AddFullname(gfxFontEntry *aFontEntry, nsAString& aFullname)
{
- if (!mFullnames.GetWeak(aFullname)) {
- mFullnames.Put(aFullname, aFontEntry);
+ if (!mExtraNames->mFullnames.GetWeak(aFullname)) {
+ mExtraNames->mFullnames.Put(aFullname, aFontEntry);
#ifdef PR_LOGGING
LOG_FONTLIST(("(fontlist-fullname) name: %s, fullname: %s\n",
NS_ConvertUTF16toUTF8(aFontEntry->Name()).get(),
NS_ConvertUTF16toUTF8(aFullname).get()));
#endif
}
}
void
gfxPlatformFontList::AddPostscriptName(gfxFontEntry *aFontEntry, nsAString& aPostscriptName)
{
- if (!mPostscriptNames.GetWeak(aPostscriptName)) {
- mPostscriptNames.Put(aPostscriptName, aFontEntry);
+ if (!mExtraNames->mPostscriptNames.GetWeak(aPostscriptName)) {
+ mExtraNames->mPostscriptNames.Put(aPostscriptName, aFontEntry);
#ifdef PR_LOGGING
LOG_FONTLIST(("(fontlist-postscript) name: %s, psname: %s\n",
NS_ConvertUTF16toUTF8(aFontEntry->Name()).get(),
NS_ConvertUTF16toUTF8(aPostscriptName).get()));
#endif
}
}
@@ -723,17 +716,17 @@ gfxPlatformFontList::RunLoader()
}
// load the cmaps if needed
if (loadCmaps) {
familyEntry->ReadAllCMAPs();
}
// read in face names
- familyEntry->ReadFaceNames(this, mNeedFullnamePostscriptNames);
+ familyEntry->ReadFaceNames(this, NeedFullnamePostscriptNames());
// check whether the family can be considered "simple" for style matching
familyEntry->CheckForSimpleFamily();
}
mStartIndex = endIndex;
return (mStartIndex >= mNumFamilies);
@@ -845,23 +838,23 @@ gfxPlatformFontList::SizeOfExcludingThis
aSizes->mFontListSize +=
mFontFamilies.SizeOfExcludingThis(SizeOfFamilyEntryExcludingThis,
aMallocSizeOf, aSizes);
aSizes->mFontListSize +=
mOtherFamilyNames.SizeOfExcludingThis(SizeOfFamilyNameEntryExcludingThis,
aMallocSizeOf);
- if (mNeedFullnamePostscriptNames) {
+ if (mExtraNames) {
aSizes->mFontListSize +=
- mFullnames.SizeOfExcludingThis(SizeOfFontNameEntryExcludingThis,
- aMallocSizeOf);
+ mExtraNames->mFullnames.SizeOfExcludingThis(SizeOfFontNameEntryExcludingThis,
+ aMallocSizeOf);
aSizes->mFontListSize +=
- mPostscriptNames.SizeOfExcludingThis(SizeOfFontNameEntryExcludingThis,
- aMallocSizeOf);
+ mExtraNames->mPostscriptNames.SizeOfExcludingThis(SizeOfFontNameEntryExcludingThis,
+ aMallocSizeOf);
}
aSizes->mFontListSize +=
mCodepointsWithNoFonts.SizeOfExcludingThis(aMallocSizeOf);
aSizes->mFontListSize +=
mFontFamiliesToLoad.SizeOfExcludingThis(aMallocSizeOf);
aSizes->mFontListSize +=
--- a/gfx/thebes/gfxPlatformFontList.h
+++ b/gfx/thebes/gfxPlatformFontList.h
@@ -136,17 +136,17 @@ public:
// name lookup table methods
void AddOtherFamilyName(gfxFontFamily *aFamilyEntry, nsAString& aOtherFamilyName);
void AddFullname(gfxFontEntry *aFontEntry, nsAString& aFullname);
void AddPostscriptName(gfxFontEntry *aFontEntry, nsAString& aPostscriptName);
- bool NeedFullnamePostscriptNames() { return mNeedFullnamePostscriptNames; }
+ bool NeedFullnamePostscriptNames() { return mExtraNames != nullptr; }
// pure virtual functions, to be provided by concrete subclasses
// get the system default font family
virtual gfxFontFamily* GetDefaultFont(const gfxFontStyle* aStyle) = 0;
// look up a font by name on the host platform
virtual gfxFontEntry* LookupLocalFont(const gfxProxyFontEntry *aProxyEntry,
@@ -264,24 +264,24 @@ protected:
nsRefPtrHashtable<nsStringHashKey, gfxFontFamily> mOtherFamilyNames;
// flag set after InitOtherFamilyNames is called upon first name lookup miss
bool mOtherFamilyNamesInitialized;
// flag set after fullname and Postcript name lists are populated
bool mFaceNamesInitialized;
- // whether these are needed for a given platform
- bool mNeedFullnamePostscriptNames;
-
- // fullname ==> font entry (unique, one name per font entry)
- nsRefPtrHashtable<nsStringHashKey, gfxFontEntry> mFullnames;
-
- // Postscript name ==> font entry (unique, one name per font entry)
- nsRefPtrHashtable<nsStringHashKey, gfxFontEntry> mPostscriptNames;
+ struct ExtraNames {
+ ExtraNames() : mFullnames(100), mPostscriptNames(100) {}
+ // fullname ==> font entry (unique, one name per font entry)
+ nsRefPtrHashtable<nsStringHashKey, gfxFontEntry> mFullnames;
+ // Postscript name ==> font entry (unique, one name per font entry)
+ nsRefPtrHashtable<nsStringHashKey, gfxFontEntry> mPostscriptNames;
+ };
+ nsAutoPtr<ExtraNames> mExtraNames;
// cached pref font lists
// maps list of family names ==> array of family entries, one per lang group
nsDataHashtable<nsUint32HashKey, nsTArray<nsRefPtr<gfxFontFamily> > > mPrefFonts;
// when system-wide font lookup fails for a character, cache it to skip future searches
gfxSparseBitSet mCodepointsWithNoFonts;
--- a/gfx/thebes/gfxSVGGlyphs.cpp
+++ b/gfx/thebes/gfxSVGGlyphs.cpp
@@ -58,19 +58,16 @@ gfxSVGGlyphs::gfxSVGGlyphs(hb_blob_t *aS
const DocIndex* docIndex = reinterpret_cast<const DocIndex*>
(svgData + mHeader->mDocIndexOffset);
// Limit the number of documents to avoid overflow
if (uint64_t(mHeader->mDocIndexOffset) + 2 +
uint16_t(docIndex->mNumEntries) * sizeof(IndexEntry) <= length) {
mDocIndex = docIndex;
}
}
-
- mGlyphDocs.Init();
- mGlyphIdMap.Init();
}
gfxSVGGlyphs::~gfxSVGGlyphs()
{
hb_blob_destroy(mSVGData);
}
/*
@@ -251,17 +248,16 @@ gfxSVGGlyphs::HasSVGGlyph(uint32_t aGlyp
Element *
gfxSVGGlyphsDocument::GetGlyphElement(uint32_t aGlyphId)
{
return mGlyphIdMap.Get(aGlyphId);
}
gfxSVGGlyphsDocument::gfxSVGGlyphsDocument(const uint8_t *aBuffer, uint32_t aBufLen)
{
- mGlyphIdMap.Init();
ParseDocument(aBuffer, aBufLen);
if (!mDocument) {
NS_WARNING("Could not parse SVG glyphs document");
return;
}
Element *root = mDocument->GetRootElement();
if (!root) {
--- a/gfx/thebes/gfxUserFontSet.cpp
+++ b/gfx/thebes/gfxUserFontSet.cpp
@@ -97,18 +97,18 @@ gfxProxyFontEntry::Matches(const nsTArra
gfxFont*
gfxProxyFontEntry::CreateFontInstance(const gfxFontStyle *aFontStyle, bool aNeedsBold)
{
// cannot create an actual font for a proxy entry
return nullptr;
}
gfxUserFontSet::gfxUserFontSet()
+ : mFontFamilies(5)
{
- mFontFamilies.Init(5);
IncrementGeneration();
}
gfxUserFontSet::~gfxUserFontSet()
{
}
gfxFontEntry*
@@ -861,17 +861,16 @@ gfxUserFontSet::UserFontCache::Entry::Ke
void
gfxUserFontSet::UserFontCache::CacheFont(gfxFontEntry *aFontEntry)
{
NS_ASSERTION(aFontEntry->mFamilyName.Length() != 0,
"caching a font associated with no family yet");
if (!sUserFonts) {
sUserFonts = new nsTHashtable<Entry>;
- sUserFonts->Init();
nsCOMPtr<nsIObserverService> obs =
mozilla::services::GetObserverService();
if (obs) {
Flusher *flusher = new Flusher;
obs->AddObserver(flusher, NS_CACHESERVICE_EMPTYCACHE_TOPIC_ID,
false);
obs->AddObserver(flusher, "last-pb-context-exited", false);
--- a/gfx/thebes/gfxWindowsPlatform.cpp
+++ b/gfx/thebes/gfxWindowsPlatform.cpp
@@ -355,19 +355,18 @@ BuildKeyNameFromFontName(nsAString &aNam
if (aName.Length() >= LF_FACESIZE)
aName.Truncate(LF_FACESIZE - 1);
ToLowerCase(aName);
}
gfxWindowsPlatform::gfxWindowsPlatform()
: mD3D9DeviceInitialized(false)
, mD3D11DeviceInitialized(false)
+ , mPrefFonts(50)
{
- mPrefFonts.Init(50);
-
mUseClearTypeForDownloadableFonts = UNINITIALIZED_VALUE;
mUseClearTypeAlways = UNINITIALIZED_VALUE;
mUsingGDIFonts = false;
/*
* Initialize COM
*/
--- a/hal/HalWakeLock.cpp
+++ b/hal/HalWakeLock.cpp
@@ -148,17 +148,16 @@ CleanupOnContentShutdown::Observe(nsISup
}
return NS_OK;
}
void
Init()
{
sLockTable = new LockTable();
- sLockTable->Init();
sInitialized = true;
nsCOMPtr<nsIObserverService> obs = mozilla::services::GetObserverService();
if (obs) {
obs->AddObserver(new ClearHashtableOnShutdown(), "xpcom-shutdown", false);
obs->AddObserver(new CleanupOnContentShutdown(), "ipc:content-shutdown", false);
}
}
@@ -213,17 +212,16 @@ ModifyWakeLock(const nsAString& aTopic,
Init();
}
ProcessLockTable* table = sLockTable->Get(aTopic);
LockCount processCount;
LockCount totalCount;
if (!table) {
table = new ProcessLockTable();
- table->Init();
sLockTable->Put(aTopic, table);
} else {
table->Get(aProcessID, &processCount);
table->EnumerateRead(CountWakeLocks, &totalCount);
}
MOZ_ASSERT(processCount.numLocks >= processCount.numHidden);
MOZ_ASSERT(aLockAdjust >= 0 || processCount.numLocks > 0);
--- a/image/src/imgLoader.cpp
+++ b/image/src/imgLoader.cpp
@@ -864,20 +864,17 @@ nsresult imgLoader::InitCache()
os->AddObserver(this, "chrome-flush-skin-caches", false);
os->AddObserver(this, "chrome-flush-caches", false);
os->AddObserver(this, "last-pb-context-exited", false);
os->AddObserver(this, "profile-before-change", false);
os->AddObserver(this, "xpcom-shutdown", false);
mCacheTracker = new imgCacheExpirationTracker();
- mCache.Init();
- mChromeCache.Init();
-
- return NS_OK;
+ return NS_OK;
}
nsresult imgLoader::Init()
{
InitCache();
ReadAcceptHeaderPref();
--- a/intl/hyphenation/src/nsHyphenationManager.cpp
+++ b/intl/hyphenation/src/nsHyphenationManager.cpp
@@ -65,19 +65,16 @@ nsHyphenationManager::Instance()
void
nsHyphenationManager::Shutdown()
{
delete sInstance;
}
nsHyphenationManager::nsHyphenationManager()
{
- mHyphAliases.Init();
- mPatternFiles.Init();
- mHyphenators.Init();
LoadPatternList();
LoadAliases();
}
nsHyphenationManager::~nsHyphenationManager()
{
sInstance = nullptr;
}
--- a/intl/locale/src/nsLanguageAtomService.cpp
+++ b/intl/locale/src/nsLanguageAtomService.cpp
@@ -12,17 +12,16 @@
#include "nsIServiceManager.h"
#include "nsIAtom.h"
#include "mozilla/Services.h"
NS_IMPL_ISUPPORTS1(nsLanguageAtomService, nsILanguageAtomService)
nsLanguageAtomService::nsLanguageAtomService()
{
- mLangToGroup.Init();
}
nsresult
nsLanguageAtomService::InitLangGroupTable()
{
if (mLangGroups)
return NS_OK;
--- a/js/xpconnect/loader/mozJSComponentLoader.cpp
+++ b/js/xpconnect/loader/mozJSComponentLoader.cpp
@@ -338,16 +338,20 @@ ReportOnCaller(JSCLContextHelper &helper
helper.reportErrorAfterPop(buf);
return NS_OK;
}
mozJSComponentLoader::mozJSComponentLoader()
: mRuntime(nullptr),
mContext(nullptr),
+ mModules(32),
+ mImports(32),
+ mInProgressImports(32),
+ mThisObjects(32),
mInitialized(false),
mReuseLoaderGlobal(false)
{
MOZ_ASSERT(!sSelf, "mozJSComponentLoader should be a singleton");
#ifdef PR_LOGGING
if (!gJSCLLog) {
gJSCLLog = PR_NewLogModule("JSComponentLoader");
@@ -408,21 +412,16 @@ mozJSComponentLoader::ReallyInit()
do_GetService(NS_SCRIPTSECURITYMANAGER_CONTRACTID);
if (!secman)
return NS_ERROR_FAILURE;
rv = secman->GetSystemPrincipal(getter_AddRefs(mSystemPrincipal));
if (NS_FAILED(rv) || !mSystemPrincipal)
return NS_ERROR_FAILURE;
- mModules.Init(32);
- mImports.Init(32);
- mInProgressImports.Init(32);
- mThisObjects.Init(32);
-
nsCOMPtr<nsIObserverService> obsSvc =
do_GetService(kObserverServiceContractID, &rv);
NS_ENSURE_SUCCESS(rv, rv);
rv = obsSvc->AddObserver(this, "xpcom-shutdown-loaders", false);
NS_ENSURE_SUCCESS(rv, rv);
#ifdef DEBUG_shaver_off
--- a/js/xpconnect/src/XPCJSRuntime.cpp
+++ b/js/xpconnect/src/XPCJSRuntime.cpp
@@ -2426,17 +2426,16 @@ SizeOfTreeIncludingThis(nsINode *tree)
}
class OrphanReporter : public JS::ObjectPrivateVisitor
{
public:
OrphanReporter(GetISupportsFun aGetISupports)
: JS::ObjectPrivateVisitor(aGetISupports)
{
- mAlreadyMeasuredOrphanTrees.Init();
}
virtual size_t sizeOfIncludingThis(nsISupports *aSupports) {
size_t n = 0;
nsCOMPtr<nsINode> node = do_QueryInterface(aSupports);
// https://bugzilla.mozilla.org/show_bug.cgi?id=773533#c11 explains
// that we have to skip XBL elements because they violate certain
// assumptions. Yuk.
--- a/layout/base/FrameLayerBuilder.cpp
+++ b/layout/base/FrameLayerBuilder.cpp
@@ -164,17 +164,16 @@ public:
LayerManagerData(LayerManager *aManager)
: mLayerManager(aManager)
#ifdef DEBUG_DISPLAY_ITEM_DATA
, mParent(nullptr)
#endif
, mInvalidateAllLayers(false)
{
MOZ_COUNT_CTOR(LayerManagerData);
- mDisplayItems.Init();
}
~LayerManagerData() {
MOZ_COUNT_DTOR(LayerManagerData);
}
#ifdef DEBUG_DISPLAY_ITEM_DATA
void Dump(const char *aPrefix = "") {
printf("%sLayerManagerData %p\n", aPrefix, this);
@@ -242,17 +241,16 @@ public:
mAppUnitsPerDevPixel = presContext->AppUnitsPerDevPixel();
mContainerReferenceFrame = aContainerItem ? aContainerItem->ReferenceFrameForChildren() :
mBuilder->FindReferenceFrameFor(mContainerFrame);
// When AllowResidualTranslation is false, display items will be drawn
// scaled with a translation by integer pixels, so we know how the snapping
// will work.
mSnappingEnabled = aManager->IsSnappingEffectiveTransforms() &&
!mParameters.AllowResidualTranslation();
- mRecycledMaskImageLayers.Init();
CollectOldLayers();
}
enum ProcessDisplayItemsFlags {
NO_COMPONENT_ALPHA = 0x01,
};
/**
--- a/layout/base/FrameLayerBuilder.h
+++ b/layout/base/FrameLayerBuilder.h
@@ -99,17 +99,16 @@ public:
FrameLayerBuilder() :
mRetainingManager(nullptr),
mDetectedDOMModification(false),
mInvalidateAllLayers(false),
mContainerLayerGeneration(0),
mMaxContainerLayerGeneration(0)
{
MOZ_COUNT_CTOR(FrameLayerBuilder);
- mThebesLayerItems.Init();
}
~FrameLayerBuilder()
{
MOZ_COUNT_DTOR(FrameLayerBuilder);
}
static void Shutdown();
--- a/layout/base/FramePropertyTable.h
+++ b/layout/base/FramePropertyTable.h
@@ -62,17 +62,16 @@ struct FramePropertyDescriptor {
* store int32_t values. Null/zero values can be stored and retrieved.
* Of course, the destructor function (if any) must handle such values
* correctly.
*/
class FramePropertyTable {
public:
FramePropertyTable() : mLastFrame(nullptr), mLastEntry(nullptr)
{
- mEntries.Init();
}
~FramePropertyTable()
{
DeleteAll();
}
/**
* Set a property value on a frame. This requires one hashtable
--- a/layout/base/MaskLayerImageCache.cpp
+++ b/layout/base/MaskLayerImageCache.cpp
@@ -8,17 +8,16 @@
using namespace mozilla::layers;
namespace mozilla {
MaskLayerImageCache::MaskLayerImageCache()
{
MOZ_COUNT_CTOR(MaskLayerImageCache);
- mMaskImageContainers.Init();
}
MaskLayerImageCache::~MaskLayerImageCache()
{
MOZ_COUNT_DTOR(MaskLayerImageCache);
}
/* static */ PLDHashOperator
--- a/layout/base/RestyleTracker.h
+++ b/layout/base/RestyleTracker.h
@@ -186,17 +186,16 @@ public:
"Must have root flag");
NS_PRECONDITION((mRestyleBits & ~ELEMENT_PENDING_RESTYLE_FLAGS) !=
(ELEMENT_ALL_RESTYLE_FLAGS & ~ELEMENT_PENDING_RESTYLE_FLAGS),
"Shouldn't have both root flags");
}
void Init(RestyleManager* aRestyleManager) {
mRestyleManager = aRestyleManager;
- mPendingRestyles.Init();
}
uint32_t Count() const {
return mPendingRestyles.Count();
}
/**
* Add a restyle for the given element to the tracker. Returns true
--- a/layout/base/nsBidiPresUtils.cpp
+++ b/layout/base/nsBidiPresUtils.cpp
@@ -49,17 +49,16 @@ struct BidiParagraphData {
nsIContent* mPrevContent;
nsAutoPtr<nsBidi> mBidiEngine;
nsIFrame* mPrevFrame;
nsAutoPtr<BidiParagraphData> mSubParagraph;
uint8_t mParagraphDepth;
void Init(nsBlockFrame *aBlockFrame)
{
- mContentToFrameIndex.Init();
mBidiEngine = new nsBidi();
mPrevContent = nullptr;
mParagraphDepth = 0;
bool styleDirectionIsRTL =
(NS_STYLE_DIRECTION_RTL == aBlockFrame->StyleVisibility()->mDirection);
if (aBlockFrame->StyleTextReset()->mUnicodeBidi &
NS_STYLE_UNICODE_BIDI_PLAINTEXT) {
@@ -106,17 +105,16 @@ struct BidiParagraphData {
}
return mSubParagraph;
}
// Initialise a sub-paragraph from its containing paragraph
void Init(BidiParagraphData *aBpd)
{
- mContentToFrameIndex.Init();
mBidiEngine = new nsBidi();
mPrevContent = nullptr;
mIsVisual = aBpd->mIsVisual;
mReset = false;
}
void Reset(nsIFrame* aBDIFrame, BidiParagraphData *aBpd)
{
@@ -1458,18 +1456,16 @@ nsBidiPresUtils::RepositionInlineFrames(
leftSpace = isLTR ? margin.left : margin.right;
nscoord left = aFirstChild->GetPosition().x - leftSpace;
nsIFrame* frame;
int32_t count = aBld->mVisualFrames.Length();
int32_t index;
nsContinuationStates continuationStates;
- continuationStates.Init();
-
// Initialize continuation states to (nullptr, 0) for
// each frame on the line.
for (index = 0; index < count; index++) {
InitContinuationStates(aBld->VisualFrameAt(index), &continuationStates);
}
// Reposition frames in visual order
for (index = 0; index < count; index++) {
--- a/layout/base/nsCSSRendering.cpp
+++ b/layout/base/nsCSSRendering.cpp
@@ -395,17 +395,16 @@ struct GradientCacheData {
* the nsStyleRect for the key, the gfxPattern for the value.
*/
class GradientCache MOZ_FINAL : public nsExpirationTracker<GradientCacheData,4>
{
public:
GradientCache()
: nsExpirationTracker<GradientCacheData, 4>(MAX_GENERATION_MS)
{
- mHashEntries.Init();
srand(time(nullptr));
mTimerPeriod = rand() % MAX_GENERATION_MS + 1;
Telemetry::Accumulate(Telemetry::GRADIENT_RETENTION_TIME, mTimerPeriod);
}
virtual void NotifyExpired(GradientCacheData* aObject)
{
// This will free the gfxPattern.
--- a/layout/base/nsCSSRenderingBorders.cpp
+++ b/layout/base/nsCSSRenderingBorders.cpp
@@ -102,17 +102,16 @@ struct BorderGradientCacheData {
* This code was pretty bluntly stolen and modified from nsCSSRendering.
*/
class BorderGradientCache MOZ_FINAL : public nsExpirationTracker<BorderGradientCacheData,4>
{
public:
BorderGradientCache()
: nsExpirationTracker<BorderGradientCacheData, 4>(GENERATION_MS)
{
- mHashEntries.Init();
mTimerPeriod = GENERATION_MS;
}
virtual void NotifyExpired(BorderGradientCacheData* aObject)
{
// This will free the gfxPattern.
RemoveObject(aObject);
mHashEntries.Remove(aObject->mKey);
--- a/layout/base/nsCounterManager.cpp
+++ b/layout/base/nsCounterManager.cpp
@@ -175,18 +175,18 @@ nsCounterList::RecalcAll()
useNode->GetText(text);
useNode->mText->SetData(text);
}
}
} while ((node = Next(node)) != First());
}
nsCounterManager::nsCounterManager()
+ : mNames(16)
{
- mNames.Init(16);
}
bool
nsCounterManager::AddCounterResetsAndIncrements(nsIFrame *aFrame)
{
const nsStyleContent *styleContent = aFrame->StyleContent();
if (!styleContent->CounterIncrementCount() &&
!styleContent->CounterResetCount())
--- a/layout/base/nsIPresShell.h
+++ b/layout/base/nsIPresShell.h
@@ -1125,17 +1125,17 @@ public:
{
return mIsActive;
}
// mouse capturing
static CapturingContentInfo gCaptureInfo;
- static nsRefPtrHashtable<nsUint32HashKey, mozilla::dom::Touch> gCaptureTouchList;
+ static nsRefPtrHashtable<nsUint32HashKey, mozilla::dom::Touch>* gCaptureTouchList;
static bool gPreventMouseEvents;
/**
* When capturing content is set, it traps all mouse events and retargets
* them at this content node. If capturing is not allowed
* (gCaptureInfo.mAllowed is false), then capturing is not set. However, if
* the CAPTURE_IGNOREALLOWED flag is set, the allowed state is ignored and
* capturing is set regardless. To disable capture, pass null for the value
--- a/layout/base/nsLayoutHistoryState.cpp
+++ b/layout/base/nsLayoutHistoryState.cpp
@@ -16,17 +16,16 @@
class nsLayoutHistoryState MOZ_FINAL : public nsILayoutHistoryState,
public nsSupportsWeakReference
{
public:
nsLayoutHistoryState()
: mScrollPositionOnly(false)
{
- mStates.Init();
}
NS_DECL_ISUPPORTS
// nsILayoutHistoryState
virtual void
AddState(const nsCString& aKey, nsPresState* aState) MOZ_OVERRIDE;
virtual nsPresState*
--- a/layout/base/nsLayoutUtils.cpp
+++ b/layout/base/nsLayoutUtils.cpp
@@ -120,17 +120,16 @@ static int32_t sIndexOfInlineFlexInDispl
// This tracks whether those ^^ indices have been initialized
static bool sAreFlexKeywordIndicesInitialized = false;
typedef nsDataHashtable<nsUint64HashKey, nsIContent*> ContentMap;
static ContentMap* sContentMap = nullptr;
static ContentMap& GetContentMap() {
if (!sContentMap) {
sContentMap = new ContentMap();
- sContentMap->Init();
}
return *sContentMap;
}
// When the pref "layout.css.flexbox.enabled" changes, this function is invoked
// to let us update kDisplayKTable, to selectively disable or restore the
// entries for "flex" and "inline-flex" in that table.
static int
--- a/layout/base/nsPresArena.cpp
+++ b/layout/base/nsPresArena.cpp
@@ -24,17 +24,16 @@
#include "nsArenaMemoryStats.h"
#include "nsPrintfCString.h"
// Size to use for PLArena block allocations.
static const size_t ARENA_PAGE_SIZE = 8192;
nsPresArena::nsPresArena()
{
- mFreeLists.Init();
PL_INIT_ARENA_POOL(&mPool, "PresArena", ARENA_PAGE_SIZE);
}
nsPresArena::~nsPresArena()
{
#if defined(MOZ_HAVE_MEM_CHECKS)
mFreeLists.EnumerateEntries(UnpoisonFreeList, nullptr);
#endif
--- a/layout/base/nsPresContext.cpp
+++ b/layout/base/nsPresContext.cpp
@@ -2672,17 +2672,16 @@ bool nsPresContext::GetPaintFlashing() c
return mPaintFlashing;
}
nsRootPresContext::nsRootPresContext(nsIDocument* aDocument,
nsPresContextType aType)
: nsPresContext(aDocument, aType),
mDOMGeneration(0)
{
- mRegisteredPlugins.Init();
}
nsRootPresContext::~nsRootPresContext()
{
NS_ASSERTION(mRegisteredPlugins.Count() == 0,
"All plugins should have been unregistered");
CancelDidPaintTimer();
CancelApplyPluginGeometryTimer();
--- a/layout/base/nsPresShell.cpp
+++ b/layout/base/nsPresShell.cpp
@@ -163,17 +163,17 @@ using namespace mozilla;
using namespace mozilla::css;
using namespace mozilla::dom;
using namespace mozilla::layers;
CapturingContentInfo nsIPresShell::gCaptureInfo =
{ false /* mAllowed */, false /* mPointerLock */, false /* mRetargetToElement */,
false /* mPreventDrag */, nullptr /* mContent */ };
nsIContent* nsIPresShell::gKeyDownTarget;
-nsRefPtrHashtable<nsUint32HashKey, dom::Touch> nsIPresShell::gCaptureTouchList;
+nsRefPtrHashtable<nsUint32HashKey, dom::Touch>* nsIPresShell::gCaptureTouchList;
bool nsIPresShell::gPreventMouseEvents = false;
// convert a color value to a string, in the CSS format #RRGGBB
// * - initially created for bugs 31816, 20760, 22963
static void ColorToString(nscolor aColor, nsAutoString &aString);
// RangePaintInfo is used to paint ranges to offscreen buffers
struct RangePaintInfo {
@@ -759,18 +759,16 @@ PresShell::Init(nsIDocument* aDocument,
NS_PRECONDITION(aPresContext, "null ptr");
NS_PRECONDITION(aViewManager, "null ptr");
NS_PRECONDITION(!mDocument, "already initialized");
if (!aDocument || !aPresContext || !aViewManager || mDocument) {
return;
}
- mFramesToDirty.Init();
-
mDocument = aDocument;
NS_ADDREF(mDocument);
mViewManager = aViewManager;
// Create our frame constructor.
mFrameConstructor = new nsCSSFrameConstructor(mDocument, this, aStyleSet);
mFrameManager = mFrameConstructor;
@@ -6155,28 +6153,28 @@ PresShell::HandleEvent(nsIFrame *
uint32_t flags = 0;
if (aEvent->message == NS_TOUCH_START) {
flags |= INPUT_IGNORE_ROOT_SCROLL_FRAME;
nsTouchEvent* touchEvent = static_cast<nsTouchEvent*>(aEvent);
// if this is a continuing session, ensure that all these events are
// in the same document by taking the target of the events already in
// the capture list
nsCOMPtr<nsIContent> anyTarget;
- if (gCaptureTouchList.Count() > 0) {
- gCaptureTouchList.Enumerate(&FindAnyTarget, &anyTarget);
+ if (gCaptureTouchList->Count() > 0) {
+ gCaptureTouchList->Enumerate(&FindAnyTarget, &anyTarget);
} else {
gPreventMouseEvents = false;
}
for (int32_t i = touchEvent->touches.Length(); i; ) {
--i;
dom::Touch* touch = touchEvent->touches[i];
int32_t id = touch->Identifier();
- if (!gCaptureTouchList.Get(id, nullptr)) {
+ if (!gCaptureTouchList->Get(id, nullptr)) {
// find the target for this touch
eventPoint = nsLayoutUtils::GetEventCoordinatesRelativeTo(aEvent,
touch->mRefPoint,
frame);
nsIFrame* target = FindFrameTargetedByInputEvent(aEvent,
frame,
eventPoint,
flags);
@@ -6220,17 +6218,17 @@ PresShell::HandleEvent(nsIFrame *
frame = target;
}
} else {
// This touch is an old touch, we need to ensure that is not
// marked as changed and set its target correctly
touch->mChanged = false;
int32_t id = touch->Identifier();
- nsRefPtr<dom::Touch> oldTouch = gCaptureTouchList.GetWeak(id);
+ nsRefPtr<dom::Touch> oldTouch = gCaptureTouchList->GetWeak(id);
if (oldTouch) {
touch->SetTarget(oldTouch->mTarget);
}
}
}
} else {
eventPoint = nsLayoutUtils::GetEventCoordinatesRelativeTo(aEvent, frame);
}
@@ -6291,17 +6289,17 @@ PresShell::HandleEvent(nsIFrame *
nsTArray< nsRefPtr<dom::Touch> >& touches = touchEvent->touches;
for (uint32_t i = 0; i < touches.Length(); ++i) {
dom::Touch* touch = touches[i];
if (!touch) {
break;
}
nsRefPtr<dom::Touch> oldTouch =
- gCaptureTouchList.GetWeak(touch->Identifier());
+ gCaptureTouchList->GetWeak(touch->Identifier());
if (!oldTouch) {
break;
}
nsCOMPtr<nsIContent> content =
do_QueryInterface(oldTouch->Target());
if (!content) {
break;
@@ -6677,31 +6675,31 @@ PresShell::HandleEventInternal(nsEvent*
break;
case NS_TOUCH_START: {
nsTouchEvent* touchEvent = static_cast<nsTouchEvent*>(aEvent);
// if there is only one touch in this touchstart event, assume that it is
// the start of a new touch session and evict any old touches in the
// queue
if (touchEvent->touches.Length() == 1) {
nsTArray< nsRefPtr<dom::Touch> > touches;
- gCaptureTouchList.Enumerate(&AppendToTouchList, (void *)&touches);
+ gCaptureTouchList->Enumerate(&AppendToTouchList, (void *)&touches);
for (uint32_t i = 0; i < touches.Length(); ++i) {
EvictTouchPoint(touches[i]);
}
}
// Add any new touches to the queue
for (uint32_t i = 0; i < touchEvent->touches.Length(); ++i) {
dom::Touch* touch = touchEvent->touches[i];
int32_t id = touch->Identifier();
- if (!gCaptureTouchList.Get(id, nullptr)) {
+ if (!gCaptureTouchList->Get(id, nullptr)) {
// If it is not already in the queue, it is a new touch
touch->mChanged = true;
}
touch->mMessage = aEvent->message;
- gCaptureTouchList.Put(id, touch);
+ gCaptureTouchList->Put(id, touch);
}
break;
}
case NS_TOUCH_CANCEL:
case NS_TOUCH_END: {
// Remove the changed touches
// need to make sure we only remove touches that are ending here
nsTouchEvent* touchEvent = static_cast<nsTouchEvent*>(aEvent);
@@ -6710,62 +6708,62 @@ PresShell::HandleEventInternal(nsEvent*
dom::Touch* touch = touches[i];
if (!touch) {
continue;
}
touch->mMessage = aEvent->message;
touch->mChanged = true;
int32_t id = touch->Identifier();
- nsRefPtr<dom::Touch> oldTouch = gCaptureTouchList.GetWeak(id);
+ nsRefPtr<dom::Touch> oldTouch = gCaptureTouchList->GetWeak(id);
if (!oldTouch) {
continue;
}
nsCOMPtr<EventTarget> targetPtr = oldTouch->mTarget;
mCurrentEventContent = do_QueryInterface(targetPtr);
touch->SetTarget(targetPtr);
- gCaptureTouchList.Remove(id);
+ gCaptureTouchList->Remove(id);
}
// add any touches left in the touch list, but ensure changed=false
- gCaptureTouchList.Enumerate(&AppendToTouchList, (void *)&touches);
+ gCaptureTouchList->Enumerate(&AppendToTouchList, (void *)&touches);
break;
}
case NS_TOUCH_MOVE: {
// Check for touches that changed. Mark them add to queue
nsTouchEvent* touchEvent = static_cast<nsTouchEvent*>(aEvent);
nsTArray< nsRefPtr<dom::Touch> >& touches = touchEvent->touches;
bool haveChanged = false;
for (int32_t i = touches.Length(); i; ) {
--i;
dom::Touch* touch = touches[i];
if (!touch) {
continue;
}
int32_t id = touch->Identifier();
touch->mMessage = aEvent->message;
- nsRefPtr<dom::Touch> oldTouch = gCaptureTouchList.GetWeak(id);
+ nsRefPtr<dom::Touch> oldTouch = gCaptureTouchList->GetWeak(id);
if (!oldTouch) {
touches.RemoveElementAt(i);
continue;
}
if (!touch->Equals(oldTouch)) {
touch->mChanged = true;
haveChanged = true;
}
nsCOMPtr<dom::EventTarget> targetPtr = oldTouch->mTarget;
if (!targetPtr) {
touches.RemoveElementAt(i);
continue;
}
touch->SetTarget(targetPtr);
- gCaptureTouchList.Put(id, touch);
+ gCaptureTouchList->Put(id, touch);
// if we're moving from touchstart to touchmove for this touch
// we allow preventDefault to prevent mouse events
if (oldTouch->mMessage != touch->mMessage) {
touchIsNew = true;
}
}
// is nothing has changed, we should just return
if (!haveChanged) {
@@ -9308,28 +9306,27 @@ nsIPresShell::IsAccessibilityActive()
nsAccessibilityService*
nsIPresShell::AccService()
{
return GetAccService();
}
#endif
-static bool inited = false;
-
void nsIPresShell::InitializeStatics()
{
- NS_ASSERTION(!inited, "InitializeStatics called multiple times!");
- gCaptureTouchList.Init();
- inited = true;
+ NS_ASSERTION(!gCaptureTouchList, "InitializeStatics called multiple times!");
+ gCaptureTouchList = new nsRefPtrHashtable<nsUint32HashKey, dom::Touch>;
}
void nsIPresShell::ReleaseStatics()
{
- NS_ASSERTION(inited, "ReleaseStatics called without Initialize!");
+ NS_ASSERTION(gCaptureTouchList, "ReleaseStatics called without Initialize!");
+ delete gCaptureTouchList;
+ gCaptureTouchList = nullptr;
}
// Asks our docshell whether we're active.
void PresShell::QueryIsActive()
{
nsCOMPtr<nsISupports> container = mPresContext->GetContainer();
if (mDocument) {
nsIDocument* displayDoc = mDocument->GetDisplayDocument();
--- a/layout/base/nsRefreshDriver.cpp
+++ b/layout/base/nsRefreshDriver.cpp
@@ -682,19 +682,16 @@ nsRefreshDriver::nsRefreshDriver(nsPresC
mFrozen(false),
mThrottled(false),
mTestControllingRefreshes(false),
mViewManagerFlushIsPending(false),
mRequestedHighPrecision(false)
{
mMostRecentRefreshEpochTime = JS_Now();
mMostRecentRefresh = TimeStamp::Now();
-
- mRequests.Init();
- mStartTable.Init();
}
nsRefreshDriver::~nsRefreshDriver()
{
NS_ABORT_IF_FALSE(ObserverCount() == 0,
"observers should have unregistered");
NS_ABORT_IF_FALSE(!mActiveTimer, "timer should be gone");
--- a/layout/base/nsRefreshDriver.h
+++ b/layout/base/nsRefreshDriver.h
@@ -229,17 +229,16 @@ public:
static int32_t DefaultInterval();
private:
typedef nsTObserverArray<nsARefreshObserver*> ObserverArray;
typedef nsTHashtable<nsISupportsHashKey> RequestTable;
struct ImageStartData {
ImageStartData()
{
- mEntries.Init();
}
mozilla::Maybe<mozilla::TimeStamp> mStartTime;
RequestTable mEntries;
};
typedef nsClassHashtable<nsUint32HashKey, ImageStartData> ImageStartTable;
void Tick(int64_t aNowEpoch, mozilla::TimeStamp aNowTime);
--- a/layout/generic/TextOverflow.cpp
+++ b/layout/generic/TextOverflow.cpp
@@ -567,18 +567,17 @@ TextOverflow::ProcessLine(const nsDispla
NS_ASSERTION(mLeft.mStyle->mType != NS_STYLE_TEXT_OVERFLOW_CLIP ||
mRight.mStyle->mType != NS_STYLE_TEXT_OVERFLOW_CLIP,
"TextOverflow with 'clip' for both sides");
mLeft.Reset();
mLeft.mActive = mLeft.mStyle->mType != NS_STYLE_TEXT_OVERFLOW_CLIP;
mRight.Reset();
mRight.mActive = mRight.mStyle->mType != NS_STYLE_TEXT_OVERFLOW_CLIP;
- FrameHashtable framesToHide;
- framesToHide.Init(100);
+ FrameHashtable framesToHide(100);
AlignmentEdges alignmentEdges;
ExamineLineFrames(aLine, &framesToHide, &alignmentEdges);
bool needLeft = mLeft.IsNeeded();
bool needRight = mRight.IsNeeded();
if (!needLeft && !needRight) {
return;
}
NS_ASSERTION(mLeft.mStyle->mType != NS_STYLE_TEXT_OVERFLOW_CLIP ||
--- a/layout/generic/nsFloatManager.cpp
+++ b/layout/generic/nsFloatManager.cpp
@@ -326,19 +326,18 @@ nsFloatManager::RemoveTrailingRegions(ns
{
if (!aFrameList) {
return NS_OK;
}
// This could be a good bit simpler if we could guarantee that the
// floats given were at the end of our list, so we could just search
// for the head of aFrameList. (But we can't;
// layout/reftests/bugs/421710-1.html crashes.)
- nsTHashtable<nsPtrHashKey<nsIFrame> > frameSet;
+ nsTHashtable<nsPtrHashKey<nsIFrame> > frameSet(1);
- frameSet.Init(1);
for (nsIFrame* f = aFrameList; f; f = f->GetNextSibling()) {
frameSet.PutEntry(f);
}
uint32_t newLength = mFloats.Length();
while (newLength > 0) {
if (!frameSet.Contains(mFloats[newLength - 1].mFrame)) {
break;
--- a/layout/generic/nsLineBox.h
+++ b/layout/generic/nsLineBox.h
@@ -336,21 +336,20 @@ private:
* for each frame on this line, but in a optimized way.
*/
void NoteFramesMovedFrom(nsLineBox* aFromLine);
void SwitchToHashtable()
{
MOZ_ASSERT(!mFlags.mHasHashedFrames);
uint32_t count = GetChildCount();
- mFrames = new nsTHashtable< nsPtrHashKey<nsIFrame> >();
mFlags.mHasHashedFrames = 1;
uint32_t minSize =
std::max(kMinChildCountForHashtable, uint32_t(PL_DHASH_MIN_SIZE));
- mFrames->Init(std::max(count, minSize));
+ mFrames = new nsTHashtable< nsPtrHashKey<nsIFrame> >(std::max(count, minSize));
for (nsIFrame* f = mFirstChild; count-- > 0; f = f->GetNextSibling()) {
mFrames->PutEntry(f);
}
}
void SwitchToCounter() {
MOZ_ASSERT(mFlags.mHasHashedFrames);
uint32_t count = GetChildCount();
delete mFrames;
--- a/layout/inspector/src/nsFontFaceList.cpp
+++ b/layout/inspector/src/nsFontFaceList.cpp
@@ -5,17 +5,16 @@
#include "nsFontFaceList.h"
#include "nsFontFace.h"
#include "nsFontFaceLoader.h"
#include "nsIFrame.h"
#include "gfxFont.h"
nsFontFaceList::nsFontFaceList()
{
- mFontFaces.Init();
}
nsFontFaceList::~nsFontFaceList()
{
}
////////////////////////////////////////////////////////////////////////
// nsISupports
--- a/layout/style/ImageLoader.cpp
+++ b/layout/style/ImageLoader.cpp
@@ -67,20 +67,16 @@ ImageLoader::DropDocumentReference()
mImages.EnumerateEntries(&ClearImageHashSet, mDocument);
mDocument = nullptr;
}
void
ImageLoader::AssociateRequestToFrame(imgIRequest* aRequest,
nsIFrame* aFrame)
{
- MOZ_ASSERT(mRequestToFrameMap.IsInitialized() &&
- mFrameToRequestMap.IsInitialized() &&
- mImages.IsInitialized());
-
nsCOMPtr<imgINotificationObserver> observer;
aRequest->GetNotificationObserver(getter_AddRefs(observer));
if (!observer) {
// The request has already been canceled, so ignore it. This is ok because
// we're not going to get any more notifications from a canceled request.
return;
}
@@ -167,20 +163,16 @@ ImageLoader::DeregisterCSSImage(ImageLoa
void
ImageLoader::DisassociateRequestFromFrame(imgIRequest* aRequest,
nsIFrame* aFrame)
{
FrameSet* frameSet = nullptr;
RequestSet* requestSet = nullptr;
- MOZ_ASSERT(mRequestToFrameMap.IsInitialized() &&
- mFrameToRequestMap.IsInitialized() &&
- mImages.IsInitialized());
-
#ifdef DEBUG
{
nsCOMPtr<imgINotificationObserver> observer;
aRequest->GetNotificationObserver(getter_AddRefs(observer));
MOZ_ASSERT(!observer || observer == this);
}
#endif
--- a/layout/style/ImageLoader.h
+++ b/layout/style/ImageLoader.h
@@ -30,20 +30,16 @@ class ImageLoader MOZ_FINAL : public img
public:
typedef mozilla::css::ImageValue Image;
ImageLoader(nsIDocument* aDocument)
: mDocument(aDocument),
mInClone(false)
{
MOZ_ASSERT(mDocument);
-
- mRequestToFrameMap.Init();
- mFrameToRequestMap.Init();
- mImages.Init();
}
NS_DECL_ISUPPORTS
NS_DECL_IMGIONLOADBLOCKER
NS_DECL_IMGINOTIFICATIONOBSERVER
void DropDocumentReference();
--- a/layout/style/Loader.cpp
+++ b/layout/style/Loader.cpp
@@ -529,33 +529,33 @@ Loader::Loader(nsIDocument* aDocument)
nsCOMPtr<nsIDOMDocument> domDoc = do_QueryInterface(mDocument);
if (domDoc) {
domDoc->GetPreferredStyleSheetSet(mPreferredSheet);
}
}
Loader::~Loader()
{
- NS_ASSERTION((!mLoadingDatas.IsInitialized()) || mLoadingDatas.Count() == 0,
+ NS_ASSERTION(!mSheets || mSheets->mLoadingDatas.Count() == 0,
"How did we get destroyed when there are loading data?");
- NS_ASSERTION((!mPendingDatas.IsInitialized()) || mPendingDatas.Count() == 0,
+ NS_ASSERTION(!mSheets || mSheets->mPendingDatas.Count() == 0,
"How did we get destroyed when there are pending data?");
// Note: no real need to revoke our stylesheet loaded events -- they
// hold strong references to us, so if we're going away that means
// they're all done.
}
void
Loader::DropDocumentReference(void)
{
mDocument = nullptr;
// Flush out pending datas just so we don't leak by accident. These
// loads should short-circuit through the mDocument check in
// LoadSheet and just end up in SheetComplete immediately
- if (mPendingDatas.IsInitialized()) {
+ if (mSheets) {
StartAlternateLoads();
}
}
static PLDHashOperator
CollectNonAlternates(URIPrincipalAndCORSModeHashKey *aKey,
SheetLoadData* &aData,
void* aClosure)
@@ -587,19 +587,19 @@ Loader::SetPreferredSheet(const nsAStrin
NS_ASSERTION(currentPreferred.Equals(aTitle),
"Unexpected argument to SetPreferredSheet");
}
#endif
mPreferredSheet = aTitle;
// start any pending alternates that aren't alternates anymore
- if (mPendingDatas.IsInitialized()) {
- LoadDataArray arr(mPendingDatas.Count());
- mPendingDatas.Enumerate(CollectNonAlternates, &arr);
+ if (mSheets) {
+ LoadDataArray arr(mSheets->mPendingDatas.Count());
+ mSheets->mPendingDatas.Enumerate(CollectNonAlternates, &arr);
mDatasToNotifyOn += arr.Length();
for (uint32_t i = 0; i < arr.Length(); ++i) {
--mDatasToNotifyOn;
LoadSheet(arr[i], eSheetNeedsParser);
}
}
@@ -987,23 +987,23 @@ Loader::RemoveEntriesWithURI(URIPrincipa
return PL_DHASH_REMOVE;
}
return PL_DHASH_NEXT;
}
nsresult
Loader::ObsoleteSheet(nsIURI* aURI)
{
- if (!mCompleteSheets.IsInitialized()) {
+ if (!mSheets) {
return NS_OK;
}
if (!aURI) {
return NS_ERROR_INVALID_ARG;
}
- mCompleteSheets.Enumerate(RemoveEntriesWithURI, aURI);
+ mSheets->mCompleteSheets.Enumerate(RemoveEntriesWithURI, aURI);
return NS_OK;
}
/**
* CheckLoadAllowed will return success if the load is allowed,
* failure otherwise.
*
* @param aSourcePrincipal the principal of the node or document or parent
@@ -1074,24 +1074,18 @@ Loader::CreateSheet(nsIURI* aURI,
const nsAString& aTitle,
StyleSheetState& aSheetState,
bool *aIsAlternate,
nsCSSStyleSheet** aSheet)
{
LOG(("css::Loader::CreateSheet"));
NS_PRECONDITION(aSheet, "Null out param!");
- if (!mCompleteSheets.IsInitialized()) {
- mCompleteSheets.Init();
- }
- if (!mLoadingDatas.IsInitialized()) {
- mLoadingDatas.Init();
- }
- if (!mPendingDatas.IsInitialized()) {
- mPendingDatas.Init();
+ if (!mSheets) {
+ mSheets = new Sheets();
}
*aSheet = nullptr;
aSheetState = eSheetStateUnknown;
// Check the alternate state before doing anything else, because it
// can mess with our hashtables.
*aIsAlternate = IsAlternate(aTitle, aHasAlternateRel);
@@ -1113,17 +1107,17 @@ Loader::CreateSheet(nsIURI* aURI,
}
#endif
bool fromCompleteSheets = false;
if (!sheet) {
// Then our per-document complete sheets.
URIPrincipalAndCORSModeHashKey key(aURI, aLoaderPrincipal, aCORSMode);
- mCompleteSheets.Get(&key, getter_AddRefs(sheet));
+ mSheets->mCompleteSheets.Get(&key, getter_AddRefs(sheet));
LOG((" From completed: %p", sheet.get()));
fromCompleteSheets = !!sheet;
}
if (sheet) {
// This sheet came from the XUL cache or our per-document hashtable; it
// better be a complete sheet.
@@ -1139,17 +1133,17 @@ Loader::CreateSheet(nsIURI* aURI,
}
}
// Then loading sheets
if (!sheet && !aSyncLoad) {
aSheetState = eSheetLoading;
SheetLoadData* loadData = nullptr;
URIPrincipalAndCORSModeHashKey key(aURI, aLoaderPrincipal, aCORSMode);
- mLoadingDatas.Get(&key, &loadData);
+ mSheets->mLoadingDatas.Get(&key, &loadData);
if (loadData) {
sheet = loadData->mSheet;
LOG((" From loading: %p", sheet.get()));
#ifdef DEBUG
bool debugEqual;
NS_ASSERTION((!aLoaderPrincipal && !loadData->mLoaderPrincipal) ||
(aLoaderPrincipal && loadData->mLoaderPrincipal &&
@@ -1159,17 +1153,17 @@ Loader::CreateSheet(nsIURI* aURI,
"Principals should be the same");
#endif
}
// Then alternate sheets
if (!sheet) {
aSheetState = eSheetPending;
loadData = nullptr;
- mPendingDatas.Get(&key, &loadData);
+ mSheets->mPendingDatas.Get(&key, &loadData);
if (loadData) {
sheet = loadData->mSheet;
LOG((" From pending: %p", sheet.get()));
#ifdef DEBUG
bool debugEqual;
NS_ASSERTION((!aLoaderPrincipal && !loadData->mLoaderPrincipal) ||
(aLoaderPrincipal && loadData->mLoaderPrincipal &&
@@ -1194,17 +1188,17 @@ Loader::CreateSheet(nsIURI* aURI,
!sheet->GetOwnerNode() && !sheet->GetParentSheet()) {
// The sheet we're cloning isn't actually referenced by
// anyone. Replace it in the cache, so that if our CSSOM is
// later modified we don't end up with two copies of our inner
// hanging around.
URIPrincipalAndCORSModeHashKey key(aURI, aLoaderPrincipal, aCORSMode);
NS_ASSERTION((*aSheet)->IsComplete(),
"Should only be caching complete sheets");
- mCompleteSheets.Put(&key, *aSheet);
+ mSheets->mCompleteSheets.Put(&key, *aSheet);
}
}
}
if (!*aSheet) {
aSheetState = eSheetNeedsParser;
nsIURI *sheetURI;
nsCOMPtr<nsIURI> baseURI;
@@ -1404,17 +1398,17 @@ Loader::LoadSheet(SheetLoadData* aLoadDa
{
LOG(("css::Loader::LoadSheet"));
NS_PRECONDITION(aLoadData, "Need a load data");
NS_PRECONDITION(aLoadData->mURI, "Need a URI to load");
NS_PRECONDITION(aLoadData->mSheet, "Need a sheet to load into");
NS_PRECONDITION(aSheetState != eSheetComplete, "Why bother?");
NS_PRECONDITION(!aLoadData->mUseSystemPrincipal || aLoadData->mSyncLoad,
"Shouldn't use system principal for async loads");
- NS_ASSERTION(mLoadingDatas.IsInitialized(), "mLoadingDatas should be initialized by now.");
+ NS_ASSERTION(mSheets, "mLoadingDatas should be initialized by now.");
LOG_URI(" Load from: '%s'", aLoadData->mURI);
nsresult rv = NS_OK;
if (!mDocument && !aLoadData->mIsNonDocumentSheet) {
// No point starting the load; just release all the data and such.
LOG_WARN((" No document and not non-document sheet; pre-dropping load"));
@@ -1468,42 +1462,42 @@ Loader::LoadSheet(SheetLoadData* aLoadDa
}
SheetLoadData* existingData = nullptr;
URIPrincipalAndCORSModeHashKey key(aLoadData->mURI,
aLoadData->mLoaderPrincipal,
aLoadData->mSheet->GetCORSMode());
if (aSheetState == eSheetLoading) {
- mLoadingDatas.Get(&key, &existingData);
+ mSheets->mLoadingDatas.Get(&key, &existingData);
NS_ASSERTION(existingData, "CreateSheet lied about the state");
}
else if (aSheetState == eSheetPending){
- mPendingDatas.Get(&key, &existingData);
+ mSheets->mPendingDatas.Get(&key, &existingData);
NS_ASSERTION(existingData, "CreateSheet lied about the state");
}
if (existingData) {
LOG((" Glomming on to existing load"));
SheetLoadData* data = existingData;
while (data->mNext) {
data = data->mNext;
}
data->mNext = aLoadData; // transfer ownership
if (aSheetState == eSheetPending && !aLoadData->mWasAlternate) {
// Kick the load off; someone cares about it right away
#ifdef DEBUG
SheetLoadData* removedData;
- NS_ASSERTION(mPendingDatas.Get(&key, &removedData) &&
+ NS_ASSERTION(mSheets->mPendingDatas.Get(&key, &removedData) &&
removedData == existingData,
"Bad pending table.");
#endif
- mPendingDatas.Remove(&key);
+ mSheets->mPendingDatas.Remove(&key);
LOG((" Forcing load of pending data"));
return LoadSheet(existingData, eSheetNeedsParser);
}
// All done here; once the load completes we'll be marked complete
// automatically
return NS_OK;
}
@@ -1619,17 +1613,17 @@ Loader::LoadSheet(SheetLoadData* aLoadDa
#endif
if (NS_FAILED(rv)) {
LOG_ERROR((" Failed to create stream loader"));
SheetComplete(aLoadData, rv);
return rv;
}
- mLoadingDatas.Put(&key, aLoadData);
+ mSheets->mLoadingDatas.Put(&key, aLoadData);
aLoadData->mIsLoading = true;
return NS_OK;
}
/**
* ParseSheet handles parsing the data stream. The main idea here is
* to push the current load data onto the parse stack before letting
@@ -1718,49 +1712,49 @@ Loader::SheetComplete(SheetLoadData* aLo
while (iter.HasMore()) {
obs = iter.GetNext();
LOG((" Notifying global observer 0x%x for data 0x%s. wasAlternate: %d",
obs.get(), data, data->mWasAlternate));
obs->StyleSheetLoaded(data->mSheet, data->mWasAlternate, aStatus);
}
}
- if (mLoadingDatas.Count() == 0 && mPendingDatas.Count() > 0) {
+ if (mSheets->mLoadingDatas.Count() == 0 && mSheets->mPendingDatas.Count() > 0) {
LOG((" No more loading sheets; starting alternates"));
StartAlternateLoads();
}
}
void
Loader::DoSheetComplete(SheetLoadData* aLoadData, nsresult aStatus,
LoadDataArray& aDatasToNotify)
{
LOG(("css::Loader::DoSheetComplete"));
NS_PRECONDITION(aLoadData, "Must have a load data!");
NS_PRECONDITION(aLoadData->mSheet, "Must have a sheet");
- NS_ASSERTION(mLoadingDatas.IsInitialized(),"mLoadingDatas should be initialized by now.");
+ NS_ASSERTION(mSheets, "mLoadingDatas should be initialized by now.");
LOG(("Load completed, status: 0x%x", aStatus));
// Twiddle the hashtables
if (aLoadData->mURI) {
LOG_URI(" Finished loading: '%s'", aLoadData->mURI);
// Remove the data from the list of loading datas
if (aLoadData->mIsLoading) {
URIPrincipalAndCORSModeHashKey key(aLoadData->mURI,
aLoadData->mLoaderPrincipal,
aLoadData->mSheet->GetCORSMode());
#ifdef DEBUG
SheetLoadData *loadingData;
- NS_ASSERTION(mLoadingDatas.Get(&key, &loadingData) &&
+ NS_ASSERTION(mSheets->mLoadingDatas.Get(&key, &loadingData) &&
loadingData == aLoadData,
"Bad loading table");
#endif
- mLoadingDatas.Remove(&key);
+ mSheets->mLoadingDatas.Remove(&key);
aLoadData->mIsLoading = false;
}
}
// Go through and deal with the whole linked list.
SheetLoadData* data = aLoadData;
while (data) {
if (!data->mSheetAlreadyComplete) {
@@ -1831,17 +1825,17 @@ Loader::DoSheetComplete(SheetLoadData* a
}
else {
#endif
URIPrincipalAndCORSModeHashKey key(aLoadData->mURI,
aLoadData->mLoaderPrincipal,
aLoadData->mSheet->GetCORSMode());
NS_ASSERTION(sheet->IsComplete(),
"Should only be caching complete sheets");
- mCompleteSheets.Put(&key, sheet);
+ mSheets->mCompleteSheets.Put(&key, sheet);
#ifdef MOZ_XUL
}
#endif
}
NS_RELEASE(aLoadData); // this will release parents and siblings and all that
}
@@ -1980,22 +1974,22 @@ Loader::LoadStyleLink(nsIContent* aEleme
// Now we need to actually load it
SheetLoadData* data = new SheetLoadData(this, aTitle, aURL, sheet,
owningElement, *aIsAlternate,
aObserver, principal);
NS_ADDREF(data);
// If we have to parse and it's an alternate non-inline, defer it
- if (aURL && state == eSheetNeedsParser && mLoadingDatas.Count() != 0 &&
+ if (aURL && state == eSheetNeedsParser && mSheets->mLoadingDatas.Count() != 0 &&
*aIsAlternate) {
LOG((" Deferring alternate sheet load"));
URIPrincipalAndCORSModeHashKey key(data->mURI, data->mLoaderPrincipal,
data->mSheet->GetCORSMode());
- mPendingDatas.Put(&key, data);
+ mSheets->mPendingDatas.Put(&key, data);
data->mMustNotify = true;
return NS_OK;
}
// Load completion will free the data
rv = LoadSheet(data, state);
NS_ENSURE_SUCCESS(rv, rv);
@@ -2350,26 +2344,26 @@ StopLoadingSheetCallback(URIPrincipalAnd
return PL_DHASH_REMOVE;
}
nsresult
Loader::Stop()
{
uint32_t pendingCount =
- mPendingDatas.IsInitialized() ? mPendingDatas.Count() : 0;
+ mSheets ? mSheets->mPendingDatas.Count() : 0;
uint32_t loadingCount =
- mLoadingDatas.IsInitialized() ? mLoadingDatas.Count() : 0;
+ mSheets ? mSheets->mLoadingDatas.Count() : 0;
LoadDataArray arr(pendingCount + loadingCount + mPostedEvents.Length());
if (pendingCount) {
- mPendingDatas.Enumerate(StopLoadingSheetCallback, &arr);
+ mSheets->mPendingDatas.Enumerate(StopLoadingSheetCallback, &arr);
}
if (loadingCount) {
- mLoadingDatas.Enumerate(StopLoadingSheetCallback, &arr);
+ mSheets->mLoadingDatas.Enumerate(StopLoadingSheetCallback, &arr);
}
uint32_t i;
for (i = 0; i < mPostedEvents.Length(); ++i) {
SheetLoadData* data = mPostedEvents[i];
data->mIsCancelled = true;
if (arr.AppendElement(data)) {
// SheetComplete() calls Release(), so give this an extra ref.
@@ -2391,18 +2385,18 @@ Loader::Stop()
}
return NS_OK;
}
bool
Loader::HasPendingLoads()
{
return
- (mLoadingDatas.IsInitialized() && mLoadingDatas.Count() != 0) ||
- (mPendingDatas.IsInitialized() && mPendingDatas.Count() != 0) ||
+ (mSheets && mSheets->mLoadingDatas.Count() != 0) ||
+ (mSheets && mSheets->mPendingDatas.Count() != 0) ||
mPostedEvents.Length() != 0 ||
mDatasToNotifyOn != 0;
}
nsresult
Loader::AddObserver(nsICSSLoaderObserver* aObserver)
{
NS_PRECONDITION(aObserver, "Must have observer");
@@ -2426,19 +2420,19 @@ CollectLoadDatas(URIPrincipalAndCORSMode
{
static_cast<Loader::LoadDataArray*>(aClosure)->AppendElement(aData);
return PL_DHASH_REMOVE;
}
void
Loader::StartAlternateLoads()
{
- NS_PRECONDITION(mPendingDatas.IsInitialized(), "Don't call me!");
- LoadDataArray arr(mPendingDatas.Count());
- mPendingDatas.Enumerate(CollectLoadDatas, &arr);
+ NS_PRECONDITION(mSheets, "Don't call me!");
+ LoadDataArray arr(mSheets->mPendingDatas.Count());
+ mSheets->mPendingDatas.Enumerate(CollectLoadDatas, &arr);
mDatasToNotifyOn += arr.Length();
for (uint32_t i = 0; i < arr.Length(); ++i) {
--mDatasToNotifyOn;
LoadSheet(arr[i], eSheetNeedsParser);
}
}
@@ -2452,26 +2446,26 @@ TraverseSheet(URIPrincipalAndCORSModeHas
NS_CYCLE_COLLECTION_NOTE_EDGE_NAME(*cb, "Sheet cache nsCSSLoader");
cb->NoteXPCOMChild(NS_ISUPPORTS_CAST(nsIStyleSheet*, aSheet));
return PL_DHASH_NEXT;
}
void
Loader::TraverseCachedSheets(nsCycleCollectionTraversalCallback& cb)
{
- if (mCompleteSheets.IsInitialized()) {
- mCompleteSheets.EnumerateRead(TraverseSheet, &cb);
+ if (mSheets) {
+ mSheets->mCompleteSheets.EnumerateRead(TraverseSheet, &cb);
}
}
void
Loader::UnlinkCachedSheets()
{
- if (mCompleteSheets.IsInitialized()) {
- mCompleteSheets.Clear();
+ if (mSheets) {
+ mSheets->mCompleteSheets.Clear();
}
}
struct SheetMemoryCounter {
size_t size;
mozilla::MallocSizeOf mallocSizeOf;
};
@@ -2491,18 +2485,19 @@ CountSheetMemory(URIPrincipalAndCORSMode
return aSheet->SizeOfIncludingThis(aMallocSizeOf);
}
size_t
Loader::SizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf) const
{
size_t s = aMallocSizeOf(this);
- s += mCompleteSheets.SizeOfExcludingThis(CountSheetMemory, aMallocSizeOf);
-
+ if (mSheets) {
+ s += mSheets->mCompleteSheets.SizeOfExcludingThis(CountSheetMemory, aMallocSizeOf);
+ }
s += mObservers.SizeOfExcludingThis(aMallocSizeOf);
// Measurement of the following members may be added later if DMD finds it is
// worthwhile:
// - mLoadingDatas: transient, and should be small
// - mPendingDatas: transient, and should be small
// - mParsingDatas: transient, and should be small
// - mPostedEvents: transient, and should be small
--- a/layout/style/Loader.h
+++ b/layout/style/Loader.h
@@ -470,22 +470,25 @@ private:
void SheetComplete(SheetLoadData* aLoadData, nsresult aStatus);
// The guts of SheetComplete. This may be called recursively on parent datas
// or datas that had glommed on to a single load. The array is there so load
// datas whose observers need to be notified can be added to it.
void DoSheetComplete(SheetLoadData* aLoadData, nsresult aStatus,
LoadDataArray& aDatasToNotify);
- nsRefPtrHashtable<URIPrincipalAndCORSModeHashKey, nsCSSStyleSheet>
- mCompleteSheets;
- nsDataHashtable<URIPrincipalAndCORSModeHashKey, SheetLoadData*>
- mLoadingDatas; // weak refs
- nsDataHashtable<URIPrincipalAndCORSModeHashKey, SheetLoadData*>
- mPendingDatas; // weak refs
+ struct Sheets {
+ nsRefPtrHashtable<URIPrincipalAndCORSModeHashKey, nsCSSStyleSheet>
+ mCompleteSheets;
+ nsDataHashtable<URIPrincipalAndCORSModeHashKey, SheetLoadData*>
+ mLoadingDatas; // weak refs
+ nsDataHashtable<URIPrincipalAndCORSModeHashKey, SheetLoadData*>
+ mPendingDatas; // weak refs
+ };
+ nsAutoPtr<Sheets> mSheets;
// We're not likely to have many levels of @import... But likely to have
// some. Allocate some storage, what the hell.
nsAutoTArray<SheetLoadData*, 8> mParsingDatas;
// The array of posted stylesheet loaded events (SheetLoadDatas) we have.
// Note that these are rare.
LoadDataArray mPostedEvents;
--- a/layout/style/nsAnimationManager.cpp
+++ b/layout/style/nsAnimationManager.cpp
@@ -692,19 +692,17 @@ struct KeyframeDataComparator {
}
bool LessThan(const KeyframeData& A, const KeyframeData& B) const {
return A.mKey < B.mKey || (A.mKey == B.mKey && A.mIndex < B.mIndex);
}
};
class ResolvedStyleCache {
public:
- ResolvedStyleCache() {
- mCache.Init(16); // FIXME: make infallible!
- }
+ ResolvedStyleCache() : mCache(16) {}
nsStyleContext* Get(nsPresContext *aPresContext,
nsStyleContext *aParentStyleContext,
nsCSSKeyframeRule *aKeyframe);
private:
nsRefPtrHashtable<nsPtrHashKey<nsCSSKeyframeRule>, nsStyleContext> mCache;
};
--- a/layout/style/nsCSSRuleProcessor.cpp
+++ b/layout/style/nsCSSRuleProcessor.cpp
@@ -916,16 +916,17 @@ static const RuleHashTableOps AtomSelect
//--------------------------------
struct RuleCascadeData {
RuleCascadeData(nsIAtom *aMedium, bool aQuirksMode)
: mRuleHash(aQuirksMode),
mStateSelectors(),
mSelectorDocumentStates(0),
+ mKeyframesRuleTable(16),
mCacheKey(aMedium),
mNext(nullptr),
mQuirksMode(aQuirksMode)
{
// mAttributeSelectors is matching on the attribute _name_, not the value,
// and we case-fold names at parse-time, so this is a case-sensitive match.
PL_DHashTableInit(&mAttributeSelectors, &AtomSelector_CSOps, nullptr,
sizeof(AtomSelectorEntry), 16);
@@ -939,17 +940,16 @@ struct RuleCascadeData {
aQuirksMode ? &AtomSelector_CIOps.ops :
&AtomSelector_CSOps,
nullptr, sizeof(AtomSelectorEntry), 16);
memset(mPseudoElementRuleHashes, 0, sizeof(mPseudoElementRuleHashes));
#ifdef MOZ_XUL
PL_DHashTableInit(&mXULTreeRules, &RuleHash_TagTable_Ops, nullptr,
sizeof(RuleHashTagTableEntry), 16);
#endif
- mKeyframesRuleTable.Init(16); // FIXME: make infallible!
}
~RuleCascadeData()
{
PL_DHashTableFinish(&mAttributeSelectors);
PL_DHashTableFinish(&mAnonBoxRules);
PL_DHashTableFinish(&mIdSelectors);
PL_DHashTableFinish(&mClassSelectors);
--- a/layout/style/nsCSSValue.cpp
+++ b/layout/style/nsCSSValue.cpp
@@ -1805,18 +1805,16 @@ css::ImageValue::ImageValue(nsIURI* aURI
// NB: If aDocument is not the original document, we may not be able to load
// images from aDocument. Instead we do the image load from the original doc
// and clone it to aDocument.
nsIDocument* loadingDoc = aDocument->GetOriginalDocument();
if (!loadingDoc) {
loadingDoc = aDocument;
}
- mRequests.Init();
-
loadingDoc->StyleImageLoader()->LoadImage(aURI, aOriginPrincipal, aReferrer,
this);
if (loadingDoc != aDocument) {
aDocument->StyleImageLoader()->MaybeRegisterCSSImage(this);
}
}
--- a/layout/style/nsFontFaceLoader.cpp
+++ b/layout/style/nsFontFaceLoader.cpp
@@ -283,17 +283,16 @@ nsFontFaceLoader::CheckLoadAllowed(nsIPr
return NS_OK;
}
nsUserFontSet::nsUserFontSet(nsPresContext *aContext)
: mPresContext(aContext)
{
NS_ASSERTION(mPresContext, "null context passed to nsUserFontSet");
- mLoaders.Init();
}
nsUserFontSet::~nsUserFontSet()
{
NS_ASSERTION(mLoaders.Count() == 0, "mLoaders should have been emptied");
}
static PLDHashOperator DestroyIterator(nsPtrHashKey<nsFontFaceLoader>* aKey,
--- a/layout/style/nsHTMLCSSStyleSheet.cpp
+++ b/layout/style/nsHTMLCSSStyleSheet.cpp
@@ -37,17 +37,16 @@ ClearAttrCache(const nsAString& aKey, Mi
return PL_DHASH_REMOVE;
}
} // anonymous namespace
nsHTMLCSSStyleSheet::nsHTMLCSSStyleSheet()
{
- mCachedStyleAttrs.Init();
}
nsHTMLCSSStyleSheet::~nsHTMLCSSStyleSheet()
{
// We may go away before all of our cached style attributes do,
// so clean up any that are left.
mCachedStyleAttrs.Enumerate(ClearAttrCache, nullptr);
}
--- a/layout/style/nsStyleSet.cpp
+++ b/layout/style/nsStyleSet.cpp
@@ -298,17 +298,16 @@ static void
SortStyleSheetsByScope(nsTArray<nsCSSStyleSheet*>& aSheets)
{
uint32_t n = aSheets.Length();
if (n == 1) {
return;
}
ScopeDepthCache cache;
- cache.Init();
nsTArray<ScopedSheetOrder> sheets;
sheets.SetLength(n);
// For each sheet, record the depth of its scope element and its original
// document order.
for (uint32_t i = 0; i < n; i++) {
sheets[i].mSheet = aSheets[i];
--- a/layout/svg/nsSVGEffects.cpp
+++ b/layout/svg/nsSVGEffects.cpp
@@ -417,17 +417,16 @@ GetEffectPropertyForURI(nsIURI *aURI, ns
if (!aURI)
return nullptr;
FrameProperties props = aFrame->Properties();
nsSVGEffects::URIObserverHashtable *hashtable =
static_cast<nsSVGEffects::URIObserverHashtable*>(props.Get(aProperty));
if (!hashtable) {
hashtable = new nsSVGEffects::URIObserverHashtable();
- hashtable->Init();
props.Set(aProperty, hashtable);
}
nsSVGRenderingObserver* prop =
static_cast<nsSVGRenderingObserver*>(hashtable->GetWeak(aURI));
if (!prop) {
bool watchImage = aProperty == nsSVGEffects::BackgroundImageProperty();
prop = aCreate(aURI, aFrame, watchImage);
hashtable->Put(aURI, prop);
--- a/layout/svg/nsSVGEffects.h
+++ b/layout/svg/nsSVGEffects.h
@@ -224,19 +224,20 @@ protected:
*
* InvalidateAll must be called before this object is destroyed, i.e.
* before the referenced frame is destroyed. This should normally happen
* via nsSVGContainerFrame::RemoveFrame, since only frames in the frame
* tree should be referenced.
*/
class nsSVGRenderingObserverList {
public:
- nsSVGRenderingObserverList() {
+ nsSVGRenderingObserverList()
+ : mObservers(5)
+ {
MOZ_COUNT_CTOR(nsSVGRenderingObserverList);
- mObservers.Init(5);
}
~nsSVGRenderingObserverList() {
InvalidateAll();
MOZ_COUNT_DTOR(nsSVGRenderingObserverList);
}
void Add(nsSVGRenderingObserver* aObserver)
--- a/layout/svg/nsSVGFilterInstance.cpp
+++ b/layout/svg/nsSVGFilterInstance.cpp
@@ -179,18 +179,17 @@ nsSVGFilterInstance::BuildPrimitives()
if (!primitive)
continue;
PrimitiveInfo* info = mPrimitives.AppendElement();
info->mFE = primitive;
}
// Now fill in all the links
- nsTHashtable<ImageAnalysisEntry> imageTable;
- imageTable.Init(10);
+ nsTHashtable<ImageAnalysisEntry> imageTable(10);
for (uint32_t i = 0; i < mPrimitives.Length(); ++i) {
PrimitiveInfo* info = &mPrimitives[i];
nsSVGFE* filter = info->mFE;
nsAutoTArray<nsSVGStringInfo,2> sources;
filter->GetSourceImageNames(sources);
for (uint32_t j=0; j<sources.Length(); ++j) {
--- a/layout/svg/nsSVGGlyphFrame.h
+++ b/layout/svg/nsSVGGlyphFrame.h
@@ -41,19 +41,17 @@ struct SVGTextObjectPaint : public gfxTe
void SetFillOpacity(float aOpacity) { mFillOpacity = aOpacity; }
float GetFillOpacity() MOZ_OVERRIDE { return mFillOpacity; }
void SetStrokeOpacity(float aOpacity) { mStrokeOpacity = aOpacity; }
float GetStrokeOpacity() MOZ_OVERRIDE { return mStrokeOpacity; }
struct Paint {
- Paint() {
- mPatternCache.Init();
- }
+ Paint() {}
void SetPaintServer(nsIFrame *aFrame, const gfxMatrix& aContextMatrix,
nsSVGPaintServerFrame *aPaintServerFrame) {
mPaintType = eStyleSVGPaintType_Server;
mPaintDefinition.mPaintServerFrame = aPaintServerFrame;
mFrame = aFrame;
mContextMatrix = aContextMatrix;
}
--- a/layout/svg/nsSVGOuterSVGFrame.cpp
+++ b/layout/svg/nsSVGOuterSVGFrame.cpp
@@ -81,36 +81,36 @@ nsSVGMutationObserver::AttributeChanged(
//----------------------------------------------------------------------
// Implementation helpers
void
nsSVGOuterSVGFrame::RegisterForeignObject(nsSVGForeignObjectFrame* aFrame)
{
NS_ASSERTION(aFrame, "Who on earth is calling us?!");
- if (!mForeignObjectHash.IsInitialized()) {
- mForeignObjectHash.Init();
+ if (!mForeignObjectHash) {
+ mForeignObjectHash = new nsTHashtable<nsPtrHashKey<nsSVGForeignObjectFrame> >();
}
- NS_ASSERTION(!mForeignObjectHash.GetEntry(aFrame),
+ NS_ASSERTION(!mForeignObjectHash->GetEntry(aFrame),
"nsSVGForeignObjectFrame already registered!");
- mForeignObjectHash.PutEntry(aFrame);
+ mForeignObjectHash->PutEntry(aFrame);
- NS_ASSERTION(mForeignObjectHash.GetEntry(aFrame),
+ NS_ASSERTION(mForeignObjectHash->GetEntry(aFrame),
"Failed to register nsSVGForeignObjectFrame!");
}
void
nsSVGOuterSVGFrame::UnregisterForeignObject(nsSVGForeignObjectFrame* aFrame)
{
NS_ASSERTION(aFrame, "Who on earth is calling us?!");
- NS_ASSERTION(mForeignObjectHash.GetEntry(aFrame),
+ NS_ASSERTION(mForeignObjectHash && mForeignObjectHash->GetEntry(aFrame),
"nsSVGForeignObjectFrame not in registry!");
- return mForeignObjectHash.RemoveEntry(aFrame);
+ return mForeignObjectHash->RemoveEntry(aFrame);
}
void
nsSVGMutationObserver::UpdateTextFragmentTrees(nsIFrame *aFrame)
{
nsIFrame* kid = aFrame->GetFirstPrincipalChild();
while (kid) {
if (kid->GetType() == nsGkAtoms::svgTextFrame) {
@@ -660,18 +660,18 @@ static PLDHashOperator CheckForeignObjec
region->Or(*region, aEntry->GetKey()->GetInvalidRegion());
return PL_DHASH_NEXT;
}
nsRegion
nsSVGOuterSVGFrame::FindInvalidatedForeignObjectFrameChildren(nsIFrame* aFrame)
{
nsRegion result;
- if (mForeignObjectHash.Count()) {
- mForeignObjectHash.EnumerateEntries(CheckForeignObjectInvalidatedArea, &result);
+ if (mForeignObjectHash && mForeignObjectHash->Count()) {
+ mForeignObjectHash->EnumerateEntries(CheckForeignObjectInvalidatedArea, &result);
}
return result;
}
void
nsDisplayOuterSVG::ComputeInvalidationRegion(nsDisplayListBuilder* aBuilder,
const nsDisplayItemGeometry* aGeometry,
nsRegion* aInvalidRegion)
--- a/layout/svg/nsSVGOuterSVGFrame.h
+++ b/layout/svg/nsSVGOuterSVGFrame.h
@@ -28,17 +28,17 @@ protected:
nsSVGOuterSVGFrame(nsStyleContext* aContext);
public:
NS_DECL_QUERYFRAME
NS_DECL_FRAMEARENA_HELPERS
#ifdef DEBUG
~nsSVGOuterSVGFrame() {
- NS_ASSERTION(mForeignObjectHash.Count() == 0,
+ NS_ASSERTION(!mForeignObjectHash || mForeignObjectHash->Count() == 0,
"foreignObject(s) still registered!");
}
#endif
// nsIFrame:
virtual nscoord GetMinWidth(nsRenderingContext *aRenderingContext) MOZ_OVERRIDE;
virtual nscoord GetPrefWidth(nsRenderingContext *aRenderingContext) MOZ_OVERRIDE;
@@ -184,17 +184,17 @@ protected:
*/
bool IsRootOfImage();
// This is temporary until display list based invalidation is implemented for
// SVG.
// A hash-set containing our nsSVGForeignObjectFrame descendants. Note we use
// a hash-set to avoid the O(N^2) behavior we'd get tearing down an SVG frame
// subtree if we were to use a list (see bug 381285 comment 20).
- nsTHashtable<nsPtrHashKey<nsSVGForeignObjectFrame> > mForeignObjectHash;
+ nsAutoPtr<nsTHashtable<nsPtrHashKey<nsSVGForeignObjectFrame> > > mForeignObjectHash;
nsAutoPtr<gfxMatrix> mCanvasTM;
nsRegion mInvalidRegion;
float mFullZoom;
bool mViewportInitialized;
--- a/layout/tables/nsTableFrame.cpp
+++ b/layout/tables/nsTableFrame.cpp
@@ -452,17 +452,16 @@ void nsTableFrame::ResetRowIndices(const
{
// Iterate over the row groups and adjust the row indices of all rows
// omit the rowgroups that will be inserted later
RowGroupArray rowGroups;
OrderRowGroups(rowGroups);
int32_t rowIndex = 0;
nsTHashtable<nsPtrHashKey<nsTableRowGroupFrame> > excludeRowGroups;
- excludeRowGroups.Init();
nsFrameList::Enumerator excludeRowGroupsEnumerator(aRowGroupsToExclude);
while (!excludeRowGroupsEnumerator.AtEnd()) {
excludeRowGroups.PutEntry(static_cast<nsTableRowGroupFrame*>(excludeRowGroupsEnumerator.get()));
excludeRowGroupsEnumerator.Next();
}
for (uint32_t rgX = 0; rgX < rowGroups.Length(); rgX++) {
nsTableRowGroupFrame* rgFrame = rowGroups[rgX];
--- a/layout/xul/base/src/nsBoxObject.cpp
+++ b/layout/xul/base/src/nsBoxObject.cpp
@@ -302,19 +302,17 @@ nsBoxObject::GetPropertyAsSupports(const
}
NS_IMETHODIMP
nsBoxObject::SetPropertyAsSupports(const PRUnichar* aPropertyName, nsISupports* aValue)
{
NS_ENSURE_ARG(aPropertyName && *aPropertyName);
if (!mPropertyTable) {
- mPropertyTable = new nsInterfaceHashtable<nsStringHashKey,nsISupports>;
- if (!mPropertyTable) return NS_ERROR_OUT_OF_MEMORY;
- mPropertyTable->Init(8);
+ mPropertyTable = new nsInterfaceHashtable<nsStringHashKey,nsISupports>(8);
}
nsDependentString propertyName(aPropertyName);
mPropertyTable->Put(propertyName, aValue);
return NS_OK;
}
NS_IMETHODIMP
--- a/layout/xul/tree/nsTreeBodyFrame.cpp
+++ b/layout/xul/tree/nsTreeBodyFrame.cpp
@@ -106,16 +106,17 @@ NS_QUERYFRAME_HEAD(nsTreeBodyFrame)
NS_QUERYFRAME_ENTRY(nsIScrollbarOwner)
NS_QUERYFRAME_ENTRY(nsTreeBodyFrame)
NS_QUERYFRAME_TAIL_INHERITING(nsLeafBoxFrame)
// Constructor
nsTreeBodyFrame::nsTreeBodyFrame(nsIPresShell* aPresShell, nsStyleContext* aContext)
:nsLeafBoxFrame(aPresShell, aContext),
mSlots(nullptr),
+ mImageCache(16),
mTopRowIndex(0),
mPageLength(0),
mHorzPosition(0),
mOriginalHorzWidth(-1),
mHorzWidth(0),
mAdjustWidth(0),
mRowHeight(0),
mIndentation(0),
@@ -163,19 +164,16 @@ nsTreeBodyFrame::Init(nsIContent* aC
nsIFrame* aParent,
nsIFrame* aPrevInFlow)
{
nsLeafBoxFrame::Init(aContent, aParent, aPrevInFlow);
mIndentation = GetIndentation();
mRowHeight = GetRowHeight();
- mCreatedListeners.Init();
-
- mImageCache.Init(16);
EnsureBoxObject();
if (LookAndFeel::GetInt(LookAndFeel::eIntID_UseOverlayScrollbars) != 0) {
mScrollbarActivity = new ScrollbarActivity(
static_cast<nsIScrollbarOwner*>(this));
}
}
--- a/mobile/android/components/build/nsAndroidHistory.cpp
+++ b/mobile/android/components/build/nsAndroidHistory.cpp
@@ -24,17 +24,16 @@ nsAndroidHistory::GetSingleton()
}
NS_ADDREF(sHistory);
return sHistory;
}
nsAndroidHistory::nsAndroidHistory()
{
- mListeners.Init();
}
NS_IMETHODIMP
nsAndroidHistory::RegisterVisitedCallback(nsIURI *aURI, Link *aContent)
{
if (!aContent || !aURI)
return NS_OK;
--- a/modules/libjar/nsJARChannel.cpp
+++ b/modules/libjar/nsJARChannel.cpp
@@ -225,20 +225,16 @@ NS_IMPL_ISUPPORTS_INHERITED7(nsJARChanne
nsIDownloadObserver,
nsIRemoteOpenFileListener,
nsIJARChannel)
nsresult
nsJARChannel::Init(nsIURI *uri)
{
nsresult rv;
- rv = nsHashPropertyBag::Init();
- if (NS_FAILED(rv))
- return rv;
-
mJarURI = do_QueryInterface(uri, &rv);
if (NS_FAILED(rv))
return rv;
mOriginalURI = mJarURI;
// Prevent loading jar:javascript URIs (see bug 290982).
nsCOMPtr<nsIURI> innerURI;
--- a/modules/libjar/nsJARProtocolHandler.cpp
+++ b/modules/libjar/nsJARProtocolHandler.cpp
@@ -29,20 +29,16 @@ static NS_DEFINE_CID(kZipReaderCacheCID,
//-----------------------------------------------------------------------------
nsJARProtocolHandler *gJarHandler = nullptr;
nsJARProtocolHandler::nsJARProtocolHandler()
: mIsMainProcess(XRE_GetProcessType() == GeckoProcessType_Default)
{
MOZ_ASSERT(NS_IsMainThread());
-
- if (!mIsMainProcess) {
- mRemoteFileListeners.Init();
- }
}
nsJARProtocolHandler::~nsJARProtocolHandler()
{
}
nsresult
nsJARProtocolHandler::Init()
--- a/modules/libjar/zipwriter/src/nsZipWriter.cpp
+++ b/modules/libjar/zipwriter/src/nsZipWriter.cpp
@@ -40,17 +40,16 @@
* [central directory]
* [end of central directory record]
*/
NS_IMPL_ISUPPORTS2(nsZipWriter, nsIZipWriter,
nsIRequestObserver)
nsZipWriter::nsZipWriter()
{
- mEntryHash.Init();
mInQueue = false;
}
nsZipWriter::~nsZipWriter()
{
if (mStream && !mInQueue)
Close();
}
--- a/modules/libpref/src/Preferences.cpp
+++ b/modules/libpref/src/Preferences.cpp
@@ -250,17 +250,16 @@ Preferences::GetInstanceForService()
// The singleton instance will delete sRootBranch and sDefaultRootBranch.
NS_RELEASE(sPreferences);
return nullptr;
}
gCacheData = new nsTArray<nsAutoPtr<CacheData> >();
gObserverTable = new nsRefPtrHashtable<ValueObserverHashKey, ValueObserver>();
- gObserverTable->Init();
// Preferences::GetInstanceForService() can be called from GetService(), and
// NS_RegisterMemoryReporter calls GetService(nsIMemoryReporter). To avoid a
// potential recursive GetService() call, we can't register the memory
// reporter here; instead, do it off a runnable.
nsRefPtr<AddPreferencesMemoryReporterRunnable> runnable =
new AddPreferencesMemoryReporterRunnable();
NS_DispatchToMainThread(runnable);
--- a/modules/libpref/src/nsPrefBranch.cpp
+++ b/modules/libpref/src/nsPrefBranch.cpp
@@ -67,17 +67,16 @@ GetContentChild()
*/
nsPrefBranch::nsPrefBranch(const char *aPrefRoot, bool aDefaultBranch)
{
mPrefRoot = aPrefRoot;
mPrefRootLength = mPrefRoot.Length();
mIsDefault = aDefaultBranch;
mFreeingObserverList = false;
- mObservers.Init();
nsCOMPtr<nsIObserverService> observerService =
mozilla::services::GetObserverService();
if (observerService) {
++mRefCnt; // Our refcnt must be > 0 when we call this, or we'll get deleted!
// add weak so we don't have to clean up at shutdown
observerService->AddObserver(this, NS_XPCOM_SHUTDOWN_OBSERVER_ID, true);
--mRefCnt;
--- a/netwerk/base/src/RedirectChannelRegistrar.cpp
+++ b/netwerk/base/src/RedirectChannelRegistrar.cpp
@@ -2,42 +2,23 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "RedirectChannelRegistrar.h"
namespace mozilla {
namespace net {
-template<class KeyClass, class T>
-bool
-RedirectChannelRegistrar::nsCOMPtrHashtable<KeyClass,T>::Get(KeyType aKey, T** retVal) const
-{
- typename base_type::EntryType* ent = this->GetEntry(aKey);
-
- if (ent) {
- if (retVal)
- NS_IF_ADDREF(*retVal = ent->mData);
-
- return true;
- }
-
- if (retVal)
- *retVal = nullptr;
-
- return false;
-}
-
NS_IMPL_ISUPPORTS1(RedirectChannelRegistrar, nsIRedirectChannelRegistrar)
RedirectChannelRegistrar::RedirectChannelRegistrar()
- : mId(1)
+ : mRealChannels(64)
+ , mParentChannels(64)
+ , mId(1)
{
- mRealChannels.Init(64);
- mParentChannels.Init(64);
}
NS_IMETHODIMP
RedirectChannelRegistrar::RegisterChannel(nsIChannel *channel,
uint32_t *_retval)
{
mRealChannels.Put(mId, channel);
*_retval = mId;
--- a/netwerk/base/src/RedirectChannelRegistrar.h
+++ b/netwerk/base/src/RedirectChannelRegistrar.h
@@ -4,45 +4,33 @@
#ifndef RedirectChannelRegistrar_h__
#define RedirectChannelRegistrar_h__
#include "nsIRedirectChannelRegistrar.h"
#include "nsIChannel.h"
#include "nsIParentChannel.h"
-#include "nsClassHashtable.h"
+#include "nsInterfaceHashtable.h"
#include "mozilla/Attributes.h"
namespace mozilla {
namespace net {
class RedirectChannelRegistrar MOZ_FINAL : public nsIRedirectChannelRegistrar
{
NS_DECL_ISUPPORTS
NS_DECL_NSIREDIRECTCHANNELREGISTRAR
RedirectChannelRegistrar();
protected:
- template<class KeyClass, class T>
- class nsCOMPtrHashtable :
- public nsBaseHashtable< KeyClass, nsCOMPtr<T>, T* >
- {
- public:
- typedef typename KeyClass::KeyType KeyType;
- typedef T* UserDataType;
- typedef nsBaseHashtable< KeyClass, nsCOMPtr<T>, T* > base_type;
-
- bool Get(KeyType aKey, UserDataType* pData) const;
- };
-
- typedef nsCOMPtrHashtable<nsUint32HashKey, nsIChannel>
+ typedef nsInterfaceHashtable<nsUint32HashKey, nsIChannel>
ChannelHashtable;
- typedef nsCOMPtrHashtable<nsUint32HashKey, nsIParentChannel>
+ typedef nsInterfaceHashtable<nsUint32HashKey, nsIParentChannel>
ParentChannelHashtable;
ChannelHashtable mRealChannels;
ParentChannelHashtable mParentChannels;
uint32_t mId;
};
}
--- a/netwerk/base/src/nsBaseChannel.h
+++ b/netwerk/base/src/nsBaseChannel.h
@@ -52,17 +52,17 @@ public:
NS_DECL_NSIINTERFACEREQUESTOR
NS_DECL_NSITRANSPORTEVENTSINK
NS_DECL_NSIASYNCVERIFYREDIRECTCALLBACK
nsBaseChannel();
// This method must be called to initialize the basechannel instance.
nsresult Init() {
- return nsHashPropertyBag::Init();
+ return NS_OK;
}
protected:
// -----------------------------------------------
// Methods to be implemented by the derived class:
virtual ~nsBaseChannel() {}
--- a/netwerk/base/src/nsProtocolProxyService.cpp
+++ b/netwerk/base/src/nsProtocolProxyService.cpp
@@ -396,18 +396,16 @@ nsProtocolProxyService::~nsProtocolProxy
NS_ASSERTION(mHostFiltersArray.Length() == 0 && mFilters == nullptr &&
mPACMan == nullptr, "what happened to xpcom-shutdown?");
}
// nsProtocolProxyService methods
nsresult
nsProtocolProxyService::Init()
{
- mFailedProxies.Init();
-
// failure to access prefs is non-fatal
nsCOMPtr<nsIPrefBranch> prefBranch =
do_GetService(NS_PREFSERVICE_CONTRACTID);
if (prefBranch) {
// monitor proxy prefs
prefBranch->AddObserver(PROXY_PREF_BRANCH, this, false);
// read all prefs
--- a/netwerk/cache/nsCacheService.cpp
+++ b/netwerk/cache/nsCacheService.cpp
@@ -1095,17 +1095,16 @@ nsCacheService::nsCacheService()
mDeactivateFailures(0),
mDeactivatedUnboundEntries(0)
{
NS_ASSERTION(gService==nullptr, "multiple nsCacheService instances!");
gService = this;
// create list of cache devices
PR_INIT_CLIST(&mDoomedEntries);
- mCustomOfflineDevices.Init();
}
nsCacheService::~nsCacheService()
{
if (mInitialized) // Shutdown hasn't been called yet.
(void) Shutdown();
if (mObserver) {
--- a/netwerk/cache/nsDiskCacheDeviceSQL.cpp
+++ b/netwerk/cache/nsDiskCacheDeviceSQL.cpp
@@ -881,16 +881,18 @@ private:
NS_IMPL_ISUPPORTS0(nsOfflineCacheDevice)
nsOfflineCacheDevice::nsOfflineCacheDevice()
: mDB(nullptr)
, mCacheCapacity(0)
, mDeltaCounter(0)
, mAutoShutdown(false)
, mLock("nsOfflineCacheDevice.lock")
+ , mActiveCaches(5)
+ , mLockedEntries(64)
{
}
/* static */
bool
nsOfflineCacheDevice::GetStrictFileOriginPolicy()
{
nsCOMPtr<nsIPrefBranch> prefs = do_GetService(NS_PREFSERVICE_CONTRACTID);
@@ -1344,23 +1346,16 @@ nsOfflineCacheDevice::BuildApplicationCa
return NS_OK;
}
nsresult
nsOfflineCacheDevice::InitActiveCaches()
{
MutexAutoLock lock(mLock);
- mCaches.Init();
- mActiveCachesByGroup.Init();
-
- mActiveCaches.Init(5);
-
- mLockedEntries.Init(64);
-
AutoResetStatement statement(mStatement_EnumerateGroups);
bool hasRows;
nsresult rv = statement->ExecuteStep(&hasRows);
NS_ENSURE_SUCCESS(rv, rv);
while (hasRows)
{
@@ -1397,18 +1392,17 @@ nsOfflineCacheDevice::ShutdownApplicatio
nsresult
nsOfflineCacheDevice::Shutdown()
{
NS_ENSURE_TRUE(mDB, NS_ERROR_NOT_INITIALIZED);
{
MutexAutoLock lock(mLock);
- if (mCaches.IsInitialized())
- mCaches.EnumerateRead(ShutdownApplicationCache, this);
+ mCaches.EnumerateRead(ShutdownApplicationCache, this);
}
{
EvictionObserver evictionObserver(mDB, mEvictionFunction);
// Delete all rows whose clientID is not an active clientID.
nsresult rv = mDB->ExecuteSimpleSQL(NS_LITERAL_CSTRING(
"DELETE FROM moz_cache WHERE rowid IN"
--- a/netwerk/cookie/nsCookieService.cpp
+++ b/netwerk/cookie/nsCookieService.cpp
@@ -2056,17 +2056,16 @@ nsCookieService::Read()
// since they can lock the database and prevent connections from being opened.
rv = mStorageService->OpenUnsharedDatabase(mDefaultDBState->cookieFile,
getter_AddRefs(mDefaultDBState->syncConn));
NS_ENSURE_SUCCESS(rv, RESULT_RETRY);
// Init our readSet hash and execute the statements. Note that, after this
// point, we cannot fail without altering the cleanup code in InitDBStates()
// to handle closing of the now-asynchronous connection.
- mDefaultDBState->readSet.Init();
mDefaultDBState->hostArray.SetCapacity(kMaxNumberOfCookies);
mDefaultDBState->readListener = new ReadCookieDBListener(mDefaultDBState);
rv = stmtRead->ExecuteAsync(mDefaultDBState->readListener,
getter_AddRefs(mDefaultDBState->pendingRead));
NS_ASSERT_SUCCESS(rv);
nsCOMPtr<mozIStoragePendingStatement> handle;
--- a/netwerk/cookie/nsCookieService.h
+++ b/netwerk/cookie/nsCookieService.h
@@ -145,17 +145,16 @@ struct CookieDomainTuple
};
// encapsulates in-memory and on-disk DB states, so we can
// conveniently switch state when entering or exiting private browsing.
struct DBState
{
DBState() : cookieCount(0), cookieOldestTime(INT64_MAX), corruptFlag(OK)
{
- hostTable.Init();
}
NS_INLINE_DECL_REFCOUNTING(DBState)
// State of the database connection.
enum CorruptFlag {
OK, // normal
CLOSING_FOR_REBUILD, // corruption detected, connection closing
--- a/netwerk/dns/nsDNSService2.cpp
+++ b/netwerk/dns/nsDNSService2.cpp
@@ -413,18 +413,16 @@ nsDNSService::Init()
// If a manual proxy is in use, disable prefetch implicitly
prefs->GetIntPref("network.proxy.type", &proxyType);
}
if (mFirstTime) {
mFirstTime = false;
- mLocalDomains.Init();
-
// register as prefs observer
if (prefs) {
prefs->AddObserver(kPrefDnsCacheEntries, this, false);
prefs->AddObserver(kPrefDnsCacheExpiration, this, false);
prefs->AddObserver(kPrefDnsCacheGrace, this, false);
prefs->AddObserver(kPrefIPv4OnlyDomains, this, false);
prefs->AddObserver(kPrefDnsLocalDomains, this, false);
prefs->AddObserver(kPrefDisableIPv6, this, false);
--- a/netwerk/dns/nsEffectiveTLDService.cpp
+++ b/netwerk/dns/nsEffectiveTLDService.cpp
@@ -72,27 +72,30 @@ public:
private:
int64_t Amount() MOZ_OVERRIDE
{
return gService ? gService->SizeOfIncludingThis(MallocSizeOf) : 0;
}
};
+nsEffectiveTLDService::nsEffectiveTLDService()
+ // We'll probably have to rehash at least once, since nsTHashtable doesn't
+ // use a perfect hash, but at least we'll save a few rehashes along the way.
+ // Next optimization here is to precompute the hash using something like
+ // gperf, but one step at a time. :-)
+ : mHash(ArrayLength(nsDomainEntry::entries))
+{
+}
+
nsresult
nsEffectiveTLDService::Init()
{
const ETLDEntry *entries = nsDomainEntry::entries;
- // We'll probably have to rehash at least once, since nsTHashtable doesn't
- // use a perfect hash, but at least we'll save a few rehashes along the way.
- // Next optimization here is to precompute the hash using something like
- // gperf, but one step at a time. :-)
- mHash.Init(ArrayLength(nsDomainEntry::entries));
-
nsresult rv;
mIDNService = do_GetService(NS_IDNSERVICE_CONTRACTID, &rv);
if (NS_FAILED(rv)) return rv;
// Initialize eTLD hash from static array
for (uint32_t i = 0; i < ArrayLength(nsDomainEntry::entries); i++) {
const char *domain = nsDomainEntry::GetEffectiveTLDName(entries[i].strtab_index);
#ifdef DEBUG
--- a/netwerk/dns/nsEffectiveTLDService.h
+++ b/netwerk/dns/nsEffectiveTLDService.h
@@ -103,17 +103,17 @@ private:
};
class nsEffectiveTLDService MOZ_FINAL : public nsIEffectiveTLDService
{
public:
NS_DECL_ISUPPORTS
NS_DECL_NSIEFFECTIVETLDSERVICE
- nsEffectiveTLDService() { }
+ nsEffectiveTLDService();
nsresult Init();
size_t SizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf);
private:
nsresult GetBaseDomainInternal(nsCString &aHostname, int32_t aAdditionalParts, nsACString &aBaseDomain);
nsresult NormalizeHostname(nsCString &aHostname);
~nsEffectiveTLDService();
--- a/netwerk/protocol/http/HttpBaseChannel.cpp
+++ b/netwerk/protocol/http/HttpBaseChannel.cpp
@@ -82,32 +82,29 @@ HttpBaseChannel::Init(nsIURI *aURI,
nsProxyInfo *aProxyInfo,
uint32_t aProxyResolveFlags,
nsIURI *aProxyURI)
{
LOG(("HttpBaseChannel::Init [this=%p]\n", this));
NS_PRECONDITION(aURI, "null uri");
- nsresult rv = nsHashPropertyBag::Init();
- if (NS_FAILED(rv)) return rv;
-
mURI = aURI;
mOriginalURI = aURI;
mDocumentURI = nullptr;
mCaps = aCaps;
mProxyResolveFlags = aProxyResolveFlags;
mProxyURI = aProxyURI;
// Construct connection info object
nsAutoCString host;
int32_t port = -1;
bool usingSSL = false;
- rv = mURI->SchemeIs("https", &usingSSL);
+ nsresult rv = mURI->SchemeIs("https", &usingSSL);
if (NS_FAILED(rv)) return rv;
rv = mURI->GetAsciiHost(host);
if (NS_FAILED(rv)) return rv;
// Reject the URL if it doesn't specify a host
if (host.IsEmpty())
return NS_ERROR_MALFORMED_URI;
--- a/netwerk/protocol/http/SpdyPush3.cpp
+++ b/netwerk/protocol/http/SpdyPush3.cpp
@@ -160,22 +160,20 @@ SpdyPushedStream3::GetBufferedData(char
}
//////////////////////////////////////////
// SpdyPushCache3
//////////////////////////////////////////
SpdyPushCache3::SpdyPushCache3()
{
- mHash.Init();
}
SpdyPushCache3::~SpdyPushCache3()
{
- mHash.Clear();
}
SpdyPushedStream3 *
SpdyPushCache3::GetPushedStream(nsCString key)
{
return mHash.Get(key);
}
--- a/netwerk/protocol/http/SpdySession2.cpp
+++ b/netwerk/protocol/http/SpdySession2.cpp
@@ -66,18 +66,16 @@ SpdySession2::SpdySession2(nsAHttpTransa
mPingSentEpoch(0),
mNextPingID(1)
{
MOZ_ASSERT(PR_GetCurrentThread() == gSocketThread);
LOG3(("SpdySession2::SpdySession2 %p transaction 1 = %p",
this, aHttpTransaction));
- mStreamIDHash.Init();
- mStreamTransactionHash.Init();
mConnection = aHttpTransaction->Connection();
mInputFrameBuffer = new char[mInputFrameBufferSize];
mDecompressBuffer = new char[mDecompressBufferSize];
mOutputQueueBuffer = new char[mOutputQueueSize];
zlibInit();
mSendingChunkSize = gHttpHandler->SpdySendingChunkSize();
if (!aHttpTransaction->IsNullTransaction())
--- a/netwerk/protocol/http/SpdySession3.cpp
+++ b/netwerk/protocol/http/SpdySession3.cpp
@@ -71,18 +71,16 @@ SpdySession3::SpdySession3(nsAHttpTransa
MOZ_ASSERT(PR_GetCurrentThread() == gSocketThread);
static uint64_t sSerial;
mSerial = ++sSerial;
LOG3(("SpdySession3::SpdySession3 %p transaction 1 = %p serial=0x%X\n",
this, aHttpTransaction, mSerial));
- mStreamIDHash.Init();
- mStreamTransactionHash.Init();
mConnection = aHttpTransaction->Connection();
mInputFrameBuffer = new char[mInputFrameBufferSize];
mOutputQueueBuffer = new char[mOutputQueueSize];
zlibInit();
mPushAllowance = gHttpHandler->SpdyPushAllowance();
mSendingChunkSize = gHttpHandler->SpdySendingChunkSize();
GenerateSettings();
--- a/netwerk/protocol/http/SpdyStream2.cpp
+++ b/netwerk/protocol/http/SpdyStream2.cpp
@@ -301,22 +301,21 @@ SpdyStream2::ParseHttpRequestHeaders(con
mTransaction->RequestHead()->GetHeader(nsHttp::Host, hostHeader);
nsCString versionHeader;
if (mTransaction->RequestHead()->Version() == NS_HTTP_VERSION_1_1)
versionHeader = NS_LITERAL_CSTRING("HTTP/1.1");
else
versionHeader = NS_LITERAL_CSTRING("HTTP/1.0");
- nsClassHashtable<nsCStringHashKey, nsCString> hdrHash;
-
// use mRequestHead() to get a sense of how big to make the hash,
// even though we are parsing the actual text stream because
// it is legit to append headers.
- hdrHash.Init(1 + (mTransaction->RequestHead()->Headers().Count() * 2));
+ nsClassHashtable<nsCStringHashKey, nsCString>
+ hdrHash(1 + (mTransaction->RequestHead()->Headers().Count() * 2));
const char *beginBuffer = mFlatHttpRequestHeaders.BeginReading();
// need to hash all the headers together to remove duplicates, special
// headers, etc..
int32_t crlfIndex = mFlatHttpRequestHeaders.Find("\r\n");
while (true) {
--- a/netwerk/protocol/http/SpdyStream3.cpp
+++ b/netwerk/protocol/http/SpdyStream3.cpp
@@ -373,22 +373,21 @@ SpdyStream3::ParseHttpRequestHeaders(con
mTxInlineFrame[17] = 0;
nsCString versionHeader;
if (mTransaction->RequestHead()->Version() == NS_HTTP_VERSION_1_1)
versionHeader = NS_LITERAL_CSTRING("HTTP/1.1");
else
versionHeader = NS_LITERAL_CSTRING("HTTP/1.0");
- nsClassHashtable<nsCStringHashKey, nsCString> hdrHash;
-
// use mRequestHead() to get a sense of how big to make the hash,
// even though we are parsing the actual text stream because
// it is legit to append headers.
- hdrHash.Init(1 + (mTransaction->RequestHead()->Headers().Count() * 2));
+ nsClassHashtable<nsCStringHashKey, nsCString>
+ hdrHash(1 + (mTransaction->RequestHead()->Headers().Count() * 2));
const char *beginBuffer = mFlatHttpRequestHeaders.BeginReading();
// need to hash all the headers together to remove duplicates, special
// headers, etc..
int32_t crlfIndex = mFlatHttpRequestHeaders.Find("\r\n");
while (true) {
--- a/netwerk/protocol/http/nsHttpConnectionMgr.cpp
+++ b/netwerk/protocol/http/nsHttpConnectionMgr.cpp
@@ -67,18 +67,16 @@ nsHttpConnectionMgr::nsHttpConnectionMgr
, mNumActiveConns(0)
, mNumIdleConns(0)
, mNumSpdyActiveConns(0)
, mNumHalfOpenConns(0)
, mTimeOfNextWakeUp(UINT64_MAX)
, mTimeoutTickArmed(false)
{
LOG(("Creating nsHttpConnectionMgr @%x\n", this));
- mCT.Init();
- mSpdyPreferredHash.Init();
}
nsHttpConnectionMgr::~nsHttpConnectionMgr()
{
LOG(("Destroying nsHttpConnectionMgr @%x\n", this));
if (mTimeoutTick)
mTimeoutTick->Cancel();
}
--- a/netwerk/protocol/res/nsResProtocolHandler.cpp
+++ b/netwerk/protocol/res/nsResProtocolHandler.cpp
@@ -98,16 +98,17 @@ nsResURL::GetClassIDNoAlloc(nsCID *aClas
return NS_OK;
}
//----------------------------------------------------------------------------
// nsResProtocolHandler <public>
//----------------------------------------------------------------------------
nsResProtocolHandler::nsResProtocolHandler()
+ : mSubstitutions(32)
{
#if defined(PR_LOGGING)
gResLog = PR_NewLogModule("nsResProtocol");
#endif
NS_ASSERTION(!gResHandler, "res handler already created!");
gResHandler = this;
}
@@ -115,18 +116,16 @@ nsResProtocolHandler::nsResProtocolHandl
nsResProtocolHandler::~nsResProtocolHandler()
{
gResHandler = nullptr;
}
nsresult
nsResProtocolHandler::Init()
{
- mSubstitutions.Init(32);
-
nsresult rv;
mIOService = do_GetIOService(&rv);
NS_ENSURE_SUCCESS(rv, rv);
nsAutoCString appURI, greURI;
rv = mozilla::Omnijar::GetURIString(mozilla::Omnijar::APP, appURI);
NS_ENSURE_SUCCESS(rv, rv);
--- a/parser/html/nsHtml5AtomTable.h
+++ b/parser/html/nsHtml5AtomTable.h
@@ -72,23 +72,16 @@ class nsHtml5AtomEntry : public nsString
*/
class nsHtml5AtomTable
{
public:
nsHtml5AtomTable();
~nsHtml5AtomTable();
/**
- * Must be called after the constructor before use.
- */
- inline void Init() {
- mTable.Init();
- }
-
- /**
* Obtains the atom for the given string in the scope of this atom table.
*/
nsIAtom* GetAtom(const nsAString& aKey);
/**
* Empties the table.
*/
void Clear() {
--- a/parser/html/nsHtml5Parser.cpp
+++ b/parser/html/nsHtml5Parser.cpp
@@ -37,17 +37,16 @@ NS_IMPL_CYCLE_COLLECTION_UNLINK_END
nsHtml5Parser::nsHtml5Parser()
: mFirstBuffer(new nsHtml5OwningUTF16Buffer((void*)nullptr))
, mLastBuffer(mFirstBuffer)
, mExecutor(new nsHtml5TreeOpExecutor())
, mTreeBuilder(new nsHtml5TreeBuilder(mExecutor, nullptr))
, mTokenizer(new nsHtml5Tokenizer(mTreeBuilder, false))
, mRootContextLineNumber(1)
{
- mAtomTable.Init(); // we aren't checking for OOM anyway...
mTokenizer->setInterner(&mAtomTable);
// There's a zeroing operator new for everything else
}
nsHtml5Parser::~nsHtml5Parser()
{
mTokenizer->end();
if (mDocWriteSpeculativeTokenizer) {
--- a/parser/html/nsHtml5StreamParser.cpp
+++ b/parser/html/nsHtml5StreamParser.cpp
@@ -168,17 +168,16 @@ nsHtml5StreamParser::nsHtml5StreamParser
, mThread(nsHtml5Module::GetStreamParserThread())
, mExecutorFlusher(new nsHtml5ExecutorFlusher(aExecutor))
, mLoadFlusher(new nsHtml5LoadFlusher(aExecutor))
, mFlushTimer(do_CreateInstance("@mozilla.org/timer;1"))
, mMode(aMode)
{
NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");
mFlushTimer->SetTarget(mThread);
- mAtomTable.Init(); // we aren't checking for OOM anyway...
#ifdef DEBUG
mAtomTable.SetPermittedLookupThread(mThread);
#endif
mTokenizer->setInterner(&mAtomTable);
mTokenizer->setEncodingDeclarationHandler(this);
if (aMode == VIEW_SOURCE_HTML || aMode == VIEW_SOURCE_XML) {
nsHtml5Highlighter* highlighter =
--- a/parser/html/nsHtml5StringParser.cpp
+++ b/parser/html/nsHtml5StringParser.cpp
@@ -14,17 +14,16 @@
NS_IMPL_ISUPPORTS0(nsHtml5StringParser)
nsHtml5StringParser::nsHtml5StringParser()
: mExecutor(new nsHtml5TreeOpExecutor(true))
, mTreeBuilder(new nsHtml5TreeBuilder(mExecutor, nullptr))
, mTokenizer(new nsHtml5Tokenizer(mTreeBuilder, false))
{
MOZ_COUNT_CTOR(nsHtml5StringParser);
- mAtomTable.Init();
mTokenizer->setInterner(&mAtomTable);
}
nsHtml5StringParser::~nsHtml5StringParser()
{
MOZ_COUNT_DTOR(nsHtml5StringParser);
}
--- a/parser/html/nsHtml5TreeOpExecutor.cpp
+++ b/parser/html/nsHtml5TreeOpExecutor.cpp
@@ -62,19 +62,19 @@ class nsHtml5ExecutorReflusher : public
return NS_OK;
}
};
static mozilla::LinkedList<nsHtml5TreeOpExecutor>* gBackgroundFlushList = nullptr;
static nsITimer* gFlushTimer = nullptr;
nsHtml5TreeOpExecutor::nsHtml5TreeOpExecutor(bool aRunsToCompletion)
+ : mPreloadedURLs(23) // Mean # of preloadable resources per page on dmoz
{
mRunsToCompletion = aRunsToCompletion;
- mPreloadedURLs.Init(23); // Mean # of preloadable resources per page on dmoz
// zeroing operator new for everything else
}
nsHtml5TreeOpExecutor::~nsHtml5TreeOpExecutor()
{
if (gBackgroundFlushList && isInList()) {
mOpQueue.Clear();
removeFrom(*gBackgroundFlushList);
--- a/rdf/base/src/nsRDFContentSink.cpp
+++ b/rdf/base/src/nsRDFContentSink.cpp
@@ -301,18 +301,16 @@ RDFContentSinkImpl::RDFContentSinkImpl()
}
rv = CallGetService(kRDFContainerUtilsCID, &gRDFContainerUtils);
NS_RegisterStaticAtoms(rdf_atoms);
}
- mNodeIDMap.Init();
-
#ifdef PR_LOGGING
if (! gLog)
gLog = PR_NewLogModule("nsRDFContentSink");
#endif
}
RDFContentSinkImpl::~RDFContentSinkImpl()
--- a/rdf/base/src/nsRDFXMLSerializer.cpp
+++ b/rdf/base/src/nsRDFXMLSerializer.cpp
@@ -128,17 +128,16 @@ nsRDFXMLSerializer::Init(nsIRDFDataSourc
nsCOMPtr<nsIAtom> prefix;
prefix = do_GetAtom("RDF");
AddNameSpace(prefix, NS_LITERAL_STRING("http://www.w3.org/1999/02/22-rdf-syntax-ns#"));
prefix = do_GetAtom("NC");
AddNameSpace(prefix, NS_LITERAL_STRING("http://home.netscape.com/NC-rdf#"));
- mQNames.Init();
mPrefixID = 0;
return NS_OK;
}
NS_IMETHODIMP
nsRDFXMLSerializer::AddNameSpace(nsIAtom* aPrefix, const nsAString& aURI)
{
--- a/security/manager/boot/src/nsSiteSecurityService.cpp
+++ b/security/manager/boot/src/nsSiteSecurityService.cpp
@@ -93,18 +93,16 @@ nsSiteSecurityService::Init()
NS_ENSURE_SUCCESS(rv, rv);
mUsePreloadList = mozilla::Preferences::GetBool("network.stricttransportsecurity.preloadlist", true);
mozilla::Preferences::AddStrongObserver(this, "network.stricttransportsecurity.preloadlist");
mObserverService = mozilla::services::GetObserverService();
if (mObserverService)
mObserverService->AddObserver(this, "last-pb-context-exited", false);
- mPrivateModeHostTable.Init();
-
return NS_OK;
}
nsresult
nsSiteSecurityService::GetHost(nsIURI *aURI, nsACString &aResult)
{
nsCOMPtr<nsIURI> innerURI = NS_GetInnermostURI(aURI);
if (!innerURI) return NS_ERROR_FAILURE;
--- a/security/manager/ssl/src/JARSignatureVerification.cpp
+++ b/security/manager/ssl/src/JARSignatureVerification.cpp
@@ -628,17 +628,16 @@ OpenSignedJARFile(nsIFile * aJarFile,
}
// Allocate the I/O buffer only once per JAR, instead of once per entry, in
// order to minimize malloc/free calls and in order to avoid fragmenting
// memory.
ScopedAutoSECItem buf(128 * 1024);
nsTHashtable<nsCStringHashKey> items;
- items.Init();
rv = ParseMF(char_ptr_cast(manifestBuffer.data), zip, items, buf);
if (NS_FAILED(rv)) {
return rv;
}
// Verify every entry in the file.
nsCOMPtr<nsIUTF8StringEnumerator> entries;
--- a/security/manager/ssl/src/TransportSecurityInfo.cpp
+++ b/security/manager/ssl/src/TransportSecurityInfo.cpp
@@ -1028,19 +1028,19 @@ formatOverridableCertErrorMessage(nsISSL
}
// RememberCertErrorsTable
/*static*/ RememberCertErrorsTable*
RememberCertErrorsTable::sInstance = nullptr;
RememberCertErrorsTable::RememberCertErrorsTable()
- : mMutex("RememberCertErrorsTable::mMutex")
+ : mErrorHosts(16)
+ , mMutex("RememberCertErrorsTable::mMutex")
{
- mErrorHosts.Init(16);
}
static nsresult
GetHostPortKey(TransportSecurityInfo* infoObject, nsAutoCString &result)
{
nsresult rv;
result.Truncate();
--- a/security/manager/ssl/src/TransportSecurityInfo.h
+++ b/security/manager/ssl/src/TransportSecurityInfo.h
@@ -129,19 +129,16 @@ public:
nsSSLStatus * status,
SECStatus certVerificationResult);
void LookupCertErrorBits(TransportSecurityInfo * infoObject,
nsSSLStatus* status);
static nsresult Init()
{
sInstance = new RememberCertErrorsTable();
- if (!sInstance->mErrorHosts.IsInitialized())
- return NS_ERROR_OUT_OF_MEMORY;
-
return NS_OK;
}
static RememberCertErrorsTable & GetInstance()
{
MOZ_ASSERT(sInstance);
return *sInstance;
}
--- a/security/manager/ssl/src/nsCertOverrideService.cpp
+++ b/security/manager/ssl/src/nsCertOverrideService.cpp
@@ -98,18 +98,16 @@ nsCertOverrideService::~nsCertOverrideSe
nsresult
nsCertOverrideService::Init()
{
if (!NS_IsMainThread()) {
NS_NOTREACHED("nsCertOverrideService initialized off main thread");
return NS_ERROR_NOT_SAME_THREAD;
}
- mSettingsTable.Init();
-
mOidTagForStoringNewHashes = SEC_OID_SHA256;
SECOidData *od = SECOID_FindOIDByTag(mOidTagForStoringNewHashes);
if (!od)
return NS_ERROR_FAILURE;
char *dotted_oid = CERT_GetOidString(&od->oid);
if (!dotted_oid)
--- a/security/manager/ssl/src/nsCertTree.cpp
+++ b/security/manager/ssl/src/nsCertTree.cpp
@@ -458,17 +458,16 @@ nsCertTree::GetCertsByTypeFromCertList(C
PR_LOG(gPIPNSSLog, PR_LOG_DEBUG, ("GetCertsByTypeFromCertList"));
if (!aCertList)
return NS_ERROR_FAILURE;
if (!mOriginalOverrideService)
return NS_ERROR_FAILURE;
nsTHashtable<nsCStringHashKey> allHostPortOverrideKeys;
- allHostPortOverrideKeys.Init();
if (aWantedType == nsIX509Cert::SERVER_CERT) {
mOriginalOverrideService->
EnumerateCertOverrides(nullptr,
CollectAllHostPortOverridesCallback,
&allHostPortOverrideKeys);
}
--- a/security/manager/ssl/src/nsClientAuthRemember.cpp
+++ b/security/manager/ssl/src/nsClientAuthRemember.cpp
@@ -44,18 +44,16 @@ nsClientAuthRememberService::~nsClientAu
nsresult
nsClientAuthRememberService::Init()
{
if (!NS_IsMainThread()) {
NS_ERROR("nsClientAuthRememberService::Init called off the main thread");
return NS_ERROR_NOT_SAME_THREAD;
}
- mSettingsTable.Init();
-
nsCOMPtr<nsIObserverService> observerService =
mozilla::services::GetObserverService();
if (observerService) {
observerService->AddObserver(this, "profile-before-change", true);
}
return NS_OK;
}
--- a/security/manager/ssl/src/nsNSSIOLayer.cpp
+++ b/security/manager/ssl/src/nsNSSIOLayer.cpp
@@ -1432,27 +1432,24 @@ nsresult nsSSLIOLayerHelpers::Init()
nsSSLPlaintextLayerIdentity = PR_GetUniqueIdentity("Plaintxext PSM layer");
nsSSLPlaintextLayerMethods = *PR_GetDefaultIOMethods();
nsSSLPlaintextLayerMethods.recv = PlaintextRecv;
}
mutex = new Mutex("nsSSLIOLayerHelpers.mutex");
- mTLSIntolerantSites = new nsTHashtable<nsCStringHashKey>();
- mTLSIntolerantSites->Init(1);
-
- mTLSTolerantSites = new nsTHashtable<nsCStringHashKey>();
+ mTLSIntolerantSites = new nsTHashtable<nsCStringHashKey>(1);
+
// Initialize the tolerant site hashtable to 16 items at the start seems
// reasonable as most servers are TLS tolerant. We just want to lower
// the rate of hashtable array reallocation.
- mTLSTolerantSites->Init(16);
-
- mRenegoUnrestrictedSites = new nsTHashtable<nsCStringHashKey>();
- mRenegoUnrestrictedSites->Init(1);
+ mTLSTolerantSites = new nsTHashtable<nsCStringHashKey>(16);
+
+ mRenegoUnrestrictedSites = new nsTHashtable<nsCStringHashKey>(1);
nsCString unrestricted_hosts;
Preferences::GetCString("security.ssl.renego_unrestricted_hosts", &unrestricted_hosts);
if (!unrestricted_hosts.IsEmpty()) {
setRenegoUnrestrictedSites(unrestricted_hosts);
}
bool enabled = false;
@@ -1513,22 +1510,20 @@ void nsSSLIOLayerHelpers::setRenegoUnres
{
MutexAutoLock lock(*mutex);
if (mRenegoUnrestrictedSites) {
delete mRenegoUnrestrictedSites;
mRenegoUnrestrictedSites = nullptr;
}
- mRenegoUnrestrictedSites = new nsTHashtable<nsCStringHashKey>();
+ mRenegoUnrestrictedSites = new nsTHashtable<nsCStringHashKey>(1);
if (!mRenegoUnrestrictedSites)
return;
- mRenegoUnrestrictedSites->Init(1);
-
nsCCharSeparatedTokenizer toker(str, ',');
while (toker.hasMoreTokens()) {
const nsCSubstring &host = toker.nextToken();
if (!host.IsEmpty()) {
mRenegoUnrestrictedSites->PutEntry(host);
}
}
--- a/startupcache/StartupCache.cpp
+++ b/startupcache/StartupCache.cpp
@@ -160,20 +160,16 @@ StartupCache::~StartupCache()
nsresult
StartupCache::Init()
{
// workaround for bug 653936
nsCOMPtr<nsIProtocolHandler> jarInitializer(do_GetService(NS_NETWORK_PROTOCOL_CONTRACTID_PREFIX "jar"));
nsresult rv;
- mTable.Init();
-#ifdef DEBUG
- mWriteObjectMap.Init();
-#endif
// This allows to override the startup cache filename
// which is useful from xpcshell, when there is no ProfLDS directory to keep cache in.
char *env = PR_GetEnv("MOZ_STARTUP_CACHE");
if (env) {
rv = NS_NewLocalFile(NS_ConvertUTF8toUTF16(env), false, getter_AddRefs(mFile));
} else {
nsCOMPtr<nsIFile> file;
@@ -440,17 +436,17 @@ CacheCloseHelper(const nsACString& key,
* to make sure there isn't a write happening on another thread
*/
void
StartupCache::WriteToDisk()
{
nsresult rv;
mStartupWriteInitiated = true;
- if (!mTable.IsInitialized() || mTable.Count() == 0)
+ if (mTable.Count() == 0)
return;
nsCOMPtr<nsIZipWriter> zipW = do_CreateInstance("@mozilla.org/zipwriter;1");
if (!zipW)
return;
rv = zipW->Open(mFile, PR_RDWR | PR_CREATE_FILE);
if (NS_FAILED(rv)) {
--- a/storage/public/StatementCache.h
+++ b/storage/public/StatementCache.h
@@ -33,17 +33,16 @@ public:
* @param aConnection
* A reference to the nsCOMPtr for the connection this cache is to be
* used for. This nsCOMPtr must at least live as long as this class,
* otherwise crashes will happen.
*/
StatementCache(nsCOMPtr<mozIStorageConnection>& aConnection)
: mConnection(aConnection)
{
- mCachedStatements.Init();
}
/**
* Obtains a cached statement. If this statement is not yet created, it will
* be created and stored for later use.
*
* @param aQuery
* The SQL string (either a const char [] or nsACString) to get a
--- a/storage/src/mozStorageBindingParams.cpp
+++ b/storage/src/mozStorageBindingParams.cpp
@@ -121,17 +121,16 @@ BindingParams::BindingParams(mozIStorage
{
}
AsyncBindingParams::AsyncBindingParams(
mozIStorageBindingParamsArray *aOwningArray
)
: BindingParams(aOwningArray)
{
- mNamedParameters.Init();
}
void
BindingParams::lock()
{
NS_ASSERTION(mLocked == false, "Parameters have already been locked!");
mLocked = true;
--- a/storage/src/mozStorageConnection.cpp
+++ b/storage/src/mozStorageConnection.cpp
@@ -471,17 +471,16 @@ Connection::Connection(Service *aService
, mDBConn(nullptr)
, mAsyncExecutionThreadShuttingDown(false)
, mTransactionInProgress(false)
, mProgressHandler(nullptr)
, mFlags(aFlags)
, mStorageService(aService)
, mAsyncOnly(aAsyncOnly)
{
- mFunctions.Init();
mStorageService->registerConnection(this);
}
Connection::~Connection()
{
(void)Close();
MOZ_ASSERT(!mAsyncExecutionThread,
--- a/storage/src/mozStorageRow.cpp
+++ b/storage/src/mozStorageRow.cpp
@@ -15,19 +15,16 @@ namespace mozilla {
namespace storage {
////////////////////////////////////////////////////////////////////////////////
//// Row
nsresult
Row::initialize(sqlite3_stmt *aStatement)
{
- // Initialize the hash table
- mNameHashtable.Init();
-
// Get the number of results
mNumCols = ::sqlite3_column_count(aStatement);
// Start copying over values
for (uint32_t i = 0; i < mNumCols; i++) {
// Store the value
nsIVariant *variant = nullptr;
int type = ::sqlite3_column_type(aStatement, i);
--- a/toolkit/components/alerts/nsXULAlerts.h
+++ b/toolkit/components/alerts/nsXULAlerts.h
@@ -14,17 +14,16 @@
using namespace mozilla;
class nsXULAlerts {
friend class nsXULAlertObserver;
public:
nsXULAlerts()
{
- mNamedWindows.Init();
}
virtual ~nsXULAlerts() {}
nsresult ShowAlertNotification(const nsAString& aImageUrl, const nsAString& aAlertTitle,
const nsAString& aAlertText, bool aAlertTextClickable,
const nsAString& aAlertCookie, nsIObserver* aAlertListener,
const nsAString& aAlertName, const nsAString& aBidi,
--- a/toolkit/components/places/History.cpp
+++ b/toolkit/components/places/History.cpp
@@ -1576,21 +1576,21 @@ static PLDHashOperator NotifyVisitRemova
/**
* Notify removed visits to observers.
*/
class NotifyRemoveVisits : public nsRunnable
{
public:
NotifyRemoveVisits(nsTHashtable<PlaceHashKey>& aPlaces)
- : mHistory(History::GetService())
+ : mPlaces(VISITS_REMOVAL_INITIAL_HASH_SIZE)
+ , mHistory(History::GetService())
{
MOZ_ASSERT(!NS_IsMainThread(),
"This should not be called on the main thread");
- mPlaces.Init(VISITS_REMOVAL_INITIAL_HASH_SIZE);
aPlaces.EnumerateEntries(TransferHashEntries, &mPlaces);
}
NS_IMETHOD Run()
{
MOZ_ASSERT(NS_IsMainThread(), "This should be called on the main thread");
// We are in the main thread, no need to lock.
@@ -1681,18 +1681,17 @@ public:
MutexAutoLock lockedScope(mHistory->GetShutdownMutex());
if (mHistory->IsShuttingDown()) {
// If we were already shutting down, we cannot remove the visits.
return NS_OK;
}
// Find all the visits relative to the current filters and whether their
// pages will be removed or not.
- nsTHashtable<PlaceHashKey> places;
- places.Init(VISITS_REMOVAL_INITIAL_HASH_SIZE);
+ nsTHashtable<PlaceHashKey> places(VISITS_REMOVAL_INITIAL_HASH_SIZE);
nsresult rv = FindRemovableVisits(places);
NS_ENSURE_SUCCESS(rv, rv);
if (places.Count() == 0)
return NS_OK;
mozStorageTransaction transaction(mDBConn, false,
mozIStorageConnection::TRANSACTION_IMMEDIATE);
@@ -1931,16 +1930,17 @@ private:
////////////////////////////////////////////////////////////////////////////////
//// History
History* History::gService = NULL;
History::History()
: mShuttingDown(false)
, mShutdownMutex("History::mShutdownMutex")
+ , mObservers(VISIT_OBSERVERS_INITIAL_CACHE_SIZE)
, mRecentlyVisitedURIsNextIndex(0)
{
NS_ASSERTION(!gService, "Ruh-roh! This service has already been created!");
gService = this;
nsCOMPtr<nsIObserverService> os = services::GetObserverService();
NS_WARN_IF_FALSE(os, "Observer service was not found!");
if (os) {
@@ -1952,22 +1952,18 @@ History::History()
}
History::~History()
{
NS_UnregisterMemoryReporter(mReporter);
gService = nullptr;
-#ifdef DEBUG
- if (mObservers.IsInitialized()) {
- NS_ASSERTION(mObservers.Count() == 0,
- "Not all Links were removed before we disappear!");
- }
-#endif
+ NS_ASSERTION(mObservers.Count() == 0,
+ "Not all Links were removed before we disappear!");
}
NS_IMETHODIMP
History::NotifyVisited(nsIURI* aURI)
{
NS_ENSURE_ARG(aURI);
nsAutoScriptBlocker scriptBlocker;
@@ -1980,24 +1976,17 @@ History::NotifyVisited(nsIURI* aURI)
URIParams uri;
SerializeURI(aURI, uri);
for (uint32_t i = 0; i < cplist.Length(); ++i) {
unused << cplist[i]->SendNotifyVisited(uri);
}
}
}
- // If the hash table has not been initialized, then we have nothing to notify
- // about.
- if (!mObservers.IsInitialized()) {
- return NS_OK;
- }
-
- // Additionally, if we have no observers for this URI, we have nothing to
- // notify about.
+ // If we have no observers for this URI, we have nothing to notify about.
KeyClass* key = mObservers.GetEntry(aURI);
if (!key) {
return NS_OK;
}
// Update status of each Link node.
{
// RemoveEntry will destroy the array, this iterator should not survive it.
@@ -2460,21 +2449,16 @@ NS_IMETHODIMP
History::RegisterVisitedCallback(nsIURI* aURI,
Link* aLink)
{
NS_ASSERTION(aURI, "Must pass a non-null URI!");
if (XRE_GetProcessType() == GeckoProcessType_Content) {
NS_PRECONDITION(aLink, "Must pass a non-null Link!");
}
- // First, ensure that our hash table is setup.
- if (!mObservers.IsInitialized()) {
- mObservers.Init(VISIT_OBSERVERS_INITIAL_CACHE_SIZE);
- }
-
// Obtain our array of observers for this URI.
#ifdef DEBUG
bool keyAlreadyExists = !!mObservers.GetEntry(aURI);
#endif
KeyClass* key = mObservers.PutEntry(aURI);
NS_ENSURE_TRUE(key, NS_ERROR_OUT_OF_MEMORY);
ObserverArray& observers = key->array;
--- a/toolkit/components/places/nsFaviconService.cpp
+++ b/toolkit/components/places/nsFaviconService.cpp
@@ -72,16 +72,18 @@ NS_IMPL_ISUPPORTS3_CI(
, nsIFaviconService
, mozIAsyncFavicons
, nsITimerCallback
)
nsFaviconService::nsFaviconService()
: mOptimizedIconDimension(OPTIMIZED_FAVICON_DIMENSION)
, mFailedFaviconSerial(0)
+ , mFailedFavicons(MAX_FAVICON_CACHE_SIZE)
+ , mUnassociatedIcons(MAX_UNASSOCIATED_FAVICONS)
{
NS_ASSERTION(!gFaviconService,
"Attempting to create two instances of the service!");
gFaviconService = this;
}
nsFaviconService::~nsFaviconService()
@@ -94,19 +96,16 @@ nsFaviconService::~nsFaviconService()
nsresult
nsFaviconService::Init()
{
mDB = Database::GetDatabase();
NS_ENSURE_STATE(mDB);
- mFailedFavicons.Init(MAX_FAVICON_CACHE_SIZE);
- mUnassociatedIcons.Init(MAX_UNASSOCIATED_FAVICONS);
-
mOptimizedIconDimension = Preferences::GetInt(
"places.favicons.optimizeToDimension", OPTIMIZED_FAVICON_DIMENSION
);
mExpireUnassociatedIconsTimer = do_CreateInstance("@mozilla.org/timer;1");
NS_ENSURE_STATE(mExpireUnassociatedIconsTimer);
return NS_OK;
--- a/toolkit/components/places/nsNavBookmarks.cpp
+++ b/toolkit/components/places/nsNavBookmarks.cpp
@@ -194,25 +194,29 @@ ExpireRecentBookmarksByParent(nsTHashtab
{
(void)hashTable->EnumerateEntries(ExpireRecentBookmarksByParentCallback,
reinterpret_cast<void*>(&aParentId));
}
} // Anonymous namespace.
-nsNavBookmarks::nsNavBookmarks() : mItemCount(0)
- , mRoot(0)
- , mMenuRoot(0)
- , mTagsRoot(0)
- , mUnfiledRoot(0)
- , mToolbarRoot(0)
- , mCanNotify(false)
- , mCacheObservers("bookmark-observers")
- , mBatching(false)
+nsNavBookmarks::nsNavBookmarks()
+ : mItemCount(0)
+ , mRoot(0)
+ , mMenuRoot(0)
+ , mTagsRoot(0)
+ , mUnfiledRoot(0)
+ , mToolbarRoot(0)
+ , mCanNotify(false)
+ , mCacheObservers("bookmark-observers")
+ , mBatching(false)
+ , mBookmarkToKeywordHash(BOOKMARKS_TO_KEYWORDS_INITIAL_CACHE_SIZE)
+ , mRecentBookmarksCache(RECENT_BOOKMARKS_INITIAL_CACHE_SIZE)
+ , mUncachableBookmarks(RECENT_BOOKMARKS_INITIAL_CACHE_SIZE)
{
NS_ASSERTION(!gBookmarksService,
"Attempting to create two instances of the service!");
gBookmarksService = this;
}
nsNavBookmarks::~nsNavBookmarks()
@@ -234,19 +238,16 @@ NS_IMPL_ISUPPORTS5(nsNavBookmarks
nsresult
nsNavBookmarks::Init()
{
mDB = Database::GetDatabase();
NS_ENSURE_STATE(mDB);
- mRecentBookmarksCache.Init(RECENT_BOOKMARKS_INITIAL_CACHE_SIZE);
- mUncachableBookmarks.Init(RECENT_BOOKMARKS_INITIAL_CACHE_SIZE);
-
nsCOMPtr<nsIObserverService> os = mozilla::services::GetObserverService();
if (os) {
(void)os->AddObserver(this, TOPIC_PLACES_MAINTENANCE, true);
(void)os->AddObserver(this, TOPIC_PLACES_SHUTDOWN, true);
(void)os->AddObserver(this, TOPIC_PLACES_CONNECTION_CLOSED, true);
}
nsresult rv = ReadRoots();
@@ -2319,17 +2320,16 @@ nsNavBookmarks::GetItemIndex(int64_t aIt
*_index = -1;
return NS_OK;
}
*_index = bookmark.position;
return NS_OK;
}
-
NS_IMETHODIMP
nsNavBookmarks::SetItemIndex(int64_t aItemId, int32_t aNewIndex)
{
NS_ENSURE_ARG_MIN(aItemId, 1);
NS_ENSURE_ARG_MIN(aNewIndex, 0);
BookmarkData bookmark;
nsresult rv = FetchItemInfo(aItemId, bookmark);
@@ -2600,21 +2600,16 @@ nsNavBookmarks::GetURIForKeyword(const n
NS_ENSURE_SUCCESS(rv, rv);
return NS_OK;
}
nsresult
nsNavBookmarks::EnsureKeywordsHash() {
- if (mBookmarkToKeywordHash.IsInitialized())
- return NS_OK;
-
- mBookmarkToKeywordHash.Init(BOOKMARKS_TO_KEYWORDS_INITIAL_CACHE_SIZE);
-
nsCOMPtr<mozIStorageStatement> stmt;
nsresult rv = mDB->MainConn()->CreateStatement(NS_LITERAL_CSTRING(
"SELECT b.id, k.keyword "
"FROM moz_bookmarks b "
"JOIN moz_keywords k ON k.id = b.keyword_id "
), getter_AddRefs(stmt));
NS_ENSURE_SUCCESS(rv, rv);
--- a/toolkit/components/places/nsNavHistory.cpp
+++ b/toolkit/components/places/nsNavHistory.cpp
@@ -251,28 +251,31 @@ const int32_t nsNavHistory::kGetInfoInde
const int32_t nsNavHistory::kGetInfoIndex_Frecency = 12;
const int32_t nsNavHistory::kGetInfoIndex_Hidden = 13;
const int32_t nsNavHistory::kGetInfoIndex_Guid = 14;
PLACES_FACTORY_SINGLETON_IMPLEMENTATION(nsNavHistory, gHistoryService)
nsNavHistory::nsNavHistory()
-: mBatchLevel(0)
-, mBatchDBTransaction(nullptr)
-, mCachedNow(0)
-, mExpireNowTimer(nullptr)
-, mHistoryEnabled(true)
-, mNumVisitsForFrecency(10)
-, mTagsFolder(-1)
-, mDaysOfHistory(-1)
-, mLastCachedStartOfDay(INT64_MAX)
-, mLastCachedEndOfDay(0)
-, mCanNotify(true)
-, mCacheObservers("history-observers")
+ : mBatchLevel(0)
+ , mBatchDBTransaction(nullptr)
+ , mCachedNow(0)
+ , mRecentTyped(RECENT_EVENTS_INITIAL_CACHE_SIZE)
+ , mRecentLink(RECENT_EVENTS_INITIAL_CACHE_SIZE)
+ , mRecentBookmark(RECENT_EVENTS_INITIAL_CACHE_SIZE)
+ , mEmbedVisits(EMBED_VISITS_INITIAL_CACHE_SIZE)
+ , mHistoryEnabled(true)
+ , mNumVisitsForFrecency(10)
+ , mTagsFolder(-1)
+ , mDaysOfHistory(-1)
+ , mLastCachedStartOfDay(INT64_MAX)
+ , mLastCachedEndOfDay(0)
+ , mCanNotify(true)
+ , mCacheObservers("history-observers")
{
NS_ASSERTION(!gHistoryService,
"Attempting to create two instances of the service!");
gHistoryService = this;
}
nsNavHistory::~nsNavHistory()
@@ -289,24 +292,16 @@ nsNavHistory::~nsNavHistory()
nsresult
nsNavHistory::Init()
{
LoadPrefs();
mDB = Database::GetDatabase();
NS_ENSURE_STATE(mDB);
- // recent events hash tables
- mRecentTyped.Init(RECENT_EVENTS_INITIAL_CACHE_SIZE);
- mRecentLink.Init(RECENT_EVENTS_INITIAL_CACHE_SIZE);
- mRecentBookmark.Init(RECENT_EVENTS_INITIAL_CACHE_SIZE);
-
- // Embed visits hash table.
- mEmbedVisits.Init(EMBED_VISITS_INITIAL_CACHE_SIZE);
-
/*****************************************************************************
*** IMPORTANT NOTICE!
***
*** Nothing after these add observer calls should return anything but NS_OK.
*** If a failure code is returned, this nsNavHistory object will be held onto
*** by the observer service and the preference service.
****************************************************************************/
@@ -2095,18 +2090,17 @@ nsNavHistory::GetQueryResults(nsNavHisto
{
NS_ENSURE_ARG_POINTER(aOptions);
NS_ASSERTION(aResults->Count() == 0, "Initial result array must be empty");
if (! aQueries.Count())
return NS_ERROR_INVALID_ARG;
nsCString queryString;
bool paramsPresent = false;
- nsNavHistory::StringHash addParams;
- addParams.Init(HISTORY_DATE_CONT_MAX);
+ nsNavHistory::StringHash addParams(HISTORY_DATE_CONT_MAX);
nsresult rv = ConstructQueryString(aQueries, aOptions, queryString,
paramsPresent, addParams);
NS_ENSURE_SUCCESS(rv,rv);
// create statement
nsCOMPtr<mozIStorageStatement> statement = mDB->GetStatement(queryString);
#ifdef DEBUG
if (!statement) {
@@ -2938,18 +2932,17 @@ nsNavHistory::AsyncExecuteLegacyQueries(
}
NS_ENSURE_ARG_MIN(queries.Count(), 1);
nsCOMPtr<nsNavHistoryQueryOptions> options = do_QueryInterface(aOptions);
NS_ENSURE_ARG(options);
nsCString queryString;
bool paramsPresent = false;
- nsNavHistory::StringHash addParams;