File: README.md

package info (click to toggle)
chromium 140.0.7339.185-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 6,193,740 kB
  • sloc: cpp: 35,093,945; ansic: 7,161,670; javascript: 4,199,694; python: 1,441,797; asm: 949,904; xml: 747,515; pascal: 187,748; perl: 88,691; sh: 88,248; objc: 79,953; sql: 52,714; cs: 44,599; fortran: 24,137; makefile: 22,114; tcl: 15,277; php: 13,980; yacc: 9,000; ruby: 7,485; awk: 3,720; lisp: 3,096; lex: 1,327; ada: 727; jsp: 228; sed: 36
file content (86 lines) | stat: -rw-r--r-- 4,078 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
# Content Accessibility Support

An overview of key concepts and features of accessibility (AX) support for a
`//content` browser.

[TOC]

## AXMode flags

[`AXMode`](/ui/accessibility/ax_mode.h) is a bitfield that specifies how much
AX data the browser needs from renderers. The browser's own UI becomes
accessible when the `kNativeAPIs` bit is set (this is typically called "native
accessibility"). The pages displayed in `WebContents` become accessible when the
`kWebContents` bit is set (typically called "web accessibility"). Additional
mode flags increase the information from pages that are made available to an AX
tool (AT). Some mode flags may enable other features in web content (e.g., image
labeling).

## Mode flag relevance

A renderer produces AX data according to the mode flags that it is given by its
`WebContents`. This may contain flags not present in the process-wide mode
(`BrowserAccessibilityState::GetAccessibilityMode()`) due to targeting (see
[Targeted accessibility](#Targeted-accessibility)).

## Enabling process-wide accessibility

Typically, AX processing is enabled for the browser when it detects the presence
of an AT. This is done via platform-specific mechanisms, which may involve
heuristics. A distinction is made between an AT that is definitively a screen
reader vs. some other tool (e.g., a form filler). When a screen reader is
detected, `kExtendedProperties` is added to the browser's `AXMode`. This may be
used as a signal for other components of the browser that need special behavior
when a screen reader is in use.

AX processing is enabled by creation of a `ScopedAccessibilityMode` (SAM)
instance, and stays active throughout the lifetime of said instance. AX
processing is enabled for the entire browser process via creation of a SAM with
one or more mode flags; see
`BrowserAccessibilityState::CreateScopedModeForProcess`. In this case, all
`WebContents` in the process receive the new mode flags (see [Progressive
Accessibility](#Progressive-Accessibility) for more details). A process-wide SAM
is the only way to enable native accessibility, as native accessibility applies
to all native UI components (i.e., Views) in the process.

## Targeted accessibility

A component that requires AX data from a specific `WebContents` uses
`BrowserAccessibilityState::CreateScopedModeForWebContents` to create a SAM
targeting that one `WebContents` (with at least the `kWebContents` mode flag).

A SAM can target all `WebContents` belonging to a particular `BrowserContext` (a
"Profile" in Chrome terms) with
`BrowserAccessibilityState::CreateScopedModeForBrowserContext`. This is most
useful for enabling mode flags associated with a user preference (e.g., image
labeling). Due to filtering performed by `BrowserAccessibilityState`, a
component may speculatively enable mode flags that depend on more fundamental
flags. For example, `kLabelImages` is filtered out if `kExtendedProperties` is
not also present.

## Data flow

A `WebContents` tells its `RenderFrame`s that it wants AX data (e.g., trees and
updates) by sending a set of `AXMode` flags to its
`blink::mojom::RenderAccessibility` interface. These mode flags tell the
renderer how much AX data the browser needs. As explained
[above](#AXMode-flags), the bare minimum mode for web AX data is `kWebContents`.

A `RenderFrame` sends AX data to its `RenderFrameHost` in the browser by way of
`RenderAccessibilityHost`. The frame's `WebContents` and its observers are given
an opportunity to view/modify the AX data before it is given to the
`BrowserAccessibilityManager` for merging into the `WebContents`'s existing
tree.

## Progressive Accessibility

Mode flag changes are not distributed immediately to `WebContents` that are
hidden. Such changes are held by the `WebContents` and only sent to its
renderers when it is unhidden (becomes visible or occluded). One implication of
this is that `WebContents::GetAccessibilityMode()` on an instance that has never
been drawn will return an empty set.

## See also

*   [Accessibility Overview](/docs/accessibility/overview.md)