This is an archived page. It's not actively maintained.

Embedding API for Accessibility

Text Zoom on a Per-Window Basis

Comments/Questions? Please contact the Mozilla Accessibility Community.

Mozilla needs to move in the direction of accessibility. Here is the W3C's definition of accessibility for a user agent like Mozilla.

In part, being accessible means supporting a built-in accessibility APIs for a platform, such as Microsoft Active Accessibility or ATK for Linux and UNIX desktops.

There are many other pieces, such as preferences to allow the user to change foreground and background colors, and font sizes. Mozilla already supports some of these options. This document lays out what we already have, and what we'll need later, in the embedding API to support accessibility.

The nsIDOMWindow::GetTextZoom(float *zoomFactor) and nsIDOMWindow::SetTextZoom(float zoomFactor) methods can be used to set a wide range of text zoom factors on a content window. A zoom factor of 1.0 represents 100%, or normal zoom. For double-sized text, use nsIDOMWindow::SetTextZoom(2.0);

Using Accessibility Preferences

There are a number of prefs related to accessibility. For the most part, an automatic reframe is performed when one of these prefs is changed. A reframe fixes the appearance of the page to match the new prefs, without reloading the document over the network. Be aware that in debug builds, this can cause a great number of assertions (bug 71598)

To use prefs in embedding, use something like the following code:

#include "nsIPref.h";
nsresult rv;

nsCOMPtr<nsIPref> prefs(do_GetService(NS_PREF_CONTRACTID, &rv));
prefs->SetBoolPref("", PR_TRUE /* or PR_FALSE */);
prefs->SetIntPref("", newValue);
prefs->SetCharPref("", newCharStarValue);

To manually add a pref to your settings, add a line like the following to your prefs.js:

user_pref("accessibility.browsewithcaret", true);

Accessibility Prefs Reference

The following is a description of what accessibility prefs give us (or will give us), for accessibility:

Functionality Implementation Works as of
SetIntPref("network.image.imageBehavior", behavior);
/* behavior: 0=Accept, 1=Accept images from originating server only, 2=no images */
Moz 0.8
SetIntPref("network.cookie.cookieBehavior", behavior);
/* behavior: 0=Accept, 1=Accept cookies from originating server only, 2=no cookies */
SetBoolPref("network.cookie.warnAboutCookies", boolWarn);
Moz 0.8
SetCharPref("", newFontName);
SetCharPref("", newFontName);
SetCharPref("", newFontName);
/* For other i18n charsets, change x-western to x-central-euro, x-cyrillic, x-unicode, x-user-def, x-baltic, el, tr, he, ar, th, ja, zh-CN or zh-TW */
SetIntPref("font.size.fixed.x-western", newFontSize);
SetIntPref("font.size.variable.x-western", newFontSize);
/* For other i18n charsets, change the name as explained above for font face*/
SetCharPref("font.default","serif"); /* or "sans-serif" */
SetIntPref("browser.use_document_fonts", whichFonts);
/* whichFonts: 0=no, 1=yes */
Moz 0.8
Fonts from Operating system?
SetBoolPref("browser.use_system_fonts", useSystemFonts);
Colors for page
SetCharPref("browser.display.foreground_color", "#abcdef" /* hex color value */);
SetCharPref("browser.display.background_color", "#abcdef" /* hex color value */);
SetBoolPref("browser.display.use_system_colors", boolSystemColors);
SetBoolPref("browser.display.use_document_colors", boolUseAuthorColors);
/* Setting use_document_colors also stops background images from loading */
Moz 0.8
Link appearance
SetCharPref("browser.anchor_color", "#abcdef" /* hex color value */);
SetCharPref("browser.visited_color", "#abcdef" /* hex color value */);
SetBoolPref("browser.underline_anchors", boolUnderlineLinks);
Moz 0.8
Focus appearance
SetBoolPref("browser.display.use_focus_colors", useFocusColors);
SetCharPref("browser.display.focus_background_color", colorString);
SetCharPref("browser.display.focus_text_color", colorString);
SetCharPref("browser.display.focus_ring_width", numPixels); /* 0-4 */
Moz 0.9.2
Text Selection appearance
SetCharPref("browser.selection.background_color", colorString);
SetCharPref("browser.selection.foreground_color", colorString);
SetCharPref("browser.selection.border", cssBorderStyleString);
/* Is a selection border hard to implement? It's a W3C UAAG requirement */
SetBoolPref("browser.selection.use_system_colors", useSystemColors);
Content Waiting Alerts
SetCharPref("", pathToSoundFile);
SetCharPref("", pathToSoundFile);
SetCharPref("", pathToSoundFile);
SetCharPref("", pathToSoundFile);
SetCharPref("", pathToSoundFile);
SetCharPref("", pathToSoundFile);
SetCharPref("", pathToSoundFile);
SetCharPref("", pathToSoundFile);
SetCharPref("", pathToSoundFile);
SetCharPref("", pathToSoundFile);
SetCharPref("", pathToSoundFile);
/* These alerts will also be mirrored visually, either on the status bar or elsewhere */
Background images
SetBoolPref("browser.accept.background_images", acceptBackgroundImages);
Blinking text
SetBoolPref("browser.blink_allowed", acceptBlinkText);
SetCharPref("image.animation_mode", animationMode);
animationMode: "normal", "none", "once"
Moz 0.8
SetBoolPref("browser.accept.applets", acceptApplets);
SetBoolPref("browser.accept.scripts", acceptScripts);
Popup windows
// Turn off for particular sites:
user_pref("capability.policy.popupsites.sites", "");
// Or turn it off everywhere:
// Override popping up new windows on target=anything
user_pref("browser.block.target_new_window", true);
// Override popup windows at beginning of new page load (blocks most popup advertisements)
user_pref("dom.disable_open_during_load", true);
Moz 0.8
Client side redirects
SetBoolPref("browser.accept.redirects", acceptRedirects);
Content refreshes
SetBoolPref("browser.accept.refreshes", acceptRefreshes);
Plugin content
SetBoolPref("browser.accept.plugin_content.[plugin_name_goes_here]", acceptPluginContent);
SetBoolPref("", acceptVideo);
SetBoolPref("", acceptAudio);
Timed events
SetBoolPref("browser.accept.timed_events", acceptTimedEvents);
Timer speed
SetIntPref("timer.relative_speed", percent);
/* 100 corresponds to normal speed, 200 to double speed */
Allow cycling in lists and links
SetBoolPref("keyboardnav.allow_cycling", allowCycling);
Mouse pointer moves with keyboard focus
SetBoolPref("keyboardnav.mouse_follows_keyboard_focus", mouseFollows);
/* If this pref is set, the mouse pointer will always be move to the 0,0 pixel of the current keyboard focus frame */
Browse with caret
SetBoolPref("accessibility.browsewithcaret", useCaret);
/* If this pref is set, the caret will be visible in the text of the browser, allowing the user to cursor around the HTML content as if in a read-only editor */
Moz 0.9

Special Content Notifications

The W3C UAAG specifies types of content that must be optional. The intention is for a user to be notified of its existence, and at some point they can choose to load the content. This is a much better alternative than having the user go through a long series of confirm boxes for each new page, for each type of content.

For each preference named "browser.accept.*", there is also an "*" preference, to allow configuration of sound files to go with each type of content. The audio file could be a clip of a human voice saying "You've got video" or even a simple beep. How we expose this through the user interface is another matter.

Accepting Special Content on an Instance Basis

After being notified of special content, the user needs to be able to select specific unloaded content for loading.

One way of doing this is to build up the nsIWebBrowserAccessible interface, so that there is a method to force loading each type of content just for the current page in the current session.

Open Issue: Accessibility Settings per URL

A powerful possibility is that we design an interface for setting certain preferences based on the URL. If we can find a clean way to present it to the user, this would be extremely useful. For example, settings per URL would allow a user to accept scripts from their known benign web pages, but not others. Users may want similarity abilities with applets, background images, style sheets, etc.

We have a permissions system for cookies and images based on URL's. Perhaps it can be extended to store accessibility preferences. This is a UI issue we'll need to settle before we know where to go with the embedding accessibility interface.