Bug 629912, part2 - crash [@ NotificationController::TextEnumerator, keep text nodes addrefed, r=marcoz, sr=neil, a=betaN
authorAlexander Surkov <surkov.alexander@gmail.com>
Mon, 31 Jan 2011 19:45:33 +0800
changeset 61648 732a38102733f90cf7ad41c9c885f7262f27a288
parent 61647 ba3fe7ee56b9e09023d825f6fae1b8e297e8f92a
child 61649 7a5f8241cfa475e9f60b2bdaa06e1c1c9c2ec6e0
push id18426
push usersurkov.alexander@gmail.com
push dateMon, 31 Jan 2011 11:54:57 +0000
treeherdermozilla-central@732a38102733 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmarcoz, neil, betaN
bugs629912
milestone2.0b11pre
first release with
nightly linux32
732a38102733 / 4.0b11pre / 20110131064712 / files
nightly linux64
732a38102733 / 4.0b11pre / 20110131064717 / files
nightly mac
732a38102733 / 4.0b11pre / 20110131064734 / files
nightly win32
732a38102733 / 4.0b11pre / 20110131064745 / files
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
releases
nightly linux32
nightly linux64
nightly mac
nightly win32
Bug 629912, part2 - crash [@ NotificationController::TextEnumerator, keep text nodes addrefed, r=marcoz, sr=neil, a=betaN
accessible/src/base/NotificationController.cpp
accessible/src/base/NotificationController.h
--- a/accessible/src/base/NotificationController.cpp
+++ b/accessible/src/base/NotificationController.cpp
@@ -570,17 +570,17 @@ NotificationController::CreateTextChange
     return;
 
   aEvent->mTextChangeEvent =
     new AccTextChangeEvent(textAccessible, offset, text, aEvent->IsShow(),
                            aEvent->mIsFromUserInput ? eFromUserInput : eNoUserInput);
 }
 
 PLDHashOperator
-NotificationController::TextEnumerator(nsPtrHashKey<nsIContent>* aEntry,
+NotificationController::TextEnumerator(nsCOMPtrHashKey<nsIContent>* aEntry,
                                        void* aUserArg)
 {
   nsDocAccessible* document = static_cast<nsDocAccessible*>(aUserArg);
   nsIContent* textNode = aEntry->GetKey();
   nsAccessible* textAcc = document->GetAccessible(textNode);
 
   // If the text node is not in tree or doesn't have frame then this case should
   // have been handled already by content removal notifications.
--- a/accessible/src/base/NotificationController.h
+++ b/accessible/src/base/NotificationController.h
@@ -338,25 +338,49 @@ private:
   };
 
   /**
    * A pending accessible tree update notifications for content insertions.
    * Don't make this an nsAutoTArray; we use SwapElements() on it.
    */
   nsTArray<nsRefPtr<ContentInsertion> > mContentInsertions;
 
+  template<class T>
+  class nsCOMPtrHashKey : public PLDHashEntryHdr
+  {
+  public:
+    typedef T* KeyType;
+    typedef const T* KeyTypePointer;
+
+    nsCOMPtrHashKey(const T* aKey) : mKey(const_cast<T*>(aKey)) {}
+    nsCOMPtrHashKey(const nsPtrHashKey<T> &aToCopy) : mKey(aToCopy.mKey) {}
+    ~nsCOMPtrHashKey() { }
+
+    KeyType GetKey() const { return mKey; }
+    PRBool KeyEquals(KeyTypePointer aKey) const { return aKey == mKey; }
+
+    static KeyTypePointer KeyToPointer(KeyType aKey) { return aKey; }
+    static PLDHashNumber HashKey(KeyTypePointer aKey)
+      { return NS_PTR_TO_INT32(aKey) >> 2; }
+
+    enum { ALLOW_MEMMOVE = PR_TRUE };
+
+   protected:
+     nsCOMPtr<T> mKey;
+  };
+
   /**
    * A pending accessible tree update notifications for rendered text changes.
    */
-  nsTHashtable<nsPtrHashKey<nsIContent> > mTextHash;
+  nsTHashtable<nsCOMPtrHashKey<nsIContent> > mTextHash;
 
   /**
    * Update the accessible tree for pending rendered text change notifications.
    */
-  static PLDHashOperator TextEnumerator(nsPtrHashKey<nsIContent>* aEntry,
+  static PLDHashOperator TextEnumerator(nsCOMPtrHashKey<nsIContent>* aEntry,
                                         void* aUserArg);
 
   /**
    * Other notifications like DOM events. Don't make this an nsAutoTArray; we
    * use SwapElements() on it.
    */
   nsTArray<nsRefPtr<Notification> > mNotifications;