diff --git a/accessible/windows/msaa/AccessibleWrap.cpp b/accessible/windows/msaa/AccessibleWrap.cpp index b67ced87505..c4e613fe2af 100644 --- a/accessible/windows/msaa/AccessibleWrap.cpp +++ b/accessible/windows/msaa/AccessibleWrap.cpp @@ -60,8 +60,6 @@ static gAccessibles = 0; #ifdef _WIN64 IDSet AccessibleWrap::sIDGen; - -static const uint32_t kNoID = 0; #endif static const int32_t kIEnumVariantDisconnected = -1; diff --git a/accessible/windows/msaa/AccessibleWrap.h b/accessible/windows/msaa/AccessibleWrap.h index 6a1ab3abdca..771dad5a02c 100644 --- a/accessible/windows/msaa/AccessibleWrap.h +++ b/accessible/windows/msaa/AccessibleWrap.h @@ -177,6 +177,11 @@ public: // construction, destruction static IDispatch* NativeAccessible(Accessible* aAccessible); +#ifdef _WIN64 + uint32_t GetExistingID() const { return mID; } + static const uint32_t kNoID = 0; +#endif + protected: virtual ~AccessibleWrap(); diff --git a/accessible/windows/msaa/Platform.cpp b/accessible/windows/msaa/Platform.cpp index 9d2fb5034b5..791205ccd85 100644 --- a/accessible/windows/msaa/Platform.cpp +++ b/accessible/windows/msaa/Platform.cpp @@ -59,6 +59,17 @@ a11y::ProxyDestroyed(ProxyAccessible* aProxy) if (!wrapper) return; + auto doc = + static_cast(WrapperFor(aProxy->Document())); +#ifdef _WIN64 + uint32_t id = wrapper->GetExistingID(); + if (id != AccessibleWrap::kNoID) { + doc->RemoveID(id); + } +#else + doc->RemoveID(-reinterpret_cast(wrapper)); +#endif + wrapper->Shutdown(); aProxy->SetWrapper(0); wrapper->Release();