зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1640553 part 1: Add the ability for AccessibleHandler to cache accessibles by id. r=eeejay
This cache is cleared when other AccessibleHandler caches are invalidated; i.e. when an event is fired. Differential Revision: https://phabricator.services.mozilla.com/D76665
This commit is contained in:
Родитель
4d5f4e2f58
Коммит
61ed1074ea
|
@ -118,6 +118,7 @@ IMPL_IUNKNOWN1(AccessibleHandlerControl, IHandlerControl)
|
|||
HRESULT
|
||||
AccessibleHandlerControl::Invalidate() {
|
||||
++mCacheGen;
|
||||
mAccessibleCache.clear();
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
|
@ -171,5 +172,23 @@ AccessibleHandlerControl::Register(NotNull<IGeckoBackChannel*> 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<AccessibleHandler> ref = it->second;
|
||||
ref.forget(aAccessible);
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
} // namespace a11y
|
||||
} // namespace mozilla
|
||||
|
|
|
@ -11,6 +11,7 @@
|
|||
#ifndef mozilla_a11y_AccessibleHandlerControl_h
|
||||
# define mozilla_a11y_AccessibleHandlerControl_h
|
||||
|
||||
# include <unordered_map>
|
||||
# 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<IGeckoBackChannel*> 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<mscom::RegisteredProxy> mIA2Proxy;
|
||||
UniquePtr<mscom::RegisteredProxy> mHandlerProxy;
|
||||
// We can't use Gecko APIs in this dll, hence the use of std::unordered_map.
|
||||
std::unordered_map<long, RefPtr<AccessibleHandler>> mAccessibleCache;
|
||||
};
|
||||
|
||||
extern mscom::SingletonFactory<AccessibleHandlerControl> gControlFactory;
|
||||
|
|
Загрузка…
Ссылка в новой задаче