Active accessibility fixes. Bug 118633 - null frame checks, bug 118761 - support STATE_SYSTEM_INVISIBLE, bug 118759 - support statusbar, bug 114109 - support dropmarker, bug 118858 and bug 118020 - text nodes shouldn't get focusable state. r's=jgaunt, sr's=hewitt, waterson

This commit is contained in:
aaronl%netscape.com 2002-01-09 10:02:29 +00:00
Родитель fc0f91cc7c
Коммит 13f63c20ef
17 изменённых файлов: 314 добавлений и 26 удалений

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

@ -57,6 +57,7 @@ interface nsIAccessibilityService : nsISupports
nsIAccessible createXULColorPickerAccessible(in nsIDOMNode aNode);
nsIAccessible createXULColorPickerTileAccessible(in nsIDOMNode aNode);
nsIAccessible createXULComboboxAccessible(in nsIDOMNode aNode);
nsIAccessible createXULDropmarkerAccessible(in nsIDOMNode aNode);
nsIAccessible createXULGroupboxAccessible(in nsIDOMNode aNode);
nsIAccessible createXULImageAccessible(in nsIDOMNode aNode);
nsIAccessible createXULListboxAccessible(in nsIDOMNode aNode);
@ -65,6 +66,7 @@ interface nsIAccessibilityService : nsISupports
nsIAccessible createXULMenupopupAccessible(in nsIDOMNode aNode);
nsIAccessible createXULMenuSeparatorAccessible(in nsIDOMNode aNode);
nsIAccessible createXULProgressMeterAccessible(in nsIDOMNode aNode);
nsIAccessible createXULStatusBarAccessible(in nsIDOMNode aNode);
nsIAccessible createXULRadioButtonAccessible(in nsIDOMNode aNode);
nsIAccessible createXULRadioGroupAccessible(in nsIDOMNode aNode);
nsIAccessible createXULSelectOptionAccessible(in nsIDOMNode aNode);

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

@ -3,3 +3,5 @@ press = Press
check = Check
uncheck = Uncheck
select = Select
open = Open
close = Close

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

@ -709,6 +709,24 @@ nsAccessibilityService::CreateXULComboboxAccessible(nsIDOMNode *aNode, nsIAccess
return NS_OK;
}
NS_IMETHODIMP
nsAccessibilityService::CreateXULDropmarkerAccessible(nsIDOMNode *aNode, nsIAccessible **_retval)
{
#ifdef MOZ_XUL
nsCOMPtr<nsIWeakReference> weakShell;
GetShellFromNode(aNode, getter_AddRefs(weakShell));
*_retval = new nsXULDropmarkerAccessible(aNode, weakShell);
if (! *_retval)
return NS_ERROR_OUT_OF_MEMORY;
NS_ADDREF(*_retval);
#else
*_retval = nsnull;
#endif // MOZ_XUL
return NS_OK;
}
NS_IMETHODIMP
nsAccessibilityService::CreateXULGroupboxAccessible(nsIDOMNode *aNode, nsIAccessible **_retval)
{
@ -938,6 +956,24 @@ nsAccessibilityService::CreateXULSelectOptionAccessible(nsIDOMNode *aNode, nsIAc
return NS_OK;
}
NS_IMETHODIMP
nsAccessibilityService::CreateXULStatusBarAccessible(nsIDOMNode *aNode, nsIAccessible **_retval)
{
#ifdef MOZ_XUL
nsCOMPtr<nsIWeakReference> weakShell;
GetShellFromNode(aNode, getter_AddRefs(weakShell));
*_retval = new nsXULStatusBarAccessible(aNode, weakShell);
if (! *_retval)
return NS_ERROR_OUT_OF_MEMORY;
NS_ADDREF(*_retval);
#else
*_retval = nsnull;
#endif // MOZ_XUL
return NS_OK;
}
NS_IMETHODIMP
nsAccessibilityService::CreateXULTextAccessible(nsIDOMNode *aNode, nsIAccessible **_retval)
{
@ -1049,8 +1085,13 @@ NS_IMETHODIMP nsAccessibilityService::GetAccessibleFor(nsIDOMNode *aNode,
// Please leave this in for now, it's a convenient debugging method
nsAutoString name;
aNode->GetLocalName(name);
if (name.Equals(NS_LITERAL_STRING("menulist")))
printf("## aaronl debugging\n");
if (name.Equals(NS_LITERAL_STRING("dropmarker")))
printf("## aaronl debugging tag name\n");
nsAutoString className;
xulElement->GetAttribute(NS_LITERAL_STRING("class"), className);
if (className.Equals(NS_LITERAL_STRING("toolbarbutton-menubutton-dropmarker")))
printf("## aaronl debugging attribute\n");
#endif
nsCOMPtr<nsIAccessibleProvider> accProv(do_QueryInterface(aNode));
if (accProv) {

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

@ -701,7 +701,7 @@ NS_IMETHODIMP nsAccessible::GetAccState(PRUint32 *aAccState)
// Check if STATE_OFFSCREEN bitflag should be turned on for this object
if (!IsEntirelyVisible())
*aAccState |= STATE_OFFSCREEN;
*aAccState |= STATE_OFFSCREEN | STATE_INVISIBLE;
return rv;
}

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

@ -221,8 +221,8 @@ NS_IMETHODIMP nsLinkableAccessible::GetAccState(PRUint32 *_retval)
nsCOMPtr<nsIPresContext> context;
shell->GetPresContext(getter_AddRefs(context));
nsCOMPtr<nsIContent> content(do_QueryInterface(mDOMNode));
nsIFrame *frame;
if (content && NS_SUCCEEDED(shell->GetPrimaryFrameFor(content, &frame))) {
nsIFrame *frame = nsnull;
if (content && NS_SUCCEEDED(shell->GetPrimaryFrameFor(content, &frame)) && frame) {
nsCOMPtr<nsISelectionController> selCon;
frame->GetSelectionController(context,getter_AddRefs(selCon));
if (selCon) {
@ -238,7 +238,7 @@ NS_IMETHODIMP nsLinkableAccessible::GetAccState(PRUint32 *_retval)
}
}
if (mIsALinkCached) {
if (IsALink()) {
// Make sure we also include all the states of the parent link, such as focusable, focused, etc.
PRUint32 role;
GetAccRole(&role);
@ -251,9 +251,8 @@ NS_IMETHODIMP nsLinkableAccessible::GetAccState(PRUint32 *_retval)
*_retval |= orState;
}
}
}
// Focused? Do we implement that here or up the chain?
return NS_OK;
}

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

@ -535,9 +535,9 @@ NS_IMETHODIMP nsComboboxButtonAccessible::GetAccActionName(PRUint8 index, nsAWri
return NS_ERROR_FAILURE;
comboFrame->IsDroppedDown(&isOpen);
if (isOpen)
_retval = NS_LITERAL_STRING("Close");
_retval = NS_LITERAL_STRING("close");
else
_retval = NS_LITERAL_STRING("Open");
_retval = NS_LITERAL_STRING("open");
return NS_OK;
}
@ -663,6 +663,10 @@ void nsComboboxWindowAccessible::GetBounds(nsRect& aBounds, nsIFrame** aBounding
nsIFrame* frame = nsnull;
nsCOMPtr<nsIContent> content(do_QueryInterface(child));
shell->GetPrimaryFrameFor(content, &frame);
if (!frame) {
*aBoundingFrame = nsnull;
return;
}
#ifdef DEBUG
if (! nsAccessible::IsCorrectFrameType(frame, nsLayoutAtoms::blockFrame))
return;

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

@ -338,8 +338,8 @@ NS_IMETHODIMP nsHTMLTextFieldAccessible::GetAccState(PRUint32 *_retval)
nsCOMPtr<nsIPresContext> context;
shell->GetPresContext(getter_AddRefs(context));
nsCOMPtr<nsIContent> content(do_QueryInterface(mDOMNode));
nsIFrame *frame;
if (content && NS_SUCCEEDED(shell->GetPrimaryFrameFor(content, &frame))) {
nsIFrame *frame = nsnull;
if (content && NS_SUCCEEDED(shell->GetPrimaryFrameFor(content, &frame)) && frame) {
nsCOMPtr<nsISelectionController> selCon;
frame->GetSelectionController(context,getter_AddRefs(selCon));
if (selCon) {

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

@ -236,15 +236,13 @@ nsresult nsHTMLSelectOptionAccessible::GetFocusedOptionNode(nsIWeakReference *aP
nsCOMPtr<nsIContent> content(do_QueryInterface(aListNode));
shell->GetPrimaryFrameFor(content, &frame);
nsresult rv;
nsCOMPtr<nsIListControlFrame> listFrame(do_QueryInterface(frame, &rv));
if (NS_FAILED(rv))
return rv; // How can list content not have a list frame?
NS_ASSERTION(listFrame, "We don't have a list frame, but rv returned a success code.");
nsCOMPtr<nsIListControlFrame> listFrame(do_QueryInterface(frame));
if (!listFrame)
return NS_ERROR_FAILURE;
// Get what's focused by asking frame for "selected item".
PRInt32 focusedOptionIndex = 0;
rv = listFrame->GetSelectedIndex(&focusedOptionIndex);
nsresult rv = listFrame->GetSelectedIndex(&focusedOptionIndex);
nsCOMPtr<nsIDOMHTMLCollection> options;

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

@ -54,6 +54,13 @@ NS_IMETHODIMP nsHTMLTableCellAccessible::GetAccRole(PRUint32 *aResult)
return NS_OK;
}
NS_IMETHODIMP nsHTMLTableCellAccessible::GetAccState(PRUint32 *aResult)
{
nsAccessible::GetAccState(aResult);
*aResult &= ~STATE_FOCUSABLE; // Inherit all states except focusable state since table cells cannot be focused
return NS_OK;
}
nsHTMLTableAccessible::nsHTMLTableAccessible(nsIDOMNode* aDomNode, nsIWeakReference* aShell):
nsBlockAccessible(aDomNode, aShell)
{

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

@ -48,6 +48,7 @@ class nsHTMLTableCellAccessible : public nsBlockAccessible
public:
nsHTMLTableCellAccessible(nsIDOMNode* aDomNode, nsIWeakReference* aShell);
NS_IMETHOD GetAccRole(PRUint32 *aResult);
NS_IMETHOD GetAccState(PRUint32 *aResult);
};

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

@ -48,7 +48,7 @@ class nsHTMLTextAccessible : public nsTextAccessible
public:
nsHTMLTextAccessible(nsIDOMNode* aDomNode, nsIWeakReference* aShell);
NS_IMETHOD GetAccName(nsAWritableString& _retval);
NS_IMETHOD GetAccName(nsAWritableString& _retval);
};
#endif

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

@ -53,7 +53,7 @@
* Default Constructor
*/
nsXULColorPickerTileAccessible::nsXULColorPickerTileAccessible(nsIDOMNode* aNode, nsIWeakReference* aShell):
nsXULButtonAccessible(aNode, aShell)
nsFormControlAccessible(aNode, aShell)
{
}

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

@ -41,9 +41,9 @@
#define _nsXULColorPickerAccessible_H_
// NOTE: alphabetically ordered
#include "nsXULFormControlAccessible.h"
#include "nsFormControlAccessible.h"
class nsXULColorPickerTileAccessible : public nsXULButtonAccessible
class nsXULColorPickerTileAccessible : public nsFormControlAccessible
{
public:
nsXULColorPickerTileAccessible(nsIDOMNode* aNode, nsIWeakReference* aShell);

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

@ -50,6 +50,8 @@
#include "nsReadableUtils.h"
#include "nsString.h"
#include "nsXULFormControlAccessible.h"
#include "nsIAccessibilityService.h"
#include "nsIServiceManager.h"
/**
* XUL Button: can contain arbitrary HTML content
@ -58,11 +60,18 @@
/**
* Default Constructor
*/
// Don't inherit from nsFormControlAccessible - it doesn't allow children and a button can have a dropmarker child
nsXULButtonAccessible::nsXULButtonAccessible(nsIDOMNode* aNode, nsIWeakReference* aShell):
nsFormControlAccessible(aNode, aShell)
nsAccessible(aNode, aShell), mAccService(do_GetService("@mozilla.org/accessibilityService;1"))
{
}
NS_IMETHODIMP nsXULButtonAccessible::GetAccName(nsAWritableString& aResult)
{
return GetXULAccName(aResult);
}
/**
* Only one actions available
*/
@ -116,8 +125,17 @@ NS_IMETHODIMP nsXULButtonAccessible::GetAccRole(PRUint32 *_retval)
NS_IMETHODIMP nsXULButtonAccessible::GetAccState(PRUint32 *_retval)
{
// get focus and disable status from base class
nsFormControlAccessible::GetAccState(_retval);
*_retval |= STATE_FOCUSABLE;
nsAccessible::GetAccState(_retval);
PRBool disabled = PR_FALSE;
nsCOMPtr<nsIDOMXULControlElement> xulFormElement(do_QueryInterface(mDOMNode));
if (xulFormElement) {
xulFormElement->GetDisabled(&disabled);
if (disabled)
*_retval |= STATE_UNAVAILABLE;
else
*_retval |= STATE_FOCUSABLE;
}
// Buttons can be checked -- they simply appear pressed in rather than checked
nsCOMPtr<nsIDOMXULButtonElement> xulButtonElement(do_QueryInterface(mDOMNode));
@ -136,6 +154,132 @@ NS_IMETHODIMP nsXULButtonAccessible::GetAccState(PRUint32 *_retval)
return NS_OK;
}
/**
* Perhaps 1 child - if there's a <dropmarker>
*/
NS_IMETHODIMP nsXULButtonAccessible::GetAccFirstChild(nsIAccessible **aResult)
{
*aResult = nsnull;
nsCOMPtr<nsIAccessible> testAccessible;
nsAccessible::GetAccLastChild(getter_AddRefs(testAccessible));
// If the anonymous tree walker can find accessible children, and the last one is a push button,
// then use it as the only accessible child -- because this is the scenario where we have a dropmarker child
if (testAccessible) {
PRUint32 role;
if (NS_SUCCEEDED(testAccessible->GetAccRole(&role)) && role == ROLE_PUSHBUTTON) {
*aResult = testAccessible;
NS_ADDREF(*aResult);
}
}
return NS_OK;
}
NS_IMETHODIMP nsXULButtonAccessible::GetAccLastChild(nsIAccessible **aResult)
{
return GetAccFirstChild(aResult);
}
NS_IMETHODIMP nsXULButtonAccessible::GetAccChildCount(PRInt32 *aResult)
{
*aResult = 0;
nsCOMPtr<nsIAccessible> accessible;
GetAccFirstChild(getter_AddRefs(accessible));
if (accessible)
*aResult = 1;
return NS_OK;
}
/**
* XUL Dropmarker: can contain arbitrary HTML content
*/
/**
* Default Constructor
*/
nsXULDropmarkerAccessible::nsXULDropmarkerAccessible(nsIDOMNode* aNode, nsIWeakReference* aShell):
nsFormControlAccessible(aNode, aShell)
{
}
/**
* Only one actions available
*/
NS_IMETHODIMP nsXULDropmarkerAccessible::GetAccNumActions(PRUint8 *aResult)
{
*aResult = eSingle_Action;
return NS_OK;;
}
PRBool nsXULDropmarkerAccessible::DropmarkerOpen(PRBool aToggleOpen)
{
PRBool isOpen = PR_FALSE;
nsCOMPtr<nsIDOMNode> parentButtonNode;
mDOMNode->GetParentNode(getter_AddRefs(parentButtonNode));
nsCOMPtr<nsIDOMXULButtonElement> parentButtonElement(do_QueryInterface(parentButtonNode));
if (parentButtonElement) {
parentButtonElement->GetOpen(&isOpen);
if (aToggleOpen)
parentButtonElement->SetOpen(!isOpen);
}
return isOpen;
}
/**
* Return the name of our only action
*/
NS_IMETHODIMP nsXULDropmarkerAccessible::GetAccActionName(PRUint8 index, nsAWritableString& aResult)
{
if (index == eAction_Click) {
if (DropmarkerOpen(PR_FALSE))
aResult = NS_LITERAL_STRING("close");
else
aResult = NS_LITERAL_STRING("open");
return NS_OK;
}
return NS_ERROR_INVALID_ARG;
}
/**
* Tell the Dropmarker to do it's action
*/
NS_IMETHODIMP nsXULDropmarkerAccessible::AccDoAction(PRUint8 index)
{
if (index == eAction_Click) {
DropmarkerOpen(PR_TRUE); // Reverse the open attribute
return NS_OK;
}
return NS_ERROR_INVALID_ARG;
}
/**
* We are a pushbutton
*/
NS_IMETHODIMP nsXULDropmarkerAccessible::GetAccRole(PRUint32 *aResult)
{
*aResult = ROLE_PUSHBUTTON;
return NS_OK;
}
NS_IMETHODIMP nsXULDropmarkerAccessible::GetAccState(PRUint32 *aResult)
{
*aResult = 0;
if (DropmarkerOpen(PR_FALSE))
*aResult = STATE_PRESSED;
return NS_OK;
}
/**
* XUL checkbox
*/
@ -378,3 +522,29 @@ nsFormControlAccessible(aNode, aShell)
{
}
/**
* XUL StatusBar: can contain arbitrary HTML content
*/
/**
* Default Constructor
*/
nsXULStatusBarAccessible::nsXULStatusBarAccessible(nsIDOMNode* aNode, nsIWeakReference* aShell):
nsFormControlAccessible(aNode, aShell)
{
}
/**
* We are a statusbar
*/
NS_IMETHODIMP nsXULStatusBarAccessible::GetAccRole(PRUint32 *_retval)
{
*_retval = ROLE_STATUSBAR;
return NS_OK;
}
NS_IMETHODIMP nsXULStatusBarAccessible::GetAccState(PRUint32 *_retval)
{
*_retval = 0; // no special state flags for status bar
return NS_OK;
}

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

@ -45,15 +45,24 @@
#include "nsFormControlAccessible.h"
#include "nsHTMLFormControlAccessible.h"
class nsXULButtonAccessible : public nsFormControlAccessible
class nsXULButtonAccessible : public nsAccessible
// Don't inherit from nsFormControlAccessible - it doesn't allow children and a button can have a dropmarker child
{
public:
nsXULButtonAccessible(nsIDOMNode* aNode, nsIWeakReference* aShell);
NS_IMETHOD GetAccName(nsAWritableString& aResult);
NS_IMETHOD GetAccRole(PRUint32 *_retval);
NS_IMETHOD GetAccState(PRUint32 *_retval);
NS_IMETHOD GetAccNumActions(PRUint8 *_retval);
NS_IMETHOD GetAccActionName(PRUint8 index, nsAWritableString& _retval);
NS_IMETHOD AccDoAction(PRUint8 index);
NS_IMETHOD GetAccFirstChild(nsIAccessible **_retval);
NS_IMETHOD GetAccLastChild(nsIAccessible **_retval);
NS_IMETHOD GetAccChildCount(PRInt32 *_retval);
private:
nsCOMPtr<nsIAccessibilityService> mAccService;
};
class nsXULCheckboxAccessible : public nsFormControlAccessible
@ -67,6 +76,20 @@ public:
NS_IMETHOD GetAccState(PRUint32 *_retval);
};
class nsXULDropmarkerAccessible : public nsFormControlAccessible
{
public:
nsXULDropmarkerAccessible(nsIDOMNode* aNode, nsIWeakReference* aShell);
NS_IMETHOD GetAccRole(PRUint32 *_retval);
NS_IMETHOD GetAccState(PRUint32 *_retval);
NS_IMETHOD GetAccNumActions(PRUint8 *_retval);
NS_IMETHOD GetAccActionName(PRUint8 index, nsAWritableString& _retval);
NS_IMETHOD AccDoAction(PRUint8 index);
private:
PRBool DropmarkerOpen(PRBool aToggleOpen);
};
class nsXULGroupboxAccessible : public nsAccessible
{
public:
@ -101,5 +124,13 @@ public:
nsXULRadioGroupAccessible(nsIDOMNode* aNode, nsIWeakReference* aShell);
};
class nsXULStatusBarAccessible : public nsFormControlAccessible
{
public:
nsXULStatusBarAccessible(nsIDOMNode* aNode, nsIWeakReference* aShell);
NS_IMETHOD GetAccRole(PRUint32 *_retval);
NS_IMETHOD GetAccState(PRUint32 *_retval);
};
#endif

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

@ -235,6 +235,17 @@
<xul:resizer dir="bottomright" style="-moz-appearance: resizer; cursor: se-resize"/>
</xul:statusbarpanel>
</content>
<implementation implements="nsIAccessibleProvider">
<property name="accessible">
<getter>
<![CDATA[
var accService = Components.classes["@mozilla.org/accessibilityService;1"].getService(Components.interfaces.nsIAccessibilityService);
return (accService? accService.createXULStatusBarAccessible(this): null);
]]>
</getter>
</property>
</implementation>
</binding>
<binding id="statusbarpanel-iconic" display="xul:button"
@ -302,6 +313,17 @@
<content>
<xul:image class="dropmarker-icon"/>
</content>
<implementation implements="nsIAccessibleProvider">
<property name="accessible">
<getter>
<![CDATA[
var accService = Components.classes["@mozilla.org/accessibilityService;1"].getService(Components.interfaces.nsIAccessibilityService);
return (accService? accService.createXULDropmarkerAccessible(this): null);
]]>
</getter>
</property>
</implementation>
</binding>
</bindings>

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

@ -58,6 +58,17 @@
<content>
<xul:image class="menubutton-dropmarker-icon"/>
</content>
<implementation implements="nsIAccessibleProvider">
<property name="accessible">
<getter>
<![CDATA[
var accService = Components.classes["@mozilla.org/accessibilityService;1"].getService(Components.interfaces.nsIAccessibilityService);
return (accService? accService.createXULDropmarkerAccessible(this): null);
]]>
</getter>
</property>
</implementation>
</binding>
</bindings>