bug 100772 bug 98777 accessible support for XUL
Description, Label, Button r=aaronl sr=hyatt
This commit is contained in:
Родитель
5d7331d24f
Коммит
a000eb321f
|
@ -42,7 +42,9 @@ interface nsIAccessibilityService : nsISupports
|
|||
nsIAccessible createHTMLRadioButtonAccessible(in nsISupports aFrame);
|
||||
nsIAccessible createHTMLButtonAccessible(in nsISupports aFrame);
|
||||
nsIAccessible createHTML4ButtonAccessible(in nsISupports aFrame);
|
||||
nsIAccessible createXULButtonAccessible(in nsIDOMNode aNode);
|
||||
nsIAccessible createHTMLTextAccessible(in nsISupports aFrame);
|
||||
nsIAccessible createXULTextAccessible(in nsIDOMNode aNode);
|
||||
nsIAccessible createXULImageAccessible(in nsIDOMNode aNode);
|
||||
nsIAccessible createHTMLImageAccessible(in nsISupports aFrame);
|
||||
nsIAccessible createHTMLAreaAccessible(in nsIWeakReference aPresShell, in nsIDOMNode aDOMNode, in nsIAccessible aAccParent);
|
||||
|
|
|
@ -198,6 +198,7 @@ NS_IMETHODIMP nsAccessibilityService::CreateXULCheckboxAccessible(nsIDOMNode *aN
|
|||
nsCOMPtr<nsIWeakReference> weakShell;
|
||||
GetShellFromNode(aNode, getter_AddRefs(weakShell));
|
||||
|
||||
// reusing the HTML accessible widget and enhancing for XUL
|
||||
*_retval = new nsHTMLCheckboxAccessible(aNode, weakShell);
|
||||
if (! *_retval)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
@ -260,6 +261,20 @@ NS_IMETHODIMP nsAccessibilityService::CreateHTML4ButtonAccessible(nsISupports *a
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsAccessibilityService::CreateXULButtonAccessible(nsIDOMNode *aNode, nsIAccessible **_retval)
|
||||
{
|
||||
nsCOMPtr<nsIWeakReference> weakShell;
|
||||
GetShellFromNode(aNode, getter_AddRefs(weakShell));
|
||||
|
||||
// reusing the HTML accessible widget and enhancing for XUL
|
||||
*_retval = new nsHTML4ButtonAccessible(aNode, weakShell);
|
||||
if (! *_retval)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
NS_ADDREF(*_retval);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* nsIAccessible createHTMLTextAccessible (in nsISupports aPresShell, in nsISupports aFrame); */
|
||||
NS_IMETHODIMP nsAccessibilityService::CreateHTMLTextAccessible(nsISupports *aFrame, nsIAccessible **_retval)
|
||||
{
|
||||
|
@ -278,6 +293,19 @@ NS_IMETHODIMP nsAccessibilityService::CreateHTMLTextAccessible(nsISupports *aFra
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsAccessibilityService::CreateXULTextAccessible(nsIDOMNode *aNode, nsIAccessible **_retval)
|
||||
{
|
||||
nsCOMPtr<nsIWeakReference> weakShell;
|
||||
GetShellFromNode(aNode, getter_AddRefs(weakShell));
|
||||
|
||||
// reusing the HTML accessible widget and enhancing for XUL
|
||||
*_retval = new nsHTMLTextAccessible(aNode, weakShell);
|
||||
if (! *_retval)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
NS_ADDREF(*_retval);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* nsIAccessible createHTMLTableAccessible (in nsISupports aPresShell, in nsISupports aFrame); */
|
||||
NS_IMETHODIMP nsAccessibilityService::CreateHTMLTableAccessible(nsISupports *aFrame, nsIAccessible **_retval)
|
||||
|
|
|
@ -51,6 +51,7 @@
|
|||
#include "nsIDOMHTMLFormElement.h"
|
||||
#include "nsISelectionController.h"
|
||||
#include "nsIDOMXULCheckboxElement.h"
|
||||
#include "nsIDOMXULButtonElement.h"
|
||||
|
||||
nsHTMLFormControlAccessible::nsHTMLFormControlAccessible(nsIDOMNode* aNode, nsIWeakReference* aShell):
|
||||
nsLeafAccessible(aNode, aShell)
|
||||
|
@ -394,9 +395,22 @@ NS_IMETHODIMP nsHTML4ButtonAccessible::GetAccActionName(PRUint8 index, nsAWritab
|
|||
NS_IMETHODIMP nsHTML4ButtonAccessible::AccDoAction(PRUint8 index)
|
||||
{
|
||||
if (index == 0) {
|
||||
nsCOMPtr<nsIDOMHTMLInputElement> element(do_QueryInterface(mDOMNode));
|
||||
element->Click();
|
||||
return NS_OK;
|
||||
nsCOMPtr<nsIDOMHTMLInputElement> inputElement(do_QueryInterface(mDOMNode));
|
||||
if ( inputElement )
|
||||
{
|
||||
inputElement->Click();
|
||||
return NS_OK;
|
||||
}
|
||||
else
|
||||
{
|
||||
nsCOMPtr<nsIDOMXULButtonElement> buttonElement(do_QueryInterface(mDOMNode));
|
||||
if ( buttonElement )
|
||||
{
|
||||
buttonElement->DoCommand();
|
||||
return NS_OK;
|
||||
}
|
||||
}
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
}
|
||||
|
@ -420,6 +434,11 @@ NS_IMETHODIMP nsHTML4ButtonAccessible::GetAccState(PRUint32 *_retval)
|
|||
/* wstring getAccName (); */
|
||||
NS_IMETHODIMP nsHTML4ButtonAccessible::GetAccName(nsAWritableString& _retval)
|
||||
{
|
||||
nsCOMPtr<nsIDOMXULButtonElement> buttonElement(do_QueryInterface(mDOMNode));
|
||||
if ( buttonElement ) {
|
||||
return buttonElement->GetLabel(_retval);
|
||||
}
|
||||
|
||||
nsresult rv = NS_ERROR_FAILURE;
|
||||
nsCOMPtr<nsIContent> content(do_QueryInterface(mDOMNode));
|
||||
|
||||
|
|
|
@ -46,6 +46,8 @@
|
|||
#include "nsISelectionController.h"
|
||||
#include "nsIPresContext.h"
|
||||
#include "nsReadableUtils.h"
|
||||
#include "nsIDOMXULDescriptionElement.h"
|
||||
#include "nsIDOMXULLabelElement.h"
|
||||
|
||||
nsHTMLTextAccessible::nsHTMLTextAccessible(nsIDOMNode* aDomNode, nsIWeakReference* aShell):
|
||||
nsLinkableAccessible(aDomNode, aShell)
|
||||
|
@ -55,8 +57,17 @@ nsLinkableAccessible(aDomNode, aShell)
|
|||
/* wstring getAccName (); */
|
||||
NS_IMETHODIMP nsHTMLTextAccessible::GetAccName(nsAWritableString& _retval)
|
||||
{
|
||||
|
||||
return mDOMNode->GetNodeValue(_retval);
|
||||
// handles descriptions and label XUL elements
|
||||
nsCOMPtr<nsIDOMXULDescriptionElement> descriptionElement(do_QueryInterface(mDOMNode));
|
||||
if (descriptionElement) {
|
||||
nsCOMPtr<nsIContent> content(do_QueryInterface(mDOMNode));
|
||||
return AppendFlatStringFromSubtree(content, &_retval);
|
||||
}
|
||||
// HTML elements
|
||||
else {
|
||||
return mDOMNode->GetNodeValue(_retval);
|
||||
}
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
/* unsigned long getAccRole (); */
|
||||
|
|
|
@ -198,6 +198,7 @@ NS_IMETHODIMP nsAccessibilityService::CreateXULCheckboxAccessible(nsIDOMNode *aN
|
|||
nsCOMPtr<nsIWeakReference> weakShell;
|
||||
GetShellFromNode(aNode, getter_AddRefs(weakShell));
|
||||
|
||||
// reusing the HTML accessible widget and enhancing for XUL
|
||||
*_retval = new nsHTMLCheckboxAccessible(aNode, weakShell);
|
||||
if (! *_retval)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
@ -260,6 +261,20 @@ NS_IMETHODIMP nsAccessibilityService::CreateHTML4ButtonAccessible(nsISupports *a
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsAccessibilityService::CreateXULButtonAccessible(nsIDOMNode *aNode, nsIAccessible **_retval)
|
||||
{
|
||||
nsCOMPtr<nsIWeakReference> weakShell;
|
||||
GetShellFromNode(aNode, getter_AddRefs(weakShell));
|
||||
|
||||
// reusing the HTML accessible widget and enhancing for XUL
|
||||
*_retval = new nsHTML4ButtonAccessible(aNode, weakShell);
|
||||
if (! *_retval)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
NS_ADDREF(*_retval);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* nsIAccessible createHTMLTextAccessible (in nsISupports aPresShell, in nsISupports aFrame); */
|
||||
NS_IMETHODIMP nsAccessibilityService::CreateHTMLTextAccessible(nsISupports *aFrame, nsIAccessible **_retval)
|
||||
{
|
||||
|
@ -278,6 +293,19 @@ NS_IMETHODIMP nsAccessibilityService::CreateHTMLTextAccessible(nsISupports *aFra
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsAccessibilityService::CreateXULTextAccessible(nsIDOMNode *aNode, nsIAccessible **_retval)
|
||||
{
|
||||
nsCOMPtr<nsIWeakReference> weakShell;
|
||||
GetShellFromNode(aNode, getter_AddRefs(weakShell));
|
||||
|
||||
// reusing the HTML accessible widget and enhancing for XUL
|
||||
*_retval = new nsHTMLTextAccessible(aNode, weakShell);
|
||||
if (! *_retval)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
NS_ADDREF(*_retval);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* nsIAccessible createHTMLTableAccessible (in nsISupports aPresShell, in nsISupports aFrame); */
|
||||
NS_IMETHODIMP nsAccessibilityService::CreateHTMLTableAccessible(nsISupports *aFrame, nsIAccessible **_retval)
|
||||
|
|
|
@ -51,6 +51,7 @@
|
|||
#include "nsIDOMHTMLFormElement.h"
|
||||
#include "nsISelectionController.h"
|
||||
#include "nsIDOMXULCheckboxElement.h"
|
||||
#include "nsIDOMXULButtonElement.h"
|
||||
|
||||
nsHTMLFormControlAccessible::nsHTMLFormControlAccessible(nsIDOMNode* aNode, nsIWeakReference* aShell):
|
||||
nsLeafAccessible(aNode, aShell)
|
||||
|
@ -394,9 +395,22 @@ NS_IMETHODIMP nsHTML4ButtonAccessible::GetAccActionName(PRUint8 index, nsAWritab
|
|||
NS_IMETHODIMP nsHTML4ButtonAccessible::AccDoAction(PRUint8 index)
|
||||
{
|
||||
if (index == 0) {
|
||||
nsCOMPtr<nsIDOMHTMLInputElement> element(do_QueryInterface(mDOMNode));
|
||||
element->Click();
|
||||
return NS_OK;
|
||||
nsCOMPtr<nsIDOMHTMLInputElement> inputElement(do_QueryInterface(mDOMNode));
|
||||
if ( inputElement )
|
||||
{
|
||||
inputElement->Click();
|
||||
return NS_OK;
|
||||
}
|
||||
else
|
||||
{
|
||||
nsCOMPtr<nsIDOMXULButtonElement> buttonElement(do_QueryInterface(mDOMNode));
|
||||
if ( buttonElement )
|
||||
{
|
||||
buttonElement->DoCommand();
|
||||
return NS_OK;
|
||||
}
|
||||
}
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
}
|
||||
|
@ -420,6 +434,11 @@ NS_IMETHODIMP nsHTML4ButtonAccessible::GetAccState(PRUint32 *_retval)
|
|||
/* wstring getAccName (); */
|
||||
NS_IMETHODIMP nsHTML4ButtonAccessible::GetAccName(nsAWritableString& _retval)
|
||||
{
|
||||
nsCOMPtr<nsIDOMXULButtonElement> buttonElement(do_QueryInterface(mDOMNode));
|
||||
if ( buttonElement ) {
|
||||
return buttonElement->GetLabel(_retval);
|
||||
}
|
||||
|
||||
nsresult rv = NS_ERROR_FAILURE;
|
||||
nsCOMPtr<nsIContent> content(do_QueryInterface(mDOMNode));
|
||||
|
||||
|
|
|
@ -46,6 +46,8 @@
|
|||
#include "nsISelectionController.h"
|
||||
#include "nsIPresContext.h"
|
||||
#include "nsReadableUtils.h"
|
||||
#include "nsIDOMXULDescriptionElement.h"
|
||||
#include "nsIDOMXULLabelElement.h"
|
||||
|
||||
nsHTMLTextAccessible::nsHTMLTextAccessible(nsIDOMNode* aDomNode, nsIWeakReference* aShell):
|
||||
nsLinkableAccessible(aDomNode, aShell)
|
||||
|
@ -55,8 +57,17 @@ nsLinkableAccessible(aDomNode, aShell)
|
|||
/* wstring getAccName (); */
|
||||
NS_IMETHODIMP nsHTMLTextAccessible::GetAccName(nsAWritableString& _retval)
|
||||
{
|
||||
|
||||
return mDOMNode->GetNodeValue(_retval);
|
||||
// handles descriptions and label XUL elements
|
||||
nsCOMPtr<nsIDOMXULDescriptionElement> descriptionElement(do_QueryInterface(mDOMNode));
|
||||
if (descriptionElement) {
|
||||
nsCOMPtr<nsIContent> content(do_QueryInterface(mDOMNode));
|
||||
return AppendFlatStringFromSubtree(content, &_retval);
|
||||
}
|
||||
// HTML elements
|
||||
else {
|
||||
return mDOMNode->GetNodeValue(_retval);
|
||||
}
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
/* unsigned long getAccRole (); */
|
||||
|
|
|
@ -37,6 +37,9 @@ XPIDLSRCS = \
|
|||
nsIDOMXULControlElement.idl \
|
||||
nsIDOMXULLabeledControlEl.idl \
|
||||
nsIDOMXULCheckboxElement.idl \
|
||||
nsIDOMXULButtonElement.idl \
|
||||
nsIDOMXULDescriptionElement.idl \
|
||||
nsIDOMXULLabelElement.idl \
|
||||
nsIDOMXULImageElement.idl \
|
||||
$(NULL)
|
||||
|
||||
|
|
|
@ -33,6 +33,9 @@ XPIDLSRCS = \
|
|||
.\nsIDOMXULControlElement.idl \
|
||||
.\nsIDOMXULLabeledControlEl.idl \
|
||||
.\nsIDOMXULCheckboxElement.idl \
|
||||
.\nsIDOMXULButtonElement.idl \
|
||||
.\nsIDOMXULDescriptionElement.idl \
|
||||
.\nsIDOMXULLabelElement.idl \
|
||||
.\nsIDOMXULImageElement.idl \
|
||||
$(NULL)
|
||||
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
xmlns:xul="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
|
||||
|
||||
<binding id="button-base" extends="chrome://global/content/bindings/general.xml#basetext">
|
||||
<implementation>
|
||||
<implementation implements="nsIDOMXULButtonElement, nsIAccessibleProvider">
|
||||
<constructor>
|
||||
<![CDATA[
|
||||
var i;
|
||||
|
@ -21,6 +21,14 @@
|
|||
}
|
||||
]]>
|
||||
</constructor>
|
||||
<property name="accessible">
|
||||
<getter>
|
||||
<![CDATA[
|
||||
var accService = Components.classes["@mozilla.org/accessibilityService;1"].getService(Components.interfaces.nsIAccessibilityService);
|
||||
return (accService? accService.createXULButtonAccessible(this): null);
|
||||
]]>
|
||||
</getter>
|
||||
</property>
|
||||
</implementation>
|
||||
</binding>
|
||||
|
||||
|
|
|
@ -5,8 +5,17 @@
|
|||
xmlns:html="http://www.w3.org/1999/xhtml"
|
||||
xmlns:xul="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
|
||||
|
||||
<!-- bound to <description>s -->
|
||||
<binding id="text-base">
|
||||
<implementation>
|
||||
<implementation implements="nsIDOMXULDescriptionElement, nsIAccessibleProvider">
|
||||
<property name="accessible">
|
||||
<getter>
|
||||
<![CDATA[
|
||||
var accService = Components.classes["@mozilla.org/accessibilityService;1"].getService(Components.interfaces.nsIAccessibilityService);
|
||||
return (accService? accService.createXULTextAccessible(this): null);
|
||||
]]>
|
||||
</getter>
|
||||
</property>
|
||||
<property name="disabled" onget="if (this.getAttribute('disabled') == 'true') return true; return false;"
|
||||
onset="if (val) this.setAttribute('disabled', 'true');
|
||||
else this.removeAttribute('disabled');
|
||||
|
@ -19,7 +28,7 @@
|
|||
</binding>
|
||||
|
||||
<binding id="text-label" extends="chrome://global/content/bindings/text.xml#text-base">
|
||||
<implementation>
|
||||
<implementation implements="nsIDOMXULLabelElement">
|
||||
<property name="accessKey" onget="return this.getAttribute('accesskey');"
|
||||
onset="this.setAttribute('accesskey', val); return val;"/>
|
||||
<property name="control" onget="return this.getAttribute('control');"
|
||||
|
|
Загрузка…
Ссылка в новой задаче