Accessibility/TextAttributes: Difference between revisions

From MozillaWiki
Jump to navigation Jump to search
No edit summary
 
(2 intermediate revisions by 2 users not shown)
Line 1: Line 1:
<small>[[Accessibility |<< Back to Accessibility Home Page]]</small>
<small>[[Accessibility |<< Back to Accessibility Home Page]]</small>


= Introduction =
Text attributes are now implemented in Firefox 3.1


This article is targeted to reflect a support of text attributes by Gecko accessibility API. There is no implementation in Gecko yet. This is a draft of specification how we will do it.
This document has been superseded by the official [https://developer.mozilla.org/en/Accessibility/AT-APIs/Gecko/TextAttrs/ text attribute developer docs].


= Proposed API =
The original text attribute proposal is available in the [https://wiki.mozilla.org/index.php?title=Accessibility/TextAttributes&action=history history for this page].
 
== Summary ==
 
The following method returns a collection of text attributes at the given offset, and calculates the range where returned attributes are stretched.
 
{| summary="Method to get text attributes" border="1" cellspacing="1" cellpadding="1"
! API
! Attributes for a text range
! Attributes for entire object
|-
| Internal XPCOM
|
<pre style="margin-left: 0; padding-left: 0; border: 0; background-color: white;">
nsIPersistentProperties
  getTextAttributes(in long offset,
                    out long rangeStartOffset,
                    out long rangeEndOffset);</pre>
|
<pre style="margin-left: 0; padding-left: 0; border: 0; background-color: white;">
nsIPersistentProperties
  getDefaultTextAttributes();</pre>
|-
| IAccessible2
|
<pre style="margin-left: 0; padding-left: 0; border: 0; background-color: white;">
HRESULT
  get_attributes(in long offset, 
                long *rangeStartOffset,
                long *rangeEndOFfset,
                BSTR *textAttributes);</pre>
|
Not supported:
 
Combined into get_attributes() results.
 
|-
| AT-SPI
|
<pre style="margin-left: 0; padding-left: 0; border: 0; background-color: white;">
string
  getAttributes(in long offset,
                out long *rangeStartOffset,
                out long *rangeEndOffset);</pre>
|
<pre style="margin-left: 0; padding-left: 0; border: 0; background-color: white;">
string getDefaultAttributes();</pre>
|}
 
== Parameters (for getTextAttributes/get_attributes/getAttributes) ==
 
; offset
: [in] the given offset
 
; rangeStartOffset
: [out] the start offset of the result range
 
; rangeEndOffset
: [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&lt;b&gt;def&lt;/b&gt;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.
 
= Events =
 
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.
 
{| summary="Proposed Text Attributes" width="90%" border="1" cellspacing="1" cellpadding="1"
! 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 <code>rgb(<i>r</i>,<i>g</i>,<i>b</i>)</code> where <i>r</i>, <i>g</i> and <i>b</i> are 0-255
| transparent
|-
| color
| Foreground color as <code>rgb(<i>r</i>,<i>g</i>,<i>b</i>)</code> where <i>r</i>, <i>g</i> and <i>b</i> are 0-255
| rgb(0,0,0)
|-
| 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 [http://www.linuxfoundation.org/en/Accessibility/IAccessible2/TextAttributes 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-align
| left/center/right/justify
| left
|-
| 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
|}
 
== Currently unsupported ==
 
The following text attributes, which are in the [http://www.linux-foundation.org/en/Accessibility/IAccessible2/TextAttributes IAccessible2 text attribute specification], are not currently supported due to today's limitations of text formatting on the web:
 
* text-line-through-mode
* text-line-through-type
* text-line-through-width
* text-outline
* text-shadow
* text-underline-type
* text-underline-width
* text-underline-mode
 
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.
* line-height
* line-spacing
* text-align
* text-indent
* 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.
 
= References =
 
* [http://www.linux-foundation.org/en/Accessibility/IAccessible2/TextAttributes IA2 Text Attributes] - IAccessible2 Text Attributes Documentation

Latest revision as of 19:25, 8 March 2012

<< Back to Accessibility Home Page

Text attributes are now implemented in Firefox 3.1

This document has been superseded by the official text attribute developer docs.

The original text attribute proposal is available in the history for this page.