зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1821956 part 8: Remove most of the remaining parts of Windows RemoteAccessible. r=nlapre
This only worked with the COM proxy architecture. It cannot be used with the cache active. This includes ScrollSubstringToPoint, and since that isn't currently supported by the cache, it isn't supported at all on Windows now. However, no one seems to use this on Windows and this implementation can't be used with the cache active anyway. Differential Revision: https://phabricator.services.mozilla.com/D177901
This commit is contained in:
Родитель
a3f5b3838c
Коммит
4f8cb5998f
|
@ -7,6 +7,7 @@
|
|||
#ifndef _CacheConstants_h_
|
||||
#define _CacheConstants_h_
|
||||
|
||||
#include "nsGkAtoms.h"
|
||||
#include "RelationType.h"
|
||||
|
||||
namespace mozilla {
|
||||
|
|
|
@ -11,7 +11,6 @@
|
|||
#include "mozilla/a11y/CacheConstants.h"
|
||||
#include "mozilla/a11y/HyperTextAccessibleBase.h"
|
||||
#include "mozilla/a11y/Role.h"
|
||||
#include "mozilla/WeakPtr.h"
|
||||
#include "AccAttributes.h"
|
||||
#include "nsIAccessibleText.h"
|
||||
#include "nsIAccessibleTypes.h"
|
||||
|
@ -32,13 +31,7 @@ enum class RelationType;
|
|||
* process.
|
||||
*/
|
||||
template <class Derived>
|
||||
#ifdef XP_WIN
|
||||
class RemoteAccessibleBase : public Accessible,
|
||||
public HyperTextAccessibleBase,
|
||||
public SupportsWeakPtr {
|
||||
#else
|
||||
class RemoteAccessibleBase : public Accessible, public HyperTextAccessibleBase {
|
||||
#endif
|
||||
public:
|
||||
virtual ~RemoteAccessibleBase() { MOZ_ASSERT(!mWrapper); }
|
||||
|
||||
|
|
|
@ -1,148 +0,0 @@
|
|||
/* -*- 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/. */
|
||||
|
||||
#include "Accessible2.h"
|
||||
#include "RemoteAccessible.h"
|
||||
#include "ia2AccessibleRelation.h"
|
||||
#include "ia2AccessibleValue.h"
|
||||
#include "IGeckoCustom.h"
|
||||
#include "mozilla/a11y/DocAccessibleParent.h"
|
||||
#include "DocAccessible.h"
|
||||
#include "mozilla/a11y/DocManager.h"
|
||||
#include "mozilla/dom/Element.h"
|
||||
#include "mozilla/dom/BrowserParent.h"
|
||||
#include "mozilla/Unused.h"
|
||||
#include "mozilla/a11y/Platform.h"
|
||||
#include "Relation.h"
|
||||
#include "RelationType.h"
|
||||
#include "mozilla/a11y/Role.h"
|
||||
#include "nsAccessibilityService.h"
|
||||
|
||||
#include <comutil.h>
|
||||
|
||||
namespace mozilla {
|
||||
namespace a11y {
|
||||
|
||||
bool RemoteAccessible::GetCOMInterface(void** aOutAccessible) const {
|
||||
if (!aOutAccessible) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// This should never be called if the cache is enabled. We can't get a COM
|
||||
// proxy from the content process in that case. Instead, the code below would
|
||||
// return an MsaaAccessible from our process which would end up calling
|
||||
// methods here in RemoteAccessible, causing infinite recursion.
|
||||
MOZ_ASSERT(!a11y::IsCacheActive());
|
||||
if (!mCOMProxy && mSafeToRecurse) {
|
||||
WeakPtr<RemoteAccessible> thisPtr = const_cast<RemoteAccessible*>(this);
|
||||
// See if we can lazily obtain a COM proxy
|
||||
MsaaAccessible* msaa = MsaaAccessible::GetFrom(thisPtr);
|
||||
bool isDefunct = false;
|
||||
// NB: Don't pass CHILDID_SELF here, use the absolute MSAA ID. Otherwise
|
||||
// GetIAccessibleFor will recurse into this function and we will just
|
||||
// overflow the stack.
|
||||
VARIANT realId = {{{VT_I4}}};
|
||||
realId.ulVal = msaa->GetExistingID();
|
||||
MOZ_DIAGNOSTIC_ASSERT(realId.ulVal != CHILDID_SELF);
|
||||
RefPtr<IAccessible> proxy = msaa->GetIAccessibleFor(realId, &isDefunct);
|
||||
if (!thisPtr) {
|
||||
*aOutAccessible = nullptr;
|
||||
return false;
|
||||
}
|
||||
thisPtr->mCOMProxy = proxy;
|
||||
}
|
||||
|
||||
RefPtr<IAccessible> addRefed = mCOMProxy;
|
||||
addRefed.forget(aOutAccessible);
|
||||
return !!mCOMProxy;
|
||||
}
|
||||
|
||||
/**
|
||||
* Specializations of this template map an IAccessible type to its IID
|
||||
*/
|
||||
template <typename Interface>
|
||||
struct InterfaceIID {};
|
||||
|
||||
template <>
|
||||
struct InterfaceIID<IAccessibleValue> {
|
||||
static REFIID Value() { return IID_IAccessibleValue; }
|
||||
};
|
||||
|
||||
template <>
|
||||
struct InterfaceIID<IAccessibleText> {
|
||||
static REFIID Value() { return IID_IAccessibleText; }
|
||||
};
|
||||
|
||||
template <>
|
||||
struct InterfaceIID<IAccessibleHyperlink> {
|
||||
static REFIID Value() { return IID_IAccessibleHyperlink; }
|
||||
};
|
||||
|
||||
template <>
|
||||
struct InterfaceIID<IGeckoCustom> {
|
||||
static REFIID Value() { return IID_IGeckoCustom; }
|
||||
};
|
||||
|
||||
template <>
|
||||
struct InterfaceIID<IAccessible2_2> {
|
||||
static REFIID Value() { return IID_IAccessible2_2; }
|
||||
};
|
||||
|
||||
/**
|
||||
* Get the COM proxy for this proxy accessible and QueryInterface it with the
|
||||
* correct IID
|
||||
*/
|
||||
template <typename Interface>
|
||||
static already_AddRefed<Interface> QueryInterface(
|
||||
const RemoteAccessible* aProxy) {
|
||||
RefPtr<IAccessible> acc;
|
||||
if (!aProxy->GetCOMInterface((void**)getter_AddRefs(acc))) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
RefPtr<Interface> acc2;
|
||||
if (FAILED(acc->QueryInterface(InterfaceIID<Interface>::Value(),
|
||||
(void**)getter_AddRefs(acc2)))) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
return acc2.forget();
|
||||
}
|
||||
|
||||
/**
|
||||
* aCoordinateType is one of the nsIAccessibleCoordinateType constants.
|
||||
*/
|
||||
void RemoteAccessible::ScrollSubstringToPoint(int32_t aStartOffset,
|
||||
int32_t aEndOffset,
|
||||
uint32_t aCoordinateType,
|
||||
int32_t aX, int32_t aY) {
|
||||
if (a11y::IsCacheActive()) {
|
||||
// Not yet supported by the cache.
|
||||
return;
|
||||
}
|
||||
RefPtr<IAccessibleText> acc = QueryInterface<IAccessibleText>(this);
|
||||
if (!acc) {
|
||||
return;
|
||||
}
|
||||
|
||||
IA2CoordinateType coordType;
|
||||
if (aCoordinateType ==
|
||||
nsIAccessibleCoordinateType::COORDTYPE_SCREEN_RELATIVE) {
|
||||
coordType = IA2_COORDTYPE_SCREEN_RELATIVE;
|
||||
} else if (aCoordinateType ==
|
||||
nsIAccessibleCoordinateType::COORDTYPE_PARENT_RELATIVE) {
|
||||
coordType = IA2_COORDTYPE_PARENT_RELATIVE;
|
||||
} else {
|
||||
MOZ_CRASH("unsupported coord type");
|
||||
}
|
||||
|
||||
acc->scrollSubstringToPoint(static_cast<long>(aStartOffset),
|
||||
static_cast<long>(aEndOffset), coordType,
|
||||
static_cast<long>(aX), static_cast<long>(aY));
|
||||
}
|
||||
|
||||
} // namespace a11y
|
||||
} // namespace mozilla
|
|
@ -7,14 +7,8 @@
|
|||
#ifndef mozilla_a11y_RemoteAccessible_h
|
||||
#define mozilla_a11y_RemoteAccessible_h
|
||||
|
||||
#include "LocalAccessible.h"
|
||||
#include "mozilla/a11y/RemoteAccessibleBase.h"
|
||||
#include "mozilla/a11y/Role.h"
|
||||
#include "nsString.h"
|
||||
#include "nsTArray.h"
|
||||
#include "nsRect.h"
|
||||
|
||||
#include <oleacc.h>
|
||||
|
||||
namespace mozilla {
|
||||
namespace a11y {
|
||||
|
@ -37,27 +31,11 @@ class RemoteAccessible : public RemoteAccessibleBase<RemoteAccessible> {
|
|||
|
||||
#include "mozilla/a11y/RemoteAccessibleShared.h"
|
||||
|
||||
bool GetCOMInterface(void** aOutAccessible) const;
|
||||
void SetCOMInterface(const RefPtr<IAccessible>& aIAccessible) {
|
||||
if (aIAccessible) {
|
||||
mCOMProxy = aIAccessible;
|
||||
} else {
|
||||
// If we were supposed to be receiving an interface (hence the call to
|
||||
// this function), but the interface turns out to be null, then we're
|
||||
// broken for some reason.
|
||||
mSafeToRecurse = false;
|
||||
}
|
||||
}
|
||||
|
||||
protected:
|
||||
explicit RemoteAccessible(DocAccessibleParent* aThisAsDoc)
|
||||
: RemoteAccessibleBase(aThisAsDoc) {
|
||||
MOZ_COUNT_CTOR(RemoteAccessible);
|
||||
}
|
||||
|
||||
private:
|
||||
RefPtr<IAccessible> mCOMProxy;
|
||||
bool mSafeToRecurse = true;
|
||||
};
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
|
|
@ -27,7 +27,6 @@ if CONFIG["ACCESSIBILITY"]:
|
|||
"DocAccessibleChild.cpp",
|
||||
"HandlerProvider.cpp",
|
||||
"PlatformChild.cpp",
|
||||
"RemoteAccessible.cpp",
|
||||
]
|
||||
|
||||
# Give some symbols a unique name in each translation unit, to avoid
|
||||
|
|
|
@ -326,8 +326,12 @@ xpcAccessibleHyperText::ScrollSubstringToPoint(int32_t aStartOffset,
|
|||
IntlLocal()->ScrollSubstringToPoint(aStartOffset, aEndOffset,
|
||||
aCoordinateType, aX, aY);
|
||||
} else {
|
||||
#if defined(XP_WIN)
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
#else
|
||||
mIntl->AsRemote()->ScrollSubstringToPoint(aStartOffset, aEndOffset,
|
||||
aCoordinateType, aX, aY);
|
||||
#endif
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче