Skip to content

Commit 03e7828

Browse files
committed
Bug 910989. Remove nsTHashtable::Init, fallible allocation, and MT hashtables. r=ehsan,bsmedberg
--HG-- extra : rebase_source : 0787130b1814c74bfb38dc178de94022f0b2e64e
1 parent 26ceee4 commit 03e7828

File tree

260 files changed

+628
-1445
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

260 files changed

+628
-1445
lines changed

accessible/src/base/DocManager.cpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,11 @@ using namespace mozilla::dom;
3838
// DocManager
3939
////////////////////////////////////////////////////////////////////////////////
4040

41+
DocManager::DocManager()
42+
: mDocAccessibleCache(4)
43+
{
44+
}
45+
4146
////////////////////////////////////////////////////////////////////////////////
4247
// DocManager public
4348

@@ -88,8 +93,6 @@ DocManager::IsProcessingRefreshDriverNotification() const
8893
bool
8994
DocManager::Init()
9095
{
91-
mDocAccessibleCache.Init(4);
92-
9396
nsCOMPtr<nsIWebProgress> progress =
9497
do_GetService(NS_DOCUMENTLOADER_SERVICE_CONTRACTID);
9598

accessible/src/base/DocManager.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ class DocManager : public nsIWebProgressListener,
7373
#endif
7474

7575
protected:
76-
DocManager() { }
76+
DocManager();
7777

7878
/**
7979
* Initialize the manager.

accessible/src/base/NotificationController.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,6 @@ NotificationController::NotificationController(DocAccessible* aDocument,
2929
EventQueue(aDocument), mObservingState(eNotObservingRefresh),
3030
mPresShell(aPresShell)
3131
{
32-
mTextHash.Init();
33-
3432
// Schedule initial accessible tree construction.
3533
ScheduleProcessing();
3634
}

accessible/src/generic/DocAccessible.cpp

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,9 @@ DocAccessible::
7474
nsIPresShell* aPresShell) :
7575
HyperTextAccessibleWrap(aRootContent, this),
7676
mDocumentNode(aDocument), mScrollPositionChangedTicks(0),
77+
// XXX aaronl should we use an algorithm for the initial cache size?
78+
mAccessibleCache(kDefaultCacheSize),
79+
mNodeToAccessibleMap(kDefaultCacheSize),
7780
mLoadState(eTreeConstructionPending), mDocFlags(0), mLoadEventType(0),
7881
mVirtualCursor(nullptr),
7982
mPresShell(aPresShell)
@@ -84,11 +87,6 @@ DocAccessible::
8487
MOZ_ASSERT(mPresShell, "should have been given a pres shell");
8588
mPresShell->SetDocAccessible(this);
8689

87-
mDependentIDsHash.Init();
88-
// XXX aaronl should we use an algorithm for the initial cache size?
89-
mAccessibleCache.Init(kDefaultCacheSize);
90-
mNodeToAccessibleMap.Init(kDefaultCacheSize);
91-
9290
// If this is a XUL Document, it should not implement nsHyperText
9391
if (mDocumentNode && mDocumentNode->IsXUL())
9492
mGenericTypes &= ~eHyperText;

accessible/src/windows/msaa/DocAccessibleWrap.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -248,7 +248,7 @@ DocAccessibleWrap::Shutdown()
248248
if (nsWinUtils::IsWindowEmulationStarted()) {
249249
// Destroy window created for root document.
250250
if (mDocFlags & eTabDocument) {
251-
nsWinUtils::sHWNDCache.Remove(mHWND);
251+
nsWinUtils::sHWNDCache->Remove(mHWND);
252252
::DestroyWindow(static_cast<HWND>(mHWND));
253253
}
254254

@@ -308,7 +308,7 @@ DocAccessibleWrap::DoInitialUpdate()
308308
mHWND = nsWinUtils::CreateNativeWindow(kClassNameTabContent, parentWnd,
309309
x, y, width, height, isActive);
310310

311-
nsWinUtils::sHWNDCache.Put(mHWND, this);
311+
nsWinUtils::sHWNDCache->Put(mHWND, this);
312312

313313
} else {
314314
DocAccessible* parentDocument = ParentDocument();

accessible/src/windows/msaa/nsWinUtils.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ const PRUnichar* kPropNameTabContent = L"AccessibleTabWindow";
3030
static LRESULT CALLBACK WindowProc(HWND hWnd, UINT msg,
3131
WPARAM wParam, LPARAM lParam);
3232

33-
nsRefPtrHashtable<nsPtrHashKey<void>, DocAccessible> nsWinUtils::sHWNDCache;
33+
nsRefPtrHashtable<nsPtrHashKey<void>, DocAccessible>* nsWinUtils::sHWNDCache = nullptr;
3434

3535
already_AddRefed<nsIDOMCSSStyleDeclaration>
3636
nsWinUtils::GetComputedStyleDeclaration(nsIContent* aContent)
@@ -60,7 +60,7 @@ nsWinUtils::MaybeStartWindowEmulation()
6060
Compatibility::IsDolphin() ||
6161
Preferences::GetBool("browser.tabs.remote")) {
6262
RegisterNativeWindow(kClassNameTabContent);
63-
sHWNDCache.Init(4);
63+
sHWNDCache = new nsRefPtrHashtable<nsPtrHashKey<void>, DocAccessible>(4);
6464
return true;
6565
}
6666

@@ -79,7 +79,7 @@ nsWinUtils::ShutdownWindowEmulation()
7979
bool
8080
nsWinUtils::IsWindowEmulationStarted()
8181
{
82-
return sHWNDCache.IsInitialized();
82+
return sHWNDCache != nullptr;
8383
}
8484

8585
void
@@ -145,7 +145,7 @@ WindowProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
145145
{
146146
if (lParam == OBJID_CLIENT) {
147147
DocAccessible* document =
148-
nsWinUtils::sHWNDCache.GetWeak(static_cast<void*>(hWnd));
148+
nsWinUtils::sHWNDCache->GetWeak(static_cast<void*>(hWnd));
149149
if (document) {
150150
IAccessible* msaaAccessible = nullptr;
151151
document->GetNativeInterface((void**)&msaaAccessible); // does an addref

accessible/src/windows/msaa/nsWinUtils.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ class nsWinUtils
7878
* Cache for HWNDs of windows created for document accessibles in windows
7979
* emulation mode.
8080
*/
81-
static nsRefPtrHashtable<nsPtrHashKey<void>, DocAccessible> sHWNDCache;
81+
static nsRefPtrHashtable<nsPtrHashKey<void>, DocAccessible>* sHWNDCache;
8282
};
8383

8484
} // namespace a11y

accessible/src/xul/XULTreeAccessible.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,8 @@ using namespace mozilla::a11y;
4040
XULTreeAccessible::
4141
XULTreeAccessible(nsIContent* aContent, DocAccessible* aDoc,
4242
nsTreeBodyFrame* aTreeFrame) :
43-
AccessibleWrap(aContent, aDoc)
43+
AccessibleWrap(aContent, aDoc),
44+
mAccessibleCache(kDefaultTreeCacheSize)
4445
{
4546
mType = eXULTreeType;
4647
mGenericTypes |= eSelect;
@@ -58,8 +59,6 @@ XULTreeAccessible::
5859
if (autoCompletePopupElm)
5960
mGenericTypes |= eAutoCompletePopup;
6061
}
61-
62-
mAccessibleCache.Init(kDefaultTreeCacheSize);
6362
}
6463

6564
////////////////////////////////////////////////////////////////////////////////

accessible/src/xul/XULTreeGridAccessible.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -267,11 +267,10 @@ XULTreeGridRowAccessible::
267267
XULTreeGridRowAccessible(nsIContent* aContent, DocAccessible* aDoc,
268268
Accessible* aTreeAcc, nsITreeBoxObject* aTree,
269269
nsITreeView* aTreeView, int32_t aRow) :
270-
XULTreeItemAccessibleBase(aContent, aDoc, aTreeAcc, aTree, aTreeView, aRow)
270+
XULTreeItemAccessibleBase(aContent, aDoc, aTreeAcc, aTree, aTreeView, aRow),
271+
mAccessibleCache(kDefaultTreeCacheSize)
271272
{
272273
mGenericTypes |= eTableRow;
273-
274-
mAccessibleCache.Init(kDefaultTreeCacheSize);
275274
}
276275

277276
////////////////////////////////////////////////////////////////////////////////

chrome/src/nsChromeRegistry.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -140,8 +140,6 @@ nsChromeRegistry::GetService()
140140
nsresult
141141
nsChromeRegistry::Init()
142142
{
143-
mOverrideTable.Init();
144-
145143
// This initialization process is fairly complicated and may cause reentrant
146144
// getservice calls to resolve chrome URIs (especially locale files). We
147145
// don't want that, so we inform the protocol handler about our existence

chrome/src/nsChromeRegistryChrome.cpp

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -124,9 +124,6 @@ nsChromeRegistryChrome::Init()
124124
if (NS_FAILED(rv))
125125
return rv;
126126

127-
mOverlayHash.Init();
128-
mStyleHash.Init();
129-
130127
mSelectedLocale = NS_LITERAL_CSTRING("en-US");
131128
mSelectedSkin = NS_LITERAL_CSTRING("classic/1.0");
132129

chrome/src/nsChromeRegistryChrome.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,6 @@ class nsChromeRegistryChrome : public nsChromeRegistry
142142
OverlayListHash() { }
143143
~OverlayListHash() { }
144144

145-
void Init() { mTable.Init(); }
146145
void Add(nsIURI* aBase, nsIURI* aOverlay);
147146
void Clear() { mTable.Clear(); }
148147
const nsCOMArray<nsIURI>* GetArray(nsIURI* aBase);

chrome/src/nsChromeRegistryContent.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212

1313
nsChromeRegistryContent::nsChromeRegistryContent()
1414
{
15-
mPackagesHash.Init();
1615
}
1716

1817
void

content/base/src/nsContentUtils.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -574,11 +574,11 @@ nsContentUtils::InitializeEventTable() {
574574
{ nullptr }
575575
};
576576

577-
sAtomEventTable = new nsDataHashtable<nsISupportsHashKey, EventNameMapping>;
578-
sStringEventTable = new nsDataHashtable<nsStringHashKey, EventNameMapping>;
577+
sAtomEventTable = new nsDataHashtable<nsISupportsHashKey, EventNameMapping>(
578+
int(ArrayLength(eventArray) / 0.75) + 1);
579+
sStringEventTable = new nsDataHashtable<nsStringHashKey, EventNameMapping>(
580+
int(ArrayLength(eventArray) / 0.75) + 1);
579581
sUserDefinedEvents = new nsCOMArray<nsIAtom>(64);
580-
sAtomEventTable->Init(int(ArrayLength(eventArray) / 0.75) + 1);
581-
sStringEventTable->Init(int(ArrayLength(eventArray) / 0.75) + 1);
582582

583583
// Subtract one from the length because of the trailing null
584584
for (uint32_t i = 0; i < ArrayLength(eventArray) - 1; ++i) {

content/base/src/nsCrossSiteListenerProxy.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,6 @@ class nsPreflightCache
8282

8383
bool Initialize()
8484
{
85-
mTable.Init();
8685
return true;
8786
}
8887

content/base/src/nsDOMAttributeMap.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@ nsDOMAttributeMap::nsDOMAttributeMap(Element* aContent)
3333
{
3434
// We don't add a reference to our content. If it goes away,
3535
// we'll be told to drop our reference
36-
mAttributeCache.Init();
3736
SetIsDOMBinding();
3837
}
3938

content/base/src/nsDOMMutationObserver.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -347,7 +347,6 @@ class nsDOMMutationObserver : public nsISupports,
347347
mozilla::dom::MutationCallback& aCb)
348348
: mOwner(aOwner), mCallback(&aCb), mWaitingForRun(false), mId(++sCount)
349349
{
350-
mTransientReceivers.Init();
351350
SetIsDOMBinding();
352351
}
353352
virtual ~nsDOMMutationObserver();

content/base/src/nsDocument.cpp

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -282,7 +282,6 @@ nsIdentifierMapEntry::AddContentChangeCallback(nsIDocument::IDTargetObserver aCa
282282
mChangeCallbacks = new nsTHashtable<ChangeCallbackEntry>;
283283
if (!mChangeCallbacks)
284284
return;
285-
mChangeCallbacks->Init();
286285
}
287286

288287
ChangeCallback cc = { aCallback, aData, aForImage };
@@ -697,8 +696,6 @@ nsOnloadBlocker::SetLoadFlags(nsLoadFlags aLoadFlags)
697696
nsExternalResourceMap::nsExternalResourceMap()
698697
: mHaveShutDown(false)
699698
{
700-
mMap.Init();
701-
mPendingLoads.Init();
702699
}
703700

704701
nsIDocument*
@@ -1394,8 +1391,6 @@ nsDocument::nsDocument(const char* aContentType)
13941391

13951392
// Start out mLastStyleSheetSet as null, per spec
13961393
SetDOMStringToNull(mLastStyleSheetSet);
1397-
1398-
mLinksToUpdate.Init();
13991394
}
14001395

14011396
static PLDHashOperator
@@ -1934,11 +1929,6 @@ nsDocument::Init()
19341929
Preferences::AddUintVarCache(&sOnloadDecodeLimit, "image.onload.decode.limit", 0);
19351930
}
19361931

1937-
mIdentifierMap.Init();
1938-
mStyledLinks.Init();
1939-
mRadioGroups.Init();
1940-
mCustomPrototypes.Init();
1941-
19421932
// Force initialization.
19431933
nsINode::nsSlots* slots = Slots();
19441934

@@ -1980,9 +1970,6 @@ nsDocument::Init()
19801970

19811971
mScriptLoader = new nsScriptLoader(this);
19821972

1983-
mImageTracker.Init();
1984-
mPlugins.Init();
1985-
19861973
mozilla::HoldJSObjects(this);
19871974

19881975
return NS_OK;
@@ -6144,8 +6131,7 @@ nsDocument::GetBoxObjectFor(Element* aElement, ErrorResult& aRv)
61446131
}
61456132

61466133
if (!mBoxObjectTable) {
6147-
mBoxObjectTable = new nsInterfaceHashtable<nsPtrHashKey<nsIContent>, nsPIBoxObject>;
6148-
mBoxObjectTable->Init(12);
6134+
mBoxObjectTable = new nsInterfaceHashtable<nsPtrHashKey<nsIContent>, nsPIBoxObject>(12);
61496135
} else {
61506136
nsCOMPtr<nsPIBoxObject> boxObject = mBoxObjectTable->Get(aElement);
61516137
if (boxObject) {
@@ -8763,7 +8749,6 @@ nsIDocument::RegisterFreezableElement(nsIContent* aContent)
87638749
mFreezableElements = new nsTHashtable<nsPtrHashKey<nsIContent> >();
87648750
if (!mFreezableElements)
87658751
return;
8766-
mFreezableElements->Init();
87678752
}
87688753
mFreezableElements->PutEntry(aContent);
87698754
}

content/base/src/nsFrameMessageManager.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -988,7 +988,6 @@ nsFrameScriptExecutor::DidCreateGlobal()
988988
if (!sCachedScripts) {
989989
sCachedScripts =
990990
new nsDataHashtable<nsStringHashKey, nsFrameJSScriptExecutorHolder*>;
991-
sCachedScripts->Init();
992991

993992
nsRefPtr<nsScriptCacheCleaner> scriptCacheCleaner =
994993
new nsScriptCacheCleaner();

content/base/src/nsHostObjectProtocolHandler.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@ nsHostObjectProtocolHandler::AddDataEntry(const nsACString& aScheme,
3434

3535
if (!gDataTable) {
3636
gDataTable = new nsClassHashtable<nsCStringHashKey, DataInfo>;
37-
gDataTable->Init();
3837
}
3938

4039
DataInfo* info = new DataInfo;

content/base/src/nsNameSpaceManager.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,10 @@ class nsNameSpaceKey : public PLDHashEntryHdr
7474

7575
class NameSpaceManagerImpl : public nsINameSpaceManager {
7676
public:
77+
NameSpaceManagerImpl()
78+
: mURIToIDTable(32)
79+
{
80+
}
7781
virtual ~NameSpaceManagerImpl()
7882
{
7983
}
@@ -102,8 +106,6 @@ NS_IMPL_ISUPPORTS1(NameSpaceManagerImpl, nsINameSpaceManager)
102106

103107
nsresult NameSpaceManagerImpl::Init()
104108
{
105-
mURIToIDTable.Init(32);
106-
107109
nsresult rv;
108110
#define REGISTER_NAMESPACE(uri, id) \
109111
rv = AddNameSpace(NS_LITERAL_STRING(uri), id); \

content/base/src/nsRange.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -364,7 +364,6 @@ nsRange::RegisterCommonAncestor(nsINode* aNode)
364364
static_cast<RangeHashTable*>(aNode->GetProperty(nsGkAtoms::range));
365365
if (!ranges) {
366366
ranges = new RangeHashTable;
367-
ranges->Init();
368367
aNode->SetProperty(nsGkAtoms::range, ranges, RangeHashTableDtor, true);
369368
}
370369
ranges->PutEntry(this);

content/base/src/nsTreeSanitizer.cpp

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1497,44 +1497,37 @@ nsTreeSanitizer::InitializeStatics()
14971497
{
14981498
NS_PRECONDITION(!sElementsHTML, "Initializing a second time.");
14991499

1500-
sElementsHTML = new nsTHashtable<nsISupportsHashKey> ();
1501-
sElementsHTML->Init(ArrayLength(kElementsHTML));
1500+
sElementsHTML = new nsTHashtable<nsISupportsHashKey>(ArrayLength(kElementsHTML));
15021501
for (uint32_t i = 0; kElementsHTML[i]; i++) {
15031502
sElementsHTML->PutEntry(*kElementsHTML[i]);
15041503
}
15051504

1506-
sAttributesHTML = new nsTHashtable<nsISupportsHashKey> ();
1507-
sAttributesHTML->Init(ArrayLength(kAttributesHTML));
1505+
sAttributesHTML = new nsTHashtable<nsISupportsHashKey>(ArrayLength(kAttributesHTML));
15081506
for (uint32_t i = 0; kAttributesHTML[i]; i++) {
15091507
sAttributesHTML->PutEntry(*kAttributesHTML[i]);
15101508
}
15111509

1512-
sPresAttributesHTML = new nsTHashtable<nsISupportsHashKey> ();
1513-
sPresAttributesHTML->Init(ArrayLength(kPresAttributesHTML));
1510+
sPresAttributesHTML = new nsTHashtable<nsISupportsHashKey>(ArrayLength(kPresAttributesHTML));
15141511
for (uint32_t i = 0; kPresAttributesHTML[i]; i++) {
15151512
sPresAttributesHTML->PutEntry(*kPresAttributesHTML[i]);
15161513
}
15171514

1518-
sElementsSVG = new nsTHashtable<nsISupportsHashKey> ();
1519-
sElementsSVG->Init(ArrayLength(kElementsSVG));
1515+
sElementsSVG = new nsTHashtable<nsISupportsHashKey>(ArrayLength(kElementsSVG));
15201516
for (uint32_t i = 0; kElementsSVG[i]; i++) {
15211517
sElementsSVG->PutEntry(*kElementsSVG[i]);
15221518
}
15231519

1524-
sAttributesSVG = new nsTHashtable<nsISupportsHashKey> ();
1525-
sAttributesSVG->Init(ArrayLength(kAttributesSVG));
1520+
sAttributesSVG = new nsTHashtable<nsISupportsHashKey>(ArrayLength(kAttributesSVG));
15261521
for (uint32_t i = 0; kAttributesSVG[i]; i++) {
15271522
sAttributesSVG->PutEntry(*kAttributesSVG[i]);
15281523
}
15291524

1530-
sElementsMathML = new nsTHashtable<nsISupportsHashKey> ();
1531-
sElementsMathML->Init(ArrayLength(kElementsMathML));
1525+
sElementsMathML = new nsTHashtable<nsISupportsHashKey>(ArrayLength(kElementsMathML));
15321526
for (uint32_t i = 0; kElementsMathML[i]; i++) {
15331527
sElementsMathML->PutEntry(*kElementsMathML[i]);
15341528
}
15351529

1536-
sAttributesMathML = new nsTHashtable<nsISupportsHashKey> ();
1537-
sAttributesMathML->Init(ArrayLength(kAttributesMathML));
1530+
sAttributesMathML = new nsTHashtable<nsISupportsHashKey>(ArrayLength(kAttributesMathML));
15381531
for (uint32_t i = 0; kAttributesMathML[i]; i++) {
15391532
sAttributesMathML->PutEntry(*kAttributesMathML[i]);
15401533
}

0 commit comments

Comments
 (0)