Bug 1187139 (part 2) - Replace nsBaseHashtable::Enumerate() calls in accessible/ with iterators. r=tbsaunde.
authorNicholas Nethercote <nnethercote@mozilla.com>
Sun, 29 Nov 2015 14:02:07 -0800
changeset 274829 06f4c59269952cb31914815e3b69d038f0da3c8d
parent 274828 a7ba739d20a99e0808eed568175aa9404f2b4929
child 274830 32528aa361207af33918e2986342bf176d8e4749
push id68686
push usernnethercote@mozilla.com
push dateTue, 01 Dec 2015 04:36:22 +0000
treeherdermozilla-inbound@32528aa36120 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerstbsaunde
bugs1187139
milestone45.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1187139 (part 2) - Replace nsBaseHashtable::Enumerate() calls in accessible/ with iterators. r=tbsaunde.
accessible/base/nsAccCache.h
accessible/xul/XULTreeAccessible.cpp
accessible/xul/XULTreeGridAccessible.cpp
--- a/accessible/base/nsAccCache.h
+++ b/accessible/base/nsAccCache.h
@@ -8,24 +8,26 @@
 
 #include "xpcAccessibleDocument.h"
 
 ////////////////////////////////////////////////////////////////////////////////
 // Accessible cache utils
 ////////////////////////////////////////////////////////////////////////////////
 
 template <class T>
-static PLDHashOperator
-UnbindCacheEntryFromDocument(const void* aKey, RefPtr<T>& aAccessible,
-                             void* aUserArg)
+void
+UnbindCacheEntriesFromDocument(
+  nsRefPtrHashtable<nsPtrHashKey<const void>, 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();
+  }
 }
 
 /**
  * Clear the cache and shutdown the accessibles.
  */
 template <class T>
 static void
 ClearCache(nsRefPtrHashtable<nsPtrHashKey<const void>, T>& aCache)
--- a/accessible/xul/XULTreeAccessible.cpp
+++ b/accessible/xul/XULTreeAccessible.cpp
@@ -140,18 +140,19 @@ XULTreeAccessible::Value(nsString& aValu
 }
 
 ////////////////////////////////////////////////////////////////////////////////
 // XULTreeAccessible: Accessible implementation
 
 void
 XULTreeAccessible::Shutdown()
 {
-  if (!mDoc->IsDefunct())
-    mAccessibleCache.Enumerate(UnbindCacheEntryFromDocument<Accessible>, nullptr);
+  if (!mDoc->IsDefunct()) {
+    UnbindCacheEntriesFromDocument(mAccessibleCache);
+  }
 
   mTree = nullptr;
   mTreeView = nullptr;
 
   AccessibleWrap::Shutdown();
 }
 
 role
@@ -545,18 +546,17 @@ XULTreeAccessible::GetTreeItemAccessible
 
 void
 XULTreeAccessible::InvalidateCache(int32_t aRow, int32_t aCount)
 {
   if (IsDefunct())
     return;
 
   if (!mTreeView) {
-    mAccessibleCache.Enumerate(UnbindCacheEntryFromDocument<Accessible>,
-                               nullptr);
+    UnbindCacheEntriesFromDocument(mAccessibleCache);
     return;
   }
 
   // Do not invalidate the cache if rows have been inserted.
   if (aCount > 0)
     return;
 
   DocAccessible* document = Document();
@@ -604,18 +604,17 @@ XULTreeAccessible::InvalidateCache(int32
 void
 XULTreeAccessible::TreeViewInvalidated(int32_t aStartRow, int32_t aEndRow,
                                        int32_t aStartCol, int32_t aEndCol)
 {
   if (IsDefunct())
     return;
 
   if (!mTreeView) {
-    mAccessibleCache.Enumerate(UnbindCacheEntryFromDocument<Accessible>,
-                               nullptr);
+    UnbindCacheEntriesFromDocument(mAccessibleCache);
     return;
   }
 
   int32_t endRow = aEndRow;
 
   nsresult rv;
   if (endRow == -1) {
     int32_t rowCount = 0;
@@ -664,35 +663,34 @@ XULTreeAccessible::TreeViewChanged(nsITr
 
   // Fire reorder event on tree accessible on accessible tree (do not fire
   // show/hide events on tree items because it can be expensive to fire them for
   // each tree item.
   RefPtr<AccReorderEvent> reorderEvent = new AccReorderEvent(this);
   Document()->FireDelayedEvent(reorderEvent);
 
   // Clear cache.
-  mAccessibleCache.Enumerate(UnbindCacheEntryFromDocument<Accessible>,
-                             nullptr);
+  UnbindCacheEntriesFromDocument(mAccessibleCache);
 
   mTreeView = aView;
 }
 
 ////////////////////////////////////////////////////////////////////////////////
 // XULTreeAccessible: protected implementation
 
 already_AddRefed<Accessible>
 XULTreeAccessible::CreateTreeItemAccessible(int32_t aRow) const
 {
   RefPtr<Accessible> accessible =
     new XULTreeItemAccessible(mContent, mDoc, const_cast<XULTreeAccessible*>(this),
                               mTree, mTreeView, aRow);
 
   return accessible.forget();
 }
-                             
+
 ////////////////////////////////////////////////////////////////////////////////
 // XULTreeItemAccessibleBase
 ////////////////////////////////////////////////////////////////////////////////
 
 XULTreeItemAccessibleBase::
   XULTreeItemAccessibleBase(nsIContent* aContent, DocAccessible* aDoc,
                             Accessible* aParent, nsITreeBoxObject* aTree,
                             nsITreeView* aTreeView, int32_t aRow) :
--- a/accessible/xul/XULTreeGridAccessible.cpp
+++ b/accessible/xul/XULTreeGridAccessible.cpp
@@ -272,18 +272,17 @@ NS_IMPL_RELEASE_INHERITED(XULTreeGridRow
 
 ////////////////////////////////////////////////////////////////////////////////
 // XULTreeGridRowAccessible: Accessible implementation
 
 void
 XULTreeGridRowAccessible::Shutdown()
 {
   if (!mDoc->IsDefunct()) {
-    mAccessibleCache.Enumerate(UnbindCacheEntryFromDocument<XULTreeGridCellAccessible>,
-                               nullptr);
+    UnbindCacheEntriesFromDocument(mAccessibleCache);
   }
 
   XULTreeItemAccessibleBase::Shutdown();
 }
 
 role
 XULTreeGridRowAccessible::NativeRole()
 {