Bug 153852 Accessibility: Support selection_changed, text_changed and text_selection_changed events for ATK

r=aaronl, sr=jst
This commit is contained in:
kyle.yuan%sun.com 2002-07-05 06:20:15 +00:00
Родитель a6105d1231
Коммит 55ee87199a
7 изменённых файлов: 167 добавлений и 133 удалений

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

@ -84,6 +84,7 @@ interface nsIAccessibleEventListener : nsISupports
const unsigned long EVENT_ATK_TEXT_CHANGE = 0x0102;
const unsigned long EVENT_ATK_TEXT_SELECTION_CHANGE = 0x0103;
const unsigned long EVENT_ATK_TEXT_CARET_MOVE = 0x0104;
const unsigned long EVENT_ATK_VISIBLE_DATA_CHANGE = 0x0105;
const unsigned long EVENT_ATK_TABLE_MODEL_CHANGE = 0x0110;
const unsigned long EVENT_ATK_TABLE_ROW_INSERT = 0x0111;
const unsigned long EVENT_ATK_TABLE_ROW_DELETE = 0x0112;

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

@ -62,6 +62,7 @@ CPPSRCS = \
EXPORTS = \
nsRootAccessible.h \
nsAccessibleEventData.h \
$(NULL)
# we don't want the shared lib, but we want to force the creation of a static lib.

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

@ -1,82 +0,0 @@
#!gmake
#
# The contents of this file are subject to the Netscape 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/NPL/
#
# 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 Netscape are
# Copyright (C) 1998 Netscape Communications Corporation. All
# Rights Reserved.
#
# Contributor(s): John Gaunt (jgaunt@netscape.com)
DEPTH = ..\..\..
MODULE = accessibility
LIBRARY_NAME = accessibility_base_s
REQUIRES = \
content \
content_xul \
docshell \
dom \
gfx \
intl \
layout \
layout_xul \
locale \
necko \
plugin \
pref \
string \
uriloader \
view \
webshell \
widget \
xpcom \
$(NULL)
CPP_OBJS = \
.\$(OBJDIR)\nsAccessibilityService.obj \
.\$(OBJDIR)\nsAccessible.obj \
.\$(OBJDIR)\nsBaseWidgetAccessible.obj \
.\$(OBJDIR)\nsFormControlAccessible.obj \
.\$(OBJDIR)\nsGenericAccessible.obj \
.\$(OBJDIR)\nsRootAccessible.obj \
.\$(OBJDIR)\nsCaretAccessible.obj \
.\$(OBJDIR)\nsSelectAccessible.obj \
.\$(OBJDIR)\nsTextAccessible.obj \
$(NULL)
EXPORTS = \
.\nsRootAccessible.h \
$(NULL)
LINCS = \
-I..\html \
-I..\xul \
-I..\..\..\layout\html\forms\public \
-I..\..\..\layout\html\forms\src \
-I..\..\..\layout\html\base\src \
-I..\..\..\widget\src\windows \
$(NULL)
include <$(DEPTH)\config\rules.mak>
libs:: $(LIBRARY)
$(MAKE_INSTALL) $(LIBRARY) $(DIST)\lib
clobber::
rm -f $(DIST)\lib\$(LIBRARY_NAME).lib

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

@ -0,0 +1,93 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Netscape 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/NPL/
*
* 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) 1998
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Kyle Yuan (kyle.yuan@sun.com)
* John Sun (john.sun@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 NPL, 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 NPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#ifndef _nsAccessibleEventData_H_
#define _nsAccessibleEventData_H_
#ifdef MOZ_ACCESSIBILITY_ATK
struct AtkStateChange {
PRUint32 state;
PRBool enable;
};
enum AtkProperty {
PROP_0, // gobject convention
PROP_NAME,
PROP_DESCRIPTION,
PROP_PARENT, // ancestry has changed
PROP_VALUE,
PROP_ROLE,
PROP_LAYER,
PROP_MDI_ZORDER,
PROP_TABLE_CAPTION,
PROP_TABLE_COLUMN_DESCRIPTION,
PROP_TABLE_COLUMN_HEADER,
PROP_TABLE_ROW_DESCRIPTION,
PROP_TABLE_ROW_HEADER,
PROP_TABLE_SUMMARY,
PROP_LAST // gobject convention
};
struct AtkPropertyChange {
PRInt32 type; // property type as listed above
void *oldvalue;
void *newvalue;
};
struct AtkChildrenChange {
PRUint32 index; // index of child in parent
nsIAccessible *child;
PRBool add; // true for add, false for delete
};
struct AtkTextChange {
PRUint32 start;
PRUint32 length;
PRBool add; // true for add, false for delete
};
struct AtkTableChange {
PRUint32 index; // the start row/column after which the rows are inserted/deleted.
PRUint32 count; // the number of inserted/deleted rows/columns
};
#endif
#endif

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

@ -167,8 +167,18 @@ NS_IMETHODIMP nsCaretAccessible::NotifySelectionChanged(nsIDOMDocument *aDoc, ns
nsRect caretScreenRect;
widget->WidgetToScreen(caretRect, mCaretRect);
#ifndef MOZ_ACCESSIBILITY_ATK
if (visible)
mListener->HandleEvent(nsIAccessibleEventListener::EVENT_LOCATION_CHANGE, this, nsnull);
#else
if (isCollapsed) {
PRInt32 caretOffset;
domSel->GetFocusOffset(&caretOffset);
mListener->HandleEvent(nsIAccessibleEventListener::EVENT_ATK_TEXT_CARET_MOVE, this, (AccessibleEventData*)&caretOffset);
}
else
mListener->HandleEvent(nsIAccessibleEventListener::EVENT_ATK_TEXT_SELECTION_CHANGE, this, nsnull);
#endif
return NS_OK;
}

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

@ -84,6 +84,8 @@
#include "nsISelectionPrivate.h"
#include "nsICaret.h"
#include "nsIAccessibleCaret.h"
#include "nsIDOMHTMLInputElement.h"
#include "nsAccessibleEventData.h"
NS_INTERFACE_MAP_BEGIN(nsRootAccessible)
NS_INTERFACE_MAP_ENTRY(nsIAccessibleDocument)
@ -526,7 +528,7 @@ NS_IMETHODIMP nsRootAccessible::GetCaretAccessible(nsIAccessibleCaret **aCaretAc
void nsRootAccessible::FireAccessibleFocusEvent(nsIAccessible *focusAccessible, nsIDOMNode *focusNode)
{
if (focusNode && gLastFocusedNode != focusNode) {
if (focusAccessible && focusNode && gLastFocusedNode != focusNode) {
mListener->HandleEvent(nsIAccessibleEventListener::EVENT_FOCUS, focusAccessible, nsnull);
NS_IF_RELEASE(gLastFocusedNode);
gLastFocusedNode = focusNode;
@ -577,6 +579,7 @@ NS_IMETHODIMP nsRootAccessible::HandleEvent(nsIDOMEvent* aEvent)
nsCOMPtr<nsIAccessible> accessible;
if (NS_SUCCEEDED(mAccService->GetAccessibleFor(targetNode, getter_AddRefs(accessible)))) {
#ifndef MOZ_ACCESSIBILITY_ATK
// tree event
if (treeBox && treeIndex >= 0 &&
(eventType.EqualsIgnoreCase("DOMMenuItemActive") || eventType.EqualsIgnoreCase("select"))) {
@ -633,6 +636,60 @@ NS_IMETHODIMP nsRootAccessible::HandleEvent(nsIDOMEvent* aEvent)
FireAccessibleFocusEvent(accessible, targetNode);
}
}
#else
AtkStateChange stateData;
if (eventType.EqualsIgnoreCase("focus") || eventType.EqualsIgnoreCase("DOMMenuItemActive")) {
if (treeBox && treeIndex >= 0) { // use focused treeitem
nsCOMPtr<nsIWeakReference> weakShell;
nsAccessibilityService::GetShellFromNode(targetNode, getter_AddRefs(weakShell));
accessible = new nsXULTreeitemAccessible(accessible, targetNode, weakShell, treeIndex);
if (!accessible)
return NS_ERROR_OUT_OF_MEMORY;
mListener->HandleEvent(nsIAccessibleEventListener::EVENT_FOCUS, accessible, nsnull);
return NS_OK;
}
else if (optionTargetNode && // use focused option
NS_SUCCEEDED(mAccService->GetAccessibleFor(optionTargetNode, getter_AddRefs(accessible)))) {
FireAccessibleFocusEvent(accessible, optionTargetNode);
}
else
FireAccessibleFocusEvent(accessible, targetNode);
}
else if (eventType.EqualsIgnoreCase("change")) {
if (selectElement) // it's a HTML <select>
mListener->HandleEvent(nsIAccessibleEventListener::EVENT_ATK_SELECTION_CHANGE, accessible, nsnull);
else {
nsCOMPtr<nsIDOMHTMLInputElement> inputElement(do_QueryInterface(targetNode));
if (inputElement) { // it's a HTML <input>
accessible->GetAccState(&stateData.state);
stateData.enable = stateData.state & STATE_CHECKED;
stateData.state = STATE_CHECKED;
mListener->HandleEvent(nsIAccessibleEventListener::EVENT_STATE_CHANGE, accessible, nsnull);
}
}
}
else if (eventType.EqualsIgnoreCase("select")) {
if (selectControl) // it's a XUL <listbox>
mListener->HandleEvent(nsIAccessibleEventListener::EVENT_ATK_SELECTION_CHANGE, accessible, nsnull);
else if (treeBox && treeIndex >= 0) // it's a XUL <tree>
mListener->HandleEvent(nsIAccessibleEventListener::EVENT_ATK_SELECTION_CHANGE, accessible, nsnull);
// XUL <menulist> doesn't send FORM_SELECT event yet :(
}
else if (eventType.EqualsIgnoreCase("input")) {
mListener->HandleEvent(nsIAccessibleEventListener::EVENT_ATK_TEXT_CHANGE, accessible, nsnull);
}
else if (eventType.EqualsIgnoreCase("CheckboxStateChange") || // it's a XUL <checkbox>
eventType.EqualsIgnoreCase("RadioStateChange")) { // it's a XUL <radio>
accessible->GetAccState(&stateData.state);
stateData.enable = stateData.state & STATE_CHECKED;
stateData.state = STATE_CHECKED;
mListener->HandleEvent(nsIAccessibleEventListener::EVENT_STATE_CHANGE, accessible, nsnull);
}
else if (eventType.EqualsIgnoreCase("popupshowing"))
mListener->HandleEvent(nsIAccessibleEventListener::EVENT_MENUPOPUPSTART, accessible, nsnull);
else if (eventType.EqualsIgnoreCase("popuphiding"))
mListener->HandleEvent(nsIAccessibleEventListener::EVENT_MENUPOPUPEND, accessible, nsnull);
#endif
}
}
return NS_OK;
@ -696,7 +753,11 @@ NS_IMETHODIMP nsRootAccessible::Select(nsIDOMEvent* aEvent)
// gets Input events when text is entered or deleted in a textarea or input
NS_IMETHODIMP nsRootAccessible::Input(nsIDOMEvent* aEvent)
{
#ifndef MOZ_ACCESSIBILITY_ATK
return NS_OK;
#else
return HandleEvent(aEvent);
#endif
}
// ------- nsIDOMXULListener Methods (8) ---------------

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

@ -170,54 +170,4 @@ class nsRootAccessible : public nsAccessible,
nsCOMPtr<nsIAccessibleCaret> mCaretAccessible;
};
#ifdef XP_UNIX
struct AtkStateChange {
PRUint32 state;
PRBool enable;
};
enum AtkProperty {
PROP_0, // gobject convention
PROP_NAME,
PROP_DESCRIPTION,
PROP_PARENT, // ancestry has changed
PROP_VALUE,
PROP_ROLE,
PROP_LAYER,
PROP_MDI_ZORDER,
PROP_TABLE_CAPTION,
PROP_TABLE_COLUMN_DESCRIPTION,
PROP_TABLE_COLUMN_HEADER,
PROP_TABLE_ROW_DESCRIPTION,
PROP_TABLE_ROW_HEADER,
PROP_TABLE_SUMMARY,
PROP_LAST // gobject convention
};
struct AtkPropertyChange {
PRInt32 type; // property type as listed above
void *oldvalue;
void *newvalue;
};
struct AtkChildrenChange {
PRUint32 index; // index of child in parent
nsIAccessible *child;
PRBool add; // true for add, false for delete
};
struct AtkTextChange {
PRUint32 start;
PRUint32 length;
PRBool add; // true for add, false for delete
};
struct AtkTableChange {
PRUint32 index; // the start row/column after which the rows are inserted/deleted.
PRUint32 count; // the number of inserted/deleted rows/columns
};
#endif
#endif