mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-02-27 21:00:50 +00:00
Active Accessibility: support HTML tags <fieldset> and <legend>. r=jgaunt, sr=hewitt
This commit is contained in:
parent
4af6c40dc3
commit
37d3cec004
@ -43,6 +43,7 @@ interface nsIAccessibilityService : nsISupports
|
||||
nsIAccessible createHTMLButtonAccessible(in nsISupports aFrame);
|
||||
nsIAccessible createHTMLCheckboxAccessible(in nsISupports aFrame);
|
||||
nsIAccessible createHTMLComboboxAccessible(in nsIDOMNode aNode, in nsISupports aPresShell);
|
||||
nsIAccessible createHTMLGroupboxAccessible(in nsISupports aFrame);
|
||||
nsIAccessible createHTMLImageAccessible(in nsISupports aFrame);
|
||||
nsIAccessible createHTMLListboxAccessible(in nsIDOMNode aNode, in nsISupports aPresShell);
|
||||
nsIAccessible createHTMLRadioButtonAccessible(in nsISupports aFrame);
|
||||
|
@ -57,6 +57,7 @@
|
||||
#include "nsIDOMDocument.h"
|
||||
#include "nsIDOMHTMLAreaElement.h"
|
||||
#include "nsIDOMHTMLOptionElement.h"
|
||||
#include "nsIDOMHTMLLegendElement.h"
|
||||
#include "nsIDOMNode.h"
|
||||
#include "nsIDOMXULCheckboxElement.h"
|
||||
#include "nsIFrame.h"
|
||||
@ -464,6 +465,24 @@ nsAccessibilityService::CreateHTMLImageAccessible(nsISupports *aFrame, nsIAccess
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsAccessibilityService::CreateHTMLGroupboxAccessible(nsISupports *aFrame, nsIAccessible **_retval)
|
||||
{
|
||||
nsIFrame* frame;
|
||||
nsCOMPtr<nsIDOMNode> node;
|
||||
nsCOMPtr<nsIWeakReference> weakShell;
|
||||
nsresult rv = GetInfo(aFrame, &frame, getter_AddRefs(weakShell), getter_AddRefs(node));
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
|
||||
*_retval = new nsHTMLGroupboxAccessible(node, weakShell);
|
||||
if (! *_retval)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
NS_ADDREF(*_retval);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsAccessibilityService::CreateHTMLListboxAccessible(nsIDOMNode* aDOMNode, nsISupports* aPresContext, nsIAccessible **_retval)
|
||||
{
|
||||
@ -582,6 +601,11 @@ nsAccessibilityService::CreateHTMLTextAccessible(nsISupports *aFrame, nsIAccessi
|
||||
if (theChar == NBSP)
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
nsCOMPtr<nsIDOMNode> parentNode;
|
||||
node->GetParentNode(getter_AddRefs(parentNode));
|
||||
nsCOMPtr<nsIDOMHTMLLegendElement> legend(do_QueryInterface(parentNode));
|
||||
if (legend) // Expose <legend> as the name in a groupbox, not as a ROLE_TEXT accessible
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
*_retval = new nsHTMLTextAccessible(node, weakShell);
|
||||
|
@ -374,3 +374,46 @@ NS_IMETHODIMP nsHTMLTextFieldAccessible::GetAccState(PRUint32 *_retval)
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
// --- groupbox -----
|
||||
|
||||
/*
|
||||
* The HTML for this is <fieldset> <legend>box-title</legend> form elements </fieldset>
|
||||
*/
|
||||
|
||||
nsHTMLGroupboxAccessible::nsHTMLGroupboxAccessible(nsIDOMNode* aNode, nsIWeakReference* aShell):
|
||||
nsAccessible(aNode, aShell)
|
||||
{
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsHTMLGroupboxAccessible::GetAccRole(PRUint32 *_retval)
|
||||
{
|
||||
*_retval = ROLE_GROUPING;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsHTMLGroupboxAccessible::GetAccState(PRUint32 *_retval)
|
||||
{
|
||||
// Groupbox doesn't support any states!
|
||||
*_retval = 0;
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsHTMLGroupboxAccessible::GetAccName(nsAWritableString& _retval)
|
||||
{
|
||||
_retval.Assign(NS_LITERAL_STRING("")); // Default name is blank
|
||||
|
||||
nsCOMPtr<nsIDOMElement> element(do_QueryInterface(mDOMNode));
|
||||
if (element) {
|
||||
nsCOMPtr<nsIDOMNodeList> legends;
|
||||
element->GetElementsByTagName(NS_LITERAL_STRING("legend"), getter_AddRefs(legends));
|
||||
if (legends) {
|
||||
nsCOMPtr<nsIDOMNode> legendNode;
|
||||
legends->Item(0, getter_AddRefs(legendNode));
|
||||
nsCOMPtr<nsIContent> legendContent(do_QueryInterface(legendNode));
|
||||
return AppendFlatStringFromSubtree(legendContent, &_retval);
|
||||
}
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
@ -100,4 +100,13 @@ public:
|
||||
NS_IMETHOD GetAccState(PRUint32 *_retval);
|
||||
};
|
||||
|
||||
class nsHTMLGroupboxAccessible : public nsAccessible
|
||||
{
|
||||
public:
|
||||
nsHTMLGroupboxAccessible(nsIDOMNode* aNode, nsIWeakReference* aShell);
|
||||
NS_IMETHOD GetAccRole(PRUint32 *_retval);
|
||||
NS_IMETHOD GetAccState(PRUint32 *_retval);
|
||||
NS_IMETHOD GetAccName(nsAWritableString& _retval);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@ -59,6 +59,10 @@
|
||||
#include "nsStyleUtil.h"
|
||||
#include "nsFont.h"
|
||||
#include "nsCOMPtr.h"
|
||||
#ifdef ACCESSIBILITY
|
||||
#include "nsIAccessibilityService.h"
|
||||
#endif
|
||||
#include "nsIServiceManager.h"
|
||||
|
||||
class nsLegendFrame;
|
||||
|
||||
@ -105,6 +109,8 @@ public:
|
||||
nsFramePaintLayer aWhichLayer,
|
||||
nsIFrame** aFrame);
|
||||
|
||||
NS_IMETHOD GetAccessible(nsIAccessible** aAccessible);
|
||||
|
||||
#ifdef DEBUG
|
||||
NS_IMETHOD GetFrameName(nsAString& aResult) const {
|
||||
return MakeFrameName(NS_LITERAL_STRING("FieldSet"), aResult);
|
||||
@ -684,3 +690,16 @@ nsFieldSetFrame::GetFrameForPoint(nsIPresContext* aPresContext,
|
||||
// this should act like a block, so we need to override
|
||||
return GetFrameForPointUsing(aPresContext, aPoint, nsnull, aWhichLayer, (aWhichLayer == NS_FRAME_PAINT_LAYER_BACKGROUND), aFrame);
|
||||
}
|
||||
|
||||
#ifdef ACCESSIBILITY
|
||||
NS_IMETHODIMP nsFieldSetFrame::GetAccessible(nsIAccessible** aAccessible)
|
||||
{
|
||||
nsCOMPtr<nsIAccessibilityService> accService = do_GetService("@mozilla.org/accessibilityService;1");
|
||||
|
||||
if (accService) {
|
||||
return accService->CreateHTMLGroupboxAccessible(NS_STATIC_CAST(nsIFrame*, this), aAccessible);
|
||||
}
|
||||
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
#endif
|
||||
|
@ -59,6 +59,10 @@
|
||||
#include "nsStyleUtil.h"
|
||||
#include "nsFont.h"
|
||||
#include "nsCOMPtr.h"
|
||||
#ifdef ACCESSIBILITY
|
||||
#include "nsIAccessibilityService.h"
|
||||
#endif
|
||||
#include "nsIServiceManager.h"
|
||||
|
||||
class nsLegendFrame;
|
||||
|
||||
@ -105,6 +109,8 @@ public:
|
||||
nsFramePaintLayer aWhichLayer,
|
||||
nsIFrame** aFrame);
|
||||
|
||||
NS_IMETHOD GetAccessible(nsIAccessible** aAccessible);
|
||||
|
||||
#ifdef DEBUG
|
||||
NS_IMETHOD GetFrameName(nsAString& aResult) const {
|
||||
return MakeFrameName(NS_LITERAL_STRING("FieldSet"), aResult);
|
||||
@ -684,3 +690,16 @@ nsFieldSetFrame::GetFrameForPoint(nsIPresContext* aPresContext,
|
||||
// this should act like a block, so we need to override
|
||||
return GetFrameForPointUsing(aPresContext, aPoint, nsnull, aWhichLayer, (aWhichLayer == NS_FRAME_PAINT_LAYER_BACKGROUND), aFrame);
|
||||
}
|
||||
|
||||
#ifdef ACCESSIBILITY
|
||||
NS_IMETHODIMP nsFieldSetFrame::GetAccessible(nsIAccessible** aAccessible)
|
||||
{
|
||||
nsCOMPtr<nsIAccessibilityService> accService = do_GetService("@mozilla.org/accessibilityService;1");
|
||||
|
||||
if (accService) {
|
||||
return accService->CreateHTMLGroupboxAccessible(NS_STATIC_CAST(nsIFrame*, this), aAccessible);
|
||||
}
|
||||
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
#endif
|
||||
|
Loading…
x
Reference in New Issue
Block a user