Commit Graph

765 Commits

Author SHA1 Message Date
James Teh
c2b101c8e7 Bug 1854040: When doing UIA client detection on Windows 11, call GetNamedPipeServerProcessId before querying the handle's name. r=nlapre
Querying a handle's name can hang forever in some cases.
I'm hoping (albeit doubtfully) that GetNamedPipeServerProcessId might not hang where querying the handle's name does, and also that the handle that's hanging isn't the handle we need.
This seems to fix the problem for one user, so maybe my doubts are unfounded.

Differential Revision: https://phabricator.services.mozilla.com/D197035
2024-02-05 21:57:37 +00:00
Emilio Cobos Álvarez
07c2523b91 Bug 1870512 - Remove accessibility hack that should not longer be needed. r=Jamie
There's no windows with popup=true anymore as of the previous patch.

Depends on D196665

Differential Revision: https://phabricator.services.mozilla.com/D196666
2023-12-20 21:51:06 +00:00
Norisz Fay
90733dd7b4 Backed out changeset 846e436ca1c2 (bug 1870512) for causing automation.py related Windows failures CLOSED TREE 2023-12-18 21:53:13 +02:00
Emilio Cobos Álvarez
1fb0635d77 Bug 1870512 - Remove accessibility hack that should not longer be needed. r=Jamie
There's no windows with popup=true anymore as of the previous patch.

Depends on D196665

Differential Revision: https://phabricator.services.mozilla.com/D196666
2023-12-18 17:56:42 +00:00
James Teh
f36ae8432b Bug 1862802 part 5: Remove virtual cursor change event. r=eeejay
Depends on D192645

Differential Revision: https://phabricator.services.mozilla.com/D192646
2023-11-29 03:53:20 +00:00
James Teh
447aa32c0e Bug 1862802 part 1: Provide an argument to PlatformCaretMoveEvent specifying whether the event was caused by user input. r=eeejay
This is needed in order to support find in page on Android using remote caret events instead of virtual cursor change events.

Depends on D192641

Differential Revision: https://phabricator.services.mozilla.com/D192642
2023-11-29 03:53:19 +00:00
Butkovits Atila
1cb12b49dd Backed out 5 changesets (bug 1862802) for causing multiple failures. CLOSED TREE
Backed out changeset 786805a2cdcc (bug 1862802)
Backed out changeset effe12f2120a (bug 1862802)
Backed out changeset 7488e7ba80c5 (bug 1862802)
Backed out changeset 3d0747ce0174 (bug 1862802)
Backed out changeset d1558d374cef (bug 1862802)
2023-11-29 03:10:17 +02:00
James Teh
44caba5c0c Bug 1862802 part 5: Remove virtual cursor change event. r=eeejay
Depends on D192645

Differential Revision: https://phabricator.services.mozilla.com/D192646
2023-11-28 22:03:21 +00:00
James Teh
cfdccbd78f Bug 1862802 part 1: Provide an argument to PlatformCaretMoveEvent specifying whether the event was caused by user input. r=eeejay
This is needed in order to support find in page on Android using remote caret events instead of virtual cursor change events.

Depends on D192641

Differential Revision: https://phabricator.services.mozilla.com/D192642
2023-11-28 22:03:19 +00:00
James Teh
384d7e17fe Bug 1863482 part 1: Change includes of RelationType.h to mozilla/a11y/RelationType.h. r=eeejay
RelationType.h will soon be generated, but it will be generated within the obj dir, so local includes won't work.
Our C++ style guide says we should prefer exported includes wherever possible anyway.

This was done with this shell command inside the accessible/ directory:

```
sed -i 's,#include "RelationType.h",#include "mozilla/a11y/RelationType.h",' `git grep -l '#include "RelationType.h"'`
```

Differential Revision: https://phabricator.services.mozilla.com/D193001
2023-11-14 02:31:54 +00:00
James Teh
6ac2a29689 Bug 1860941: Don't pointlessly call GetProp in EnableBlindAggregation if there's no LazyInstantiator on which blind aggregation needs to be enabled. r=morgan
Differential Revision: https://phabricator.services.mozilla.com/D191812
2023-10-25 22:58:15 +00:00
James Teh
9dfdbe18c8 Bug 1860001: Handle invalid events. r=eeejay
Differential Revision: https://phabricator.services.mozilla.com/D191601
2023-10-23 22:48:11 +00:00
James Teh
92e74db106 Bug 1843832: Never return the text leaf child of a link when calling IAccessible::accHitTest on an ancestor of the link. r=nlapre
This is necessary to work around a bug in the Windows UI Automation -> IAccessible2 proxy.
See the code comments for details.

Differential Revision: https://phabricator.services.mozilla.com/D187529
2023-10-05 04:12:28 +00:00
Yannis Juglaret
b24022bb02 Bug 1777960 - Patch msctf.dll to prevent a crash with ZoneAlarm Anti-Keylogger. r=gstoll,win-reviewers
Starting with Windows 11 22H2, Microsoft has made internal changes in
msctf.dll. The TF_Notify function, also known as CtfImmNotify from
imm32.dll, uses a new convention for its third argument. These changes
are incompatible with current versions of ZoneAlarm Anti-Keylogger,
resulting in crashes in our main process.

This patch converts messages forwarded by ZoneAlarm Anti-Keylogger to
the new convention. If we detect the product and an incompatible version
of msctf.dll, then we hook TF_Notify and detect any message using the
old convention, and convert it to the new convention.

Differential Revision: https://phabricator.services.mozilla.com/D189518
2023-10-03 15:24:47 +00:00
Masatoshi Kimura
217c7989da Bug 1852806 - Remove macros for older Windows SDK from accessible/windows/msaa/. r=nlapre
Differential Revision: https://phabricator.services.mozilla.com/D188018
2023-09-15 03:19:25 +00:00
Cosmin Sabou
f8c16a8f94 Backed out 15 changesets (bug 1852806) for causing mda failures on test_video_low_power_telemetry.html. CLOSED TREE
Backed out changeset faea1f4cb9a9 (bug 1852806)
Backed out changeset 4db93c374f9b (bug 1852806)
Backed out changeset 7e40e0e04921 (bug 1852806)
Backed out changeset b0a66c4269ce (bug 1852806)
Backed out changeset 4ff3545936f9 (bug 1852806)
Backed out changeset 02c0a8eb3fd6 (bug 1852806)
Backed out changeset ae2c7b33acfb (bug 1852806)
Backed out changeset 2b89ba254a1a (bug 1852806)
Backed out changeset dfa4f73fc548 (bug 1852806)
Backed out changeset daffcc4c1877 (bug 1852806)
Backed out changeset 33855bcdf15e (bug 1852806)
Backed out changeset 694f29707f3e (bug 1852806)
Backed out changeset 1891eda22a59 (bug 1852806)
Backed out changeset 1b854941389c (bug 1852806)
Backed out changeset 2f7cfe04be59 (bug 1852806)
2023-09-15 09:48:27 +03:00
Masatoshi Kimura
dd10eddab9 Bug 1852806 - Remove macros for older Windows SDK from accessible/windows/msaa/. r=nlapre
Differential Revision: https://phabricator.services.mozilla.com/D188018
2023-09-15 03:19:25 +00:00
James Teh
5e1a54c589 Bug 1851288: Cache when a UIA client is not on the block list. r=nlapre
Previously, we cached when a UIA client was blocked or when there were no UIA clients.
However, we did not cache the result when a UIA client was present but *not* blocked.
This isn't normally a problem because a11y is normally instantiated in this case, which means we won't try to do any client detection again this session.
However, if a11y is force disabled via the pref, we still do detection, but we don't instantiate.
This meant that a UIA client which hammered us with queries would keep triggering the detection code, since we weren't caching the result.
That resulted in severe performance degradation for impacted users.
To fix this, cache the UIA detection result even if we do allow a11y instantiation.

Differential Revision: https://phabricator.services.mozilla.com/D187869
2023-09-12 01:09:49 +00:00
Masatoshi Kimura
57cbcde5bb Bug 1849927 - Fix build error with WINVER >= 0x0A00 in accessible/windows/msaa/. r=nlapre
Differential Revision: https://phabricator.services.mozilla.com/D186745
2023-09-06 19:30:01 +00:00
James Teh
8cb1edbab3 Bug 1847489: Detect UIA clients in Windows 10. r=nlapre
The new detection code introduced in bug 1838123 doesn't work on Windows 10.
This patch:

1. Splits the Windows 11 code into its own function.
2. Refactors the system handle enumeration code into its own function which can be called with a lambda, since it is needed for both Windows 11 and Windows 10.
3. Adds code to detect clients on Windows 10 based on the old detection code before bug 1838123, with some noteworthy changes:
    - Hooking the UIA window message doesn't work; our hook runs too late. It also doesn't work well for blocking; some clients will very likely poke us more than the maximum attempts in the old code (5 times).
    - Instead, we run this code as part of LazyInstantiator::ShouldInstantiate, just as we do for all other client detection.
    - This means we use the same UIA detection caching strategy; i.e. reset on foreground changes.
    - It also means we reuse the same instantiator setting and block listing code in LazyInstantiator.

Differential Revision: https://phabricator.services.mozilla.com/D185627
2023-08-10 01:00:13 +00:00
Natalia Csoregi
9358a33249 Backed out changeset e57e57aa46ba (bug 1847489) for causing win bustage on CompatibilityUIA.cpp. CLOSED TREE 2023-08-09 14:37:36 +03:00
James Teh
fc74f60e4b Bug 1847489: Detect UIA clients in Windows 10. r=nlapre
The new detection code introduced in bug 1838123 doesn't work on Windows 10.
This patch:

1. Splits the Windows 11 code into its own function.
2. Refactors the system handle enumeration code into its own function which can be called with a lambda, since it is needed for both Windows 11 and Windows 10.
3. Adds code to detect clients on Windows 10 based on the old detection code before bug 1838123, with some noteworthy changes:
    - Hooking the UIA window message doesn't work; our hook runs too late. It also doesn't work well for blocking; some clients will very likely poke us more than the maximum attempts in the old code (5 times).
    - Instead, we run this code as part of LazyInstantiator::ShouldInstantiate, just as we do for all other client detection.
    - This means we use the same UIA detection caching strategy; i.e. reset on foreground changes.
    - It also means we reuse the same instantiator setting and block listing code in LazyInstantiator.

Differential Revision: https://phabricator.services.mozilla.com/D185627
2023-08-09 04:02:46 +00:00
James Teh
378e556724 Bug 1372296: Unify ScrollSubstringToPoint for local and remote Accessibles, thus enabling support for RemoteAccessible on Windows. r=eeejay
Eventually, the bulk of this functionality should be moved to TextLeafRange.
In the meantime, let's get rid of the platform specific ugliness here.

Differential Revision: https://phabricator.services.mozilla.com/D185263
2023-08-08 05:18:55 +00:00
Narcis Beleuzu
7fcb244e50 Backed out changeset 270594af44f1 (bug 1372296) for bustages on ia2AccessibleText.cpp 2023-08-08 07:44:53 +03:00
James Teh
0a2d00604f Bug 1372296: Unify ScrollSubstringToPoint for local and remote Accessibles, thus enabling support for RemoteAccessible on Windows. r=eeejay
Eventually, the bulk of this functionality should be moved to TextLeafRange.
In the meantime, let's get rid of the platform specific ugliness here.

Differential Revision: https://phabricator.services.mozilla.com/D185263
2023-08-08 00:59:25 +00:00
James Teh
4286f529f3 Bug 1846660 part 4: Implement IAccessibleTextSelectionContainer interface. r=nlapre
get_selections is largely based on the old IAccessible2_3::get_selectionRanges method.
However, this makes use of HyperTextAccessibleBase::CroppedSelectionRanges, which didn't exist before.
It has also been updated to return IAccessibleText pointers as required by the new interface.

setSelections is entirely new, but relies on existing mechanisms to convert offsets and to add and remove selections.

Differential Revision: https://phabricator.services.mozilla.com/D185135
2023-08-04 02:51:43 +00:00
James Teh
c36ade2bea Bug 1846660 part 3: Provide a way to safely get an Accessible from a COM pointer provided to us by a client. r=nlapre
IAccessibleTextSelectionContainer::setSelections passes us IAccessibleText COM pointers to identify the target Accessibles.
We need to safely get a Gecko Accessible from such a COM pointer.
The client could hand us anything, so it's not safe to just static_cast without being certain that it's one of our Accessibles.
Instead, we use an internal IID to validate that it's an MsaaAccessible and return the correct pointer, after which we can easily get the Accessible.

Differential Revision: https://phabricator.services.mozilla.com/D185134
2023-08-04 02:51:42 +00:00
James Teh
96cc6ec069 Bug 1846660 part 1: Remove deprecated IAccessible2_3 implementation and interface. r=nlapre
No clients actually use this due to inherent flaws.

Differential Revision: https://phabricator.services.mozilla.com/D185132
2023-08-04 02:51:42 +00:00
Natalia Csoregi
84729900a3 Backed out 4 changesets (bug 1846660) for causing bustage on ia2AccessibleTextSelectionContainer.h. CLOSED TREE
Backed out changeset c097c6502edc (bug 1846660)
Backed out changeset 9bf0e6ec2653 (bug 1846660)
Backed out changeset eb0515d87ee5 (bug 1846660)
Backed out changeset f12d2f98186b (bug 1846660)
2023-08-04 04:30:18 +03:00
James Teh
074cfeaa5f Bug 1846660 part 4: Implement IAccessibleTextSelectionContainer interface. r=nlapre
get_selections is largely based on the old IAccessible2_3::get_selectionRanges method.
However, this makes use of HyperTextAccessibleBase::CroppedSelectionRanges, which didn't exist before.
It has also been updated to return IAccessibleText pointers as required by the new interface.

setSelections is entirely new, but relies on existing mechanisms to convert offsets and to add and remove selections.

Differential Revision: https://phabricator.services.mozilla.com/D185135
2023-08-03 23:00:01 +00:00
James Teh
5e107cd26a Bug 1846660 part 3: Provide a way to safely get an Accessible from a COM pointer provided to us by a client. r=nlapre
IAccessibleTextSelectionContainer::setSelections passes us IAccessibleText COM pointers to identify the target Accessibles.
We need to safely get a Gecko Accessible from such a COM pointer.
The client could hand us anything, so it's not safe to just static_cast without being certain that it's one of our Accessibles.
Instead, we use an internal IID to validate that it's an MsaaAccessible and return the correct pointer, after which we can easily get the Accessible.

Differential Revision: https://phabricator.services.mozilla.com/D185134
2023-08-03 23:00:01 +00:00
James Teh
85a75acb0e Bug 1846660 part 1: Remove deprecated IAccessible2_3 implementation and interface. r=nlapre
No clients actually use this due to inherent flaws.

Differential Revision: https://phabricator.services.mozilla.com/D185132
2023-08-03 23:00:00 +00:00
James Teh
e110b02d35 Bug 1846922: Allow QueryInterface to IAccessibleEditableText and IAccessibleHypertext2 for RemoteAccessible. r=nlapre
The methods have already been updated to used unified cross-platform methods.
All that was preventing these from working was the IsLocal restriction in QueryInterface.

Differential Revision: https://phabricator.services.mozilla.com/D185253
2023-08-03 21:53:57 +00:00
James Teh
23fd30a006 Bug 1845883: Remove HyperTextAccessibleWrap. r=nlapre
This is now just an alias for HyperTextAccessible on all platforms.
This was done with the following bash script:

```
cd accessible
find -name HyperTextAccessibleWrap.h -delete
sed -i 's/#include "HyperTextAccessibleWrap.h"/#include "HyperTextAccessible.h"/;/"HyperTextAccessibleWrap.h",/d;s/HyperTextAccessibleWrap/HyperTextAccessible/g' `git grep -l HyperTextAccessibleWrap`
```

Differential Revision: https://phabricator.services.mozilla.com/D184796
2023-08-02 01:42:17 +00:00
James Teh
313b0fbdf5 Bug 1743749 part 2: Replace usage of atoms as cache keys with the new CacheKey aliases. r=nlapre
This was done with the following Python script:

```
import re

cacheConsts = open("accessible/base/CacheConstants.h", "rt").read()
aliases = {
  alias: atom
  for atom, alias in
  re.findall(
    r'static constexpr nsStaticAtom\*\s+(.*?)\s+=\s+(nsGkAtoms::.*?);',
    cacheConsts
  )
}

RE_ATOM = re.compile(r'(fields->SetAttribute|(?:mCachedFields|aFields)->(?:GetAttribute|GetAttributeRefPtr|GetMutableAttribute|HasAttribute|Remove|SetAttribute)(?:<.+>)?)(\(\s*)(nsGkAtoms::[a-zA-Z_]+)')

def repl(m):
  # Group 3 is the atom.
  alias = aliases.get(m.group(3))
  if not alias:
    # No alias for this atom. Return input unaltered.
    return m.group(0)
  alias = "CacheKey::" + alias
  # Groups 1 and 2 should be returned unaltered. Group 3 (the atom) is replaced
  # with the alias.
  return m.group(1) + m.group(2) + alias

for fn in (
  # Found with: git grep -l 'ields->'
  "accessible/base/CachedTableAccessible.cpp",
  "accessible/base/nsAccessibilityService.cpp",
  "accessible/base/TextLeafRange.cpp",
  "accessible/generic/LocalAccessible.cpp",
  "accessible/ipc/DocAccessibleParent.cpp",
  "accessible/ipc/RemoteAccessible.cpp",
  "accessible/ipc/RemoteAccessible.h",
  "accessible/windows/sdn/sdnAccessible.cpp",
):
  input = open(fn, "rt").read()
  output = RE_ATOM.sub(repl, input)
  open(fn, "wt").write(output)
```

Differential Revision: https://phabricator.services.mozilla.com/D184791
2023-07-31 23:09:56 +00:00
James Teh
c68c3ca8b3 Bug 1844238 part 1: Change includes of Role.h to mozilla/a11y/Role.h. r=eeejay
Role.h will soon be generated, but it is generated within the obj dir, so local includes won't work.
Our C++ style guide says we should prefer exported includes wherever possible anyway.

This was done with this shell command inside the accessible/ directory:

```
sed -i 's,#include "Role.h",#include "mozilla/a11y/Role.h",' `git grep -l '#include "Role.h"'`
```

Differential Revision: https://phabricator.services.mozilla.com/D183940
2023-07-26 02:19:41 +00:00
James Teh
daf109ee7f Bug 412902: Remove unused accessibility events. r=eeejay
This removes the unused AccTableChangeEvent class, as well as the following unused event constants:

- EVENT_ACTIVE_DECENDENT_CHANGED
- EVENT_LOCATION_CHANGE
- EVENT_HELP_CHANGE
- EVENT_DEFACTION_CHANGE
- EVENT_ACTION_CHANGE
- EVENT_ACCELERATOR_CHANGE
- EVENT_FOREGROUND
- EVENT_CAPTURE_START
- EVENT_CAPTURE_END
- EVENT_MOVESIZE_START
- EVENT_MOVESIZE_END
- EVENT_CONTEXTHELP_START
- EVENT_CONTEXTHELP_END
- EVENT_DRAGDROP_END
- EVENT_DIALOG_START
- EVENT_DIALOG_END
- EVENT_MINIMIZE_START
- EVENT_MINIMIZE_END
- EVENT_DOCUMENT_ATTRIBUTES_CHANGED
- EVENT_DOCUMENT_CONTENT_CHANGED
- EVENT_PROPERTY_CHANGED
- EVENT_PAGE_CHANGED
- EVENT_TEXT_CHANGED
- EVENT_TEXT_UPDATED
- EVENT_VISIBLE_DATA_CHANGED
- EVENT_TEXT_COLUMN_CHANGED
- EVENT_SECTION_CHANGED
- EVENT_TABLE_CAPTION_CHANGED
- EVENT_TABLE_MODEL_CHANGED
- EVENT_TABLE_SUMMARY_CHANGED
- EVENT_TABLE_ROW_DESCRIPTION_CHANGED
- EVENT_TABLE_ROW_HEADER_CHANGED
- EVENT_TABLE_ROW_INSERT
- EVENT_TABLE_ROW_DELETE
- EVENT_TABLE_ROW_REORDER
- EVENT_TABLE_COLUMN_DESCRIPTION_CHANGED
- EVENT_TABLE_COLUMN_HEADER_CHANGED
- EVENT_TABLE_COLUMN_INSERT
- EVENT_TABLE_COLUMN_DELETE
- EVENT_TABLE_COLUMN_REORDER
- EVENT_WINDOW_CREATE
- EVENT_WINDOW_DESTROY
- EVENT_WINDOW_RESIZE
- EVENT_HYPERLINK_END_INDEX_CHANGED
- EVENT_HYPERLINK_NUMBER_OF_ANCHORS_CHANGED
- EVENT_HYPERLINK_SELECTED_LINK_CHANGED
- EVENT_HYPERTEXT_LINK_ACTIVATED
- EVENT_HYPERTEXT_LINK_SELECTED
- EVENT_HYPERLINK_START_INDEX_CHANGED
- EVENT_HYPERTEXT_CHANGED
- EVENT_HYPERTEXT_NLINKS_CHANGED

Differential Revision: https://phabricator.services.mozilla.com/D183709
2023-07-19 02:56:55 +00:00
James Teh
c4c4fee14f Bug 1694573 part 6: Remove now empty Windows HyperTextAccessibleWrap. r=eeejay
Differential Revision: https://phabricator.services.mozilla.com/D183705
2023-07-19 02:56:55 +00:00
James Teh
7c63b7fc05 Bug 1694573 part 5: Make LocalAccessible call Platform*Event. Remove most of the platform HandleAccEvent overrides. r=eeejay
Mac and Android still override HandleAccEvent for platform specific behaviour other than firing the event.
The Android behaviour can be unified properly in future work.

ATK is the platform layer with the most churn because there were inconsistencies in the way local and remote events were handled.
I'm reasonably sure these were unintentional inconsistencies, so I've done my best to unify them.

Differential Revision: https://phabricator.services.mozilla.com/D183704
2023-07-19 02:56:54 +00:00
James Teh
ecc3d38304 Bug 1694573 part 3: Add a unified version of Windows UpdateSystemCaretFor. r=eeejay
This takes an Accessible and a rect and calls the local or remote versions appropriately.
This avoids the duplication of conditional behaviour in PlatformFocusEvent and PlatformCaretMoveEvent.

Differential Revision: https://phabricator.services.mozilla.com/D183702
2023-07-19 02:56:54 +00:00
James Teh
4d2410a13e Bug 1694573 part 2: Make Platform*Event functions take Accessible instead of RemoteAccessible. r=eeejay
Some of these methods don't yet handle LocalAccessible properly, but that will be fixed in subsequent patches.

Differential Revision: https://phabricator.services.mozilla.com/D183701
2023-07-19 02:56:53 +00:00
James Teh
7e43083f11 Bug 1694573 part 1: Rename Proxy*Event to Platform*Event. r=eeejay
This was done with the following command in the accessible/ directory:

```
sed -i 's/\bProxy\(.*\)Event\b/Platform\1Event/' `git grep -l 'Proxy.*Event'`
```

Differential Revision: https://phabricator.services.mozilla.com/D183700
2023-07-19 02:56:53 +00:00
James Teh
93ea0f991e Bug 798492: Don't return BSTR from IAccessible::get_accRole. r=nlapre
This is a hack that was implemented a long time ago before IAccessible2.
However, it violates the MSAA API, breaks Microsoft's Inspect tool and violates the Core/HTML AAM specs.
In terms of backwards compatibility, anyone who wants to really access web content will be using IAccessible2 anyway.
Also, Chromium has never implemented this hack.

The mappings were largely taken from the Core and HTML AAM specs.
Where those specs didn't specify an MSAA role, ROLE_SYSTEM_GROUPING has been used, which is the closest we can get to a generic mapping and is also used by Chromium for these cases.

Differential Revision: https://phabricator.services.mozilla.com/D183828
2023-07-19 02:51:29 +00:00
James Teh
6d32b64ab0 Bug 1838123: Update UI Automation client detection to work with modern versions of Windows. r=nlapre,handyman
The window message we previously hooked no longer gets sent and the associated shared memory no longer seems to be created either.
Also, we don't seem to be notified about the load of UIAutomationCore.dll until after it has already instantiated a11y, which is obviously too late for us to hook anything.
Instead, we block UIA instantiation via LazyInstantiator, just as we do for MSAA/IA2:

1. Refactor CompatibilityUIA so that rather than being called by a hook, it simply allows the caller to query the process ids of any UIA clients.
2. CompatibilityUIA now searches handles in our process for named pipes created by UIA for communication with the remote process and then uses GetNamedPipeServerProcessId to get the process id on the other end of each pipe.
3. Refactor LazyInstantiator so that it first tries to get the MSAA/IA2 client process id, then calls CompatibilityUIA to get any UIA client process ids.
4. LazyInstantiator now handles setting the instantiator and blocking of clients for UIA as well as MSAA/IA2 using the same code.
5. Because UIA client detection can be expensive if clients repeatedly query us, cache the result. Reset that cache only when one of our windows comes to the foreground.

Differential Revision: https://phabricator.services.mozilla.com/D181958
2023-07-13 05:25:20 +00:00
Iulian Moraru
1cfd3a3bc7 Backed out changeset 0724fde82b2f (bug 1838123) for causing build bustages. CLOSED TREE 2023-07-13 07:35:44 +03:00
James Teh
b9171ec2f1 Bug 1838123: Update UI Automation client detection to work with modern versions of Windows. r=nlapre,handyman
The window message we previously hooked no longer gets sent and the associated shared memory no longer seems to be created either.
Also, we don't seem to be notified about the load of UIAutomationCore.dll until after it has already instantiated a11y, which is obviously too late for us to hook anything.
Instead, we block UIA instantiation via LazyInstantiator, just as we do for MSAA/IA2:

1. Refactor CompatibilityUIA so that rather than being called by a hook, it simply allows the caller to query the process ids of any UIA clients.
2. CompatibilityUIA now searches handles in our process for named pipes created by UIA for communication with the remote process and then uses GetNamedPipeServerProcessId to get the process id on the other end of each pipe.
3. Refactor LazyInstantiator so that it first tries to get the MSAA/IA2 client process id, then calls CompatibilityUIA to get any UIA client process ids.
4. LazyInstantiator now handles setting the instantiator and blocking of clients for UIA as well as MSAA/IA2 using the same code.
5. Because UIA client detection can be expensive if clients repeatedly query us, cache the result. Reset that cache only when one of our windows comes to the foreground.

Differential Revision: https://phabricator.services.mozilla.com/D181958
2023-07-13 03:57:30 +00:00
James Teh
e72ae1eb3e Bug 1841943: Remove broken LazyInstantiator code to resolve a fake root accessible. r=nlapre
The code previously called DefWindowProc to get a system generated client IAccessible. However, DefWindowProc doesn't do this and I'm fairly sure it never has.
Even if we use CreateStdAccessibleObject instead:

1. We crash in LazyInstantiator's destructor because we try to call into mWeakMsaaRoot, which doesn't exist in this case.
2. We crash when some clients call us because AddRef and Release assume that we've transplanted our ref count into mRealRootUnk, but we don't do that in the case of a fake root.
3. We don't (and can't) aggregate the fake root COM object, so QueryInterface would be asymmetric. This may well cause obscure crashes/leaks.

We could fix all of these issues, but since this has clearly never been used or relied upon, we should just remove it.
We already have stub implementations for key methods and the others will just fail as they always have.
There should be no visible change with this patch.

Differential Revision: https://phabricator.services.mozilla.com/D182864
2023-07-11 21:58:49 +00:00
James Teh
cb27283aab Bug 1841942: Don't call GetProp in LazyInstantiator::GetRootAccessible if a11y is already instantiated. r=nlapre
If a11y is instantiated, we always want to return the real root.
Furthermore, we clear the instantiator prop anyway when we instantiate a11y.
Therefore, calling GetProp is wasteful if a11y is instantiated.
Instead, we now only call GetProp if a11y isn't instantiated yet.

Differential Revision: https://phabricator.services.mozilla.com/D182863
2023-07-11 21:58:16 +00:00
James Teh
bac4f88bdf Bug 1841941: Use CreateStdAccessibleObject instead of AccessibleObjectFromWindow when getting the window IAccessible. r=nlapre
We use AccessibleObjectFromWindow to get a system generated IAccessible for the window.
While this works well enough, it first sends WM_GETOBJECT to our window, goes through our window proc, etc., which is pointless since it will return nothing.
We should just call CreateStdAccessibleObject directly instead, which is what the existing code ends up doing indirectly.

Differential Revision: https://phabricator.services.mozilla.com/D182862
2023-07-11 21:57:29 +00:00
James Teh
6c99023552 Bug 1840295: Remove Windows specific ifdefs for PDocAccessible:: FocusEvent and CaretMoveEvent. r=eeejay
On Windows, focus and caret move events include the caret rectangle.
This isn't used on other platforms.
To simplify the cross-platform interface (including Platform.h), remove the ifdefs from there.
However, we use ifdefs to avoid calculating the rectangle on non-Windows platforms, instead just sending an empty rectangle.

Differential Revision: https://phabricator.services.mozilla.com/D182138
2023-07-05 04:15:27 +00:00