File tree Expand file tree Collapse file tree 4 files changed +17
-4
lines changed Expand file tree Collapse file tree 4 files changed +17
-4
lines changed Original file line number Diff line number Diff line change @@ -93,7 +93,13 @@ using namespace mozilla::a11y;
93
93
// //////////////////////////////////////////////////////////////////////////////
94
94
// Accessible: nsISupports and cycle collection
95
95
96
- NS_IMPL_CYCLE_COLLECTION (Accessible, mContent )
96
+ NS_IMPL_CYCLE_COLLECTION_CLASS (Accessible)
97
+ NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(Accessible)
98
+ tmp->Shutdown();
99
+ NS_IMPL_CYCLE_COLLECTION_UNLINK_END
100
+ NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN (Accessible)
101
+ NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mContent , mDoc )
102
+ NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
97
103
98
104
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(Accessible)
99
105
if (aIID.Equals(NS_GET_IID(Accessible)))
Original file line number Diff line number Diff line change @@ -1138,7 +1138,7 @@ class Accessible : public nsISupports
1138
1138
1139
1139
// Data Members
1140
1140
nsCOMPtr<nsIContent> mContent ;
1141
- DocAccessible* mDoc ;
1141
+ RefPtr< DocAccessible> mDoc ;
1142
1142
1143
1143
Accessible* mParent ;
1144
1144
nsTArray<Accessible*> mChildren ;
Original file line number Diff line number Diff line change @@ -80,7 +80,12 @@ static const uint32_t kRelationAttrsLen = ArrayLength(kRelationAttrs);
80
80
81
81
DocAccessible::
82
82
DocAccessible (nsIDocument* aDocument, nsIPresShell* aPresShell) :
83
- HyperTextAccessibleWrap(nullptr , this ),
83
+ // XXX don't pass a document to the Accessible constructor so that we don't
84
+ // set mDoc until our vtable is fully setup. If we set mDoc before setting
85
+ // up the vtable we will call Accessible::AddRef() but not the overrides of
86
+ // it for subclasses. It is important to call those overrides to avoid
87
+ // confusing leak checking machinary.
88
+ HyperTextAccessibleWrap(nullptr , nullptr ),
84
89
// XXX aaronl should we use an algorithm for the initial cache size?
85
90
mAccessibleCache(kDefaultCacheLength ),
86
91
mNodeToAccessibleMap(kDefaultCacheLength ),
@@ -92,6 +97,7 @@ DocAccessible::
92
97
{
93
98
mGenericTypes |= eDocument;
94
99
mStateFlags |= eNotNodeMapEntry;
100
+ mDoc = this ;
95
101
96
102
MOZ_ASSERT (mPresShell , " should have been given a pres shell" );
97
103
mPresShell ->SetDocAccessible (this );
Original file line number Diff line number Diff line change 90
90
AccessibleWrap::Shutdown()
91
91
{
92
92
if (mID != kNoID ) {
93
- auto doc = static_cast <DocAccessibleWrap*>(mDoc );
93
+ auto doc = static_cast <DocAccessibleWrap*>(mDoc . get () );
94
94
MOZ_ASSERT (doc);
95
95
if (doc) {
96
96
doc->RemoveID (mID );
97
+ mID = kNoID ;
97
98
}
98
99
}
99
100
You can’t perform that action at this time.
0 commit comments