Commit Graph

387 Commits

Author SHA1 Message Date
Morgan Rae Reschenberg
9384c6696d Bug 1880578: Ignore aria-hidden when applied to root document elements and root svg elements r=Jamie
Differential Revision: https://phabricator.services.mozilla.com/D243394
2025-04-15 21:34:59 +00:00
James Teh
77511775f1 Bug 1959892 part 2: Block requesting of new cache domains while firing UIA events. r=morgan
Previously, UIA requested certain cache domains just by firing events, even if no client cared about those events.
This happened because unlike MSAA/IA2 win events, many UIA events include information about the thing that is changing; e.g. a name change event includes the new name.
In addition, live region events are based on other events (name change, text inserted, text removed) and thus need to query whether the element is a live region, which requires additional domains.
this caused our caching granularity tests to break, since those deliberately request only specific domains.
Firing core events caused us to fire UIA events (even if a UIA client didn't actually query us), which in turn caused us to request domains the test doesn't expect.
Less critical (but still important), this meant that these domains would always have been enabled as soon as an event is fired.
That's not great, since it somewhat defeats the point of caching granularity.
As mentioned in the previous patch, checking UiaClientsAreListening() is not sufficient to mitigate this in most cases.

The ideal solution is perhaps to avoid firing those events in the first place.
However, that would require checking for specific domains in the UIA code, which seems fragile if we change what domains are required for existing core methods, add new core methods, etc.
Also, we should probably really be avoiding these events at the core level, rather than requiring OS specific code to filter these out.

Instead, as a more straightforward solution, this patch adds a CacheDomainActivationBlocker RAII class to prevent requesting of new domains.
This is used specifically when firing UIA events.
The events we fire won't contain all the data they should, but that's okay because no client likely cares yet.
We still use explicit client queries (plus a list of known clients) as a signal to request new domains, after which the events will contain information from all the domains that are now active.
This approach could also easily be used on other platforms where needed.

Differential Revision: https://phabricator.services.mozilla.com/D245373
2025-04-15 00:43:28 +00:00
James Teh
510cf177bc Bug 1951720: Don't exclude 0 width whitespace text nodes from the accessibility tree if they're at the end of a wrapped line. r=morgan
In bug 1951067, I pruned all 0 width whitespace text nodes from the accessibility tree.
However, it turns out that whitespace text nodes at the end of wrapped lines can also be 0 width.
These have semantic importance, since otherwise, words in separate inline nodes can be merged together without a space.
To fix this, explicitly check that the node is before a hard line break, not a soft (wrapped) line break.

Differential Revision: https://phabricator.services.mozilla.com/D242290
2025-03-21 02:15:18 +00:00
Tom Schuster
b8d11d463f Bug 1951893 - Remove unneeded StaticAtom suffixes. r=emilio
Differential Revision: https://phabricator.services.mozilla.com/D240598
2025-03-11 11:36:09 +00:00
Morgan Rae Reschenberg
766d0df3f6 Bug 1950235: Add PerfStats markers for medium and low priority non-platform-specific code r=bdekoz
Differential Revision: https://phabricator.services.mozilla.com/D239446
2025-03-10 20:11:00 +00:00
James Teh
33f663a00c Bug 1951067: Don't include invisible whitespace text nodes in the accessibility tree. r=morgan
Differential Revision: https://phabricator.services.mozilla.com/D240001
2025-03-04 05:19:36 +00:00
Cristian Tuns
e9b5bd777c Backed out 2 changesets (bug 1950235) for causing build bustages in LocalAccessible.cpp CLOSED TREE
Backed out changeset a7ee39abfd2a (bug 1950235)
Backed out changeset f1de564abb08 (bug 1950235)
2025-03-03 20:57:45 -05:00
Morgan Rae Reschenberg
961806856f Bug 1950235: Add PerfStats markers for medium and low priority non-platform-specific code r=bdekoz
Differential Revision: https://phabricator.services.mozilla.com/D239446
2025-03-04 00:42:25 +00:00
Nazım Can Altınova
ff6637364b Bug 1799109 - Replace AUTO_PROFILER_MARKER_TEXT markers without a text with the new untyped one r=profiler-reviewers,florian
Differential Revision: https://phabricator.services.mozilla.com/D238121
2025-02-27 21:45:18 +00:00
James Teh
e6e199ac31 Bug 1888298: If shutdown of the accessibility service is triggered by a document shutting down, shut down the service asynchronously. r=nlapre
When DocAccessibles shut down, they shut down their child documents.
However, shutting down a document can result in shutting down the accessibility service if XPCOM is the only consumer and there are no more cached XPCOM documents.
If this is triggered by a child document, the service will shut down while the parent document is still shutting down, resulting in reentry and a crash.
In bug 1690456, code was added to prevent shutting down the service for a document with a parent.
However, this doesn't address "hanging child documents"; i.e. documents which currently have no parent because their OuterDocAccessible is being destroyed/recreated.

Rather than trying to avoid this specific case and given that we've hit reentry problems here twice before now (bug 1330765 and bug 1690456), I've taken a completely different approach.
Whenever shutdown of the service is triggered by a document shutdown, we now shut down the service asynchronously by dispatching a runnable.
This ensures that the service can't be shut down while shutting down a document.
We do this for both local and remote documents, since although we've never seen this for remote documents, I think this is safer.

In addition:

1. DocAccessible::Shutdown now has a diagnostic assert to hopefully detect such reentry should it occur again in future, making it much easier to debug.
2. Functions related to this have been refactored slightly for readability and consistency.

Differential Revision: https://phabricator.services.mozilla.com/D238143
2025-02-19 03:23:42 +00:00
Chris H-C
7030f16e2c Bug 1936822 - Remove unused A11Y_ flag histograms r=morgan
Differential Revision: https://phabricator.services.mozilla.com/D231948
2024-12-16 21:30:23 +00:00
Eitan Isaacson
8ff48aca2d Bug 1907247 - Update non-doc body element bounds when they change. r=morgan
Differential Revision: https://phabricator.services.mozilla.com/D226971
2024-10-30 19:43:50 +00:00
serge-sans-paille
5946338a6a Bug 1920718 - Annotate all global variable with runtime initialization attributes r=glandium,application-update-reviewers,media-playback-reviewers,anti-tracking-reviewers,places-reviewers,profiler-reviewers,gfx-reviewers,aosmond,lina,nalexander,aabh,geckoview-reviewers,win-reviewers,gstoll,m_kato
MOZ_RUNINIT => initialized at runtime
MOZ_CONSTINIT => initialized at compile time
MOZ_GLOBINIT => initialized either at runtime or compile time, depending on template parameter, macro parameter etc
This annotation is only understood by our clang-tidy plugin. It has no
effect on regular compilation.

Differential Revision: https://phabricator.services.mozilla.com/D223341
2024-10-30 11:05:24 +00:00
James Teh
2262393866 Bug 1926198: Use GetAccessibleOrContainer in nsAccessibilityService::NotifyOfAnchorJumpTo. r=morgan
The target might be an element for which we don't create an Accessible; e.g. a <b> element.
Previously, we wouldn't fire an event in NotifyOfAnchorJumpTo and would instead defer the event until the next document focus.
However, the document might already have focus, in which case we won't fire this event when the user expects it (if ever).
Instead, use GetAccessibleOrContainer, which is also consistent with the deferred anchor jump code in FocusManager.
This means we will fire the event on the correct container Accessible immediately.

Differential Revision: https://phabricator.services.mozilla.com/D226437
2024-10-29 01:54:00 +00:00
serge-sans-paille
262f78c07f Bug 1922838 - Replace ArrayLength, ArrayEnd and MOZ_ARRAY_LENGTH by standard alternative r=glandium,necko-reviewers,jgilbert,application-update-reviewers,media-playback-reviewers,credential-management-reviewers,anti-tracking-reviewers,places-reviewers,profiler-reviewers,win-reviewers,dom-storage-reviewers,bytesized,janv,dimi,daisuke,karlt,gstoll,canaltinova,timhuang
Namely std::size, std::end and std::size. This drops C support for
MOZ_ARRAY_LENGTH but it wasn't used anyway.

Differential Revision: https://phabricator.services.mozilla.com/D224611
2024-10-28 08:21:19 +00:00
Adi
392af3d795 Backed out 2 changesets (bug 1926214, bug 1926198) for causing ba failures. CLOSED TREE
Backed out changeset ada40589ff0c (bug 1926214)
Backed out changeset fbb2bce6d562 (bug 1926198)
2024-10-28 09:34:01 +02:00
James Teh
514bbb3b43 Bug 1926198: Use GetAccessibleOrContainer in nsAccessibilityService::NotifyOfAnchorJumpTo. r=morgan
The target might be an element for which we don't create an Accessible; e.g. a <b> element.
Previously, we wouldn't fire an event in NotifyOfAnchorJumpTo and would instead defer the event until the next document focus.
However, the document might already have focus, in which case we won't fire this event when the user expects it (if ever).
Instead, use GetAccessibleOrContainer, which is also consistent with the deferred anchor jump code in FocusManager.
This means we will fire the event on the correct container Accessible immediately.

Differential Revision: https://phabricator.services.mozilla.com/D226437
2024-10-28 06:42:30 +00:00
Alexandru Marc
a5eb905bf4 Backed out changeset d92f391b3b0c (bug 1922838) for backing out bug 1915351 2024-10-25 16:42:33 +03:00
serge-sans-paille
07101ac24d Bug 1922838 - Replace ArrayLength, ArrayEnd and MOZ_ARRAY_LENGTH by standard alternative r=glandium,necko-reviewers,jgilbert,application-update-reviewers,media-playback-reviewers,credential-management-reviewers,anti-tracking-reviewers,places-reviewers,profiler-reviewers,win-reviewers,dom-storage-reviewers,bytesized,janv,dimi,daisuke,karlt,gstoll,canaltinova,timhuang
Namely std::size, std::end and std::size. This drops C support for
MOZ_ARRAY_LENGTH but it wasn't used anyway.

Differential Revision: https://phabricator.services.mozilla.com/D224611
2024-10-24 09:06:01 +00:00
Alexandru Marc
004e704b22 Backed out changeset 448597bce69d (bug 1922838) for causing build bustages. CLOSED TREE 2024-10-24 11:37:49 +03:00
serge-sans-paille
2c916d4973 Bug 1922838 - Replace ArrayLength, ArrayEnd and MOZ_ARRAY_LENGTH by standard alternative r=glandium,necko-reviewers,jgilbert,application-update-reviewers,media-playback-reviewers,credential-management-reviewers,anti-tracking-reviewers,places-reviewers,profiler-reviewers,win-reviewers,dom-storage-reviewers,bytesized,janv,dimi,daisuke,karlt,gstoll,canaltinova,timhuang
Namely std::size, std::end and std::size. This drops C support for
MOZ_ARRAY_LENGTH but it wasn't used anyway.

Differential Revision: https://phabricator.services.mozilla.com/D224611
2024-10-24 07:38:30 +00:00
Nathan LaPre
8c82146b25 Bug 1921917: Create startup pref to enable all cache domains, r=eeejay
This revision adds a pref, read only on startup, that enables all cache domains.
By default, cache domains are only enabled as-needed. This pref is uesful for
test environments, such as fuzzing.

Differential Revision: https://phabricator.services.mozilla.com/D224187
2024-10-09 19:27:32 +00:00
Nathan LaPre
85ad293bff Bug 1794974: Part 2: Add ability to query and send individual cache domains, r=Jamie
This revision adds the capability of querying and sending information about
individual cache domains. It introduces the concept of active cache domains to
the accessibility service: cache domains that we think clients need. Conversely,
cache domains that clients don't need are inactive, and we avoid doing any work
to push information about those domains. This revision adds an IPC mechanism for
setting cache domains. It adds a way for content process documents to enable,
gather, and send to the parent process information from all of their accessibles
that's newly needed. It adds a way to instantiate new accessibility services
with a predetermined set of cache domains. It adds a mechanism for local accs to
use in BundleFieldsForCache, but doesn't implement it yet (see next revision).

Differential Revision: https://phabricator.services.mozilla.com/D220036
2024-09-09 23:02:19 +00:00
Nathan LaPre
96df3b0894 Bug 1794974: Part 1: Add improved client detection, automatic domain setting, r=Jamie
This revision is a step towards ensuring we get the right domains for known
accessibility instantiators. We want to anticipate the needs of known clients
and make sure we have all the cache domains ready, especially for heavy-use
clients like screen readers. The domains we'll need are a bit of a work in
progress, but can be updated easily. For now, err on the side of caution. This
revision also implements better client detection on macOS, so we can handle
multiple clients.

Differential Revision: https://phabricator.services.mozilla.com/D220035
2024-09-09 23:02:19 +00:00
Sylvestre Ledru
a3ea006705 Bug 1519636 - Reformat recent changes to the Google coding style r=emilio,necko-reviewers,geckoview-reviewers,application-update-reviewers,media-playback-reviewers,devtools-reviewers,anti-tracking-reviewers,profiler-reviewers,win-reviewers,migration-reviewers,padenot,mconley,nchevobbe,kershaw,gstoll,mstange,bytesized,m_kato
This new version of clang 17 also slightly changed the formatting.

# ignore-this-changeset

Differential Revision: https://phabricator.services.mozilla.com/D215914
2024-07-17 11:15:31 +00:00
James Teh
785eb3315f Bug 1896047 part 5: Support CSS alt text for text content. r=eeejay
CSS alt text makes most sense for an image.
However, even when the content property specifies text, you can still specify alt text!
To support this, this patch does two things:

1. Uses the alt text for the TextLeafAccessible instead of the primary text.
2. Tweaks nsTextEquivUtils to use the alt text when gathering text from a subtree.

As with the last patch, changing the CSS content replaces the pseudo-element, which in turn replaces the Accessible with a new one, so we don't need any additional code to handle updates.

Differential Revision: https://phabricator.services.mozilla.com/D210017
2024-05-17 00:24:16 +00:00
James Teh
5745b19958 Bug 1896047 part 4: Create an ImageAccessible for a pseudo-element image if there is CSS alt text. r=eeejay
Previously, a11y did get notified about CSS images, but we chose not to create Accessibles for them.
This patch allows us to create an ImageAccessible for a CSS image if it has alt text.
Since there is now an Accessible, the previous patch will then mean that Accessible::Name will return the CSS alt text.
Changing the CSS content replaces the pseudo-element, which in turn replaces the Accessible with a new one, so we don't need any additional code to handle updates.

Differential Revision: https://phabricator.services.mozilla.com/D210016
2024-05-17 00:24:15 +00:00
Ting-Yu Lin
b4a0842882 Bug 1824877 Part 3 - Change ScrollContainerFrame's type from Scroll to ScrollContainer. r=dholbert
This effectively changes the `IsScrollFrame()` helper to
`IsScrollContainerFrame()`.

Differential Revision: https://phabricator.services.mozilla.com/D210357
2024-05-15 17:50:49 +00:00
Emilio Cobos Álvarez
bf22d33f87 Bug 1895208 - Refactor IsFocusable checks to take flags rather than bool arguments. r=smaug
This doesn't change behavior on its own, but it's likely we want to make
the tab focusability more complicated in bug 1895184, and this will make
changes to this area less painful.

Differential Revision: https://phabricator.services.mozilla.com/D209525
2024-05-06 21:54:37 +00:00
Nathan LaPre
2d9e7d2141 Bug 1877811: Maybe create SVG accessible in display:contents contexts, r=Jamie
Since SVG elements aren't in a markup map, Gecko doesn't check for them when
searching markup maps while determining whether to create an accessible in
display:contents contexts. This revision addresses the problem by factoring out
the SVG creation code and using it in two places - newly in the dislay:contents
code. This revision also removes expected failures from relevant web platform
tests.

Differential Revision: https://phabricator.services.mozilla.com/D207943
2024-04-23 02:42:59 +00:00
Nathan LaPre
fa3588f7a9 Bug 1849160 - Part 1: Implement rowgroup role, r=Jamie
This revision implements the ARIA rowgroup role in Gecko. Previously, Gecko was
using roles::GROUPING for multiple types of groups and disambiguating them
in various places. This revision unwinds that while maintaining present
functionality.

Differential Revision: https://phabricator.services.mozilla.com/D205671
2024-04-10 17:22:12 +00:00
Norisz Fay
7ded2bfda7 Backed out 4 changesets (bug 1849160) for causing gv-junit failure on AccessibilityTest#testSelectable CLOSED TREE
Backed out changeset 0fb937f8c362 (bug 1849160)
Backed out changeset fe5651e406e5 (bug 1849160)
Backed out changeset 8f14ad3ed8b4 (bug 1849160)
Backed out changeset 9a745f454db2 (bug 1849160)
2024-04-02 07:32:11 +03:00
Nathan LaPre
4390b93fe8 Bug 1849160 - Part 1: Implement rowgroup role, r=Jamie
This revision implements the ARIA rowgroup role in Gecko. Previously, Gecko was
using roles::GROUPING for multiple types of groups and disambiguating them
in various places. This revision unwinds that while maintaining present
functionality.

Differential Revision: https://phabricator.services.mozilla.com/D205671
2024-04-02 02:17:38 +00:00
James Teh
2e9ea0c1aa Bug 1886371 part 6: Add UIA control types to RoleMap. r=nlapre
The actual ControlType property implementation is the subject of a subsequent patch.

Differential Revision: https://phabricator.services.mozilla.com/D205184
2024-03-25 03:28:05 +00:00
Eitan Isaacson
f7667a25ce Bug 1861211 - Make isAccessibilityElement conditional on a per-role basis. r=Jamie
Differential Revision: https://phabricator.services.mozilla.com/D191882
2024-03-04 21:19:09 +00:00
Gabriele Svelto
e1e9346196 Bug 1831092 - Use the new pull-based API for all crash annotations and remove the global annotations table r=jgilbert,necko-reviewers,media-playback-reviewers,profiler-reviewers,win-reviewers,padenot,handyman,afranchuk,valentin,alwu,sotaro
This changes comes with several different refactorings all rolled into one,
unfotunately I couldn't find a way to pull them apart:
- First of all annotations now can either recorded (that is, we copy the value
  and have the crash reporting code own the copy) or registered. Several
  annotations are changed to use this functionality so that we don't need to
  update them as their value change.
- The code in the exception handler is modified to read the annotations from
  the mozannotation_client crate. This has the unfortunate side-effect that
  we need three different bits of code to serialize them: one for annotations
  read from a child process, one for reading annotations from the main process
  outside of the exception handler and one for reading annotations from the
  main process within the exception handler. As we move to fully
  out-of-process crash reporting the last two methods will go away.
- The mozannotation_client crate now doesn't record annotation types anymore.
  I realized as I was working on this that storing types at runtime has two
  issues: the first one is that buggy code might change the type of an
  annotation (that is record it under two different types at two different
  moments), the second issue is that types might become corrupt during a
  crash, so better enforce them at annotation-writing time. The end result is
  that the mozannotation_* crates now only store byte buffers, track the
  format the data is stored in (null-terminated string, fixed size buffer,
  etc...) but not the type of data each annotation is supposed to contain.
- Which brings us to the next change: concrete types for annotations are now
  enforced when they're written out. If an annotation doesn't match the
  expected type it's skipped. Storing an annotation with the wrong type will
  also trigger an assertion in debug builds.

Differential Revision: https://phabricator.services.mozilla.com/D195248
2024-03-04 10:24:43 +00:00
James Teh
421fc7b6f3 Bug 1879255 part 3: Notify accessibility about changes to explicitly set attr-elements. r=smaug,eeejay
Accessibility needs to keep track of changes to explicitly set attr-elements.
Since the popovertarget content attribute is "" for any explicitly set attr-element, we won't always get attribute change notifications for the content attribute when .popoverTargetElement is set.
For example, if e1's popovertarget content attribute is absent and you set e1.popoverTargetElement to e2, the popovertarget content attribute will be "".
If you later set e1.popoverTargetElement to e3, there won't be a notification for the content attribute change, since it remains "".
Even if there were, it might occur before the element has changed, which means we can't detect any relevant state changes there; e.g. mPrevStateBits.
To deal with this, we now have DOM notify accessibility before and after the explicitly set attr-element is changed.
Within DocAccessible, this is treated like any other attribute change, but the notification methods get called consistently and at the appropriate time.

Differential Revision: https://phabricator.services.mozilla.com/D201662
2024-02-21 00:05:21 +00:00
James Teh
1a8d9444bc Bug 1870783 part 4: Fire state change events on all popover invokers. r=eeejay
A popover can have multiple invoker buttons.
Previously, we only fired a state change event on the button which was invoked.
This meant that the cached expanded/collapsed state of any other invokers was stale.
To facilitate this:

1. Add popovertarget to DocAccessible's kRelationAttrs so that we track reverse relationships. This will also later be used for exposing relations.
2. When an Accessible is shown or hidden, if it is a popover, use RelatedAccIterator to get all the invokers and fire appropriate state change events on each of them.
3. This also means we can get rid of nsAccessibilityService::PopovertargetMaybeChanged, since this explicit notification from DOM is no longer useful.
4. Add popovertarget to LocalAccessible::AttributeChangesState so that we fire an event for the expandable/expanded/collapsed state change if appropriate when that attribute is changed.

Differential Revision: https://phabricator.services.mozilla.com/D199842
2024-02-12 06:24:15 +00:00
Ziran Sun
2a15361c10 Bug 1867811 - Expose EXPANDED state for element with popovertarget. r=Jamie
Differential Revision: https://phabricator.services.mozilla.com/D196541
2023-12-19 17:30:56 +00:00
James Teh
8502d24b52 Bug 1836823: If we create an Accessible for SVG <foreignObject> due to an ARIA role, etc., use a HyperTextAccessible. r=morgan
We don't normally create an Accessible for <foreignObject>.
However, if there's an ARIA role or similar, we forceably create one.
Previously, if we ever did this for an SVG element, we would use an AccessibleWrap, which doesn't support HyperText.
This is normally correct because most SVG elements can't contain text.
However, a <foreignObject> can most definitely contain text, so we must use HyperTextAccessible.
This fixes assertions and text attributes.

Differential Revision: https://phabricator.services.mozilla.com/D195387
2023-12-11 00:39:25 +00:00
James Teh
b609a36524 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
Sylvestre Ledru
b0fe72dee5 Bug 1856795 - Remove redundant member init r=emilio
Done with:
./mach static-analysis check --checks="-*, readability-redundant-member-init" --fix .

https://clang.llvm.org/extra/clang-tidy/checks/readability/redundant-member-init.html

Differential Revision: https://phabricator.services.mozilla.com/D190002
2023-10-15 15:29:02 +00:00
Cristina Horotan
7388749830 Backed out 2 changesets (bug 1856795) for causing build bustage at BasicEvents.h CLOSED TREE
Backed out changeset 1d98b028923a (bug 1856795)
Backed out changeset eae2ac93e17c (bug 1856795)
2023-10-14 21:42:14 +03:00
Sylvestre Ledru
4a97019e39 Bug 1856795 - Remove redundant member init r=emilio
Done with:
./mach static-analysis check --checks="-*, readability-redundant-member-init" --fix .

https://clang.llvm.org/extra/clang-tidy/checks/readability/redundant-member-init.html

Differential Revision: https://phabricator.services.mozilla.com/D190002
2023-10-14 17:34:26 +00:00
James Teh
a34c364ee8 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
d9ee2ad4ee 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
16935b4b44 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
Nathan LaPre
1055f41a81 Bug 854796: Anchor, area elements without href shouldn't have link role, r=Jamie,devtools-reviewers
Per the HTML-AAM spec, a and area elements without href attributes should have
generic roles. This revision implements this preference by creating hypertext
accessibles when said elements lack href attributes (or click listeners). A
byproduct of this change is recognizing that a elements have no intrinsic role
mapping; they could be generics or links. This revision handles situations
where href or click listeners might appear or dissapear, and recreates the
accessibles when necessary. Since image map areas are handled by their
containing image maps, this revision specializes HTMLAreaAccessible::NativeRole
to account for the discrepancy that we can't account for in the markup map.
This revision also changes the relevant WPT test expectations, updates existing
tests that this change affects, and adds tests to verify that changing href
and click listeners dynamically changes the role appropriately.

Differential Revision: https://phabricator.services.mozilla.com/D183550
2023-07-24 19:31:29 +00:00
James Teh
d206d4737a Bug 1765968: Call QueueCacheUpdate instead of SendCache wherever possible. r=morgan
Differential Revision: https://phabricator.services.mozilla.com/D183950
2023-07-21 02:24:44 +00:00
Nathan LaPre
22e4c96a2b Bug 1840732 Part 1: Remove unnecessary includes from accessible/base, r=Jamie
This revision removes unnecessary include directives from cpp files in the
accessible/base directory. These suggestions came from the Include What You Use
tool.

Differential Revision: https://phabricator.services.mozilla.com/D182288
2023-07-07 03:22:07 +00:00