bug 1124285 - setup proxies on windows r=davidb

Unfortunately on windows there's no separate object implementing the
native interfaces.  That means we need to have a type of accessible that
just wraps a proxy.
This commit is contained in:
Trevor Saunders 2015-01-19 16:34:14 -05:00
parent 0c14b0f231
commit d2ca83463f
6 changed files with 65 additions and 18 deletions

View File

@ -64,10 +64,10 @@ AccGroupInfo::Update()
// If the previous item in the group has calculated group information then
// build group information for this item based on found one.
if (sibling->mGroupInfo) {
mPosInSet += sibling->mGroupInfo->mPosInSet;
mParent = sibling->mGroupInfo->mParent;
mSetSize = sibling->mGroupInfo->mSetSize;
if (sibling->mBits.groupInfo) {
mPosInSet += sibling->mBits.groupInfo->mPosInSet;
mParent = sibling->mBits.groupInfo->mParent;
mSetSize = sibling->mBits.groupInfo->mSetSize;
return;
}
@ -101,9 +101,9 @@ AccGroupInfo::Update()
// If the next item in the group has calculated group information then
// build group information for this item based on found one.
if (sibling->mGroupInfo) {
mParent = sibling->mGroupInfo->mParent;
mSetSize = sibling->mGroupInfo->mSetSize;
if (sibling->mBits.groupInfo) {
mParent = sibling->mBits.groupInfo->mParent;
mSetSize = sibling->mBits.groupInfo->mSetSize;
return;
}

View File

@ -52,6 +52,7 @@ enum AccType {
eHTMLOptGroupType,
eImageMapType,
eMenuPopupType,
eProxyType,
eProgressType,
eRootType,
eXULLabelType,

View File

@ -109,6 +109,7 @@ Accessible::Accessible(nsIContent* aContent, DocAccessible* aDoc) :
mStateFlags(0), mContextFlags(0), mType(0), mGenericTypes(0),
mIndexOfEmbeddedChild(-1), mRoleMapEntry(nullptr)
{
mBits.groupInfo = nullptr;
#ifdef NS_DEBUG_X
{
nsCOMPtr<nsIPresShell> shell(do_QueryReferent(aShell));
@ -1949,7 +1950,11 @@ Accessible::UnbindFromParent()
mParent = nullptr;
mIndexInParent = -1;
mIndexOfEmbeddedChild = -1;
mGroupInfo = nullptr;
if (IsProxy())
MOZ_CRASH("this should never be called on proxy wrappers");
delete mBits.groupInfo;
mBits.groupInfo = nullptr;
mContextFlags &= ~eHasNameDependentParent;
}
@ -2525,17 +2530,20 @@ Accessible::GetActionRule() const
AccGroupInfo*
Accessible::GetGroupInfo()
{
if (mGroupInfo){
if (IsProxy())
MOZ_CRASH("This should never be called on proxy wrappers");
if (mBits.groupInfo){
if (HasDirtyGroupInfo()) {
mGroupInfo->Update();
mBits.groupInfo->Update();
SetDirtyGroupInfo(false);
}
return mGroupInfo;
return mBits.groupInfo;
}
mGroupInfo = AccGroupInfo::CreateGroupInfo(this);
return mGroupInfo;
mBits.groupInfo = AccGroupInfo::CreateGroupInfo(this);
return mBits.groupInfo;
}
void

View File

@ -39,6 +39,7 @@ class HTMLLIAccessible;
class HyperTextAccessible;
class ImageAccessible;
class KeyBinding;
class ProxyAccessible;
class Relation;
class RootAccessible;
class TableAccessible;
@ -607,6 +608,8 @@ public:
bool IsMenuPopup() const { return mType == eMenuPopupType; }
bool IsProxy() const { return mType == eProxyType; }
bool IsProgress() const { return mType == eProgressType; }
bool IsRoot() const { return mType == eRootType; }
@ -1103,7 +1106,11 @@ protected:
int32_t mIndexOfEmbeddedChild;
friend class EmbeddedObjCollector;
nsAutoPtr<AccGroupInfo> mGroupInfo;
union
{
AccGroupInfo* groupInfo;
ProxyAccessible* proxy;
} mBits;
friend class AccGroupInfo;
/**

View File

@ -80,7 +80,13 @@ AccessibleWrap::QueryInterface(REFIID iid, void** ppv)
*ppv = nullptr;
if (IID_IUnknown == iid || IID_IDispatch == iid || IID_IAccessible == iid)
if (IID_IUnknown == iid)
*ppv = static_cast<IAccessible*>(this);
if (!*ppv && IsProxy())
return E_NOINTERFACE;
if (IID_IDispatch == iid || IID_IAccessible == iid)
*ppv = static_cast<IAccessible*>(this);
else if (IID_IEnumVARIANT == iid) {
// Don't support this interface for leaf elements.

View File

@ -10,6 +10,7 @@
#include "Compatibility.h"
#include "HyperTextAccessibleWrap.h"
#include "nsWinUtils.h"
#include "mozilla/a11y/ProxyAccessible.h"
#include "mozilla/ClearOnShutdown.h"
@ -34,14 +35,38 @@ a11y::PlatformShutdown()
nsWinUtils::ShutdownWindowEmulation();
}
void
a11y::ProxyCreated(ProxyAccessible*, uint32_t)
class ProxyAccessibleWrap : public AccessibleWrap
{
public:
ProxyAccessibleWrap(ProxyAccessible* aProxy) :
AccessibleWrap(nullptr, nullptr)
{
mType = eProxyType;
mBits.proxy = aProxy;
}
virtual void Shutdown() MOZ_OVERRIDE
{
mBits.proxy = nullptr;
}
};
void
a11y::ProxyCreated(ProxyAccessible* aProxy, uint32_t)
{
ProxyAccessibleWrap* wrapper = new ProxyAccessibleWrap(aProxy);
wrapper->AddRef();
aProxy->SetWrapper(reinterpret_cast<uintptr_t>(wrapper));
}
void
a11y::ProxyDestroyed(ProxyAccessible*)
a11y::ProxyDestroyed(ProxyAccessible* aProxy)
{
ProxyAccessibleWrap* wrapper =
reinterpret_cast<ProxyAccessibleWrap*>(aProxy->GetWrapper());
wrapper->Shutdown();
aProxy->SetWrapper(0);
wrapper->Release();
}
void