From 4f8cb5998f8a2627b33fc0acc96ad6c8cea0e17f Mon Sep 17 00:00:00 2001 From: James Teh Date: Sun, 21 May 2023 22:23:48 +0000 Subject: [PATCH] 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 --- accessible/base/CacheConstants.h | 1 + accessible/ipc/RemoteAccessibleBase.h | 7 - accessible/ipc/win/RemoteAccessible.cpp | 148 -------------------- accessible/ipc/win/RemoteAccessible.h | 22 --- accessible/ipc/win/moz.build | 1 - accessible/xpcom/xpcAccessibleHyperText.cpp | 4 + 6 files changed, 5 insertions(+), 178 deletions(-) delete mode 100644 accessible/ipc/win/RemoteAccessible.cpp diff --git a/accessible/base/CacheConstants.h b/accessible/base/CacheConstants.h index a0517d3ad2e5..ab835b463913 100644 --- a/accessible/base/CacheConstants.h +++ b/accessible/base/CacheConstants.h @@ -7,6 +7,7 @@ #ifndef _CacheConstants_h_ #define _CacheConstants_h_ +#include "nsGkAtoms.h" #include "RelationType.h" namespace mozilla { diff --git a/accessible/ipc/RemoteAccessibleBase.h b/accessible/ipc/RemoteAccessibleBase.h index 4df232d562ff..0689b614e700 100644 --- a/accessible/ipc/RemoteAccessibleBase.h +++ b/accessible/ipc/RemoteAccessibleBase.h @@ -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 -#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); } diff --git a/accessible/ipc/win/RemoteAccessible.cpp b/accessible/ipc/win/RemoteAccessible.cpp deleted file mode 100644 index 50b5cb447f59..000000000000 --- a/accessible/ipc/win/RemoteAccessible.cpp +++ /dev/null @@ -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 - -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 thisPtr = const_cast(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 proxy = msaa->GetIAccessibleFor(realId, &isDefunct); - if (!thisPtr) { - *aOutAccessible = nullptr; - return false; - } - thisPtr->mCOMProxy = proxy; - } - - RefPtr addRefed = mCOMProxy; - addRefed.forget(aOutAccessible); - return !!mCOMProxy; -} - -/** - * Specializations of this template map an IAccessible type to its IID - */ -template -struct InterfaceIID {}; - -template <> -struct InterfaceIID { - static REFIID Value() { return IID_IAccessibleValue; } -}; - -template <> -struct InterfaceIID { - static REFIID Value() { return IID_IAccessibleText; } -}; - -template <> -struct InterfaceIID { - static REFIID Value() { return IID_IAccessibleHyperlink; } -}; - -template <> -struct InterfaceIID { - static REFIID Value() { return IID_IGeckoCustom; } -}; - -template <> -struct InterfaceIID { - static REFIID Value() { return IID_IAccessible2_2; } -}; - -/** - * Get the COM proxy for this proxy accessible and QueryInterface it with the - * correct IID - */ -template -static already_AddRefed QueryInterface( - const RemoteAccessible* aProxy) { - RefPtr acc; - if (!aProxy->GetCOMInterface((void**)getter_AddRefs(acc))) { - return nullptr; - } - - RefPtr acc2; - if (FAILED(acc->QueryInterface(InterfaceIID::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 acc = QueryInterface(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(aStartOffset), - static_cast(aEndOffset), coordType, - static_cast(aX), static_cast(aY)); -} - -} // namespace a11y -} // namespace mozilla diff --git a/accessible/ipc/win/RemoteAccessible.h b/accessible/ipc/win/RemoteAccessible.h index e530292ec183..b8755972ccb1 100644 --- a/accessible/ipc/win/RemoteAccessible.h +++ b/accessible/ipc/win/RemoteAccessible.h @@ -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 namespace mozilla { namespace a11y { @@ -37,27 +31,11 @@ class RemoteAccessible : public RemoteAccessibleBase { #include "mozilla/a11y/RemoteAccessibleShared.h" - bool GetCOMInterface(void** aOutAccessible) const; - void SetCOMInterface(const RefPtr& 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 mCOMProxy; - bool mSafeToRecurse = true; }; //////////////////////////////////////////////////////////////////////////////// diff --git a/accessible/ipc/win/moz.build b/accessible/ipc/win/moz.build index 597f358f0bec..80f30990052c 100644 --- a/accessible/ipc/win/moz.build +++ b/accessible/ipc/win/moz.build @@ -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 diff --git a/accessible/xpcom/xpcAccessibleHyperText.cpp b/accessible/xpcom/xpcAccessibleHyperText.cpp index 67e5d1424c71..1dcae7f7bcfa 100644 --- a/accessible/xpcom/xpcAccessibleHyperText.cpp +++ b/accessible/xpcom/xpcAccessibleHyperText.cpp @@ -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; }