From 19e006d017be7c737c72c06f2ede4227841d79a0 Mon Sep 17 00:00:00 2001 From: James Teh Date: Sat, 1 May 2021 02:51:23 +0000 Subject: [PATCH] Bug 1694865 part 16: Transitional implementation of IUnknown in MsaaAccessible/MsaaDocAccessible which delegates to AccessibleWrap. r=morgan This is necessary to enable COM objects which aggregate AccessibleWrap/DocAccessibleWrap to aggregate MsaaAccessible/MsaaDocAccessible instead. Ultimately, the IUnknown implementation will be moved out of AccessibleWrap altogether and into MsaaAccessible, but we can't do that yet. Even though MsaaDocAccessible indirectly inherits from MsaaAccessible, we have to override QueryInterface due to the naming conflict with nsISupports. Differential Revision: https://phabricator.services.mozilla.com/D112948 --- accessible/windows/msaa/MsaaAccessible.cpp | 14 ++++++++++++++ accessible/windows/msaa/MsaaAccessible.h | 5 +++++ accessible/windows/msaa/MsaaDocAccessible.h | 12 +++++++++--- 3 files changed, 28 insertions(+), 3 deletions(-) diff --git a/accessible/windows/msaa/MsaaAccessible.cpp b/accessible/windows/msaa/MsaaAccessible.cpp index 262d94579bb3..83c0dcd4c07a 100644 --- a/accessible/windows/msaa/MsaaAccessible.cpp +++ b/accessible/windows/msaa/MsaaAccessible.cpp @@ -618,6 +618,20 @@ ITypeInfo* MsaaAccessible::GetTI(LCID lcid) { return gTypeInfo; } +// IUnknown methods +// XXX This delegation to AccessibleWrap is a necessary hack until we can move +// the IUnknown implementation out of AccessibleWrap. + +STDMETHODIMP MsaaAccessible::QueryInterface(REFIID iid, void** ppv) { + return static_cast(this)->QueryInterface(iid, ppv); +} +ULONG STDMETHODCALLTYPE MsaaAccessible::AddRef() { + return static_cast(this)->AddRef(); +} +ULONG STDMETHODCALLTYPE MsaaAccessible::Release() { + return static_cast(this)->Release(); +} + // IAccessible methods STDMETHODIMP diff --git a/accessible/windows/msaa/MsaaAccessible.h b/accessible/windows/msaa/MsaaAccessible.h index 50aa67378e60..43db988360d2 100644 --- a/accessible/windows/msaa/MsaaAccessible.h +++ b/accessible/windows/msaa/MsaaAccessible.h @@ -66,6 +66,11 @@ class MsaaAccessible : public ia2Accessible, static IDispatch* NativeAccessible(LocalAccessible* aAccessible); + // IUnknown + STDMETHODIMP QueryInterface(REFIID, void**) override; + ULONG STDMETHODCALLTYPE AddRef() override; + ULONG STDMETHODCALLTYPE Release() override; + // IAccessible virtual /* [id][propget] */ HRESULT STDMETHODCALLTYPE get_accParent( /* [retval][out] */ IDispatch __RPC_FAR* __RPC_FAR* ppdispParent) diff --git a/accessible/windows/msaa/MsaaDocAccessible.h b/accessible/windows/msaa/MsaaDocAccessible.h index dc5ab1c7aef0..499653492f58 100644 --- a/accessible/windows/msaa/MsaaDocAccessible.h +++ b/accessible/windows/msaa/MsaaDocAccessible.h @@ -24,6 +24,15 @@ class MsaaDocAccessible : public DocAccessible { MsaaDocAccessible(dom::Document* aDocument, PresShell* aPresShell) : DocAccessible(aDocument, aPresShell) {} + DocAccessible* DocAcc(); + + // IUnknown + // XXX This override of QueryInterface is a necessary hack until we get rid + // of the inheritance of DocAccessible. + STDMETHODIMP QueryInterface(REFIID iid, void** ppv) override { + return MsaaAccessible::QueryInterface(iid, ppv); + } + // IAccessible // Override get_accParent for e10s @@ -52,9 +61,6 @@ class MsaaDocAccessible : public DocAccessible { * This provides a mapping from 32 bit id to accessible objects. */ nsTHashMap mIDToAccessibleMap; - - private: - DocAccessible* DocAcc(); }; } // namespace a11y