diff --git a/accessible/public/nsIAccessibilityService.idl b/accessible/public/nsIAccessibilityService.idl index 71775058be86..0c3f717f788f 100644 --- a/accessible/public/nsIAccessibilityService.idl +++ b/accessible/public/nsIAccessibilityService.idl @@ -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); diff --git a/accessible/src/base/nsAccessibilityService.cpp b/accessible/src/base/nsAccessibilityService.cpp index 62641508e937..70ddf6050549 100644 --- a/accessible/src/base/nsAccessibilityService.cpp +++ b/accessible/src/base/nsAccessibilityService.cpp @@ -198,6 +198,7 @@ NS_IMETHODIMP nsAccessibilityService::CreateXULCheckboxAccessible(nsIDOMNode *aN nsCOMPtr 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 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 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) diff --git a/accessible/src/html/nsHTMLFormControlAccessible.cpp b/accessible/src/html/nsHTMLFormControlAccessible.cpp index ff0055b7fbb9..7703155efe2e 100644 --- a/accessible/src/html/nsHTMLFormControlAccessible.cpp +++ b/accessible/src/html/nsHTMLFormControlAccessible.cpp @@ -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 element(do_QueryInterface(mDOMNode)); - element->Click(); - return NS_OK; + nsCOMPtr inputElement(do_QueryInterface(mDOMNode)); + if ( inputElement ) + { + inputElement->Click(); + return NS_OK; + } + else + { + nsCOMPtr 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 buttonElement(do_QueryInterface(mDOMNode)); + if ( buttonElement ) { + return buttonElement->GetLabel(_retval); + } + nsresult rv = NS_ERROR_FAILURE; nsCOMPtr content(do_QueryInterface(mDOMNode)); diff --git a/accessible/src/html/nsHTMLTextAccessible.cpp b/accessible/src/html/nsHTMLTextAccessible.cpp index 8af366b4e9b1..8d9acc7d17f8 100644 --- a/accessible/src/html/nsHTMLTextAccessible.cpp +++ b/accessible/src/html/nsHTMLTextAccessible.cpp @@ -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 descriptionElement(do_QueryInterface(mDOMNode)); + if (descriptionElement) { + nsCOMPtr content(do_QueryInterface(mDOMNode)); + return AppendFlatStringFromSubtree(content, &_retval); + } + // HTML elements + else { + return mDOMNode->GetNodeValue(_retval); + } + return NS_ERROR_FAILURE; } /* unsigned long getAccRole (); */ diff --git a/accessible/src/nsAccessibilityService.cpp b/accessible/src/nsAccessibilityService.cpp index 62641508e937..70ddf6050549 100644 --- a/accessible/src/nsAccessibilityService.cpp +++ b/accessible/src/nsAccessibilityService.cpp @@ -198,6 +198,7 @@ NS_IMETHODIMP nsAccessibilityService::CreateXULCheckboxAccessible(nsIDOMNode *aN nsCOMPtr 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 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 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) diff --git a/accessible/src/nsHTMLFormControlAccessible.cpp b/accessible/src/nsHTMLFormControlAccessible.cpp index ff0055b7fbb9..7703155efe2e 100644 --- a/accessible/src/nsHTMLFormControlAccessible.cpp +++ b/accessible/src/nsHTMLFormControlAccessible.cpp @@ -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 element(do_QueryInterface(mDOMNode)); - element->Click(); - return NS_OK; + nsCOMPtr inputElement(do_QueryInterface(mDOMNode)); + if ( inputElement ) + { + inputElement->Click(); + return NS_OK; + } + else + { + nsCOMPtr 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 buttonElement(do_QueryInterface(mDOMNode)); + if ( buttonElement ) { + return buttonElement->GetLabel(_retval); + } + nsresult rv = NS_ERROR_FAILURE; nsCOMPtr content(do_QueryInterface(mDOMNode)); diff --git a/accessible/src/nsHTMLTextAccessible.cpp b/accessible/src/nsHTMLTextAccessible.cpp index 8af366b4e9b1..8d9acc7d17f8 100644 --- a/accessible/src/nsHTMLTextAccessible.cpp +++ b/accessible/src/nsHTMLTextAccessible.cpp @@ -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 descriptionElement(do_QueryInterface(mDOMNode)); + if (descriptionElement) { + nsCOMPtr content(do_QueryInterface(mDOMNode)); + return AppendFlatStringFromSubtree(content, &_retval); + } + // HTML elements + else { + return mDOMNode->GetNodeValue(_retval); + } + return NS_ERROR_FAILURE; } /* unsigned long getAccRole (); */ diff --git a/dom/public/idl/xul/Makefile.in b/dom/public/idl/xul/Makefile.in index 29e4203029d3..e755af7ecdd6 100644 --- a/dom/public/idl/xul/Makefile.in +++ b/dom/public/idl/xul/Makefile.in @@ -37,6 +37,9 @@ XPIDLSRCS = \ nsIDOMXULControlElement.idl \ nsIDOMXULLabeledControlEl.idl \ nsIDOMXULCheckboxElement.idl \ + nsIDOMXULButtonElement.idl \ + nsIDOMXULDescriptionElement.idl \ + nsIDOMXULLabelElement.idl \ nsIDOMXULImageElement.idl \ $(NULL) diff --git a/dom/public/idl/xul/makefile.win b/dom/public/idl/xul/makefile.win index 08a69f131299..073277c6df01 100644 --- a/dom/public/idl/xul/makefile.win +++ b/dom/public/idl/xul/makefile.win @@ -33,6 +33,9 @@ XPIDLSRCS = \ .\nsIDOMXULControlElement.idl \ .\nsIDOMXULLabeledControlEl.idl \ .\nsIDOMXULCheckboxElement.idl \ + .\nsIDOMXULButtonElement.idl \ + .\nsIDOMXULDescriptionElement.idl \ + .\nsIDOMXULLabelElement.idl \ .\nsIDOMXULImageElement.idl \ $(NULL) diff --git a/xpfe/global/resources/content/bindings/button.xml b/xpfe/global/resources/content/bindings/button.xml index 692964866d50..764b99093094 100644 --- a/xpfe/global/resources/content/bindings/button.xml +++ b/xpfe/global/resources/content/bindings/button.xml @@ -5,7 +5,7 @@ xmlns:xul="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"> - + + + + + + diff --git a/xpfe/global/resources/content/bindings/text.xml b/xpfe/global/resources/content/bindings/text.xml index df7922272e63..8637390286b9 100644 --- a/xpfe/global/resources/content/bindings/text.xml +++ b/xpfe/global/resources/content/bindings/text.xml @@ -5,8 +5,17 @@ xmlns:html="http://www.w3.org/1999/xhtml" xmlns:xul="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"> + - + + + + + + - +