Bug 82207. XUL Checkbox working with MSAA. r=jgaunt, sr=hyatt

This commit is contained in:
aaronl%netscape.com 2001-09-08 16:22:09 +00:00
Родитель 8271ce3a1d
Коммит 70d5ec6da2
27 изменённых файлов: 508 добавлений и 61 удалений

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

@ -36,6 +36,7 @@ XPIDLSRCS = \
nsIAccessibleEventReceiver.idl \
nsIAccessibleEventListener.idl \
nsIAccessibleSelectable.idl \
nsIAccessibleProvider.idl \
$(NULL)
EXPORTS = \

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

@ -30,6 +30,7 @@ XPIDLSRCS = \
.\nsIAccessibleEventReceiver.idl \
.\nsIAccessibleEventListener.idl \
.\nsIAccessibleSelectable.idl \
.\nsIAccessibleProvider.idl \
$(NULL)
EXPORTS = \

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

@ -38,6 +38,7 @@ interface nsIAccessibilityService : nsISupports
nsIAccessible createHTMLListboxAccessible(in nsIDOMNode aNode, in nsISupports aPresShell);
nsIAccessible createHTMLSelectOptionAccessible(in nsIDOMNode aNode, in nsIAccessible aAccParent, in nsISupports aPresShell);
nsIAccessible createHTMLCheckboxAccessible(in nsISupports aFrame);
nsIAccessible createXULCheckboxAccessible(in nsIDOMNode aNode);
nsIAccessible createHTMLRadioButtonAccessible(in nsISupports aFrame);
nsIAccessible createHTMLButtonAccessible(in nsISupports aFrame);
nsIAccessible createHTML4ButtonAccessible(in nsISupports aFrame);

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

@ -0,0 +1,33 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Mozilla Public
* License Version 1.1 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code is the Mozilla browser.
*
* The Initial Developer of the Original Code is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1999 Netscape Communications Corporation. All
* Rights Reserved.
*
* Original Author: John Gaunt (jgaunt@netscape.com)
*
* Contributor(s):
* John Gaunt
*/
#include "nsISupports.idl"
#include "nsIAccessible.idl"
[scriptable, uuid(3f0e3eb0-1dd2-11b2-9605-be5b8e76cf4b)]
interface nsIAccessibleProvider : nsISupports
{
readonly attribute nsIAccessible accessible;
};

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

@ -45,10 +45,12 @@
#include "nsHTMLListboxAccessible.h"
#include "nsIDOMHTMLAreaElement.h"
#include "nsHTMLFormControlAccessible.h"
#include "nsIAccessibleProvider.h"
#include "nsILink.h"
#include "nsIDocShellTreeItem.h"
#include "nsIDOMDocument.h"
#include "nsIDOMHTMLOptionElement.h"
#include "nsIDOMXULCheckboxElement.h"
// IFrame
#include "nsIDocShell.h"
@ -175,6 +177,19 @@ NS_IMETHODIMP nsAccessibilityService::CreateHTMLCheckboxAccessible(nsISupports *
return NS_OK;
}
NS_IMETHODIMP nsAccessibilityService::CreateXULCheckboxAccessible(nsIDOMNode *aNode, nsIAccessible **_retval)
{
nsCOMPtr<nsIWeakReference> weakShell;
GetShellFromNode(aNode, getter_AddRefs(weakShell));
*_retval = new nsHTMLCheckboxAccessible(aNode, weakShell);
if (! *_retval)
return NS_ERROR_OUT_OF_MEMORY;
NS_ADDREF(*_retval);
return NS_OK;
}
/* nsIAccessible createHTMRadioButtonAccessible (in nsISupports aPresShell, in nsISupports aFrame); */
NS_IMETHODIMP nsAccessibilityService::CreateHTMLRadioButtonAccessible(nsISupports *aFrame, nsIAccessible **_retval)
{
@ -340,6 +355,28 @@ NS_IMETHODIMP nsAccessibilityService::CreateHTMLTextFieldAccessible(nsISupports
return NS_OK;
}
NS_IMETHODIMP nsAccessibilityService::GetShellFromNode(nsIDOMNode *aNode, nsIWeakReference **aWeakShell)
{
nsCOMPtr<nsIDOMDocument> domDoc;
aNode->GetOwnerDocument(getter_AddRefs(domDoc));
nsCOMPtr<nsIDocument> doc(do_QueryInterface(domDoc));
if (!doc)
return NS_ERROR_INVALID_ARG;
// ---- Get the pres shell ----
nsCOMPtr<nsIPresShell> shell;
doc->GetShellAt(0, getter_AddRefs(shell));
if (!shell)
return NS_ERROR_FAILURE;
nsCOMPtr<nsIWeakReference> weakRef(do_GetWeakReference(shell));
*aWeakShell = weakRef;
NS_IF_ADDREF(*aWeakShell);
return NS_OK;
}
NS_IMETHODIMP nsAccessibilityService::GetInfo(nsISupports* aFrame, nsIFrame** aRealFrame, nsIWeakReference** aShell, nsIDOMNode** aNode)
{
NS_ASSERTION(aFrame,"Error -- 1st argument (aFrame) is null!!");
@ -624,9 +661,12 @@ NS_IMETHODIMP nsAccessibilityService::GetAccessibleFor(nsIDOMNode *aNode,
nsCOMPtr<nsIAccessible> newAcc;
frame->GetAccessible(getter_AddRefs(newAcc));
// ---- Try QI'ing node to get nsIAccessible ----
if (!newAcc)
newAcc = do_QueryInterface(aNode);
// ---- Is it a XUL element? -- they impl nsIAccessibleProvider via XBL
if (!newAcc) {
nsCOMPtr<nsIAccessibleProvider> accProv(do_QueryInterface(aNode));
if (accProv)
accProv->GetAccessible(getter_AddRefs(newAcc));
}
// ---- If link, create link accessible ----
if (!newAcc) {

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

@ -51,6 +51,7 @@ public:
private:
NS_IMETHOD GetInfo(nsISupports* aFrame, nsIFrame** aRealFrame, nsIWeakReference** aShell, nsIDOMNode** aContent);
NS_IMETHOD GetShellFromNode(nsIDOMNode *aNode, nsIWeakReference **weakShell);
void GetOwnerFor(nsIPresShell *aPresShell, nsIPresShell **aOwnerShell, nsIContent **aOwnerContent);
nsIContent* FindContentForDocShell(nsIPresShell* aPresShell, nsIContent* aContent, nsIDocShell* aDocShell);

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

@ -623,6 +623,49 @@ NS_IMETHODIMP nsAccessible::GetAccState(PRUint32 *aAccState)
}
}
nsCOMPtr<nsIContent> content(do_QueryInterface(mDOMNode));
if (content) {
nsCOMPtr<nsIPresShell> shell(do_QueryReferent(mPresShell));
if (shell) {
nsIFrame *frame = nsnull;
shell->GetPrimaryFrameFor(content, &frame);
if (frame) {
/*
PRBool isVisible = PR_FALSE, isFinishedLooking = PR_FALSE;
nsCOMPtr<nsIPresContext> presContext;
shell->GetPresContext(getter_AddRefs(presContext));
nsRect twipsRect, pixelsRect;
GetAbsoluteFramePosition(presContext, frame, twipsRect, pixelsRect);
//frame->IsVisibleForPainting(presContext, presContext, PR_TRUE, &isVisible); // 3rd param = bool to check css visibility
//frame->CheckVisibility(presContext, 0,1, PR_TRUE, &isFinishedLooking, &isVisible);
if (twipsRect.y < 0)
*aAccState |= STATE_OFFSCREEN;
*/
nsSize frameSize;
frame->GetSize(frameSize);
if (frameSize.width == 0)
*aAccState |= STATE_INVISIBLE;
}
}
}
/**
* called to see if the children of the frame are visible from indexstart to index end.
* this does not change any state. returns PR_TRUE only if the indexes are valid and any of
* the children are visible. for textframes this index is the character index.
* if aStart = aEnd result will be PR_FALSE
* @param aStart start index of first child from 0-N (number of children)
* @param aEnd end index of last child from 0-N
* @param aRecurse should this frame talk to siblings to get to the contents other children?
* @param aFinished did this frame have the aEndIndex? or is there more work to do
* @param _retval return value true or false. false = range is not rendered.
*/
//NS_IMETHOD CheckVisibility(nsIPresContext* aContext, PRInt32 aStartIndex, PRInt32 aEndIndex, PRBool aRecurse, PRBool *aFinished, PRBool *_retval)=0;
return rv;
}

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

@ -25,7 +25,6 @@
#include "nsIFrame.h"
#include "nsCOMPtr.h"
#include "nsIWeakReference.h"
#include "nsISelectionController.h"
#include "nsReadableUtils.h"
#include "nsIContent.h"

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

@ -30,7 +30,6 @@
#include "nsIServiceManager.h"
#include "nsIDOMElement.h"
#include "nsIDOMHTMLAreaElement.h"
#include "nsGUIEvent.h"
// --- area -----

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

@ -29,12 +29,12 @@
#include "nsHTMLAtoms.h"
#include "nsIDOMHTMLButtonElement.h"
#include "nsReadableUtils.h"
#include "nsString.h"
#include "nsAccessible.h"
#include "nsIFrame.h"
#include "nsIDOMHTMLLabelElement.h"
#include "nsIDOMHTMLFormElement.h"
#include "nsISelectionController.h"
#include "nsIDOMXULCheckboxElement.h"
nsHTMLFormControlAccessible::nsHTMLFormControlAccessible(nsIDOMNode* aNode, nsIWeakReference* aShell):
nsLeafAccessible(aNode, aShell)
@ -117,25 +117,29 @@ NS_IMETHODIMP nsHTMLFormControlAccessible::GetAccName(nsAWritableString& _retval
NS_IMETHODIMP nsHTMLFormControlAccessible::GetAccState(PRUint32 *_retval)
{
// can be
// focusable, focused, checked, protected, unavailable
nsCOMPtr<nsIDOMHTMLInputElement> element(do_QueryInterface(mDOMNode));
// focusable, focused, protected, unavailable
nsCOMPtr<nsIDOMHTMLInputElement> htmlFormElement(do_QueryInterface(mDOMNode));
nsAccessible::GetAccState(_retval);
*_retval |= STATE_FOCUSABLE;
PRBool checked = PR_FALSE;
element->GetChecked(&checked);
if (checked) *_retval |= STATE_CHECKED;
PRBool disabled = PR_FALSE;
element->GetDisabled(&disabled);
if (htmlFormElement) {
htmlFormElement->GetDisabled(&disabled);
nsAutoString typeString;
htmlFormElement->GetType(typeString);
if (typeString.EqualsIgnoreCase("password"))
*_retval |= STATE_PROTECTED;
}
else {
nsCOMPtr<nsIDOMXULControlElement> xulFormElement(do_QueryInterface(mDOMNode));
if (xulFormElement)
xulFormElement->GetDisabled(&disabled);
}
if (disabled)
*_retval |= STATE_UNAVAILABLE;
nsAutoString typeString;
element->GetType(typeString);
if (typeString.EqualsIgnoreCase("password"))
*_retval |= STATE_PROTECTED;
else
*_retval |= STATE_FOCUSABLE;
return NS_OK;
}
@ -164,15 +168,12 @@ NS_IMETHODIMP nsHTMLCheckboxAccessible::GetAccNumActions(PRUint8 *_retval)
/* wstring getAccActionName (in PRUint8 index); */
NS_IMETHODIMP nsHTMLCheckboxAccessible::GetAccActionName(PRUint8 index, nsAWritableString& _retval)
{
if (index == 0) {
if (index == 0) { // 0 is the magic value for default action
// check or uncheck
nsCOMPtr<nsIDOMHTMLInputElement> element(do_QueryInterface(mDOMNode));
PRUint32 state;
GetAccState(&state);
PRBool checked = PR_FALSE;
if (element)
element->GetChecked(&checked);
if (checked)
if (state & STATE_CHECKED)
_retval = NS_LITERAL_STRING("uncheck");
else
_retval = NS_LITERAL_STRING("check");
@ -186,15 +187,43 @@ NS_IMETHODIMP nsHTMLCheckboxAccessible::GetAccActionName(PRUint8 index, nsAWrita
NS_IMETHODIMP nsHTMLCheckboxAccessible::AccDoAction(PRUint8 index)
{
if (index == 0) { // 0 is the magic value for default action
nsCOMPtr<nsIDOMHTMLInputElement> element(do_QueryInterface(mDOMNode));
nsCOMPtr<nsIDOMHTMLInputElement> htmlCheckboxElement(do_QueryInterface(mDOMNode));
PRBool checked = PR_FALSE;
element->GetChecked(&checked);
element->SetChecked(checked ? PR_FALSE : PR_TRUE);
if (htmlCheckboxElement) {
htmlCheckboxElement->GetChecked(&checked);
htmlCheckboxElement->SetChecked(!checked);
}
else {
nsCOMPtr<nsIDOMXULCheckboxElement> xulCheckboxElement(do_QueryInterface(mDOMNode));
if (xulCheckboxElement) {
xulCheckboxElement->GetChecked(&checked);
xulCheckboxElement->SetChecked(!checked);
}
}
return NS_OK;
}
return NS_ERROR_INVALID_ARG;
}
NS_IMETHODIMP nsHTMLCheckboxAccessible::GetAccState(PRUint32 *_retval)
{
nsHTMLFormControlAccessible::GetAccState(_retval);
PRBool checked = PR_FALSE; // Radio buttons and check boxes can be checked
nsCOMPtr<nsIDOMHTMLInputElement> htmlCheckboxElement(do_QueryInterface(mDOMNode));
if (htmlCheckboxElement)
htmlCheckboxElement->GetChecked(&checked);
else {
nsCOMPtr<nsIDOMXULCheckboxElement> xulCheckboxElement(do_QueryInterface(mDOMNode));
if (xulCheckboxElement)
xulCheckboxElement->GetChecked(&checked);
}
if (checked)
*_retval |= STATE_CHECKED;
return NS_OK;
}
//------ Radio button -------
@ -240,6 +269,28 @@ NS_IMETHODIMP nsHTMLRadioButtonAccessible::GetAccRole(PRUint32 *_retval)
return NS_OK;
}
NS_IMETHODIMP nsHTMLRadioButtonAccessible::GetAccState(PRUint32 *_retval)
{
nsHTMLFormControlAccessible::GetAccState(_retval);
PRBool checked = PR_FALSE; // Radio buttons and check boxes can be checked
nsCOMPtr<nsIDOMHTMLInputElement> htmlRadioElement(do_QueryInterface(mDOMNode));
if (htmlRadioElement)
htmlRadioElement->GetChecked(&checked);
/* ----- Need to add this code soon
nsCOMPtr<nsIDOMXULRadioElement> xulRadioElement(do_QueryInteface(mDOMNode));
if (xulRadioElement)
xulRadioElement->GetChecked(&checked);
*/
if (checked)
*_retval |= STATE_CHECKED;
return NS_OK;
}
// ----- Button -----
nsHTMLButtonAccessible::nsHTMLButtonAccessible(nsIDOMNode* aNode, nsIWeakReference* aShell):
@ -387,6 +438,11 @@ NS_IMETHODIMP nsHTMLTextFieldAccessible::GetAccRole(PRUint32 *_retval)
/* wstring getAccValue (); */
NS_IMETHODIMP nsHTMLTextFieldAccessible::GetAccValue(nsAWritableString& _retval)
{
PRUint32 state;
GetAccState(&state);
if (state & STATE_PROTECTED) // Don't return password text!
return NS_ERROR_FAILURE;
nsCOMPtr<nsIDOMHTMLTextAreaElement> textArea(do_QueryInterface(mDOMNode));
if (textArea) {
textArea->GetValue(_retval);

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

@ -54,6 +54,7 @@ public:
NS_IMETHOD GetAccNumActions(PRUint8 *_retval);
NS_IMETHOD GetAccActionName(PRUint8 index, nsAWritableString& _retval);
NS_IMETHOD AccDoAction(PRUint8 index);
NS_IMETHOD GetAccState(PRUint32 *_retval);
};
class nsHTMLRadioButtonAccessible : public nsHTMLFormControlAccessible
@ -65,6 +66,7 @@ public:
NS_IMETHOD GetAccNumActions(PRUint8 *_retval);
NS_IMETHOD GetAccActionName(PRUint8 index, nsAWritableString& _retval);
NS_IMETHOD AccDoAction(PRUint8 index);
NS_IMETHOD GetAccState(PRUint32 *_retval);
};
class nsHTMLButtonAccessible : public nsHTMLFormControlAccessible

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

@ -24,7 +24,6 @@
#include "nsHTMLTextAccessible.h"
#include "nsWeakReference.h"
#include "nsIFrame.h"
#include "nsString.h"
#include "nsILink.h"
#include "nsILinkHandler.h"
#include "nsISelection.h"

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

@ -45,10 +45,12 @@
#include "nsHTMLListboxAccessible.h"
#include "nsIDOMHTMLAreaElement.h"
#include "nsHTMLFormControlAccessible.h"
#include "nsIAccessibleProvider.h"
#include "nsILink.h"
#include "nsIDocShellTreeItem.h"
#include "nsIDOMDocument.h"
#include "nsIDOMHTMLOptionElement.h"
#include "nsIDOMXULCheckboxElement.h"
// IFrame
#include "nsIDocShell.h"
@ -175,6 +177,19 @@ NS_IMETHODIMP nsAccessibilityService::CreateHTMLCheckboxAccessible(nsISupports *
return NS_OK;
}
NS_IMETHODIMP nsAccessibilityService::CreateXULCheckboxAccessible(nsIDOMNode *aNode, nsIAccessible **_retval)
{
nsCOMPtr<nsIWeakReference> weakShell;
GetShellFromNode(aNode, getter_AddRefs(weakShell));
*_retval = new nsHTMLCheckboxAccessible(aNode, weakShell);
if (! *_retval)
return NS_ERROR_OUT_OF_MEMORY;
NS_ADDREF(*_retval);
return NS_OK;
}
/* nsIAccessible createHTMRadioButtonAccessible (in nsISupports aPresShell, in nsISupports aFrame); */
NS_IMETHODIMP nsAccessibilityService::CreateHTMLRadioButtonAccessible(nsISupports *aFrame, nsIAccessible **_retval)
{
@ -340,6 +355,28 @@ NS_IMETHODIMP nsAccessibilityService::CreateHTMLTextFieldAccessible(nsISupports
return NS_OK;
}
NS_IMETHODIMP nsAccessibilityService::GetShellFromNode(nsIDOMNode *aNode, nsIWeakReference **aWeakShell)
{
nsCOMPtr<nsIDOMDocument> domDoc;
aNode->GetOwnerDocument(getter_AddRefs(domDoc));
nsCOMPtr<nsIDocument> doc(do_QueryInterface(domDoc));
if (!doc)
return NS_ERROR_INVALID_ARG;
// ---- Get the pres shell ----
nsCOMPtr<nsIPresShell> shell;
doc->GetShellAt(0, getter_AddRefs(shell));
if (!shell)
return NS_ERROR_FAILURE;
nsCOMPtr<nsIWeakReference> weakRef(do_GetWeakReference(shell));
*aWeakShell = weakRef;
NS_IF_ADDREF(*aWeakShell);
return NS_OK;
}
NS_IMETHODIMP nsAccessibilityService::GetInfo(nsISupports* aFrame, nsIFrame** aRealFrame, nsIWeakReference** aShell, nsIDOMNode** aNode)
{
NS_ASSERTION(aFrame,"Error -- 1st argument (aFrame) is null!!");
@ -624,9 +661,12 @@ NS_IMETHODIMP nsAccessibilityService::GetAccessibleFor(nsIDOMNode *aNode,
nsCOMPtr<nsIAccessible> newAcc;
frame->GetAccessible(getter_AddRefs(newAcc));
// ---- Try QI'ing node to get nsIAccessible ----
if (!newAcc)
newAcc = do_QueryInterface(aNode);
// ---- Is it a XUL element? -- they impl nsIAccessibleProvider via XBL
if (!newAcc) {
nsCOMPtr<nsIAccessibleProvider> accProv(do_QueryInterface(aNode));
if (accProv)
accProv->GetAccessible(getter_AddRefs(newAcc));
}
// ---- If link, create link accessible ----
if (!newAcc) {

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

@ -51,6 +51,7 @@ public:
private:
NS_IMETHOD GetInfo(nsISupports* aFrame, nsIFrame** aRealFrame, nsIWeakReference** aShell, nsIDOMNode** aContent);
NS_IMETHOD GetShellFromNode(nsIDOMNode *aNode, nsIWeakReference **weakShell);
void GetOwnerFor(nsIPresShell *aPresShell, nsIPresShell **aOwnerShell, nsIContent **aOwnerContent);
nsIContent* FindContentForDocShell(nsIPresShell* aPresShell, nsIContent* aContent, nsIDocShell* aDocShell);

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

@ -623,6 +623,49 @@ NS_IMETHODIMP nsAccessible::GetAccState(PRUint32 *aAccState)
}
}
nsCOMPtr<nsIContent> content(do_QueryInterface(mDOMNode));
if (content) {
nsCOMPtr<nsIPresShell> shell(do_QueryReferent(mPresShell));
if (shell) {
nsIFrame *frame = nsnull;
shell->GetPrimaryFrameFor(content, &frame);
if (frame) {
/*
PRBool isVisible = PR_FALSE, isFinishedLooking = PR_FALSE;
nsCOMPtr<nsIPresContext> presContext;
shell->GetPresContext(getter_AddRefs(presContext));
nsRect twipsRect, pixelsRect;
GetAbsoluteFramePosition(presContext, frame, twipsRect, pixelsRect);
//frame->IsVisibleForPainting(presContext, presContext, PR_TRUE, &isVisible); // 3rd param = bool to check css visibility
//frame->CheckVisibility(presContext, 0,1, PR_TRUE, &isFinishedLooking, &isVisible);
if (twipsRect.y < 0)
*aAccState |= STATE_OFFSCREEN;
*/
nsSize frameSize;
frame->GetSize(frameSize);
if (frameSize.width == 0)
*aAccState |= STATE_INVISIBLE;
}
}
}
/**
* called to see if the children of the frame are visible from indexstart to index end.
* this does not change any state. returns PR_TRUE only if the indexes are valid and any of
* the children are visible. for textframes this index is the character index.
* if aStart = aEnd result will be PR_FALSE
* @param aStart start index of first child from 0-N (number of children)
* @param aEnd end index of last child from 0-N
* @param aRecurse should this frame talk to siblings to get to the contents other children?
* @param aFinished did this frame have the aEndIndex? or is there more work to do
* @param _retval return value true or false. false = range is not rendered.
*/
//NS_IMETHOD CheckVisibility(nsIPresContext* aContext, PRInt32 aStartIndex, PRInt32 aEndIndex, PRBool aRecurse, PRBool *aFinished, PRBool *_retval)=0;
return rv;
}

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

@ -25,7 +25,6 @@
#include "nsIFrame.h"
#include "nsCOMPtr.h"
#include "nsIWeakReference.h"
#include "nsISelectionController.h"
#include "nsReadableUtils.h"
#include "nsIContent.h"

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

@ -30,7 +30,6 @@
#include "nsIServiceManager.h"
#include "nsIDOMElement.h"
#include "nsIDOMHTMLAreaElement.h"
#include "nsGUIEvent.h"
// --- area -----

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

@ -29,12 +29,12 @@
#include "nsHTMLAtoms.h"
#include "nsIDOMHTMLButtonElement.h"
#include "nsReadableUtils.h"
#include "nsString.h"
#include "nsAccessible.h"
#include "nsIFrame.h"
#include "nsIDOMHTMLLabelElement.h"
#include "nsIDOMHTMLFormElement.h"
#include "nsISelectionController.h"
#include "nsIDOMXULCheckboxElement.h"
nsHTMLFormControlAccessible::nsHTMLFormControlAccessible(nsIDOMNode* aNode, nsIWeakReference* aShell):
nsLeafAccessible(aNode, aShell)
@ -117,25 +117,29 @@ NS_IMETHODIMP nsHTMLFormControlAccessible::GetAccName(nsAWritableString& _retval
NS_IMETHODIMP nsHTMLFormControlAccessible::GetAccState(PRUint32 *_retval)
{
// can be
// focusable, focused, checked, protected, unavailable
nsCOMPtr<nsIDOMHTMLInputElement> element(do_QueryInterface(mDOMNode));
// focusable, focused, protected, unavailable
nsCOMPtr<nsIDOMHTMLInputElement> htmlFormElement(do_QueryInterface(mDOMNode));
nsAccessible::GetAccState(_retval);
*_retval |= STATE_FOCUSABLE;
PRBool checked = PR_FALSE;
element->GetChecked(&checked);
if (checked) *_retval |= STATE_CHECKED;
PRBool disabled = PR_FALSE;
element->GetDisabled(&disabled);
if (htmlFormElement) {
htmlFormElement->GetDisabled(&disabled);
nsAutoString typeString;
htmlFormElement->GetType(typeString);
if (typeString.EqualsIgnoreCase("password"))
*_retval |= STATE_PROTECTED;
}
else {
nsCOMPtr<nsIDOMXULControlElement> xulFormElement(do_QueryInterface(mDOMNode));
if (xulFormElement)
xulFormElement->GetDisabled(&disabled);
}
if (disabled)
*_retval |= STATE_UNAVAILABLE;
nsAutoString typeString;
element->GetType(typeString);
if (typeString.EqualsIgnoreCase("password"))
*_retval |= STATE_PROTECTED;
else
*_retval |= STATE_FOCUSABLE;
return NS_OK;
}
@ -164,15 +168,12 @@ NS_IMETHODIMP nsHTMLCheckboxAccessible::GetAccNumActions(PRUint8 *_retval)
/* wstring getAccActionName (in PRUint8 index); */
NS_IMETHODIMP nsHTMLCheckboxAccessible::GetAccActionName(PRUint8 index, nsAWritableString& _retval)
{
if (index == 0) {
if (index == 0) { // 0 is the magic value for default action
// check or uncheck
nsCOMPtr<nsIDOMHTMLInputElement> element(do_QueryInterface(mDOMNode));
PRUint32 state;
GetAccState(&state);
PRBool checked = PR_FALSE;
if (element)
element->GetChecked(&checked);
if (checked)
if (state & STATE_CHECKED)
_retval = NS_LITERAL_STRING("uncheck");
else
_retval = NS_LITERAL_STRING("check");
@ -186,15 +187,43 @@ NS_IMETHODIMP nsHTMLCheckboxAccessible::GetAccActionName(PRUint8 index, nsAWrita
NS_IMETHODIMP nsHTMLCheckboxAccessible::AccDoAction(PRUint8 index)
{
if (index == 0) { // 0 is the magic value for default action
nsCOMPtr<nsIDOMHTMLInputElement> element(do_QueryInterface(mDOMNode));
nsCOMPtr<nsIDOMHTMLInputElement> htmlCheckboxElement(do_QueryInterface(mDOMNode));
PRBool checked = PR_FALSE;
element->GetChecked(&checked);
element->SetChecked(checked ? PR_FALSE : PR_TRUE);
if (htmlCheckboxElement) {
htmlCheckboxElement->GetChecked(&checked);
htmlCheckboxElement->SetChecked(!checked);
}
else {
nsCOMPtr<nsIDOMXULCheckboxElement> xulCheckboxElement(do_QueryInterface(mDOMNode));
if (xulCheckboxElement) {
xulCheckboxElement->GetChecked(&checked);
xulCheckboxElement->SetChecked(!checked);
}
}
return NS_OK;
}
return NS_ERROR_INVALID_ARG;
}
NS_IMETHODIMP nsHTMLCheckboxAccessible::GetAccState(PRUint32 *_retval)
{
nsHTMLFormControlAccessible::GetAccState(_retval);
PRBool checked = PR_FALSE; // Radio buttons and check boxes can be checked
nsCOMPtr<nsIDOMHTMLInputElement> htmlCheckboxElement(do_QueryInterface(mDOMNode));
if (htmlCheckboxElement)
htmlCheckboxElement->GetChecked(&checked);
else {
nsCOMPtr<nsIDOMXULCheckboxElement> xulCheckboxElement(do_QueryInterface(mDOMNode));
if (xulCheckboxElement)
xulCheckboxElement->GetChecked(&checked);
}
if (checked)
*_retval |= STATE_CHECKED;
return NS_OK;
}
//------ Radio button -------
@ -240,6 +269,28 @@ NS_IMETHODIMP nsHTMLRadioButtonAccessible::GetAccRole(PRUint32 *_retval)
return NS_OK;
}
NS_IMETHODIMP nsHTMLRadioButtonAccessible::GetAccState(PRUint32 *_retval)
{
nsHTMLFormControlAccessible::GetAccState(_retval);
PRBool checked = PR_FALSE; // Radio buttons and check boxes can be checked
nsCOMPtr<nsIDOMHTMLInputElement> htmlRadioElement(do_QueryInterface(mDOMNode));
if (htmlRadioElement)
htmlRadioElement->GetChecked(&checked);
/* ----- Need to add this code soon
nsCOMPtr<nsIDOMXULRadioElement> xulRadioElement(do_QueryInteface(mDOMNode));
if (xulRadioElement)
xulRadioElement->GetChecked(&checked);
*/
if (checked)
*_retval |= STATE_CHECKED;
return NS_OK;
}
// ----- Button -----
nsHTMLButtonAccessible::nsHTMLButtonAccessible(nsIDOMNode* aNode, nsIWeakReference* aShell):
@ -387,6 +438,11 @@ NS_IMETHODIMP nsHTMLTextFieldAccessible::GetAccRole(PRUint32 *_retval)
/* wstring getAccValue (); */
NS_IMETHODIMP nsHTMLTextFieldAccessible::GetAccValue(nsAWritableString& _retval)
{
PRUint32 state;
GetAccState(&state);
if (state & STATE_PROTECTED) // Don't return password text!
return NS_ERROR_FAILURE;
nsCOMPtr<nsIDOMHTMLTextAreaElement> textArea(do_QueryInterface(mDOMNode));
if (textArea) {
textArea->GetValue(_retval);

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

@ -54,6 +54,7 @@ public:
NS_IMETHOD GetAccNumActions(PRUint8 *_retval);
NS_IMETHOD GetAccActionName(PRUint8 index, nsAWritableString& _retval);
NS_IMETHOD AccDoAction(PRUint8 index);
NS_IMETHOD GetAccState(PRUint32 *_retval);
};
class nsHTMLRadioButtonAccessible : public nsHTMLFormControlAccessible
@ -65,6 +66,7 @@ public:
NS_IMETHOD GetAccNumActions(PRUint8 *_retval);
NS_IMETHOD GetAccActionName(PRUint8 index, nsAWritableString& _retval);
NS_IMETHOD AccDoAction(PRUint8 index);
NS_IMETHOD GetAccState(PRUint32 *_retval);
};
class nsHTMLButtonAccessible : public nsHTMLFormControlAccessible

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

@ -24,7 +24,6 @@
#include "nsHTMLTextAccessible.h"
#include "nsWeakReference.h"
#include "nsIFrame.h"
#include "nsString.h"
#include "nsILink.h"
#include "nsILinkHandler.h"
#include "nsISelection.h"

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

@ -2,3 +2,6 @@ nsIDOMXULCommandDispatcher.idl
nsIDOMXULDocument.idl
nsIDOMXULElement.idl
nsIDOMXULTreeElement.idl
nsIDOMXULCheckboxElement.idl
nsIDOMXULControlElement.idl
nsIDOMXULLabeledControlElement.idl

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

@ -34,6 +34,9 @@ XPIDLSRCS = \
nsIDOMXULDocument.idl \
nsIDOMXULElement.idl \
nsIDOMXULTreeElement.idl \
nsIDOMXULCheckboxElement.idl \
nsIDOMXULControlElement.idl \
nsIDOMXULLabeledControlElement.idl \
$(NULL)
include $(topsrcdir)/config/rules.mk

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

@ -30,6 +30,9 @@ XPIDLSRCS = \
.\nsIDOMXULDocument.idl \
.\nsIDOMXULElement.idl \
.\nsIDOMXULTreeElement.idl \
.\nsIDOMXULCheckboxElement.idl \
.\nsIDOMXULControlElement.idl \
.\nsIDOMXULLabeledControlElement.idl \
$(NULL)
include <$(DEPTH)\config\rules.mak>

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

@ -0,0 +1,37 @@
/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/*
* The contents of this file are subject to the Netscape Public
* License Version 1.1 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 2000 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
* David Hyatt <hyatt@netscape.com> (original author)
* Johnny Stenback <jst@netscape.com>
*/
#include "nsIDOMElement.idl"
#include "nsIDOMXULLabeledControlElement.idl"
[scriptable, uuid(5afaba88-1dd2-11b2-9249-dd65a129d0e4)]
interface nsIDOMXULCheckboxElement : nsIDOMXULLabeledControlElement {
attribute boolean checked;
attribute long checkState;
attribute boolean autoCheck;
};

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

@ -0,0 +1,41 @@
/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/*
* The contents of this file are subject to the Netscape Public
* License Version 1.1 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 2000 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
* David Hyatt <hyatt@netscape.com> (original author)
* Johnny Stenback <jst@netscape.com>
*/
#include "nsIDOMElement.idl"
#include "nsIDOMXULElement.idl"
interface nsIControllers;
[scriptable, uuid(007b8358-1dd2-11b2-8924-d209efc3f124)]
interface nsIDOMXULControlElement : nsIDOMXULElement {
attribute boolean disabled;
attribute long tabIndex;
// readonly attribute nsIControllers controllers;
// void focus();
// void blur();
};

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

@ -0,0 +1,38 @@
/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/*
* The contents of this file are subject to the Netscape Public
* License Version 1.1 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 2000 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
* David Hyatt <hyatt@netscape.com> (original author)
* Johnny Stenback <jst@netscape.com>
*/
#include "nsIDOMElement.idl"
#include "nsIDOMXULControlElement.idl"
[scriptable, uuid(a457ea70-1dd1-11b2-9089-8fd894122084)]
interface nsIDOMXULLabeledControlElement : nsIDOMXULControlElement {
attribute DOMString crop;
attribute DOMString image;
attribute DOMString label;
attribute DOMString accessKey;
attribute DOMString command;
// void doCommand();
};

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

@ -21,7 +21,15 @@
</xul:hbox>
</content>
<implementation>
<implementation implements="nsIDOMXULCheckboxElement, nsIAccessibleProvider">
<property name="accessible">
<getter>
<![CDATA[
var accService = Components.classes["@mozilla.org/accessibilityService;1"].getService(Components.interfaces.nsIAccessibilityService);
return (accService? accService.createXULCheckboxAccessible(this): null);
]]>
</getter>
</property>
<!-- public implementation -->
<property name="checked" onset="if (val) this.setAttribute('checked', 'true');
else this.removeAttribute('checked');