Or if there's a blinking insertion bar around it, probably the user can enter text. I'm pretty sure you can imagine how complex the systems were and how difficult this was to maintain, and there was a sort of ambiguity. So on top of that, every time a new version of the user interface would come out, screen readers had to ensure the off-screen model was still accurate. Drinking time, sorry. So what's a better solution? Well, already at the end of the, in the late 90s, accessibility APIs were introduced, and the role of accessibility APIs was to allow programs and applications to construct the text database that assistive technologies were previously building themselves. Concretely, they allow operating systems to describe UI elements as objects with names and properties, so that assistive technologies can access those objects. And I put accessibility APIs in the plural form because there are many, they are platform-specific. You have some for Mac, you have some for Windows, you have some for Android, and they're pretty much standards.
So you might wonder what does an accessibility API look like? And in practice, it's a tree representation of the interface. For example, on the Mac, a window would be an application that contains two children, a menu bar, the thing that's at the top, and a window that contains the application itself. Then the menu bar would also contain, as children, all the menu items, and the window would contain a left bar, a close button, search inputs, et cetera. For each UI element, developers can typically set roles, is that the window, is that a menu? They can set properties. What's the position of this window? What's its size? They can set states. Is this menu item selected or not? And other properties that are useful for developers, like events. Okay, so now we all know, we know all about screen readers and accessibility APIs, but what about the accessibility tree then? Well, the accessibility tree is a separate representation of the DOM that focuses on accessibility-related information. It is built by the browser that then passes this information to the platform accessibility API. So in summary, the accessibility tree makes the link between your HTML, the platform accessibility API, and assistive technology.
So now let's look at how browsers generate this tree. If you think of a typical page that's meant to be interacted with a screen, a mouse and a keyboard, a typical critical rendering path would look like this. The browser creates the DOM and the CSS object model, then it creates the render tree, which is basically the DOM minus some elements that are hidden by CSS. When the render tree is ready, the browser can determine the exact size and position of the element, does the layout step, and then it paints the nodes on the screen one by one. And after that, the user can interact with the page with its mouse, keyboard, et cetera. Now looking at the experience from the point of view of a user that uses assistive technology, it was different. Well, the layout and the paint step aren't relevant here because it's not something that assistive technologies will leverage. However, the browser will use the render tree, the tree without the hidden elements, to construct the accessibility tree. Then the accessibility tree will pass the information to the platform accessibility API that can be queried by assistive technologies like screen readers. Okay, so let's look at what the tree looks like. So how to show the accessibility tree. The best way to get a grasp of it is to look at it using DevTools. I'm going to use Chrome DevTools in this presentation.
Comments