Bug 629912, part2 - crash [@ NotificationController::TextEnumerator, keep text nodes addrefed, r=marcoz, sr=neil, a=betaN
Bug 629912, part2 - crash [@ NotificationController::TextEnumerator, keep text nodes addrefed, r=marcoz, sr=neil, a=betaN
--- 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;