2015-04-06 13:04:44 +03:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* vim: set ts=2 et sw=2 tw=80: */
|
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. *
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef MOZILLA_A11Y_ProxyWrappers_h
|
|
|
|
#define MOZILLA_A11Y_ProxyWrappers_h
|
|
|
|
|
|
|
|
#include "HyperTextAccessible.h"
|
|
|
|
|
|
|
|
namespace mozilla {
|
|
|
|
namespace a11y {
|
|
|
|
|
|
|
|
class ProxyAccessibleWrap : public AccessibleWrap
|
|
|
|
{
|
2016-08-19 22:16:42 +03:00
|
|
|
public:
|
2016-12-16 10:43:21 +03:00
|
|
|
explicit ProxyAccessibleWrap(ProxyAccessible* aProxy) :
|
2015-04-06 13:04:44 +03:00
|
|
|
AccessibleWrap(nullptr, nullptr)
|
|
|
|
{
|
|
|
|
mType = eProxyType;
|
|
|
|
mBits.proxy = aProxy;
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual void Shutdown() override
|
|
|
|
{
|
|
|
|
mBits.proxy = nullptr;
|
2015-10-01 23:47:04 +03:00
|
|
|
mStateFlags |= eIsDefunct;
|
2015-04-06 13:04:44 +03:00
|
|
|
}
|
2016-08-19 22:16:42 +03:00
|
|
|
|
|
|
|
virtual void GetNativeInterface(void** aOutAccessible) override
|
|
|
|
{
|
|
|
|
mBits.proxy->GetCOMInterface(aOutAccessible);
|
|
|
|
}
|
2015-04-06 13:04:44 +03:00
|
|
|
};
|
|
|
|
|
2015-08-07 21:22:52 +03:00
|
|
|
class HyperTextProxyAccessibleWrap : public HyperTextAccessibleWrap
|
2015-04-06 13:04:44 +03:00
|
|
|
{
|
2015-08-07 22:33:20 +03:00
|
|
|
public:
|
2016-12-16 10:43:21 +03:00
|
|
|
explicit HyperTextProxyAccessibleWrap(ProxyAccessible* aProxy) :
|
2015-08-07 21:22:52 +03:00
|
|
|
HyperTextAccessibleWrap(nullptr, nullptr)
|
|
|
|
{
|
|
|
|
mType = eProxyType;
|
|
|
|
mBits.proxy = aProxy;
|
|
|
|
}
|
|
|
|
|
2015-10-01 23:47:04 +03:00
|
|
|
virtual void Shutdown() override
|
|
|
|
{
|
|
|
|
mBits.proxy = nullptr;
|
2016-08-19 22:16:42 +03:00
|
|
|
mStateFlags |= eIsDefunct;
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual void GetNativeInterface(void** aOutAccessible) override
|
|
|
|
{
|
|
|
|
mBits.proxy->GetCOMInterface(aOutAccessible);
|
2015-10-01 23:47:04 +03:00
|
|
|
}
|
2015-04-06 13:04:44 +03:00
|
|
|
};
|
|
|
|
|
2015-08-07 22:42:52 +03:00
|
|
|
class DocProxyAccessibleWrap : public HyperTextProxyAccessibleWrap
|
|
|
|
{
|
|
|
|
public:
|
2016-12-16 10:43:21 +03:00
|
|
|
explicit DocProxyAccessibleWrap(ProxyAccessible* aProxy) :
|
2015-08-11 22:53:43 +03:00
|
|
|
HyperTextProxyAccessibleWrap(aProxy)
|
|
|
|
{ mGenericTypes |= eDocument; }
|
2015-08-12 00:01:01 +03:00
|
|
|
|
|
|
|
void AddID(uint32_t aID, AccessibleWrap* aAcc)
|
|
|
|
{ mIDToAccessibleMap.Put(aID, aAcc); }
|
|
|
|
void RemoveID(uint32_t aID) { mIDToAccessibleMap.Remove(aID); }
|
|
|
|
AccessibleWrap* GetAccessibleByID(uint32_t aID) const
|
|
|
|
{ return mIDToAccessibleMap.Get(aID); }
|
|
|
|
|
|
|
|
private:
|
|
|
|
/*
|
|
|
|
* This provides a mapping from 32 bit id to accessible objects.
|
|
|
|
*/
|
|
|
|
nsDataHashtable<nsUint32HashKey, AccessibleWrap*> mIDToAccessibleMap;
|
2015-08-07 22:42:52 +03:00
|
|
|
};
|
|
|
|
|
2015-04-06 13:04:44 +03:00
|
|
|
template<typename T>
|
|
|
|
inline ProxyAccessible*
|
|
|
|
HyperTextProxyFor(T* aWrapper)
|
|
|
|
{
|
|
|
|
static_assert(mozilla::IsBaseOf<IUnknown, T>::value, "only IAccessible* should be passed in");
|
|
|
|
auto wrapper = static_cast<HyperTextProxyAccessibleWrap*>(aWrapper);
|
|
|
|
return wrapper->IsProxy() ? wrapper->Proxy() : nullptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|