diff --git a/accessible/ipc/win/handler/AccessibleHandlerControl.cpp b/accessible/ipc/win/handler/AccessibleHandlerControl.cpp index cf14de22a652..d1be2cf11067 100644 --- a/accessible/ipc/win/handler/AccessibleHandlerControl.cpp +++ b/accessible/ipc/win/handler/AccessibleHandlerControl.cpp @@ -118,6 +118,7 @@ IMPL_IUNKNOWN1(AccessibleHandlerControl, IHandlerControl) HRESULT AccessibleHandlerControl::Invalidate() { ++mCacheGen; + mAccessibleCache.clear(); return S_OK; } @@ -171,5 +172,23 @@ AccessibleHandlerControl::Register(NotNull aGecko) { return hr; } +void AccessibleHandlerControl::CacheAccessible(long aUniqueId, + AccessibleHandler* aAccessible) { + MOZ_ASSERT(aUniqueId && aAccessible); + mAccessibleCache[aUniqueId] = aAccessible; +} + +HRESULT AccessibleHandlerControl::GetCachedAccessible( + long aUniqueId, AccessibleHandler** aAccessible) { + MOZ_ASSERT(aUniqueId && aAccessible); + auto it = mAccessibleCache.find(aUniqueId); + if (it == mAccessibleCache.end()) { + return E_INVALIDARG; + } + RefPtr ref = it->second; + ref.forget(aAccessible); + return S_OK; +} + } // namespace a11y } // namespace mozilla diff --git a/accessible/ipc/win/handler/AccessibleHandlerControl.h b/accessible/ipc/win/handler/AccessibleHandlerControl.h index 6e39f0623e64..00379fc76a80 100644 --- a/accessible/ipc/win/handler/AccessibleHandlerControl.h +++ b/accessible/ipc/win/handler/AccessibleHandlerControl.h @@ -11,6 +11,7 @@ #ifndef mozilla_a11y_AccessibleHandlerControl_h # define mozilla_a11y_AccessibleHandlerControl_h +# include # include "Factory.h" # include "HandlerData.h" # include "IUnknownImpl.h" @@ -48,6 +49,8 @@ class TextChange final { } // namespace detail +class AccessibleHandler; + class AccessibleHandlerControl final : public IHandlerControl { public: static HRESULT Create(AccessibleHandlerControl** aOutObject); @@ -69,6 +72,9 @@ class AccessibleHandlerControl final : public IHandlerControl { HRESULT Register(NotNull aGecko); + void CacheAccessible(long aUniqueId, AccessibleHandler* aAccessible); + HRESULT GetCachedAccessible(long aUniqueId, AccessibleHandler** aAccessible); + private: AccessibleHandlerControl(); ~AccessibleHandlerControl() = default; @@ -78,6 +84,8 @@ class AccessibleHandlerControl final : public IHandlerControl { detail::TextChange mTextChange; UniquePtr mIA2Proxy; UniquePtr mHandlerProxy; + // We can't use Gecko APIs in this dll, hence the use of std::unordered_map. + std::unordered_map> mAccessibleCache; }; extern mscom::SingletonFactory gControlFactory;