From 640af21671ba27c0474bb1f7074aca7afe1eb5e2 Mon Sep 17 00:00:00 2001 From: James Teh Date: Fri, 9 Sep 2022 01:44:52 +0000 Subject: [PATCH] Bug 1789750: Don't try to get a COM proxy in Windows RemoteAccessible when the cache is disabled. r=nlapre For methods supported by the cache, we already delegate to RemoteAccessibleBase where the caching implementation lives. However, there are still some less used methods which aren't supported by the cache yet. These methods are never called by the code which Windows a11y clients interact with (MsaaAccessible and friends). However, they can be called from XPCOM; e.g. when using the Browser Console. For now, just early return in these cases so we don't crash. Eventually, we'll need to unify these methods and support them with the cache enabled. Differential Revision: https://phabricator.services.mozilla.com/D156771 --- accessible/ipc/win/RemoteAccessible.cpp | 37 +++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/accessible/ipc/win/RemoteAccessible.cpp b/accessible/ipc/win/RemoteAccessible.cpp index e0543f37f8fa..f913588d2822 100644 --- a/accessible/ipc/win/RemoteAccessible.cpp +++ b/accessible/ipc/win/RemoteAccessible.cpp @@ -278,6 +278,11 @@ nsIntRect RemoteAccessible::BoundsInCSSPixels() const { } void RemoteAccessible::Language(nsString& aLocale) { + if (StaticPrefs::accessibility_cache_enabled_AtStartup()) { + // Not yet supported by the cache. + aLocale.Truncate(); + return; + } aLocale.Truncate(); RefPtr acc; @@ -462,6 +467,10 @@ double RemoteAccessible::CurValue() const { } bool RemoteAccessible::SetCurValue(double aValue) { + if (StaticPrefs::accessibility_cache_enabled_AtStartup()) { + // Not yet supported by the cache. + return false; + } RefPtr acc = QueryInterface(this); if (!acc) { return false; @@ -668,6 +677,10 @@ void RemoteAccessible::TextAtOffset(int32_t aOffset, bool RemoteAccessible::AddToSelection(int32_t aStartOffset, int32_t aEndOffset) { + if (StaticPrefs::accessibility_cache_enabled_AtStartup()) { + // Not yet supported by the cache. + return false; + } RefPtr acc = QueryInterface(this); if (!acc) { return false; @@ -678,6 +691,10 @@ bool RemoteAccessible::AddToSelection(int32_t aStartOffset, } bool RemoteAccessible::RemoveFromSelection(int32_t aSelectionNum) { + if (StaticPrefs::accessibility_cache_enabled_AtStartup()) { + // Not yet supported by the cache. + return false; + } RefPtr acc = QueryInterface(this); if (!acc) { return false; @@ -724,6 +741,10 @@ void RemoteAccessible::SetCaretOffset(int32_t aOffset) { void RemoteAccessible::ScrollSubstringTo(int32_t aStartOffset, int32_t aEndOffset, uint32_t aScrollType) { + if (StaticPrefs::accessibility_cache_enabled_AtStartup()) { + // Not yet supported by the cache. + return; + } RefPtr acc = QueryInterface(this); if (!acc) { return; @@ -741,6 +762,10 @@ void RemoteAccessible::ScrollSubstringToPoint(int32_t aStartOffset, int32_t aEndOffset, uint32_t aCoordinateType, int32_t aX, int32_t aY) { + if (StaticPrefs::accessibility_cache_enabled_AtStartup()) { + // Not yet supported by the cache. + return; + } RefPtr acc = QueryInterface(this); if (!acc) { return; @@ -763,6 +788,10 @@ void RemoteAccessible::ScrollSubstringToPoint(int32_t aStartOffset, } bool RemoteAccessible::IsLinkValid() { + if (StaticPrefs::accessibility_cache_enabled_AtStartup()) { + // Not yet supported by the cache. + return false; + } RefPtr acc = QueryInterface(this); if (!acc) { return false; @@ -778,6 +807,10 @@ bool RemoteAccessible::IsLinkValid() { uint32_t RemoteAccessible::AnchorCount(bool* aOk) { *aOk = false; + if (StaticPrefs::accessibility_cache_enabled_AtStartup()) { + // Not yet supported by the cache. + return 0; + } RefPtr custom = QueryInterface(this); if (!custom) { return 0; @@ -793,6 +826,10 @@ uint32_t RemoteAccessible::AnchorCount(bool* aOk) { } RemoteAccessible* RemoteAccessible::AnchorAt(uint32_t aIdx) { + if (StaticPrefs::accessibility_cache_enabled_AtStartup()) { + // Not yet supported by the cache. + return nullptr; + } RefPtr link = QueryInterface(this); if (!link) {