You are currently viewing a snapshot of www.mozilla.org taken on April 21, 2008. Most of this content is highly out of date (some pages haven't been updated since the project began in 1998) and exists for historical purposes only. If there are any pages on this archive site that you think should be added back to www.mozilla.org, please file a bug.



Embedding API for Accessibility

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.

Text Zoom on a Per-Window Basis

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("bool.pref.name", PR_TRUE /* or PR_FALSE */);
prefs->SetIntPref("int.pref.name", newValue);
prefs->SetCharPref("string.pref.name", 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
Images
SetIntPref("network.image.imageBehavior", behavior);
/* behavior: 0=Accept, 1=Accept images from originating server only, 2=no images */
Moz 0.8
Cookies
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
Fonts
SetCharPref("font.name.monospace.x-western", newFontName);
SetCharPref("font.name.serif.x-western", newFontName);
SetCharPref("font.name.sans-serif.x-western", 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);
No
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);
No
Content Waiting Alerts
SetCharPref("alert.audio.mail_waiting", pathToSoundFile);
SetCharPref("alert.audio.background_image_waiting", pathToSoundFile);
SetCharPref("alert.audio.popup_waiting", pathToSoundFile);
SetCharPref("alert.audio.applet_waiting", pathToSoundFile);
SetCharPref("alert.audio.script_waiting", pathToSoundFile);
SetCharPref("alert.audio.redirect_waiting", pathToSoundFile);
SetCharPref("alert.audio.refresh_waiting", pathToSoundFile);
SetCharPref("alert.audio.plugin_content_waiting", pathToSoundFile);
SetCharPref("alert.audio.video_waiting", pathToSoundFile);
SetCharPref("alert.audio.audio_waiting", pathToSoundFile);
SetCharPref("alert.audio.timed_event_waiting", pathToSoundFile);
/* These alerts will also be mirrored visually, either on the status bar or elsewhere */
No
Background images
SetBoolPref("browser.accept.background_images", acceptBackgroundImages);
No
Blinking text
SetBoolPref("browser.blink_allowed", acceptBlinkText);
No
Animations
SetCharPref("image.animation_mode", animationMode);
animationMode: "normal", "none", "once"
Moz 0.8
Applets
SetBoolPref("browser.accept.applets", acceptApplets);
No
Scripts
SetBoolPref("browser.accept.scripts", acceptScripts);
No
Popup windows
// Turn window.open off for particular sites:
user_pref("capability.policy.popupsites.sites", "http://www.annoyingsite1.com http://www.popupsite2.com");
user_pref("capability.policy.popupsites.windowinternal.open","noAccess");
 
// Or turn it off everywhere:
user_pref("capability.policy.default.windowinternal.open","noAccess");
 
// 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);
No
Content refreshes
SetBoolPref("browser.accept.refreshes", acceptRefreshes);
No
Plugin content
SetBoolPref("browser.accept.plugin_content.[plugin_name_goes_here]", acceptPluginContent);
No
Video
SetBoolPref("browser.accept.video", acceptVideo);
No
Audio
SetBoolPref("browser.accept.audio", acceptAudio);
No
Timed events
SetBoolPref("browser.accept.timed_events", acceptTimedEvents);
No
Timer speed
SetIntPref("timer.relative_speed", percent);
/* 100 corresponds to normal speed, 200 to double speed */
No
Allow cycling in lists and links
SetBoolPref("keyboardnav.allow_cycling", allowCycling);
No
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 */
No
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 "alert.audio.*" 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.