From 1a8b28c4396f69069d0f8a48206afb77f123bd45 Mon Sep 17 00:00:00 2001 From: Nicholas Nethercote Date: Sun, 29 Nov 2015 14:02:07 -0800 Subject: [PATCH] Bug 1187139 (part 2) - Replace nsBaseHashtable::Enumerate() calls in accessible/ with iterators. r=tbsaunde. --HG-- extra : rebase_source : 1362c77b2a88ea1f02a549a18086986b73b419e4 --- accessible/base/nsAccCache.h | 16 +++++++++------- accessible/xul/XULTreeAccessible.cpp | 16 +++++++--------- accessible/xul/XULTreeGridAccessible.cpp | 3 +-- 3 files changed, 17 insertions(+), 18 deletions(-) diff --git a/accessible/base/nsAccCache.h b/accessible/base/nsAccCache.h index d89475aca27c..4e97dbf2c4f4 100644 --- a/accessible/base/nsAccCache.h +++ b/accessible/base/nsAccCache.h @@ -13,14 +13,16 @@ //////////////////////////////////////////////////////////////////////////////// template -static PLDHashOperator -UnbindCacheEntryFromDocument(const void* aKey, RefPtr& aAccessible, - void* aUserArg) +void +UnbindCacheEntriesFromDocument( + nsRefPtrHashtable, T>& aCache) { - MOZ_ASSERT(aAccessible && !aAccessible->IsDefunct()); - aAccessible->Document()->UnbindFromDocument(aAccessible); - - return PL_DHASH_REMOVE; + for (auto iter = aCache.Iter(); !iter.Done(); iter.Next()) { + T* accessible = iter.Data(); + MOZ_ASSERT(accessible && !accessible->IsDefunct()); + accessible->Document()->UnbindFromDocument(accessible); + iter.Remove(); + } } /** diff --git a/accessible/xul/XULTreeAccessible.cpp b/accessible/xul/XULTreeAccessible.cpp index 5d2d062a98dc..f6dfb7eaa5e4 100644 --- a/accessible/xul/XULTreeAccessible.cpp +++ b/accessible/xul/XULTreeAccessible.cpp @@ -145,8 +145,9 @@ XULTreeAccessible::Value(nsString& aValue) void XULTreeAccessible::Shutdown() { - if (!mDoc->IsDefunct()) - mAccessibleCache.Enumerate(UnbindCacheEntryFromDocument, nullptr); + if (!mDoc->IsDefunct()) { + UnbindCacheEntriesFromDocument(mAccessibleCache); + } mTree = nullptr; mTreeView = nullptr; @@ -550,8 +551,7 @@ XULTreeAccessible::InvalidateCache(int32_t aRow, int32_t aCount) return; if (!mTreeView) { - mAccessibleCache.Enumerate(UnbindCacheEntryFromDocument, - nullptr); + UnbindCacheEntriesFromDocument(mAccessibleCache); return; } @@ -609,8 +609,7 @@ XULTreeAccessible::TreeViewInvalidated(int32_t aStartRow, int32_t aEndRow, return; if (!mTreeView) { - mAccessibleCache.Enumerate(UnbindCacheEntryFromDocument, - nullptr); + UnbindCacheEntriesFromDocument(mAccessibleCache); return; } @@ -669,8 +668,7 @@ XULTreeAccessible::TreeViewChanged(nsITreeView* aView) Document()->FireDelayedEvent(reorderEvent); // Clear cache. - mAccessibleCache.Enumerate(UnbindCacheEntryFromDocument, - nullptr); + UnbindCacheEntriesFromDocument(mAccessibleCache); mTreeView = aView; } @@ -687,7 +685,7 @@ XULTreeAccessible::CreateTreeItemAccessible(int32_t aRow) const return accessible.forget(); } - + //////////////////////////////////////////////////////////////////////////////// // XULTreeItemAccessibleBase //////////////////////////////////////////////////////////////////////////////// diff --git a/accessible/xul/XULTreeGridAccessible.cpp b/accessible/xul/XULTreeGridAccessible.cpp index 8efb1b3248d6..dc809b0edb10 100644 --- a/accessible/xul/XULTreeGridAccessible.cpp +++ b/accessible/xul/XULTreeGridAccessible.cpp @@ -277,8 +277,7 @@ void XULTreeGridRowAccessible::Shutdown() { if (!mDoc->IsDefunct()) { - mAccessibleCache.Enumerate(UnbindCacheEntryFromDocument, - nullptr); + UnbindCacheEntriesFromDocument(mAccessibleCache); } XULTreeItemAccessibleBase::Shutdown();