Bug 92827. Active Accessibility: refine behavior of client/pane objects. r=jgaunt, rs=waterson

This commit is contained in:
aaronl%netscape.com 2001-07-31 22:23:58 +00:00
parent a80cd5bfe0
commit 2cb8fd21af
8 changed files with 112 additions and 2 deletions

View File

@ -20,6 +20,7 @@
* Contributor(s):
*/
#include "nsIAccessible.h"
#include "nsRootAccessible.h"
#include "nsCOMPtr.h"
#include "nsIDocument.h"
@ -35,6 +36,7 @@
#include "nsHTMLFormControlAccessible.h"
#include "nsHTMLLinkAccessible.h"
#include "nsIURI.h"
#include "nsIDocShell.h"
#include "nsIDocShellTreeItem.h"
#include "nsIXULDocument.h"
#include "nsIDOMDocument.h"
@ -126,6 +128,11 @@ NS_IMETHODIMP nsRootAccessible::GetAccRole(PRUint32 *aAccRole)
return NS_ERROR_FAILURE;
}
/*
// Commenting this out for now.
// It was requested that we always use pane objects instead of client objects.
// However, it might be asked that we put client objects back.
nsCOMPtr<nsIPresContext> context;
shell->GetPresContext(getter_AddRefs(context));
nsCOMPtr<nsISupports> container;
@ -143,9 +150,18 @@ NS_IMETHODIMP nsRootAccessible::GetAccRole(PRUint32 *aAccRole)
}
*aAccRole = ROLE_CLIENT;
*/
*aAccRole = ROLE_PANE;
return NS_OK;
}
NS_IMETHODIMP nsRootAccessible::GetAccState(PRUint32 *aAccState)
{
return nsDocAccessibleMixin::GetAccState(aAccState);
}
NS_IMETHODIMP nsRootAccessible::GetAccValue(nsAWritableString& aAccValue)
{
return GetURL(aAccValue);
@ -430,3 +446,35 @@ NS_IMETHODIMP nsDocAccessibleMixin::GetDocument(nsIDocument **doc)
return NS_ERROR_FAILURE;
}
NS_IMETHODIMP nsDocAccessibleMixin::GetAccState(PRUint32 *aAccState)
{
// Screen readers need to know when the document is finished loading (STATE_BUSY flag)
// We do it this way, rather than via nsIWebProgressListener, because
// if accessibility was turned on after a document already finished loading,
// we would get no state changes from nsIWebProgressListener.
// The GetBusyFlags method, however, always has the current busy state information for us.
*aAccState = 0;
if (mDocument) {
nsCOMPtr<nsIPresShell> presShell;
mDocument->GetShellAt(0, getter_AddRefs(presShell));
if (presShell) {
nsCOMPtr<nsIPresContext> context;
presShell->GetPresContext(getter_AddRefs(context));
if (context) {
nsCOMPtr<nsISupports> container;
context->GetContainer(getter_AddRefs(container));
if (container) {
nsCOMPtr<nsIDocShell> docShell(do_QueryInterface(container));
if (docShell) {
PRUint32 busyFlags;
docShell->GetBusyFlags(&busyFlags);
if (busyFlags != nsIDocShell::BUSY_FLAGS_NONE)
*aAccState = nsIAccessible::STATE_BUSY;
}
}
}
}
}
return NS_OK;
}

View File

@ -40,6 +40,8 @@ class nsDocAccessibleMixin
NS_DECL_NSIACCESSIBLEDOCUMENT
NS_IMETHOD GetAccState(PRUint32 *aAccState);
protected:
nsCOMPtr<nsIDocument> mDocument;
};
@ -63,6 +65,7 @@ class nsRootAccessible : public nsAccessible,
NS_IMETHOD GetAccValue(nsAWritableString& aAccValue);
NS_IMETHOD GetAccParent(nsIAccessible * *aAccParent);
NS_IMETHOD GetAccRole(PRUint32 *aAccRole);
NS_IMETHOD GetAccState(PRUint32 *aAccState);
// ----- nsIAccessibleEventReceiver -------------------

View File

@ -106,7 +106,10 @@ NS_IMETHODIMP nsHTMLIFrameAccessible::GetAccRole(PRUint32 *_retval)
return NS_OK;
}
// ------- nsIAccessibleDocument Methods (5) ---------------
NS_IMETHODIMP nsHTMLIFrameAccessible::GetAccState(PRUint32 *aAccState)
{
return nsDocAccessibleMixin::GetAccState(aAccState);
}
NS_IMETHODIMP nsHTMLIFrameAccessible::GetURL(nsAWritableString& aURL)
{

View File

@ -46,6 +46,7 @@ class nsHTMLIFrameAccessible : public nsHTMLBlockAccessible,
NS_IMETHOD GetAccName(nsAWritableString& aAccName);
NS_IMETHOD GetAccValue(nsAWritableString& AccValue);
NS_IMETHOD GetAccRole(PRUint32 *aAccRole);
NS_IMETHOD GetAccState(PRUint32 *aAccState);
protected:
nsCOMPtr<nsIAccessible> mRootAccessible;

View File

@ -106,7 +106,10 @@ NS_IMETHODIMP nsHTMLIFrameAccessible::GetAccRole(PRUint32 *_retval)
return NS_OK;
}
// ------- nsIAccessibleDocument Methods (5) ---------------
NS_IMETHODIMP nsHTMLIFrameAccessible::GetAccState(PRUint32 *aAccState)
{
return nsDocAccessibleMixin::GetAccState(aAccState);
}
NS_IMETHODIMP nsHTMLIFrameAccessible::GetURL(nsAWritableString& aURL)
{

View File

@ -46,6 +46,7 @@ class nsHTMLIFrameAccessible : public nsHTMLBlockAccessible,
NS_IMETHOD GetAccName(nsAWritableString& aAccName);
NS_IMETHOD GetAccValue(nsAWritableString& AccValue);
NS_IMETHOD GetAccRole(PRUint32 *aAccRole);
NS_IMETHOD GetAccState(PRUint32 *aAccState);
protected:
nsCOMPtr<nsIAccessible> mRootAccessible;

View File

@ -20,6 +20,7 @@
* Contributor(s):
*/
#include "nsIAccessible.h"
#include "nsRootAccessible.h"
#include "nsCOMPtr.h"
#include "nsIDocument.h"
@ -35,6 +36,7 @@
#include "nsHTMLFormControlAccessible.h"
#include "nsHTMLLinkAccessible.h"
#include "nsIURI.h"
#include "nsIDocShell.h"
#include "nsIDocShellTreeItem.h"
#include "nsIXULDocument.h"
#include "nsIDOMDocument.h"
@ -126,6 +128,11 @@ NS_IMETHODIMP nsRootAccessible::GetAccRole(PRUint32 *aAccRole)
return NS_ERROR_FAILURE;
}
/*
// Commenting this out for now.
// It was requested that we always use pane objects instead of client objects.
// However, it might be asked that we put client objects back.
nsCOMPtr<nsIPresContext> context;
shell->GetPresContext(getter_AddRefs(context));
nsCOMPtr<nsISupports> container;
@ -143,9 +150,18 @@ NS_IMETHODIMP nsRootAccessible::GetAccRole(PRUint32 *aAccRole)
}
*aAccRole = ROLE_CLIENT;
*/
*aAccRole = ROLE_PANE;
return NS_OK;
}
NS_IMETHODIMP nsRootAccessible::GetAccState(PRUint32 *aAccState)
{
return nsDocAccessibleMixin::GetAccState(aAccState);
}
NS_IMETHODIMP nsRootAccessible::GetAccValue(nsAWritableString& aAccValue)
{
return GetURL(aAccValue);
@ -430,3 +446,35 @@ NS_IMETHODIMP nsDocAccessibleMixin::GetDocument(nsIDocument **doc)
return NS_ERROR_FAILURE;
}
NS_IMETHODIMP nsDocAccessibleMixin::GetAccState(PRUint32 *aAccState)
{
// Screen readers need to know when the document is finished loading (STATE_BUSY flag)
// We do it this way, rather than via nsIWebProgressListener, because
// if accessibility was turned on after a document already finished loading,
// we would get no state changes from nsIWebProgressListener.
// The GetBusyFlags method, however, always has the current busy state information for us.
*aAccState = 0;
if (mDocument) {
nsCOMPtr<nsIPresShell> presShell;
mDocument->GetShellAt(0, getter_AddRefs(presShell));
if (presShell) {
nsCOMPtr<nsIPresContext> context;
presShell->GetPresContext(getter_AddRefs(context));
if (context) {
nsCOMPtr<nsISupports> container;
context->GetContainer(getter_AddRefs(container));
if (container) {
nsCOMPtr<nsIDocShell> docShell(do_QueryInterface(container));
if (docShell) {
PRUint32 busyFlags;
docShell->GetBusyFlags(&busyFlags);
if (busyFlags != nsIDocShell::BUSY_FLAGS_NONE)
*aAccState = nsIAccessible::STATE_BUSY;
}
}
}
}
}
return NS_OK;
}

View File

@ -40,6 +40,8 @@ class nsDocAccessibleMixin
NS_DECL_NSIACCESSIBLEDOCUMENT
NS_IMETHOD GetAccState(PRUint32 *aAccState);
protected:
nsCOMPtr<nsIDocument> mDocument;
};
@ -63,6 +65,7 @@ class nsRootAccessible : public nsAccessible,
NS_IMETHOD GetAccValue(nsAWritableString& aAccValue);
NS_IMETHOD GetAccParent(nsIAccessible * *aAccParent);
NS_IMETHOD GetAccRole(PRUint32 *aAccRole);
NS_IMETHOD GetAccState(PRUint32 *aAccState);
// ----- nsIAccessibleEventReceiver -------------------