This article is proposal of text attributes support by Gecko accessibility API. Text attributes have been supported since Firefox 3.1 (Gecko 1.9.1). Please refer to out primary Text Attributes documentation because this one may be out of dated.
The following method returns a collection of text attributes at the given offset, and calculates the range where returned attributes are stretched.
|API||Attributes for a text range||Attributes for entire object|
nsIPersistentProperties getTextAttributes(in long offset, out long rangeStartOffset, out long rangeEndOffset);
HRESULT get_attributes(in long offset, long *rangeStartOffset, long *rangeEndOFfset, BSTR *textAttributes);
Combined into get_attributes() results.
string getAttributes(in long offset, out long *rangeStartOffset, out long *rangeEndOffset);
Parameters (for getTextAttributes/get_attributes/getAttributes)
- [in] the given offset
- [out] the start offset of the result range
- [out] the end offset of the result range
Ranges are not nested. They are consecutive, so that AT's always know when to ask for the next range. For example, for text 'abc<b>def</b>ghi', there are three ranges (0, 3), (3, 6) and (6, 9).
Return Value for both methods
A collection of text attributes (the list of pairs consisted from name and value). All text attributes that apply to the current range are exposed, but in order to conserve the amount of data passed, most text attributes will have reasonable defaults and will not be exposed in the list when they are equal to the default. For example, if font-style is "normal" it will not be exposed in the return value. See the list of text attributes below to find the defaults.
The IA2 and ATK/AT-SPI return value is a single strange in the format name:value;name:value;name:value etc.
When a certain text attribute is changed then the internal event 'EVENT_TEXT_ATTRIBUTE_CHANGED' should be fired.
In IA2, there is no data to specify what attribute changed, and for what offsets. Therefore, the AT must cache attributes of any objects that it will want to know about text attribute changes for. For example, it can cache the the text attribute ranges for the current text accessible, and compare the previous text attribute runs with the current text attribute runs.
Events will be fired for the topic object to which they apply, in order to avoid floods of too many events. For example, if someone selects all and then boldfaces the selection -- every object in the accessible tree is essentially getting an attribute change. We will reduce the number of events by only firing the text attribute change event on the root accessible for the change.
For Firefox 3, events will not be fired for style changes that are not caused by DOM changes. At the moment we are focused on the rich text editing use case. For rich text editing there will always be a DOM change.
List of supported attributes
Linux Foundation Proposed (ATK + IA2)
Note: the following characters in names and values need to be escaped with a backslash: backslash, colon, comma, equals, and semicolon.
|Attribute name||Attribute description||Default value if attribute not exposed|
|auto-generated||"true" for list bullet/numbering text or layout-inserted text (such as via CSS pseudo styles :before or :after)||false|
|background-color|| Background color as
|color|| Foreground color as
|font-family||The computed font name||no default, always specified|
|font-size||Font size in points||no default, always specified|
|font-style||italic (oblique not currently supported)||normal|
|font-weight||The computed font weight (100, 200, 300, 400, 500, 600, 700, 800, 900; normal = 400, bold = 700, bolder = 900)||400|
|invalid||"spelling" if it is marked by the inline spell checker for being incorrectly spelled. Attribute not present in all other cases. Also can support "grammar" or "true" (generally invalid but no reason given) since aria-invalid can be used to mark up any span, and aria-invalid must map to this.||Not misspelled or invalid in any way|
|language||What language is this text in, e.g. en-US (do we want this or do we use IA2::locale and make sure each locale change gets separate accessible object?) We purposely call this language and not lang, to be in line with the IA2 text attributes spec.||en-US|
|text-line-through-style||solid (only exposed if if there is a line through)||no line through|
|text-underline-style||solid (only exposed if if there is an underline)||no underline|
|text-indent||[#]mm where [#] is the number of millimeters (max precision = 1/100 of a millimeter). The text "mm" must come after the number.||0 = no indent|
|text-position (for sup/sub)||super/sub (translate from values in vertical-align)||none|
|writing-mode||rl or lr (we don't support tb - top to bottom)||lr|
The following text attributes, which are in the IAccessible2 text attribute specification, are not currently supported due to today's limitations of text formatting on the web:
The following object attribute in IA2 is not supported, because we support it via text attributes in a different way:
- list (with sub-attributes style, level & prefix) -- the list bullet text is exposed via the accessible text interface, with the text attribute static=true
The following IA2 object attributes are not supported, but potentially could be if asked for. We may need them to fully support online word processors, but need to think about how to pass on the true intentions of the word processor at that place in the text. In fact, it is currently possible for the word processor to specify these on any object by prepending aria- to the object attribute name and simply insert the attribute on the appropriate element.
- margin-left, margin-top, margin-right, margin-bottom: these object attributes are not supported, because the related browser CSS attributes have nothing to do with page margins as the IA2 object attributes do. In Mozilla the bounds of an object can be used to find where it is located.
- IA2 Text Attributes - IAccessible2 Text Attributes Documentation