Merge mozilla-central into Electrolysis.

This commit is contained in:
Benjamin Smedberg 2009-09-18 16:47:18 -04:00
Родитель a98c33cdc3 de30b0442f
Коммит 181f308c2e
2125 изменённых файлов: 87319 добавлений и 87443 удалений

Просмотреть файл

@ -193,7 +193,6 @@ ifdef MOZ_CRASHREPORTER
$(MAKE_SYM_STORE_PATH) > \
$(DIST)/crashreporter-symbols/$(SYMBOL_INDEX_NAME)
echo packing symbols
mkdir -p $(topsrcdir)/../$(BUILDID)
cd $(DIST)/crashreporter-symbols && \
zip -r9D ../"$(SYMBOL_ARCHIVE_BASENAME).zip" .
endif # MOZ_CRASHREPORTER
@ -209,6 +208,7 @@ ifdef MOZILLA_OFFICIAL
echo signing NSS libs
cd $(DIST)/bin; ./shlibsign.exe -v -i softokn3.dll
cd $(DIST)/bin; ./shlibsign.exe -v -i freebl3.dll
cd $(DIST)/bin; ./shlibsign.exe -v -i nssdbm3.dll
endif # MOZILLA_OFFICIAL
deliver: rebase signnss

Просмотреть файл

@ -68,6 +68,8 @@ MIDL_INTERFACES = \
AccessibleImage.idl \
AccessibleRelation.idl \
AccessibleTable.idl \
AccessibleTable2.idl \
AccessibleTableCell.idl \
AccessibleText.idl \
AccessibleValue.idl \
$(NULL)

Просмотреть файл

@ -46,7 +46,7 @@ interface nsObjectFrame;
interface nsIContent;
interface nsITimer;
[uuid(05481634-4700-45d6-8a0c-704f3a5abc00)]
[uuid(6a58f7e8-587c-40dd-b684-dc3e54f1342a)]
interface nsIAccessibilityService : nsIAccessibleRetrieval
{
nsIAccessible createOuterDocAccessible(in nsIDOMNode aNode);
@ -72,7 +72,6 @@ interface nsIAccessibilityService : nsIAccessibleRetrieval
nsIAccessible createHTMLSelectOptionAccessible(in nsIDOMNode aNode, in nsIAccessible aAccParent, in nsIWeakReference aPresShell);
nsIAccessible createHTMLTableAccessible(in nsIFrame aFrame);
nsIAccessible createHTMLTableCellAccessible(in nsIFrame aFrame);
nsIAccessible createHTMLTableHeadAccessible(in nsIDOMNode aDOMNode);
nsIAccessible createHTMLTextAccessible(in nsIFrame aFrame);
nsIAccessible createHTMLTextFieldAccessible(in nsIFrame aFrame);
nsIAccessible createHTMLCaptionAccessible(in nsIFrame aFrame);
@ -86,22 +85,24 @@ interface nsIAccessibilityService : nsIAccessibleRetrieval
void removeNativeRootAccessible(in nsIAccessible aRootAccessible);
/**
* Invalidate the accessibility cache associated with aPresShell, for accessibles
* that were generated for aContainerContent and its subtree.
* The container content node for the change is passed in, rather than the
* changed presentation for the content node itself.
* @param aPresShell The presShell where changes occured
* @param aChangeContent The affected DOM content
* @param aEvent The event from nsIAccessibleEvent that
* caused the change:
* Must be one of:
* EVENT_REORDER (change),
* EVENT_SHOW (make visible or create) or
* EVENT_HIDE (destroy or hide)
* Used to describe sort of changes leading to accessible tree invalidation.
*/
void invalidateSubtreeFor(in nsIPresShell aPresShell,
in nsIContent aChangedContent,
in PRUint32 aEvent);
const unsigned long NODE_APPEND = 0x01;
const unsigned long NODE_REMOVE = 0x02;
const unsigned long NODE_SIGNIFICANT_CHANGE = 0x03;
const unsigned long FRAME_SHOW = 0x04;
const unsigned long FRAME_HIDE = 0x05;
const unsigned long FRAME_SIGNIFICANT_CHANGE = 0x06;
/**
* Invalidate the accessible tree when DOM tree or frame tree is changed.
*
* @param aPresShell [in] the presShell where changes occured
* @param aContent [in] the affected DOM content
* @param aChangeType [in] the change type (see constants declared above)
*/
void invalidateSubtreeFor(in nsIPresShell aPresShell, in nsIContent aContent,
in PRUint32 aChangeType);
/**
* An internal doc load event has occured. Handle the event and remove it from the list.

Просмотреть файл

@ -61,426 +61,403 @@ interface nsIDOMNode;
*
* @status UNDER_REVIEW
*/
[scriptable, uuid(ba448f0e-a761-48c8-a0f5-1f25e23d4fe4)]
[scriptable, uuid(5713f093-1d67-4666-b9e2-516f410976bc)]
interface nsIAccessibleEvent : nsISupports
{
/**
* An object has been created.
*/
const unsigned long EVENT_DOM_CREATE = 0x0001;
const unsigned long EVENT_SHOW = 0x0001;
/**
* An object has been destroyed.
*/
const unsigned long EVENT_DOM_DESTROY = 0x0002;
const unsigned long EVENT_HIDE = 0x0002;
/**
* An object's properties or content have changed significantly so that the
* type of object has really changed, and therefore the accessible should be
* destroyed or recreated.
* An object's children have changed
*/
const unsigned long EVENT_DOM_SIGNIFICANT_CHANGE = 0x0003;
/**
* A hidden object is shown -- this is a layout occurance and is thus asynchronous
*/
const unsigned long EVENT_ASYNCH_SHOW = 0x0004;
/**
* An object is hidden -- this is a layout occurance and is thus asynchronous
*/
const unsigned long EVENT_ASYNCH_HIDE = 0x0005;
/**
* An object had a significant layout change which could affect
* the type of accessible object -- this is a layout occurance and is thus asynchronous
*/
const unsigned long EVENT_ASYNCH_SIGNIFICANT_CHANGE = 0x0006;
const unsigned long EVENT_REORDER = 0x0003;
/**
* The active descendant of a component has changed. The active descendant
* is used in objects with transient children.
*/
const unsigned long EVENT_ACTIVE_DECENDENT_CHANGED = 0x0007;
const unsigned long EVENT_ACTIVE_DECENDENT_CHANGED = 0x0004;
/**
* An object has received the keyboard focus.
*/
const unsigned long EVENT_FOCUS = 0x0008;
const unsigned long EVENT_FOCUS = 0x0005;
/**
* An object's state has changed.
*/
const unsigned long EVENT_STATE_CHANGE = 0x0009;
const unsigned long EVENT_STATE_CHANGE = 0x0006;
/**
* An object has changed location, shape, or size.
*/
const unsigned long EVENT_LOCATION_CHANGE = 0x000A;
const unsigned long EVENT_LOCATION_CHANGE = 0x0007;
/**
* An object's Name property has changed.
*/
const unsigned long EVENT_NAME_CHANGE = 0x000B;
const unsigned long EVENT_NAME_CHANGE = 0x0008;
/**
* An object's Description property has changed.
*/
const unsigned long EVENT_DESCRIPTION_CHANGE = 0x000C;
const unsigned long EVENT_DESCRIPTION_CHANGE = 0x0009;
/**
* An object's Value property has changed.
*/
const unsigned long EVENT_VALUE_CHANGE = 0x000D;
const unsigned long EVENT_VALUE_CHANGE = 0x000A;
/**
* An object's help has changed.
*/
const unsigned long EVENT_HELP_CHANGE = 0x000E;
const unsigned long EVENT_HELP_CHANGE = 0x000B;
/**
* An object's default action has changed.
*/
const unsigned long EVENT_DEFACTION_CHANGE = 0x000F;
const unsigned long EVENT_DEFACTION_CHANGE = 0x000C;
/**
* An object's action has changed.
*/
const unsigned long EVENT_ACTION_CHANGE = 0x0010;
const unsigned long EVENT_ACTION_CHANGE = 0x000D;
/**
* An object's keyboard shortcut has changed.
*/
const unsigned long EVENT_ACCELERATOR_CHANGE = 0x0011;
const unsigned long EVENT_ACCELERATOR_CHANGE = 0x000E;
/**
* The selection within a container object has changed.
*/
const unsigned long EVENT_SELECTION = 0x0012;
const unsigned long EVENT_SELECTION = 0x000F;
/**
* An item within a container object has been added to the selection.
*/
const unsigned long EVENT_SELECTION_ADD = 0x0013;
const unsigned long EVENT_SELECTION_ADD = 0x0010;
/**
* An item within a container object has been removed from the selection.
*/
const unsigned long EVENT_SELECTION_REMOVE = 0x0014;
const unsigned long EVENT_SELECTION_REMOVE = 0x0011;
/**
* Numerous selection changes have occurred within a container object.
*/
const unsigned long EVENT_SELECTION_WITHIN = 0x0015;
const unsigned long EVENT_SELECTION_WITHIN = 0x0012;
/**
* An alert has been generated. Server applications send this event when a
* user needs to know that a user interface element has changed.
*/
const unsigned long EVENT_ALERT = 0x0016;
const unsigned long EVENT_ALERT = 0x0013;
/**
* The foreground window has changed.
*/
const unsigned long EVENT_FOREGROUND = 0x0017;
const unsigned long EVENT_FOREGROUND = 0x0014;
/**
* A menu item on the menu bar has been selected.
*/
const unsigned long EVENT_MENU_START = 0x0018;
const unsigned long EVENT_MENU_START = 0x0015;
/**
* A menu from the menu bar has been closed.
*/
const unsigned long EVENT_MENU_END = 0x0019;
const unsigned long EVENT_MENU_END = 0x0016;
/**
* A pop-up menu has been displayed.
*/
const unsigned long EVENT_MENUPOPUP_START = 0x001A;
const unsigned long EVENT_MENUPOPUP_START = 0x0017;
/**
* A pop-up menu has been closed.
*/
const unsigned long EVENT_MENUPOPUP_END = 0x001B;
const unsigned long EVENT_MENUPOPUP_END = 0x0018;
/**
* A window has received mouse capture.
*/
const unsigned long EVENT_CAPTURE_START = 0x001C;
const unsigned long EVENT_CAPTURE_START = 0x0019;
/**
* A window has lost mouse capture.
*/
const unsigned long EVENT_CAPTURE_END = 0x001D;
const unsigned long EVENT_CAPTURE_END = 0x001A;
/**
* A window is being moved or resized.
*/
const unsigned long EVENT_MOVESIZE_START = 0x001E;
const unsigned long EVENT_MOVESIZE_START = 0x001B;
/**
* The movement or resizing of a window has finished
*/
const unsigned long EVENT_MOVESIZE_END = 0x001F;
const unsigned long EVENT_MOVESIZE_END = 0x001C;
/**
* A window has entered context-sensitive Help mode
*/
const unsigned long EVENT_CONTEXTHELP_START = 0x0020;
const unsigned long EVENT_CONTEXTHELP_START = 0x001D;
/**
* A window has exited context-sensitive Help mode
*/
const unsigned long EVENT_CONTEXTHELP_END = 0x0021;
const unsigned long EVENT_CONTEXTHELP_END = 0x001E;
/**
* An application is about to enter drag-and-drop mode
*/
const unsigned long EVENT_DRAGDROP_START = 0x0022;
const unsigned long EVENT_DRAGDROP_START = 0x001F;
/**
* An application is about to exit drag-and-drop mode
*/
const unsigned long EVENT_DRAGDROP_END = 0x0023;
const unsigned long EVENT_DRAGDROP_END = 0x0020;
/**
* A dialog box has been displayed
*/
const unsigned long EVENT_DIALOG_START = 0x0024;
const unsigned long EVENT_DIALOG_START = 0x0021;
/**
* A dialog box has been closed
*/
const unsigned long EVENT_DIALOG_END = 0x0025;
const unsigned long EVENT_DIALOG_END = 0x0022;
/**
* Scrolling has started on a scroll bar
*/
const unsigned long EVENT_SCROLLING_START = 0x0026;
const unsigned long EVENT_SCROLLING_START = 0x0023;
/**
* Scrolling has ended on a scroll bar
*/
const unsigned long EVENT_SCROLLING_END = 0x0027;
const unsigned long EVENT_SCROLLING_END = 0x0024;
/**
* A window object is about to be minimized or maximized
*/
const unsigned long EVENT_MINIMIZE_START = 0x0028;
const unsigned long EVENT_MINIMIZE_START = 0x0025;
/**
* A window object has been minimized or maximized
*/
const unsigned long EVENT_MINIMIZE_END = 0x0029;
const unsigned long EVENT_MINIMIZE_END = 0x0026;
/**
* XXX:
*/
const unsigned long EVENT_DOCUMENT_LOAD_START = 0x002A;
const unsigned long EVENT_DOCUMENT_LOAD_START = 0x0027;
/**
* The loading of the document has completed.
*/
const unsigned long EVENT_DOCUMENT_LOAD_COMPLETE = 0x002B;
const unsigned long EVENT_DOCUMENT_LOAD_COMPLETE = 0x0028;
/**
* The document contents are being reloaded.
*/
const unsigned long EVENT_DOCUMENT_RELOAD = 0x002C;
const unsigned long EVENT_DOCUMENT_RELOAD = 0x0029;
/**
* The loading of the document was interrupted.
*/
const unsigned long EVENT_DOCUMENT_LOAD_STOPPED = 0x002D;
const unsigned long EVENT_DOCUMENT_LOAD_STOPPED = 0x002A;
/**
* The document wide attributes of the document object have changed.
*/
const unsigned long EVENT_DOCUMENT_ATTRIBUTES_CHANGED = 0x002E;
const unsigned long EVENT_DOCUMENT_ATTRIBUTES_CHANGED = 0x002B;
/**
* The contents of the document have changed.
*/
const unsigned long EVENT_DOCUMENT_CONTENT_CHANGED = 0x002F;
const unsigned long EVENT_DOCUMENT_CONTENT_CHANGED = 0x002C;
const unsigned long EVENT_PROPERTY_CHANGED = 0x0030;
const unsigned long EVENT_SELECTION_CHANGED = 0x0031;
const unsigned long EVENT_PROPERTY_CHANGED = 0x002D;
const unsigned long EVENT_SELECTION_CHANGED = 0x002E;
/**
* A text object's attributes changed.
* Also see EVENT_OBJECT_ATTRIBUTE_CHANGED.
*/
const unsigned long EVENT_TEXT_ATTRIBUTE_CHANGED = 0x0032;
const unsigned long EVENT_TEXT_ATTRIBUTE_CHANGED = 0x002F;
/**
* The caret has moved to a new position.
*/
const unsigned long EVENT_TEXT_CARET_MOVED = 0x0033;
const unsigned long EVENT_TEXT_CARET_MOVED = 0x0030;
/**
* This event indicates general text changes, i.e. changes to text that is
* exposed through the IAccessibleText and IAccessibleEditableText interfaces.
*/
const unsigned long EVENT_TEXT_CHANGED = 0x0034;
const unsigned long EVENT_TEXT_CHANGED = 0x0031;
/**
* Text was inserted.
*/
const unsigned long EVENT_TEXT_INSERTED = 0x0035;
const unsigned long EVENT_TEXT_INSERTED = 0x0032;
/**
* Text was removed.
*/
const unsigned long EVENT_TEXT_REMOVED = 0x0036;
const unsigned long EVENT_TEXT_REMOVED = 0x0033;
/**
* Text was updated.
*/
const unsigned long EVENT_TEXT_UPDATED = 0x0037;
const unsigned long EVENT_TEXT_UPDATED = 0x0034;
/**
* The text selection changed.
*/
const unsigned long EVENT_TEXT_SELECTION_CHANGED = 0x0038;
const unsigned long EVENT_TEXT_SELECTION_CHANGED = 0x0035;
/**
* A visibile data event indicates the change of the visual appearance
* of an accessible object. This includes for example most of the
* attributes available via the IAccessibleComponent interface.
*/
const unsigned long EVENT_VISIBLE_DATA_CHANGED = 0x0039;
const unsigned long EVENT_VISIBLE_DATA_CHANGED = 0x0036;
/**
* The caret moved from one column to the next.
*/
const unsigned long EVENT_TEXT_COLUMN_CHANGED = 0x003A;
const unsigned long EVENT_TEXT_COLUMN_CHANGED = 0x0037;
/**
* The caret moved from one section to the next.
*/
const unsigned long EVENT_SECTION_CHANGED = 0x003B;
const unsigned long EVENT_SECTION_CHANGED = 0x0038;
/**
* A table caption changed.
*/
const unsigned long EVENT_TABLE_CAPTION_CHANGED = 0x003C;
const unsigned long EVENT_TABLE_CAPTION_CHANGED = 0x0039;
/**
* A table's data changed.
*/
const unsigned long EVENT_TABLE_MODEL_CHANGED = 0x003D;
const unsigned long EVENT_TABLE_MODEL_CHANGED = 0x003A;
/**
* A table's summary changed.
*/
const unsigned long EVENT_TABLE_SUMMARY_CHANGED = 0x003E;
const unsigned long EVENT_TABLE_SUMMARY_CHANGED = 0x003B;
/**
* A table's row description changed.
*/
const unsigned long EVENT_TABLE_ROW_DESCRIPTION_CHANGED = 0x003F;
const unsigned long EVENT_TABLE_ROW_DESCRIPTION_CHANGED = 0x003C;
/**
* A table's row header changed.
*/
const unsigned long EVENT_TABLE_ROW_HEADER_CHANGED = 0x0040;
const unsigned long EVENT_TABLE_ROW_HEADER_CHANGED = 0x003D;
const unsigned long EVENT_TABLE_ROW_INSERT = 0x0041;
const unsigned long EVENT_TABLE_ROW_DELETE = 0x0042;
const unsigned long EVENT_TABLE_ROW_REORDER = 0x0043;
const unsigned long EVENT_TABLE_ROW_INSERT = 0x003E;
const unsigned long EVENT_TABLE_ROW_DELETE = 0x003F;
const unsigned long EVENT_TABLE_ROW_REORDER = 0x0040;
/**
* A table's column description changed.
*/
const unsigned long EVENT_TABLE_COLUMN_DESCRIPTION_CHANGED = 0x0044;
const unsigned long EVENT_TABLE_COLUMN_DESCRIPTION_CHANGED = 0x0041;
/**
* A table's column header changed.
*/
const unsigned long EVENT_TABLE_COLUMN_HEADER_CHANGED = 0x0045;
const unsigned long EVENT_TABLE_COLUMN_HEADER_CHANGED = 0x0042;
const unsigned long EVENT_TABLE_COLUMN_INSERT = 0x0046;
const unsigned long EVENT_TABLE_COLUMN_DELETE = 0x0047;
const unsigned long EVENT_TABLE_COLUMN_REORDER = 0x0048;
const unsigned long EVENT_TABLE_COLUMN_INSERT = 0x0043;
const unsigned long EVENT_TABLE_COLUMN_DELETE = 0x0044;
const unsigned long EVENT_TABLE_COLUMN_REORDER = 0x0045;
const unsigned long EVENT_WINDOW_ACTIVATE = 0x0049;
const unsigned long EVENT_WINDOW_CREATE = 0x004A;
const unsigned long EVENT_WINDOW_DEACTIVATE = 0x004B;
const unsigned long EVENT_WINDOW_DESTROY = 0x004C;
const unsigned long EVENT_WINDOW_MAXIMIZE = 0x004D;
const unsigned long EVENT_WINDOW_MINIMIZE = 0x004E;
const unsigned long EVENT_WINDOW_RESIZE = 0x004F;
const unsigned long EVENT_WINDOW_RESTORE = 0x0050;
const unsigned long EVENT_WINDOW_ACTIVATE = 0x0046;
const unsigned long EVENT_WINDOW_CREATE = 0x0047;
const unsigned long EVENT_WINDOW_DEACTIVATE = 0x0048;
const unsigned long EVENT_WINDOW_DESTROY = 0x0049;
const unsigned long EVENT_WINDOW_MAXIMIZE = 0x004A;
const unsigned long EVENT_WINDOW_MINIMIZE = 0x004B;
const unsigned long EVENT_WINDOW_RESIZE = 0x004C;
const unsigned long EVENT_WINDOW_RESTORE = 0x004D;
/**
* The ending index of this link within the containing string has changed.
*/
const unsigned long EVENT_HYPERLINK_END_INDEX_CHANGED = 0x0051;
const unsigned long EVENT_HYPERLINK_END_INDEX_CHANGED = 0x004E;
/**
* The number of anchors assoicated with this hyperlink object has changed.
*/
const unsigned long EVENT_HYPERLINK_NUMBER_OF_ANCHORS_CHANGED = 0x0052;
const unsigned long EVENT_HYPERLINK_NUMBER_OF_ANCHORS_CHANGED = 0x004F;
/**
* The hyperlink selected state changed from selected to unselected or
* from unselected to selected.
*/
const unsigned long EVENT_HYPERLINK_SELECTED_LINK_CHANGED = 0x0053;
const unsigned long EVENT_HYPERLINK_SELECTED_LINK_CHANGED = 0x0050;
/**
* One of the links associated with the hypertext object has been activated.
*/
const unsigned long EVENT_HYPERTEXT_LINK_ACTIVATED = 0x0054;
const unsigned long EVENT_HYPERTEXT_LINK_ACTIVATED = 0x0051;
/**
* One of the links associated with the hypertext object has been selected.
*/
const unsigned long EVENT_HYPERTEXT_LINK_SELECTED = 0x0055;
const unsigned long EVENT_HYPERTEXT_LINK_SELECTED = 0x0052;
/**
* The starting index of this link within the containing string has changed.
*/
const unsigned long EVENT_HYPERLINK_START_INDEX_CHANGED = 0x0056;
const unsigned long EVENT_HYPERLINK_START_INDEX_CHANGED = 0x0053;
/**
* Focus has changed from one hypertext object to another, or focus moved
* from a non-hypertext object to a hypertext object, or focus moved from a
* hypertext object to a non-hypertext object.
*/
const unsigned long EVENT_HYPERTEXT_CHANGED = 0x0057;
const unsigned long EVENT_HYPERTEXT_CHANGED = 0x0054;
/**
* The number of hyperlinks associated with a hypertext object changed.
*/
const unsigned long EVENT_HYPERTEXT_NLINKS_CHANGED = 0x0058;
const unsigned long EVENT_HYPERTEXT_NLINKS_CHANGED = 0x0055;
/**
* An object's attributes changed. Also see EVENT_TEXT_ATTRIBUTE_CHANGED.
*/
const unsigned long EVENT_OBJECT_ATTRIBUTE_CHANGED = 0x0059;
const unsigned long EVENT_OBJECT_ATTRIBUTE_CHANGED = 0x0056;
/**
* A slide changed in a presentation document or a page boundary was
* crossed in a word processing document.
*/
const unsigned long EVENT_PAGE_CHANGED = 0x005A;
const unsigned long EVENT_PAGE_CHANGED = 0x0057;
/**
* Used internally in Gecko.
*/
const unsigned long EVENT_INTERNAL_LOAD = 0x005B;
/**
* An object's children have changed
*/
const unsigned long EVENT_REORDER = 0x005C;
const unsigned long EVENT_INTERNAL_LOAD = 0x0058;
/**
* Help make sure event map does not get out-of-line.
*/
const unsigned long EVENT_LAST_ENTRY = 0x005D;
const unsigned long EVENT_LAST_ENTRY = 0x0059;
/**
* The type of event, based on the enumerated event values
@ -515,8 +492,8 @@ interface nsIAccessibleEvent : nsISupports
};
[scriptable, uuid(444db51a-05fd-4576-8a64-32dbb2a83884)]
interface nsIAccessibleStateChangeEvent : nsIAccessibleEvent
[scriptable, uuid(9addd25d-8fa1-415e-94ec-6038f220d3e4)]
interface nsIAccessibleStateChangeEvent : nsISupports
{
/**
* Returns the state of accessible (see constants declared
@ -536,8 +513,8 @@ interface nsIAccessibleStateChangeEvent : nsIAccessibleEvent
};
[scriptable, uuid(50a1e151-8e5f-4bcc-aaaf-a4bed1190e93)]
interface nsIAccessibleTextChangeEvent : nsIAccessibleEvent
[scriptable, uuid(21e0f8bd-5638-4964-870b-3c8e944ac4c4)]
interface nsIAccessibleTextChangeEvent : nsISupports
{
/**
* Returns offset of changed text in accessible.
@ -560,8 +537,8 @@ interface nsIAccessibleTextChangeEvent : nsIAccessibleEvent
readonly attribute DOMString modifiedText;
};
[scriptable, uuid(b9076dce-4cd3-4e3d-a7f6-7f33a7f40c31)]
interface nsIAccessibleCaretMoveEvent: nsIAccessibleEvent
[scriptable, uuid(5675c486-a230-4d85-a4bd-33670826d5ff)]
interface nsIAccessibleCaretMoveEvent: nsISupports
{
/**
* Return caret offset.
@ -569,8 +546,8 @@ interface nsIAccessibleCaretMoveEvent: nsIAccessibleEvent
readonly attribute long caretOffset;
};
[scriptable, uuid(a9485c7b-5861-4695-8441-fab0235b205d)]
interface nsIAccessibleTableChangeEvent: nsIAccessibleEvent
[scriptable, uuid(df517997-ed52-4ea2-b310-2f8e0fe64572)]
interface nsIAccessibleTableChangeEvent: nsISupports
{
/**
* Return the row or column index.

Просмотреть файл

@ -24,6 +24,7 @@
* Paul Sandoz (paul.sandoz@sun.com)
* Bill Haneman (bill.haneman@sun.com)
* John Gaunt (jgaunt@netscape.com)
* Alexander Surkov <surkov.alexander@gmail.com>
*
* Alternatively, the contents of this file may be used under the terms of
* either of the GNU General Public License Version 2 or later (the "GPL"),
@ -42,216 +43,201 @@
#include "nsISupports.idl"
interface nsIAccessible;
interface nsIArray;
[scriptable, uuid(dcc1e5c3-966e-45b2-b30a-839d35432b24)]
[scriptable, uuid(035c0c0e-41e3-4985-8ad9-d9f14cdc667a)]
interface nsIAccessibleTable : nsISupports
{
/**
* Returns the caption accessible for the table. For example, html:caption
* Return the caption accessible for the table. For example, html:caption
* element of html:table element.
*/
readonly attribute nsIAccessible caption;
readonly attribute nsIAccessible caption;
/**
* Returns summary description for the table. For example, @summary attribute
* on html:element.
* Return summary description for the table. For example, @summary attribute
* on html:table element.
*/
readonly attribute AString summary;
readonly attribute AString summary;
/**
* Returns columns count in the table.
* XXX: not very well named property.
* Return columns count in the table.
*/
readonly attribute long columns;
readonly attribute long columnCount;
/**
* Returns table accessible containing column headers.
* Return rows count in the table.
*/
readonly attribute nsIAccessibleTable columnHeader;
readonly attribute long rowCount;
/**
* Returns rows count in the table.
* XXX: not very well named property.
*/
readonly attribute long rows;
/**
* Returns table accessible containing row headers.
*/
readonly attribute nsIAccessibleTable rowHeader;
/**
* Returns the accessible object at the specified row and column in the table.
* Return the accessible object at the specified row and column in the table.
* If both row and column index are valid then the corresponding accessible
* object is returned that represents the requested cell regardless of whether
* the cell is currently visible (on the screen).
*
* @param row - The row index for which to retrieve the cell.
* @param column - The column index for which to retrieve the cell.
* @param rowIndex [in] the row index to retrieve the cell at
* @param columnIndex [in] the column index to retrieve the cell at
*/
nsIAccessible cellRefAt(in long row, in long column);
nsIAccessible getCellAt(in long rowIndex, in long columnIndex);
/**
* Translates the given row and column indices into the corresponding cell
* Translate the given row and column indices into the corresponding cell
* index.
*
* @param row - index of the row of the table for which to return the cell
* index.
* @param column - index of the column of the table for which to return
* the cell index.
* @param rowIndex [in] the row index to return cell index at
* @param columnIndex [in] the column index to return cell index at
*/
long getIndexAt(in long row, in long column);
long getCellIndexAt(in long rowIndex, in long columnIndex);
/**
* Translates the given child index into the corresponding column index.
* Translate the given cell index into the corresponding column index.
*
* @param index - index of the child of the table for which to return
* the column index.
* @param cellIndex [in] index of the table cell to return column index for
*/
long getColumnAtIndex(in long index);
long getColumnIndexAt(in long cellIndex);
/**
* Translates the given child index into the corresponding row index.
* Translate the given cell index into the corresponding row index.
*
* @param index - index of the child of the table for which to return
* the row index.
* @param cellIndex [in] index of the table cell to return row index for
*/
long getRowAtIndex(in long index);
long getRowIndexAt(in long cellIndex);
/**
* Returns the number of columns occupied by the accessible object
* at the specified row and column in the table. The result differs from 1
* if the specified cell spans multiple columns.
* Return the number of columns occupied by the accessible cell at
* the specified row and column in the table. The result differs from 1 if
* the specified cell spans multiple columns.
*
* @param row - Row index of the accessible for which to return
* the column extent.
* @param column - Column index of the accessible for which to return
* the column extent.
* @param row [in] row index of the cell to return the column extent for
* @param column [in] column index of the cell to return the column extent
* for
*/
long getColumnExtentAt(in long row, in long column);
/**
* Returns the number of rows occupied by the accessible oject
* at the specified row and column in the table. The result differs from 1
* if the specified cell spans multiple rows.
* Return the number of rows occupied by the accessible cell at the specified
* row and column in the table. The result differs from 1 if the specified
* cell spans multiple rows.
*
* @param row - Row index of the accessible for which to return
* the column extent.
* @param column - Column index of the accessible for which to return
* the column extent.
* @param row [in] row index of the cell to return the column extent for
* @param column [in] column index of the cell to return the column extent
* for
*/
long getRowExtentAt(in long row, in long column);
/**
* Returns the description text of the specified column in the table.
* @param column - The index of the column for which to retrieve
* the description.
*/
AString getColumnDescription(in long column);
/**
* Returns the description text of the specified row in the table.
* @param row - The index of the row for which to retrieve the description.
*/
AString getRowDescription(in long row);
/**
* Returns a boolean value indicating whether the specified column is
* completely selected.
* Return the description text of the specified column in the table.
*
* @param column - Index of the column for which to determine whether it is
* selected.
* @param columnIndex [in] the column index to retrieve description for
*/
boolean isColumnSelected(in long column);
AString getColumnDescription(in long columnIndex);
/**
* Returns a boolean value indicating whether the specified row is completely
* selected.
* Return the description text of the specified row in the table.
*
* @param row - Index of the row for which to determine whether it is
* selected.
* @param rowIndex [in] the row index to retrieve description for
*/
boolean isRowSelected(in long row);
AString getRowDescription(in long rowIndex);
/**
* Returns a boolean value indicating whether the specified cell is selected.
* Return a boolean value indicating whether the specified column is
* selected, i.e. all cells within the column are selected.
*
* @param row - Index of the row for the cell to determine whether it is
* selected.
* @param column - Index of the column for the cell to determine whether it
* is selected.
* @param columnIndex [in] the column index to determine if it's selected
*/
boolean isCellSelected(in long row, in long column);
boolean isColumnSelected(in long columnIndex);
/**
* Returns the total number of selected cells.
*/
readonly attribute unsigned long selectedCellsCount;
/**
* Returns the total number of selected columns.
*/
readonly attribute unsigned long selectedColumnsCount;
/**
* Returns the total number of selected rows.
*/
readonly attribute unsigned long selectedRowsCount;
/**
* Returns a list of cells indexes currently selected.
* Return a boolean value indicating whether the specified row is selected,
* i.e. all cells within the row are selected.
*
* @param cellsSize - length of array
* @param cells - array of indexes of selected cells
* @param rowIndex [in] the row index to determine whether it's selected
*/
void getSelectedCells(out unsigned long cellsSize,
[retval, array, size_is(cellsSize)] out long cells);
boolean isRowSelected(in long rowIndex);
/**
* Returns a list of column indexes currently selected.
* Return a boolean value indicating whether the specified cell is selected.
*
* @param columnsSize - Length of array
* @param columns - Array of indexes of selected columns
* @param rowIndex [in] the row index of the cell
* @param columnIndex [in] the column index of the cell
*/
void getSelectedColumns(out unsigned long columnsSize,
[retval, array, size_is(columnsSize)] out long columns);
boolean isCellSelected(in long rowIndex, in long columnIndex);
/**
* Returns a list of row indexes currently selected.
*
* @param rowsSize - Length of array
* @param rows - Array of indexes of selected rows
* Return the total number of selected cells.
*/
void getSelectedRows(out unsigned long rowsSize,
[retval, array, size_is(rowsSize)] out long rows);
readonly attribute unsigned long selectedCellCount;
/**
* Selects a row and unselects all previously selected rows.
*
* @param row - Index of the row to be selected.
* Return the total number of selected columns.
*/
void selectRow(in long row);
readonly attribute unsigned long selectedColumnCount;
/**
* Selects a column and unselects all previously selected columns.
*
* @param column - Index of the column to be selected.
* Return the total number of selected rows.
*/
void selectColumn(in long column);
readonly attribute unsigned long selectedRowCount;
/**
* Unselects one row, leaving other selected rows selected (if any).
* Return an array of selected cells.
*/
readonly attribute nsIArray selectedCells;
/**
* Return an array of cell indices currently selected.
*
* @param row - Index of the row to be selected.
* @param cellsArraySize [in] length of array
* @param cellsArray [in] array of indexes of selected cells
*/
void getSelectedCellIndices(out unsigned long cellsArraySize,
[retval, array, size_is(cellsArraySize)] out long cellsArray);
/**
* Return an array of column indices currently selected.
*
* @param columnsArraySize [in] length of array
* @param columnsArray [in] array of indices of selected columns
*/
void getSelectedColumnIndices(out unsigned long columnsArraySize,
[retval, array, size_is(columnsArraySize)] out long columnsArray);
/**
* Return an array of row indices currently selected.
*
* @param rowsArraySize [in] Length of array
* @param rowsArray [in] array of indices of selected rows
*/
void getSelectedRowIndices(out unsigned long rowsArraySize,
[retval, array, size_is(rowsArraySize)] out long rowsArray);
/**
* Select a row and unselects all previously selected rows.
*
* @param rowIndex [in] the row index to select
*/
void selectRow(in long rowIndex);
/**
* Select a column and unselects all previously selected columns.
*
* @param columnIndex [in] the column index to select
*/
void selectColumn(in long columnIndex);
/**
* Unselect the given row, leaving other selected rows selected (if any).
*
* @param rowIndex [in] the row index to select
*/
void unselectRow(in long row);
void unselectRow(in long rowIndex);
/**
* Unselects one column, leaving other selected columns selected (if any).
* Unselect the given column, leaving other selected columns selected (if any).
*
* @param column - Index of the column to be selected.
* @param columnIndex [in] the column index to select
*/
void unselectColumn(in long column);
void unselectColumn(in long columnIndex);
/**
* Use heuristics to determine if table is most likely used for layout.
@ -259,3 +245,49 @@ interface nsIAccessibleTable : nsISupports
boolean isProbablyForLayout();
};
[scriptable, uuid(654e296d-fae6-452b-987d-746b20b9514b)]
interface nsIAccessibleTableCell : nsISupports
{
/**
* Return host table accessible.
*/
readonly attribute nsIAccessibleTable table;
/**
* Return column index of this cell.
*/
readonly attribute long columnIndex;
/**
* Return row index of this cell.
*/
readonly attribute long rowIndex;
/**
* Return the number of columns occupied by this cell. The result differs
* from 1 if the specified cell spans multiple columns.
*/
readonly attribute long columnExtent;
/**
* Return the number of rows occupied by this accessible cell. The result
* differs from 1 if the specified cell spans multiple rows.
*/
readonly attribute long rowExtent;
/**
* Return an array of column header cells for this cell.
*/
readonly attribute nsIArray columnHeaderCells;
/**
* Return an array of row header cells for this cell.
*/
readonly attribute nsIArray rowHeaderCells;
/**
* Return a boolean value indicating whether this cell is selected.
*/
boolean isSelected();
};

Просмотреть файл

@ -66,12 +66,6 @@ CPPSRCS = \
nsMaiInterfaceImage.cpp \
$(NULL)
ifdef MOZ_XUL
CPPSRCS += \
nsXULTreeAccessibleWrap.cpp \
$(NULL)
endif
EXPORTS = \
nsAccessNodeWrap.h \
nsARIAGridAccessibleWrap.h \
@ -80,7 +74,8 @@ EXPORTS = \
nsRootAccessibleWrap.h \
nsTextAccessibleWrap.h \
nsXULMenuAccessibleWrap.h \
nsXULTreeAccessibleWrap.h \
nsXULListboxAccessibleWrap.h \
nsXULTreeGridAccessibleWrap.h \
nsHyperTextAccessibleWrap.h \
nsHTMLImageAccessibleWrap.h \
nsHTMLTableAccessibleWrap.h \

Просмотреть файл

@ -44,6 +44,7 @@
#include "nsARIAGridAccessible.h"
typedef class nsARIAGridAccessible nsARIAGridAccessibleWrap;
typedef class nsARIAGridCellAccessible nsARIAGridCellAccessibleWrap;
#endif

Просмотреть файл

@ -1131,10 +1131,8 @@ nsAccessibleWrap::FirePlatformEvent(nsIAccessibleEvent *aEvent)
// We don't create ATK objects for nsIAccessible plain text leaves,
// just return NS_OK in such case
if (!atkObj) {
NS_ASSERTION(type == nsIAccessibleEvent::EVENT_ASYNCH_SHOW ||
type == nsIAccessibleEvent::EVENT_ASYNCH_HIDE ||
type == nsIAccessibleEvent::EVENT_DOM_CREATE ||
type == nsIAccessibleEvent::EVENT_DOM_DESTROY,
NS_ASSERTION(type == nsIAccessibleEvent::EVENT_SHOW ||
type == nsIAccessibleEvent::EVENT_HIDE,
"Event other than SHOW and HIDE fired for plain text leaves");
return NS_OK;
}
@ -1159,7 +1157,7 @@ nsAccessibleWrap::FirePlatformEvent(nsIAccessibleEvent *aEvent)
if (rootAccWrap && rootAccWrap->mActivated) {
atk_focus_tracker_notify(atkObj);
// Fire state change event for focus
nsCOMPtr<nsIAccessibleStateChangeEvent> stateChangeEvent =
nsCOMPtr<nsIAccessibleEvent> stateChangeEvent =
new nsAccStateChangeEvent(accessible,
nsIAccessibleStates::STATE_FOCUSED,
PR_FALSE, PR_TRUE);
@ -1308,12 +1306,10 @@ nsAccessibleWrap::FirePlatformEvent(nsIAccessibleEvent *aEvent)
g_signal_emit_by_name(atkObj, "visible_data_changed");
break;
case nsIAccessibleEvent::EVENT_DOM_CREATE:
case nsIAccessibleEvent::EVENT_ASYNCH_SHOW:
case nsIAccessibleEvent::EVENT_SHOW:
return FireAtkShowHideEvent(aEvent, atkObj, PR_TRUE);
case nsIAccessibleEvent::EVENT_DOM_DESTROY:
case nsIAccessibleEvent::EVENT_ASYNCH_HIDE:
case nsIAccessibleEvent::EVENT_HIDE:
return FireAtkShowHideEvent(aEvent, atkObj, PR_FALSE);
/*
@ -1450,7 +1446,7 @@ nsAccessibleWrap::FireAtkTextChangedEvent(nsIAccessibleEvent *aEvent,
event->IsInserted(&isInserted);
PRBool isFromUserInput;
event->GetIsFromUserInput(&isFromUserInput);
aEvent->GetIsFromUserInput(&isFromUserInput);
char *signal_name = g_strconcat(isInserted ? "text_changed::insert" : "text_changed::delete",
isFromUserInput ? "" : kNonUserInputEvent, NULL);

Просмотреть файл

@ -44,8 +44,8 @@
#include "nsHTMLTableAccessible.h"
typedef class nsHTMLTableAccessible nsHTMLTableAccessibleWrap;
typedef class nsHTMLTableHeadAccessible nsHTMLTableHeadAccessibleWrap;
typedef class nsHTMLTableCellAccessible nsHTMLTableCellAccessibleWrap;
typedef class nsHTMLTableHeaderCellAccessible nsHTMLTableHeaderCellAccessibleWrap;
#endif

Просмотреть файл

@ -40,6 +40,8 @@
#include "nsMaiInterfaceTable.h"
#include "nsArrayUtils.h"
void
tableInterfaceInitCB(AtkTableIface *aIface)
@ -81,7 +83,7 @@ refAtCB(AtkTable *aTable, gint aRow, gint aColumn)
NS_ENSURE_TRUE(accTable, nsnull);
nsCOMPtr<nsIAccessible> cell;
nsresult rv = accTable->CellRefAt(aRow, aColumn,getter_AddRefs(cell));
nsresult rv = accTable->GetCellAt(aRow, aColumn,getter_AddRefs(cell));
if (NS_FAILED(rv) || !cell)
return nsnull;
@ -105,7 +107,7 @@ getIndexAtCB(AtkTable *aTable, gint aRow, gint aColumn)
NS_ENSURE_TRUE(accTable, -1);
PRInt32 index;
nsresult rv = accTable->GetIndexAt(aRow, aColumn, &index);
nsresult rv = accTable->GetCellIndexAt(aRow, aColumn, &index);
NS_ENSURE_SUCCESS(rv, -1);
return static_cast<gint>(index);
@ -124,7 +126,7 @@ getColumnAtIndexCB(AtkTable *aTable, gint aIndex)
NS_ENSURE_TRUE(accTable, -1);
PRInt32 col;
nsresult rv = accTable->GetColumnAtIndex(aIndex, &col);
nsresult rv = accTable->GetColumnIndexAt(aIndex, &col);
NS_ENSURE_SUCCESS(rv, -1);
return static_cast<gint>(col);
@ -143,7 +145,7 @@ getRowAtIndexCB(AtkTable *aTable, gint aIndex)
NS_ENSURE_TRUE(accTable, -1);
PRInt32 row;
nsresult rv = accTable->GetRowAtIndex(aIndex, &row);
nsresult rv = accTable->GetRowIndexAt(aIndex, &row);
NS_ENSURE_SUCCESS(rv, -1);
return static_cast<gint>(row);
@ -162,7 +164,7 @@ getColumnCountCB(AtkTable *aTable)
NS_ENSURE_TRUE(accTable, -1);
PRInt32 count;
nsresult rv = accTable->GetColumns(&count);
nsresult rv = accTable->GetColumnCount(&count);
NS_ENSURE_SUCCESS(rv, -1);
return static_cast<gint>(count);
@ -181,7 +183,7 @@ getRowCountCB(AtkTable *aTable)
NS_ENSURE_TRUE(accTable, -1);
PRInt32 count;
nsresult rv = accTable->GetRows(&count);
nsresult rv = accTable->GetRowCount(&count);
NS_ENSURE_SUCCESS(rv, -1);
return static_cast<gint>(count);
@ -278,25 +280,34 @@ getColumnHeaderCB(AtkTable *aTable, gint aColumn)
getter_AddRefs(accTable));
NS_ENSURE_TRUE(accTable, nsnull);
nsCOMPtr<nsIAccessibleTable> header;
nsresult rv = accTable->GetColumnHeader(getter_AddRefs(header));
NS_ENSURE_SUCCESS(rv, nsnull);
NS_ENSURE_TRUE(header, nsnull);
nsCOMPtr<nsIAccessible> accCell;
accTable->GetCellAt(0, aColumn, getter_AddRefs(accCell));
if (!accCell)
return nsnull;
// Note: "table column header" has different definition between atk and mai
//
// 1. "getColumnHeaderCB" defined in AtkTableIface should return object
// whose role is "ATK_ROLE_TABLE_COLUMN_HEADER", which is implemented
// by nsXULTreeColumnItemAccessible.
//
// 2. "GetColumnHeader" defined in nsIAccessibleTable returns
// nsXULTreeColumnsAccessibleWrap, which exports nsIAccessibleTable and is
// "ROLE_LIST".
nsCOMPtr<nsIAccessible> accHeader;
header->CellRefAt(0, aColumn, getter_AddRefs(accHeader));
NS_ENSURE_TRUE(accHeader, nsnull);
// If the cell at the first row is column header then assume it is column
// header for all rows,
if (nsAccUtils::Role(accCell) == nsIAccessibleRole::ROLE_COLUMNHEADER)
return nsAccessibleWrap::GetAtkObject(accCell);
return nsAccessibleWrap::GetAtkObject(accHeader);
// otherwise get column header for the data cell at the first row.
nsCOMPtr<nsIAccessibleTableCell> accTableCell =
do_QueryInterface(accCell);
if (accTableCell) {
nsCOMPtr<nsIArray> headerCells;
accTableCell->GetColumnHeaderCells(getter_AddRefs(headerCells));
if (headerCells) {
nsresult rv;
nsCOMPtr<nsIAccessible> accHeaderCell =
do_QueryElementAt(headerCells, 0, &rv);
NS_ENSURE_SUCCESS(rv, nsnull);
return nsAccessibleWrap::GetAtkObject(accHeaderCell);
}
}
return nsnull;
}
const gchar*
@ -330,14 +341,34 @@ getRowHeaderCB(AtkTable *aTable, gint aRow)
getter_AddRefs(accTable));
NS_ENSURE_TRUE(accTable, nsnull);
nsCOMPtr<nsIAccessibleTable> header;
nsresult rv = accTable->GetRowHeader(getter_AddRefs(header));
NS_ENSURE_SUCCESS(rv, nsnull);
nsCOMPtr<nsIAccessible> accCell;
accTable->GetCellAt(aRow, 0, getter_AddRefs(accCell));
if (!accCell)
return nsnull;
nsCOMPtr<nsIAccessible> accHeader(do_QueryInterface(header));
NS_ENSURE_TRUE(accHeader, nsnull);
// If the cell at the first column is row header then assume it is row
// header for all columns,
if (nsAccUtils::Role(accCell) == nsIAccessibleRole::ROLE_ROWHEADER)
return nsAccessibleWrap::GetAtkObject(accCell);
return nsAccessibleWrap::GetAtkObject(accHeader);
// otherwise get row header for the data cell at the first column.
nsCOMPtr<nsIAccessibleTableCell> accTableCell =
do_QueryInterface(accCell);
if (accTableCell) {
nsCOMPtr<nsIArray> headerCells;
accTableCell->GetRowHeaderCells(getter_AddRefs(headerCells));
if (headerCells) {
nsresult rv;
nsCOMPtr<nsIAccessible> accHeaderCell =
do_QueryElementAt(headerCells, 0, &rv);
NS_ENSURE_SUCCESS(rv, nsnull);
return nsAccessibleWrap::GetAtkObject(accHeaderCell);
}
}
return nsnull;
}
AtkObject*
@ -364,7 +395,7 @@ getSelectedColumnsCB(AtkTable *aTable, gint **aSelected)
PRUint32 size = 0;
PRInt32 *columns = NULL;
nsresult rv = accTable->GetSelectedColumns(&size, &columns);
nsresult rv = accTable->GetSelectedColumnIndices(&size, &columns);
if (NS_FAILED(rv) || (size == 0) || !columns) {
*aSelected = nsnull;
return 0;
@ -399,7 +430,7 @@ getSelectedRowsCB(AtkTable *aTable, gint **aSelected)
PRUint32 size = 0;
PRInt32 *rows = NULL;
nsresult rv = accTable->GetSelectedRows(&size, &rows);
nsresult rv = accTable->GetSelectedRowIndices(&size, &rows);
if (NS_FAILED(rv) || (size == 0) || !rows) {
*aSelected = nsnull;
return 0;

Просмотреть файл

@ -15,15 +15,16 @@
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 2003
* Mozilla Corporation.
* Portions created by the Initial Developer are Copyright (C) 2009
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Alexander Surkov <surkov.alexander@gmail.com> (original author)
*
* Alternatively, the contents of this file may be used under the terms of
* either of the GNU General Public License Version 2 or later (the "GPL"),
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
@ -35,16 +36,12 @@
*
* ***** END LICENSE BLOCK ***** */
// Force references to all of the symbols that we want exported from
// the dll that are located in the .lib files we link with
#ifndef __nsXULListboxAccessibleWrap_h__
#define __nsXULListboxAccessibleWrap_h__
#include "nsFileSpec.h"
#include "NSReg.h"
#include "nsXULListboxAccessible.h"
void XXXNeverCalled_obsolete()
{
nsFileURL(NULL);
nsFileSpec s;
typedef class nsXULListboxAccessible nsXULListboxAccessibleWrap;
typedef class nsXULListCellAccessible nsXULListCellAccessibleWrap;
NR_RegSetBufferSize(NULL, 0);
}
#endif

Просмотреть файл

@ -1,289 +0,0 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Sun Microsystems, Inc.
* Portions created by the Initial Developer are Copyright (C) 2002
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Pete Zha (pete.zha@sun.com)
* Kyle Yuan (kyle.yuan@sun.com)
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#include "nsIDOMElement.h"
#include "nsITreeSelection.h"
#include "nsITreeColumns.h"
#include "nsXULTreeAccessibleWrap.h"
// --------------------------------------------------------
// nsXULTreeAccessibleWrap Accessible
// --------------------------------------------------------
nsXULTreeGridAccessibleWrap::
nsXULTreeGridAccessibleWrap(nsIDOMNode *aDOMNode, nsIWeakReference *aShell):
nsXULTreeGridAccessible(aDOMNode, aShell)
{
}
NS_IMETHODIMP
nsXULTreeGridAccessibleWrap::GetColumnHeader(nsIAccessibleTable **aColumnHeader)
{
nsresult rv = NS_OK;
nsCOMPtr<nsIAccessible> acc;
nsAccessible::GetFirstChild(getter_AddRefs(acc));
NS_ENSURE_TRUE(acc, NS_ERROR_FAILURE);
nsCOMPtr<nsIAccessibleTable> accTable(do_QueryInterface(acc, &rv));
NS_ENSURE_SUCCESS(rv, rv);
*aColumnHeader = accTable;
NS_IF_ADDREF(*aColumnHeader);
return rv;
}
NS_IMETHODIMP
nsXULTreeGridAccessibleWrap::GetColumnDescription(PRInt32 aColumn, nsAString & _retval)
{
nsCOMPtr<nsIAccessibleTable> columnHeader;
nsresult rv = GetColumnHeader(getter_AddRefs(columnHeader));
if (NS_SUCCEEDED(rv) && columnHeader) {
return columnHeader->GetColumnDescription(aColumn, _retval);
}
return NS_ERROR_FAILURE;
}
// --------------------------------------------------------
// nsXULTreeColumnsAccessibleWrap Accessible
// --------------------------------------------------------
NS_IMPL_ISUPPORTS_INHERITED1(nsXULTreeColumnsAccessibleWrap, nsXULTreeColumnsAccessible, nsIAccessibleTable)
nsXULTreeColumnsAccessibleWrap::nsXULTreeColumnsAccessibleWrap(nsIDOMNode *aDOMNode, nsIWeakReference *aShell):
nsXULTreeColumnsAccessible(aDOMNode, aShell)
{
}
NS_IMETHODIMP nsXULTreeColumnsAccessibleWrap::GetCaption(nsIAccessible **aCaption)
{
*aCaption = nsnull;
return NS_OK;
}
NS_IMETHODIMP nsXULTreeColumnsAccessibleWrap::GetSummary(nsAString &aSummary)
{
aSummary.Truncate();
return NS_OK;
}
NS_IMETHODIMP nsXULTreeColumnsAccessibleWrap::GetColumns(PRInt32 *aColumns)
{
nsresult rv = GetChildCount(aColumns);
return *aColumns > 0 ? rv : NS_ERROR_FAILURE;
}
NS_IMETHODIMP nsXULTreeColumnsAccessibleWrap::GetColumnHeader(nsIAccessibleTable * *aColumnHeader)
{
// Column header not supported.
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP nsXULTreeColumnsAccessibleWrap::GetRows(PRInt32 *aRows)
{
NS_ENSURE_ARG_POINTER(aRows);
*aRows = 1;
return NS_OK;
}
NS_IMETHODIMP nsXULTreeColumnsAccessibleWrap::GetRowHeader(nsIAccessibleTable * *aRowHeader)
{
// Row header not supported.
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP
nsXULTreeColumnsAccessibleWrap::GetSelectedCellsCount(PRUint32* aCount)
{
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP
nsXULTreeColumnsAccessibleWrap::GetSelectedColumnsCount(PRUint32* aCount)
{
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP
nsXULTreeColumnsAccessibleWrap::GetSelectedRowsCount(PRUint32* aCount)
{
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP
nsXULTreeColumnsAccessibleWrap::GetSelectedCells(PRUint32 *aNumCells,
PRInt32 **aCells)
{
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP nsXULTreeColumnsAccessibleWrap::GetSelectedColumns(PRUint32 *columnsSize, PRInt32 **columns)
{
// Header can not be selected.
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP nsXULTreeColumnsAccessibleWrap::GetSelectedRows(PRUint32 *rowsSize, PRInt32 **rows)
{
// Header can not be selected.
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP nsXULTreeColumnsAccessibleWrap::CellRefAt(PRInt32 aRow, PRInt32 aColumn, nsIAccessible **_retval)
{
nsCOMPtr<nsIAccessible> next, temp;
GetFirstChild(getter_AddRefs(next));
NS_ENSURE_TRUE(next, NS_ERROR_FAILURE);
for (PRInt32 col = 0; col < aColumn; col++) {
next->GetNextSibling(getter_AddRefs(temp));
NS_ENSURE_TRUE(temp, NS_ERROR_FAILURE);
next = temp;
}
*_retval = next;
NS_IF_ADDREF(*_retval);
return NS_OK;
}
NS_IMETHODIMP nsXULTreeColumnsAccessibleWrap::GetIndexAt(PRInt32 aRow, PRInt32 aColumn, PRInt32 *_retval)
{
NS_ENSURE_ARG_POINTER(_retval);
*_retval = aColumn;
return NS_OK;
}
NS_IMETHODIMP nsXULTreeColumnsAccessibleWrap::GetColumnAtIndex(PRInt32 aIndex, PRInt32 *_retval)
{
NS_ENSURE_ARG_POINTER(_retval);
*_retval = aIndex;
return NS_OK;
}
NS_IMETHODIMP nsXULTreeColumnsAccessibleWrap::GetRowAtIndex(PRInt32 aIndex, PRInt32 *_retval)
{
NS_ENSURE_ARG_POINTER(_retval);
*_retval = 0;
return NS_OK;
}
NS_IMETHODIMP nsXULTreeColumnsAccessibleWrap::GetColumnExtentAt(PRInt32 aRow, PRInt32 aColumn, PRInt32 *_retval)
{
NS_ENSURE_ARG_POINTER(_retval);
*_retval = 1;
return NS_OK;
}
NS_IMETHODIMP nsXULTreeColumnsAccessibleWrap::GetRowExtentAt(PRInt32 aRow, PRInt32 aColumn, PRInt32 *_retval)
{
NS_ENSURE_ARG_POINTER(_retval);
*_retval = 1;
return NS_OK;
}
NS_IMETHODIMP nsXULTreeColumnsAccessibleWrap::GetColumnDescription(PRInt32 aColumn, nsAString & _retval)
{
nsCOMPtr<nsIAccessible> column;
nsresult rv = CellRefAt(0, aColumn, getter_AddRefs(column));
if (NS_SUCCEEDED(rv) && column) {
return column->GetName(_retval);
}
return NS_ERROR_FAILURE;
}
NS_IMETHODIMP nsXULTreeColumnsAccessibleWrap::GetRowDescription(PRInt32 aRow, nsAString & _retval)
{
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP nsXULTreeColumnsAccessibleWrap::IsColumnSelected(PRInt32 aColumn, PRBool *_retval)
{
// Header can not be selected.
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP nsXULTreeColumnsAccessibleWrap::IsRowSelected(PRInt32 aRow, PRBool *_retval)
{
// Header can not be selected.
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP nsXULTreeColumnsAccessibleWrap::IsCellSelected(PRInt32 aRow, PRInt32 aColumn, PRBool *_retval)
{
// Header can not be selected.
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP
nsXULTreeColumnsAccessibleWrap::SelectRow(PRInt32 aRow)
{
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP
nsXULTreeColumnsAccessibleWrap::SelectColumn(PRInt32 aColumn)
{
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP
nsXULTreeColumnsAccessibleWrap::UnselectRow(PRInt32 aRow)
{
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP
nsXULTreeColumnsAccessibleWrap::UnselectColumn(PRInt32 aColumn)
{
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP nsXULTreeColumnsAccessibleWrap::IsProbablyForLayout(PRBool *aIsProbablyForLayout)
{
*aIsProbablyForLayout = PR_FALSE;
return NS_OK;
}

Просмотреть файл

@ -0,0 +1,49 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Sun Microsystems, Inc.
* Portions created by the Initial Developer are Copyright (C) 2002
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Pete Zha (pete.zha@sun.com)
* Kyle Yuan (kyle.yuan@sun.com)
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#ifndef __nsXULTreeGridAccessibleWrap_h__
#define __nsXULTreeGridAccessibleWrap_h__
#include "nsXULTreeGridAccessible.h"
typedef class nsXULTreeGridAccessible nsXULTreeGridAccessibleWrap;
typedef class nsXULTreeGridCellAccessible nsXULTreeGridCellAccessibleWrap;
#endif

Просмотреть файл

@ -38,6 +38,7 @@
#include "nsARIAGridAccessible.h"
#include "nsComponentManagerUtils.h"
////////////////////////////////////////////////////////////////////////////////
// nsARIAGridAccessible
@ -89,10 +90,10 @@ nsARIAGridAccessible::GetSummary(nsAString &aSummary)
}
NS_IMETHODIMP
nsARIAGridAccessible::GetColumns(PRInt32 *aColumns)
nsARIAGridAccessible::GetColumnCount(PRInt32 *acolumnCount)
{
NS_ENSURE_ARG_POINTER(aColumns);
*aColumns = 0;
NS_ENSURE_ARG_POINTER(acolumnCount);
*acolumnCount = 0;
if (IsDefunct())
return NS_ERROR_FAILURE;
@ -100,55 +101,29 @@ nsARIAGridAccessible::GetColumns(PRInt32 *aColumns)
nsCOMPtr<nsIAccessible> row = GetNextRow();
nsCOMPtr<nsIAccessible> cell;
while ((cell = GetNextCellInRow(row, cell)))
(*aColumns)++;
(*acolumnCount)++;
return NS_OK;
}
NS_IMETHODIMP
nsARIAGridAccessible::GetColumnHeader(nsIAccessibleTable **aColumnHeader)
nsARIAGridAccessible::GetRowCount(PRInt32 *arowCount)
{
NS_ENSURE_ARG_POINTER(aColumnHeader);
*aColumnHeader = nsnull;
if (IsDefunct())
return NS_ERROR_FAILURE;
// XXX: what should we return here?
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP
nsARIAGridAccessible::GetRows(PRInt32 *aRows)
{
NS_ENSURE_ARG_POINTER(aRows);
*aRows = 0;
NS_ENSURE_ARG_POINTER(arowCount);
*arowCount = 0;
if (IsDefunct())
return NS_ERROR_FAILURE;
nsCOMPtr<nsIAccessible> row;
while ((row = GetNextRow(row)))
(*aRows)++;
(*arowCount)++;
return NS_OK;
}
NS_IMETHODIMP
nsARIAGridAccessible::GetRowHeader(nsIAccessibleTable **aRowHeader)
{
NS_ENSURE_ARG_POINTER(aRowHeader);
*aRowHeader = nsnull;
if (IsDefunct())
return NS_ERROR_FAILURE;
// XXX: what should we return here?
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP
nsARIAGridAccessible::CellRefAt(PRInt32 aRow, PRInt32 aColumn,
nsARIAGridAccessible::GetCellAt(PRInt32 aRowIndex, PRInt32 aColumnIndex,
nsIAccessible **aAccessible)
{
NS_ENSURE_ARG_POINTER(aAccessible);
@ -157,10 +132,10 @@ nsARIAGridAccessible::CellRefAt(PRInt32 aRow, PRInt32 aColumn,
if (IsDefunct())
return NS_ERROR_FAILURE;
nsCOMPtr<nsIAccessible> row = GetRowAt(aRow);
nsCOMPtr<nsIAccessible> row = GetRowAt(aRowIndex);
NS_ENSURE_ARG(row);
nsCOMPtr<nsIAccessible> cell = GetCellInRowAt(row, aColumn);
nsCOMPtr<nsIAccessible> cell = GetCellInRowAt(row, aColumnIndex);
NS_ENSURE_ARG(cell);
NS_ADDREF(*aAccessible = cell);
@ -168,71 +143,73 @@ nsARIAGridAccessible::CellRefAt(PRInt32 aRow, PRInt32 aColumn,
}
NS_IMETHODIMP
nsARIAGridAccessible::GetIndexAt(PRInt32 aRow, PRInt32 aColumn, PRInt32 *aIndex)
nsARIAGridAccessible::GetCellIndexAt(PRInt32 aRowIndex, PRInt32 aColumnIndex,
PRInt32 *aCellIndex)
{
NS_ENSURE_ARG_POINTER(aIndex);
*aIndex = -1;
NS_ENSURE_ARG_POINTER(aCellIndex);
*aCellIndex = -1;
if (IsDefunct())
return NS_ERROR_FAILURE;
NS_ENSURE_ARG(aRow >= 0 && aColumn >= 0);
NS_ENSURE_ARG(aRowIndex >= 0 && aColumnIndex >= 0);
PRInt32 rowCount = 0;
GetRows(&rowCount);
NS_ENSURE_ARG(aRow < rowCount);
GetRowCount(&rowCount);
NS_ENSURE_ARG(aRowIndex < rowCount);
PRInt32 colCount = 0;
GetColumns(&colCount);
NS_ENSURE_ARG(aColumn < colCount);
PRInt32 colsCount = 0;
GetColumnCount(&colsCount);
NS_ENSURE_ARG(aColumnIndex < colsCount);
*aIndex = colCount * aRow + aColumn;
*aCellIndex = colsCount * aRowIndex + aColumnIndex;
return NS_OK;
}
NS_IMETHODIMP
nsARIAGridAccessible::GetColumnAtIndex(PRInt32 aIndex, PRInt32 *aColumn)
nsARIAGridAccessible::GetColumnIndexAt(PRInt32 aCellIndex,
PRInt32 *aColumnIndex)
{
NS_ENSURE_ARG_POINTER(aColumn);
*aColumn = -1;
NS_ENSURE_ARG_POINTER(aColumnIndex);
*aColumnIndex = -1;
if (IsDefunct())
return NS_ERROR_FAILURE;
NS_ENSURE_ARG(aIndex >= 0);
NS_ENSURE_ARG(aCellIndex >= 0);
PRInt32 rowCount = 0;
GetRows(&rowCount);
PRInt32 colCount = 0;
GetColumns(&colCount);
GetRowCount(&rowCount);
NS_ENSURE_ARG(aIndex < rowCount * colCount);
PRInt32 colsCount = 0;
GetColumnCount(&colsCount);
*aColumn = aIndex % colCount;
NS_ENSURE_ARG(aCellIndex < rowCount * colsCount);
*aColumnIndex = aCellIndex % colsCount;
return NS_OK;
}
NS_IMETHODIMP
nsARIAGridAccessible::GetRowAtIndex(PRInt32 aIndex, PRInt32 *aRow)
nsARIAGridAccessible::GetRowIndexAt(PRInt32 aCellIndex, PRInt32 *aRowIndex)
{
NS_ENSURE_ARG_POINTER(aRow);
*aRow = -1;
NS_ENSURE_ARG_POINTER(aRowIndex);
*aRowIndex = -1;
if (IsDefunct())
return NS_ERROR_FAILURE;
NS_ENSURE_ARG(aIndex >= 0);
NS_ENSURE_ARG(aCellIndex >= 0);
PRInt32 rowCount = 0;
GetRows(&rowCount);
GetRowCount(&rowCount);
PRInt32 colCount = 0;
GetColumns(&colCount);
PRInt32 colsCount = 0;
GetColumnCount(&colsCount);
NS_ENSURE_ARG(aIndex < rowCount * colCount);
NS_ENSURE_ARG(aCellIndex < rowCount * colsCount);
*aRow = aIndex / colCount;
*aRowIndex = aCellIndex / colsCount;
return NS_OK;
}
@ -313,12 +290,12 @@ nsARIAGridAccessible::IsColumnSelected(PRInt32 aColumn, PRBool *aIsSelected)
return NS_OK;
do {
if (!IsARIASelected(row)) {
if (!nsAccUtils::IsARIASelected(row)) {
nsCOMPtr<nsIAccessible> cell = GetCellInRowAt(row, aColumn);
if (!cell) // Do not fail due to wrong markup
return NS_OK;
if (!IsARIASelected(cell))
if (!nsAccUtils::IsARIASelected(cell))
return NS_OK;
}
} while ((row = GetNextRow(row)));
@ -339,10 +316,10 @@ nsARIAGridAccessible::IsRowSelected(PRInt32 aRow, PRBool *aIsSelected)
nsCOMPtr<nsIAccessible> row = GetRowAt(aRow);
NS_ENSURE_ARG(row);
if (!IsARIASelected(row)) {
if (!nsAccUtils::IsARIASelected(row)) {
nsCOMPtr<nsIAccessible> cell;
while ((cell = GetNextCellInRow(row, cell))) {
if (!IsARIASelected(cell))
if (!nsAccUtils::IsARIASelected(cell))
return NS_OK;
}
}
@ -364,11 +341,11 @@ nsARIAGridAccessible::IsCellSelected(PRInt32 aRow, PRInt32 aColumn,
nsCOMPtr<nsIAccessible> row(GetRowAt(aRow));
NS_ENSURE_ARG(row);
if (!IsARIASelected(row)) {
if (!nsAccUtils::IsARIASelected(row)) {
nsCOMPtr<nsIAccessible> cell(GetCellInRowAt(row, aColumn));
NS_ENSURE_ARG(cell);
if (!IsARIASelected(cell))
if (!nsAccUtils::IsARIASelected(cell))
return NS_OK;
}
@ -377,7 +354,7 @@ nsARIAGridAccessible::IsCellSelected(PRInt32 aRow, PRInt32 aColumn,
}
NS_IMETHODIMP
nsARIAGridAccessible::GetSelectedCellsCount(PRUint32* aCount)
nsARIAGridAccessible::GetSelectedCellCount(PRUint32* aCount)
{
NS_ENSURE_ARG_POINTER(aCount);
*aCount = 0;
@ -386,18 +363,18 @@ nsARIAGridAccessible::GetSelectedCellsCount(PRUint32* aCount)
return NS_ERROR_FAILURE;
PRInt32 colCount = 0;
GetColumns(&colCount);
GetColumnCount(&colCount);
nsCOMPtr<nsIAccessible> row;
while ((row = GetNextRow(row))) {
if (IsARIASelected(row)) {
if (nsAccUtils::IsARIASelected(row)) {
(*aCount) += colCount;
continue;
}
nsCOMPtr<nsIAccessible> cell;
while ((cell = GetNextCellInRow(row, cell))) {
if (IsARIASelected(cell))
if (nsAccUtils::IsARIASelected(cell))
(*aCount)++;
}
}
@ -406,13 +383,13 @@ nsARIAGridAccessible::GetSelectedCellsCount(PRUint32* aCount)
}
NS_IMETHODIMP
nsARIAGridAccessible::GetSelectedColumnsCount(PRUint32* aCount)
nsARIAGridAccessible::GetSelectedColumnCount(PRUint32* aCount)
{
return GetSelectedColumnsArray(aCount);
}
NS_IMETHODIMP
nsARIAGridAccessible::GetSelectedRowsCount(PRUint32* aCount)
nsARIAGridAccessible::GetSelectedRowCount(PRUint32* aCount)
{
NS_ENSURE_ARG_POINTER(aCount);
*aCount = 0;
@ -422,7 +399,7 @@ nsARIAGridAccessible::GetSelectedRowsCount(PRUint32* aCount)
nsCOMPtr<nsIAccessible> row;
while ((row = GetNextRow(row))) {
if (IsARIASelected(row)) {
if (nsAccUtils::IsARIASelected(row)) {
(*aCount)++;
continue;
}
@ -433,7 +410,7 @@ nsARIAGridAccessible::GetSelectedRowsCount(PRUint32* aCount)
PRBool isRowSelected = PR_TRUE;
do {
if (!IsARIASelected(cell)) {
if (!nsAccUtils::IsARIASelected(cell)) {
isRowSelected = PR_FALSE;
break;
}
@ -447,7 +424,43 @@ nsARIAGridAccessible::GetSelectedRowsCount(PRUint32* aCount)
}
NS_IMETHODIMP
nsARIAGridAccessible::GetSelectedCells(PRUint32 *aCellsCount, PRInt32 **aCells)
nsARIAGridAccessible::GetSelectedCells(nsIArray **aCells)
{
NS_ENSURE_ARG_POINTER(aCells);
*aCells = nsnull;
if (IsDefunct())
return NS_ERROR_FAILURE;
nsresult rv = NS_OK;
nsCOMPtr<nsIMutableArray> selCells =
do_CreateInstance(NS_ARRAY_CONTRACTID, &rv);
NS_ENSURE_SUCCESS(rv, rv);
nsCOMPtr<nsIAccessible> row;
while (row = GetNextRow(row)) {
if (nsAccUtils::IsARIASelected(row)) {
nsCOMPtr<nsIAccessible> cell;
while (cell = GetNextCellInRow(row, cell))
selCells->AppendElement(cell, PR_FALSE);
continue;
}
nsCOMPtr<nsIAccessible> cell;
while (cell = GetNextCellInRow(row, cell)) {
if (nsAccUtils::IsARIASelected(cell))
selCells->AppendElement(cell, PR_FALSE);
}
}
NS_ADDREF(*aCells = selCells);
return NS_OK;
}
NS_IMETHODIMP
nsARIAGridAccessible::GetSelectedCellIndices(PRUint32 *aCellsCount,
PRInt32 **aCells)
{
NS_ENSURE_ARG_POINTER(aCellsCount);
*aCellsCount = 0;
@ -458,16 +471,16 @@ nsARIAGridAccessible::GetSelectedCells(PRUint32 *aCellsCount, PRInt32 **aCells)
return NS_ERROR_FAILURE;
PRInt32 rowCount = 0;
GetRows(&rowCount);
GetRowCount(&rowCount);
PRInt32 colCount = 0;
GetColumns(&colCount);
GetColumnCount(&colCount);
nsTArray<PRInt32> selCells(rowCount * colCount);
nsCOMPtr<nsIAccessible> row;
for (PRInt32 rowIdx = 0; row = GetNextRow(row); rowIdx++) {
if (IsARIASelected(row)) {
if (nsAccUtils::IsARIASelected(row)) {
for (PRInt32 colIdx = 0; colIdx < colCount; colIdx++)
selCells.AppendElement(rowIdx * colCount + colIdx);
@ -476,7 +489,7 @@ nsARIAGridAccessible::GetSelectedCells(PRUint32 *aCellsCount, PRInt32 **aCells)
nsCOMPtr<nsIAccessible> cell;
for (PRInt32 colIdx = 0; cell = GetNextCellInRow(row, cell); colIdx++) {
if (IsARIASelected(cell))
if (nsAccUtils::IsARIASelected(cell))
selCells.AppendElement(rowIdx * colCount + colIdx);
}
}
@ -494,19 +507,20 @@ nsARIAGridAccessible::GetSelectedCells(PRUint32 *aCellsCount, PRInt32 **aCells)
}
NS_IMETHODIMP
nsARIAGridAccessible::GetSelectedColumns(PRUint32 *aColumnsCount,
PRInt32 **aColumns)
nsARIAGridAccessible::GetSelectedColumnIndices(PRUint32 *acolumnCount,
PRInt32 **aColumns)
{
NS_ENSURE_ARG_POINTER(aColumns);
return GetSelectedColumnsArray(aColumnsCount, aColumns);
return GetSelectedColumnsArray(acolumnCount, aColumns);
}
NS_IMETHODIMP
nsARIAGridAccessible::GetSelectedRows(PRUint32 *aRowsCount, PRInt32 **aRows)
nsARIAGridAccessible::GetSelectedRowIndices(PRUint32 *arowCount,
PRInt32 **aRows)
{
NS_ENSURE_ARG_POINTER(aRowsCount);
*aRowsCount = 0;
NS_ENSURE_ARG_POINTER(arowCount);
*arowCount = 0;
NS_ENSURE_ARG_POINTER(aRows);
*aRows = nsnull;
@ -514,7 +528,7 @@ nsARIAGridAccessible::GetSelectedRows(PRUint32 *aRowsCount, PRInt32 **aRows)
return NS_ERROR_FAILURE;
PRInt32 rowCount = 0;
GetRows(&rowCount);
GetRowCount(&rowCount);
if (!rowCount)
return NS_OK;
@ -522,7 +536,7 @@ nsARIAGridAccessible::GetSelectedRows(PRUint32 *aRowsCount, PRInt32 **aRows)
nsCOMPtr<nsIAccessible> row;
for (PRInt32 rowIdx = 0; row = GetNextRow(row); rowIdx++) {
if (IsARIASelected(row)) {
if (nsAccUtils::IsARIASelected(row)) {
selRows.AppendElement(rowIdx);
continue;
}
@ -533,7 +547,7 @@ nsARIAGridAccessible::GetSelectedRows(PRUint32 *aRowsCount, PRInt32 **aRows)
PRBool isRowSelected = PR_TRUE;
do {
if (!IsARIASelected(cell)) {
if (!nsAccUtils::IsARIASelected(cell)) {
isRowSelected = PR_FALSE;
break;
}
@ -543,15 +557,15 @@ nsARIAGridAccessible::GetSelectedRows(PRUint32 *aRowsCount, PRInt32 **aRows)
selRows.AppendElement(rowIdx);
}
PRUint32 selRowsCount = selRows.Length();
if (!selRowsCount)
PRUint32 selrowCount = selRows.Length();
if (!selrowCount)
return NS_OK;
*aRows = static_cast<PRInt32*>(
nsMemory::Clone(selRows.Elements(), selRowsCount * sizeof(PRInt32)));
nsMemory::Clone(selRows.Elements(), selrowCount * sizeof(PRInt32)));
NS_ENSURE_TRUE(*aRows, NS_ERROR_OUT_OF_MEMORY);
*aRowsCount = selRowsCount;
*arowCount = selrowCount;
return NS_OK;
}
@ -648,7 +662,7 @@ nsARIAGridAccessible::IsValidRow(PRInt32 aRow)
return PR_FALSE;
PRInt32 rowCount = 0;
GetRows(&rowCount);
GetRowCount(&rowCount);
return aRow < rowCount;
}
@ -659,7 +673,7 @@ nsARIAGridAccessible::IsValidColumn(PRInt32 aColumn)
return PR_FALSE;
PRInt32 colCount = 0;
GetColumns(&colCount);
GetColumnCount(&colCount);
return aColumn < colCount;
}
@ -670,12 +684,12 @@ nsARIAGridAccessible::IsValidRowNColumn(PRInt32 aRow, PRInt32 aColumn)
return PR_FALSE;
PRInt32 rowCount = 0;
GetRows(&rowCount);
GetRowCount(&rowCount);
if (aRow >= rowCount)
return PR_FALSE;
PRInt32 colCount = 0;
GetColumns(&colCount);
GetColumnCount(&colCount);
return aColumn < colCount;
}
@ -747,25 +761,6 @@ nsARIAGridAccessible::GetNextCellInRow(nsIAccessible *aRow, nsIAccessible *aCell
return nsnull;
}
PRBool
nsARIAGridAccessible::IsARIASelected(nsIAccessible *aAccessible)
{
nsRefPtr<nsAccessible> acc = nsAccUtils::QueryAccessible(aAccessible);
nsCOMPtr<nsIDOMNode> node;
acc->GetDOMNode(getter_AddRefs(node));
NS_ASSERTION(node, "No DOM node!");
if (node) {
nsCOMPtr<nsIContent> content(do_QueryInterface(node));
if (content->AttrValueIs(kNameSpaceID_None,
nsAccessibilityAtoms::aria_selected,
nsAccessibilityAtoms::_true, eCaseMatters))
return PR_TRUE;
}
return PR_FALSE;
}
nsresult
nsARIAGridAccessible::SetARIASelected(nsIAccessible *aAccessible,
PRBool aIsSelected, PRBool aNotify)
@ -820,7 +815,7 @@ nsARIAGridAccessible::SetARIASelected(nsIAccessible *aAccessible,
aAccessible->GetParent(getter_AddRefs(row));
if (nsAccUtils::Role(row) == nsIAccessibleRole::ROLE_ROW &&
IsARIASelected(row)) {
nsAccUtils::IsARIASelected(row)) {
rv = SetARIASelected(row, PR_FALSE, PR_FALSE);
NS_ENSURE_SUCCESS(rv, rv);
@ -838,11 +833,11 @@ nsARIAGridAccessible::SetARIASelected(nsIAccessible *aAccessible,
}
nsresult
nsARIAGridAccessible::GetSelectedColumnsArray(PRUint32 *aColumnsCount,
nsARIAGridAccessible::GetSelectedColumnsArray(PRUint32 *acolumnCount,
PRInt32 **aColumns)
{
NS_ENSURE_ARG_POINTER(aColumnsCount);
*aColumnsCount = 0;
NS_ENSURE_ARG_POINTER(acolumnCount);
*acolumnCount = 0;
if (aColumns)
*aColumns = nsnull;
@ -854,7 +849,7 @@ nsARIAGridAccessible::GetSelectedColumnsArray(PRUint32 *aColumnsCount,
return NS_OK;
PRInt32 colCount = 0;
GetColumns(&colCount);
GetColumnCount(&colCount);
if (!colCount)
return NS_OK;
@ -866,14 +861,14 @@ nsARIAGridAccessible::GetSelectedColumnsArray(PRUint32 *aColumnsCount,
isColSelArray[i] = PR_TRUE;
do {
if (IsARIASelected(row))
if (nsAccUtils::IsARIASelected(row))
continue;
PRInt32 colIdx = 0;
nsCOMPtr<nsIAccessible> cell;
for (colIdx = 0; cell = GetNextCellInRow(row, cell); colIdx++) {
if (isColSelArray.SafeElementAt(colIdx, PR_FALSE) &&
!IsARIASelected(cell)) {
!nsAccUtils::IsARIASelected(cell)) {
isColSelArray[colIdx] = PR_FALSE;
selColCount--;
}
@ -884,7 +879,7 @@ nsARIAGridAccessible::GetSelectedColumnsArray(PRUint32 *aColumnsCount,
return NS_OK;
if (!aColumns) {
*aColumnsCount = selColCount;
*acolumnCount = selColCount;
return NS_OK;
}
@ -892,7 +887,7 @@ nsARIAGridAccessible::GetSelectedColumnsArray(PRUint32 *aColumnsCount,
nsMemory::Alloc(selColCount * sizeof(PRInt32)));
NS_ENSURE_TRUE(*aColumns, NS_ERROR_OUT_OF_MEMORY);
*aColumnsCount = selColCount;
*acolumnCount = selColCount;
for (PRInt32 colIdx = 0, idx = 0; colIdx < colCount; colIdx++) {
if (isColSelArray[colIdx])
(*aColumns)[idx++] = colIdx;
@ -919,8 +914,169 @@ nsARIAGridCellAccessible::nsARIAGridCellAccessible(nsIDOMNode* aDomNode,
////////////////////////////////////////////////////////////////////////////////
// nsISupports
NS_IMPL_ISUPPORTS_INHERITED0(nsARIAGridCellAccessible,
nsHyperTextAccessible)
NS_IMPL_ISUPPORTS_INHERITED1(nsARIAGridCellAccessible,
nsHyperTextAccessible,
nsIAccessibleTableCell)
////////////////////////////////////////////////////////////////////////////////
// nsIAccessibleTableCell
NS_IMETHODIMP
nsARIAGridCellAccessible::GetTable(nsIAccessibleTable **aTable)
{
NS_ENSURE_ARG_POINTER(aTable);
*aTable = nsnull;
nsCOMPtr<nsIAccessible> thisRow;
GetParent(getter_AddRefs(thisRow));
if (nsAccUtils::Role(thisRow) != nsIAccessibleRole::ROLE_ROW)
return NS_OK;
nsCOMPtr<nsIAccessible> table;
thisRow->GetParent(getter_AddRefs(table));
if (nsAccUtils::Role(table) != nsIAccessibleRole::ROLE_TABLE &&
nsAccUtils::Role(table) != nsIAccessibleRole::ROLE_TREE_TABLE)
return NS_OK;
CallQueryInterface(table, aTable);
return NS_OK;
}
NS_IMETHODIMP
nsARIAGridCellAccessible::GetColumnIndex(PRInt32 *aColumnIndex)
{
NS_ENSURE_ARG_POINTER(aColumnIndex);
*aColumnIndex = -1;
if (IsDefunct())
return NS_ERROR_FAILURE;
*aColumnIndex = 0;
nsCOMPtr<nsIAccessible> prevCell, tmpAcc;
GetPreviousSibling(getter_AddRefs(prevCell));
while (prevCell) {
PRUint32 role = nsAccUtils::Role(prevCell);
if (role == nsIAccessibleRole::ROLE_GRID_CELL ||
role == nsIAccessibleRole::ROLE_ROWHEADER ||
role == nsIAccessibleRole::ROLE_COLUMNHEADER)
(*aColumnIndex)++;
prevCell->GetPreviousSibling(getter_AddRefs(tmpAcc));
tmpAcc.swap(prevCell);
}
return NS_OK;
}
NS_IMETHODIMP
nsARIAGridCellAccessible::GetRowIndex(PRInt32 *aRowIndex)
{
NS_ENSURE_ARG_POINTER(aRowIndex);
*aRowIndex = -1;
if (IsDefunct())
return NS_ERROR_FAILURE;
nsCOMPtr<nsIAccessible> row, prevRow;
GetParent(getter_AddRefs(row));
while (row) {
if (nsAccUtils::Role(row) == nsIAccessibleRole::ROLE_ROW)
(*aRowIndex)++;
row->GetPreviousSibling(getter_AddRefs(prevRow));
row.swap(prevRow);
}
return NS_OK;
}
NS_IMETHODIMP
nsARIAGridCellAccessible::GetColumnExtent(PRInt32 *aExtentCount)
{
NS_ENSURE_ARG_POINTER(aExtentCount);
*aExtentCount = 0;
if (IsDefunct())
return NS_ERROR_FAILURE;
*aExtentCount = 1;
return NS_OK;
}
NS_IMETHODIMP
nsARIAGridCellAccessible::GetRowExtent(PRInt32 *aExtentCount)
{
NS_ENSURE_ARG_POINTER(aExtentCount);
*aExtentCount = 0;
if (IsDefunct())
return NS_ERROR_FAILURE;
*aExtentCount = 1;
return NS_OK;
}
NS_IMETHODIMP
nsARIAGridCellAccessible::GetColumnHeaderCells(nsIArray **aHeaderCells)
{
NS_ENSURE_ARG_POINTER(aHeaderCells);
*aHeaderCells = nsnull;
if (IsDefunct())
return NS_ERROR_FAILURE;
nsCOMPtr<nsIAccessibleTable> table;
GetTable(getter_AddRefs(table));
if (!table)
return NS_OK;
return nsAccUtils::GetHeaderCellsFor(table, this,
nsAccUtils::eColumnHeaderCells,
aHeaderCells);
}
NS_IMETHODIMP
nsARIAGridCellAccessible::GetRowHeaderCells(nsIArray **aHeaderCells)
{
NS_ENSURE_ARG_POINTER(aHeaderCells);
*aHeaderCells = nsnull;
if (IsDefunct())
return NS_ERROR_FAILURE;
nsCOMPtr<nsIAccessibleTable> table;
GetTable(getter_AddRefs(table));
if (!table)
return NS_OK;
return nsAccUtils::GetHeaderCellsFor(table, this,
nsAccUtils::eRowHeaderCells,
aHeaderCells);
}
NS_IMETHODIMP
nsARIAGridCellAccessible::IsSelected(PRBool *aIsSelected)
{
NS_ENSURE_ARG_POINTER(aIsSelected);
*aIsSelected = PR_FALSE;
if (IsDefunct())
return NS_ERROR_FAILURE;
nsCOMPtr<nsIAccessible> row;
GetParent(getter_AddRefs(row));
if (nsAccUtils::Role(row) != nsIAccessibleRole::ROLE_ROW)
return NS_OK;
if (!nsAccUtils::IsARIASelected(row) && !nsAccUtils::IsARIASelected(this))
return NS_OK;
*aIsSelected = PR_TRUE;
return NS_OK;
}
////////////////////////////////////////////////////////////////////////////////
// nsAccessible

Просмотреть файл

@ -103,12 +103,6 @@ protected:
already_AddRefed<nsIAccessible> GetNextCellInRow(nsIAccessible *aRow,
nsIAccessible *aCell = nsnull);
/**
* Return true if the DOM node of given accessible has aria-selected="true"
* attribute.
*/
PRBool IsARIASelected(nsIAccessible *aAccessible);
/**
* Set aria-selected attribute value on DOM node of the given accessible.
*
@ -121,9 +115,9 @@ protected:
PRBool aNotify = PR_TRUE);
/**
* Helper method for GetSelectedColumnsCount and GetSelectedColumns.
* Helper method for GetSelectedColumnCount and GetSelectedColumns.
*/
nsresult GetSelectedColumnsArray(PRUint32 *aColumnsCount,
nsresult GetSelectedColumnsArray(PRUint32 *acolumnCount,
PRInt32 **aColumns = nsnull);
};
@ -131,7 +125,8 @@ protected:
/**
* Accessible for ARIA gridcell and rowheader/columnheader.
*/
class nsARIAGridCellAccessible : public nsHyperTextAccessibleWrap
class nsARIAGridCellAccessible : public nsHyperTextAccessibleWrap,
public nsIAccessibleTableCell
{
public:
nsARIAGridCellAccessible(nsIDOMNode* aDOMNode, nsIWeakReference* aShell);
@ -139,6 +134,9 @@ public:
// nsISupports
NS_DECL_ISUPPORTS_INHERITED
// nsIAccessibleTableCell
NS_DECL_NSIACCESSIBLETABLECELL
// nsAccessible
virtual nsresult GetARIAState(PRUint32 *aState, PRUint32 *aExtraState);
virtual nsresult GetAttributesInternal(nsIPersistentProperties *aAttributes);

Просмотреть файл

@ -56,6 +56,7 @@
#include "nsIDOMXULSelectCntrlEl.h"
#include "nsIDOMXULSelectCntrlItemEl.h"
#include "nsWhitespaceTokenizer.h"
#include "nsComponentManagerUtils.h"
void
nsAccUtils::GetAccAttr(nsIPersistentProperties *aAttributes,
@ -478,6 +479,25 @@ nsAccUtils::GetARIATreeItemParent(nsIAccessible *aStartTreeItem,
}
}
PRBool
nsAccUtils::IsARIASelected(nsIAccessible *aAccessible)
{
nsRefPtr<nsAccessible> acc = nsAccUtils::QueryAccessible(aAccessible);
nsCOMPtr<nsIDOMNode> node;
acc->GetDOMNode(getter_AddRefs(node));
NS_ASSERTION(node, "No DOM node!");
if (node) {
nsCOMPtr<nsIContent> content(do_QueryInterface(node));
if (content->AttrValueIs(kNameSpaceID_None,
nsAccessibilityAtoms::aria_selected,
nsAccessibilityAtoms::_true, eCaseMatters))
return PR_TRUE;
}
return PR_FALSE;
}
already_AddRefed<nsIAccessibleText>
nsAccUtils::GetTextAccessibleFromSelection(nsISelection *aSelection,
nsIDOMNode **aNode)
@ -648,7 +668,10 @@ nsAccUtils::GetRoleMapEntry(nsIDOMNode *aNode)
{
nsIContent *content = nsCoreUtils::GetRoleContent(aNode);
nsAutoString roleString;
if (!content || !content->GetAttr(kNameSpaceID_None, nsAccessibilityAtoms::role, roleString)) {
if (!content ||
!content->GetAttr(kNameSpaceID_None, nsAccessibilityAtoms::role, roleString) ||
roleString.IsEmpty()) {
// We treat role="" as if the role attribute is absent (per aria spec:8.1.1)
return nsnull;
}
@ -674,7 +697,7 @@ nsAccUtils::GetRoleMapEntry(nsIDOMNode *aNode)
}
}
// Always use some entry if there is a role string
// Always use some entry if there is a non-empty role string
// To ensure an accessible object is created
return &nsARIAMap::gLandmarkRoleMap;
}
@ -706,17 +729,19 @@ nsAccUtils::GetAttributeCharacteristics(nsIAtom* aAtom)
return 0;
}
void
PRBool
nsAccUtils::GetLiveAttrValue(PRUint32 aRule, nsAString& aValue)
{
switch (aRule) {
case eOffLiveAttr:
aValue = NS_LITERAL_STRING("off");
break;
return PR_TRUE;
case ePoliteLiveAttr:
aValue = NS_LITERAL_STRING("polite");
break;
return PR_TRUE;
}
return PR_FALSE;
}
already_AddRefed<nsAccessible>
@ -907,3 +932,58 @@ nsAccUtils::GetMultiSelectFor(nsIDOMNode *aNode)
accessible.swap(returnAccessible);
return returnAccessible;
}
nsresult
nsAccUtils::GetHeaderCellsFor(nsIAccessibleTable *aTable,
nsIAccessibleTableCell *aCell,
PRInt32 aRowOrColHeaderCells, nsIArray **aCells)
{
nsresult rv = NS_OK;
nsCOMPtr<nsIMutableArray> cells = do_CreateInstance(NS_ARRAY_CONTRACTID, &rv);
NS_ENSURE_SUCCESS(rv, rv);
PRInt32 rowIdx = -1;
rv = aCell->GetRowIndex(&rowIdx);
NS_ENSURE_SUCCESS(rv, rv);
PRInt32 colIdx = -1;
rv = aCell->GetColumnIndex(&colIdx);
NS_ENSURE_SUCCESS(rv, rv);
PRBool moveToLeft = aRowOrColHeaderCells == eRowHeaderCells;
// Move to the left or top to find row header cells or column header cells.
PRInt32 index = (moveToLeft ? colIdx : rowIdx) - 1;
for (; index >= 0; index--) {
PRInt32 curRowIdx = moveToLeft ? rowIdx : index;
PRInt32 curColIdx = moveToLeft ? index : colIdx;
nsCOMPtr<nsIAccessible> cell;
rv = aTable->GetCellAt(curRowIdx, curColIdx, getter_AddRefs(cell));
NS_ENSURE_SUCCESS(rv, rv);
nsCOMPtr<nsIAccessibleTableCell> tableCellAcc =
do_QueryInterface(cell);
PRInt32 origIdx = 1;
if (moveToLeft)
rv = tableCellAcc->GetColumnIndex(&origIdx);
else
rv = tableCellAcc->GetRowIndex(&origIdx);
NS_ENSURE_SUCCESS(rv, rv);
if (origIdx == index) {
// Append original header cells only.
PRUint32 role = Role(cell);
PRBool isHeader = moveToLeft ?
role == nsIAccessibleRole::ROLE_ROWHEADER :
role == nsIAccessibleRole::ROLE_COLUMNHEADER;
if (isHeader)
cells->AppendElement(cell, PR_FALSE);
}
}
NS_ADDREF(*aCells = cells);
return NS_OK;
}

Просмотреть файл

@ -179,6 +179,12 @@ public:
nsIContent *aStartTreeItemContent,
nsIAccessible **aTreeItemParent);
/**
* Return true if the DOM node of given accessible has aria-selected="true"
* attribute.
*/
static PRBool IsARIASelected(nsIAccessible *aAccessible);
/**
* Return text accessible containing focus point of the given selection.
* Used for normal and misspelling selection changes processing.
@ -283,10 +289,15 @@ public:
static PRUint8 GetAttributeCharacteristics(nsIAtom* aAtom);
/**
* Return the 'live' or 'container-live' object attribute value from the given
* Get the 'live' or 'container-live' object attribute value from the given
* ELiveAttrRule constant.
*
* @param aRule [in] rule constant (see ELiveAttrRule in nsAccMap.h)
* @param aValue [out] object attribute value
*
* @return true if object attribute should be exposed
*/
static void GetLiveAttrValue(PRUint32 aRule, nsAString& aValue);
static PRBool GetLiveAttrValue(PRUint32 aRule, nsAString& aValue);
/**
* Query DestinationType from the given SourceType.
@ -424,11 +435,11 @@ public:
/**
* Return true if the given accessible hasn't children.
*/
static PRBool IsLeaf(nsIAccessible *aAcc)
static inline PRBool IsLeaf(nsIAccessible *aAcc)
{
PRInt32 numChildren;
PRInt32 numChildren = 0;
aAcc->GetChildCount(&numChildren);
return numChildren > 0;
return numChildren == 0;
}
/**
@ -447,6 +458,32 @@ public:
* Return multiselectable parent for the given selectable accessible if any.
*/
static already_AddRefed<nsIAccessible> GetMultiSelectFor(nsIDOMNode *aNode);
/**
* Search hint enum constants. Used by GetHeaderCellsFor() method.
*/
enum {
// search for row header cells, left direction
eRowHeaderCells,
// search for column header cells, top direction
eColumnHeaderCells
};
/**
* Return an array of row or column header cells for the given cell.
*
* @param aTable [in] table accessible
* @param aCell [in] cell accessible within the given table to
* get header cells
* @param aRowOrColHeaderCells [in] specifies whether column or row header
* cells are returned (see enum constants
* above)
* @param aCells [out] array of header cell accessibles
*/
static nsresult GetHeaderCellsFor(nsIAccessibleTable *aTable,
nsIAccessibleTableCell *aCell,
PRInt32 aRowOrColHeaderCells,
nsIArray **aCells);
};
#endif

Просмотреть файл

@ -88,13 +88,14 @@
#ifdef MOZ_XUL
#include "nsXULAlertAccessible.h"
#include "nsXULColorPickerAccessible.h"
#include "nsXULComboboxAccessible.h"
#include "nsXULFormControlAccessible.h"
#include "nsXULListboxAccessibleWrap.h"
#include "nsXULMenuAccessibleWrap.h"
#include "nsXULSelectAccessible.h"
#include "nsXULSliderAccessible.h"
#include "nsXULTabAccessible.h"
#include "nsXULTextAccessible.h"
#include "nsXULTreeAccessibleWrap.h"
#include "nsXULTreeGridAccessibleWrap.h"
#endif
// For native window support for object/embed/applet tags
@ -567,11 +568,6 @@ nsAccessibilityService::CreateHTMLAccessibleByMarkup(nsIFrame *aFrame,
tag == nsAccessibilityAtoms::h4 ||
tag == nsAccessibilityAtoms::h5 ||
tag == nsAccessibilityAtoms::h6 ||
#ifndef MOZ_ACCESSIBILITY_ATK
tag == nsAccessibilityAtoms::tbody ||
tag == nsAccessibilityAtoms::tfoot ||
tag == nsAccessibilityAtoms::thead ||
#endif
tag == nsAccessibilityAtoms::q) {
return CreateHyperTextAccessible(aFrame, aAccessible);
}
@ -580,7 +576,7 @@ nsAccessibilityService::CreateHTMLAccessibleByMarkup(nsIFrame *aFrame,
nsIAccessibleRole::ROLE_ROW);
}
else if (nsCoreUtils::IsHTMLTableHeader(content)) {
*aAccessible = new nsHTMLTableHeaderAccessible(aNode, aWeakShell);
*aAccessible = new nsHTMLTableHeaderCellAccessibleWrap(aNode, aWeakShell);
}
NS_IF_ADDREF(*aAccessible);
@ -837,34 +833,8 @@ nsAccessibilityService::CreateHTMLTableAccessible(nsIFrame *aFrame, nsIAccessibl
}
NS_IMETHODIMP
nsAccessibilityService::CreateHTMLTableHeadAccessible(nsIDOMNode *aDOMNode, nsIAccessible **_retval)
{
#ifndef MOZ_ACCESSIBILITY_ATK
*_retval = nsnull;
return NS_ERROR_FAILURE;
#else
NS_ENSURE_ARG_POINTER(aDOMNode);
nsresult rv = NS_OK;
nsCOMPtr<nsIWeakReference> weakShell;
rv = GetShellFromNode(aDOMNode, getter_AddRefs(weakShell));
NS_ENSURE_SUCCESS(rv, rv);
nsHTMLTableHeadAccessibleWrap* accTableHead =
new nsHTMLTableHeadAccessibleWrap(aDOMNode, weakShell);
NS_ENSURE_TRUE(accTableHead, NS_ERROR_OUT_OF_MEMORY);
*_retval = static_cast<nsIAccessible *>(accTableHead);
NS_IF_ADDREF(*_retval);
return rv;
#endif
}
NS_IMETHODIMP
nsAccessibilityService::CreateHTMLTableCellAccessible(nsIFrame *aFrame, nsIAccessible **_retval)
nsAccessibilityService::CreateHTMLTableCellAccessible(nsIFrame *aFrame,
nsIAccessible **aAccessible)
{
nsCOMPtr<nsIDOMNode> node;
nsCOMPtr<nsIWeakReference> weakShell;
@ -872,11 +842,11 @@ nsAccessibilityService::CreateHTMLTableCellAccessible(nsIFrame *aFrame, nsIAcces
if (NS_FAILED(rv))
return rv;
*_retval = new nsHTMLTableCellAccessible(node, weakShell);
if (! *_retval)
*aAccessible = new nsHTMLTableCellAccessibleWrap(node, weakShell);
if (!*aAccessible)
return NS_ERROR_OUT_OF_MEMORY;
NS_ADDREF(*_retval);
NS_ADDREF(*aAccessible);
return NS_OK;
}
@ -1524,7 +1494,7 @@ NS_IMETHODIMP nsAccessibilityService::GetAccessible(nsIDOMNode *aNode,
frameType == nsAccessibilityAtoms::tableRowGroupFrame ||
frameType == nsAccessibilityAtoms::tableRowFrame;
if (!roleMapEntry && partOfHTMLTable) {
if (partOfHTMLTable) {
// Table-related frames don't get table-related roles
// unless they are inside a table, but they may still get generic
// accessibles
@ -1533,31 +1503,49 @@ NS_IMETHODIMP nsAccessibilityService::GetAccessible(nsIDOMNode *aNode,
nsIFrame *tableFrame = aPresShell->GetPrimaryFrameFor(tableContent);
if (!tableFrame)
continue;
if (tableFrame->GetType() == nsAccessibilityAtoms::tableOuterFrame) {
nsCOMPtr<nsIDOMNode> tableNode(do_QueryInterface(tableContent));
nsCOMPtr<nsIAccessible> tableAccessible;
GetAccessibleInShell(tableNode, aPresShell, getter_AddRefs(tableAccessible));
if (!tableAccessible && !content->IsFocusable()) {
GetAccessibleInShell(tableNode, aPresShell,
getter_AddRefs(tableAccessible));
if (tableAccessible) {
if (!roleMapEntry) {
PRUint32 role = nsAccUtils::Role(tableAccessible);
if (role != nsIAccessibleRole::ROLE_TABLE &&
role != nsIAccessibleRole::ROLE_TREE_TABLE) {
// No ARIA role and not in table: override role. For example,
// <table role="label"><td>content</td></table>
roleMapEntry = &nsARIAMap::gEmptyRoleMap;
}
}
break;
}
#ifdef DEBUG
nsRoleMapEntry *tableRoleMapEntry =
nsAccUtils::GetRoleMapEntry(tableNode);
NS_ASSERTION(tableRoleMapEntry &&
!nsCRT::strcmp(tableRoleMapEntry->roleString, "presentation"),
"No accessible for parent table and it didn't have role of presentation");
nsRoleMapEntry *tableRoleMapEntry =
nsAccUtils::GetRoleMapEntry(tableNode);
NS_ASSERTION(tableRoleMapEntry &&
!nsCRT::strcmp(tableRoleMapEntry->roleString, "presentation"),
"No accessible for parent table and it didn't have role of presentation");
#endif
// Table-related descendants of presentation table are also presentation
// Don't create accessibles for them unless they need to fire focus events
if (!roleMapEntry && !content->IsFocusable()) {
// Table-related descendants of presentation table are also
// presentation if they aren't focusable and have not explicit ARIA
// role (don't create accessibles for them unless they need to fire
// focus events).
return NS_OK;
}
if (tableAccessible &&
nsAccUtils::Role(tableAccessible) != nsIAccessibleRole::ROLE_TABLE) {
NS_ASSERTION(!roleMapEntry, "Should not be changing ARIA role, just overriding impl class role");
// Not in table: override role (roleMap entry was null).
roleMapEntry = &nsARIAMap::gEmptyRoleMap;
}
// otherwise create ARIA based accessible.
tryTagNameOrFrame = PR_FALSE;
break;
}
else if (tableContent->Tag() == nsAccessibilityAtoms::table) {
if (tableContent->Tag() == nsAccessibilityAtoms::table) {
// Stop before we are fooled by any additional table ancestors
// This table cell frameis part of a separate ancestor table.
tryTagNameOrFrame = PR_FALSE;
@ -1582,7 +1570,7 @@ NS_IMETHODIMP nsAccessibilityService::GetAccessible(nsIDOMNode *aNode,
} else if (roleMapEntry->role == nsIAccessibleRole::ROLE_GRID_CELL ||
roleMapEntry->role == nsIAccessibleRole::ROLE_ROWHEADER ||
roleMapEntry->role == nsIAccessibleRole::ROLE_COLUMNHEADER) {
newAcc = new nsARIAGridCellAccessible(aNode, aWeakShell);
newAcc = new nsARIAGridCellAccessibleWrap(aNode, aWeakShell);
}
}
}
@ -1828,10 +1816,10 @@ nsresult nsAccessibilityService::GetAccessibleByType(nsIDOMNode *aNode,
*aAccessible = new nsXULLinkAccessible(aNode, weakShell);
break;
case nsIAccessibleProvider::XULListbox:
*aAccessible = new nsXULListboxAccessible(aNode, weakShell);
*aAccessible = new nsXULListboxAccessibleWrap(aNode, weakShell);
break;
case nsIAccessibleProvider::XULListCell:
*aAccessible = new nsXULListCellAccessible(aNode, weakShell);
*aAccessible = new nsXULListCellAccessibleWrap(aNode, weakShell);
break;
case nsIAccessibleProvider::XULListHead:
*aAccessible = new nsXULColumnsAccessible(aNode, weakShell);
@ -1909,7 +1897,7 @@ nsresult nsAccessibilityService::GetAccessibleByType(nsIDOMNode *aNode,
case nsIAccessibleProvider::XULTree:
return GetAccessibleForXULTree(aNode, weakShell, aAccessible);
case nsIAccessibleProvider::XULTreeColumns:
*aAccessible = new nsXULTreeColumnsAccessibleWrap(aNode, weakShell);
*aAccessible = new nsXULTreeColumnsAccessible(aNode, weakShell);
break;
case nsIAccessibleProvider::XULTreeColumnItem:
*aAccessible = new nsXULColumnItemAccessible(aNode, weakShell);
@ -2042,25 +2030,27 @@ NS_IMETHODIMP nsAccessibilityService::RemoveNativeRootAccessible(nsIAccessible *
}
// Called from layout when the frame tree owned by a node changes significantly
NS_IMETHODIMP nsAccessibilityService::InvalidateSubtreeFor(nsIPresShell *aShell,
nsIContent *aChangeContent,
PRUint32 aEvent)
NS_IMETHODIMP
nsAccessibilityService::InvalidateSubtreeFor(nsIPresShell *aShell,
nsIContent *aChangeContent,
PRUint32 aChangeType)
{
NS_ASSERTION(aEvent == nsIAccessibleEvent::EVENT_ASYNCH_SIGNIFICANT_CHANGE ||
aEvent == nsIAccessibleEvent::EVENT_ASYNCH_SHOW ||
aEvent == nsIAccessibleEvent::EVENT_ASYNCH_HIDE ||
aEvent == nsIAccessibleEvent::EVENT_DOM_SIGNIFICANT_CHANGE ||
aEvent == nsIAccessibleEvent::EVENT_DOM_CREATE ||
aEvent == nsIAccessibleEvent::EVENT_DOM_DESTROY,
NS_ASSERTION(aChangeType == nsIAccessibilityService::FRAME_SIGNIFICANT_CHANGE ||
aChangeType == nsIAccessibilityService::FRAME_SHOW ||
aChangeType == nsIAccessibilityService::FRAME_HIDE ||
aChangeType == nsIAccessibilityService::NODE_SIGNIFICANT_CHANGE ||
aChangeType == nsIAccessibilityService::NODE_APPEND ||
aChangeType == nsIAccessibilityService::NODE_REMOVE,
"Incorrect aEvent passed in");
NS_ENSURE_ARG_POINTER(aShell);
nsCOMPtr<nsIAccessibleDocument> accessibleDoc =
nsAccessNode::GetDocAccessibleFor(aShell->GetDocument());
nsRefPtr<nsDocAccessible> docAcc =
nsAccUtils::QueryAccessibleDocument(accessibleDoc);
if (docAcc)
docAcc->InvalidateCacheSubtree(aChangeContent, aEvent);
docAcc->InvalidateCacheSubtree(aChangeContent, aChangeType);
return NS_OK;
}

Просмотреть файл

@ -298,12 +298,9 @@ static const char kRoleNames[][20] = {
*/
static const char kEventTypeNames[][40] = {
"unknown", //
"DOM node create", // EVENT_DOM_CREATE
"DOM node destroy", // EVENT_DOM_DESTROY
"DOM node significant change", // EVENT_DOM_SIGNIFICANT_CHANGE
"async show", // EVENT_ASYNCH_SHOW
"async hide", // EVENT_ASYNCH_HIDE
"async significant change", // EVENT_ASYNCH_SIGNIFICANT_CHANGE
"show", // EVENT_SHOW
"hide", // EVENT_HIDE
"reorder", // EVENT_REORDER
"active decendent change", // EVENT_ACTIVE_DECENDENT_CHANGED
"focus", // EVENT_FOCUS
"state change", // EVENT_STATE_CHANGE
@ -388,8 +385,7 @@ static const char kEventTypeNames[][40] = {
"hypertext links count changed", // EVENT_HYPERTEXT_NLINKS_CHANGED
"object attribute changed", // EVENT_OBJECT_ATTRIBUTE_CHANGED
"page changed", // EVENT_PAGE_CHANGED
"internal load", // EVENT_INTERNAL_LOAD
"reorder" // EVENT_REORDER
"internal load" // EVENT_INTERNAL_LOAD
};
/**

Просмотреть файл

@ -1748,8 +1748,8 @@ nsAccessible::GetAttributes(nsIPersistentProperties **aAttributes)
nsAutoString live;
nsAccUtils::GetAccAttr(attributes, nsAccessibilityAtoms::live, live);
if (live.IsEmpty()) {
nsAccUtils::GetLiveAttrValue(mRoleMapEntry->liveAttRule, live);
nsAccUtils::SetAccAttr(attributes, nsAccessibilityAtoms::live, live);
if (nsAccUtils::GetLiveAttrValue(mRoleMapEntry->liveAttRule, live))
nsAccUtils::SetAccAttr(attributes, nsAccessibilityAtoms::live, live);
}
}
@ -2030,9 +2030,12 @@ nsAccessible::GetARIAState(PRUint32 *aState, PRUint32 *aExtraState)
}
if (mRoleMapEntry) {
// Once an ARIA role is used, default to not-readonly. This can be overridden
// by aria-readonly, or if the ARIA role is mapped to readonly by default
*aState &= ~nsIAccessibleStates::STATE_READONLY;
// We only force the readonly bit off if we have a real mapping for the aria
// role. This preserves the ability for screen readers to use readonly
// (primarily on the document) as the hint for creating a virtual buffer.
if (mRoleMapEntry->role != nsIAccessibleRole::ROLE_NOTHING)
*aState &= ~nsIAccessibleStates::STATE_READONLY;
if (content->HasAttr(kNameSpaceID_None, content->GetIDAttributeName())) {
// If has a role & ID and aria-activedescendant on the container, assume focusable

Просмотреть файл

@ -77,21 +77,19 @@ NS_IMPL_CYCLE_COLLECTING_RELEASE(nsAccEvent)
// nsAccEvent. Constructors
nsAccEvent::nsAccEvent(PRUint32 aEventType, nsIAccessible *aAccessible,
PRBool aIsAsynch, EEventRule aEventRule)
: mEventType(aEventType)
, mEventRule(aEventRule)
, mAccessible(aAccessible)
PRBool aIsAsync, EEventRule aEventRule) :
mEventType(aEventType), mEventRule(aEventRule), mIsAsync(aIsAsync),
mAccessible(aAccessible)
{
CaptureIsFromUserInput(aIsAsynch);
CaptureIsFromUserInput();
}
nsAccEvent::nsAccEvent(PRUint32 aEventType, nsIDOMNode *aDOMNode,
PRBool aIsAsynch, EEventRule aEventRule)
: mEventType(aEventType)
, mEventRule(aEventRule)
, mDOMNode(aDOMNode)
PRBool aIsAsync, EEventRule aEventRule) :
mEventType(aEventType), mEventRule(aEventRule), mIsAsync(aIsAsync),
mDOMNode(aDOMNode)
{
CaptureIsFromUserInput(aIsAsynch);
CaptureIsFromUserInput();
}
void nsAccEvent::GetLastEventAttributes(nsIDOMNode *aNode,
@ -107,7 +105,8 @@ void nsAccEvent::GetLastEventAttributes(nsIDOMNode *aNode,
}
}
void nsAccEvent::CaptureIsFromUserInput(PRBool aIsAsynch)
void
nsAccEvent::CaptureIsFromUserInput()
{
nsCOMPtr<nsIDOMNode> eventNode;
GetDOMNode(getter_AddRefs(eventNode));
@ -126,7 +125,7 @@ void nsAccEvent::CaptureIsFromUserInput(PRBool aIsAsynch)
return;
}
if (!aIsAsynch) {
if (!mIsAsync) {
PrepareForEvent(eventNode);
mIsFromUserInput = gLastEventFromUserInput;
}
@ -308,97 +307,97 @@ nsAccEvent::GetAccessibleByNode()
/* static */
void
nsAccEvent::ApplyEventRules(nsCOMArray<nsIAccessibleEvent> &aEventsToFire)
nsAccEvent::ApplyEventRules(nsTArray<nsCOMPtr<nsIAccessibleEvent> > &aEventsToFire)
{
PRUint32 numQueuedEvents = aEventsToFire.Count();
for (PRInt32 tail = numQueuedEvents - 1; tail >= 0; tail --) {
nsRefPtr<nsAccEvent> tailEvent = GetAccEventPtr(aEventsToFire[tail]);
switch(tailEvent->mEventRule) {
case nsAccEvent::eCoalesceFromSameSubtree:
{
for (PRInt32 index = 0; index < tail; index ++) {
nsRefPtr<nsAccEvent> thisEvent = GetAccEventPtr(aEventsToFire[index]);
if (thisEvent->mEventType != tailEvent->mEventType)
continue; // Different type
PRUint32 numQueuedEvents = aEventsToFire.Length();
PRInt32 tail = numQueuedEvents - 1;
if (thisEvent->mEventRule == nsAccEvent::eAllowDupes ||
thisEvent->mEventRule == nsAccEvent::eDoNotEmit)
continue; // Do not need to check
nsRefPtr<nsAccEvent> tailEvent = GetAccEventPtr(aEventsToFire[tail]);
switch(tailEvent->mEventRule) {
case nsAccEvent::eCoalesceFromSameSubtree:
{
for (PRInt32 index = 0; index < tail; index ++) {
nsRefPtr<nsAccEvent> thisEvent = GetAccEventPtr(aEventsToFire[index]);
if (thisEvent->mEventType != tailEvent->mEventType)
continue; // Different type
if (thisEvent->mDOMNode == tailEvent->mDOMNode) {
if (thisEvent->mEventType == nsIAccessibleEvent::EVENT_REORDER) {
CoalesceReorderEventsFromSameSource(thisEvent, tailEvent);
continue;
}
if (thisEvent->mEventRule == nsAccEvent::eAllowDupes ||
thisEvent->mEventRule == nsAccEvent::eDoNotEmit)
continue; // Do not need to check
// Dupe
thisEvent->mEventRule = nsAccEvent::eDoNotEmit;
if (thisEvent->mDOMNode == tailEvent->mDOMNode) {
if (thisEvent->mEventType == nsIAccessibleEvent::EVENT_REORDER) {
CoalesceReorderEventsFromSameSource(thisEvent, tailEvent);
continue;
}
if (nsCoreUtils::IsAncestorOf(tailEvent->mDOMNode,
thisEvent->mDOMNode)) {
// thisDOMNode is a descendant of tailDOMNode
if (thisEvent->mEventType == nsIAccessibleEvent::EVENT_REORDER) {
CoalesceReorderEventsFromSameTree(tailEvent, thisEvent);
continue;
}
// Do not emit thisEvent, also apply this result to sibling
// nodes of thisDOMNode.
thisEvent->mEventRule = nsAccEvent::eDoNotEmit;
ApplyToSiblings(aEventsToFire, 0, index, thisEvent->mEventType,
thisEvent->mDOMNode, nsAccEvent::eDoNotEmit);
// Dupe
thisEvent->mEventRule = nsAccEvent::eDoNotEmit;
continue;
}
if (nsCoreUtils::IsAncestorOf(tailEvent->mDOMNode,
thisEvent->mDOMNode)) {
// thisDOMNode is a descendant of tailDOMNode
if (thisEvent->mEventType == nsIAccessibleEvent::EVENT_REORDER) {
CoalesceReorderEventsFromSameTree(tailEvent, thisEvent);
continue;
}
if (nsCoreUtils::IsAncestorOf(thisEvent->mDOMNode,
tailEvent->mDOMNode)) {
// tailDOMNode is a descendant of thisDOMNode
if (thisEvent->mEventType == nsIAccessibleEvent::EVENT_REORDER) {
CoalesceReorderEventsFromSameTree(thisEvent, tailEvent);
continue;
}
// Do not emit tailEvent, also apply this result to sibling
// nodes of tailDOMNode.
tailEvent->mEventRule = nsAccEvent::eDoNotEmit;
ApplyToSiblings(aEventsToFire, 0, tail, tailEvent->mEventType,
tailEvent->mDOMNode, nsAccEvent::eDoNotEmit);
break;
// Do not emit thisEvent, also apply this result to sibling
// nodes of thisDOMNode.
thisEvent->mEventRule = nsAccEvent::eDoNotEmit;
ApplyToSiblings(aEventsToFire, 0, index, thisEvent->mEventType,
thisEvent->mDOMNode, nsAccEvent::eDoNotEmit);
continue;
}
if (nsCoreUtils::IsAncestorOf(thisEvent->mDOMNode,
tailEvent->mDOMNode)) {
// tailDOMNode is a descendant of thisDOMNode
if (thisEvent->mEventType == nsIAccessibleEvent::EVENT_REORDER) {
CoalesceReorderEventsFromSameTree(thisEvent, tailEvent);
continue;
}
} // for (index)
if (tailEvent->mEventRule != nsAccEvent::eDoNotEmit) {
// Not in another event node's subtree, and no other event is in
// this event node's subtree.
// This event should be emitted
// Apply this result to sibling nodes of tailDOMNode
// Do not emit tailEvent, also apply this result to sibling
// nodes of tailDOMNode.
tailEvent->mEventRule = nsAccEvent::eDoNotEmit;
ApplyToSiblings(aEventsToFire, 0, tail, tailEvent->mEventType,
tailEvent->mDOMNode, nsAccEvent::eAllowDupes);
tailEvent->mDOMNode, nsAccEvent::eDoNotEmit);
break;
}
} break; // case eCoalesceFromSameSubtree
} // for (index)
case nsAccEvent::eRemoveDupes:
{
// Check for repeat events.
for (PRInt32 index = 0; index < tail; index ++) {
nsRefPtr<nsAccEvent> accEvent = GetAccEventPtr(aEventsToFire[index]);
if (accEvent->mEventType == tailEvent->mEventType &&
accEvent->mEventRule == tailEvent->mEventRule &&
accEvent->mDOMNode == tailEvent->mDOMNode) {
accEvent->mEventRule = nsAccEvent::eDoNotEmit;
}
if (tailEvent->mEventRule != nsAccEvent::eDoNotEmit) {
// Not in another event node's subtree, and no other event is in
// this event node's subtree.
// This event should be emitted
// Apply this result to sibling nodes of tailDOMNode
ApplyToSiblings(aEventsToFire, 0, tail, tailEvent->mEventType,
tailEvent->mDOMNode, nsAccEvent::eAllowDupes);
}
} break; // case eCoalesceFromSameSubtree
case nsAccEvent::eRemoveDupes:
{
// Check for repeat events.
for (PRInt32 index = 0; index < tail; index ++) {
nsRefPtr<nsAccEvent> accEvent = GetAccEventPtr(aEventsToFire[index]);
if (accEvent->mEventType == tailEvent->mEventType &&
accEvent->mEventRule == tailEvent->mEventRule &&
accEvent->mDOMNode == tailEvent->mDOMNode) {
accEvent->mEventRule = nsAccEvent::eDoNotEmit;
}
} break; // case eRemoveDupes
}
} break; // case eRemoveDupes
default:
break; // case eAllowDupes, eDoNotEmit
} // switch
} // for (tail)
default:
break; // case eAllowDupes, eDoNotEmit
} // switch
}
/* static */
void
nsAccEvent::ApplyToSiblings(nsCOMArray<nsIAccessibleEvent> &aEventsToFire,
nsAccEvent::ApplyToSiblings(nsTArray<nsCOMPtr<nsIAccessibleEvent> > &aEventsToFire,
PRUint32 aStart, PRUint32 aEnd,
PRUint32 aEventType, nsIDOMNode* aDOMNode,
EEventRule aEventRule)
@ -569,11 +568,13 @@ nsAccTextChangeEvent::
aAccessible, aIsAsynch),
mStart(aStart), mLength(aLength), mIsInserted(aIsInserted)
{
#ifdef XP_WIN
nsCOMPtr<nsIAccessibleText> textAccessible = do_QueryInterface(aAccessible);
NS_ASSERTION(textAccessible, "Should not be firing test change event for non-text accessible!!!");
if (textAccessible) {
textAccessible->GetText(aStart, aStart + aLength, mModifiedText);
}
#endif
}
NS_IMETHODIMP

Просмотреть файл

@ -105,11 +105,12 @@ public:
protected:
already_AddRefed<nsIAccessible> GetAccessibleByNode();
void CaptureIsFromUserInput(PRBool aIsAsynch);
void CaptureIsFromUserInput();
PRBool mIsFromUserInput;
PRUint32 mEventType;
EEventRule mEventRule;
PRPackedBool mIsAsync;
nsCOMPtr<nsIAccessible> mAccessible;
nsCOMPtr<nsIDOMNode> mDOMNode;
nsCOMPtr<nsIAccessibleDocument> mDocAccessible;
@ -128,6 +129,10 @@ public:
nsRefPtr<nsAccEvent> accEvent = GetAccEventPtr(aAccEvent);
return accEvent->mEventRule;
}
static PRBool IsAsyncEvent(nsIAccessibleEvent *aAccEvent) {
nsRefPtr<nsAccEvent> accEvent = GetAccEventPtr(aAccEvent);
return accEvent->mIsAsync;
}
static PRBool IsFromUserInput(nsIAccessibleEvent *aAccEvent) {
PRBool isFromUserInput;
aAccEvent->GetIsFromUserInput(&isFromUserInput);
@ -164,7 +169,7 @@ public:
* Event rule of filtered events will be set to eDoNotEmit.
* Events with other event rule are good to emit.
*/
static void ApplyEventRules(nsCOMArray<nsIAccessibleEvent> &aEventsToFire);
static void ApplyEventRules(nsTArray<nsCOMPtr<nsIAccessibleEvent> > &aEventsToFire);
private:
static already_AddRefed<nsAccEvent> GetAccEventPtr(nsIAccessibleEvent *aAccEvent) {
@ -183,7 +188,7 @@ private:
* @param aEventRule the event rule to be applied
* (should be eDoNotEmit or eAllowDupes)
*/
static void ApplyToSiblings(nsCOMArray<nsIAccessibleEvent> &aEventsToFire,
static void ApplyToSiblings(nsTArray<nsCOMPtr<nsIAccessibleEvent> > &aEventsToFire,
PRUint32 aStart, PRUint32 aEnd,
PRUint32 aEventType, nsIDOMNode* aDOMNode,
EEventRule aEventRule);
@ -258,7 +263,6 @@ public:
PRUint32 aState, PRBool aIsExtraState);
NS_DECL_ISUPPORTS_INHERITED
NS_FORWARD_NSIACCESSIBLEEVENT(nsAccEvent::)
NS_DECL_NSIACCESSIBLESTATECHANGEEVENT
private:
@ -275,7 +279,6 @@ public:
PRBool aIsInserted, PRBool aIsAsynch = PR_FALSE);
NS_DECL_ISUPPORTS_INHERITED
NS_FORWARD_NSIACCESSIBLEEVENT(nsAccEvent::)
NS_DECL_NSIACCESSIBLETEXTCHANGEEVENT
private:
@ -293,7 +296,6 @@ public:
nsAccCaretMoveEvent(nsIDOMNode *aNode);
NS_DECL_ISUPPORTS_INHERITED
NS_FORWARD_NSIACCESSIBLEEVENT(nsAccEvent::)
NS_DECL_NSIACCESSIBLECARETMOVEEVENT
private:
@ -308,7 +310,6 @@ public:
PRBool aIsAsynch);
NS_DECL_ISUPPORTS
NS_FORWARD_NSIACCESSIBLEEVENT(nsAccEvent::)
NS_DECL_NSIACCESSIBLETABLECHANGEEVENT
private:

Просмотреть файл

@ -269,7 +269,7 @@ nsCaretAccessible::NormalSelectionChanged(nsIDOMDocument *aDoc,
mLastCaretOffset = caretOffset;
mLastTextAccessible = textAcc;
nsCOMPtr<nsIAccessibleCaretMoveEvent> event =
nsCOMPtr<nsIAccessibleEvent> event =
new nsAccCaretMoveEvent(textNode);
NS_ENSURE_TRUE(event, NS_ERROR_OUT_OF_MEMORY);

Просмотреть файл

@ -1027,7 +1027,7 @@ nsCoreUtils::GetLastSensibleColumn(nsITreeBoxObject *aTree)
}
PRUint32
nsCoreUtils::GetSensibleColumnsCount(nsITreeBoxObject *aTree)
nsCoreUtils::GetSensiblecolumnCount(nsITreeBoxObject *aTree)
{
PRUint32 count = 0;

Просмотреть файл

@ -413,7 +413,7 @@ public:
/**
* Return sensible columns count for the given tree box object.
*/
static PRUint32 GetSensibleColumnsCount(nsITreeBoxObject *aTree);
static PRUint32 GetSensiblecolumnCount(nsITreeBoxObject *aTree);
/**
* Return sensible column at the given index for the given tree box object.

Просмотреть файл

@ -86,7 +86,8 @@ nsIAtom *nsDocAccessible::gLastFocusedFrameType = nsnull;
nsDocAccessible::nsDocAccessible(nsIDOMNode *aDOMNode, nsIWeakReference* aShell):
nsHyperTextAccessibleWrap(aDOMNode, aShell), mWnd(nsnull),
mScrollPositionChangedTicks(0), mIsContentLoaded(PR_FALSE),
mIsLoadCompleteFired(PR_FALSE), mInFlushPendingEvents(PR_FALSE)
mIsLoadCompleteFired(PR_FALSE), mInFlushPendingEvents(PR_FALSE),
mFireEventTimerStarted(PR_FALSE)
{
// XXX aaronl should we use an algorithm for the initial cache size?
mAccessNodeCache.Init(kDefaultCacheSize);
@ -153,12 +154,17 @@ ElementTraverser(const void *aKey, nsIAccessNode *aAccessNode,
NS_IMPL_CYCLE_COLLECTION_CLASS(nsDocAccessible)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INHERITED(nsDocAccessible, nsAccessible)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSCOMARRAY(mEventsToFire)
tmp->mAccessNodeCache.EnumerateRead(ElementTraverser, &cb);
PRUint32 i, length = tmp->mEventsToFire.Length();
for (i = 0; i < length; ++i) {
NS_CYCLE_COLLECTION_NOTE_EDGE_NAME(cb, "mEventsToFire[i]");
cb.NoteXPCOMChild(tmp->mEventsToFire[i].get());
}
tmp->mAccessNodeCache.EnumerateRead(ElementTraverser, &cb);
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN_INHERITED(nsDocAccessible, nsAccessible)
NS_IMPL_CYCLE_COLLECTION_UNLINK_NSCOMARRAY(mEventsToFire)
NS_IMPL_CYCLE_COLLECTION_UNLINK_NSTARRAY(mEventsToFire)
tmp->ClearCache(tmp->mAccessNodeCache);
NS_IMPL_CYCLE_COLLECTION_UNLINK_END
@ -652,17 +658,17 @@ nsDocAccessible::Shutdown()
nsHyperTextAccessibleWrap::Shutdown();
if (mFireEventTimer) {
// Doc being shut down before events fired,
// Doc being shut down before delayed events were processed.
mFireEventTimer->Cancel();
mFireEventTimer = nsnull;
if (mEventsToFire.Count() > 0 ) {
mEventsToFire.Clear();
// Make sure we release the kung fu death grip which is always
// there when there are still events left to be fired
// If FlushPendingEvents() is in call stack,
// kung fu death grip will be released there.
if (!mInFlushPendingEvents)
NS_RELEASE_THIS();
mEventsToFire.Clear();
if (mFireEventTimerStarted && !mInFlushPendingEvents) {
// Make sure we release the kung fu death grip which is always there when
// fire event timer was started but FlushPendingEvents() callback wasn't
// triggered yet. If FlushPendingEvents() is in call stack, kung fu death
// grip will be released there.
NS_RELEASE_THIS();
}
}
@ -929,7 +935,8 @@ nsDocAccessible::FireDocLoadEvents(PRUint32 aEventType)
if (sameTypeRoot != treeItem) {
// Fire show/hide events to indicate frame/iframe content is new, rather than
// doc load event which causes screen readers to act is if entire page is reloaded
InvalidateCacheSubtree(nsnull, nsIAccessibleEvent::EVENT_DOM_SIGNIFICANT_CHANGE);
InvalidateCacheSubtree(nsnull,
nsIAccessibilityService::NODE_SIGNIFICANT_CHANGE);
}
// Fire STATE_CHANGE event for doc load finish if focus is in same doc tree
if (gLastFocusedNode) {
@ -939,7 +946,7 @@ nsDocAccessible::FireDocLoadEvents(PRUint32 aEventType)
nsCOMPtr<nsIDocShellTreeItem> sameTypeRootOfFocus;
focusedTreeItem->GetSameTypeRootTreeItem(getter_AddRefs(sameTypeRootOfFocus));
if (sameTypeRoot == sameTypeRootOfFocus) {
nsCOMPtr<nsIAccessibleStateChangeEvent> accEvent =
nsCOMPtr<nsIAccessibleEvent> accEvent =
new nsAccStateChangeEvent(this, nsIAccessibleStates::STATE_BUSY, PR_FALSE, PR_FALSE);
FireAccessibleEvent(accEvent);
FireAnchorJumpEvent();
@ -953,7 +960,7 @@ nsDocAccessible::FireDocLoadEvents(PRUint32 aEventType)
if (!isFinished) {
// Fire state change event to set STATE_BUSY when document is loading. For
// example, Window-Eyes expects to get it.
nsCOMPtr<nsIAccessibleStateChangeEvent> accEvent =
nsCOMPtr<nsIAccessibleEvent> accEvent =
new nsAccStateChangeEvent(this, nsIAccessibleStates::STATE_BUSY,
PR_FALSE, PR_TRUE);
FireAccessibleEvent(accEvent);
@ -1047,7 +1054,7 @@ NS_IMETHODIMP nsDocAccessible::Observe(nsISupports *aSubject, const char *aTopic
{
if (!nsCRT::strcmp(aTopic,"obs_documentCreated")) {
// State editable will now be set, readonly is now clear
nsCOMPtr<nsIAccessibleStateChangeEvent> event =
nsCOMPtr<nsIAccessibleEvent> event =
new nsAccStateChangeEvent(this, nsIAccessibleStates::EXT_STATE_EDITABLE,
PR_TRUE, PR_TRUE);
FireAccessibleEvent(event);
@ -1139,24 +1146,30 @@ nsDocAccessible::AttributeChangedImpl(nsIContent* aContent, PRInt32 aNameSpaceID
// layout change, that event can use the last known user input state
nsAccEvent::PrepareForEvent(targetNode);
// Universal boolean properties that don't require a role.
// Universal boolean properties that don't require a role. Fire the state
// change when disabled or aria-disabled attribute is set.
if (aAttribute == nsAccessibilityAtoms::disabled ||
aAttribute == nsAccessibilityAtoms::aria_disabled) {
// Fire the state change whether disabled attribute is
// set for XUL, HTML or ARIA namespace.
// Checking the namespace would not seem to gain us anything, because
// disabled really is going to mean the same thing in any namespace.
// We use the attribute instead of the disabled state bit because
// ARIA's aria-disabled does not affect the disabled state bit
nsCOMPtr<nsIAccessibleStateChangeEvent> enabledChangeEvent =
// Note. Checking the XUL or HTML namespace would not seem to gain us
// anything, because disabled attribute really is going to mean the same
// thing in any namespace.
// Note. We use the attribute instead of the disabled state bit because
// ARIA's aria-disabled does not affect the disabled state bit.
nsCOMPtr<nsIAccessibleEvent> enabledChangeEvent =
new nsAccStateChangeEvent(targetNode,
nsIAccessibleStates::EXT_STATE_ENABLED,
PR_TRUE);
FireDelayedAccessibleEvent(enabledChangeEvent);
nsCOMPtr<nsIAccessibleStateChangeEvent> sensitiveChangeEvent =
nsCOMPtr<nsIAccessibleEvent> sensitiveChangeEvent =
new nsAccStateChangeEvent(targetNode,
nsIAccessibleStates::EXT_STATE_SENSITIVE,
PR_TRUE);
FireDelayedAccessibleEvent(sensitiveChangeEvent);
return;
}
@ -1177,7 +1190,8 @@ nsDocAccessible::AttributeChangedImpl(nsIContent* aContent, PRInt32 aNameSpaceID
// Not worth the expense to ensure which namespace these are in
// It doesn't kill use to recreate the accessible even if the attribute was used
// in the wrong namespace or an element that doesn't support it
InvalidateCacheSubtree(aContent, nsIAccessibleEvent::EVENT_DOM_SIGNIFICANT_CHANGE);
InvalidateCacheSubtree(aContent,
nsIAccessibilityService::NODE_SIGNIFICANT_CHANGE);
return;
}
@ -1185,8 +1199,8 @@ nsDocAccessible::AttributeChangedImpl(nsIContent* aContent, PRInt32 aNameSpaceID
aAttribute == nsAccessibilityAtoms::title ||
aAttribute == nsAccessibilityAtoms::aria_label ||
aAttribute == nsAccessibilityAtoms::aria_labelledby) {
FireDelayedToolkitEvent(nsIAccessibleEvent::EVENT_NAME_CHANGE,
targetNode);
FireDelayedAccessibleEvent(nsIAccessibleEvent::EVENT_NAME_CHANGE,
targetNode);
return;
}
@ -1208,26 +1222,26 @@ nsDocAccessible::AttributeChangedImpl(nsIContent* aContent, PRInt32 aNameSpaceID
nsCOMPtr<nsIDOMNode> multiSelectDOMNode;
multiSelectAccessNode->GetDOMNode(getter_AddRefs(multiSelectDOMNode));
NS_ASSERTION(multiSelectDOMNode, "A new accessible without a DOM node!");
FireDelayedToolkitEvent(nsIAccessibleEvent::EVENT_SELECTION_WITHIN,
multiSelectDOMNode,
nsAccEvent::eAllowDupes);
FireDelayedAccessibleEvent(nsIAccessibleEvent::EVENT_SELECTION_WITHIN,
multiSelectDOMNode,
nsAccEvent::eAllowDupes);
static nsIContent::AttrValuesArray strings[] =
{&nsAccessibilityAtoms::_empty, &nsAccessibilityAtoms::_false, nsnull};
if (aContent->FindAttrValueIn(kNameSpaceID_None, aAttribute,
strings, eCaseMatters) >= 0) {
FireDelayedToolkitEvent(nsIAccessibleEvent::EVENT_SELECTION_REMOVE,
targetNode);
FireDelayedAccessibleEvent(nsIAccessibleEvent::EVENT_SELECTION_REMOVE,
targetNode);
return;
}
FireDelayedToolkitEvent(nsIAccessibleEvent::EVENT_SELECTION_ADD,
targetNode);
FireDelayedAccessibleEvent(nsIAccessibleEvent::EVENT_SELECTION_ADD,
targetNode);
}
}
if (aAttribute == nsAccessibilityAtoms::contenteditable) {
nsCOMPtr<nsIAccessibleStateChangeEvent> editableChangeEvent =
nsCOMPtr<nsIAccessibleEvent> editableChangeEvent =
new nsAccStateChangeEvent(targetNode,
nsIAccessibleStates::EXT_STATE_EDITABLE,
PR_TRUE);
@ -1244,7 +1258,7 @@ nsDocAccessible::ARIAAttributeChanged(nsIContent* aContent, nsIAtom* aAttribute)
return;
if (aAttribute == nsAccessibilityAtoms::aria_required) {
nsCOMPtr<nsIAccessibleStateChangeEvent> event =
nsCOMPtr<nsIAccessibleEvent> event =
new nsAccStateChangeEvent(targetNode,
nsIAccessibleStates::STATE_REQUIRED,
PR_FALSE);
@ -1253,7 +1267,7 @@ nsDocAccessible::ARIAAttributeChanged(nsIContent* aContent, nsIAtom* aAttribute)
}
if (aAttribute == nsAccessibilityAtoms::aria_invalid) {
nsCOMPtr<nsIAccessibleStateChangeEvent> event =
nsCOMPtr<nsIAccessibleEvent> event =
new nsAccStateChangeEvent(targetNode,
nsIAccessibleStates::STATE_INVALID,
PR_FALSE);
@ -1287,7 +1301,7 @@ nsDocAccessible::ARIAAttributeChanged(nsIContent* aContent, nsIAtom* aAttribute)
const PRUint32 kState = (aAttribute == nsAccessibilityAtoms::aria_checked) ?
nsIAccessibleStates::STATE_CHECKED :
nsIAccessibleStates::STATE_PRESSED;
nsCOMPtr<nsIAccessibleStateChangeEvent> event =
nsCOMPtr<nsIAccessibleEvent> event =
new nsAccStateChangeEvent(targetNode, kState, PR_FALSE);
FireDelayedAccessibleEvent(event);
if (targetNode == gLastFocusedNode) {
@ -1302,7 +1316,7 @@ nsDocAccessible::ARIAAttributeChanged(nsIContent* aContent, nsIAtom* aAttribute)
PRBool isMixed =
(nsAccUtils::State(accessible) & nsIAccessibleStates::STATE_MIXED) != 0;
if (wasMixed != isMixed) {
nsCOMPtr<nsIAccessibleStateChangeEvent> event =
nsCOMPtr<nsIAccessibleEvent> event =
new nsAccStateChangeEvent(targetNode,
nsIAccessibleStates::STATE_MIXED,
PR_FALSE, isMixed);
@ -1314,7 +1328,7 @@ nsDocAccessible::ARIAAttributeChanged(nsIContent* aContent, nsIAtom* aAttribute)
}
if (aAttribute == nsAccessibilityAtoms::aria_expanded) {
nsCOMPtr<nsIAccessibleStateChangeEvent> event =
nsCOMPtr<nsIAccessibleEvent> event =
new nsAccStateChangeEvent(targetNode,
nsIAccessibleStates::STATE_EXPANDED,
PR_FALSE);
@ -1323,7 +1337,7 @@ nsDocAccessible::ARIAAttributeChanged(nsIContent* aContent, nsIAtom* aAttribute)
}
if (aAttribute == nsAccessibilityAtoms::aria_readonly) {
nsCOMPtr<nsIAccessibleStateChangeEvent> event =
nsCOMPtr<nsIAccessibleEvent> event =
new nsAccStateChangeEvent(targetNode,
nsIAccessibleStates::STATE_READONLY,
PR_FALSE);
@ -1340,7 +1354,8 @@ nsDocAccessible::ARIAAttributeChanged(nsIContent* aContent, nsIAtom* aAttribute)
aContent->AttrValueIs(kNameSpaceID_None,
nsAccessibilityAtoms::aria_valuetext, nsAccessibilityAtoms::_empty,
eCaseMatters)))) {
FireDelayedToolkitEvent(nsIAccessibleEvent::EVENT_VALUE_CHANGE, targetNode);
FireDelayedAccessibleEvent(nsIAccessibleEvent::EVENT_VALUE_CHANGE,
targetNode);
return;
}
@ -1349,7 +1364,8 @@ nsDocAccessible::ARIAAttributeChanged(nsIContent* aContent, nsIAtom* aAttribute)
// This affects whether the accessible supports nsIAccessibleSelectable.
// COM says we cannot change what interfaces are supported on-the-fly,
// so invalidate this object. A new one will be created on demand.
InvalidateCacheSubtree(aContent, nsIAccessibleEvent::EVENT_DOM_SIGNIFICANT_CHANGE);
InvalidateCacheSubtree(aContent,
nsIAccessibilityService::NODE_SIGNIFICANT_CHANGE);
return;
}
@ -1357,8 +1373,8 @@ nsDocAccessible::ARIAAttributeChanged(nsIContent* aContent, nsIAtom* aAttribute)
// at least until native API comes up with a more meaningful event.
if (aAttribute == nsAccessibilityAtoms::aria_grabbed ||
aAttribute == nsAccessibilityAtoms::aria_dropeffect) {
FireDelayedToolkitEvent(nsIAccessibleEvent::EVENT_OBJECT_ATTRIBUTE_CHANGED,
targetNode);
FireDelayedAccessibleEvent(nsIAccessibleEvent::EVENT_OBJECT_ATTRIBUTE_CHANGED,
targetNode);
}
}
@ -1379,7 +1395,7 @@ void nsDocAccessible::ContentAppended(nsIDocument *aDocument,
// unless an accessible can be created for the passed in node, which it
// can't do unless the node is visible. The right thing happens there so
// no need for an extra visibility check here.
InvalidateCacheSubtree(child, nsIAccessibleEvent::EVENT_DOM_CREATE);
InvalidateCacheSubtree(child, nsIAccessibilityService::NODE_APPEND);
}
}
@ -1418,18 +1434,19 @@ nsDocAccessible::ContentInserted(nsIDocument *aDocument, nsIContent* aContainer,
// unless an accessible can be created for the passed in node, which it
// can't do unless the node is visible. The right thing happens there so
// no need for an extra visibility check here.
InvalidateCacheSubtree(aChild, nsIAccessibleEvent::EVENT_DOM_CREATE);
InvalidateCacheSubtree(aChild, nsIAccessibilityService::NODE_APPEND);
}
void
nsDocAccessible::ContentRemoved(nsIDocument *aDocument, nsIContent* aContainer,
nsIContent* aChild, PRInt32 aIndexInContainer)
{
// Invalidate the subtree of the removed element.
// InvalidateCacheSubtree(aChild, nsIAccessibleEvent::EVENT_DOM_DESTROY);
// This is no longer needed, we get our notifications directly from content
// *before* the frame for the content is destroyed, or any other side effects occur.
// That allows us to correctly calculate the TEXT_REMOVED event if there is one.
// It's no needed to invalidate the subtree of the removed element,
// because we get notifications directly from content (see
// nsGenericElement::doRemoveChildAt) *before* the frame for the content is
// destroyed, or any other side effects occur . That allows us to correctly
// calculate the TEXT_REMOVED event if there is one and coalesce events from
// the same subtree.
}
void
@ -1505,7 +1522,7 @@ nsDocAccessible::FireTextChangeEventForText(nsIContent *aContent,
if (NS_FAILED(rv))
return;
nsCOMPtr<nsIAccessibleTextChangeEvent> event =
nsCOMPtr<nsIAccessibleEvent> event =
new nsAccTextChangeEvent(accessible, offset,
renderedEndOffset - renderedStartOffset,
aIsInserted, PR_FALSE);
@ -1515,7 +1532,7 @@ nsDocAccessible::FireTextChangeEventForText(nsIContent *aContent,
}
}
already_AddRefed<nsIAccessibleTextChangeEvent>
already_AddRefed<nsIAccessibleEvent>
nsDocAccessible::CreateTextChangeEventForNode(nsIAccessible *aContainerAccessible,
nsIDOMNode *aChangeNode,
nsIAccessible *aAccessibleForChangeNode,
@ -1585,20 +1602,21 @@ nsDocAccessible::CreateTextChangeEventForNode(nsIAccessible *aContainerAccessibl
return nsnull;
}
nsIAccessibleTextChangeEvent *event =
nsIAccessibleEvent *event =
new nsAccTextChangeEvent(aContainerAccessible, offset, length, aIsInserting, aIsAsynch);
NS_IF_ADDREF(event);
return event;
}
nsresult nsDocAccessible::FireDelayedToolkitEvent(PRUint32 aEvent,
nsIDOMNode *aDOMNode,
nsAccEvent::EEventRule aAllowDupes,
PRBool aIsAsynch)
nsresult
nsDocAccessible::FireDelayedAccessibleEvent(PRUint32 aEventType,
nsIDOMNode *aDOMNode,
nsAccEvent::EEventRule aAllowDupes,
PRBool aIsAsynch)
{
nsCOMPtr<nsIAccessibleEvent> event =
new nsAccEvent(aEvent, aDOMNode, aIsAsynch, aAllowDupes);
new nsAccEvent(aEventType, aDOMNode, aIsAsynch, aAllowDupes);
NS_ENSURE_TRUE(event, NS_ERROR_OUT_OF_MEMORY);
return FireDelayedAccessibleEvent(event);
@ -1607,31 +1625,54 @@ nsresult nsDocAccessible::FireDelayedToolkitEvent(PRUint32 aEvent,
nsresult
nsDocAccessible::FireDelayedAccessibleEvent(nsIAccessibleEvent *aEvent)
{
NS_ENSURE_TRUE(aEvent, NS_ERROR_FAILURE);
NS_ENSURE_ARG(aEvent);
mEventsToFire.AppendElement(aEvent);
// Filter events.
nsAccEvent::ApplyEventRules(mEventsToFire);
// Process events.
return PreparePendingEventsFlush();
}
nsresult
nsDocAccessible::PreparePendingEventsFlush()
{
nsresult rv = NS_OK;
// Create timer if we don't have it yet.
if (!mFireEventTimer) {
// Do not yet have a timer going for firing another event.
mFireEventTimer = do_CreateInstance("@mozilla.org/timer;1");
NS_ENSURE_TRUE(mFireEventTimer, NS_ERROR_OUT_OF_MEMORY);
mFireEventTimer = do_CreateInstance("@mozilla.org/timer;1", &rv);
NS_ENSURE_SUCCESS(rv, rv);
}
mEventsToFire.AppendObject(aEvent);
if (mEventsToFire.Count() == 1) {
// This is be the first delayed event in queue, start timer
// so that event gets fired via FlushEventsCallback
NS_ADDREF_THIS(); // Kung fu death grip to prevent crash in callback
mFireEventTimer->InitWithFuncCallback(FlushEventsCallback,
this, 0, nsITimer::TYPE_ONE_SHOT);
// If there are delayed events in the queue and event timer wasn't started
// then initialize the timer so that delayed event will be processed in
// FlushPendingEvents.
if (mEventsToFire.Length() > 0 && !mFireEventTimerStarted) {
rv = mFireEventTimer->InitWithFuncCallback(FlushEventsCallback,
this, 0,
nsITimer::TYPE_ONE_SHOT);
if (NS_SUCCEEDED(rv)) {
// Kung fu death grip to prevent crash in callback.
NS_ADDREF_THIS();
mFireEventTimerStarted = PR_TRUE;
}
}
return NS_OK;
return rv;
}
void
nsDocAccessible::FlushPendingEvents()
{
mInFlushPendingEvents = PR_TRUE;
PRUint32 length = mEventsToFire.Count();
PRUint32 length = mEventsToFire.Length();
NS_ASSERTION(length, "How did we get here without events to fire?");
nsCOMPtr<nsIPresShell> presShell = GetPresShell();
if (!presShell)
@ -1643,14 +1684,18 @@ nsDocAccessible::FlushPendingEvents()
// visibility. We don't flush the display because we don't care about
// painting. If no flush is necessary the method will simple return.
presShell->FlushPendingNotifications(Flush_Layout);
// filter events
nsAccEvent::ApplyEventRules(mEventsToFire);
}
// Process only currently queued events. In the meantime, newly appended
// events will not be processed.
for (PRUint32 index = 0; index < length; index ++) {
nsCOMPtr<nsIAccessibleEvent> accessibleEvent(
do_QueryInterface(mEventsToFire[index]));
// No presshell means the document was shut down duiring event handling
// by AT.
if (!mWeakShell)
break;
nsCOMPtr<nsIAccessibleEvent> accessibleEvent(mEventsToFire[index]);
if (nsAccEvent::EventRule(accessibleEvent) == nsAccEvent::eDoNotEmit)
continue;
@ -1662,9 +1707,10 @@ nsDocAccessible::FlushPendingEvents()
PRUint32 eventType = nsAccEvent::EventType(accessibleEvent);
PRBool isFromUserInput = nsAccEvent::IsFromUserInput(accessibleEvent);
if (domNode == gLastFocusedNode &&
(eventType == nsIAccessibleEvent::EVENT_ASYNCH_HIDE ||
eventType == nsIAccessibleEvent::EVENT_ASYNCH_SHOW)) {
PRBool isAsync = nsAccEvent::IsAsyncEvent(accessibleEvent);
if (domNode == gLastFocusedNode && isAsync &&
(eventType == nsIAccessibleEvent::EVENT_SHOW ||
eventType == nsIAccessibleEvent::EVENT_HIDE)) {
// If frame type didn't change for this event, then we don't actually need to invalidate
// However, we only keep track of the old frame type for the focus, where it's very
// important not to destroy and recreate the accessible for minor style changes,
@ -1679,15 +1725,15 @@ nsDocAccessible::FlushPendingEvents()
if (newFrameType == gLastFocusedFrameType) {
// Don't need to invalidate this current accessible, but can
// just invalidate the children instead
FireShowHideEvents(domNode, PR_TRUE, eventType, PR_FALSE, isFromUserInput);
FireShowHideEvents(domNode, PR_TRUE, eventType, eNormalEvent,
isAsync, isFromUserInput);
continue;
}
gLastFocusedFrameType = newFrameType;
}
}
if (eventType == nsIAccessibleEvent::EVENT_DOM_CREATE ||
eventType == nsIAccessibleEvent::EVENT_ASYNCH_SHOW) {
if (eventType == nsIAccessibleEvent::EVENT_SHOW) {
nsCOMPtr<nsIAccessible> containerAccessible;
if (accessible)
@ -1700,7 +1746,7 @@ nsDocAccessible::FlushPendingEvents()
containerAccessible = this;
}
if (eventType == nsIAccessibleEvent::EVENT_ASYNCH_SHOW) {
if (isAsync) {
// For asynch show, delayed invalidatation of parent's children
nsRefPtr<nsAccessible> containerAcc =
nsAccUtils::QueryAccessible(containerAccessible);
@ -1719,7 +1765,7 @@ nsDocAccessible::FlushPendingEvents()
// wait to fire this here, instead of in InvalidateCacheSubtree(), where we wouldn't be able to calculate
// the offset, length and text for the text change.
if (domNode && domNode != mDOMNode) {
nsCOMPtr<nsIAccessibleTextChangeEvent> textChangeEvent =
nsCOMPtr<nsIAccessibleEvent> textChangeEvent =
CreateTextChangeEventForNode(containerAccessible, domNode, accessible, PR_TRUE, PR_TRUE);
if (textChangeEvent) {
nsAccEvent::PrepareForEvent(textChangeEvent, isFromUserInput);
@ -1731,7 +1777,8 @@ nsDocAccessible::FlushPendingEvents()
}
// Fire show/create events for this node or first accessible descendants of it
FireShowHideEvents(domNode, PR_FALSE, eventType, PR_FALSE, isFromUserInput);
FireShowHideEvents(domNode, PR_FALSE, eventType, eNormalEvent, isAsync,
isFromUserInput);
continue;
}
@ -1760,7 +1807,7 @@ nsDocAccessible::FlushPendingEvents()
GetAccService()->GetAccessibleFor(gLastFocusedNode, getter_AddRefs(accForFocus));
nsAccUtils::FireAccEvent(nsIAccessibleEvent::EVENT_ALERT, accForFocus);
#endif
nsCOMPtr<nsIAccessibleCaretMoveEvent> caretMoveEvent =
nsCOMPtr<nsIAccessibleEvent> caretMoveEvent =
new nsAccCaretMoveEvent(accessible, caretOffset);
if (!caretMoveEvent)
break; // Out of memory, break out to release kung fu death grip
@ -1792,9 +1839,9 @@ nsDocAccessible::FlushPendingEvents()
nsAccEvent::PrepareForEvent(accessibleEvent);
FireAccessibleEvent(accessibleEvent);
// Post event processing
if (eventType == nsIAccessibleEvent::EVENT_ASYNCH_HIDE ||
eventType == nsIAccessibleEvent::EVENT_DOM_DESTROY) {
// Shutdown nsIAccessNode's or nsIAccessibles for any DOM nodes in this subtree
if (eventType == nsIAccessibleEvent::EVENT_HIDE) {
// Shutdown nsIAccessNode's or nsIAccessibles for any DOM nodes in
// this subtree.
nsCOMPtr<nsIDOMNode> hidingNode;
accessibleEvent->GetDOMNode(getter_AddRefs(hidingNode));
if (hidingNode) {
@ -1804,12 +1851,24 @@ nsDocAccessible::FlushPendingEvents()
}
}
}
mEventsToFire.Clear(); // Clear out array
mInFlushPendingEvents = PR_FALSE;
NS_RELEASE_THIS(); // Release kung fu death grip
// After a flood of events, reset so that user input flag is off
// Mark we are ready to start event processing timer again.
mFireEventTimerStarted = PR_FALSE;
// If the document accessible is alive then remove processed events from the
// queue (otherwise they were removed on shutdown already) and reinitialize
// queue processing callback if necessary (new events might occur duiring
// delayed event processing).
if (mWeakShell) {
mEventsToFire.RemoveElementsAt(0, length);
PreparePendingEventsFlush();
}
// After a flood of events, reset so that user input flag is off.
nsAccEvent::ResetLastInputState();
mInFlushPendingEvents = PR_FALSE;
NS_RELEASE_THIS(); // Release kung fu death grip.
}
void nsDocAccessible::FlushEventsCallback(nsITimer *aTimer, void *aClosure)
@ -1932,27 +1991,27 @@ void nsDocAccessible::RefreshNodes(nsIDOMNode *aStartNode)
void
nsDocAccessible::InvalidateCacheSubtree(nsIContent *aChild,
PRUint32 aChangeEventType)
PRUint32 aChangeType)
{
PRBool isHiding =
aChangeEventType == nsIAccessibleEvent::EVENT_ASYNCH_HIDE ||
aChangeEventType == nsIAccessibleEvent::EVENT_DOM_DESTROY;
PRBool isHiding =
aChangeType == nsIAccessibilityService::FRAME_HIDE ||
aChangeType == nsIAccessibilityService::NODE_REMOVE;
PRBool isShowing =
aChangeEventType == nsIAccessibleEvent::EVENT_ASYNCH_SHOW ||
aChangeEventType == nsIAccessibleEvent::EVENT_DOM_CREATE;
PRBool isShowing =
aChangeType == nsIAccessibilityService::FRAME_SHOW ||
aChangeType == nsIAccessibilityService::NODE_APPEND;
PRBool isChanging =
aChangeEventType == nsIAccessibleEvent::EVENT_DOM_SIGNIFICANT_CHANGE ||
aChangeEventType == nsIAccessibleEvent::EVENT_ASYNCH_SIGNIFICANT_CHANGE;
PRBool isChanging =
aChangeType == nsIAccessibilityService::NODE_SIGNIFICANT_CHANGE ||
aChangeType == nsIAccessibilityService::FRAME_SIGNIFICANT_CHANGE;
NS_ASSERTION(isChanging || isHiding || isShowing,
"Incorrect aChangeEventType passed in");
PRBool isAsynch =
aChangeEventType == nsIAccessibleEvent::EVENT_ASYNCH_HIDE ||
aChangeEventType == nsIAccessibleEvent::EVENT_ASYNCH_SHOW ||
aChangeEventType == nsIAccessibleEvent::EVENT_ASYNCH_SIGNIFICANT_CHANGE;
PRBool isAsynch =
aChangeType == nsIAccessibilityService::FRAME_HIDE ||
aChangeType == nsIAccessibilityService::FRAME_SHOW ||
aChangeType == nsIAccessibilityService::FRAME_SIGNIFICANT_CHANGE;
// Invalidate cache subtree
// We have to check for accessibles for each dom node by traversing DOM tree
@ -2012,24 +2071,18 @@ nsDocAccessible::InvalidateCacheSubtree(nsIContent *aChild,
nsAutoString localName;
childNode->GetLocalName(localName);
const char *hasAccessible = childAccessible ? " (acc)" : "";
if (aChangeEventType == nsIAccessibleEvent::EVENT_ASYNCH_HIDE) {
if (aChangeType == nsIAccessibilityService::FRAME_HIDE)
printf("[Hide %s %s]\n", NS_ConvertUTF16toUTF8(localName).get(), hasAccessible);
}
else if (aChangeEventType == nsIAccessibleEvent::EVENT_ASYNCH_SHOW) {
else if (aChangeType == nsIAccessibilityService::FRAME_SHOW)
printf("[Show %s %s]\n", NS_ConvertUTF16toUTF8(localName).get(), hasAccessible);
}
else if (aChangeEventType == nsIAccessibleEvent::EVENT_ASYNCH_SIGNIFICANT_CHANGE) {
else if (aChangeType == nsIAccessibilityService::FRAME_SIGNIFICANT_CHANGE)
printf("[Layout change %s %s]\n", NS_ConvertUTF16toUTF8(localName).get(), hasAccessible);
}
else if (aChangeEventType == nsIAccessibleEvent::EVENT_DOM_CREATE) {
else if (aChangeType == nsIAccessibleEvent::NODE_APPEND)
printf("[Create %s %s]\n", NS_ConvertUTF16toUTF8(localName).get(), hasAccessible);
}
else if (aChangeEventType == nsIAccessibleEvent::EVENT_DOM_DESTROY) {
else if (aChangeType == nsIAccessibilityService::NODE_REMOVE)
printf("[Destroy %s %s]\n", NS_ConvertUTF16toUTF8(localName).get(), hasAccessible);
}
else if (aChangeEventType == nsIAccessibleEvent::EVENT_DOM_SIGNIFICANT_CHANGE) {
else if (aChangeEventType == nsIAccessibilityService::NODE_SIGNIFICANT_CHANGE)
printf("[Type change %s %s]\n", NS_ConvertUTF16toUTF8(localName).get(), hasAccessible);
}
#endif
nsCOMPtr<nsIAccessible> containerAccessible;
@ -2039,7 +2092,7 @@ nsDocAccessible::InvalidateCacheSubtree(nsIContent *aChild,
}
if (!isShowing) {
// Fire EVENT_ASYNCH_HIDE or EVENT_DOM_DESTROY
// Fire EVENT_HIDE.
if (isHiding) {
nsCOMPtr<nsIContent> content(do_QueryInterface(childNode));
if (content) {
@ -2058,12 +2111,12 @@ nsDocAccessible::InvalidateCacheSubtree(nsIContent *aChild,
}
}
PRUint32 removalEventType = isAsynch ? nsIAccessibleEvent::EVENT_ASYNCH_HIDE :
nsIAccessibleEvent::EVENT_DOM_DESTROY;
// Fire an event if the accessible existed for node being hidden, otherwise
// for the first line accessible descendants. Fire before the accessible(s) away.
nsresult rv = FireShowHideEvents(childNode, PR_FALSE, removalEventType, PR_TRUE, PR_FALSE);
// for the first line accessible descendants. Fire before the accessible(s)
// away.
nsresult rv = FireShowHideEvents(childNode, PR_FALSE,
nsIAccessibleEvent::EVENT_HIDE,
eDelayedEvent, isAsynch, PR_FALSE);
NS_ENSURE_SUCCESS(rv,);
if (childNode != mDOMNode) { // Fire text change unless the node being removed is for this doc
@ -2072,7 +2125,7 @@ nsDocAccessible::InvalidateCacheSubtree(nsIContent *aChild,
// XXX Collate events when a range is deleted
// XXX We need a way to ignore SplitNode and JoinNode() when they
// do not affect the text within the hypertext
nsCOMPtr<nsIAccessibleTextChangeEvent> textChangeEvent =
nsCOMPtr<nsIAccessibleEvent> textChangeEvent =
CreateTextChangeEventForNode(containerAccessible, childNode, childAccessible,
PR_FALSE, isAsynch);
if (textChangeEvent) {
@ -2098,24 +2151,25 @@ nsDocAccessible::InvalidateCacheSubtree(nsIContent *aChild,
containerAcc->InvalidateChildren();
}
// Fire EVENT_SHOW, EVENT_MENUPOPUP_START for newly visible content.
// Fire after a short timer, because we want to make sure the view has been
// updated to make this accessible content visible. If we don't wait,
// the assistive technology may receive the event and then retrieve
// nsIAccessibleStates::STATE_INVISIBLE for the event's accessible object.
PRUint32 additionEvent = isAsynch ? nsIAccessibleEvent::EVENT_ASYNCH_SHOW :
nsIAccessibleEvent::EVENT_DOM_CREATE;
FireDelayedToolkitEvent(additionEvent, childNode,
nsAccEvent::eCoalesceFromSameSubtree,
isAsynch);
FireDelayedAccessibleEvent(nsIAccessibleEvent::EVENT_SHOW, childNode,
nsAccEvent::eCoalesceFromSameSubtree,
isAsynch);
// Check to see change occured in an ARIA menu, and fire
// an EVENT_MENUPOPUP_START if it did.
nsRoleMapEntry *roleMapEntry = nsAccUtils::GetRoleMapEntry(childNode);
if (roleMapEntry && roleMapEntry->role == nsIAccessibleRole::ROLE_MENUPOPUP) {
FireDelayedToolkitEvent(nsIAccessibleEvent::EVENT_MENUPOPUP_START,
childNode, nsAccEvent::eRemoveDupes,
isAsynch);
FireDelayedAccessibleEvent(nsIAccessibleEvent::EVENT_MENUPOPUP_START,
childNode, nsAccEvent::eRemoveDupes,
isAsynch);
}
// Check to see if change occured inside an alert, and fire an EVENT_ALERT if it did
@ -2123,8 +2177,8 @@ nsDocAccessible::InvalidateCacheSubtree(nsIContent *aChild,
while (PR_TRUE) {
if (roleMapEntry && roleMapEntry->role == nsIAccessibleRole::ROLE_ALERT) {
nsCOMPtr<nsIDOMNode> alertNode(do_QueryInterface(ancestor));
FireDelayedToolkitEvent(nsIAccessibleEvent::EVENT_ALERT, alertNode,
nsAccEvent::eRemoveDupes, isAsynch);
FireDelayedAccessibleEvent(nsIAccessibleEvent::EVENT_ALERT, alertNode,
nsAccEvent::eRemoveDupes, isAsynch);
break;
}
ancestor = ancestor->GetParent();
@ -2204,15 +2258,18 @@ nsDocAccessible::GetAccessibleInParentChain(nsIDOMNode *aNode,
}
nsresult
nsDocAccessible::FireShowHideEvents(nsIDOMNode *aDOMNode, PRBool aAvoidOnThisNode, PRUint32 aEventType,
PRBool aDelay, PRBool aForceIsFromUserInput)
nsDocAccessible::FireShowHideEvents(nsIDOMNode *aDOMNode,
PRBool aAvoidOnThisNode,
PRUint32 aEventType,
EEventFiringType aDelayedOrNormal,
PRBool aIsAsyncChange,
PRBool aForceIsFromUserInput)
{
NS_ENSURE_ARG(aDOMNode);
nsCOMPtr<nsIAccessible> accessible;
if (!aAvoidOnThisNode) {
if (aEventType == nsIAccessibleEvent::EVENT_ASYNCH_HIDE ||
aEventType == nsIAccessibleEvent::EVENT_DOM_DESTROY) {
if (aEventType == nsIAccessibleEvent::EVENT_HIDE) {
// Don't allow creation for accessibles when nodes going away
nsCOMPtr<nsIAccessNode> accessNode;
GetCachedAccessNode(aDOMNode, getter_AddRefs(accessNode));
@ -2225,21 +2282,20 @@ nsDocAccessible::FireShowHideEvents(nsIDOMNode *aDOMNode, PRBool aAvoidOnThisNod
}
if (accessible) {
// Found an accessible, so fire the show/hide on it and don't
// look further into this subtree
PRBool isAsynch = aEventType == nsIAccessibleEvent::EVENT_ASYNCH_HIDE ||
aEventType == nsIAccessibleEvent::EVENT_ASYNCH_SHOW;
// Found an accessible, so fire the show/hide on it and don't look further
// into this subtree.
nsCOMPtr<nsIAccessibleEvent> event =
new nsAccEvent(aEventType, accessible, isAsynch,
new nsAccEvent(aEventType, accessible, aIsAsyncChange,
nsAccEvent::eCoalesceFromSameSubtree);
NS_ENSURE_TRUE(event, NS_ERROR_OUT_OF_MEMORY);
if (aForceIsFromUserInput) {
nsAccEvent::PrepareForEvent(event, aForceIsFromUserInput);
}
if (aDelay) {
if (aDelayedOrNormal == eDelayedEvent)
return FireDelayedAccessibleEvent(event);
}
return FireAccessibleEvent(event);
}
@ -2250,7 +2306,8 @@ nsDocAccessible::FireShowHideEvents(nsIDOMNode *aDOMNode, PRBool aAvoidOnThisNod
for (PRUint32 index = 0; index < count; index++) {
nsCOMPtr<nsIDOMNode> childNode = do_QueryInterface(node->GetChildAt(index));
nsresult rv = FireShowHideEvents(childNode, PR_FALSE, aEventType,
aDelay, aForceIsFromUserInput);
aDelayedOrNormal, aIsAsyncChange,
aForceIsFromUserInput);
NS_ENSURE_SUCCESS(rv, rv);
}

Просмотреть файл

@ -121,15 +121,15 @@ public:
/**
* Non-virtual method to fire a delayed event after a 0 length timeout.
*
* @param aEvent [in] the nsIAccessibleEvent event type
* @param aEventType [in] the nsIAccessibleEvent event type
* @param aDOMNode [in] DOM node the accesible event should be fired for
* @param aAllowDupes [in] rule to process an event (see EEventRule constants)
* @param aIsAsynch [in] set to PR_TRUE if this is not being called from
* code synchronous with a DOM event
*/
nsresult FireDelayedToolkitEvent(PRUint32 aEvent, nsIDOMNode *aDOMNode,
nsAccEvent::EEventRule aAllowDupes = nsAccEvent::eRemoveDupes,
PRBool aIsAsynch = PR_FALSE);
nsresult FireDelayedAccessibleEvent(PRUint32 aEventType, nsIDOMNode *aDOMNode,
nsAccEvent::EEventRule aAllowDupes = nsAccEvent::eRemoveDupes,
PRBool aIsAsynch = PR_FALSE);
/**
* Fire accessible event after timeout.
@ -165,11 +165,6 @@ public:
*/
void RemoveAccessNodeFromCache(nsIAccessNode *aAccessNode);
/**
* Fires pending events.
*/
void FlushPendingEvents();
/**
* Fire document load events.
*
@ -225,6 +220,16 @@ protected:
*/
void ARIAAttributeChanged(nsIContent* aContent, nsIAtom* aAttribute);
/**
* Process delayed (pending) events resulted in normal events firing.
*/
void FlushPendingEvents();
/**
* Start the timer to flush delayed (pending) events.
*/
nsresult PreparePendingEventsFlush();
/**
* Fire text changed event for character data changed. The method is used
* from nsIMutationObserver methods.
@ -245,25 +250,38 @@ protected:
* @param aAccessibleForChangeNode, the accessible for that node, or nsnull if none exists
* @param aIsInserting, is aChangeNode being created or shown (vs. removed or hidden)
*/
already_AddRefed<nsIAccessibleTextChangeEvent>
already_AddRefed<nsIAccessibleEvent>
CreateTextChangeEventForNode(nsIAccessible *aContainerAccessible,
nsIDOMNode *aChangeNode,
nsIAccessible *aAccessibleForNode,
PRBool aIsInserting,
PRBool aIsAsynch);
/**
* Fire show/hide events for either the current node if it has an accessible,
* or the first-line accessible descendants of the given node.
*
* @param aDOMNode the given node
* @param aEventType event type to fire an event
* @param aAvoidOnThisNode Call with PR_TRUE the first time to prevent event firing on root node for change
* @param aDelay whether to fire the event on a delay
* @param aForceIsFromUserInput the event is known to be from user input
*/
nsresult FireShowHideEvents(nsIDOMNode *aDOMNode, PRBool aAvoidOnThisNode, PRUint32 aEventType,
PRBool aDelay, PRBool aForceIsFromUserInput);
/**
* Used to define should the event be fired on a delay.
*/
enum EEventFiringType {
eNormalEvent,
eDelayedEvent
};
/**
* Fire show/hide events for either the current node if it has an accessible,
* or the first-line accessible descendants of the given node.
*
* @param aDOMNode [in] the given node
* @param aAvoidOnThisNode [in] call with PR_TRUE the first time to
* prevent event firing on root node for change
* @param aEventType [in] event type to fire an event
* @param aDelayedOrNormal [in] whether to fire the event on a delay
* @param aIsAsyncChange [in] whether casual change is async
* @param aForceIsFromUserInput [in] the event is known to be from user input
*/
nsresult FireShowHideEvents(nsIDOMNode *aDOMNode, PRBool aAvoidOnThisNode,
PRUint32 aEventType,
EEventFiringType aDelayedOrNormal,
PRBool aIsAsyncChange,
PRBool aForceIsFromUserInput);
/**
* If the given accessible object is a ROLE_ENTRY, fire a value change event for it
@ -278,12 +296,15 @@ protected:
PRUint16 mScrollPositionChangedTicks; // Used for tracking scroll events
PRPackedBool mIsContentLoaded;
PRPackedBool mIsLoadCompleteFired;
nsCOMArray<nsIAccessibleEvent> mEventsToFire;
protected:
PRBool mIsAnchor;
PRBool mIsAnchorJumped;
PRBool mInFlushPendingEvents;
PRBool mInFlushPendingEvents;
PRBool mFireEventTimerStarted;
nsTArray<nsCOMPtr<nsIAccessibleEvent> > mEventsToFire;
static PRUint32 gLastFocusedAccessiblesState;
static nsIAtom *gLastFocusedFrameType;
};

Просмотреть файл

@ -396,7 +396,8 @@ void nsRootAccessible::TryFireEarlyLoadEvent(nsIDOMNode *aDocNode)
NS_ASSERTION(rootContentTreeItem, "No root content tree item");
if (rootContentTreeItem == treeItem) {
// No frames or iframes, so we can fire the doc load finished event early
FireDelayedToolkitEvent(nsIAccessibleEvent::EVENT_INTERNAL_LOAD, aDocNode);
FireDelayedAccessibleEvent(nsIAccessibleEvent::EVENT_INTERNAL_LOAD,
aDocNode);
}
}
@ -538,9 +539,9 @@ PRBool nsRootAccessible::FireAccessibleFocusEvent(nsIAccessible *aAccessible,
}
}
FireDelayedToolkitEvent(nsIAccessibleEvent::EVENT_FOCUS,
finalFocusNode, nsAccEvent::eRemoveDupes,
aIsAsynch);
FireDelayedAccessibleEvent(nsIAccessibleEvent::EVENT_FOCUS,
finalFocusNode, nsAccEvent::eRemoveDupes,
aIsAsynch);
return PR_TRUE;
}
@ -683,7 +684,7 @@ nsresult nsRootAccessible::HandleEventWithTarget(nsIDOMEvent* aEvent,
PRBool isEnabled = (state & (nsIAccessibleStates::STATE_CHECKED |
nsIAccessibleStates::STATE_SELECTED)) != 0;
nsCOMPtr<nsIAccessibleStateChangeEvent> accEvent =
nsCOMPtr<nsIAccessibleEvent> accEvent =
new nsAccStateChangeEvent(accessible, nsIAccessibleStates::STATE_CHECKED,
PR_FALSE, isEnabled);
acc->FireAccessibleEvent(accEvent);
@ -699,7 +700,7 @@ nsresult nsRootAccessible::HandleEventWithTarget(nsIDOMEvent* aEvent,
PRBool isEnabled = !!(state & nsIAccessibleStates::STATE_CHECKED);
nsCOMPtr<nsIAccessibleStateChangeEvent> accEvent =
nsCOMPtr<nsIAccessibleEvent> accEvent =
new nsAccStateChangeEvent(accessible,
nsIAccessibleStates::STATE_CHECKED,
PR_FALSE, isEnabled);
@ -735,7 +736,7 @@ nsresult nsRootAccessible::HandleEventWithTarget(nsIDOMEvent* aEvent,
PRUint32 state = nsAccUtils::State(accessible); // collapsed/expanded changed
PRBool isEnabled = (state & nsIAccessibleStates::STATE_EXPANDED) != 0;
nsCOMPtr<nsIAccessibleStateChangeEvent> accEvent =
nsCOMPtr<nsIAccessibleEvent> accEvent =
new nsAccStateChangeEvent(accessible, nsIAccessibleStates::STATE_EXPANDED,
PR_FALSE, isEnabled);
return FireAccessibleEvent(accEvent);
@ -893,7 +894,8 @@ nsresult nsRootAccessible::HandleEventWithTarget(nsIDOMEvent* aEvent,
FireCurrentFocusEvent();
}
else if (eventType.EqualsLiteral("ValueChange")) {
FireDelayedToolkitEvent(nsIAccessibleEvent::EVENT_VALUE_CHANGE, aTargetNode, nsAccEvent::eRemoveDupes);
FireDelayedAccessibleEvent(nsIAccessibleEvent::EVENT_VALUE_CHANGE,
aTargetNode, nsAccEvent::eRemoveDupes);
}
#ifdef DEBUG
else if (eventType.EqualsLiteral("mouseover")) {
@ -1091,7 +1093,7 @@ nsRootAccessible::HandlePopupShownEvent(nsIAccessible *aAccessible)
// The accessible for it stays the same no matter where it moves.
// AT's expect to get an EVENT_SHOW for the tooltip.
// In event callback the tooltip's accessible will be ready.
return nsAccUtils::FireAccEvent(nsIAccessibleEvent::EVENT_ASYNCH_SHOW,
return nsAccUtils::FireAccEvent(nsIAccessibleEvent::EVENT_SHOW,
aAccessible);
}
@ -1104,7 +1106,7 @@ nsRootAccessible::HandlePopupShownEvent(nsIAccessible *aAccessible)
PRUint32 comboboxRole = nsAccUtils::Role(comboboxAcc);
if (comboboxRole == nsIAccessibleRole::ROLE_COMBOBOX ||
comboboxRole == nsIAccessibleRole::ROLE_AUTOCOMPLETE) {
nsCOMPtr<nsIAccessibleStateChangeEvent> event =
nsCOMPtr<nsIAccessibleEvent> event =
new nsAccStateChangeEvent(comboboxAcc,
nsIAccessibleStates::STATE_EXPANDED,
PR_FALSE, PR_TRUE);
@ -1148,7 +1150,7 @@ nsRootAccessible::HandlePopupHidingEvent(nsIDOMNode *aNode,
PRUint32 comboboxRole = nsAccUtils::Role(comboboxAcc);
if (comboboxRole == nsIAccessibleRole::ROLE_COMBOBOX ||
comboboxRole == nsIAccessibleRole::ROLE_AUTOCOMPLETE) {
nsCOMPtr<nsIAccessibleStateChangeEvent> event =
nsCOMPtr<nsIAccessibleEvent> event =
new nsAccStateChangeEvent(comboboxAcc,
nsIAccessibleStates::STATE_EXPANDED,
PR_FALSE, PR_FALSE);

Просмотреть файл

@ -48,9 +48,6 @@ LIBRARY_NAME = accessibility_html_s
LIBXUL_LIBRARY = 1
ifeq ($(MOZ_WIDGET_TOOLKIT),gtk2)
REQUIRES += editor
endif
CPPSRCS = \
nsHTMLAreaAccessible.cpp \

Разница между файлами не показана из-за своего большого размера Загрузить разницу

Просмотреть файл

@ -39,15 +39,17 @@
#ifndef _nsHTMLTableAccessible_H_
#define _nsHTMLTableAccessible_H_
#include "nsBaseWidgetAccessible.h"
#include "nsHyperTextAccessibleWrap.h"
#include "nsIAccessibleTable.h"
class nsITableLayout;
class nsITableCellLayout;
/**
* HTML table cell accessible (html:td).
*/
class nsHTMLTableCellAccessible : public nsHyperTextAccessibleWrap
class nsHTMLTableCellAccessible : public nsHyperTextAccessibleWrap,
public nsIAccessibleTableCell
{
public:
nsHTMLTableCellAccessible(nsIDOMNode* aDomNode, nsIWeakReference* aShell);
@ -55,78 +57,54 @@ public:
// nsISupports
NS_DECL_ISUPPORTS_INHERITED
// nsIAccessible
NS_IMETHOD GetRelationByType(PRUint32 aRelationType,
nsIAccessibleRelation **aRelation);
// nsIAccessibleTableCell
NS_DECL_NSIACCESSIBLETABLECELL
// nsAccessible
virtual nsresult GetRoleInternal(PRUint32 *aRole);
virtual nsresult GetStateInternal(PRUint32 *aState, PRUint32 *aExtraState);
virtual nsresult GetAttributesInternal(nsIPersistentProperties *aAttributes);
protected:
/**
* Return host table accessible.
*/
already_AddRefed<nsIAccessibleTable> GetTableAccessible();
/**
* Return nsITableCellLayout of the table cell frame.
*/
nsITableCellLayout* GetCellLayout();
/**
* Return row and column indices of the cell.
*/
nsresult GetCellIndexes(PRInt32& aRowIdx, PRInt32& aColIdx);
/**
* Search hint enum constants. Used by FindCellsForRelation method.
* Return an array of row or column header cells.
*/
enum {
// search for header cells, up-left direction search
eHeadersForCell,
// search for row header cell, right direction search
eCellsForRowHeader,
// search for column header cell, down direction search
eCellsForColumnHeader
};
/**
* Add found cells as relation targets.
*
* @param aSearchHint [in] enum constan defined above, defines an
* algorithm to search cells
* @param aRelationType [in] relation type
* @param aRelation [in, out] relation object
*/
nsresult FindCellsForRelation(PRInt32 aSearchHint, PRUint32 aRelationType,
nsIAccessibleRelation **aRelation);
/**
* Return the cell or header cell at the given row and column.
*
* @param aTableAcc [in] table accessible the search is prepared in
* @param aAnchorCell [in] anchor cell, found cell should be different
* from it
* @param aRowIdx [in] row index
* @param aColIdx [in] column index
* @param aLookForHeader [in] flag specifies if found cell must be a header
* @return found cell content
*/
nsIContent* FindCell(nsHTMLTableAccessible *aTableAcc, nsIContent *aAnchorCell,
PRInt32 aRowIdx, PRInt32 aColIdx,
PRInt32 aLookForHeader);
nsresult GetHeaderCells(PRInt32 aRowOrColumnHeaderCell,
nsIArray **aHeaderCells);
};
/**
* HTML table row/column header accessible (html:th or html:td@scope).
*/
class nsHTMLTableHeaderAccessible : public nsHTMLTableCellAccessible
class nsHTMLTableHeaderCellAccessible : public nsHTMLTableCellAccessible
{
public:
nsHTMLTableHeaderAccessible(nsIDOMNode* aDomNode, nsIWeakReference* aShell);
nsHTMLTableHeaderCellAccessible(nsIDOMNode* aDomNode,
nsIWeakReference* aShell);
// nsAccessible
virtual nsresult GetRoleInternal(PRUint32 *aRole);
// nsIAccessible
NS_IMETHOD GetRelationByType(PRUint32 aRelationType,
nsIAccessibleRelation **aRelation);
};
/**
* HTML table accessible.
* HTML table accessible (html:table).
*/
// To turn on table debugging descriptions define SHOW_LAYOUT_HEURISTIC
@ -184,33 +162,40 @@ public:
*/
nsresult GetCellAt(PRInt32 aRowIndex, PRInt32 aColIndex,
nsIDOMElement* &aCell);
/**
* Return nsITableLayout for the frame of the accessible table.
*/
nsITableLayout* GetTableLayout();
protected:
/**
* Selects or unselects row or column.
*
* @param aIndex - index of row or column to be selected
* @param aTarget - indicates what should be selected, either row or column
* (see nsISelectionPrivate)
* @param aDoSelect - indicates whether row or column should selected or
* unselected
*/
nsresult SelectRowOrColumn(PRInt32 aIndex, PRUint32 aTarget, PRBool aDoSelect);
/**
* Selects or unselects the cell.
*
* @param aSelection - the selection of document
* @param aDocument - the document that contains the cell
* @param aCellElement - the cell of table
* @param aDoSelect - indicates whether cell should be selected or unselected
*/
nsresult SelectCell(nsISelection *aSelection, nsIDocument *aDocument,
nsIDOMElement *aCellElement, PRBool aDoSelect);
// nsAccessible
virtual void CacheChildren();
nsresult GetTableNode(nsIDOMNode **_retval);
nsresult GetTableLayout(nsITableLayout **aLayoutObject);
// nsHTMLTableAccessible
/**
* Add row or column to selection.
*
* @param aIndex [in] index of row or column to be selected
* @param aTarget [in] indicates what should be selected, either row or column
* (see nsISelectionPrivate)
*/
nsresult AddRowOrColumnToSelection(PRInt32 aIndex, PRUint32 aTarget);
/**
* Removes rows or columns at the given index or outside it from selection.
*
* @param aIndex [in] row or column index
* @param aTarget [in] indicates whether row or column should unselected
* @param aIsOuter [in] indicates whether all rows or column excepting
* the given one should be unselected or the given one
* should be unselected only
*/
nsresult RemoveRowsOrColumnsFromSelection(PRInt32 aIndex,
PRUint32 aTarget,
PRBool aIsOuter);
/**
* Return true if table has an element with the given tag name.
@ -230,23 +215,9 @@ NS_DEFINE_STATIC_IID_ACCESSOR(nsHTMLTableAccessible,
NS_TABLEACCESSIBLE_IMPL_CID)
class nsHTMLTableHeadAccessible : public nsHTMLTableAccessible
{
public:
NS_DECL_ISUPPORTS_INHERITED
nsHTMLTableHeadAccessible(nsIDOMNode *aDomNode, nsIWeakReference *aShell);
/* nsIAccessibleTable */
NS_IMETHOD GetCaption(nsIAccessible **aCaption);
NS_IMETHOD GetSummary(nsAString &aSummary);
NS_IMETHOD GetColumnHeader(nsIAccessibleTable **aColumnHeader);
NS_IMETHOD GetRows(PRInt32 *aRows);
// nsAccessible
virtual nsresult GetRoleInternal(PRUint32 *aRole);
};
/**
* HTML caption accessible (html:caption).
*/
class nsHTMLCaptionAccessible : public nsHyperTextAccessibleWrap
{
public:

Просмотреть файл

@ -65,7 +65,8 @@ EXPORTS = \
nsDocAccessibleWrap.h \
nsRootAccessibleWrap.h \
nsXULMenuAccessibleWrap.h \
nsXULTreeAccessibleWrap.h \
nsXULListboxAccessibleWrap.h \
nsXULTreeGridAccessibleWrap.h \
nsHyperTextAccessibleWrap.h \
nsHTMLImageAccessibleWrap.h \
nsHTMLTableAccessibleWrap.h \

Просмотреть файл

@ -44,6 +44,7 @@
#include "nsARIAGridAccessible.h"
typedef class nsARIAGridAccessible nsARIAGridAccessibleWrap;
typedef class nsARIAGridCellAccessible nsARIAGridCellAccessibleWrap;
#endif

Просмотреть файл

@ -44,8 +44,8 @@
#include "nsHTMLTableAccessible.h"
typedef class nsHTMLTableAccessible nsHTMLTableAccessibleWrap;
typedef class nsHTMLTableHeadAccessible nsHTMLTableHeadAccessibleWrap;
typedef class nsHTMLTableCellAccessible nsHTMLTableCellAccessibleWrap;
typedef class nsHTMLTableHeaderCellAccessible nsHTMLTableHeaderCellAccessibleWrap;
#endif

Просмотреть файл

@ -0,0 +1,47 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Mozilla Corporation.
* Portions created by the Initial Developer are Copyright (C) 2009
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Alexander Surkov <surkov.alexander@gmail.com> (original author)
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#ifndef __nsXULListboxAccessibleWrap_h__
#define __nsXULListboxAccessibleWrap_h__
#include "nsXULListboxAccessible.h"
typedef class nsXULListboxAccessible nsXULListboxAccessibleWrap;
typedef class nsXULListCellAccessible nsXULListCellAccessibleWrap;
#endif

Просмотреть файл

@ -35,11 +35,12 @@
*
* ***** END LICENSE BLOCK ***** */
#ifndef __nsXULTreeAccessibleWrap_h__
#define __nsXULTreeAccessibleWrap_h__
#ifndef __nsXULTreeGridAccessibleWrap_h__
#define __nsXULTreeGridAccessibleWrap_h__
#include "nsXULTreeGridAccessible.h"
typedef class nsXULTreeGridAccessible nsXULTreeGridAccessibleWrap;
typedef class nsXULTreeColumnsAccessible nsXULTreeColumnsAccessibleWrap;
typedef class nsXULTreeGridAccessible nsXULTreeGridAccessibleWrap;
typedef class nsXULTreeGridCellAccessible nsXULTreeGridCellAccessibleWrap;
#endif

Просмотреть файл

@ -96,7 +96,7 @@ __try {
return E_FAIL;
void *instancePtr = NULL;
rv = winAccessNode->QueryNativeInterface(IID_IUnknown, &instancePtr);
rv = winAccessNode->QueryNativeInterface(IID_IUnknown, &instancePtr);
if (NS_FAILED(rv))
return E_FAIL;

Просмотреть файл

@ -42,11 +42,13 @@
#include "Accessible2.h"
#include "AccessibleTable_i.c"
#include "AccessibleTable2_i.c"
#include "nsIAccessible.h"
#include "nsIAccessibleTable.h"
#include "nsIWinAccessNode.h"
#include "nsAccessNodeWrap.h"
#include "nsWinUtils.h"
#include "nsCOMPtr.h"
#include "nsString.h"
@ -67,9 +69,16 @@ CAccessibleTable::QueryInterface(REFIID iid, void** ppv)
return S_OK;
}
if (IID_IAccessibleTable2 == iid) {
*ppv = static_cast<IAccessibleTable2*>(this);
(reinterpret_cast<IUnknown*>(*ppv))->AddRef();
return S_OK;
}
return E_NOINTERFACE;
}
////////////////////////////////////////////////////////////////////////////////
// IAccessibleTable
STDMETHODIMP
@ -85,7 +94,7 @@ __try {
return E_FAIL;
nsCOMPtr<nsIAccessible> cell;
nsresult rv = tableAcc->CellRefAt(aRow, aColumn, getter_AddRefs(cell));
nsresult rv = tableAcc->GetCellAt(aRow, aColumn, getter_AddRefs(cell));
if (NS_FAILED(rv))
return GetHRESULT(rv);
@ -153,14 +162,15 @@ __try {
return E_FAIL;
PRInt32 childIndex = 0;
nsresult rv = tableAcc->GetIndexAt(aRowIndex, aColumnIndex, &childIndex);
nsresult rv = tableAcc->GetCellIndexAt(aRowIndex, aColumnIndex, &childIndex);
if (NS_FAILED(rv))
return GetHRESULT(rv);
*aChildIndex = childIndex;
return S_OK;
} __except(nsAccessNodeWrap::FilterA11yExceptions(::GetExceptionCode(), GetExceptionInformation())) { }
} __except(nsAccessNodeWrap::FilterA11yExceptions(::GetExceptionCode(),
GetExceptionInformation())) { }
return E_FAIL;
}
@ -220,37 +230,11 @@ CAccessibleTable::get_columnHeader(IAccessibleTable **aAccessibleTable,
{
__try {
*aAccessibleTable = NULL;
*aStartingRowIndex = -1;
// XXX: starting row index is always 0.
*aStartingRowIndex = 0;
nsCOMPtr<nsIAccessibleTable> tableAcc(do_QueryInterface(this));
NS_ASSERTION(tableAcc, CANT_QUERY_ASSERTION_MSG);
if (!tableAcc)
return E_FAIL;
nsCOMPtr<nsIAccessibleTable> header;
nsresult rv = tableAcc->GetColumnHeader(getter_AddRefs(header));
if (NS_FAILED(rv))
return GetHRESULT(rv);
if (!header)
return S_FALSE;
nsCOMPtr<nsIWinAccessNode> winAccessNode(do_QueryInterface(header));
if (!winAccessNode)
return E_FAIL;
void *instancePtr = NULL;
rv = winAccessNode->QueryNativeInterface(IID_IAccessibleTable, &instancePtr);
if (NS_FAILED(rv))
return GetHRESULT(rv);
*aAccessibleTable = static_cast<IAccessibleTable*>(instancePtr);
return S_OK;
} __except(nsAccessNodeWrap::FilterA11yExceptions(::GetExceptionCode(), GetExceptionInformation())) { }
return E_FAIL;
} __except(nsAccessNodeWrap::FilterA11yExceptions(::GetExceptionCode(),
GetExceptionInformation())) {}
return E_NOTIMPL;
}
STDMETHODIMP
@ -265,14 +249,15 @@ __try {
return E_FAIL;
PRInt32 columnIndex = 0;
nsresult rv = tableAcc->GetColumnAtIndex(aChildIndex, &columnIndex);
nsresult rv = tableAcc->GetColumnIndexAt(aChildIndex, &columnIndex);
if (NS_FAILED(rv))
return GetHRESULT(rv);
*aColumnIndex = columnIndex;
return S_OK;
} __except(nsAccessNodeWrap::FilterA11yExceptions(::GetExceptionCode(), GetExceptionInformation())) { }
} __except(nsAccessNodeWrap::FilterA11yExceptions(::GetExceptionCode(),
GetExceptionInformation())) {}
return E_FAIL;
}
@ -288,14 +273,15 @@ __try {
return E_FAIL;
PRInt32 columnCount = 0;
nsresult rv = tableAcc->GetColumns(&columnCount);
nsresult rv = tableAcc->GetColumnCount(&columnCount);
if (NS_FAILED(rv))
return GetHRESULT(rv);
*aColumnCount = columnCount;
return S_OK;
} __except(nsAccessNodeWrap::FilterA11yExceptions(::GetExceptionCode(), GetExceptionInformation())) { }
} __except(nsAccessNodeWrap::FilterA11yExceptions(::GetExceptionCode(),
GetExceptionInformation())) {}
return E_FAIL;
}
@ -311,14 +297,15 @@ __try {
return E_FAIL;
PRInt32 rowCount = 0;
nsresult rv = tableAcc->GetRows(&rowCount);
nsresult rv = tableAcc->GetRowCount(&rowCount);
if (NS_FAILED(rv))
return GetHRESULT(rv);
*aRowCount = rowCount;
return S_OK;
} __except(nsAccessNodeWrap::FilterA11yExceptions(::GetExceptionCode(), GetExceptionInformation())) { }
} __except(nsAccessNodeWrap::FilterA11yExceptions(::GetExceptionCode(),
GetExceptionInformation())) {}
return E_FAIL;
}
@ -334,7 +321,7 @@ __try {
return E_FAIL;
PRUint32 count = 0;
nsresult rv = tableAcc->GetSelectedCellsCount(&count);
nsresult rv = tableAcc->GetSelectedCellCount(&count);
if (NS_FAILED(rv))
return GetHRESULT(rv);
@ -357,7 +344,7 @@ __try {
return E_FAIL;
PRUint32 count = 0;
nsresult rv = tableAcc->GetSelectedColumnsCount(&count);
nsresult rv = tableAcc->GetSelectedColumnCount(&count);
if (NS_FAILED(rv))
return GetHRESULT(rv);
@ -380,7 +367,7 @@ __try {
return E_FAIL;
PRUint32 count = 0;
nsresult rv = tableAcc->GetSelectedRowsCount(&count);
nsresult rv = tableAcc->GetSelectedRowCount(&count);
if (NS_FAILED(rv))
return GetHRESULT(rv);
@ -446,38 +433,11 @@ CAccessibleTable::get_rowHeader(IAccessibleTable **aAccessibleTable,
{
__try {
*aAccessibleTable = NULL;
*aStartingColumnIndex = -1;
// XXX: starting column index is always 0.
*aStartingColumnIndex = 0;
nsCOMPtr<nsIAccessibleTable> tableAcc(do_QueryInterface(this));
NS_ASSERTION(tableAcc, CANT_QUERY_ASSERTION_MSG);
if (!tableAcc)
return E_FAIL;
nsCOMPtr<nsIAccessibleTable> header;
nsresult rv = tableAcc->GetRowHeader(getter_AddRefs(header));
if (NS_FAILED(rv))
return GetHRESULT(rv);
if (!header)
return S_FALSE;
nsCOMPtr<nsIWinAccessNode> winAccessNode(do_QueryInterface(header));
if (!winAccessNode)
return E_FAIL;
void *instancePtr = NULL;
rv = winAccessNode->QueryNativeInterface(IID_IAccessibleTable,
&instancePtr);
if (NS_FAILED(rv))
return GetHRESULT(rv);
*aAccessibleTable = static_cast<IAccessibleTable*>(instancePtr);
return S_OK;
} __except(nsAccessNodeWrap::FilterA11yExceptions(::GetExceptionCode(), GetExceptionInformation())) { }
return E_FAIL;
} __except(nsAccessNodeWrap::FilterA11yExceptions(::GetExceptionCode(),
GetExceptionInformation())) {}
return E_NOTIMPL;
}
STDMETHODIMP
@ -492,14 +452,15 @@ __try {
return E_FAIL;
PRInt32 rowIndex = 0;
nsresult rv = tableAcc->GetRowAtIndex(aChildIndex, &rowIndex);
nsresult rv = tableAcc->GetRowIndexAt(aChildIndex, &rowIndex);
if (NS_FAILED(rv))
return GetHRESULT(rv);
*aRowIndex = rowIndex;
return S_OK;
} __except(nsAccessNodeWrap::FilterA11yExceptions(::GetExceptionCode(), GetExceptionInformation())) { }
} __except(nsAccessNodeWrap::FilterA11yExceptions(::GetExceptionCode(),
GetExceptionInformation())) {}
return E_FAIL;
}
@ -508,8 +469,10 @@ CAccessibleTable::get_selectedChildren(long aMaxChildren, long **aChildren,
long *aNChildren)
{
__try {
return GetSelectedItems(aMaxChildren, aChildren, aNChildren, ITEMSTYPE_CELLS);
} __except(nsAccessNodeWrap::FilterA11yExceptions(::GetExceptionCode(), GetExceptionInformation())) { }
return GetSelectedItems(aChildren, aNChildren, ITEMSTYPE_CELLS);
} __except(nsAccessNodeWrap::FilterA11yExceptions(::GetExceptionCode(),
GetExceptionInformation())) {}
return E_FAIL;
}
@ -518,8 +481,10 @@ CAccessibleTable::get_selectedColumns(long aMaxColumns, long **aColumns,
long *aNColumns)
{
__try {
return GetSelectedItems(aMaxColumns, aColumns, aNColumns, ITEMSTYPE_COLUMNS);
} __except(nsAccessNodeWrap::FilterA11yExceptions(::GetExceptionCode(), GetExceptionInformation())) { }
return GetSelectedItems(aColumns, aNColumns, ITEMSTYPE_COLUMNS);
} __except(nsAccessNodeWrap::FilterA11yExceptions(::GetExceptionCode(),
GetExceptionInformation())) {}
return E_FAIL;
}
@ -527,8 +492,10 @@ STDMETHODIMP
CAccessibleTable::get_selectedRows(long aMaxRows, long **aRows, long *aNRows)
{
__try {
return GetSelectedItems(aMaxRows, aRows, aNRows, ITEMSTYPE_ROWS);
} __except(nsAccessNodeWrap::FilterA11yExceptions(::GetExceptionCode(), GetExceptionInformation())) { }
return GetSelectedItems(aRows, aNRows, ITEMSTYPE_ROWS);
} __except(nsAccessNodeWrap::FilterA11yExceptions(::GetExceptionCode(),
GetExceptionInformation())) {}
return E_FAIL;
}
@ -700,12 +667,12 @@ __try {
return E_FAIL;
PRInt32 row = -1;
nsresult rv = tableAcc->GetRowAtIndex(aIndex, &row);
nsresult rv = tableAcc->GetRowIndexAt(aIndex, &row);
if (NS_FAILED(rv))
return GetHRESULT(rv);
PRInt32 column = -1;
rv = tableAcc->GetColumnAtIndex(aIndex, &column);
rv = tableAcc->GetColumnIndexAt(aIndex, &column);
if (NS_FAILED(rv))
return GetHRESULT(rv);
@ -744,11 +711,71 @@ __try {
return E_NOTIMPL;
}
// CAccessibleTable
////////////////////////////////////////////////////////////////////////////////
// IAccessibleTable2
STDMETHODIMP
CAccessibleTable::get_cellAt(long row, long column, IUnknown **cell)
{
return get_accessibleAt(row, column, cell);
}
STDMETHODIMP
CAccessibleTable::get_nSelectedCells(long *cellCount)
{
return get_nSelectedChildren(cellCount);
}
STDMETHODIMP
CAccessibleTable::get_selectedCells(IUnknown ***cells, long *nSelectedCells)
{
__try {
nsCOMPtr<nsIAccessibleTable> tableAcc(do_QueryInterface(this));
NS_ASSERTION(tableAcc, CANT_QUERY_ASSERTION_MSG);
if (!tableAcc)
return E_FAIL;
nsCOMPtr<nsIArray> geckoCells;
nsresult rv = tableAcc->GetSelectedCells(getter_AddRefs(geckoCells));
if (NS_FAILED(rv))
return GetHRESULT(rv);
return nsWinUtils::ConvertToIA2Array(geckoCells, cells, nSelectedCells);
} __except(nsAccessNodeWrap::FilterA11yExceptions(::GetExceptionCode(),
GetExceptionInformation())) {}
return E_FAIL;
}
STDMETHODIMP
CAccessibleTable::get_selectedColumns(long **aColumns, long *aNColumns)
{
__try {
return GetSelectedItems(aColumns, aNColumns, ITEMSTYPE_COLUMNS);
} __except(nsAccessNodeWrap::FilterA11yExceptions(::GetExceptionCode(),
GetExceptionInformation())) {}
return E_FAIL;
}
STDMETHODIMP
CAccessibleTable::get_selectedRows(long **aRows, long *aNRows)
{
__try {
return GetSelectedItems(aRows, aNRows, ITEMSTYPE_ROWS);
} __except(nsAccessNodeWrap::FilterA11yExceptions(::GetExceptionCode(),
GetExceptionInformation())) {}
return E_FAIL;
}
////////////////////////////////////////////////////////////////////////////////
// CAccessibleTable public
HRESULT
CAccessibleTable::GetSelectedItems(long aMaxItems, long **aItems,
long *aItemsCount, eItemsType aType)
CAccessibleTable::GetSelectedItems(long **aItems, long *aItemsCount,
eItemsType aType)
{
*aItemsCount = 0;
@ -763,13 +790,13 @@ CAccessibleTable::GetSelectedItems(long aMaxItems, long **aItems,
nsresult rv = NS_OK;
switch (aType) {
case ITEMSTYPE_CELLS:
rv = tableAcc->GetSelectedCells(&size, &items);
rv = tableAcc->GetSelectedCellIndices(&size, &items);
break;
case ITEMSTYPE_COLUMNS:
rv = tableAcc->GetSelectedColumns(&size, &items);
rv = tableAcc->GetSelectedColumnIndices(&size, &items);
break;
case ITEMSTYPE_ROWS:
rv = tableAcc->GetSelectedRows(&size, &items);
rv = tableAcc->GetSelectedRowIndices(&size, &items);
break;
default:
return E_FAIL;
@ -781,14 +808,12 @@ CAccessibleTable::GetSelectedItems(long aMaxItems, long **aItems,
if (size == 0 || !items)
return S_FALSE;
PRUint32 maxSize = size < static_cast<PRUint32>(aMaxItems) ? size : aMaxItems;
*aItemsCount = maxSize;
*aItems = static_cast<long*>(nsMemory::Alloc((maxSize) * sizeof(long)));
*aItems = static_cast<long*>(nsMemory::Alloc((size) * sizeof(long)));
if (!*aItems)
return E_OUTOFMEMORY;
for (PRUint32 index = 0; index < maxSize; ++index)
*aItemsCount = size;
for (PRUint32 index = 0; index < size; ++index)
(*aItems)[index] = items[index];
nsMemory::Free(items);

Просмотреть файл

@ -44,9 +44,11 @@
#include "nsISupports.h"
#include "AccessibleTable.h"
#include "AccessibleTable2.h"
class CAccessibleTable: public nsISupports,
public IAccessibleTable
public IAccessibleTable,
public IAccessibleTable2
{
public:
@ -170,6 +172,29 @@ public:
virtual /* [propget] */ HRESULT STDMETHODCALLTYPE get_modelChange(
/* [retval][out] */ IA2TableModelChange *modelChange);
// IAccessibleTable2
virtual /* [propget] */ HRESULT STDMETHODCALLTYPE get_cellAt(
/* [in] */ long row,
/* [in] */ long column,
/* [out, retval] */ IUnknown **cell);
virtual /* [propget] */ HRESULT STDMETHODCALLTYPE get_nSelectedCells(
/* [out, retval] */ long *cellCount);
virtual /* [propget] */ HRESULT STDMETHODCALLTYPE get_selectedCells(
/* [out, size_is(,*nSelectedCells,)] */ IUnknown ***cells,
/* [out, retval] */ long *nSelectedCells);
virtual /* [propget] */ HRESULT STDMETHODCALLTYPE get_selectedColumns(
/* [out, size_is(,*nColumns)] */ long **selectedColumns,
/* [out, retval] */ long *nColumns);
virtual /* [propget] */ HRESULT STDMETHODCALLTYPE get_selectedRows(
/* [out, size_is(,*nRows)] */ long **selectedRows,
/* [out, retval] */ long *nRows);
private:
enum eItemsType {
ITEMSTYPE_CELLS,
@ -177,9 +202,7 @@ private:
ITEMSTYPE_ROWS
};
HRESULT GetSelectedItems(long aMaxItems, long **aItems, long *aItemsCount,
eItemsType aType);
HRESULT GetSelectedItems(long **aItems, long *aItemsCount, eItemsType aType);
};
#endif

Просмотреть файл

@ -0,0 +1,341 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim:expandtab:shiftwidth=2:tabstop=2:
*/
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Mozilla Corporation.
* Portions created by the Initial Developer are Copyright (C) 2009
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Alexander Surkov <surkov.alexander@gmail.com> (original author)
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#include "CAccessibleTableCell.h"
#include "Accessible2.h"
#include "AccessibleTable2_i.c"
#include "AccessibleTableCell_i.c"
#include "nsIAccessible.h"
#include "nsIAccessibleTable.h"
#include "nsIWinAccessNode.h"
#include "nsAccessNodeWrap.h"
#include "nsWinUtils.h"
#include "nsCOMPtr.h"
#include "nsString.h"
#define TABLECELL_INTERFACE_UNSUPPORTED_MSG \
"Subclass of CAccessibleTableCell doesn't implement nsIAccessibleTableCell"\
// IUnknown
STDMETHODIMP
CAccessibleTableCell::QueryInterface(REFIID iid, void** ppv)
{
*ppv = NULL;
if (IID_IAccessibleTableCell == iid) {
*ppv = static_cast<IAccessibleTableCell*>(this);
(reinterpret_cast<IUnknown*>(*ppv))->AddRef();
return S_OK;
}
return E_NOINTERFACE;
}
////////////////////////////////////////////////////////////////////////////////
// IAccessibleTableCell
STDMETHODIMP
CAccessibleTableCell::get_table(IUnknown **table)
{
__try {
nsCOMPtr<nsIAccessibleTableCell> tableCell(do_QueryInterface(this));
NS_ASSERTION(tableCell, TABLECELL_INTERFACE_UNSUPPORTED_MSG);
if (!tableCell)
return E_FAIL;
nsCOMPtr<nsIAccessibleTable> geckoTable;
nsresult rv = tableCell->GetTable(getter_AddRefs(geckoTable));
if (NS_FAILED(rv))
return GetHRESULT(rv);
nsCOMPtr<nsIWinAccessNode> winAccessNode = do_QueryInterface(geckoTable);
if (!winAccessNode)
return E_FAIL;
void *instancePtr = NULL;
rv = winAccessNode->QueryNativeInterface(IID_IUnknown, &instancePtr);
if (NS_FAILED(rv))
return GetHRESULT(rv);
*table = static_cast<IUnknown*>(instancePtr);
return S_OK;
} __except(nsAccessNodeWrap::FilterA11yExceptions(::GetExceptionCode(),
GetExceptionInformation())) {}
return E_FAIL;
}
STDMETHODIMP
CAccessibleTableCell::get_columnExtent(long *nColumnsSpanned)
{
__try {
*nColumnsSpanned = 0;
nsCOMPtr<nsIAccessibleTableCell> tableCell(do_QueryInterface(this));
NS_ASSERTION(tableCell, TABLECELL_INTERFACE_UNSUPPORTED_MSG);
if (!tableCell)
return E_FAIL;
PRInt32 columnsSpanned = 0;
nsresult rv = tableCell->GetColumnExtent(&columnsSpanned);
if (NS_SUCCEEDED(rv)) {
*nColumnsSpanned = columnsSpanned;
return S_OK;
}
return GetHRESULT(rv);
} __except(nsAccessNodeWrap::FilterA11yExceptions(::GetExceptionCode(),
GetExceptionInformation())) {}
return E_FAIL;
}
STDMETHODIMP
CAccessibleTableCell::get_columnHeaderCells(IUnknown ***cellAccessibles,
long *nColumnHeaderCells)
{
__try {
nsCOMPtr<nsIAccessibleTableCell> tableCell(do_QueryInterface(this));
NS_ASSERTION(tableCell, TABLECELL_INTERFACE_UNSUPPORTED_MSG);
if (!tableCell)
return E_FAIL;
nsCOMPtr<nsIArray> headerCells;
nsresult rv = tableCell->GetColumnHeaderCells(getter_AddRefs(headerCells));
if (NS_FAILED(rv))
return GetHRESULT(rv);
return nsWinUtils::ConvertToIA2Array(headerCells, cellAccessibles,
nColumnHeaderCells);
} __except(nsAccessNodeWrap::FilterA11yExceptions(::GetExceptionCode(),
GetExceptionInformation())) {}
return E_FAIL;
}
STDMETHODIMP
CAccessibleTableCell::get_columnIndex(long *columnIndex)
{
__try {
*columnIndex = -1;
nsCOMPtr<nsIAccessibleTableCell> tableCell(do_QueryInterface(this));
NS_ASSERTION(tableCell, TABLECELL_INTERFACE_UNSUPPORTED_MSG);
if (!tableCell)
return E_FAIL;
PRInt32 colIdx = -1;
nsresult rv = tableCell->GetColumnIndex(&colIdx);
if (NS_SUCCEEDED(rv)) {
*columnIndex = colIdx;
return S_OK;
}
return GetHRESULT(rv);
} __except(nsAccessNodeWrap::FilterA11yExceptions(::GetExceptionCode(),
GetExceptionInformation())) {}
return E_FAIL;
}
STDMETHODIMP
CAccessibleTableCell::get_rowExtent(long *nRowsSpanned)
{
__try {
*nRowsSpanned = 0;
nsCOMPtr<nsIAccessibleTableCell> tableCell(do_QueryInterface(this));
NS_ASSERTION(tableCell, TABLECELL_INTERFACE_UNSUPPORTED_MSG);
if (!tableCell)
return E_FAIL;
PRInt32 rowsSpanned = 0;
nsresult rv = tableCell->GetRowExtent(&rowsSpanned);
if (NS_SUCCEEDED(rv)) {
*nRowsSpanned = rowsSpanned;
return S_OK;
}
return GetHRESULT(rv);
} __except(nsAccessNodeWrap::FilterA11yExceptions(::GetExceptionCode(),
GetExceptionInformation())) {}
return E_FAIL;
}
STDMETHODIMP
CAccessibleTableCell::get_rowHeaderCells(IUnknown ***cellAccessibles,
long *nRowHeaderCells)
{
__try {
nsCOMPtr<nsIAccessibleTableCell> tableCell(do_QueryInterface(this));
NS_ASSERTION(tableCell, TABLECELL_INTERFACE_UNSUPPORTED_MSG);
if (!tableCell)
return E_FAIL;
nsCOMPtr<nsIArray> headerCells;
nsresult rv = tableCell->GetRowHeaderCells(getter_AddRefs(headerCells));
if (NS_FAILED(rv))
return GetHRESULT(rv);
return nsWinUtils::ConvertToIA2Array(headerCells, cellAccessibles,
nRowHeaderCells);
} __except(nsAccessNodeWrap::FilterA11yExceptions(::GetExceptionCode(),
GetExceptionInformation())) {}
return E_FAIL;
}
STDMETHODIMP
CAccessibleTableCell::get_rowIndex(long *rowIndex)
{
__try {
*rowIndex = -1;
nsCOMPtr<nsIAccessibleTableCell> tableCell(do_QueryInterface(this));
NS_ASSERTION(tableCell, TABLECELL_INTERFACE_UNSUPPORTED_MSG);
if (!tableCell)
return E_FAIL;
PRInt32 rowIdx = -1;
nsresult rv = tableCell->GetRowIndex(&rowIdx);
if (NS_SUCCEEDED(rv)) {
*rowIndex = rowIdx;
return S_OK;
}
return GetHRESULT(rv);
} __except(nsAccessNodeWrap::FilterA11yExceptions(::GetExceptionCode(),
GetExceptionInformation())) {}
return E_FAIL;
}
STDMETHODIMP
CAccessibleTableCell::get_rowColumnExtents(long *row, long *column,
long *rowExtents,
long *columnExtents,
boolean *isSelected)
{
__try {
*row = 0;
*column = 0;
*rowExtents = 0;
*columnExtents = 0;
*isSelected = false;
nsCOMPtr<nsIAccessibleTableCell> tableCell(do_QueryInterface(this));
NS_ASSERTION(tableCell, TABLECELL_INTERFACE_UNSUPPORTED_MSG);
if (!tableCell)
return E_FAIL;
PRInt32 rowIdx = -1;
nsresult rv = tableCell->GetRowIndex(&rowIdx);
if (NS_FAILED(rv))
return GetHRESULT(rv);
PRInt32 columnIdx = -1;
rv = tableCell->GetColumnIndex(&columnIdx);
if (NS_FAILED(rv))
return GetHRESULT(rv);
PRInt32 spannedRows = 0;
rv = tableCell->GetRowExtent(&spannedRows);
if (NS_FAILED(rv))
return GetHRESULT(rv);
PRInt32 spannedColumns = 0;
rv = tableCell->GetColumnExtent(&spannedColumns);
if (NS_FAILED(rv))
return GetHRESULT(rv);
PRBool isSel = PR_FALSE;
rv = tableCell->IsSelected(&isSel);
if (NS_FAILED(rv))
return GetHRESULT(rv);
*row = rowIdx;
*column = columnIdx;
*rowExtents = spannedRows;
*columnExtents = spannedColumns;
*isSelected = isSel;
return S_OK;
} __except(nsAccessNodeWrap::FilterA11yExceptions(::GetExceptionCode(),
GetExceptionInformation())) {}
return E_FAIL;
}
STDMETHODIMP
CAccessibleTableCell::get_isSelected(boolean *isSelected)
{
__try {
*isSelected = false;
nsCOMPtr<nsIAccessibleTableCell> tableCell(do_QueryInterface(this));
NS_ASSERTION(tableCell, TABLECELL_INTERFACE_UNSUPPORTED_MSG);
if (!tableCell)
return E_FAIL;
PRBool isSel = PR_FALSE;
nsresult rv = tableCell->IsSelected(&isSel);
if (NS_SUCCEEDED(rv)) {
*isSelected = isSel;
return S_OK;
}
return GetHRESULT(rv);
} __except(nsAccessNodeWrap::FilterA11yExceptions(::GetExceptionCode(),
GetExceptionInformation())) {}
return E_FAIL;
}

Просмотреть файл

@ -0,0 +1,92 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim:expandtab:shiftwidth=2:tabstop=2:
*/
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Mozilla Corporation.
* Portions created by the Initial Developer are Copyright (C) 2009
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Alexander Surkov <surkov.alexander@gmail.com> (original author)
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#ifndef _ACCESSIBLE_TABLECELL_H
#define _ACCESSIBLE_TABLECELL_H
#include "nsISupports.h"
#include "AccessibleTableCell.h"
class CAccessibleTableCell: public nsISupports,
public IAccessibleTableCell
{
public:
// IUnknown
STDMETHODIMP QueryInterface(REFIID, void**);
// IAccessibleTableCell
virtual /* [propget] */ HRESULT STDMETHODCALLTYPE get_table(
/* [out, retval] */ IUnknown **table);
virtual /* [propget] */ HRESULT STDMETHODCALLTYPE get_columnExtent(
/* [out, retval] */ long *nColumnsSpanned);
virtual /* [propget] */ HRESULT STDMETHODCALLTYPE get_columnHeaderCells(
/* [out, size_is(,*nColumnHeaderCells,)] */ IUnknown ***cellAccessibles,
/* [out, retval] */ long *nColumnHeaderCells);
virtual /* [propget] */ HRESULT STDMETHODCALLTYPE get_columnIndex(
/* [out, retval] */ long *columnIndex);
virtual /* [propget] */ HRESULT STDMETHODCALLTYPE get_rowExtent(
/* [out, retval] */ long *nRowsSpanned);
virtual /* [propget] */ HRESULT STDMETHODCALLTYPE get_rowHeaderCells(
/* [out, size_is(,*nRowHeaderCells,)] */ IUnknown ***cellAccessibles,
/* [out, retval] */ long *nRowHeaderCells);
virtual /* [propget] */ HRESULT STDMETHODCALLTYPE get_rowIndex(
/* [out, retval] */ long *rowIndex);
virtual /* [propget] */ HRESULT STDMETHODCALLTYPE get_rowColumnExtents(
/* [out] */ long *row,
/* [out] */ long *column,
/* [out] */ long *rowExtents,
/* [out] */ long *columnExtents,
/* [out, retval] */ boolean *isSelected);
virtual /* [propget] */ HRESULT STDMETHODCALLTYPE get_isSelected(
/* [out, retval] */ boolean *isSelected);
};
#endif

Просмотреть файл

@ -55,12 +55,14 @@ CPPSRCS = \
nsHTMLWin32ObjectAccessible.cpp \
nsARIAGridAccessibleWrap.cpp \
nsXULMenuAccessibleWrap.cpp \
nsXULTreeAccessibleWrap.cpp \
nsXULListboxAccessibleWrap.cpp \
nsXULTreeGridAccessibleWrap.cpp \
nsHyperTextAccessibleWrap.cpp \
nsHTMLImageAccessibleWrap.cpp \
nsHTMLTableAccessibleWrap.cpp \
nsAccessibleRelationWrap.cpp \
nsApplicationAccessibleWrap.cpp \
nsWinUtils.cpp \
CAccessibleAction.cpp \
CAccessibleImage.cpp \
CAccessibleComponent.cpp \
@ -69,6 +71,7 @@ CPPSRCS = \
CAccessibleHyperlink.cpp \
CAccessibleHypertext.cpp \
CAccessibleTable.cpp \
CAccessibleTableCell.cpp \
CAccessibleValue.cpp \
$(NULL)
@ -81,7 +84,8 @@ EXPORTS = \
nsHTMLWin32ObjectAccessible.h \
nsARIAGridAccessibleWrap.h \
nsXULMenuAccessibleWrap.h \
nsXULTreeAccessibleWrap.h \
nsXULListboxAccessibleWrap.h \
nsXULTreeGridAccessibleWrap.h \
nsHyperTextAccessibleWrap.h \
nsHTMLImageAccessibleWrap.h \
nsHTMLTableAccessibleWrap.h \
@ -95,6 +99,7 @@ EXPORTS = \
CAccessibleHyperlink.h \
CAccessibleHypertext.h \
CAccessibleTable.h \
CAccessibleTableCell.h \
CAccessibleValue.h \
$(NULL)

Просмотреть файл

@ -40,9 +40,25 @@
#include "nsARIAGridAccessibleWrap.h"
////////////////////////////////////////////////////////////////////////////////
// nsARIAGridAccessibleWrap
////////////////////////////////////////////////////////////////////////////////
NS_IMPL_ISUPPORTS_INHERITED0(nsARIAGridAccessibleWrap,
nsARIAGridAccessible)
IMPL_IUNKNOWN_INHERITED1(nsARIAGridAccessibleWrap,
nsAccessibleWrap,
CAccessibleTable);
CAccessibleTable)
////////////////////////////////////////////////////////////////////////////////
// nsARIAGridCellAccessibleWrap
////////////////////////////////////////////////////////////////////////////////
NS_IMPL_ISUPPORTS_INHERITED0(nsARIAGridCellAccessibleWrap,
nsARIAGridCellAccessible)
IMPL_IUNKNOWN_INHERITED1(nsARIAGridCellAccessibleWrap,
nsHyperTextAccessibleWrap,
CAccessibleTableCell)

Просмотреть файл

@ -43,10 +43,11 @@
#include "nsARIAGridAccessible.h"
#include "CAccessibleTable.h"
#include "CAccessibleTableCell.h"
/**
* Accessible for ARIA grid and treegrid implementing IAccessibleTable
* interface.
* IA2 wrapper class for nsARIAGridAccessible implementing IAccessibleTable and
* IAccessibleTable2 interfaces.
*/
class nsARIAGridAccessibleWrap : public nsARIAGridAccessible,
public CAccessibleTable
@ -62,4 +63,22 @@ public:
NS_DECL_ISUPPORTS_INHERITED
};
/**
* IA2 wrapper class for nsARIAGridCellAccessible implementing
* IAccessibleTableCell interface.
*/
class nsARIAGridCellAccessibleWrap : public nsARIAGridCellAccessible,
public CAccessibleTableCell
{
public:
nsARIAGridCellAccessibleWrap(nsIDOMNode* aNode, nsIWeakReference* aShell) :
nsARIAGridCellAccessible(aNode, aShell) {}
// IUnknown
DECL_IUNKNOWN_INHERITED
// nsISupports
NS_DECL_ISUPPORTS_INHERITED
};
#endif

Просмотреть файл

@ -1688,8 +1688,7 @@ nsAccessibleWrap::FirePlatformEvent(nsIAccessibleEvent *aEvent)
// See if we're in a scrollable area with its own window
nsCOMPtr<nsIAccessible> newAccessible;
if (eventType == nsIAccessibleEvent::EVENT_ASYNCH_HIDE ||
eventType == nsIAccessibleEvent::EVENT_DOM_DESTROY) {
if (eventType == nsIAccessibleEvent::EVENT_HIDE) {
// Don't use frame from current accessible when we're hiding that
// accessible.
accessible->GetParent(getter_AddRefs(newAccessible));

Просмотреть файл

@ -70,6 +70,13 @@ Class::QueryInterface(REFIID iid, void** ppv) \
if (SUCCEEDED(hr)) \
return hr; \
#define IMPL_IUNKNOWN_QUERY_ENTRY_COND(Class, Cond) \
if (Cond) { \
hr = Class::QueryInterface(iid, ppv); \
if (SUCCEEDED(hr)) \
return hr; \
} \
#define IMPL_IUNKNOWN_INHERITED0(Class, Super) \
IMPL_IUNKNOWN_QUERY_HEAD(Class) \
IMPL_IUNKNOWN_QUERY_ENTRY(Super) \

Просмотреть файл

@ -49,12 +49,9 @@ const PRUint32 kEVENT_LAST_ENTRY = 0xffffffff;
static const PRUint32 gWinEventMap[] = {
kEVENT_WIN_UNKNOWN, // nsIAccessibleEvent doesn't have 0 constant
EVENT_OBJECT_SHOW, // nsIAccessibleEvent::EVENT_DOM_CREATE
EVENT_OBJECT_HIDE, // nsIAccessibleEvent::EVENT_DOM_DESTROY
kEVENT_WIN_UNKNOWN, // nsIAccessibleEvent::EVENT_DOM_SIGNIFICANT_CHANGE
EVENT_OBJECT_SHOW, // nsIAccessibleEvent::EVENT_ASYNCH_SHOW
EVENT_OBJECT_HIDE, // nsIAccessibleEvent::EVENT_ASYNCH_HIDE
kEVENT_WIN_UNKNOWN, // nsIAccessibleEvent::EVENT_ASYNCH_LAYOUT_CHANGE
EVENT_OBJECT_SHOW, // nsIAccessibleEvent::EVENT_SHOW
EVENT_OBJECT_HIDE, // nsIAccessibleEvent::EVENT_HIDE
EVENT_OBJECT_REORDER, // nsIAccessibleEvent::EVENT_REORDER
IA2_EVENT_ACTIVE_DECENDENT_CHANGED, // nsIAccessibleEvent::EVENT_ACTIVE_DECENDENT_CHANGED
EVENT_OBJECT_FOCUS, // nsIAccessibleEvent::EVENT_FOCUS
EVENT_OBJECT_STATECHANGE, // nsIAccessibleEvent::EVENT_STATE_CHANGE
@ -140,7 +137,6 @@ static const PRUint32 gWinEventMap[] = {
IA2_EVENT_OBJECT_ATTRIBUTE_CHANGED, // nsIAccessibleEvent::EVENT_OBJECT_ATTRIBUTE_CHANGED
IA2_EVENT_PAGE_CHANGED, // nsIAccessibleEvent::EVENT_PAGE_CHANGED
kEVENT_WIN_UNKNOWN, // nsIAccessibleEvent::EVENT_INTERNAL_LOAD
EVENT_OBJECT_REORDER, // nsIAccessibleEvent::EVENT_REORDER
kEVENT_LAST_ENTRY // nsIAccessibleEvent::EVENT_LAST_ENTRY
};

Просмотреть файл

@ -40,17 +40,37 @@
#include "nsHTMLTableAccessibleWrap.h"
////////////////////////////////////////////////////////////////////////////////
// nsHTMLTableAccessibleWrap
////////////////////////////////////////////////////////////////////////////////
NS_IMPL_ISUPPORTS_INHERITED0(nsHTMLTableAccessibleWrap,
nsHTMLTableAccessible)
IMPL_IUNKNOWN_INHERITED1(nsHTMLTableAccessibleWrap,
nsAccessibleWrap,
CAccessibleTable);
CAccessibleTable)
NS_IMPL_ISUPPORTS_INHERITED0(nsHTMLTableHeadAccessibleWrap,
nsHTMLTableHeadAccessible)
IMPL_IUNKNOWN_INHERITED1(nsHTMLTableHeadAccessibleWrap,
nsAccessibleWrap,
CAccessibleTable);
////////////////////////////////////////////////////////////////////////////////
// nsHTMLTableCellAccessibleWrap
////////////////////////////////////////////////////////////////////////////////
NS_IMPL_ISUPPORTS_INHERITED0(nsHTMLTableCellAccessibleWrap,
nsHTMLTableCellAccessible)
IMPL_IUNKNOWN_INHERITED1(nsHTMLTableCellAccessibleWrap,
nsHyperTextAccessibleWrap,
CAccessibleTableCell)
////////////////////////////////////////////////////////////////////////////////
// nsHTMLTableCellAccessibleWrap
////////////////////////////////////////////////////////////////////////////////
NS_IMPL_ISUPPORTS_INHERITED0(nsHTMLTableHeaderCellAccessibleWrap,
nsHTMLTableHeaderCellAccessible)
IMPL_IUNKNOWN_INHERITED1(nsHTMLTableHeaderCellAccessibleWrap,
nsHyperTextAccessibleWrap,
CAccessibleTableCell)

Просмотреть файл

@ -42,8 +42,14 @@
#define _NSHTMLTABLEACCESSIBLEWRAP_H
#include "nsHTMLTableAccessible.h"
#include "CAccessibleTable.h"
#include "CAccessibleTable.h"
#include "CAccessibleTableCell.h"
/**
* IA2 wrapper class for nsHTMLTableAccessible implementing IAccessibleTable
* and IAccessibleTable2 interfaces.
*/
class nsHTMLTableAccessibleWrap : public nsHTMLTableAccessible,
public CAccessibleTable
{
@ -58,12 +64,37 @@ public:
NS_DECL_ISUPPORTS_INHERITED
};
class nsHTMLTableHeadAccessibleWrap : public nsHTMLTableHeadAccessible,
public CAccessibleTable
/**
* IA2 wrapper class for nsHTMLTableCellAccessible implementing
* IAccessibleTableCell interface.
*/
class nsHTMLTableCellAccessibleWrap : public nsHTMLTableCellAccessible,
public CAccessibleTableCell
{
public:
nsHTMLTableHeadAccessibleWrap(nsIDOMNode* aNode, nsIWeakReference* aShell) :
nsHTMLTableHeadAccessible(aNode, aShell){}
nsHTMLTableCellAccessibleWrap(nsIDOMNode* aNode, nsIWeakReference* aShell) :
nsHTMLTableCellAccessible(aNode, aShell) {}
// IUnknown
DECL_IUNKNOWN_INHERITED
// nsISupports
NS_DECL_ISUPPORTS_INHERITED
};
/**
* IA2 wrapper class for nsHTMLTableHeaderCellAccessible implementing
* IAccessibleTableCell interface.
*/
class nsHTMLTableHeaderCellAccessibleWrap : public nsHTMLTableHeaderCellAccessible,
public CAccessibleTableCell
{
public:
nsHTMLTableHeaderCellAccessibleWrap(nsIDOMNode* aNode,
nsIWeakReference* aShell) :
nsHTMLTableHeaderCellAccessible(aNode, aShell) {}
// IUnknown
DECL_IUNKNOWN_INHERITED

Просмотреть файл

@ -95,8 +95,10 @@ nsHyperTextAccessibleWrap::GetModifiedText(PRBool aGetInsertedText,
if (aGetInsertedText != isInserted)
return NS_OK;
nsCOMPtr<nsIAccessibleEvent> event(do_QueryInterface(gTextEvent));
nsCOMPtr<nsIAccessible> targetAcc;
gTextEvent->GetAccessible(getter_AddRefs(targetAcc));
event->GetAccessible(getter_AddRefs(targetAcc));
if (targetAcc != this)
return NS_OK;

Просмотреть файл

@ -0,0 +1,92 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim:expandtab:shiftwidth=2:tabstop=2:
*/
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Mozilla Corporation.
* Portions created by the Initial Developer are Copyright (C) 2009
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Alexander Surkov <surkov.alexander@gmail.com> (original author)
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#include "nsWinUtils.h"
#include "nsAccessibleWrap.h"
#include "nsIWinAccessNode.h"
#include "nsArrayUtils.h"
HRESULT
nsWinUtils::ConvertToIA2Array(nsIArray *aGeckoArray, IUnknown ***aIA2Array,
long *aIA2ArrayLen)
{
*aIA2Array = NULL;
*aIA2ArrayLen = 0;
PRUint32 length = 0;
nsresult rv = aGeckoArray->GetLength(&length);
if (NS_FAILED(rv))
return GetHRESULT(rv);
*aIA2Array =
static_cast<IUnknown**>(nsMemory::Alloc((length) * sizeof(IUnknown*)));
if (!*aIA2Array)
return E_OUTOFMEMORY;
PRUint32 idx = 0;
for (; idx < length; ++idx) {
nsCOMPtr<nsIWinAccessNode> winAccessNode =
do_QueryElementAt(aGeckoArray, idx, &rv);
if (NS_FAILED(rv))
break;
void *instancePtr = NULL;
nsresult rv = winAccessNode->QueryNativeInterface(IID_IUnknown,
&instancePtr);
if (NS_FAILED(rv))
break;
(*aIA2Array)[idx] = static_cast<IUnknown*>(instancePtr);
}
if (NS_FAILED(rv)) {
for (PRUint32 idx2 = 0; idx2 < idx; idx2++) {
(*aIA2Array)[idx2]->Release();
(*aIA2Array)[idx2] = NULL;
}
nsMemory::Free(*aIA2Array);
return GetHRESULT(rv);
}
*aIA2ArrayLen = length;
return S_OK;
}

Просмотреть файл

@ -1,6 +1,7 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* ***** BEGIN LICENSE BLOCK *****
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim:expandtab:shiftwidth=2:tabstop=2:
*/
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
@ -16,12 +17,12 @@
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 2001
* Mozilla Corporation.
* Portions created by the Initial Developer are Copyright (C) 2009
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Stuart Parmenter <pavlov@netscape.com>
* Alexander Surkov <surkov.alexander@gmail.com> (original author)
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
@ -37,25 +38,23 @@
*
* ***** END LICENSE BLOCK ***** */
#include "nsISupports.idl"
#ifndef nsWinUtils_h_
#define nsWinUtils_h_
interface imgIContainer;
#include "Accessible2.h"
/**
* imgILoad interface
*
* @author Stuart Parmenter <pavlov@netscape.com>
* @version 0.1
* @see imagelib2
*/
[scriptable, uuid(e6273acc-1dd1-11b2-a08b-824ad1b1628d)]
interface imgILoad : nsISupports
#include "nsIArray.h"
class nsWinUtils
{
public:
/**
* the image container...
* @return the image object associated with the request.
* @attention NEED DOCS
* Convert nsIArray array of accessible objects to an array of IUnknown*
* objects used in IA2 methods.
*/
attribute imgIContainer image;
readonly attribute PRBool isMultiPartChannel;
static HRESULT ConvertToIA2Array(nsIArray *aCollection,
IUnknown ***aAccessibles, long *aCount);
};
#endif

Просмотреть файл

@ -0,0 +1,75 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Mozilla Corporation.
* Portions created by the Initial Developer are Copyright (C) 2009
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Alexander Surkov <surkov.alexander@gmail.com> (original author)
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#include "nsXULListboxAccessibleWrap.h"
////////////////////////////////////////////////////////////////////////////////
// nsXULListboxAccessibleWrap
////////////////////////////////////////////////////////////////////////////////
nsXULListboxAccessibleWrap::
nsXULListboxAccessibleWrap(nsIDOMNode *aDOMNode, nsIWeakReference *aShell) :
nsXULListboxAccessible(aDOMNode, aShell)
{
}
NS_IMPL_ISUPPORTS_INHERITED0(nsXULListboxAccessibleWrap,
nsXULListboxAccessible)
IMPL_IUNKNOWN_QUERY_HEAD(nsXULListboxAccessibleWrap)
IMPL_IUNKNOWN_QUERY_ENTRY_COND(CAccessibleTable, IsMulticolumn());
IMPL_IUNKNOWN_QUERY_ENTRY(nsAccessibleWrap)
IMPL_IUNKNOWN_QUERY_TAIL
////////////////////////////////////////////////////////////////////////////////
// nsXULListCellAccessibleWrap
////////////////////////////////////////////////////////////////////////////////
nsXULListCellAccessibleWrap::
nsXULListCellAccessibleWrap(nsIDOMNode *aDOMNode, nsIWeakReference *aShell) :
nsXULListCellAccessible(aDOMNode, aShell)
{
}
NS_IMPL_ISUPPORTS_INHERITED0(nsXULListCellAccessibleWrap,
nsXULListCellAccessible)
IMPL_IUNKNOWN_INHERITED1(nsXULListCellAccessibleWrap,
nsHyperTextAccessibleWrap,
CAccessibleTableCell)

Просмотреть файл

@ -15,13 +15,12 @@
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Sun Microsystems, Inc.
* Portions created by the Initial Developer are Copyright (C) 2002
* Mozilla Corporation.
* Portions created by the Initial Developer are Copyright (C) 2009
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Pete Zha (pete.zha@sun.com)
* Kyle Yuan (kyle.yuan@sun.com)
* Alexander Surkov <surkov.alexander@gmail.com> (original author)
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
@ -37,29 +36,46 @@
*
* ***** END LICENSE BLOCK ***** */
#ifndef __nsXULTreeAccessibleWrap_h__
#define __nsXULTreeAccessibleWrap_h__
#ifndef __nsXULListboxAccessibleWrap_h__
#define __nsXULListboxAccessibleWrap_h__
#include "nsXULTreeGridAccessible.h"
#include "nsXULListboxAccessible.h"
class nsXULTreeGridAccessibleWrap : public nsXULTreeGridAccessible
#include "CAccessibleTable.h"
#include "CAccessibleTableCell.h"
/**
* IA2 wrapper class for nsXULListboxAccessible class implementing
* IAccessibleTable and IAccessibleTable2 interfaces.
*/
class nsXULListboxAccessibleWrap : public nsXULListboxAccessible,
public CAccessibleTable
{
public:
nsXULTreeGridAccessibleWrap(nsIDOMNode* aDOMNode, nsIWeakReference* aShell);
nsXULListboxAccessibleWrap(nsIDOMNode *aDOMNode, nsIWeakReference *aShell);
// nsIAccessibleTable
NS_IMETHOD GetColumnHeader(nsIAccessibleTable **aColumnHeader);
NS_IMETHOD GetColumnDescription(PRInt32 aColumn, nsAString& aDescription);
// IUnknown
DECL_IUNKNOWN_INHERITED
// nsISupports
NS_DECL_ISUPPORTS_INHERITED
};
class nsXULTreeColumnsAccessibleWrap : public nsXULTreeColumnsAccessible,
public nsIAccessibleTable
/**
* IA2 wrapper class for nsXULListCellAccessible class, implements
* IAccessibleTableCell interface.
*/
class nsXULListCellAccessibleWrap : public nsXULListCellAccessible,
public CAccessibleTableCell
{
public:
NS_DECL_ISUPPORTS_INHERITED
NS_DECL_NSIACCESSIBLETABLE
nsXULListCellAccessibleWrap(nsIDOMNode *aDOMNode, nsIWeakReference *aShell);
nsXULTreeColumnsAccessibleWrap(nsIDOMNode* aDOMNode, nsIWeakReference* aShell);
// IUnknown
DECL_IUNKNOWN_INHERITED
// nsISupports
NS_DECL_ISUPPORTS_INHERITED
};
#endif

Просмотреть файл

@ -0,0 +1,81 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Netscape Corp.
* Portions created by the Initial Developer are Copyright (C) 2003
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Aaron Leventhal <aaronleventhal@moonset.net> (original author)
* Alexander Surkov <surkov.alexander@gmail.com>
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#include "nsXULTreeGridAccessibleWrap.h"
////////////////////////////////////////////////////////////////////////////////
// nsXULTreeGridAccessibleWrap
////////////////////////////////////////////////////////////////////////////////
nsXULTreeGridAccessibleWrap::
nsXULTreeGridAccessibleWrap(nsIDOMNode *aDOMNode, nsIWeakReference *aShell) :
nsXULTreeGridAccessible(aDOMNode, aShell)
{
}
NS_IMPL_ISUPPORTS_INHERITED0(nsXULTreeGridAccessibleWrap,
nsXULTreeGridAccessible)
IMPL_IUNKNOWN_INHERITED1(nsXULTreeGridAccessibleWrap,
nsAccessibleWrap,
CAccessibleTable)
////////////////////////////////////////////////////////////////////////////////
// nsXULTreeGridCellAccessibleWrap
////////////////////////////////////////////////////////////////////////////////
nsXULTreeGridCellAccessibleWrap::
nsXULTreeGridCellAccessibleWrap(nsIDOMNode *aDOMNode,
nsIWeakReference *aShell,
nsXULTreeGridRowAccessible *aRowAcc,
nsITreeBoxObject *aTree,
nsITreeView *aTreeView,
PRInt32 aRow, nsITreeColumn* aColumn) :
nsXULTreeGridCellAccessible(aDOMNode, aShell, aRowAcc, aTree, aTreeView,
aRow, aColumn)
{
}
NS_IMPL_ISUPPORTS_INHERITED0(nsXULTreeGridCellAccessibleWrap,
nsXULTreeGridCellAccessible)
IMPL_IUNKNOWN_INHERITED1(nsXULTreeGridCellAccessibleWrap,
nsAccessibleWrap,
CAccessibleTableCell)

Просмотреть файл

@ -37,25 +37,45 @@
*
* ***** END LICENSE BLOCK ***** */
#ifndef __nsXULTreeAccessibleWrap_h__
#define __nsXULTreeAccessibleWrap_h__
#ifndef __nsXULTreeGridAccessibleWrap_h__
#define __nsXULTreeGridAccessibleWrap_h__
#include "nsXULTreeGridAccessible.h"
#include "CAccessibleTable.h"
typedef class nsXULTreeColumnsAccessible nsXULTreeColumnsAccessibleWrap;
#include "CAccessibleTableCell.h"
/**
* IA2 wrapper of nsXULTreeGridAccessible class, implements IAccessibleTable
* interface.
* IA2 wrapper class for nsXULTreeGridAccessible class implementing
* IAccessibleTable and IAccessibleTable2 interfaces.
*/
class nsXULTreeGridAccessibleWrap : public nsXULTreeGridAccessible,
public CAccessibleTable
{
public:
nsXULTreeGridAccessibleWrap(nsIDOMNode *aDOMNode, nsIWeakReference *aShell);
virtual ~nsXULTreeGridAccessibleWrap() {}
// IUnknown
DECL_IUNKNOWN_INHERITED
// nsISupports
NS_DECL_ISUPPORTS_INHERITED
};
/**
* IA2 wrapper class for nsXULTreeGridCellAccessible class, implements
* IAccessibleTableCell interface.
*/
class nsXULTreeGridCellAccessibleWrap : public nsXULTreeGridCellAccessible,
public CAccessibleTableCell
{
public:
nsXULTreeGridCellAccessibleWrap(nsIDOMNode *aDOMNode,
nsIWeakReference *aShell,
nsXULTreeGridRowAccessible *aRowAcc,
nsITreeBoxObject *aTree,
nsITreeView *aTreeView,
PRInt32 aRow, nsITreeColumn* aColumn);
// IUnknown
DECL_IUNKNOWN_INHERITED

Просмотреть файл

@ -60,7 +60,8 @@ EXPORTS = \
nsDocAccessibleWrap.h \
nsRootAccessibleWrap.h \
nsXULMenuAccessibleWrap.h \
nsXULTreeAccessibleWrap.h \
nsXULListboxAccessibleWrap.h \
nsXULTreeGridAccessibleWrap.h \
nsHyperTextAccessibleWrap.h \
nsHTMLImageAccessibleWrap.h \
nsHTMLTableAccessibleWrap.h \

Просмотреть файл

@ -44,6 +44,7 @@
#include "nsARIAGridAccessible.h"
typedef class nsARIAGridAccessible nsARIAGridAccessibleWrap;
typedef class nsARIAGridCellAccessible nsARIAGridCellAccessibleWrap;
#endif

Просмотреть файл

@ -44,8 +44,8 @@
#include "nsHTMLTableAccessible.h"
typedef class nsHTMLTableAccessible nsHTMLTableAccessibleWrap;
typedef class nsHTMLTableHeadAccessible nsHTMLTableHeadAccessibleWrap;
typedef class nsHTMLTableCellAccessible nsHTMLTableCellAccessibleWrap;
typedef class nsHTMLTableHeaderCellAccessible nsHTMLTableHeaderCellAccessibleWrap;
#endif

Просмотреть файл

@ -0,0 +1,47 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Mozilla Corporation.
* Portions created by the Initial Developer are Copyright (C) 2009
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Alexander Surkov <surkov.alexander@gmail.com> (original author)
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#ifndef __nsXULListboxAccessibleWrap_h__
#define __nsXULListboxAccessibleWrap_h__
#include "nsXULListboxAccessible.h"
typedef class nsXULListboxAccessible nsXULListboxAccessibleWrap;
typedef class nsXULListCellAccessible nsXULListCellAccessibleWrap;
#endif

Просмотреть файл

@ -35,11 +35,12 @@
*
* ***** END LICENSE BLOCK ***** */
#ifndef __nsXULTreeAccessibleWrap_h__
#define __nsXULTreeAccessibleWrap_h__
#ifndef __nsXULTreeGridAccessibleWrap_h__
#define __nsXULTreeGridAccessibleWrap_h__
#include "nsXULTreeGridAccessible.h"
typedef class nsXULTreeGridAccessible nsXULTreeGridAccessibleWrap;
typedef class nsXULTreeColumnsAccessible nsXULTreeColumnsAccessibleWrap;
typedef class nsXULTreeGridAccessible nsXULTreeGridAccessibleWrap;
typedef class nsXULTreeGridCellAccessible nsXULTreeGridCellAccessibleWrap;
#endif

Просмотреть файл

@ -48,9 +48,6 @@ LIBRARY_NAME = accessibility_xforms_s
LIBXUL_LIBRARY = 1
ifeq ($(MOZ_WIDGET_TOOLKIT),gtk2)
REQUIRES += editor
endif
CPPSRCS = \
nsXFormsAccessible.cpp \

Просмотреть файл

@ -48,16 +48,14 @@ LIBRARY_NAME = accessibility_xul_s
LIBXUL_LIBRARY = 1
ifeq ($(MOZ_WIDGET_TOOLKIT),gtk2)
REQUIRES += editor
endif
CPPSRCS = \
nsXULAlertAccessible.cpp \
nsXULColorPickerAccessible.cpp \
nsXULComboboxAccessible.cpp \
nsXULFormControlAccessible.cpp \
nsXULListboxAccessible.cpp \
nsXULMenuAccessible.cpp \
nsXULSelectAccessible.cpp \
nsXULSliderAccessible.cpp \
nsXULTabAccessible.cpp \
nsXULTextAccessible.cpp \

Просмотреть файл

@ -0,0 +1,237 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 2009
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Aaron Leventhal <aaronl@netscape.com> (original author)
* Kyle Yuan <kyle.yuan@sun.com>
* Alexander Surkov <surkov.alexander@gmail.com>
*
* Alternatively, the contents of this file may be used under the terms of
* either of the GNU General Public License Version 2 or later (the "GPL"),
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#include "nsXULComboboxAccessible.h"
#include "nsIDOMXULMenuListElement.h"
#include "nsIDOMXULSelectCntrlItemEl.h"
#include "nsServiceManagerUtils.h"
////////////////////////////////////////////////////////////////////////////////
// nsXULComboboxAccessible
////////////////////////////////////////////////////////////////////////////////
nsXULComboboxAccessible::
nsXULComboboxAccessible(nsIDOMNode* aDOMNode, nsIWeakReference* aShell) :
nsAccessibleWrap(aDOMNode, aShell)
{
}
nsresult
nsXULComboboxAccessible::Init()
{
nsresult rv = nsAccessibleWrap::Init();
nsXULMenupopupAccessible::GenerateMenu(mDOMNode);
return rv;
}
nsresult
nsXULComboboxAccessible::GetRoleInternal(PRUint32 *aRole)
{
nsCOMPtr<nsIContent> content = do_QueryInterface(mDOMNode);
if (!content) {
return NS_ERROR_FAILURE;
}
if (content->AttrValueIs(kNameSpaceID_None, nsAccessibilityAtoms::type,
NS_LITERAL_STRING("autocomplete"), eIgnoreCase)) {
*aRole = nsIAccessibleRole::ROLE_AUTOCOMPLETE;
} else {
*aRole = nsIAccessibleRole::ROLE_COMBOBOX;
}
return NS_OK;
}
nsresult
nsXULComboboxAccessible::GetStateInternal(PRUint32 *aState,
PRUint32 *aExtraState)
{
// As a nsComboboxAccessible we can have the following states:
// STATE_FOCUSED
// STATE_FOCUSABLE
// STATE_HASPOPUP
// STATE_EXPANDED
// STATE_COLLAPSED
// Get focus status from base class
nsresult rv = nsAccessible::GetStateInternal(aState, aExtraState);
NS_ENSURE_A11Y_SUCCESS(rv, rv);
nsCOMPtr<nsIDOMXULMenuListElement> menuList(do_QueryInterface(mDOMNode));
if (menuList) {
PRBool isOpen;
menuList->GetOpen(&isOpen);
if (isOpen) {
*aState |= nsIAccessibleStates::STATE_EXPANDED;
}
else {
*aState |= nsIAccessibleStates::STATE_COLLAPSED;
}
}
*aState |= nsIAccessibleStates::STATE_HASPOPUP |
nsIAccessibleStates::STATE_FOCUSABLE;
return NS_OK;
}
NS_IMETHODIMP
nsXULComboboxAccessible::GetValue(nsAString& aValue)
{
aValue.Truncate();
if (IsDefunct())
return NS_ERROR_FAILURE;
// The value is the option or text shown entered in the combobox.
nsCOMPtr<nsIDOMXULMenuListElement> menuList(do_QueryInterface(mDOMNode));
if (menuList)
return menuList->GetLabel(aValue);
return NS_ERROR_FAILURE;
}
NS_IMETHODIMP
nsXULComboboxAccessible::GetDescription(nsAString& aDescription)
{
aDescription.Truncate();
if (IsDefunct())
return NS_ERROR_FAILURE;
// Use description of currently focused option
nsCOMPtr<nsIDOMXULMenuListElement> menuListElm(do_QueryInterface(mDOMNode));
if (!menuListElm)
return NS_ERROR_FAILURE;
nsCOMPtr<nsIDOMXULSelectControlItemElement> focusedOptionItem;
menuListElm->GetSelectedItem(getter_AddRefs(focusedOptionItem));
nsCOMPtr<nsIDOMNode> focusedOptionNode(do_QueryInterface(focusedOptionItem));
if (focusedOptionNode) {
nsCOMPtr<nsIAccessible> focusedOption;
GetAccService()->GetAccessibleInWeakShell(focusedOptionNode, mWeakShell,
getter_AddRefs(focusedOption));
NS_ENSURE_TRUE(focusedOption, NS_ERROR_FAILURE);
return focusedOption->GetDescription(aDescription);
}
return NS_OK;
}
PRBool
nsXULComboboxAccessible::GetAllowsAnonChildAccessibles()
{
nsCOMPtr<nsIContent> content = do_QueryInterface(mDOMNode);
NS_ASSERTION(content, "No content during accessible tree building!");
if (!content)
return PR_FALSE;
if (content->NodeInfo()->Equals(nsAccessibilityAtoms::textbox, kNameSpaceID_XUL) ||
content->AttrValueIs(kNameSpaceID_None, nsAccessibilityAtoms::editable,
nsAccessibilityAtoms::_true, eIgnoreCase)) {
// Both the XUL <textbox type="autocomplete"> and <menulist editable="true"> widgets
// use nsXULComboboxAccessible. We need to walk the anonymous children for these
// so that the entry field is a child
return PR_TRUE;
}
// Argument of PR_FALSE indicates we don't walk anonymous children for
// menuitems
return PR_FALSE;
}
NS_IMETHODIMP
nsXULComboboxAccessible::GetNumActions(PRUint8 *aNumActions)
{
NS_ENSURE_ARG_POINTER(aNumActions);
// Just one action (click).
*aNumActions = 1;
return NS_OK;
}
NS_IMETHODIMP
nsXULComboboxAccessible::DoAction(PRUint8 aIndex)
{
if (aIndex != nsXULComboboxAccessible::eAction_Click) {
return NS_ERROR_INVALID_ARG;
}
if (IsDefunct())
return NS_ERROR_FAILURE;
// Programmaticaly toggle the combo box.
nsCOMPtr<nsIDOMXULMenuListElement> menuList(do_QueryInterface(mDOMNode));
if (!menuList) {
return NS_ERROR_FAILURE;
}
PRBool isDroppedDown;
menuList->GetOpen(&isDroppedDown);
return menuList->SetOpen(!isDroppedDown);
}
NS_IMETHODIMP
nsXULComboboxAccessible::GetActionName(PRUint8 aIndex, nsAString& aName)
{
if (aIndex != nsXULComboboxAccessible::eAction_Click) {
return NS_ERROR_INVALID_ARG;
}
if (IsDefunct())
return NS_ERROR_FAILURE;
// Our action name is the reverse of our state:
// if we are close -> open is our name.
// if we are open -> close is our name.
// Uses the frame to get the state, updated on every click.
nsCOMPtr<nsIDOMXULMenuListElement> menuList(do_QueryInterface(mDOMNode));
if (!menuList) {
return NS_ERROR_FAILURE;
}
PRBool isDroppedDown;
menuList->GetOpen(&isDroppedDown);
if (isDroppedDown)
aName.AssignLiteral("close");
else
aName.AssignLiteral("open");
return NS_OK;
}

Просмотреть файл

@ -0,0 +1,72 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 2009
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Aaron Leventhal <aaronl@netscape.com> (original author)
* Alexander Surkov <surkov.alexander@gmail.com>
*
* Alternatively, the contents of this file may be used under the terms of
* either of the GNU General Public License Version 2 or later (the "GPL"),
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#ifndef __nsXULComboboxAccessible_h__
#define __nsXULComboboxAccessible_h__
#include "nsCOMPtr.h"
#include "nsXULMenuAccessible.h"
/**
* Used for XUL comboboxes like xul:menulist and autocomplete textbox.
*/
class nsXULComboboxAccessible : public nsAccessibleWrap
{
public:
enum { eAction_Click = 0 };
nsXULComboboxAccessible(nsIDOMNode* aDOMNode, nsIWeakReference* aShell);
// nsIAccessible
NS_IMETHOD GetValue(nsAString& aValue);
NS_IMETHOD GetDescription(nsAString& aDescription);
NS_IMETHOD DoAction(PRUint8 aIndex);
NS_IMETHOD GetNumActions(PRUint8 *aNumActions);
NS_IMETHOD GetActionName(PRUint8 aIndex, nsAString& aName);
// nsAccessNode
virtual nsresult Init();
// nsAccessible
virtual nsresult GetRoleInternal(PRUint32 *aRole);
virtual nsresult GetStateInternal(PRUint32 *aState, PRUint32 *aExtraState);
virtual PRBool GetAllowsAnonChildAccessibles();
};
#endif

Просмотреть файл

@ -43,7 +43,7 @@
// NOTE: alphabetically ordered
#include "nsAccessibleWrap.h"
#include "nsFormControlAccessible.h"
#include "nsXULSelectAccessible.h"
#include "nsXULMenuAccessible.h"
#include "nsHyperTextAccessibleWrap.h"
class nsXULButtonAccessible : public nsAccessibleWrap

Просмотреть файл

@ -20,8 +20,9 @@
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Original Author: Eric Vaughan (evaughan@netscape.com)
* Kyle Yuan (kyle.yuan@sun.com)
* Aaron Leventhal <aaronl@netscape.com> (original author)
* Kyle Yuan <kyle.yuan@sun.com>
* Alexander Surkov <surkov.alexander@gmail.com>
*
* Alternatively, the contents of this file may be used under the terms of
* either of the GNU General Public License Version 2 or later (the "GPL"),
@ -37,20 +38,16 @@
*
* ***** END LICENSE BLOCK ***** */
#include "nsXULSelectAccessible.h"
#include "nsAccessibilityService.h"
#include "nsIContent.h"
#include "nsIDOMXULMenuListElement.h"
#include "nsXULListboxAccessible.h"
#include "nsIDOMXULPopupElement.h"
#include "nsIDOMXULMultSelectCntrlEl.h"
#include "nsIDOMXULSelectCntrlItemEl.h"
#include "nsIDOMXULTextboxElement.h"
#include "nsIPresShell.h"
#include "nsIServiceManager.h"
#include "nsCaseTreatment.h"
#include "nsServiceManagerUtils.h"
////////////////////////////////////////////////////////////////////////////////
// nsXULColumnsAccessible
////////////////////////////////////////////////////////////////////////////////
nsXULColumnsAccessible::
nsXULColumnsAccessible(nsIDOMNode *aDOMNode, nsIWeakReference *aShell) :
@ -87,8 +84,10 @@ nsXULColumnsAccessible::GetStateInternal(PRUint32 *aState,
return NS_OK;
}
////////////////////////////////////////////////////////////////////////////////
// nsXULColumnItemAccessible
////////////////////////////////////////////////////////////////////////////////
nsXULColumnItemAccessible::
nsXULColumnItemAccessible(nsIDOMNode *aDOMNode, nsIWeakReference *aShell) :
@ -153,6 +152,7 @@ nsXULColumnItemAccessible::DoAction(PRUint8 aIndex)
////////////////////////////////////////////////////////////////////////////////
// nsXULListboxAccessible
////////////////////////////////////////////////////////////////////////////////
nsXULListboxAccessible::
nsXULListboxAccessible(nsIDOMNode* aDOMNode, nsIWeakReference* aShell) :
@ -170,7 +170,7 @@ nsXULListboxAccessible::QueryInterface(REFNSIID aIID, void** aInstancePtr)
if (*aInstancePtr)
return rv;
if (aIID.Equals(NS_GET_IID(nsIAccessibleTable)) && IsTree()) {
if (aIID.Equals(NS_GET_IID(nsIAccessibleTable)) && IsMulticolumn()) {
*aInstancePtr = static_cast<nsIAccessibleTable*>(this);
NS_ADDREF_THIS();
return NS_OK;
@ -180,13 +180,13 @@ nsXULListboxAccessible::QueryInterface(REFNSIID aIID, void** aInstancePtr)
}
PRBool
nsXULListboxAccessible::IsTree()
nsXULListboxAccessible::IsMulticolumn()
{
PRInt32 numColumns = 0;
nsresult rv = GetColumns(&numColumns);
nsresult rv = GetColumnCount(&numColumns);
if (NS_FAILED(rv))
return PR_FALSE;
return numColumns > 1;
}
@ -250,7 +250,7 @@ nsXULListboxAccessible::GetRoleInternal(PRUint32 *aRole)
}
}
if (IsTree())
if (IsMulticolumn())
*aRole = nsIAccessibleRole::ROLE_TABLE;
else
*aRole = nsIAccessibleRole::ROLE_LISTBOX;
@ -279,12 +279,12 @@ nsXULListboxAccessible::GetSummary(nsAString &aSummary)
}
NS_IMETHODIMP
nsXULListboxAccessible::GetColumns(PRInt32 *aNumColumns)
nsXULListboxAccessible::GetColumnCount(PRInt32 *aColumnsCout)
{
NS_ENSURE_ARG_POINTER(aNumColumns);
*aNumColumns = 0;
NS_ENSURE_ARG_POINTER(aColumnsCout);
*aColumnsCout = 0;
if (!mDOMNode)
if (IsDefunct())
return NS_ERROR_FAILURE;
nsCOMPtr<nsIContent> content(do_QueryInterface(mDOMNode));
@ -318,26 +318,17 @@ nsXULListboxAccessible::GetColumns(PRInt32 *aNumColumns)
}
}
*aNumColumns = columnCount;
*aColumnsCout = columnCount;
return NS_OK;
}
NS_IMETHODIMP
nsXULListboxAccessible::GetColumnHeader(nsIAccessibleTable **aColumnHeader)
nsXULListboxAccessible::GetRowCount(PRInt32 *arowCount)
{
NS_ENSURE_ARG_POINTER(aColumnHeader);
*aColumnHeader = nsnull;
NS_ENSURE_ARG_POINTER(arowCount);
*arowCount = 0;
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP
nsXULListboxAccessible::GetRows(PRInt32 *aNumRows)
{
NS_ENSURE_ARG_POINTER(aNumRows);
*aNumRows = 0;
if (!mDOMNode)
if (IsDefunct())
return NS_ERROR_FAILURE;
nsCOMPtr<nsIDOMXULSelectControlElement> element(do_QueryInterface(mDOMNode));
@ -347,21 +338,12 @@ nsXULListboxAccessible::GetRows(PRInt32 *aNumRows)
nsresult rv = element->GetItemCount(&itemCount);
NS_ENSURE_SUCCESS(rv, rv);
*aNumRows = itemCount;
*arowCount = itemCount;
return NS_OK;
}
NS_IMETHODIMP
nsXULListboxAccessible::GetRowHeader(nsIAccessibleTable **aRowHeader)
{
NS_ENSURE_ARG_POINTER(aRowHeader);
*aRowHeader = nsnull;
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP
nsXULListboxAccessible::CellRefAt(PRInt32 aRow, PRInt32 aColumn,
nsXULListboxAccessible::GetCellAt(PRInt32 aRow, PRInt32 aColumn,
nsIAccessible **aAccessibleCell)
{
NS_ENSURE_ARG_POINTER(aAccessibleCell);
@ -377,8 +359,10 @@ nsXULListboxAccessible::CellRefAt(PRInt32 aRow, PRInt32 aColumn,
control->GetItemAtIndex(aRow, getter_AddRefs(item));
NS_ENSURE_TRUE(item, NS_ERROR_INVALID_ARG);
nsCOMPtr<nsIDOMNode> itemNode(do_QueryInterface(item));
nsCOMPtr<nsIAccessible> accessibleRow;
GetAccService()->GetAccessibleInWeakShell(item, mWeakShell,
GetAccService()->GetAccessibleInWeakShell(itemNode, mWeakShell,
getter_AddRefs(accessibleRow));
NS_ENSURE_STATE(accessibleRow);
@ -389,19 +373,19 @@ nsXULListboxAccessible::CellRefAt(PRInt32 aRow, PRInt32 aColumn,
}
NS_IMETHODIMP
nsXULListboxAccessible::GetIndexAt(PRInt32 aRow, PRInt32 aColumn,
PRInt32 *aIndex)
nsXULListboxAccessible::GetCellIndexAt(PRInt32 aRow, PRInt32 aColumn,
PRInt32 *aIndex)
{
NS_ENSURE_ARG_POINTER(aIndex);
*aIndex = -1;
PRInt32 rowCount = 0;
nsresult rv = GetRows(&rowCount);
nsresult rv = GetRowCount(&rowCount);
NS_ENSURE_SUCCESS(rv, rv);
NS_ENSURE_TRUE(0 <= aRow && aRow <= rowCount, NS_ERROR_INVALID_ARG);
PRInt32 columnCount = 0;
rv = GetColumns(&columnCount);
rv = GetColumnCount(&columnCount);
NS_ENSURE_SUCCESS(rv, rv);
NS_ENSURE_TRUE(0 <= aColumn && aColumn <= columnCount, NS_ERROR_INVALID_ARG);
@ -410,13 +394,13 @@ nsXULListboxAccessible::GetIndexAt(PRInt32 aRow, PRInt32 aColumn,
}
NS_IMETHODIMP
nsXULListboxAccessible::GetColumnAtIndex(PRInt32 aIndex, PRInt32 *aColumn)
nsXULListboxAccessible::GetColumnIndexAt(PRInt32 aIndex, PRInt32 *aColumn)
{
NS_ENSURE_ARG_POINTER(aColumn);
*aColumn = -1;
PRInt32 columnCount = 0;
nsresult rv = GetColumns(&columnCount);
nsresult rv = GetColumnCount(&columnCount);
NS_ENSURE_SUCCESS(rv, rv);
*aColumn = aIndex % columnCount;
@ -424,13 +408,13 @@ nsXULListboxAccessible::GetColumnAtIndex(PRInt32 aIndex, PRInt32 *aColumn)
}
NS_IMETHODIMP
nsXULListboxAccessible::GetRowAtIndex(PRInt32 aIndex, PRInt32 *aRow)
nsXULListboxAccessible::GetRowIndexAt(PRInt32 aIndex, PRInt32 *aRow)
{
NS_ENSURE_ARG_POINTER(aRow);
*aRow = -1;
PRInt32 columnCount = 0;
nsresult rv = GetColumns(&columnCount);
nsresult rv = GetColumnCount(&columnCount);
NS_ENSURE_SUCCESS(rv, rv);
*aRow = aIndex / columnCount;
@ -486,15 +470,15 @@ nsXULListboxAccessible::IsColumnSelected(PRInt32 aColumn, PRBool *aIsSelected)
NS_ASSERTION(control,
"Doesn't implement nsIDOMXULMultiSelectControlElement.");
PRInt32 selectedRowsCount = 0;
nsresult rv = control->GetSelectedCount(&selectedRowsCount);
PRInt32 selectedrowCount = 0;
nsresult rv = control->GetSelectedCount(&selectedrowCount);
NS_ENSURE_SUCCESS(rv, rv);
PRInt32 rowsCount = 0;
rv = GetRows(&rowsCount);
PRInt32 rowCount = 0;
rv = GetRowCount(&rowCount);
NS_ENSURE_SUCCESS(rv, rv);
*aIsSelected = (selectedRowsCount == rowsCount);
*aIsSelected = (selectedrowCount == rowCount);
return NS_OK;
}
@ -520,14 +504,14 @@ nsXULListboxAccessible::IsRowSelected(PRInt32 aRow, PRBool *aIsSelected)
}
NS_IMETHODIMP
nsXULListboxAccessible::IsCellSelected(PRInt32 aRow, PRInt32 aColumn,
nsXULListboxAccessible::IsCellSelected(PRInt32 aRowIndex, PRInt32 aColumnIndex,
PRBool *aIsSelected)
{
return IsRowSelected(aRow, aIsSelected);
return IsRowSelected(aRowIndex, aIsSelected);
}
NS_IMETHODIMP
nsXULListboxAccessible::GetSelectedCellsCount(PRUint32* aCount)
nsXULListboxAccessible::GetSelectedCellCount(PRUint32* aCount)
{
NS_ENSURE_ARG_POINTER(aCount);
*aCount = 0;
@ -549,49 +533,16 @@ nsXULListboxAccessible::GetSelectedCellsCount(PRUint32* aCount)
if (!selectedItemsCount)
return NS_OK;
PRInt32 columnsCount = 0;
rv = GetColumns(&columnsCount);
PRInt32 columnCount = 0;
rv = GetColumnCount(&columnCount);
NS_ENSURE_SUCCESS(rv, rv);
*aCount = selectedItemsCount * columnsCount;
*aCount = selectedItemsCount * columnCount;
return NS_OK;
}
NS_IMETHODIMP
nsXULListboxAccessible::GetSelectedColumnsCount(PRUint32* aCount)
{
NS_ENSURE_ARG_POINTER(aCount);
*aCount = 0;
if (IsDefunct())
return NS_ERROR_FAILURE;
nsCOMPtr<nsIDOMXULMultiSelectControlElement> control =
do_QueryInterface(mDOMNode);
NS_ASSERTION(control,
"Doesn't implement nsIDOMXULMultiSelectControlElement.");
PRInt32 selectedRowsCount = 0;
nsresult rv = control->GetSelectedCount(&selectedRowsCount);
NS_ENSURE_SUCCESS(rv, rv);
PRInt32 rowsCount = 0;
rv = GetRows(&rowsCount);
NS_ENSURE_SUCCESS(rv, rv);
if (selectedRowsCount != rowsCount)
return NS_OK;
PRInt32 columnsCount = 0;
rv = GetColumns(&columnsCount);
NS_ENSURE_SUCCESS(rv, rv);
*aCount = columnsCount;
return NS_OK;
}
NS_IMETHODIMP
nsXULListboxAccessible::GetSelectedRowsCount(PRUint32* aCount)
nsXULListboxAccessible::GetSelectedColumnCount(PRUint32* aCount)
{
NS_ENSURE_ARG_POINTER(aCount);
*aCount = 0;
@ -604,16 +555,103 @@ nsXULListboxAccessible::GetSelectedRowsCount(PRUint32* aCount)
NS_ASSERTION(control,
"Doesn't implement nsIDOMXULMultiSelectControlElement.");
PRInt32 selectedRowsCount = 0;
nsresult rv = control->GetSelectedCount(&selectedRowsCount);
PRInt32 selectedrowCount = 0;
nsresult rv = control->GetSelectedCount(&selectedrowCount);
NS_ENSURE_SUCCESS(rv, rv);
*aCount = selectedRowsCount;
PRInt32 rowCount = 0;
rv = GetRowCount(&rowCount);
NS_ENSURE_SUCCESS(rv, rv);
if (selectedrowCount != rowCount)
return NS_OK;
PRInt32 columnCount = 0;
rv = GetColumnCount(&columnCount);
NS_ENSURE_SUCCESS(rv, rv);
*aCount = columnCount;
return NS_OK;
}
NS_IMETHODIMP
nsXULListboxAccessible::GetSelectedCells(PRUint32 *aNumCells, PRInt32 **aCells)
nsXULListboxAccessible::GetSelectedRowCount(PRUint32* aCount)
{
NS_ENSURE_ARG_POINTER(aCount);
*aCount = 0;
if (IsDefunct())
return NS_ERROR_FAILURE;
nsCOMPtr<nsIDOMXULMultiSelectControlElement> control =
do_QueryInterface(mDOMNode);
NS_ASSERTION(control,
"Doesn't implement nsIDOMXULMultiSelectControlElement.");
PRInt32 selectedrowCount = 0;
nsresult rv = control->GetSelectedCount(&selectedrowCount);
NS_ENSURE_SUCCESS(rv, rv);
*aCount = selectedrowCount;
return NS_OK;
}
NS_IMETHODIMP
nsXULListboxAccessible::GetSelectedCells(nsIArray **aCells)
{
NS_ENSURE_ARG_POINTER(aCells);
*aCells = nsnull;
if (IsDefunct())
return NS_ERROR_FAILURE;
nsresult rv = NS_OK;
nsCOMPtr<nsIMutableArray> selCells =
do_CreateInstance(NS_ARRAY_CONTRACTID, &rv);
NS_ENSURE_SUCCESS(rv, rv);
nsCOMPtr<nsIDOMXULMultiSelectControlElement> control =
do_QueryInterface(mDOMNode);
NS_ASSERTION(control,
"Doesn't implement nsIDOMXULMultiSelectControlElement.");
nsCOMPtr<nsIDOMNodeList> selectedItems;
control->GetSelectedItems(getter_AddRefs(selectedItems));
if (!selectedItems)
return NS_OK;
PRUint32 selectedItemsCount = 0;
rv = selectedItems->GetLength(&selectedItemsCount);
NS_ENSURE_SUCCESS(rv, rv);
PRUint32 index = 0;
for (; index < selectedItemsCount; index++) {
nsCOMPtr<nsIDOMNode> itemNode;
selectedItems->Item(index, getter_AddRefs(itemNode));
nsCOMPtr<nsIAccessible> item;
GetAccService()->GetAccessibleInWeakShell(itemNode, mWeakShell,
getter_AddRefs(item));
if (item) {
nsCOMPtr<nsIAccessible> cell, nextCell;
item->GetFirstChild(getter_AddRefs(cell));
while (cell) {
if (nsAccUtils::Role(cell) == nsIAccessibleRole::ROLE_CELL)
selCells->AppendElement(cell, PR_FALSE);
cell->GetNextSibling(getter_AddRefs(nextCell));
nextCell.swap(cell);
}
}
}
NS_ADDREF(*aCells = selCells);
return NS_OK;
}
NS_IMETHODIMP
nsXULListboxAccessible::GetSelectedCellIndices(PRUint32 *aNumCells,
PRInt32 **aCells)
{
NS_ENSURE_ARG_POINTER(aNumCells);
*aNumCells = 0;
@ -622,7 +660,7 @@ nsXULListboxAccessible::GetSelectedCells(PRUint32 *aNumCells, PRInt32 **aCells)
if (IsDefunct())
return NS_ERROR_FAILURE;
nsCOMPtr<nsIDOMXULMultiSelectControlElement> control =
do_QueryInterface(mDOMNode);
NS_ASSERTION(control,
@ -637,11 +675,11 @@ nsXULListboxAccessible::GetSelectedCells(PRUint32 *aNumCells, PRInt32 **aCells)
nsresult rv = selectedItems->GetLength(&selectedItemsCount);
NS_ENSURE_SUCCESS(rv, rv);
PRInt32 columnsCount = 0;
rv = GetColumns(&columnsCount);
PRInt32 columnCount = 0;
rv = GetColumnCount(&columnCount);
NS_ENSURE_SUCCESS(rv, rv);
PRUint32 cellsCount = selectedItemsCount * columnsCount;
PRUint32 cellsCount = selectedItemsCount * columnCount;
PRInt32 *cellsIdxArray =
static_cast<PRInt32*>(nsMemory::Alloc((cellsCount) * sizeof(PRInt32)));
@ -659,8 +697,8 @@ nsXULListboxAccessible::GetSelectedCells(PRUint32 *aNumCells, PRInt32 **aCells)
control->GetIndexOfItem(item, &itemIdx);
if (itemIdx != -1) {
PRInt32 colIdx = 0;
for (; colIdx < columnsCount; colIdx++)
cellsIdxArray[cellsIdx++] = itemIdx * columnsCount + colIdx;
for (; colIdx < columnCount; colIdx++)
cellsIdxArray[cellsIdx++] = itemIdx * columnCount + colIdx;
}
}
}
@ -672,8 +710,8 @@ nsXULListboxAccessible::GetSelectedCells(PRUint32 *aNumCells, PRInt32 **aCells)
}
NS_IMETHODIMP
nsXULListboxAccessible::GetSelectedColumns(PRUint32 *aNumColumns,
PRInt32 **aColumns)
nsXULListboxAccessible::GetSelectedColumnIndices(PRUint32 *aNumColumns,
PRInt32 **aColumns)
{
NS_ENSURE_ARG_POINTER(aNumColumns);
*aNumColumns = 0;
@ -683,29 +721,30 @@ nsXULListboxAccessible::GetSelectedColumns(PRUint32 *aNumColumns,
if (IsDefunct())
return NS_ERROR_FAILURE;
PRUint32 columnsCount = 0;
nsresult rv = GetSelectedColumnsCount(&columnsCount);
PRUint32 columnCount = 0;
nsresult rv = GetSelectedColumnCount(&columnCount);
NS_ENSURE_SUCCESS(rv, rv);
if (!columnsCount)
if (!columnCount)
return NS_OK;
PRInt32 *colsIdxArray =
static_cast<PRInt32*>(nsMemory::Alloc((columnsCount) * sizeof(PRInt32)));
static_cast<PRInt32*>(nsMemory::Alloc((columnCount) * sizeof(PRInt32)));
NS_ENSURE_TRUE(colsIdxArray, NS_ERROR_OUT_OF_MEMORY);
PRUint32 colIdx = 0;
for (; colIdx < columnsCount; colIdx++)
for (; colIdx < columnCount; colIdx++)
colsIdxArray[colIdx] = colIdx;
*aNumColumns = columnsCount;
*aNumColumns = columnCount;
*aColumns = colsIdxArray;
return NS_OK;
}
NS_IMETHODIMP
nsXULListboxAccessible::GetSelectedRows(PRUint32 *aNumRows, PRInt32 **aRows)
nsXULListboxAccessible::GetSelectedRowIndices(PRUint32 *aNumRows,
PRInt32 **aRows)
{
NS_ENSURE_ARG_POINTER(aNumRows);
*aNumRows = 0;
@ -764,7 +803,7 @@ nsXULListboxAccessible::SelectRow(PRInt32 aRow)
return NS_ERROR_FAILURE;
nsCOMPtr<nsIDOMXULMultiSelectControlElement> control =
do_QueryInterface(mDOMNode);
do_QueryInterface(mDOMNode);
NS_ASSERTION(control,
"Doesn't implement nsIDOMXULMultiSelectControlElement.");
@ -818,13 +857,14 @@ nsXULListboxAccessible::IsProbablyForLayout(PRBool *aIsProbablyForLayout)
////////////////////////////////////////////////////////////////////////////////
// nsXULListitemAccessible
////////////////////////////////////////////////////////////////////////////////
nsXULListitemAccessible::
nsXULListitemAccessible(nsIDOMNode* aDOMNode, nsIWeakReference* aShell) :
nsXULMenuitemAccessible(aDOMNode, aShell)
{
mIsCheckbox = PR_FALSE;
nsCOMPtr<nsIDOMElement> listItem (do_QueryInterface(mDOMNode));
nsCOMPtr<nsIDOMElement> listItem(do_QueryInterface(mDOMNode));
if (listItem) {
nsAutoString typeString;
nsresult res = listItem->GetAttribute(NS_LITERAL_STRING("type"), typeString);
@ -926,7 +966,10 @@ nsXULListitemAccessible::GetStateInternal(PRUint32 *aState,
*aState = nsIAccessibleStates::STATE_FOCUSABLE |
nsIAccessibleStates::STATE_SELECTABLE;
nsCOMPtr<nsIDOMXULSelectControlItemElement> listItem (do_QueryInterface(mDOMNode));
nsCOMPtr<nsIDOMXULSelectControlItemElement> listItem =
do_QueryInterface(mDOMNode);
if (listItem) {
PRBool isSelected;
listItem->GetSelected(&isSelected);
@ -982,15 +1025,222 @@ nsXULListitemAccessible::GetAttributesInternal(nsIPersistentProperties *aAttribu
}
////////////////////////////////////////////////////////////////////////////////
// nsXULListCellAccessible
////////////////////////////////////////////////////////////////////////////////
nsXULListCellAccessible::
nsXULListCellAccessible(nsIDOMNode* aDOMNode, nsIWeakReference* aShell):
nsHyperTextAccessibleWrap(aDOMNode, aShell)
{
}
////////////////////////////////////////////////////////////////////////////////
// nsISupports
NS_IMPL_ISUPPORTS_INHERITED1(nsXULListCellAccessible,
nsHyperTextAccessible,
nsIAccessibleTableCell)
////////////////////////////////////////////////////////////////////////////////
// nsXULListCellAccessible: nsIAccessibleTableCell implementation
NS_IMETHODIMP
nsXULListCellAccessible::GetTable(nsIAccessibleTable **aTable)
{
NS_ENSURE_ARG_POINTER(aTable);
*aTable = nsnull;
if (IsDefunct())
return NS_ERROR_FAILURE;
nsCOMPtr<nsIAccessible> thisRow;
GetParent(getter_AddRefs(thisRow));
if (nsAccUtils::Role(thisRow) != nsIAccessibleRole::ROLE_ROW)
return NS_OK;
nsCOMPtr<nsIAccessible> table;
thisRow->GetParent(getter_AddRefs(table));
if (nsAccUtils::Role(table) != nsIAccessibleRole::ROLE_TABLE)
return NS_OK;
CallQueryInterface(table, aTable);
return NS_OK;
}
NS_IMETHODIMP
nsXULListCellAccessible::GetColumnIndex(PRInt32 *aColumnIndex)
{
NS_ENSURE_ARG_POINTER(aColumnIndex);
*aColumnIndex = -1;
if (IsDefunct())
return NS_ERROR_FAILURE;
*aColumnIndex = 0;
nsCOMPtr<nsIAccessible> prevCell, tmpAcc;
GetPreviousSibling(getter_AddRefs(prevCell));
while (prevCell) {
PRUint32 role = nsAccUtils::Role(prevCell);
if (role == nsIAccessibleRole::ROLE_CELL ||
role == nsIAccessibleRole::ROLE_GRID_CELL ||
role == nsIAccessibleRole::ROLE_ROWHEADER ||
role == nsIAccessibleRole::ROLE_COLUMNHEADER)
(*aColumnIndex)++;
prevCell->GetPreviousSibling(getter_AddRefs(tmpAcc));
tmpAcc.swap(prevCell);
}
return NS_OK;
}
NS_IMETHODIMP
nsXULListCellAccessible::GetRowIndex(PRInt32 *aRowIndex)
{
NS_ENSURE_ARG_POINTER(aRowIndex);
*aRowIndex = -1;
if (IsDefunct())
return NS_ERROR_FAILURE;
nsCOMPtr<nsIAccessible> row, prevRow;
GetParent(getter_AddRefs(row));
while (row) {
if (nsAccUtils::Role(row) == nsIAccessibleRole::ROLE_ROW)
(*aRowIndex)++;
row->GetPreviousSibling(getter_AddRefs(prevRow));
row.swap(prevRow);
}
return NS_OK;
}
NS_IMETHODIMP
nsXULListCellAccessible::GetColumnExtent(PRInt32 *aExtentCount)
{
NS_ENSURE_ARG_POINTER(aExtentCount);
*aExtentCount = 0;
if (IsDefunct())
return NS_ERROR_FAILURE;
*aExtentCount = 1;
return NS_OK;
}
NS_IMETHODIMP
nsXULListCellAccessible::GetRowExtent(PRInt32 *aExtentCount)
{
NS_ENSURE_ARG_POINTER(aExtentCount);
*aExtentCount = 0;
if (IsDefunct())
return NS_ERROR_FAILURE;
*aExtentCount = 1;
return NS_OK;
}
NS_IMETHODIMP
nsXULListCellAccessible::GetColumnHeaderCells(nsIArray **aHeaderCells)
{
NS_ENSURE_ARG_POINTER(aHeaderCells);
*aHeaderCells = nsnull;
if (IsDefunct())
return NS_ERROR_FAILURE;
nsCOMPtr<nsIAccessibleTable> table;
GetTable(getter_AddRefs(table));
if (!table)
return NS_OK;
// Get column header cell from XUL listhead.
nsCOMPtr<nsIAccessible> tableAcc(do_QueryInterface(table));
nsCOMPtr<nsIAccessible> list, nextChild;
tableAcc->GetFirstChild(getter_AddRefs(list));
while (list) {
if (nsAccUtils::Role(list) == nsIAccessibleRole::ROLE_LIST)
break;
list->GetNextSibling(getter_AddRefs(nextChild));
nextChild.swap(list);
}
if (list) {
PRInt32 colIdx = -1;
GetColumnIndex(&colIdx);
nsCOMPtr<nsIAccessible> headerCell;
list->GetChildAt(colIdx, getter_AddRefs(headerCell));
if (headerCell) {
nsresult rv = NS_OK;
nsCOMPtr<nsIMutableArray> headerCells =
do_CreateInstance(NS_ARRAY_CONTRACTID, &rv);
NS_ENSURE_SUCCESS(rv, rv);
headerCells->AppendElement(headerCell, PR_FALSE);
NS_ADDREF(*aHeaderCells = headerCells);
return NS_OK;
}
}
// No column header cell from XUL markup, try to get it from ARIA markup.
return nsAccUtils::GetHeaderCellsFor(table, this,
nsAccUtils::eColumnHeaderCells,
aHeaderCells);
}
NS_IMETHODIMP
nsXULListCellAccessible::GetRowHeaderCells(nsIArray **aHeaderCells)
{
NS_ENSURE_ARG_POINTER(aHeaderCells);
*aHeaderCells = nsnull;
if (IsDefunct())
return NS_ERROR_FAILURE;
nsCOMPtr<nsIAccessibleTable> table;
GetTable(getter_AddRefs(table));
if (!table)
return NS_OK;
// Calculate row header cells from ARIA markup.
return nsAccUtils::GetHeaderCellsFor(table, this,
nsAccUtils::eRowHeaderCells,
aHeaderCells);
}
NS_IMETHODIMP
nsXULListCellAccessible::IsSelected(PRBool *aIsSelected)
{
NS_ENSURE_ARG_POINTER(aIsSelected);
*aIsSelected = PR_FALSE;
if (IsDefunct())
return NS_ERROR_FAILURE;
nsCOMPtr<nsIAccessibleTable> table;
GetTable(getter_AddRefs(table));
if (!table)
return NS_OK;
PRInt32 rowIdx = -1;
GetRowIndex(&rowIdx);
return table->IsRowSelected(rowIdx, aIsSelected);
}
////////////////////////////////////////////////////////////////////////////////
// nsXULListCellAccessible. nsAccessible implementation
nsresult
nsXULListCellAccessible::GetRoleInternal(PRUint32 *aRole)
{
@ -998,183 +1248,30 @@ nsXULListCellAccessible::GetRoleInternal(PRUint32 *aRole)
return NS_OK;
}
/** ------------------------------------------------------ */
/** Finally, the Combobox widgets */
/** ------------------------------------------------------ */
/** ----- nsXULComboboxAccessible ----- */
/** Constructor */
nsXULComboboxAccessible::nsXULComboboxAccessible(nsIDOMNode* aDOMNode, nsIWeakReference* aShell):
nsAccessibleWrap(aDOMNode, aShell)
{
}
nsresult
nsXULComboboxAccessible::Init()
nsXULListCellAccessible::GetAttributesInternal(nsIPersistentProperties *aAttributes)
{
nsresult rv = nsAccessibleWrap::Init();
nsXULMenupopupAccessible::GenerateMenu(mDOMNode);
return rv;
}
NS_ENSURE_ARG_POINTER(aAttributes);
/** We are a combobox */
nsresult
nsXULComboboxAccessible::GetRoleInternal(PRUint32 *aRole)
{
nsCOMPtr<nsIContent> content = do_QueryInterface(mDOMNode);
if (!content) {
if (IsDefunct())
return NS_ERROR_FAILURE;
}
if (content->AttrValueIs(kNameSpaceID_None, nsAccessibilityAtoms::type,
NS_LITERAL_STRING("autocomplete"), eIgnoreCase)) {
*aRole = nsIAccessibleRole::ROLE_AUTOCOMPLETE;
} else {
*aRole = nsIAccessibleRole::ROLE_COMBOBOX;
}
return NS_OK;
}
/**
* As a nsComboboxAccessible we can have the following states:
* STATE_FOCUSED
* STATE_FOCUSABLE
* STATE_HASPOPUP
* STATE_EXPANDED
* STATE_COLLAPSED
*/
nsresult
nsXULComboboxAccessible::GetStateInternal(PRUint32 *aState,
PRUint32 *aExtraState)
{
// Get focus status from base class
nsresult rv = nsAccessible::GetStateInternal(aState, aExtraState);
NS_ENSURE_A11Y_SUCCESS(rv, rv);
// "table-cell-index" attribute
nsCOMPtr<nsIAccessibleTable> table;
GetTable(getter_AddRefs(table));
nsCOMPtr<nsIDOMXULMenuListElement> menuList(do_QueryInterface(mDOMNode));
if (menuList) {
PRBool isOpen;
menuList->GetOpen(&isOpen);
if (isOpen) {
*aState |= nsIAccessibleStates::STATE_EXPANDED;
}
else {
*aState |= nsIAccessibleStates::STATE_COLLAPSED;
}
}
PRInt32 rowIdx = -1;
GetRowIndex(&rowIdx);
PRInt32 colIdx = -1;
GetColumnIndex(&colIdx);
*aState |= nsIAccessibleStates::STATE_HASPOPUP |
nsIAccessibleStates::STATE_FOCUSABLE;
PRInt32 cellIdx = -1;
table->GetCellIndexAt(rowIdx, colIdx, &cellIdx);
nsAutoString stringIdx;
stringIdx.AppendInt(cellIdx);
nsAccUtils::SetAccAttr(aAttributes, nsAccessibilityAtoms::tableCellIndex,
stringIdx);
return NS_OK;
}
NS_IMETHODIMP nsXULComboboxAccessible::GetValue(nsAString& _retval)
{
_retval.Truncate();
// The MSAA/ATK value is the option or text shown entered in the combobox
nsCOMPtr<nsIDOMXULMenuListElement> menuList(do_QueryInterface(mDOMNode));
if (menuList) {
return menuList->GetLabel(_retval);
}
return NS_ERROR_FAILURE;
}
NS_IMETHODIMP nsXULComboboxAccessible::GetDescription(nsAString& aDescription)
{
// Use description of currently focused option
aDescription.Truncate();
nsCOMPtr<nsIDOMXULMenuListElement> menuList(do_QueryInterface(mDOMNode));
if (!menuList) {
return NS_ERROR_FAILURE; // Shut down
}
nsCOMPtr<nsIDOMXULSelectControlItemElement> focusedOption;
menuList->GetSelectedItem(getter_AddRefs(focusedOption));
nsCOMPtr<nsIDOMNode> focusedOptionNode(do_QueryInterface(focusedOption));
if (focusedOptionNode) {
nsCOMPtr<nsIAccessibilityService> accService =
do_GetService("@mozilla.org/accessibilityService;1");
NS_ENSURE_TRUE(accService, NS_ERROR_FAILURE);
nsCOMPtr<nsIAccessible> focusedOptionAccessible;
accService->GetAccessibleInWeakShell(focusedOptionNode, mWeakShell,
getter_AddRefs(focusedOptionAccessible));
NS_ENSURE_TRUE(focusedOptionAccessible, NS_ERROR_FAILURE);
return focusedOptionAccessible->GetDescription(aDescription);
}
return NS_OK;
}
PRBool
nsXULComboboxAccessible::GetAllowsAnonChildAccessibles()
{
nsCOMPtr<nsIContent> content = do_QueryInterface(mDOMNode);
NS_ASSERTION(content, "No content during accessible tree building!");
if (!content)
return PR_FALSE;
if (content->NodeInfo()->Equals(nsAccessibilityAtoms::textbox, kNameSpaceID_XUL) ||
content->AttrValueIs(kNameSpaceID_None, nsAccessibilityAtoms::editable,
nsAccessibilityAtoms::_true, eIgnoreCase)) {
// Both the XUL <textbox type="autocomplete"> and <menulist editable="true"> widgets
// use nsXULComboboxAccessible. We need to walk the anonymous children for these
// so that the entry field is a child
return PR_TRUE;
}
// Argument of PR_FALSE indicates we don't walk anonymous children for
// menuitems
return PR_FALSE;
}
/** Just one action ( click ). */
NS_IMETHODIMP nsXULComboboxAccessible::GetNumActions(PRUint8 *aNumActions)
{
*aNumActions = 1;
return NS_OK;
}
/**
* Programmaticaly toggle the combo box
*/
NS_IMETHODIMP nsXULComboboxAccessible::DoAction(PRUint8 aIndex)
{
if (aIndex != nsXULComboboxAccessible::eAction_Click) {
return NS_ERROR_INVALID_ARG;
}
nsCOMPtr<nsIDOMXULMenuListElement> menuList(do_QueryInterface(mDOMNode));
if (!menuList) {
return NS_ERROR_FAILURE;
}
PRBool isDroppedDown;
menuList->GetOpen(&isDroppedDown);
return menuList->SetOpen(!isDroppedDown);
}
/**
* Our action name is the reverse of our state:
* if we are closed -> open is our name.
* if we are open -> closed is our name.
* Uses the frame to get the state, updated on every click
*/
NS_IMETHODIMP nsXULComboboxAccessible::GetActionName(PRUint8 aIndex, nsAString& aName)
{
if (aIndex != nsXULComboboxAccessible::eAction_Click) {
return NS_ERROR_INVALID_ARG;
}
nsCOMPtr<nsIDOMXULMenuListElement> menuList(do_QueryInterface(mDOMNode));
if (!menuList) {
return NS_ERROR_FAILURE;
}
PRBool isDroppedDown;
menuList->GetOpen(&isDroppedDown);
if (isDroppedDown)
aName.AssignLiteral("close");
else
aName.AssignLiteral("open");
return NS_OK;
}

Просмотреть файл

@ -20,7 +20,9 @@
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Kyle Yuan (kyle.yuan@sun.com)
* Aaron Leventhal <aaronl@netscape.com> (original author)
* Kyle Yuan <kyle.yuan@sun.com>
* Alexander Surkov <surkov.alexander@gmail.com>
*
* Alternatively, the contents of this file may be used under the terms of
* either of the GNU General Public License Version 2 or later (the "GPL"),
@ -35,8 +37,8 @@
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#ifndef __nsXULSelectAccessible_h__
#define __nsXULSelectAccessible_h__
#ifndef __nsXULListboxAccessible_h__
#define __nsXULListboxAccessible_h__
#include "nsIAccessibleTable.h"
@ -81,25 +83,6 @@ public:
enum { eAction_Click = 0 };
};
/**
* Listboxes (xul:listbox) and Comboboxes (xul:menulist) are made up of a
* number of different widgets, some of which are shared between the two.
* This file contains all of the widgets for both of them, for XUL only.
*
* Listbox:
* - nsXULListboxAccessible
* - nsXULSelectOptionAccessible
*
* Comboboxes:
* - nsXULComboboxAccessible <menulist />
* - nsXULMenuAccessible <menupopup />
* - nsXULMenuitemAccessible(s) <menuitem />
*/
/** ------------------------------------------------------ */
/** First, the common widgets */
/** ------------------------------------------------------ */
/*
* A class the represents the XUL Listbox widget.
*/
@ -121,7 +104,7 @@ public:
virtual nsresult GetStateInternal(PRUint32 *aState, PRUint32 *aExtraState);
protected:
PRBool IsTree();
PRBool IsMulticolumn();
};
/**
@ -159,44 +142,21 @@ private:
/**
* Class represents xul:listcell.
*/
class nsXULListCellAccessible : public nsHyperTextAccessibleWrap
class nsXULListCellAccessible : public nsHyperTextAccessibleWrap,
public nsIAccessibleTableCell
{
public:
nsXULListCellAccessible(nsIDOMNode* aDOMNode, nsIWeakReference* aShell);
// nsAccessible
virtual nsresult GetRoleInternal(PRUint32 *aRole);
};
// nsISupports
NS_DECL_ISUPPORTS_INHERITED
/** ------------------------------------------------------ */
/** Finally, the Combobox widgets */
/** ------------------------------------------------------ */
/*
* A class the represents the XUL Combobox widget.
*/
class nsXULComboboxAccessible : public nsAccessibleWrap
{
public:
enum { eAction_Click = 0 };
nsXULComboboxAccessible(nsIDOMNode* aDOMNode, nsIWeakReference* aShell);
virtual ~nsXULComboboxAccessible() {}
// nsIAccessible
NS_IMETHOD GetValue(nsAString& _retval);
NS_IMETHOD GetDescription(nsAString& aDescription);
NS_IMETHOD DoAction(PRUint8 index);
NS_IMETHOD GetNumActions(PRUint8 *aNumActions);
NS_IMETHOD GetActionName(PRUint8 index, nsAString& aName);
// nsAccessNode
virtual nsresult Init();
// nsIAccessibleTableCell
NS_DECL_NSIACCESSIBLETABLECELL
// nsAccessible
virtual nsresult GetAttributesInternal(nsIPersistentProperties *aAttributes);
virtual nsresult GetRoleInternal(PRUint32 *aRole);
virtual nsresult GetStateInternal(PRUint32 *aState, PRUint32 *aExtraState);
virtual PRBool GetAllowsAnonChildAccessibles();
};
#endif

Просмотреть файл

@ -41,7 +41,7 @@
// NOTE: alphabetically ordered
#include "nsBaseWidgetAccessible.h"
#include "nsXULSelectAccessible.h"
#include "nsXULMenuAccessible.h"
/**
* An individual tab, xul:tab element

Просмотреть файл

@ -592,8 +592,7 @@ nsXULTreeAccessible::InvalidateCache(PRInt32 aRow, PRInt32 aCount)
nsAccUtils::QueryAccessible(accessNode);
nsCOMPtr<nsIAccessibleEvent> event =
new nsAccEvent(nsIAccessibleEvent::EVENT_DOM_DESTROY,
accessible, PR_FALSE);
new nsAccEvent(nsIAccessibleEvent::EVENT_HIDE, accessible, PR_FALSE);
FireAccessibleEvent(event);
accessible->Shutdown();
@ -706,8 +705,7 @@ nsXULTreeAccessible::TreeViewChanged()
// AT because it should be expensive to fire destroy events for each tree item
// in cache.
nsCOMPtr<nsIAccessibleEvent> eventDestroy =
new nsAccEvent(nsIAccessibleEvent::EVENT_DOM_DESTROY,
this, PR_FALSE);
new nsAccEvent(nsIAccessibleEvent::EVENT_HIDE, this, PR_FALSE);
if (!eventDestroy)
return;
@ -718,8 +716,7 @@ nsXULTreeAccessible::TreeViewChanged()
mTree->GetView(getter_AddRefs(mTreeView));
nsCOMPtr<nsIAccessibleEvent> eventCreate =
new nsAccEvent(nsIAccessibleEvent::EVENT_DOM_CREATE,
this, PR_FALSE);
new nsAccEvent(nsIAccessibleEvent::EVENT_SHOW, this, PR_FALSE);
if (!eventCreate)
return;
@ -804,9 +801,9 @@ nsXULTreeItemAccessibleBase::GetNextSibling(nsIAccessible **aNextSibling)
nsAccUtils::QueryAccessibleTree(mParent);
NS_ENSURE_STATE(treeAcc);
PRInt32 rowsCount = 0;
mTreeView->GetRowCount(&rowsCount);
if (mRow + 1 >= rowsCount)
PRInt32 rowCount = 0;
mTreeView->GetRowCount(&rowCount);
if (mRow + 1 >= rowCount)
return NS_OK;
treeAcc->GetTreeItemAccessible(mRow + 1, aNextSibling);

Просмотреть файл

@ -41,7 +41,7 @@
#include "nsITreeBoxObject.h"
#include "nsITreeView.h"
#include "nsITreeColumns.h"
#include "nsXULSelectAccessible.h"
#include "nsXULListboxAccessible.h"
/*
* A class the represents the XUL Tree widget.

Просмотреть файл

@ -36,9 +36,10 @@
*
* ***** END LICENSE BLOCK ***** */
#include "nsXULTreeGridAccessible.h"
#include "nsXULTreeGridAccessibleWrap.h"
#include "nsITreeSelection.h"
#include "nsServiceManagerUtils.h"
////////////////////////////////////////////////////////////////////////////////
// Internal static functions
@ -94,68 +95,50 @@ nsXULTreeGridAccessible::GetSummary(nsAString &aSummary)
}
NS_IMETHODIMP
nsXULTreeGridAccessible::GetColumns(PRInt32 *aColumnsCount)
nsXULTreeGridAccessible::GetColumnCount(PRInt32 *acolumnCount)
{
NS_ENSURE_ARG_POINTER(aColumnsCount);
*aColumnsCount = 0;
NS_ENSURE_ARG_POINTER(acolumnCount);
*acolumnCount = 0;
if (IsDefunct())
return NS_ERROR_FAILURE;
*aColumnsCount = nsCoreUtils::GetSensibleColumnsCount(mTree);
*acolumnCount = nsCoreUtils::GetSensiblecolumnCount(mTree);
return NS_OK;
}
NS_IMETHODIMP
nsXULTreeGridAccessible::GetColumnHeader(nsIAccessibleTable **aColumnHeader)
nsXULTreeGridAccessible::GetRowCount(PRInt32 *arowCount)
{
NS_ENSURE_ARG_POINTER(aColumnHeader);
*aColumnHeader = nsnull;
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP
nsXULTreeGridAccessible::GetRows(PRInt32 *aRowsCount)
{
NS_ENSURE_ARG_POINTER(aRowsCount);
*aRowsCount = nsnull;
NS_ENSURE_ARG_POINTER(arowCount);
*arowCount = nsnull;
if (IsDefunct())
return NS_ERROR_FAILURE;
return mTreeView->GetRowCount(aRowsCount);
return mTreeView->GetRowCount(arowCount);
}
NS_IMETHODIMP
nsXULTreeGridAccessible::GetRowHeader(nsIAccessibleTable **aRowHeader)
{
NS_ENSURE_ARG_POINTER(aRowHeader);
*aRowHeader = nsnull;
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP
nsXULTreeGridAccessible::GetSelectedCellsCount(PRUint32* aCount)
nsXULTreeGridAccessible::GetSelectedCellCount(PRUint32* aCount)
{
NS_ENSURE_ARG_POINTER(aCount);
*aCount = 0;
PRUint32 selectedRowsCount = 0;
nsresult rv = GetSelectedRowsCount(&selectedRowsCount);
PRUint32 selectedrowCount = 0;
nsresult rv = GetSelectedRowCount(&selectedrowCount);
NS_ENSURE_SUCCESS(rv, rv);
PRInt32 columnsCount = 0;
rv = GetColumns(&columnsCount);
PRInt32 columnCount = 0;
rv = GetColumnCount(&columnCount);
NS_ENSURE_SUCCESS(rv, rv);
*aCount = selectedRowsCount * columnsCount;
*aCount = selectedrowCount * columnCount;
return NS_OK;
}
NS_IMETHODIMP
nsXULTreeGridAccessible::GetSelectedColumnsCount(PRUint32* aCount)
nsXULTreeGridAccessible::GetSelectedColumnCount(PRUint32* aCount)
{
NS_ENSURE_ARG_POINTER(aCount);
*aCount = 0;
@ -166,27 +149,27 @@ nsXULTreeGridAccessible::GetSelectedColumnsCount(PRUint32* aCount)
// If all the row has been selected, then all the columns are selected,
// because we can't select a column alone.
PRInt32 rowsCount = 0;
nsresult rv = GetRows(&rowsCount);
PRInt32 rowCount = 0;
nsresult rv = GetRowCount(&rowCount);
NS_ENSURE_SUCCESS(rv, rv);
PRInt32 selectedRowsCount = 0;
rv = GetSelectionCount(&selectedRowsCount);
PRInt32 selectedrowCount = 0;
rv = GetSelectionCount(&selectedrowCount);
NS_ENSURE_SUCCESS(rv, rv);
if (rowsCount == selectedRowsCount) {
PRInt32 columnsCount = 0;
rv = GetColumns(&columnsCount);
if (rowCount == selectedrowCount) {
PRInt32 columnCount = 0;
rv = GetColumnCount(&columnCount);
NS_ENSURE_SUCCESS(rv, rv);
*aCount = columnsCount;
*aCount = columnCount;
}
return NS_OK;
}
NS_IMETHODIMP
nsXULTreeGridAccessible::GetSelectedRowsCount(PRUint32* aCount)
nsXULTreeGridAccessible::GetSelectedRowCount(PRUint32* aCount)
{
NS_ENSURE_ARG_POINTER(aCount);
*aCount = 0;
@ -194,64 +177,105 @@ nsXULTreeGridAccessible::GetSelectedRowsCount(PRUint32* aCount)
if (IsDefunct())
return NS_ERROR_FAILURE;
PRInt32 selectedRowsCount = 0;
nsresult rv = GetSelectionCount(&selectedRowsCount);
PRInt32 selectedrowCount = 0;
nsresult rv = GetSelectionCount(&selectedrowCount);
NS_ENSURE_SUCCESS(rv, rv);
*aCount = selectedRowsCount;
*aCount = selectedrowCount;
return NS_OK;
}
NS_IMETHODIMP
nsXULTreeGridAccessible::GetSelectedCells(PRUint32 *aCellsCount,
PRInt32 **aCells)
nsXULTreeGridAccessible::GetSelectedCells(nsIArray **aCells)
{
NS_ENSURE_ARG_POINTER(aCells);
*aCells = nsnull;
nsCOMPtr<nsIMutableArray> selCells = do_CreateInstance(NS_ARRAY_CONTRACTID);
NS_ENSURE_TRUE(selCells, NS_ERROR_FAILURE);
PRInt32 selectedrowCount = 0;
nsresult rv = GetSelectionCount(&selectedrowCount);
NS_ENSURE_SUCCESS(rv, rv);
PRInt32 columnCount = 0;
rv = GetColumnCount(&columnCount);
NS_ENSURE_SUCCESS(rv, rv);
nsCOMPtr<nsITreeSelection> selection;
rv = mTreeView->GetSelection(getter_AddRefs(selection));
NS_ENSURE_SUCCESS(rv, rv);
PRInt32 rowCount = 0;
rv = GetRowCount(&rowCount);
NS_ENSURE_SUCCESS(rv, rv);
PRBool isSelected;
for (PRInt32 rowIdx = 0; rowIdx < rowCount; rowIdx++) {
selection->IsSelected(rowIdx, &isSelected);
if (isSelected) {
for (PRInt32 colIdx = 0; colIdx < columnCount; colIdx++) {
nsCOMPtr<nsIAccessible> cell;
GetCellAt(rowIdx, colIdx, getter_AddRefs(cell));
selCells->AppendElement(cell, PR_FALSE);
}
}
}
NS_ADDREF(*aCells = selCells);
return NS_OK;
}
NS_IMETHODIMP
nsXULTreeGridAccessible::GetSelectedCellIndices(PRUint32 *aCellsCount,
PRInt32 **aCells)
{
NS_ENSURE_ARG_POINTER(aCellsCount);
*aCellsCount = 0;
NS_ENSURE_ARG_POINTER(aCells);
*aCells = nsnull;
PRInt32 selectedRowsCount = 0;
nsresult rv = GetSelectionCount(&selectedRowsCount);
PRInt32 selectedrowCount = 0;
nsresult rv = GetSelectionCount(&selectedrowCount);
NS_ENSURE_SUCCESS(rv, rv);
PRInt32 columnsCount = 0;
rv = GetColumns(&columnsCount);
PRInt32 columnCount = 0;
rv = GetColumnCount(&columnCount);
NS_ENSURE_SUCCESS(rv, rv);
PRInt32 selectedCellsCount = selectedRowsCount * columnsCount;
PRInt32 selectedCellCount = selectedrowCount * columnCount;
PRInt32* outArray = static_cast<PRInt32*>(
nsMemory::Alloc(selectedCellsCount * sizeof(PRInt32)));
nsMemory::Alloc(selectedCellCount * sizeof(PRInt32)));
NS_ENSURE_TRUE(outArray, NS_ERROR_OUT_OF_MEMORY);
nsCOMPtr<nsITreeSelection> selection;
rv = mTreeView->GetSelection(getter_AddRefs(selection));
NS_ENSURE_SUCCESS(rv, rv);
PRInt32 rowsCount = 0;
rv = GetRows(&rowsCount);
PRInt32 rowCount = 0;
rv = GetRowCount(&rowCount);
NS_ENSURE_SUCCESS(rv, rv);
PRBool isSelected;
for (PRInt32 rowIdx = 0, arrayIdx = 0; rowIdx < rowsCount; rowIdx++) {
for (PRInt32 rowIdx = 0, arrayIdx = 0; rowIdx < rowCount; rowIdx++) {
selection->IsSelected(rowIdx, &isSelected);
if (isSelected) {
for (PRInt32 colIdx = 0; colIdx < columnsCount; colIdx++)
outArray[arrayIdx++] = rowIdx * columnsCount + colIdx;
for (PRInt32 colIdx = 0; colIdx < columnCount; colIdx++)
outArray[arrayIdx++] = rowIdx * columnCount + colIdx;
}
}
*aCellsCount = selectedCellsCount;
*aCellsCount = selectedCellCount;
*aCells = outArray;
return NS_OK;
}
NS_IMETHODIMP
nsXULTreeGridAccessible::GetSelectedColumns(PRUint32 *aColumnsCount,
PRInt32 **aColumns)
nsXULTreeGridAccessible::GetSelectedColumnIndices(PRUint32 *acolumnCount,
PRInt32 **aColumns)
{
NS_ENSURE_ARG_POINTER(aColumnsCount);
*aColumnsCount = 0;
NS_ENSURE_ARG_POINTER(acolumnCount);
*acolumnCount = 0;
NS_ENSURE_ARG_POINTER(aColumns);
*aColumns = nsnull;
@ -261,74 +285,75 @@ nsXULTreeGridAccessible::GetSelectedColumns(PRUint32 *aColumnsCount,
// If all the row has been selected, then all the columns are selected.
// Because we can't select a column alone.
PRInt32 rowsCount = 0;
nsresult rv = GetRows(&rowsCount);
PRInt32 rowCount = 0;
nsresult rv = GetRowCount(&rowCount);
NS_ENSURE_SUCCESS(rv, rv);
PRInt32 selectedRowsCount = 0;
rv = GetSelectionCount(&selectedRowsCount);
PRInt32 selectedrowCount = 0;
rv = GetSelectionCount(&selectedrowCount);
NS_ENSURE_SUCCESS(rv, rv);
if (rowsCount != selectedRowsCount)
if (rowCount != selectedrowCount)
return NS_OK;
PRInt32 columnsCount = 0;
rv = GetColumns(&columnsCount);
PRInt32 columnCount = 0;
rv = GetColumnCount(&columnCount);
NS_ENSURE_SUCCESS(rv, rv);
PRInt32* outArray = static_cast<PRInt32*>(
nsMemory::Alloc(columnsCount * sizeof(PRInt32)));
nsMemory::Alloc(columnCount * sizeof(PRInt32)));
NS_ENSURE_TRUE(outArray, NS_ERROR_OUT_OF_MEMORY);
for (PRInt32 colIdx = 0; colIdx < columnsCount; colIdx++)
for (PRInt32 colIdx = 0; colIdx < columnCount; colIdx++)
outArray[colIdx] = colIdx;
*aColumnsCount = columnsCount;
*acolumnCount = columnCount;
*aColumns = outArray;
return NS_OK;
}
NS_IMETHODIMP
nsXULTreeGridAccessible::GetSelectedRows(PRUint32 *aRowsCount, PRInt32 **aRows)
nsXULTreeGridAccessible::GetSelectedRowIndices(PRUint32 *arowCount,
PRInt32 **aRows)
{
NS_ENSURE_ARG_POINTER(aRowsCount);
*aRowsCount = 0;
NS_ENSURE_ARG_POINTER(arowCount);
*arowCount = 0;
NS_ENSURE_ARG_POINTER(aRows);
*aRows = nsnull;
if (IsDefunct())
return NS_ERROR_FAILURE;
PRInt32 selectedRowsCount = 0;
nsresult rv = GetSelectionCount(&selectedRowsCount);
PRInt32 selectedrowCount = 0;
nsresult rv = GetSelectionCount(&selectedrowCount);
NS_ENSURE_SUCCESS(rv, rv);
PRInt32* outArray = static_cast<PRInt32*>(
nsMemory::Alloc(selectedRowsCount * sizeof(PRInt32)));
nsMemory::Alloc(selectedrowCount * sizeof(PRInt32)));
NS_ENSURE_TRUE(outArray, NS_ERROR_OUT_OF_MEMORY);
nsCOMPtr<nsITreeSelection> selection;
rv = mTreeView->GetSelection(getter_AddRefs(selection));
NS_ENSURE_SUCCESS(rv, rv);
PRInt32 rowsCount = 0;
rv = GetRows(&rowsCount);
PRInt32 rowCount = 0;
rv = GetRowCount(&rowCount);
NS_ENSURE_SUCCESS(rv, rv);
PRBool isSelected;
for (PRInt32 rowIdx = 0, arrayIdx = 0; rowIdx < rowsCount; rowIdx++) {
for (PRInt32 rowIdx = 0, arrayIdx = 0; rowIdx < rowCount; rowIdx++) {
selection->IsSelected(rowIdx, &isSelected);
if (isSelected)
outArray[arrayIdx++] = rowIdx;
}
*aRowsCount = selectedRowsCount;
*arowCount = selectedrowCount;
*aRows = outArray;
return NS_OK;
}
NS_IMETHODIMP
nsXULTreeGridAccessible::CellRefAt(PRInt32 aRowIndex, PRInt32 aColumnIndex,
nsXULTreeGridAccessible::GetCellAt(PRInt32 aRowIndex, PRInt32 aColumnIndex,
nsIAccessible **aCell)
{
NS_ENSURE_ARG_POINTER(aCell);
@ -355,8 +380,8 @@ nsXULTreeGridAccessible::CellRefAt(PRInt32 aRowIndex, PRInt32 aColumnIndex,
}
NS_IMETHODIMP
nsXULTreeGridAccessible::GetIndexAt(PRInt32 aRowIndex, PRInt32 aColumnIndex,
PRInt32 *aCellIndex)
nsXULTreeGridAccessible::GetCellIndexAt(PRInt32 aRowIndex, PRInt32 aColumnIndex,
PRInt32 *aCellIndex)
{
NS_ENSURE_ARG_POINTER(aCellIndex);
*aCellIndex = -1;
@ -364,40 +389,40 @@ nsXULTreeGridAccessible::GetIndexAt(PRInt32 aRowIndex, PRInt32 aColumnIndex,
if (IsDefunct())
return NS_ERROR_FAILURE;
PRInt32 columnsCount = 0;
nsresult rv = GetColumns(&columnsCount);
PRInt32 columnCount = 0;
nsresult rv = GetColumnCount(&columnCount);
NS_ENSURE_SUCCESS(rv, rv);
*aCellIndex = aRowIndex * columnsCount + aColumnIndex;
*aCellIndex = aRowIndex * columnCount + aColumnIndex;
return NS_OK;
}
NS_IMETHODIMP
nsXULTreeGridAccessible::GetColumnAtIndex(PRInt32 aCellIndex,
nsXULTreeGridAccessible::GetColumnIndexAt(PRInt32 aCellIndex,
PRInt32 *aColumnIndex)
{
NS_ENSURE_ARG_POINTER(aColumnIndex);
*aColumnIndex = -1;
PRInt32 columnsCount = 0;
nsresult rv = GetColumns(&columnsCount);
PRInt32 columnCount = 0;
nsresult rv = GetColumnCount(&columnCount);
NS_ENSURE_SUCCESS(rv, rv);
*aColumnIndex = aCellIndex % columnsCount;
*aColumnIndex = aCellIndex % columnCount;
return NS_OK;
}
NS_IMETHODIMP
nsXULTreeGridAccessible::GetRowAtIndex(PRInt32 aCellIndex, PRInt32 *aRowIndex)
nsXULTreeGridAccessible::GetRowIndexAt(PRInt32 aCellIndex, PRInt32 *aRowIndex)
{
NS_ENSURE_ARG_POINTER(aRowIndex);
*aRowIndex = -1;
PRInt32 columnsCount;
nsresult rv = GetColumns(&columnsCount);
PRInt32 columnCount;
nsresult rv = GetColumnCount(&columnCount);
NS_ENSURE_SUCCESS(rv, rv);
*aRowIndex = aCellIndex / columnsCount;
*aRowIndex = aCellIndex / columnCount;
return NS_OK;
}
@ -428,7 +453,19 @@ nsXULTreeGridAccessible::GetColumnDescription(PRInt32 aColumnIndex,
{
aDescription.Truncate();
return NS_ERROR_NOT_IMPLEMENTED;
if (IsDefunct())
return NS_ERROR_FAILURE;
nsCOMPtr<nsIAccessible> treeColumns;
nsAccessible::GetFirstChild(getter_AddRefs(treeColumns));
if (treeColumns) {
nsCOMPtr<nsIAccessible> treeColumnItem;
treeColumns->GetChildAt(aColumnIndex, getter_AddRefs(treeColumnItem));
if (treeColumnItem)
return treeColumnItem->GetName(aDescription);
}
return NS_OK;
}
NS_IMETHODIMP
@ -436,8 +473,7 @@ nsXULTreeGridAccessible::GetRowDescription(PRInt32 aRowIndex,
nsAString& aDescription)
{
aDescription.Truncate();
return NS_ERROR_NOT_IMPLEMENTED;
return NS_OK;
}
NS_IMETHODIMP
@ -453,15 +489,15 @@ nsXULTreeGridAccessible::IsColumnSelected(PRInt32 aColumnIndex,
// If all the row has been selected, then all the columns are selected.
// Because we can't select a column alone.
PRInt32 rowsCount = 0;
nsresult rv = GetRows(&rowsCount);
PRInt32 rowCount = 0;
nsresult rv = GetRowCount(&rowCount);
NS_ENSURE_SUCCESS(rv, rv);
PRInt32 selectedRowsCount = 0;
rv = GetSelectionCount(&selectedRowsCount);
PRInt32 selectedrowCount = 0;
rv = GetSelectionCount(&selectedrowCount);
NS_ENSURE_SUCCESS(rv, rv);
*aIsSelected = rowsCount == selectedRowsCount;
*aIsSelected = rowCount == selectedrowCount;
return NS_OK;
}
@ -647,7 +683,7 @@ nsXULTreeGridRowAccessible::GetChildCount(PRInt32 *aChildCount)
if (IsDefunct())
return NS_ERROR_FAILURE;
*aChildCount = nsCoreUtils::GetSensibleColumnsCount(mTree);
*aChildCount = nsCoreUtils::GetSensiblecolumnCount(mTree);
return NS_OK;
}
@ -741,8 +777,8 @@ nsXULTreeGridRowAccessible::GetCellAccessible(nsITreeColumn* aColumn,
if (!accessNode) {
nsRefPtr<nsAccessNode> cellAcc =
new nsXULTreeGridCellAccessible(mDOMNode, mWeakShell, this, mTree,
mTreeView, mRow, aColumn);
new nsXULTreeGridCellAccessibleWrap(mDOMNode, mWeakShell, this, mTree,
mTreeView, mRow, aColumn);
if (!cellAcc)
return;
@ -801,8 +837,9 @@ nsXULTreeGridCellAccessible(nsIDOMNode *aDOMNode, nsIWeakReference *aShell,
////////////////////////////////////////////////////////////////////////////////
// nsXULTreeGridCellAccessible: nsISupports implementation
NS_IMPL_ISUPPORTS_INHERITED1(nsXULTreeGridCellAccessible,
NS_IMPL_ISUPPORTS_INHERITED2(nsXULTreeGridCellAccessible,
nsLeafAccessible,
nsIAccessibleTableCell,
nsXULTreeGridCellAccessible)
////////////////////////////////////////////////////////////////////////////////
@ -1030,6 +1067,131 @@ nsXULTreeGridCellAccessible::DoAction(PRUint8 aIndex)
return NS_ERROR_INVALID_ARG;
}
////////////////////////////////////////////////////////////////////////////////
// nsXULTreeGridCellAccessible: nsIAccessibleTableCell implementation
NS_IMETHODIMP
nsXULTreeGridCellAccessible::GetTable(nsIAccessibleTable **aTable)
{
NS_ENSURE_ARG_POINTER(aTable);
*aTable = nsnull;
if (IsDefunct())
return NS_OK;
nsCOMPtr<nsIAccessible> accessible;
mParent->GetParent(getter_AddRefs(accessible));
CallQueryInterface(accessible, aTable);
return NS_OK;
}
NS_IMETHODIMP
nsXULTreeGridCellAccessible::GetColumnIndex(PRInt32 *aColumnIndex)
{
NS_ENSURE_ARG_POINTER(aColumnIndex);
*aColumnIndex = -1;
if (IsDefunct())
return NS_ERROR_FAILURE;
*aColumnIndex = GetColumnIndex();
return NS_OK;
}
NS_IMETHODIMP
nsXULTreeGridCellAccessible::GetRowIndex(PRInt32 *aRowIndex)
{
NS_ENSURE_ARG_POINTER(aRowIndex);
*aRowIndex = -1;
if (IsDefunct())
return NS_ERROR_FAILURE;
*aRowIndex = mRow;
return NS_OK;
}
NS_IMETHODIMP
nsXULTreeGridCellAccessible::GetColumnExtent(PRInt32 *aExtentCount)
{
NS_ENSURE_ARG_POINTER(aExtentCount);
*aExtentCount = 1;
return NS_OK;
}
NS_IMETHODIMP
nsXULTreeGridCellAccessible::GetRowExtent(PRInt32 *aExtentCount)
{
NS_ENSURE_ARG_POINTER(aExtentCount);
*aExtentCount = 1;
return NS_OK;
}
NS_IMETHODIMP
nsXULTreeGridCellAccessible::GetColumnHeaderCells(nsIArray **aHeaderCells)
{
NS_ENSURE_ARG_POINTER(aHeaderCells);
*aHeaderCells = nsnull;
if (IsDefunct())
return NS_ERROR_FAILURE;
nsresult rv = NS_OK;
nsCOMPtr<nsIMutableArray> headerCells =
do_CreateInstance(NS_ARRAY_CONTRACTID, &rv);
NS_ENSURE_SUCCESS(rv, rv);
nsCOMPtr<nsIDOMElement> columnElm;
mColumn->GetElement(getter_AddRefs(columnElm));
nsCOMPtr<nsIAccessible> headerCell;
GetAccService()->GetAccessibleInWeakShell(columnElm, mWeakShell,
getter_AddRefs(headerCell));
if (headerCell)
headerCells->AppendElement(headerCell, PR_FALSE);
NS_ADDREF(*aHeaderCells = headerCells);
return NS_OK;
}
NS_IMETHODIMP
nsXULTreeGridCellAccessible::GetRowHeaderCells(nsIArray **aHeaderCells)
{
NS_ENSURE_ARG_POINTER(aHeaderCells);
*aHeaderCells = nsnull;
if (IsDefunct())
return NS_ERROR_FAILURE;
nsresult rv = NS_OK;
nsCOMPtr<nsIMutableArray> headerCells =
do_CreateInstance(NS_ARRAY_CONTRACTID, &rv);
NS_ENSURE_SUCCESS(rv, rv);
NS_ADDREF(*aHeaderCells = headerCells);
return NS_OK;
}
NS_IMETHODIMP
nsXULTreeGridCellAccessible::IsSelected(PRBool *aIsSelected)
{
NS_ENSURE_ARG_POINTER(aIsSelected);
*aIsSelected = PR_FALSE;
if (IsDefunct())
return NS_ERROR_FAILURE;
nsCOMPtr<nsITreeSelection> selection;
nsresult rv = mTreeView->GetSelection(getter_AddRefs(selection));
NS_ENSURE_SUCCESS(rv, rv);
return selection->IsSelected(mRow, aIsSelected);
}
////////////////////////////////////////////////////////////////////////////////
// nsXULTreeGridCellAccessible: nsAccessNode implementation
@ -1072,10 +1234,14 @@ nsXULTreeGridCellAccessible::GetAttributesInternal(nsIPersistentProperties *aAtt
mParent->GetParent(getter_AddRefs(accessible));
nsCOMPtr<nsIAccessibleTable> tableAccessible = do_QueryInterface(accessible);
// XXX - temp fix for crash bug 516047
if (!tableAccessible)
return NS_ERROR_FAILURE;
PRInt32 colIdx = GetColumnIndex();
PRInt32 cellIdx = -1;
tableAccessible->GetIndexAt(mRow, colIdx, &cellIdx);
tableAccessible->GetCellIndexAt(mRow, colIdx, &cellIdx);
nsAutoString stringIdx;
stringIdx.AppendInt(cellIdx);
@ -1166,7 +1332,7 @@ nsXULTreeGridCellAccessible::CellInvalidated()
mTreeView->GetCellValue(mRow, mColumn, textEquiv);
if (mCachedTextEquiv != textEquiv) {
PRBool isEnabled = textEquiv.EqualsLiteral("true");
nsCOMPtr<nsIAccessibleStateChangeEvent> accEvent =
nsCOMPtr<nsIAccessibleEvent> accEvent =
new nsAccStateChangeEvent(this, nsIAccessibleStates::STATE_CHECKED,
PR_FALSE, isEnabled);
if (accEvent)

Просмотреть файл

@ -123,7 +123,8 @@ protected:
{ 0xa9, 0x32, 0x4c, 0x5c, 0xa5, 0xde, 0x5d, 0xff } \
}
class nsXULTreeGridCellAccessible : public nsLeafAccessible
class nsXULTreeGridCellAccessible : public nsLeafAccessible,
public nsIAccessibleTableCell
{
public:
nsXULTreeGridCellAccessible(nsIDOMNode *aDOMNode, nsIWeakReference *aShell,
@ -152,6 +153,9 @@ public:
NS_IMETHOD GetActionName(PRUint8 aIndex, nsAString& aName);
NS_IMETHOD DoAction(PRUint8 aIndex);
// nsIAccessibleTableCell
NS_DECL_NSIACCESSIBLETABLECELL
// nsAccessNode
virtual PRBool IsDefunct();
virtual nsresult Init();

Просмотреть файл

@ -70,6 +70,7 @@ _TEST_FILES =\
value.js \
test_accessnode_invalidation.html \
test_actions.xul \
test_actions_anchors.html \
test_actions_aria.html \
test_actions_inputs.html \
test_actions_tree.xul \
@ -77,7 +78,6 @@ _TEST_FILES =\
test_aria_activedescendant.html \
test_aria_role_article.html \
test_aria_role_equation.html \
test_aria_role_grid.html \
test_aria_roles.html \
test_aria_roles.xul \
test_aria_token_attrs.html \
@ -88,13 +88,15 @@ _TEST_FILES =\
test_cssattrs.html \
test_descr.html \
test_elm_filectrl.html \
test_elm_listbox.xul \
$(warning test_elm_media.html temporarily disabled) \
test_elm_table.html \
test_elm_tree.xul \
test_elm_txtcntnr.html \
test_events_caretmove.html \
test_events_coalescence.html \
test_events_doc.html \
test_events_draganddrop.html \
test_events_flush.html \
test_events_focus.xul \
test_events_mutation.html \
test_events_tree.xul \
@ -117,13 +119,11 @@ _TEST_FILES =\
test_nsIAccessibleHyperLink.xul \
test_nsIAccessibleHyperText.html \
test_nsIAccessibleImage.html \
$(warning test_nsIAccessibleTable_listboxes.xul temporarily disabled) \
test_nsIAccessNode_utils.html \
test_nsOuterDocAccessible.html \
test_objectattrs.html \
test_relations.html \
test_relations.xul \
test_relations_table.html \
test_relations_tree.xul \
test_role_nsHyperTextAcc.html \
test_role_table_cells.html \
@ -135,15 +135,25 @@ _TEST_FILES =\
test_states_popup.xul \
test_states_tree.xul \
test_table_1.html \
test_table_2.html \
test_table_4.html \
test_table_headers.html \
test_table_headers_ariagrid.html \
test_table_headers_listbox.xul \
test_table_headers_tree.xul \
test_table_indexes.html \
test_table_indexes_ariagrid.html \
test_table_indexes_listbox.xul \
test_table_indexes_tree.xul \
test_table_layoutguess.html \
test_table_sels.html \
test_table_sels_ariagrid.html \
test_table_sels_listbox.xul \
test_table_sels_tree.xul \
test_table_struct.html \
test_table_struct_ariagrid.html \
test_table_struct_ariatreegrid.html \
test_table_struct_listbox.xul \
test_table_struct_tree.xul \
test_textattrs.html \
test_textboxes.html \
test_textboxes.xul \

Просмотреть файл

@ -22,7 +22,7 @@ function testAttrs(aAccOrElmOrID, aAttrs, aSkipUnexpectedAttrs)
* @param aAbsentAttrs [in] map of attributes that should not be
* present (name/value pairs)
*/
function testAbsentAttrs(aAccOrElmOrID, aAbsentAttrs, aSkipUnexpectedAttrs)
function testAbsentAttrs(aAccOrElmOrID, aAbsentAttrs)
{
testAttrsInternal(aAccOrElmOrID, {}, true, aAbsentAttrs);
}
@ -190,6 +190,7 @@ function testAttrsInternal(aAccOrElmOrID, aAttrs, aSkipUnexpectedAttrs,
function compareAttrs(aErrorMsg, aAttrs, aExpectedAttrs, aSkipUnexpectedAttrs,
aAbsentAttrs)
{
// Check if all obtained attributes are expected and have expected value.
var enumerate = aAttrs.enumerate();
while (enumerate.hasMoreElements()) {
var prop = enumerate.getNext().QueryInterface(nsIPropertyElement);
@ -209,6 +210,7 @@ function compareAttrs(aErrorMsg, aAttrs, aExpectedAttrs, aSkipUnexpectedAttrs,
}
}
// Check if all expected attributes are presented.
for (var name in aExpectedAttrs) {
var value = "";
try {
@ -220,18 +222,20 @@ function compareAttrs(aErrorMsg, aAttrs, aExpectedAttrs, aSkipUnexpectedAttrs,
"There is no expected attribute '" + name + "' " + aErrorMsg);
}
if (aAbsentAttrs)
// Check if all unexpected attributes are absent.
if (aAbsentAttrs) {
for (var name in aAbsentAttrs) {
var value = "";
try {
value = aAttrs.getStringProperty(name);
} catch(e) { }
var wasFound = false;
if (value)
ok(false,
"There is an unexpected attribute '" + name + "' " + aErrorMsg);
else
ok(true,
"There is no unexpected attribute '" + name + "' " + aErrorMsg);
var enumerate = aAttrs.enumerate();
while (enumerate.hasMoreElements()) {
var prop = enumerate.getNext().QueryInterface(nsIPropertyElement);
if (prop.key == name)
wasFound = true;
}
}
ok(!wasFound,
"There is an unexpected attribute '" + name + "' " + aErrorMsg);
}
}

Просмотреть файл

@ -32,6 +32,7 @@ const nsIAccessibleHyperText = Components.interfaces.nsIAccessibleHyperText;
const nsIAccessibleImage = Components.interfaces.nsIAccessibleImage;
const nsIAccessibleSelectable = Components.interfaces.nsIAccessibleSelectable;
const nsIAccessibleTable = Components.interfaces.nsIAccessibleTable;
const nsIAccessibleTableCell = Components.interfaces.nsIAccessibleTableCell;
const nsIAccessibleValue = Components.interfaces.nsIAccessibleValue;
const nsIObserverService = Components.interfaces.nsIObserverService;
@ -292,6 +293,15 @@ function ensureAccessibleTree(aAccOrElmOrID)
/**
* Compare expected and actual accessibles trees.
*
* @param aAccOrElmOrID [in] accessible identifier
* @param aAccTree [in] JS object, each field corresponds to property of
* accessible object. Additionally special properties
* are presented:
* children - an array of JS objects representing
* children of accessible
* states - an object having states and extraStates
* fields
*/
function testAccessibleTree(aAccOrElmOrID, aAccTree)
{
@ -300,7 +310,7 @@ function testAccessibleTree(aAccOrElmOrID, aAccTree)
return;
for (var prop in aAccTree) {
var msg = "Wrong value of property '" + prop + "'.";
var msg = "Wrong value of property '" + prop + "' for " + prettyName(acc) + ".";
if (prop == "role") {
is(roleToString(acc[prop]), roleToString(aAccTree[prop]), msg);

Просмотреть файл

@ -1,11 +1,13 @@
////////////////////////////////////////////////////////////////////////////////
// Constants
const EVENT_HIDE = nsIAccessibleEvent.EVENT_HIDE;
const EVENT_SHOW = nsIAccessibleEvent.EVENT_SHOW;
const EVENT_DOCUMENT_LOAD_COMPLETE =
nsIAccessibleEvent.EVENT_DOCUMENT_LOAD_COMPLETE;
const EVENT_DOM_DESTROY = nsIAccessibleEvent.EVENT_DOM_DESTROY;
const EVENT_FOCUS = nsIAccessibleEvent.EVENT_FOCUS;
const EVENT_NAME_CHANGE = nsIAccessibleEvent.EVENT_NAME_CHANGE;
const EVENT_SCROLLING_START = nsIAccessibleEvent.EVENT_SCROLLING_START;
const EVENT_STATE_CHANGE = nsIAccessibleEvent.EVENT_STATE_CHANGE;
const EVENT_REORDER = nsIAccessibleEvent.EVENT_REORDER;
@ -122,15 +124,10 @@ function invokerChecker(aEventType, aTarget)
* // (used in the case when invoker expects single event).
* DOMNode getter: function() {},
*
* // Array of items defining events expected (or not expected, see
* // 'doNotExpectEvents' property) on invoker's action.
* // Array of checker objects defining expected events on invoker's action.
* //
* // Every array item should be either
* // 1) an array consisted from two elements, the first element is DOM or
* // a11y event type, second element is event target (DOM node or
* // accessible).
* // Checker object interface:
* //
* // 2) object (invoker's checker object) like
* // var checker = {
* // type getter: function() {}, // DOM or a11y event type
* // target getter: function() {}, // DOM node or accessible
@ -140,9 +137,9 @@ function invokerChecker(aEventType, aTarget)
* // };
* eventSeq getter() {},
*
* // [optional, used together with 'eventSeq'] Boolean indicates if events
* // specified by 'eventSeq' property shouldn't be triggerd by invoker.
* doNotExpectEvents getter() {},
* // Array of checker objects defining unexpected events on invoker's
* // action.
* unexpectedEventSeq getter() {},
*
* // The ID of invoker.
* getID: function(){} // returns invoker ID
@ -173,8 +170,7 @@ function eventQueue(aEventType)
// XXX: Intermittent test_events_caretmove.html fails withouth timeout,
// see bug 474952.
window.setTimeout(function(aQueue) { aQueue.processNextInvoker(); }, 500,
this);
this.processNextInvokerInTimeout(true);
}
/**
@ -197,15 +193,20 @@ function eventQueue(aEventType)
var invoker = this.getInvoker();
if (invoker) {
if ("finalCheck" in invoker)
invoker.finalCheck();
if (invoker.wasCaught) {
for (var idx = 0; idx < invoker.wasCaught.length; idx++) {
var id = this.getEventID(idx);
var type = this.getEventType(idx);
var unexpected = this.mEventSeq[idx].unexpected;
var typeStr = (typeof type == "string") ?
type : gAccRetrieval.getStringEventType(type);
var msg = "test with ID = '" + id + "' failed. ";
if (invoker.doNotExpectEvents) {
if (unexpected) {
var wasCaught = invoker.wasCaught[idx];
if (!testFailed)
testFailed = wasCaught;
@ -255,11 +256,22 @@ function eventQueue(aEventType)
return;
}
if (invoker.doNotExpectEvents) {
// Check in timeout invoker didn't fire registered events.
window.setTimeout(function(aQueue) { aQueue.processNextInvoker(); }, 500,
this);
if (this.areAllEventsUnexpected())
this.processNextInvokerInTimeout(true);
}
this.processNextInvokerInTimeout = function eventQueue_processNextInvokerInTimeout(aUncondProcess)
{
if (!aUncondProcess && this.areAllEventsExpected()) {
// We need delay to avoid events coalesce from different invokers.
var queue = this;
SimpleTest.executeSoon(function() { queue.processNextInvoker(); });
return;
}
// Check in timeout invoker didn't fire registered events.
window.setTimeout(function(aQueue) { aQueue.processNextInvoker(); }, 500,
this);
}
/**
@ -281,33 +293,38 @@ function eventQueue(aEventType)
if ("debugCheck" in invoker)
invoker.debugCheck(aEvent);
if (invoker.doNotExpectEvents) {
// Search through event sequence to ensure it doesn't contain handled
// event.
for (var idx = 0; idx < this.mEventSeq.length; idx++) {
if (this.compareEvents(idx, aEvent))
invoker.wasCaught[idx] = true;
}
} else {
// We wait for events in order specified by eventSeq variable.
var idx = this.mEventSeqIdx + 1;
var matched = this.compareEvents(idx, aEvent);
this.dumpEventToDOM(aEvent, idx, matched);
if (matched) {
this.checkEvent(idx, aEvent);
// Search through unexpected events to ensure no one of them was handled.
for (var idx = 0; idx < this.mEventSeq.length; idx++) {
if (this.mEventSeq[idx].unexpected && this.compareEvents(idx, aEvent))
invoker.wasCaught[idx] = true;
}
if (idx == this.mEventSeq.length - 1) {
// We need delay to avoid events coalesce from different invokers.
var queue = this;
SimpleTest.executeSoon(function() { queue.processNextInvoker(); });
return;
}
// Wait for next expected event in an order specified by event sequence.
this.mEventSeqIdx = idx;
// Compute next expected event index.
for (var idx = this.mEventSeqIdx + 1;
idx < this.mEventSeq.length && this.mEventSeq[idx].unexpected; idx++);
if (idx == this.mEventSeq.length) {
// There is no expected events in the sequence.
this.processNextInvokerInTimeout();
return;
}
var matched = this.compareEvents(idx, aEvent);
this.dumpEventToDOM(aEvent, idx, matched);
if (matched) {
this.checkEvent(idx, aEvent);
invoker.wasCaught[idx] = true;
// The last event is expected and was handled, proceed next invoker.
if (idx == this.mEventSeq.length - 1) {
this.processNextInvokerInTimeout();
return;
}
this.mEventSeqIdx = idx;
}
}
@ -324,12 +341,26 @@ function eventQueue(aEventType)
this.setEventHandler = function eventQueue_setEventHandler(aInvoker)
{
// Create unique event sequence concatenating expected and unexpected
// events.
this.mEventSeq = ("eventSeq" in aInvoker) ?
aInvoker.eventSeq :
[ new invokerChecker(this.mDefEventType, aInvoker.DOMNode) ];
for (var idx = 0; idx < this.mEventSeq.length; idx++)
this.mEventSeq[idx].unexpected = false;
var unexpectedSeq = aInvoker.unexpectedEventSeq;
if (unexpectedSeq) {
for (var idx = 0; idx < unexpectedSeq.length; idx++)
unexpectedSeq[idx].unexpected = true;
this.mEventSeq = this.mEventSeq.concat(unexpectedSeq);
}
this.mEventSeqIdx = -1;
// Register event listeners
if (this.mEventSeq) {
aInvoker.wasCaught = new Array(this.mEventSeq.length);
@ -389,6 +420,16 @@ function eventQueue(aEventType)
return true;
}
this.getEventID = function eventQueue_getEventID(aIdx)
{
var eventItem = this.mEventSeq[aIdx];
if ("getID" in eventItem)
return eventItem.getID();
var invoker = this.getInvoker();
return invoker.getID();
}
this.compareEvents = function eventQueue_compareEvents(aIdx, aEvent)
{
var eventType1 = this.getEventType(aIdx);
@ -425,14 +466,24 @@ function eventQueue(aEventType)
invoker.check(aEvent);
}
this.getEventID = function eventQueue_getEventID(aIdx)
this.areAllEventsExpected = function eventQueue_areAllEventsExpected()
{
var eventItem = this.mEventSeq[aIdx];
if ("getID" in eventItem)
return eventItem.getID();
for (var idx = 0; idx < this.mEventSeq.length; idx++) {
if (this.mEventSeq[idx].unexpected)
return false;
}
var invoker = this.getInvoker();
return invoker.getID();
return true;
}
this.areAllEventsUnexpected = function eventQueue_areAllEventsUnxpected()
{
for (var idx = 0; idx < this.mEventSeq.length; idx++) {
if (!this.mEventSeq[idx].unexpected)
return false;
}
return true;
}
this.dumpEventToDOM = function eventQueue_dumpEventToDOM(aOrigEvent,

Просмотреть файл

@ -5,7 +5,7 @@ const nsIDOMKeyEvent = Components.interfaces.nsIDOMKeyEvent;
*/
function grid(aTableIdentifier)
{
this.getRowsCount = function getRowsCount()
this.getRowCount = function getRowCount()
{
return this.table.rows.length - (this.table.tHead ? 1 : 0);
}
@ -21,12 +21,12 @@ function grid(aTableIdentifier)
this.getMaxIndex = function getMaxIndex()
{
return this.getRowsCount() * this.getColsCount() - 1;
return this.getRowCount() * this.getColsCount() - 1;
}
this.getCellAtIndex = function getCellAtIndex(aIndex)
{
var rowsCount = this.getRowsCount();
var rowCount = this.getRowCount();
var colsCount = this.getColsCount();
var rowIdx = Math.floor(aIndex / colsCount);
@ -50,9 +50,9 @@ function grid(aTableIdentifier)
this.getCurrentCell = function getCurrentCell()
{
var rowsCount = this.table.rows.length;
var rowCount = this.table.rows.length;
var colsCount = this.getColsCount();
for (var rowIdx = 0; rowIdx < rowsCount; rowIdx++) {
for (var rowIdx = 0; rowIdx < rowCount; rowIdx++) {
for (var colIdx = 0; colIdx < colsCount; colIdx++) {
var cell = this.table.rows[rowIdx].cells[colIdx];
if (cell.hasAttribute("tabindex"))

Просмотреть файл

@ -4,6 +4,7 @@
const ROLE_ALERT = nsIAccessibleRole.ROLE_ALERT;
const ROLE_APPLICATION = nsIAccessibleRole.ROLE_APPLICATION;
const ROLE_APP_ROOT = nsIAccessibleRole.ROLE_APP_ROOT;
const ROLE_CAPTION = nsIAccessibleRole.ROLE_CAPTION;
const ROLE_CELL = nsIAccessibleRole.ROLE_CELL;
const ROLE_CHROME_WINDOW = nsIAccessibleRole.ROLE_CHROME_WINDOW;
const ROLE_COMBOBOX = nsIAccessibleRole.ROLE_COMBOBOX;
@ -34,6 +35,7 @@ const ROLE_PASSWORD_TEXT = nsIAccessibleRole.ROLE_PASSWORD_TEXT;
const ROLE_PROGRESSBAR = nsIAccessibleRole.ROLE_PROGRESSBAR;
const ROLE_PUSHBUTTON = nsIAccessibleRole.ROLE_PUSHBUTTON;
const ROLE_ROW = nsIAccessibleRole.ROLE_ROW;
const ROLE_ROWHEADER = nsIAccessibleRole.ROLE_ROWHEADER;
const ROLE_SECTION = nsIAccessibleRole.ROLE_SECTION;
const ROLE_SLIDER = nsIAccessibleRole.ROLE_SLIDER;
const ROLE_TABLE = nsIAccessibleRole.ROLE_TABLE;

Просмотреть файл

@ -4,9 +4,192 @@
*
* Required:
* common.js
* role.js
* states.js
*/
/**
* Constants used to describe cells array.
*/
const kDataCell = 1; // Indicates the cell is origin data cell
const kRowHeaderCell = 2; // Indicates the cell is row header cell
const kColHeaderCell = 4; // Indicated teh cell is column header cell
const kOrigin = kDataCell | kRowHeaderCell | kColHeaderCell;
const kRowSpanned = 8; // Indicates the cell is not origin and row spanned
const kColSpanned = 16; // Indicates the cell is not origin and column spanned
const kSpanned = kRowSpanned | kColSpanned;
/**
* Constants to define column header type.
*/
const kNoColumnHeader = 0;
const kListboxColumnHeader = 1;
const kTreeColumnHeader = 2;
/**
* Test table structure and related methods.
*
* @param aIdentifier [in] table accessible identifier
* @param aCellsArray [in] two dimensional array (row X columns) of
* cell types (see constants defined above).
* @param aColHeaderType [in] specifies wether column header cells are
* arranged into the list.
* @param aCaption [in] caption text if any
* @param aSummary [in] summary text if any
* @param aIsTreeTable [in] specifies whether given table is tree table
*/
function testTableStruct(aIdentifier, aCellsArray, aColHeaderType,
aCaption, aSummary, aIsTreeTable)
{
var tableNode = getNode(aIdentifier);
var isGrid = tableNode.getAttribute("role") == "grid" ||
tableNode.getAttribute("role") == "treegrid" ||
tableNode.localName == "tree";
var rowCount = aCellsArray.length;
var colsCount = aCellsArray[0].length;
// Test table accessible tree.
var tableObj = {
role: aIsTreeTable ? ROLE_TREE_TABLE : ROLE_TABLE,
children: []
};
// caption accessible handling
if (aCaption) {
var captionObj = {
role: ROLE_CAPTION,
children: [
{
role: ROLE_TEXT_LEAF,
name: aCaption
}
]
};
tableObj.children.push(captionObj);
}
// special types of column headers handling
if (aColHeaderType) {
var headersObj = {
role: ROLE_LIST,
children: []
};
for (var idx = 0; idx < colsCount; idx++) {
var headerCellObj = {
role: ROLE_COLUMNHEADER
};
headersObj.children.push(headerCellObj);
}
if (aColHeaderType == kTreeColumnHeader) {
var columnPickerObj = {
role: ROLE_PUSHBUTTON
};
headersObj.children.push(columnPickerObj);
}
tableObj.children.push(headersObj);
}
// rows and cells accessibles
for (var rowIdx = 0; rowIdx < rowCount; rowIdx++) {
var rowObj = {
role: ROLE_ROW,
children: []
};
for (var colIdx = 0; colIdx < colsCount; colIdx++) {
var celltype = aCellsArray[rowIdx][colIdx];
var role = ROLE_NOTHING;
switch (celltype) {
case kDataCell:
role = (isGrid ? ROLE_GRID_CELL : ROLE_CELL);
break;
case kRowHeaderCell:
role = ROLE_ROWHEADER;
break;
case kColHeaderCell:
role = ROLE_COLUMNHEADER;
break;
}
if (role != ROLE_NOTHING) {
var cellObj = {
role: role
};
rowObj.children.push(cellObj);
}
}
tableObj.children.push(rowObj);
}
testAccessibleTree(aIdentifier, tableObj);
// Test table table interface.
var table = getAccessible(aIdentifier, [nsIAccessibleTable]);
// summary
if (aSummary)
is(table.summary, aSummary,
"Wrong summary of the table " + prettyName(aIdentifier));
// rowCount and columnCount
is(table.rowCount, rowCount,
"Wrong rows count of " + prettyName(aIdentifier));
is(table.columnCount, colsCount,
"Wrong columns count of " + prettyName(aIdentifier));
// rows and columns extents
for (var rowIdx = 0; rowIdx < rowCount; rowIdx++) {
for (var colIdx = 0; colIdx < colsCount; colIdx++) {
var celltype = aCellsArray[rowIdx][colIdx];
if (celltype & kOrigin) {
// table getRowExtentAt
var rowExtent = table.getRowExtentAt(rowIdx, colIdx);
for (var idx = rowIdx + 1;
idx < rowCount && (aCellsArray[idx][colIdx] & kRowSpanned);
idx++);
var expectedRowExtent = idx - rowIdx;
is(rowExtent, expectedRowExtent,
"getRowExtentAt: Wrong number of spanned rows at (" + rowIdx + ", " +
colIdx + ") for " + prettyName(aIdentifier));
// table getColumnExtentAt
var colExtent = table.getColumnExtentAt(rowIdx, colIdx);
for (var idx = colIdx + 1;
idx < colsCount && (aCellsArray[rowIdx][idx] & kColSpanned);
idx++);
var expectedColExtent = idx - colIdx;
is(colExtent, expectedColExtent,
"getColumnExtentAt: Wrong number of spanned columns at (" + rowIdx +
", " + colIdx + ") for " + prettyName(aIdentifier));
// cell rowExtent and columnExtent
var cell = getAccessible(table.getCellAt(rowIdx, colIdx),
[nsIAccessibleTableCell]);
is(cell.rowExtent, expectedRowExtent,
"rowExtent: Wrong number of spanned rows at (" + rowIdx + ", " +
colIdx + ") for " + prettyName(aIdentifier));
is(cell.columnExtent, expectedColExtent,
"columnExtent: Wrong number of spanned column at (" + rowIdx + ", " +
colIdx + ") for " + prettyName(aIdentifier));
}
}
}
}
/**
* Test table indexes.
*
@ -30,16 +213,17 @@ function testTableIndexes(aIdentifier, aIdxes)
for (var colIdx = 0; colIdx < colCount; colIdx++) {
var idx = aIdxes[rowIdx][colIdx];
// cellRefAt
// getCellAt
try {
cellAcc = null;
cellAcc = tableAcc.cellRefAt(rowIdx, colIdx);
cellAcc = tableAcc.getCellAt(rowIdx, colIdx);
} catch (e) { }
ok(idx != -1 && cellAcc || idx == -1 && !cellAcc,
id + ": Can't get cell accessible at row = " + rowIdx + ", column = " + colIdx);
if (idx != - 1) {
// getRowAtIndex
var origRowIdx = rowIdx;
while (origRowIdx > 0 &&
@ -47,13 +231,13 @@ function testTableIndexes(aIdentifier, aIdxes)
origRowIdx--;
try {
obtainedRowIdx = tableAcc.getRowAtIndex(idx);
obtainedRowIdx = tableAcc.getRowIndexAt(idx);
} catch (e) {
ok(false, id + ": can't get row index for cell index " + idx + "," + e);
}
is(obtainedRowIdx, origRowIdx,
id + ": row for index " + idx +" is not correct");
id + ": row for index " + idx +" is not correct");
// getColumnAtIndex
var origColIdx = colIdx;
@ -62,7 +246,7 @@ function testTableIndexes(aIdentifier, aIdxes)
origColIdx--;
try {
obtainedColIdx = tableAcc.getColumnAtIndex(idx);
obtainedColIdx = tableAcc.getColumnIndexAt(idx);
} catch (e) {
ok(false, id + ": can't get column index for cell index " + idx + "," + e);
}
@ -70,27 +254,63 @@ function testTableIndexes(aIdentifier, aIdxes)
is(obtainedColIdx, origColIdx,
id + ": column for index " + idx +" is not correct");
// 'table-cell-index' attribute
if (cellAcc) {
var cellId = prettyName(cellAcc);
cellAcc = getAccessible(cellAcc, [nsIAccessibleTableCell]);
// cell: 'table-cell-index' attribute
var attrs = cellAcc.attributes;
var strIdx = "";
try {
strIdx = attrs.getStringProperty("table-cell-index");
} catch (e) {
ok(false,
id + ": no cell index from object attributes on the cell accessible at index " + idx + ".");
cellId + ": no cell index from object attributes on the cell accessible at index " + idx + ".");
}
if (strIdx) {
is (parseInt(strIdx), idx,
id + ": cell index from object attributes of cell accessible isn't corrent.");
cellId + ": cell index from object attributes of cell accessible isn't corrent.");
}
// cell: table
try {
is(cellAcc.table, tableAcc,
cellId + ": wrong table accessible for the cell.");
} catch (e) {
ok(false,
cellId + ": can't get table accessible from the cell.");
}
// cell: getRowIndex
try {
obtainedRowIdx = cellAcc.rowIndex;
} catch (e) {
ok(false,
cellId + ": can't get row index of the cell at index " + idx + "," + e);
}
is(obtainedRowIdx, origRowIdx,
cellId + ": row for the cell at index " + idx +" is not correct");
// cell: getColumnIndex
try {
obtainedColIdx = cellAcc.columnIndex;
} catch (e) {
ok(false,
cellId + ": can't get column index of the cell at index " + idx + "," + e);
}
is(obtainedColIdx, origColIdx,
id + ": column for the cell at index " + idx +" is not correct");
}
}
// getIndexAt
// getCellIndexAt
try {
obtainedIdx = tableAcc.getIndexAt(rowIdx, colIdx);
obtainedIdx = tableAcc.getCellIndexAt(rowIdx, colIdx);
} catch (e) {
obtainedIdx = -1;
}
@ -105,8 +325,9 @@ function testTableIndexes(aIdentifier, aIdxes)
* Test table getters selection methods.
*
* @param aIdentifier [in] table accessible identifier
* @param aCellsArray [in] two dimensional array (row X columns) of selected
* cells states.
* @param aCellsArray [in] two dimensional array (row X columns) of cells
* states (either boolean (selected/unselected) if cell is
* origin, otherwise kRowSpanned or kColSpanned constant).
* @param aMsg [in] text appended before every message
*/
function testTableSelection(aIdentifier, aCellsArray, aMsg)
@ -116,7 +337,7 @@ function testTableSelection(aIdentifier, aCellsArray, aMsg)
if (!acc)
return;
var rowsCount = aCellsArray.length;
var rowCount = aCellsArray.length;
var colsCount = aCellsArray[0].length;
// Columns selection tests.
@ -125,7 +346,7 @@ function testTableSelection(aIdentifier, aCellsArray, aMsg)
// isColumnSelected test
for (var colIdx = 0; colIdx < colsCount; colIdx++) {
var isColSelected = true;
for (var rowIdx = 0; rowIdx < rowsCount; rowIdx++) {
for (var rowIdx = 0; rowIdx < rowCount; rowIdx++) {
if (aCellsArray[rowIdx][colIdx] == false) {
isColSelected = false;
break;
@ -141,12 +362,12 @@ function testTableSelection(aIdentifier, aCellsArray, aMsg)
}
// selectedColsCount test
is(acc.selectedColumnsCount, selCols.length,
is(acc.selectedColumnCount, selCols.length,
msg + "Wrong count of selected columns for " + prettyName(aIdentifier));
// getSelectedColumns test
var actualSelColsCountObj = { value: null };
var actualSelCols = acc.getSelectedColumns(actualSelColsCountObj);
var actualSelCols = acc.getSelectedColumnIndices(actualSelColsCountObj);
var actualSelColsCount = actualSelColsCountObj.value;
is (actualSelColsCount, selCols.length,
@ -162,8 +383,8 @@ function testTableSelection(aIdentifier, aCellsArray, aMsg)
var selRows = new Array();
// isRowSelected test
var selRowsCount = 0;
for (var rowIdx = 0; rowIdx < rowsCount; rowIdx++) {
var selrowCount = 0;
for (var rowIdx = 0; rowIdx < rowCount; rowIdx++) {
var isRowSelected = true;
for (var colIdx = 0; colIdx < colsCount; colIdx++) {
if (aCellsArray[rowIdx][colIdx] == false) {
@ -180,20 +401,20 @@ function testTableSelection(aIdentifier, aCellsArray, aMsg)
selRows.push(rowIdx);
}
// selectedRowsCount test
is(acc.selectedRowsCount, selRows.length,
// selectedRowCount test
is(acc.selectedRowCount, selRows.length,
msg + "Wrong count of selected rows for " + prettyName(aIdentifier));
// getSelectedRows test
var actualSelRowsCountObj = { value: null };
var actualSelRows = acc.getSelectedRows(actualSelRowsCountObj);
var actualSelrowCountObj = { value: null };
var actualSelRows = acc.getSelectedRowIndices(actualSelrowCountObj);
var actualSelRowsCount = actualSelRowsCountObj.value;
is (actualSelRowsCount, selRows.length,
var actualSelrowCount = actualSelrowCountObj.value;
is (actualSelrowCount, selRows.length,
msg + "Wrong count of selected rows for " + prettyName(aIdentifier) +
"from getSelectedRows.");
for (var i = 0; i < actualSelRowsCount; i++) {
for (var i = 0; i < actualSelrowCount; i++) {
is (actualSelRows[i], selRows[i],
msg + "Row at index " + selRows[i] + " should be selected.");
}
@ -202,45 +423,64 @@ function testTableSelection(aIdentifier, aCellsArray, aMsg)
var selCells = new Array();
// isCellSelected test
for (var rowIdx = 0; rowIdx < rowsCount; rowIdx++) {
for (var rowIdx = 0; rowIdx < rowCount; rowIdx++) {
for (var colIdx = 0; colIdx < colsCount; colIdx++) {
if (aCellsArray[rowIdx][colIdx] == undefined)
if (aCellsArray[rowIdx][colIdx] & kSpanned)
continue;
is(acc.isCellSelected(rowIdx, colIdx), aCellsArray[rowIdx][colIdx],
msg + "Wrong selection state of cell at " + rowIdx + " row and " +
colIdx + " column for " + prettyName(aIdentifier));
if (aCellsArray[rowIdx][colIdx])
selCells.push(acc.getIndexAt(rowIdx, colIdx));
selCells.push(acc.getCellIndexAt(rowIdx, colIdx));
}
}
// selectedCellsCount tests
is(acc.selectedCellsCount, selCells.length,
// selectedCellCount tests
is(acc.selectedCellCount, selCells.length,
msg + "Wrong count of selected cells for " + prettyName(aIdentifier));
// getSelectedCells test
// getSelectedCellIndices test
var actualSelCellsCountObj = { value: null };
var actualSelCells = acc.getSelectedCells(actualSelCellsCountObj);
var actualSelCells = acc.getSelectedCellIndices(actualSelCellsCountObj);
var actualSelCellsCount = actualSelCellsCountObj.value;
is (actualSelCellsCount, selCells.length,
msg + "Wrong count of selected cells for " + prettyName(aIdentifier) +
"from getSelectedCells.");
is(actualSelCellsCount, selCells.length,
msg + "Wrong count of selected cells for " + prettyName(aIdentifier) +
"from getSelectedCells.");
for (var i = 0; i < actualSelCellsCount; i++) {
is (actualSelCells[i], selCells[i],
msg + "Cell at index " + selCells[i] + " should be selected.");
is(actualSelCells[i], selCells[i],
msg + "getSelectedCellIndices: Cell at index " + selCells[i] +
" should be selected.");
}
// selectedCells and isSelected tests
var actualSelCellsArray = acc.selectedCells;
for (var i = 0; i < actualSelCellsCount; i++) {
var actualSelCellAccessible =
actualSelCellsArray.queryElementAt(i, nsIAccessibleTableCell);
var colIdx = acc.getColumnIndexAt(selCells[i]);
var rowIdx = acc.getRowIndexAt(selCells[i]);
var expectedSelCellAccessible = acc.getCellAt(rowIdx, colIdx);
ok(actualSelCellAccessible, expectedSelCellAccessible,
msg + "getSelectedCells: Cell at index " + selCells[i] +
" should be selected.");
ok(actualSelCellAccessible.isSelected(),
"isSelected: Cell at index " + selCells[i] + " should be selected.");
}
// selected states tests
for (var rowIdx = 0; rowIdx < rowsCount; rowIdx++) {
for (var rowIdx = 0; rowIdx < rowCount; rowIdx++) {
for (var colIdx = 0; colIdx < colsCount; colIdx++) {
if (aCellsArray[rowIdx][colIdx] == undefined)
if (aCellsArray[rowIdx][colIdx] & kSpanned)
continue;
var cell = acc.cellRefAt(rowIdx, colIdx);
var cell = acc.getCellAt(rowIdx, colIdx);
var isSel = aCellsArray[rowIdx][colIdx];
if (isSel)
testStates(cell, STATE_SELECTED);
@ -259,10 +499,13 @@ function testUnselectTableColumn(aIdentifier, aColIdx, aCellsArray)
if (!acc)
return;
var rowsCount = aCellsArray.length;
for (var rowIdx = 0; rowIdx < rowsCount; rowIdx++) {
if (aCellsArray[rowIdx][aColIdx] != undefined)
aCellsArray[rowIdx][aColIdx] = false;
var rowCount = aCellsArray.length;
for (var rowIdx = 0; rowIdx < rowCount; rowIdx++) {
var cellState = aCellsArray[rowIdx][aColIdx];
// Unselect origin cell.
var [origRowIdx, origColIdx] =
getOrigRowAndColumn(aCellsArray, rowIdx, aColIdx);
aCellsArray[origRowIdx][origColIdx] = false;
}
acc.unselectColumn(aColIdx);
@ -279,13 +522,47 @@ function testSelectTableColumn(aIdentifier, aColIdx, aCellsArray)
if (!acc)
return;
var rowsCount = aCellsArray.length;
var rowCount = aCellsArray.length;
var colsCount = aCellsArray[0].length;
for (var rowIdx = 0; rowIdx < rowsCount; rowIdx++) {
for (var rowIdx = 0; rowIdx < rowCount; rowIdx++) {
for (var colIdx = 0; colIdx < colsCount; colIdx++) {
if (aCellsArray[rowIdx][colIdx] != undefined)
aCellsArray[rowIdx][colIdx] = (colIdx == aColIdx);
var cellState = aCellsArray[rowIdx][colIdx];
if (colIdx == aColIdx) { // select target column
if (!(cellState & kSpanned)) {
// Select the cell if it is origin.
aCellsArray[rowIdx][colIdx] = true;
} else {
// If the cell is spanned then search origin cell and select it.
var [origRowIdx, origColIdx] = getOrigRowAndColumn(aCellsArray,
rowIdx, colIdx);
aCellsArray[origRowIdx][origColIdx] = true;
}
} else if (!(cellState & kSpanned)) { // unselect other columns
if (colIdx > aColIdx) {
// Unselect the cell if traversed column index is greater than column
// index of target cell.
aCellsArray[rowIdx][colIdx] = false;
} else if (!(aCellsArray[rowIdx][aColIdx] & kColSpanned)) {
// Unselect the cell if the target cell is not row spanned.
aCellsArray[rowIdx][colIdx] = false;
} else {
// Unselect the cell if it is not spanned to the target cell.
for (var spannedColIdx = colIdx + 1; spannedColIdx < aColIdx;
spannedColIdx++) {
var spannedCellState = aCellsArray[rowIdx][spannedColIdx];
if (!(spannedCellState & kRowSpanned)) {
aCellsArray[rowIdx][colIdx] = false;
break;
}
}
}
}
}
}
@ -305,8 +582,10 @@ function testUnselectTableRow(aIdentifier, aRowIdx, aCellsArray)
var colsCount = aCellsArray[0].length;
for (var colIdx = 0; colIdx < colsCount; colIdx++) {
if (aCellsArray[aRowIdx][colIdx] != undefined)
aCellsArray[aRowIdx][colIdx] = false;
// Unselect origin cell.
var [origRowIdx, origColIdx] = getOrigRowAndColumn(aCellsArray,
aRowIdx, colIdx);
aCellsArray[origRowIdx][origColIdx] = false;
}
acc.unselectRow(aRowIdx);
@ -323,13 +602,48 @@ function testSelectTableRow(aIdentifier, aRowIdx, aCellsArray)
if (!acc)
return;
var rowsCount = aCellsArray.length;
var rowCount = aCellsArray.length;
var colsCount = aCellsArray[0].length;
for (var rowIdx = 0; rowIdx < rowsCount; rowIdx++) {
for (var rowIdx = 0; rowIdx < rowCount; rowIdx++) {
for (var colIdx = 0; colIdx < colsCount; colIdx++) {
if (aCellsArray[rowIdx][colIdx] != undefined)
aCellsArray[rowIdx][colIdx] = (rowIdx == aRowIdx);
var cellState = aCellsArray[rowIdx][colIdx];
if (rowIdx == aRowIdx) { // select the given row
if (!(cellState & kSpanned)) {
// Select the cell if it is origin.
aCellsArray[rowIdx][colIdx] = true;
} else {
// If the cell is spanned then search origin cell and select it.
var [origRowIdx, origColIdx] = getOrigRowAndColumn(aCellsArray,
rowIdx, colIdx);
aCellsArray[origRowIdx][origColIdx] = true;
}
} else if (!(cellState & kSpanned)) { // unselect other rows
if (rowIdx > aRowIdx) {
// Unselect the cell if traversed row index is greater than row
// index of target cell.
aCellsArray[rowIdx][colIdx] = false;
} else if (!(aCellsArray[aRowIdx][colIdx] & kRowSpanned)) {
// Unselect the cell if the target cell is not row spanned.
aCellsArray[rowIdx][colIdx] = false;
} else {
// Unselect the cell if it is not spanned to the target cell.
for (var spannedRowIdx = rowIdx + 1; spannedRowIdx < aRowIdx;
spannedRowIdx++) {
var spannedCellState = aCellsArray[spannedRowIdx][colIdx];
if (!(spannedCellState & kRowSpanned)) {
aCellsArray[rowIdx][colIdx] = false;
break;
}
}
}
}
}
}
@ -337,3 +651,90 @@ function testSelectTableRow(aIdentifier, aRowIdx, aCellsArray)
testTableSelection(aIdentifier, aCellsArray,
"Select " + aRowIdx + " row: ");
}
/**
* Test columnHeaderCells and rowHeaderCells of accessible table.
*/
function testHeaderCells(aHeaderInfoMap)
{
for (var testIdx = 0; testIdx < aHeaderInfoMap.length; testIdx++) {
var dataCellIdentifier = aHeaderInfoMap[testIdx].cell;
var dataCell = getAccessible(dataCellIdentifier, [nsIAccessibleTableCell]);
// row header cells
var rowHeaderCells = aHeaderInfoMap[testIdx].rowHeaderCells;
var rowHeaderCellsCount = rowHeaderCells.length;
var actualRowHeaderCells = dataCell.rowHeaderCells;
var actualRowHeaderCellsCount = actualRowHeaderCells.length;
is(actualRowHeaderCellsCount, rowHeaderCellsCount,
"Wrong number of row header cells for the cell " +
prettyName(dataCellIdentifier));
if (actualRowHeaderCellsCount == rowHeaderCellsCount) {
for (var idx = 0; idx < rowHeaderCellsCount; idx++) {
var rowHeaderCell = getAccessible(rowHeaderCells[idx]);
var actualRowHeaderCell =
actualRowHeaderCells.queryElementAt(idx, nsIAccessible);
ok(actualRowHeaderCell, rowHeaderCell,
"Wrong row header cell at index " + idx + " for the cell " +
prettyName(rowHeaderCells[idx]));
}
}
// column header cells
var colHeaderCells = aHeaderInfoMap[testIdx].columnHeaderCells;
var colHeaderCellsCount = colHeaderCells.length;
var actualColHeaderCells = dataCell.columnHeaderCells;
var actualColHeaderCellsCount = actualColHeaderCells.length;
is(actualColHeaderCellsCount, colHeaderCellsCount,
"Wrong number of column header cells for the cell " +
prettyName(dataCellIdentifier));
if (actualColHeaderCellsCount == colHeaderCellsCount) {
for (var idx = 0; idx < colHeaderCellsCount; idx++) {
var colHeaderCell = getAccessible(colHeaderCells[idx]);
var actualColHeaderCell =
actualColHeaderCells.queryElementAt(idx, nsIAccessible);
ok(actualColHeaderCell, colHeaderCell,
"Wrong column header cell at index " + idx + " for the cell " +
prettyName(colHeaderCells[idx]));
}
}
}
}
////////////////////////////////////////////////////////////////////////////////
// private implementation
/**
* Return row and column of orig cell for the given spanned cell.
*/
function getOrigRowAndColumn(aCellsArray, aRowIdx, aColIdx)
{
var cellState = aCellsArray[aRowIdx][aColIdx];
var origRowIdx = aRowIdx, origColIdx = aColIdx;
if (cellState & kRowSpanned) {
for (var prevRowIdx = aRowIdx - 1; prevRowIdx >= 0; prevRowIdx--) {
var prevCellState = aCellsArray[prevRowIdx][aColIdx];
if (!(prevCellState & kRowSpanned)) {
origRowIdx = prevRowIdx;
break;
}
}
}
if (cellState & kColSpanned) {
for (var prevColIdx = aColIdx - 1; prevColIdx >= 0; prevColIdx--) {
var prevCellState = aCellsArray[aRowIdx][prevColIdx];
if (!(prevCellState & kColSpanned)) {
origColIdx = prevColIdx;
break;
}
}
}
return [origRowIdx, origColIdx];
}

Просмотреть файл

@ -0,0 +1,138 @@
<html>
<head>
<title>nsIAccessible actions testing for anchors</title>
<link rel="stylesheet" type="text/css"
href="chrome://mochikit/content/tests/SimpleTest/test.css" />
<script type="application/javascript"
src="chrome://mochikit/content/MochiKit/packed.js"></script>
<script type="application/javascript"
src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
<script type="application/javascript"
src="chrome://mochikit/content/a11y/accessible/common.js"></script>
<script type="application/javascript"
src="chrome://mochikit/content/a11y/accessible/events.js"></script>
<script type="application/javascript"
src="chrome://mochikit/content/a11y/accessible/actions.js"></script>
<script type="application/javascript">
////////////////////////////////////////////////////////////////////////////
// Event checkers
function scrollingChecker(aAcc)
{
this.type = EVENT_SCROLLING_START;
this.target = aAcc;
this.getID = function scrollingChecker_getID()
{
return "scrolling start handling for " + prettyName(aAcc);
}
}
////////////////////////////////////////////////////////////////////////////
// Test
// gA11yEventDumpID = "debug"; // debug stuff
function doTest()
{
if (!WIN) {
ok(true,
"Nothing to test because scolling events are fired on Windows only");
SimpleTest.finish();
return;
}
var actionsArray = [
{
ID: "anchor1",
actionName: "jump",
actionIndex: 0,
events: CLICK_EVENTS,
eventSeq: [
new scrollingChecker(getAccessible("bottom1"))
]
},
{
ID: "anchor2",
actionName: "jump",
actionIndex: 0,
events: CLICK_EVENTS,
eventSeq: [
new scrollingChecker(getAccessible("bottom2").firstChild)
]
}
];
testActions(actionsArray);
}
SimpleTest.waitForExplicitFinish();
addA11yLoadEvent(doTest);
</script>
</head>
<body>
<a target="_blank"
href="https://bugzilla.mozilla.org/show_bug.cgi?id=506389"
title="Some same page links do not fire EVENT_SYSTEM_SCROLLINGSTART">
Mozilla Bug 506389
</a>
<p id="display"></p>
<div id="content" style="display: none"></div>
<pre id="test">
</pre>
<div id="debug"></div>
<h1>This is a test page for anchors</h1>
This is a top anchor<a name="Top">
</a><a id="anchor1" href="#bottom1">Link to anchor</a>
<a id="anchor2" href="#bottom2">Link to div</a>
<br><br><br><br><br><br><br><br><br><br>
<br><br><br><br><br><br><br><br><br><br>
<br><br><br><br><br><br><br><br><br><br>
<br><br><br><br><br><br><br><br><br><br>
<br><br><br><br><br><br><br><br><br><br>
<br><br><br><br><br><br><br><br><br><br>
<br><br><br><br><br><br><br><br><br><br>
<br><br><br><br><br><br><br><br><br><br>
<br><br><br><br><br><br><br><br><br><br>
<br><br><br><br><br><br><br><br><br><br>
<br><br><br><br><br><br><br><br><br><br><br>
<br><br><br><br><br><br><br><br><br><br><br>
<br><br><br><br><br><br><br><br><br><br>
<br><br><br><br><br><br><br><br><br><br>
<br><br><br><br><br>This is some text in the middle<br><br><br><br><br>
<br><br><br><br><br><br><br><br><br><br>
<br><br><br><br><br><br><br><br><br><br>
<br><br><br><br><br><br><br><br><br><br>
<br><br><br><br><br><br><br><br><br><br>
<br><br><br><br><br><br><br><br><br><br>
<br><br><br><br><br><br><br><br><br><br>
<br><br><br><br><br><br><br><br><br><br>
<br><br><br><br><br><br><br><br><br><br>
<br><br><br><br><br><br><br><br><br><br>
<br><br><br><br><br><br><br><br><br><br>
<br><br><br><br><br><br><br><br><br><br>
<br><br><br><br><br><br><br><br><br><br>
<br><br><br><br><br><br><br><br><br><br>
<br><br><br><br><br><br><br><br><br><br>
<br><br><br><br><br><br><br><br><br><br>
<br><br><br><br><br><br><br><br><br><br>
<br><br><br><br><br><br><br><br><br><br>
<br><br><br><br><br><br><br><br><br><br>
<br><br><br><br><br><br><br><br><br><br>
This is some text.
This is a bottom anchor<a id="bottom1"></a>
<br><br><br><br><br><br><br><br><br><br>
<br><br><br><br><br><br><br><br><br><br>
<br><br><br><br><br><br><br><br><br><br>
<div id="bottom2">This is a div</div>
</body>
</html>

Просмотреть файл

@ -1,146 +0,0 @@
<!DOCTYPE html>
<html>
<head>
<title>ARIA grid based on HTML table tests</title>
<link rel="stylesheet" type="text/css"
href="chrome://mochikit/content/tests/SimpleTest/test.css" />
<style>
td:focus {
background-color: lightblue;
}
th {
-moz-box-align: center;
-moz-box-pack: center;
border: 2px solid;
-moz-border-top-colors: ThreeDHighlight ThreeDLightShadow;
-moz-border-right-colors: ThreeDDarkShadow ThreeDShadow;
-moz-border-bottom-colors: ThreeDDarkShadow ThreeDShadow;
-moz-border-left-colors: ThreeDHighlight ThreeDLightShadow;
background-color: -moz-Dialog;
color: -moz-DialogText;
padding: 0px 4px;
}
</style>
<script type="application/javascript"
src="chrome://mochikit/content/MochiKit/packed.js"></script>
<script type="application/javascript"
src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
<script type="application/javascript"
src="chrome://mochikit/content/a11y/accessible/grid.js"></script>
<script type="application/javascript"
src="chrome://mochikit/content/a11y/accessible/common.js"></script>
<script type="application/javascript"
src="chrome://mochikit/content/a11y/accessible/role.js"></script>
<script type="application/javascript">
var gGrid = null;
function doTest()
{
gGrid = new grid("grid");
// Test accessible hierarchy of ARIA grid.
var accTree = {
role: ROLE_TABLE,
children: [
{
role: ROLE_TEXT_CONTAINER, // thead
children: [
{
role: ROLE_ROW,
children: [
{
role: ROLE_COLUMNHEADER
},
{
role: ROLE_COLUMNHEADER
},
{
role: ROLE_COLUMNHEADER
}
]
}
]
},
{
role: ROLE_TEXT_CONTAINER, // tbody
children: [
{
role: ROLE_ROW,
children: [
{
role: ROLE_GRID_CELL
},
{
role: ROLE_GRID_CELL
},
{
role: ROLE_GRID_CELL
}
]
},
{
role: ROLE_ROW,
children: [
{
role: ROLE_GRID_CELL
},
{
role: ROLE_GRID_CELL
},
{
role: ROLE_GRID_CELL
}
]
}
]
}
]
};
if (LINUX)
todo(false, "No tests on linux because of different hierarchies.");
else
testAccessibleTree("grid", accTree);
SimpleTest.finish();
}
SimpleTest.waitForExplicitFinish();
addA11yLoadEvent(doTest);
</script>
</head>
<body>
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=491683"
title="ARIA grid based on HTML table">Mozilla Bug 491683</a>
<p id="display"></p>
<div id="content" style="display: none"></div>
<pre id="test">
</pre>
<table role="grid" id="grid" border="1" cellpadding="10" cellspacing="0">
<thead>
<tr role="row">
<th role="columnheader">subject</td>
<th role="columnheader">sender</th>
<th role="columnheader">date</th>
</tr>
</thead>
<tbody>
<tr role="row">
<td role="gridcell" tabindex="0">about everything</td>
<td role="gridcell">president</td>
<td role="gridcell">today</td>
</tr>
<tr role="row">
<td role="gridcell">new bugs</td>
<td role="gridcell">mozilla team</td>
<td role="gridcell">today</td>
</tr>
</tbody>
</table>
</body>
</html>

Просмотреть файл

@ -50,7 +50,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=469688
"landmarked table should have nsIAccessibleTable");
if (accessibleTable)
is(accessibleTable.cellRefAt(0,0).firstChild.name, "hi", "no cell");
is(accessibleTable.getCellAt(0,0).firstChild.name, "hi", "no cell");
}
// test gEmptyRoleMap

Просмотреть файл

@ -7,108 +7,75 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=420863
<title>Table indexes chrome tests</title>
<link rel="stylesheet" type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css" />
<script type="application/javascript" src="chrome://mochikit/content/MochiKit/packed.js"></script>
<script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
<script type="application/javascript"
src="chrome://mochikit/content/MochiKit/packed.js"></script>
<script type="application/javascript"
src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
<script type="application/javascript"
src="chrome://mochikit/content/a11y/accessible/common.js"></script>
<script type="application/javascript"
src="chrome://mochikit/content/a11y/accessible/events.js"></script>
<script type="application/javascript"
src="chrome://mochikit/content/a11y/accessible/actions.js"></script>
<script type="application/javascript">
var gAccService = null;
var gTdClickAttr = false;
var gTdClickEventHandler = false;
var gClickHandler = null;
var gID = "";
var gNode = null;
var gAcc = null;
function doTest()
{
const nsIAccessibleRetrieval =
Components.interfaces.nsIAccessibleRetrieval;
gAccService = Components.classes["@mozilla.org/accessibleRetrieval;1"].
getService(nsIAccessibleRetrieval);
// Actions should be exposed on any accessible having related DOM node
// with registered 'click' event handler.
//////////////////////////////////////////////////////////////////////////
// generic td
gID = "td1";
gNode = document.getElementById(gID);
gAcc = gAccService.getAccessibleFor(gNode);
var td1Acc = getAccessible("td1");
if (!td1Acc) {
SimpleTest.finish();
return;
}
is(gAcc.numActions, 0, gID + ": shouldn't have actions");
is(td1Acc.numActions, 0,
"Simple table cell shouldn't have any actions");
//////////////////////////////////////////////////////////////////////////
// td with 'onclick' attribute
gID = "td2";
gNode = document.getElementById(gID);
gAcc = gAccService.getAccessibleFor(gNode);
is(gAcc.numActions, 1, gID + ": should have one action");
is(gAcc.getActionName(0), "click", gID + ": should have 'click' action");
gAcc.doAction(0);
// actions are performed via timeout
window.setTimeout(doTest2, 0);
}
function doTest2()
{
//////////////////////////////////////////////////////////////////////////
// td with 'onclick' attribute (sequel, see doTest1())
ok(gTdClickAttr, gID + ": 'click' action hasn't been performed");
//////////////////////////////////////////////////////////////////////////
// td with registered 'click' event handler
gID = "td3";
gNode = document.getElementById(gID);
gAcc = gAccService.getAccessibleFor(gNode);
// one td with 'onclick' attribute and one with registered click handler
var td3Node = getNode("td3");
// register 'click' event handler
gClickHandler = {
handleEvent: function handleEvent(aEvent)
{
gTdClickEventHandler = true;
}
};
gNode.addEventListener("click", gClickHandler, false);
td3Node.addEventListener("click", gClickHandler, false);
// check actions
is(gAcc.numActions, 1, gID + ": should have one action");
is(gAcc.getActionName(0), "click", gID + ": should have 'click' action");
gAcc.doAction(0);
var actionsArray = [
{
ID: "td2", // "onclick" attribute
actionName: "click",
actionIndex: 0,
events: CLICK_EVENTS
},
{
ID: td3Node,
actionName: "click",
actionIndex: 0,
events: CLICK_EVENTS,
checkOnClickEvent: function check(aEvent)
{
// unregister click event handler
this.ID.removeEventListener("click", gClickHandler, false);
// actions are performed via timeout
window.setTimeout(doTest3, 0);
}
// check actions
is(getAccessible(this.ID).numActions, 0,
"td3 shouldn't have actions");
}
}
];
function doTest3()
{
//////////////////////////////////////////////////////////////////////////
// td with registered 'click' event handler (sequel, see doTest2())
ok(gTdClickEventHandler, gID + ": 'click' action hasn't been performed");
// unregister click event handler
gNode.removeEventListener("click", gClickHandler, false);
// check actions
// XXX see bug 456347, sometimes after removing the event listener, the
// accessible is no longer valid. When fixing that bug, remove the
// try/exception and simply test for the gAcc.numActions value directly.
var numActions = -1;
try {
numActions = gAcc.numActions;
} catch(e) {}
if (numActions == -1)
todo(false,
"gAcc.numActions should not throw after click handler was removed!");
else
is(numActions, 0, gID + ": shouldn't have actions");
SimpleTest.finish();
testActions(actionsArray); // will call SimpleTest.finish()
}
SimpleTest.waitForExplicitFinish();

Просмотреть файл

@ -0,0 +1,76 @@
<?xml version="1.0"?>
<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
<?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css"
type="text/css"?>
<window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
title="XUL listbox element test.">
<script type="application/javascript"
src="chrome://mochikit/content/MochiKit/packed.js"></script>
<script type="application/javascript"
src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js" />
<script type="application/javascript"
src="chrome://mochikit/content/a11y/accessible/common.js"></script>
<script type="application/javascript"
src="chrome://mochikit/content/a11y/accessible/role.js"></script>
<script type="application/javascript">
<![CDATA[
function doTest()
{
var id = "";
var listbox = null, acc = null;
//////////////////////////////////////////////////////////////////////////
// Simple listbox. There is no nsIAccessibleTable interface.
id = "listbox1";
acc = getAccessible(id);
// query nsIAccessibleTable
try {
acc.QueryInterface(nsIAccessibleTable);
ok(false,
id + " shouldn't implement nsIAccessibleTable interface.");
} catch(e) {
ok(true, id + " doesn't implement nsIAccessibleTable interface.");
}
// role
testRole(id, ROLE_LISTBOX);
SimpleTest.finish();
}
SimpleTest.waitForExplicitFinish();
addLoadEvent(doTest);
]]>
</script>
<hbox style="overflow: auto;">
<body xmlns="http://www.w3.org/1999/xhtml">
<a target="_blank"
href="https://bugzilla.mozilla.org/show_bug.cgi?id=418371"
title="implement the rest of methods of nsIAccessibleTable on xul:listbox">
Mozilla Bug 418371
</a>
<p id="display"></p>
<div id="content" style="display: none">
</div>
<pre id="test">
</pre>
</body>
<vbox flex="1">
<label control="listbox1" value="listbox: "/>
<listbox id="listbox1">
<listitem label="item1" id="item1"/>
<listitem label="item2" id="item2"/>
</listbox>
</vbox>
</hbox>
</window>

Просмотреть файл

@ -1,117 +0,0 @@
<!DOCTYPE html>
<html>
<!--
https://bugzilla.mozilla.org/show_bug.cgi?id=483573
-->
<head>
<title>File Input Control tests</title>
<link rel="stylesheet" type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css" />
<script type="application/javascript"
src="chrome://mochikit/content/MochiKit/packed.js"></script>
<script type="application/javascript"
src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
<script type="application/javascript"
src="chrome://mochikit/content/a11y/accessible/common.js"></script>
<script type="application/javascript"
src="chrome://mochikit/content/a11y/accessible/role.js"></script>
<script type="application/javascript">
function doTest()
{
var accTree = {
role: ROLE_TABLE, // table
children: [
{
role: ROLE_TEXT_CONTAINER, // thead
children: [
{
role: ROLE_ROW,
children: [
{
role: ROLE_COLUMNHEADER
},
{
role: ROLE_COLUMNHEADER
}
]
}
]
},
{
role: ROLE_TEXT_CONTAINER, // tbody
children: [
{
role: ROLE_ROW,
children: [
{
role: ROLE_CELL
},
{
role: ROLE_CELL
}
]
}
]
},
{
role: ROLE_TEXT_CONTAINER, // tfoot
children: [
{
role: ROLE_ROW,
children: [
{
role: ROLE_COLUMNHEADER
},
{
role: ROLE_COLUMNHEADER
}
]
}
]
}
]
};
if (LINUX)
todo(false, "No tests on linux because of different hierarchies.");
else
testAccessibleTree("table", accTree);
SimpleTest.finish();
}
SimpleTest.waitForExplicitFinish();
addLoadEvent(doTest);
</script>
</head>
<body>
<a target="_blank"
title="create accessibles for HTML tr"
href="https://bugzilla.mozilla.org/show_bug.cgi?id=493695">Mozilla Bug 493695</a>
<p id="display"></p>
<div id="content" style="display: none"></div>
<pre id="test">
</pre>
<table id="table">
<thead>
<tr>
<th>col1</th><th>col2</th>
</tr>
</thead>
<tbody>
<tr>
<td>cell1</td><td>cell2</td>
</tr>
</tbody>
<tfoot>
<tr>
<th>col1</th><th>col2</th>
</tr>
</tfoot>
</table>
</body>
</html>

Просмотреть файл

@ -26,7 +26,7 @@
////////////////////////////////////////////////////////////////////////////
// Accessible tree testers
function getTreeItemAccTree(aTableRole, aColumnsCount)
function getTreeItemAccTree(aTableRole, acolumnCount)
{
var treeItemRole;
switch (aTableRole) {
@ -47,7 +47,7 @@
};
if (aTableRole == ROLE_TABLE || aTableRole == ROLE_TREE_TABLE) {
for (var idx = 0; idx < aColumnsCount; idx++) {
for (var idx = 0; idx < acolumnCount; idx++) {
var cellAccTree = {
role: ROLE_GRID_CELL,
children: []
@ -75,15 +75,15 @@
var treeBoxObject = aTree.treeBoxObject;
var view = treeBoxObject.view;
var columnsCount = treeBoxObject.columns.count;
var columnCount = treeBoxObject.columns.count;
for (var idx = 0; idx < columnsCount; idx++)
for (var idx = 0; idx < columnCount; idx++)
accTreeForColumns.children.push({ role: ROLE_COLUMNHEADER, children: []});
if (!aTree.hasAttribute("hidecolumnpicker"))
accTreeForColumns.children.push({ role: ROLE_PUSHBUTTON, children: []});
for (var idx = 0; idx < view.rowCount; idx++)
accTreeForTree.children.push(getTreeItemAccTree(aRole, columnsCount));
accTreeForTree.children.push(getTreeItemAccTree(aRole, columnCount));
testAccessibleTree(aTree, accTreeForTree);
}

Просмотреть файл

@ -156,6 +156,8 @@
*/
var gQueue = null;
// gA11yEventDumpID = "eventdump"; // debug stuff
function testCaretOffset(aAccOrElmOrID, aCaretOffset)
{
var acc = getAccessible(aAccOrElmOrID, [nsIAccessibleText]);
@ -220,5 +222,6 @@
<p id="p" contentEditable="true"><span>text</span><br/>text</p>
<div id="div" contentEditable="true"><p id="p1_in_div">text</p><p id="p2_in_div">text</p></div>
<div id="eventdump"></div>
</body>
</html>

Просмотреть файл

@ -0,0 +1,411 @@
<html>
<head>
<title>Accessible mutation events coalescence testing</title>
<link rel="stylesheet" type="text/css"
href="chrome://mochikit/content/tests/SimpleTest/test.css" />
<script type="application/javascript"
src="chrome://mochikit/content/MochiKit/packed.js"></script>
<script type="application/javascript"
src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
<script type="application/javascript"
src="chrome://mochikit/content/tests/SimpleTest/EventUtils.js"></script>
<script type="application/javascript"
src="chrome://mochikit/content/a11y/accessible/common.js"></script>
<script type="application/javascript"
src="chrome://mochikit/content/a11y/accessible/events.js"></script>
<script type="application/javascript">
////////////////////////////////////////////////////////////////////////////
// Invoker base classes
const kRemoveElm = 1;
const kHideElm = 2;
const kAddElm = 3;
const kShowElm = 4;
const kToDo = true;
/**
* Base class to test of mutation events coalescence.
*/
function coalescenceBase(aChildAction, aParentAction,
aPerformActionOnChildInTheFirstPlace,
aIsChildsToDo)
{
// Invoker interface
this.invoke = function coalescenceBase_invoke()
{
if (aPerformActionOnChildInTheFirstPlace) {
this.invokeAction(this.childNode, aChildAction);
this.invokeAction(this.parentNode, aParentAction);
} else {
this.invokeAction(this.parentNode, aParentAction);
this.invokeAction(this.childNode, aChildAction);
}
}
this.getID = function coalescenceBase_getID()
{
var childAction = this.getActionName(aChildAction) + " child";
var parentAction = this.getActionName(aParentAction) + " parent";
if (aPerformActionOnChildInTheFirstPlace)
return childAction + " and then " + parentAction;
return parentAction + " and then " + childAction;
}
this.finalCheck = function coalescenceBase_check()
{
if (!aIsChildsToDo)
return;
var eventType = eventTypeToString(this.getEventType(aChildAction));
todo(false,
"Unexpected event " + eventType +
" for child in the test '" + this.getID() + "'");
}
// Implementation details
this.invokeAction = function coalescenceBase_invokeAction(aNode, aAction)
{
switch (aAction) {
case kRemoveElm:
aNode.parentNode.removeChild(aNode);
break;
case kHideElm:
aNode.style.display = "none";
break;
case kAddElm:
if (aNode == this.parentNode)
this.hostNode.appendChild(this.parentNode);
else
this.parentNode.appendChild(this.childNode);
break;
case kShowElm:
aNode.style.display = "block";
default:
return INVOKER_ACTION_FAILED;
}
}
this.getEventType = function coalescenceBase_getEventType(aAction)
{
switch (aAction) {
case kRemoveElm: case kHideElm:
return EVENT_HIDE;
case kAddElm: case kShowElm:
return EVENT_SHOW;
}
}
this.getActionName = function coalescenceBase_getActionName(aAction)
{
switch (aAction) {
case kRemoveElm:
return "remove";
case kHideElm:
return "hide";
case kAddElm:
return "add";
case kShowElm:
return "show";
default:
return "??";
}
}
this.initSequence = function coalescenceBase_initSequence()
{
// expected events
var eventType = this.getEventType(aParentAction);
this.eventSeq = [
new invokerChecker(eventType, this.parentNode),
new invokerChecker(EVENT_REORDER, this.hostNode)
];
// unexpected events
this.unexpectedEventSeq = [
new invokerChecker(EVENT_REORDER, this.parentNode)
];
if (!aIsChildsToDo) {
var eventType = this.getEventType(aChildAction);
var checker = new invokerChecker(eventType, this.childNode);
this.unexpectedEventSeq.unshift(checker);
}
}
}
/**
* Remove or hide mutation events coalescence testing.
*/
function removeOrHideCoalescenceBase(aChildID, aParentID,
aChildAction, aParentAction,
aPerformActionOnChildInTheFirstPlace,
aIsChildsToDo)
{
this.__proto__ = new coalescenceBase(aChildAction, aParentAction,
aPerformActionOnChildInTheFirstPlace,
aIsChildsToDo);
this.init = function removeOrHideCoalescenceBase_init()
{
this.childNode = getNode(aChildID);
this.parentNode = getNode(aParentID);
this.hostNode = this.parentNode.parentNode;
// ensure child accessible is created
getAccessible(this.childNode);
}
// Initalization
this.init();
this.initSequence();
}
////////////////////////////////////////////////////////////////////////////
// Invokers
/**
* Remove child node and then its parent node from DOM tree.
*/
function removeChildNParent(aChildID, aParentID)
{
this.__proto__ = new removeOrHideCoalescenceBase(aChildID, aParentID,
kRemoveElm, kRemoveElm,
true, kToDo);
}
/**
* Remove parent node and then its child node from DOM tree.
*/
function removeParentNChild(aChildID, aParentID)
{
this.__proto__ = new removeOrHideCoalescenceBase(aChildID, aParentID,
kRemoveElm, kRemoveElm,
false);
}
/**
* Hide child node and then its parent node.
*/
function hideChildNParent(aChildID, aParentID)
{
this.__proto__ = new removeOrHideCoalescenceBase(aChildID, aParentID,
kHideElm, kHideElm,
true);
}
/**
* Hide parent node and then its child node.
*/
function hideParentNChild(aChildID, aParentID)
{
this.__proto__ = new removeOrHideCoalescenceBase(aChildID, aParentID,
kHideElm, kHideElm,
false);
}
/**
* Hide child node and then remove its parent node.
*/
function hideChildNRemoveParent(aChildID, aParentID)
{
this.__proto__ = new removeOrHideCoalescenceBase(aChildID, aParentID,
kHideElm, kRemoveElm,
true);
}
/**
* Hide parent node and then remove its child node.
*/
function hideParentNRemoveChild(aChildID, aParentID)
{
// Because of async layout changes we handle remove child node change
// before than hide parent node change even we hide parent before we
// remove a child. Therefore mark this as todo until we have more smart
// events coalescence.
this.__proto__ = new removeOrHideCoalescenceBase(aChildID, aParentID,
kRemoveElm, kHideElm,
false, kToDo);
}
/**
* Remove child node and then hide its parent node.
*/
function removeChildNHideParent(aChildID, aParentID)
{
this.__proto__ = new removeOrHideCoalescenceBase(aChildID, aParentID,
kRemoveElm, kHideElm,
true, kToDo);
}
/**
* Remove parent node and then hide its child node.
*/
function removeParentNHideChild(aChildID, aParentID)
{
this.__proto__ = new removeOrHideCoalescenceBase(aChildID, aParentID,
kHideElm, kRemoveElm,
false);
}
/**
* Create and append parent node and create and append child node to it.
*/
function addParentNChild(aHostID, aPerformActionOnChildInTheFirstPlace)
{
this.init = function addParentNChild_init()
{
this.hostNode = getNode(aHostID);
this.parentNode = document.createElement("select");
this.childNode = document.createElement("option");
this.childNode.textContent = "testing";
}
this.__proto__ = new coalescenceBase(kAddElm, kAddElm,
aPerformActionOnChildInTheFirstPlace);
this.init();
this.initSequence();
}
/**
* Show parent node and show child node to it.
*/
function showParentNChild(aParentID, aChildID,
aPerformActionOnChildInTheFirstPlace)
{
this.init = function showParentNChild_init()
{
this.parentNode = getNode(aParentID);
this.hostNode = this.parentNode.parentNode;
this.childNode = getNode(aChildID);
}
this.__proto__ = new coalescenceBase(kShowElm, kShowElm,
aPerformActionOnChildInTheFirstPlace);
this.init();
this.initSequence();
}
/**
* Create and append child node to the DOM and then show parent node.
*/
function showParentNAddChild(aParentID,
aPerformActionOnChildInTheFirstPlace)
{
this.init = function showParentNAddChild_init()
{
this.parentNode = getNode(aParentID);
this.hostNode = this.parentNode.parentNode;
this.childNode = document.createElement("option");
this.childNode.textContent = "testing";
}
this.__proto__ = new coalescenceBase(kAddElm, kShowElm,
aPerformActionOnChildInTheFirstPlace);
this.init();
this.initSequence();
}
////////////////////////////////////////////////////////////////////////////
// Do tests.
var gQueue = null;
// var gA11yEventDumpID = "eventdump"; // debug stuff
function doTests()
{
gQueue = new eventQueue();
gQueue.push(new removeChildNParent("option1", "select1"));
gQueue.push(new removeParentNChild("option2", "select2"));
gQueue.push(new hideChildNParent("option3", "select3"));
gQueue.push(new hideParentNChild("option4", "select4"));
gQueue.push(new hideChildNRemoveParent("option5", "select5"));
gQueue.push(new hideParentNRemoveChild("option6", "select6"));
gQueue.push(new removeChildNHideParent("option7", "select7"));
gQueue.push(new removeParentNHideChild("option8", "select8"));
gQueue.push(new addParentNChild("testContainer", false));
gQueue.push(new addParentNChild("testContainer", true));
gQueue.push(new showParentNChild("select9", "option9", false));
gQueue.push(new showParentNChild("select10", "option10", true));
gQueue.push(new showParentNAddChild("select11", false));
gQueue.push(new showParentNAddChild("select12", true));
gQueue.invoke(); // Will call SimpleTest.finish();
}
SimpleTest.waitForExplicitFinish();
addA11yLoadEvent(doTests);
</script>
</head>
<body>
<a target="_blank"
href="https://bugzilla.mozilla.org/show_bug.cgi?id=513213"
title="coalesce events when new event is appended to the queue">
Mozilla Bug 513213
</a>
<p id="display"></p>
<div id="content" style="display: none"></div>
<pre id="test">
</pre>
<div id="eventdump"></div>
<div id="testContainer">
<select id="select1">
<option id="option1">option</option>
</select>
<select id="select2">
<option id="option2">option</option>
</select>
<select id="select3">
<option id="option3">option</option>
</select>
<select id="select4">
<option id="option4">option</option>
</select>
<select id="select5">
<option id="option5">option</option>
</select>
<select id="select6">
<option id="option6">option</option>
</select>
<select id="select7">
<option id="option7">option</option>
</select>
<select id="select8">
<option id="option8">option</option>
</select>
<select id="select9" style="display: none">
<option id="option9" style="display: none">testing</option>
</select>
<select id="select10" style="display: none">
<option id="option10" style="display: none">testing</option>
</select>
<select id="select11" style="display: none"></select>
<select id="select12" style="display: none"></select>
</div>
</body>
</html>

Просмотреть файл

@ -0,0 +1,78 @@
<html>
<head>
<title>Flush delayed events testing</title>
<link rel="stylesheet" type="text/css"
href="chrome://mochikit/content/tests/SimpleTest/test.css" />
<script type="application/javascript"
src="chrome://mochikit/content/MochiKit/packed.js"></script>
<script type="application/javascript"
src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
<script type="application/javascript"
src="chrome://mochikit/content/tests/SimpleTest/EventUtils.js"></script>
<script type="application/javascript"
src="chrome://mochikit/content/a11y/accessible/common.js"></script>
<script type="application/javascript"
src="chrome://mochikit/content/a11y/accessible/events.js"></script>
<script type="application/javascript">
var gFocusHandler = {
handleEvent: function(aEvent) {
switch (this.count) {
case 0:
is(aEvent.DOMNode, getNode("input1"),
"Focus event for input1 was expected!");
getAccessible("input2").takeFocus();
break;
case 1:
is(aEvent.DOMNode, getNode("input2"),
"Focus event for input2 was expected!");
unregisterA11yEventListener(EVENT_FOCUS, gFocusHandler);
SimpleTest.finish();
break;
default:
ok(false, "Wrong focus event!");
}
this.count++;
},
count: 0
};
function doTests()
{
registerA11yEventListener(EVENT_FOCUS, gFocusHandler);
getAccessible("input1").takeFocus();
}
SimpleTest.waitForExplicitFinish();
addA11yLoadEvent(doTests);
</script>
</head>
<body>
<a target="_blank"
href="https://bugzilla.mozilla.org/show_bug.cgi?id=477551"
title="nsDocAccessible::FlushPendingEvents isn't robust">
Mozilla Bug 477551
</a>
<p id="display"></p>
<div id="content" style="display: none"></div>
<pre id="test">
</pre>
<input id="input1">
<input id="input2">
</body>
</html>

Просмотреть файл

@ -42,16 +42,14 @@
* @param aNodeOrID [in] node invoker's action is executed for
* @param aEventTypes [in] events to register (see constants above)
* @param aDoNotExpectEvents [in] boolean indicates if events are expected
* @param aIsDOMChange [in] boolean indicates if these are DOM events
* layout events.
*/
function mutateA11yTree(aNodeOrID, aEventTypes,
aDoNotExpectEvents, aIsDOMChange)
function mutateA11yTree(aNodeOrID, aEventTypes, aDoNotExpectEvents)
{
// Interface
this.DOMNode = getNode(aNodeOrID);
this.doNotExpectEvents = aDoNotExpectEvents;
this.eventSeq = [];
this.unexpectedEventSeq = [];
/**
* Change default target (aNodeOrID) registered for the given event type.
@ -59,9 +57,9 @@
this.setTarget = function mutateA11yTree_setTarget(aEventType, aTarget)
{
var type = this.getA11yEventType(aEventType);
for (var idx = 0; idx < this.eventSeq.length; idx++) {
if (this.eventSeq[idx].type == type) {
this.eventSeq[idx].target = aTarget;
for (var idx = 0; idx < this.getEventSeq().length; idx++) {
if (this.getEventSeq()[idx].type == type) {
this.getEventSeq()[idx].target = aTarget;
return idx;
}
}
@ -78,7 +76,7 @@
var type = this.getA11yEventType(aEventType);
for (var i = 1; i < aTargets.length; i++) {
var checker = new invokerChecker(type, aTargets[i]);
this.eventSeq.splice(++targetIdx, 0, checker);
this.getEventSeq().splice(++targetIdx, 0, checker);
}
}
@ -88,39 +86,34 @@
if (aEventType == kReorderEvent)
return nsIAccessibleEvent.EVENT_REORDER;
if (this.mIsDOMChange) {
if (aEventType == kHideEvent)
return nsIAccessibleEvent.EVENT_DOM_DESTROY;
if (aEventType == kHideEvent)
return nsIAccessibleEvent.EVENT_HIDE;
if (aEventType == kShowEvent)
return nsIAccessibleEvent.EVENT_DOM_CREATE;
} else {
if (aEventType == kHideEvent)
return nsIAccessibleEvent.EVENT_ASYNCH_HIDE;
if (aEventType == kShowEvent)
return nsIAccessibleEvent.EVENT_ASYNCH_SHOW;
}
if (aEventType == kShowEvent)
return nsIAccessibleEvent.EVENT_SHOW;
}
this.mIsDOMChange = aIsDOMChange;
this.getEventSeq = function mutateA11yTree_getEventSeq()
{
return this.doNotExpectEvents ? this.unexpectedEventSeq : this.eventSeq;
}
if (aEventTypes & kHideEvent) {
var checker = new invokerChecker(this.getA11yEventType(kHideEvent),
this.DOMNode);
this.eventSeq.push(checker);
this.getEventSeq().push(checker);
}
if (aEventTypes & kShowEvent) {
var checker = new invokerChecker(this.getA11yEventType(kShowEvent),
this.DOMNode);
this.eventSeq.push(checker);
this.getEventSeq().push(checker);
}
if (aEventTypes & kReorderEvent) {
var checker = new invokerChecker(this.getA11yEventType(kReorderEvent),
this.DOMNode.parentNode);
this.eventSeq.push(checker);
this.getEventSeq().push(checker);
}
}
@ -129,7 +122,7 @@
*/
function changeStyle(aNodeOrID, aProp, aValue, aEventTypes)
{
this.__proto__ = new mutateA11yTree(aNodeOrID, aEventTypes, false, false);
this.__proto__ = new mutateA11yTree(aNodeOrID, aEventTypes, false);
this.invoke = function changeStyle_invoke()
{
@ -147,7 +140,7 @@
*/
function changeClass(aParentNodeOrID, aNodeOrID, aClassName, aEventTypes)
{
this.__proto__ = new mutateA11yTree(aNodeOrID, aEventTypes, false, false);
this.__proto__ = new mutateA11yTree(aNodeOrID, aEventTypes, false);
this.invoke = function changeClass_invoke()
{
@ -172,7 +165,7 @@
var doNotExpectEvents = (aEventTypes == kNoEvents);
this.__proto__ = new mutateA11yTree(aNodeOrID, eventTypes,
doNotExpectEvents, true);
doNotExpectEvents);
this.invoke = function cloneAndAppendToDOM_invoke()
{
@ -207,7 +200,7 @@
var doNotExpectEvents = (aEventTypes == kNoEvents);
this.__proto__ = new mutateA11yTree(aNodeOrID, eventTypes,
doNotExpectEvents, true);
doNotExpectEvents);
this.invoke = function removeFromDOM_invoke()
{
@ -233,7 +226,7 @@
function cloneAndReplaceInDOM(aNodeOrID)
{
this.__proto__ = new mutateA11yTree(aNodeOrID, kHideAndShowEvents,
false, true);
false);
this.invoke = function cloneAndReplaceInDOM_invoke()
{
@ -286,7 +279,7 @@
* Do tests.
*/
var gQueue = null;
// var gA11yEventDumpID = "eventdump"; // debug stuff
// gA11yEventDumpID = "eventdump"; // debug stuff
function doTests()
{

Просмотреть файл

@ -112,7 +112,7 @@
var acc = getAccessible(gTree);
var tableAcc = getAccessible(acc, [nsIAccessibleTable]);
return tableAcc.cellRefAt(aRow, aCol);
return tableAcc.getCellAt(aRow, aCol);
}
this.getID = function getID()
{

Просмотреть файл

@ -40,6 +40,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=391829
// live object attribute
testAttrs("live", {"live" : "polite"}, true);
testAttrs("live2", {"live" : "polite"}, true);
testAbsentAttrs("live3", {"live" : ""});
testAttrs("log", {"live" : "polite"}, true);
testAttrs("logAssertive", {"live" : "assertive"}, true);
testAttrs("marquee", {"live" : "off"}, true);
@ -121,6 +122,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=391829
<div id="live" aria-live="polite">excuse <div id="liveChild">me</div></div>
<div id="live2" role="marquee" aria-live="polite">excuse <div id="live2Child">me</div></div>
<div id="live3" role="section">excuse</div>
<div id="log" role="log">excuse <div id="logChild">me</div></div>
<div id="logAssertive" role="log" aria-live="assertive">excuse <div id="logAssertiveChild">me</div></div>
<div id="marquee" role="marquee">excuse <div id="marqueeChild">me</div></div>

Просмотреть файл

@ -1,112 +0,0 @@
<!DOCTYPE HTML PUBLIC "-//w3c//dtd html 4.0 transitional//en">
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<link rel="stylesheet" type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css" />
<script type="application/javascript"
src="chrome://mochikit/content/MochiKit/packed.js"></script>
<script type="application/javascript"
src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
<script type="application/javascript"
src="chrome://mochikit/content/a11y/accessible/common.js"></script>
<script type="application/javascript"
src="chrome://mochikit/content/a11y/accessible/relations.js"></script>
<script type="application/javascript">
function doTest()
{
//////////////////////////////////////////////////////////////////////////
// relations from markup
// 'description_for' relations for column headers
testRelation("table1_0", RELATION_DESCRIPTION_FOR,
["table1_3", "table1_6"]);
testRelation("table1_1", RELATION_DESCRIPTION_FOR,
["table1_4", "table1_7"]);
testRelation("table1_2", RELATION_DESCRIPTION_FOR,
["table1_5", "table1_8"]);
// 'description_for' relations for row headers
testRelation("table1_3", RELATION_DESCRIPTION_FOR,
["table1_4", "table1_5"]);
testRelation("table1_6", RELATION_DESCRIPTION_FOR,
["table1_7", "table1_8"]);
// 'described_by' relations for cells
testRelation("table1_4", RELATION_DESCRIBED_BY,
["table1_1", "table1_3"]);
testRelation("table1_5", RELATION_DESCRIBED_BY,
["table1_2", "table1_3"]);
testRelation("table1_7", RELATION_DESCRIBED_BY,
["table1_1", "table1_6"]);
testRelation("table1_8", RELATION_DESCRIBED_BY,
["table1_2", "table1_6"]);
//////////////////////////////////////////////////////////////////////////
// relations from @headers
// 'description_for' relations for column headers
testRelation("table2_3", RELATION_DESCRIPTION_FOR,
["table2_0"]);
testRelation("table2_4", RELATION_DESCRIPTION_FOR,
["table2_1"]);
// 'description_by' relations for cells
testRelation("table2_0", RELATION_DESCRIBED_BY,
["table2_3"]);
testRelation("table2_1", RELATION_DESCRIBED_BY,
["table2_4"]);
SimpleTest.finish();
}
SimpleTest.waitForExplicitFinish();
addLoadEvent(doTest);
</script>
</head>
<body>
<a target="_blank"
href="https://bugzilla.mozilla.org/show_bug.cgi?id="
title="">Mozilla Bug </a>
<p id="display"></p>
<div id="content" style="display: none"></div>
<pre id="test">
</pre>
<table id="table1">
<thead>
<tr>
<th id="table1_0">col1</th>
<th id="table1_1">col2</th>
<td id="table1_2" scope="col">col3</td>
</tr>
</thead>
<tbody>
<tr>
<th id="table1_3">row1</th>
<td id="table1_4">cell1</td>
<td id="table1_5">cell2</td>
</tr>
<tr>
<td id="table1_6" scope="row">row2</td>
<td id="table1_7">cell3</td>
<td id="table1_8">cell4</td>
</tr>
</tbody>
</table>
<table id="table2">
<tr>
<td id="table2_0" headers="table2_3">cell1</td>
<td id="table2_1" headers="table2_4">cell2</td>
</tr>
<tr>
<td id="table2_3" scope="col">col1</td>
<td id="table2_4" scope="col">col2</td>
</tr>
</table>
</body>
</html>

Просмотреть файл

@ -3,6 +3,7 @@
<!--
https://bugzilla.mozilla.org/show_bug.cgi?id=454997
https://bugzilla.mozilla.org/show_bug.cgi?id=467387
https://bugzilla.mozilla.org/show_bug.cgi?id=509696
-->
<head>
<title>states of document</title>
@ -21,6 +22,19 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=467387
<script type="application/javascript">
function doTest()
{
// Bug 509696
testStates(document, STATE_READONLY); // role=""
todo(false, "enable commented tests when we support body role changes");
/*
document.body.setAttribute("role","banner"); // no platform mapping
testStates(document, STATE_READONLY);
document.body.setAttribute("role","foo"); // bogus role
testStates(document, STATE_READONLY);
document.body.removeAttribute("role");
testStates(document, STATE_READONLY);
*/
// Bugs 454997 and 467387
testStates(document, STATE_READONLY);
testStates("document", STATE_READONLY);
testStates("editable_document", 0, EXT_STATE_EDITABLE);
@ -46,14 +60,17 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=467387
</script>
</head>
<body>
<body role="">
<a target="_blank"
title="nsIAccessible states tests of editable document"
title="<body contenteditable='true'> exposed incorrectly"
href="https://bugzilla.mozilla.org/show_bug.cgi?id=454997">Mozilla Bug 454997</a>
<a target="_blank"
title="nsIAccessible states tests of editable document"
href="https://bugzilla.mozilla.org/show_bug.cgi?id=467387">Mozilla Bug 467387</a>
<a target="_blank"
title="Role attribute on body with empty string causes DocAccessible not to have read-only state."
href="https://bugzilla.mozilla.org/show_bug.cgi?id=509696">Mozilla Bug 509696</a>
<p id="display"></p>
<div id="content" style="display: none"></div>
<pre id="test">

Просмотреть файл

@ -16,16 +16,6 @@
function doTest()
{
var accTable = getAccessible("table", [nsIAccessibleTable]);
var caption = accTable.caption;
is(caption.firstChild.name, "Test Table", "wrong text inside caption");
is(caption.children.queryElementAt(0, nsIAccessible).name, "Test Table",
"wrong text inside caption");
is(accTable.summary, "this is a test table for nsIAccessibleTable",
"wrong summary on table");
is(accTable.columns, 4, "wrong number of columns");
is(accTable.rows, 3, "wrong number of rows");
var s = window.getSelection();
if (s.rangeCount > 0)
@ -36,14 +26,14 @@ function doTest()
range.selectNode(cell);
s.addRange(range);
is(accTable.selectedCellsCount, 1, "only one cell selected");
is(accTable.selectedCellCount, 1, "only one cell selected");
cell = getNode("col2a");
range.selectNode(cell);
s.addRange(range);
cell = getNode("col2c");
range.selectNode(cell);
s.addRange(range);
is(accTable.selectedColumnsCount, 1, "only one column selected");
is(accTable.selectedColumnCount, 1, "only one column selected");
cell = getNode("row2a");
range.selectNode(cell);
s.addRange(range);
@ -54,30 +44,7 @@ function doTest()
range.selectNode(cell);
s.addRange(range);
is(accTable.selectedRowsCount, 1, "no cells selected");
var rowheader;
var works = true;
try {
rowheader = accTable.rowHeader;
}
catch (e) {
works = false;
}
todo(works, "rowHeader should not throw");
var columnHeader;
works = true;
try {
columnHeader = accTable.columnHeader;
columnHeaderIndex = columnHeader.getIndexAt(0, 2);
is(columnHeaderIndex, 2, "columnheaderindex is wrong");
}
catch (e) {
works = false;
}
if (!works)
todo(works, "columnHeader should not throw");
is(accTable.selectedRowCount, 1, "no cells selected");
var columnDescription;
works = true;

Просмотреть файл

@ -1,91 +0,0 @@
<!DOCTYPE HTML PUBLIC "-//w3c//dtd html 4.0 transitional//en">
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<title> nsIAccessibleTable Interface Test Case </title>
<link rel="stylesheet" type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css" />
<script type="application/javascript"
src="chrome://mochikit/content/MochiKit/packed.js"></script>
<script type="application/javascript"
src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
<script type="application/javascript"
src="chrome://mochikit/content/a11y/accessible/common.js"></script>
<script type="text/javascript">
function doTest()
{
// bug 410052
var accTable = getAccessible("table", [nsIAccessibleTable]);
is(accTable.getIndexAt(2,4), 17, "wrong index returned");
is(accTable.getColumnExtentAt(2,2), 2, "colspan wrong");
is(accTable.getColumnExtentAt(0,3), 2, "colspan wrong");
is(accTable.getColumnExtentAt(3,5), 1, "colspan");
is(accTable.getRowExtentAt(0,7), 4, "rowspan wrong");
is(accTable.getRowExtentAt(2,7), 4,"rowspan wrong");
is(accTable.getColumnExtentAt(2,3), 1, "colspan wrong");
is(accTable.cellRefAt(2,1).firstChild.name, "c1", "wrong cell");
SimpleTest.finish();
}
SimpleTest.waitForExplicitFinish();
addLoadEvent(doTest);
</script>
</head>
<body>
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=410052">Mozilla Bug 410052</a>
<br>
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=417912"
title="GetCellDataAt callers that expect an error if no cell is found are wrong">
Mozilla Bug 417912
</a>
<p id="display"></p>
<div id="content" style="display: none"></div>
<pre id="test">
</pre>
<!-- Test Table -->
<br><br><b> Testing Table:</b><br><br>
<center>
<table cellpadding="2" cellspacing="2" border="1" width="50%" id="table">
<tbody>
<tr>
<td><br></td>
<td><br></td>
<td rowspan="1" colspan="2"><br></td>
<td><br></td>
<td><br></td>
<td><br></td>
<td rowspan="4" colspan="1"><br></td>
</tr>
<tr>
<td><br></td>
<td><br></td>
<td><br></td>
<td><br></td>
<td><br></td>
<td><br></td>
<td><br></td>
</tr>
<tr>
<td><br></td>
<td rowspan="2" colspan="2">c1</td>
<td><br></td>
<td><br></td>
<td rowspan="2" colspan="1"><br></td>
<td><br></td>
</tr>
<tr>
<td><br></td>
<td><br></td>
<td><br></td>
<td><br></td>
</tr>
</tbody>
</table>
</center>
</body>
</html>

Просмотреть файл

@ -44,8 +44,8 @@ function doTest()
if (tableInterfaceExposed) {
testRole(accTable3, ROLE_ALERT);
is(accTable3.cellRefAt(0,0).firstChild.name, "cell0", "wrong cell");
is(accTable3.cellRefAt(0,1).firstChild.name, "cell1", "wrong cell");
is(accTable3.getCellAt(0,0).firstChild.name, "cell0", "wrong cell");
is(accTable3.getCellAt(0,1).firstChild.name, "cell1", "wrong cell");
}
// Test table with role=log and aria property in tr. We create accessible for
@ -62,10 +62,10 @@ function doTest()
testRole(accTable4, ROLE_TABLE);
is(accTable4.cellRefAt(0,0).firstChild.name, "cell0", "wrong cell");
is(accTable4.cellRefAt(0,1).firstChild.name, "cell1", "wrong cell");
is(accTable4.cellRefAt(1,0).firstChild.name, "cell2", "wrong cell");
is(accTable4.cellRefAt(1,1).firstChild.name, "cell3", "wrong cell");
is(accTable4.getCellAt(0,0).firstChild.name, "cell0", "wrong cell");
is(accTable4.getCellAt(0,1).firstChild.name, "cell1", "wrong cell");
is(accTable4.getCellAt(1,0).firstChild.name, "cell2", "wrong cell");
is(accTable4.getCellAt(1,1).firstChild.name, "cell3", "wrong cell");
}
// Test table with display:inline and an outside table. We shouldn't be fooled

Просмотреть файл

@ -0,0 +1,204 @@
<!DOCTYPE HTML PUBLIC "-//w3c//dtd html 4.0 transitional//en">
<html>
<head>
<title>Table header information cells for HTML table</title>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<link rel="stylesheet" type="text/css"
href="chrome://mochikit/content/tests/SimpleTest/test.css" />
<script type="application/javascript"
src="chrome://mochikit/content/MochiKit/packed.js"></script>
<script type="application/javascript"
src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
<script type="application/javascript"
src="chrome://mochikit/content/a11y/accessible/common.js"></script>
<script type="application/javascript"
src="chrome://mochikit/content/a11y/accessible/table.js"></script>
<script type="application/javascript">
function doTest()
{
//////////////////////////////////////////////////////////////////////////
// column header from thead and row header from @scope inside of tfoot
var headerInfoMap = [
{
cell: "table1_cell_1",
rowHeaderCells: [],
columnHeaderCells: [ "table1_weekday", "table1_date" ]
},
{
cell: "table1_cell_2",
rowHeaderCells: [],
columnHeaderCells: [ "table1_day", "table1_date" ]
},
{
cell: "table1_cell_3",
rowHeaderCells: [],
columnHeaderCells: [ "table1_qty" ]
},
{
cell: "table1_cell_4",
rowHeaderCells: [],
columnHeaderCells: [ "table1_weekday", "table1_date" ]
},
{
cell: "table1_cell_5",
rowHeaderCells: [],
columnHeaderCells: [ "table1_day", "table1_date" ]
},
{
cell: "table1_cell_6",
rowHeaderCells: [],
columnHeaderCells: [ "table1_qty" ]
},
{
cell: "table1_cell_7",
rowHeaderCells: [ "table1_total" ],
columnHeaderCells: [ "table1_qty" ]
}
];
testHeaderCells(headerInfoMap);
//////////////////////////////////////////////////////////////////////////
// column and row headers from thead and @scope
headerInfoMap = [
{
cell: "table2_cell_2",
rowHeaderCells: [ "table2_rh_1" ],
columnHeaderCells: [ "table2_ch_2" ]
},
{
cell: "table2_cell_3",
rowHeaderCells: [ "table2_rh_1" ],
columnHeaderCells: [ "table2_ch_3" ]
},
{
cell: "table2_cell_5",
rowHeaderCells: [ "table2_rh_2" ],
columnHeaderCells: [ "table2_ch_2" ]
},
{
cell: "table2_cell_6",
rowHeaderCells: [ "table2_rh_2" ],
columnHeaderCells: [ "table2_ch_3" ]
},
{
cell: "table2_rh_1",
rowHeaderCells: [],
columnHeaderCells: [ "table2_ch_1" ]
},
{
cell: "table2_rh_2",
rowHeaderCells: [],
columnHeaderCells: [ "table2_ch_1" ]
}
];
testHeaderCells(headerInfoMap);
//////////////////////////////////////////////////////////////////////////
// column headers from @headers
headerInfoMap = [
{
cell: "table3_cell_1",
rowHeaderCells: [],
columnHeaderCells: [ "table3_ch_1" ]
},
{
cell: "table3_cell_2",
rowHeaderCells: [],
columnHeaderCells: [ "table3_ch_2" ]
}
];
testHeaderCells(headerInfoMap);
SimpleTest.finish();
}
SimpleTest.waitForExplicitFinish();
addLoadEvent(doTest);
</script>
</head>
<body>
<a target="_blank"
title="implement IAccessibleTable2"
href="https://bugzilla.mozilla.org/show_bug.cgi?id=512424">Mozilla Bug 512424</a>
<p id="display"></p>
<div id="content" style="display: none"></div>
<pre id="test">
</pre>
<table id="table1" border="1">
<thead>
<tr>
<th id="table1_date" colspan="2">Date</th>
<th id="table1_qty" rowspan="2">Qty</th>
</tr>
<tr>
<th id="table1_weekday">Weekday</th>
<th id="table1_day">Day</th>
</tr>
</thead>
<tbody>
<tr>
<td id="table1_cell_1">Mon</td>
<td id="table1_cell_2">1</td>
<td id="table1_cell_3">20</td>
</tr>
<tr>
<td id="table1_cell_4">Thu</td>
<td id="table1_cell_5">2</td>
<td id="table1_cell_6">15</td>
</tr>
</tbody>
<tfoot>
<tr>
<th id="table1_total" scope="row" colspan="2">Total</th>
<td id="table1_cell_7">35</td>
</tr>
</tfoot>
</table>
<table id="table2" border="1">
<thead>
<tr>
<th id="table2_ch_1">col1</th>
<th id="table2_ch_2">col2</th>
<td id="table2_ch_3" scope="col">col3</td>
</tr>
</thead>
<tbody>
<tr>
<th id="table2_rh_1">row1</th>
<td id="table2_cell_2">cell1</td>
<td id="table2_cell_3">cell2</td>
</tr>
<tr>
<td id="table2_rh_2" scope="row">row2</td>
<td id="table2_cell_5">cell3</td>
<td id="table2_cell_6">cell4</td>
</tr>
</tbody>
</table>
<table id="table3" border="1">
<tr>
<td id="table3_cell_1" headers="table3_ch_1">cell1</td>
<td id="table3_cell_2" headers="table3_ch_2">cell2</td>
</tr>
<tr>
<td id="table3_ch_1" scope="col">col1</td>
<td id="table3_ch_2" scope="col">col2</td>
</tr>
</table>
</body>
</html>

Просмотреть файл

@ -0,0 +1,141 @@
<!DOCTYPE HTML PUBLIC "-//w3c//dtd html 4.0 transitional//en">
<html>
<head>
<title>Table header information cells for ARIA grid</title>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<link rel="stylesheet" type="text/css"
href="chrome://mochikit/content/tests/SimpleTest/test.css" />
<script type="application/javascript"
src="chrome://mochikit/content/MochiKit/packed.js"></script>
<script type="application/javascript"
src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
<script type="application/javascript"
src="chrome://mochikit/content/a11y/accessible/common.js"></script>
<script type="application/javascript"
src="chrome://mochikit/content/a11y/accessible/table.js"></script>
<script type="application/javascript">
function doTest()
{
//////////////////////////////////////////////////////////////////////////
// column and row headers from markup
headerInfoMap = [
{
cell: "table_dc_1",
rowHeaderCells: [ "table_rh_1" ],
columnHeaderCells: [ "table_ch_2" ]
},
{
cell: "table_dc_2",
rowHeaderCells: [ "table_rh_1" ],
columnHeaderCells: [ "table_ch_3" ]
},
{
cell: "table_dc_3",
rowHeaderCells: [ "table_rh_2" ],
columnHeaderCells: [ "table_ch_2" ]
},
{
cell: "table_dc_4",
rowHeaderCells: [ "table_rh_2" ],
columnHeaderCells: [ "table_ch_3" ]
},
{
cell: "table_rh_1",
rowHeaderCells: [],
columnHeaderCells: [ "table_ch_1" ]
},
{
cell: "table_rh_2",
rowHeaderCells: [],
columnHeaderCells: [ "table_ch_1" ]
}
];
testHeaderCells(headerInfoMap);
//////////////////////////////////////////////////////////////////////////
// column and row headers from markup for crazy grid.
headerInfoMap = [
{
// not focusable cell (nsARIAGridCellAccessible is used)
cell: "table2_dc_1",
rowHeaderCells: [],
columnHeaderCells: [ "table2_ch_1" ]
},
{
// focusable cell (nsARIAGridCellAccessible is used)
cell: "table2_dc_2",
rowHeaderCells: [],
columnHeaderCells: [ "table2_ch_2" ]
}
];
testHeaderCells(headerInfoMap);
SimpleTest.finish();
}
SimpleTest.waitForExplicitFinish();
addLoadEvent(doTest);
</script>
</head>
<body>
<a target="_blank"
title="implement IAccessibleTable2"
href="https://bugzilla.mozilla.org/show_bug.cgi?id=512424">Mozilla Bug 512424</a>
<a target="_blank"
title="nsHTMLTableCellAccessible is used in dojo's crazy ARIA grid"
href="https://bugzilla.mozilla.org/show_bug.cgi?id=513848">Mozilla Bug 513848</a>
<p id="display"></p>
<div id="content" style="display: none"></div>
<pre id="test">
</pre>
<div role="grid">
<div role="row">
<span id="table_ch_1" role="columnheader">col_1</span>
<span id="table_ch_2" role="columnheader">col_2</span>
<span id="table_ch_3" role="columnheader">col_3</span>
</div>
<div role="row">
<span id="table_rh_1" role="rowheader">row_1</span>
<span id="table_dc_1" role="gridcell">cell1</span>
<span id="table_dc_2" role="gridcell">cell2</span>
</div>
<div role="row">
<span id="table_rh_2" role="rowheader">row_2</span>
<span id="table_dc_3" role="gridcell">cell3</span>
<span id="table_dc_4" role="gridcell">cell4</span>
</div>
</div>
<div role="grid">
<div role="row">
<table role="presentation">
<tr>
<td id="table2_ch_1" role="columnheader">header1</td>
<td id="table2_ch_2" role="columnheader">header2</td>
</tr>
</table>
</div>
<div role="row">
<table role="presentation">
<tr>
<td id="table2_dc_1" role="gridcell">cell1</td>
<td id="table2_dc_2" role="gridcell" tabindex="-1">cell2</td>
</tr>
</table>
</div>
</div>
</body>
</html>

Некоторые файлы не были показаны из-за слишком большого количества измененных файлов Показать больше