Fix for bug 371594 - expose groupPosition for Gecko. r=aaronlev

This commit is contained in:
surkov.alexander@gmail.com 2007-03-27 05:17:11 -07:00
parent c1fc03e9c8
commit dcc41ced76
38 changed files with 573 additions and 459 deletions

View File

@ -57,7 +57,7 @@ interface nsIDOMDOMStringList;
*
* @status UNDER_REVIEW
*/
[scriptable, uuid(6ff04a18-a66c-4e50-9099-8e46eca181f6)]
[scriptable, uuid(1f4ab23c-2878-4b26-9679-855f839d4542)]
interface nsIAccessible : nsISupports
{
/**
@ -186,6 +186,17 @@ interface nsIAccessible : nsISupports
*/
readonly attribute nsIPersistentProperties attributes;
/**
* Returns grouping information. Used for tree items, list items, tab panel
* labels, radio buttons, etc. Also used for collectons of non-text objects.
*
* @param groupLevel - 0-based, similar to ARIA 'level' property
* @param similarItemsInGroup - 1-based, similar to ARIA 'setsize' property
* @param positionInGroup - 0-based, similar to ARIA 'posinset' property
*/
void groupPosition(out long aGroupLevel, out long aSimilarItemsInGroup,
out long aPositionInGroup);
/**
* Accessible child which contains the coordinate at (x, y) in screen pixels.
*/

View File

@ -92,7 +92,6 @@ EXPORTS = \
nsAccessNodeWrap.h \
nsAccessibleWrap.h \
nsDocAccessibleWrap.h \
nsHTMLFormControlAccessibleWrap.h \
nsRootAccessibleWrap.h \
nsTextAccessibleWrap.h \
nsXULMenuAccessibleWrap.h \

View File

@ -58,7 +58,6 @@
#include "nsMaiInterfaceTable.h"
#include "nsXPCOMStrings.h"
#include "nsComponentManagerUtils.h"
#include "nsIPersistentProperties2.h"
#include "nsMaiInterfaceDocument.h"
#include "nsMaiInterfaceImage.h"

View File

@ -90,6 +90,4 @@ private:
PRUint16 CreateMaiInterfaces(void);
};
typedef class nsHTMLRadioButtonAccessible nsHTMLRadioButtonAccessibleWrap;
#endif /* __NS_ACCESSIBLE_WRAP_H__ */

View File

@ -1,46 +0,0 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* 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 mozilla.org code.
*
* The Initial Developer of the Original Code is
* Sun Microsystems, Inc.
* Portions created by the Initial Developer are Copyright (C) 2002
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Kyle Yuan (kyle.yuan@sun.com)
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#ifndef __nsHTMLFormControlAccessibleWrap_h__
#define __nsHTMLFormControlAccessibleWrap_h__
#include "nsHTMLFormControlAccessible.h"
typedef class nsHTMLRadioButtonAccessible nsHTMLRadioButtonAccessibleWrap;
#endif

View File

@ -77,6 +77,7 @@ CPPSRCS = \
nsDocAccessible.cpp \
nsOuterDocAccessible.cpp \
nsAccessibilityAtoms.cpp \
nsAccessibilityUtils.cpp \
nsAccessibilityService.cpp \
nsAccessible.cpp \
nsAccessibleTreeWalker.cpp \

View File

@ -42,7 +42,6 @@
#include "nsCURILoader.h"
#include "nsDocAccessible.h"
#include "nsHTMLAreaAccessible.h"
#include "nsHTMLFormControlAccessibleWrap.h"
#include "nsHTMLImageAccessible.h"
#include "nsHTMLLinkAccessible.h"
#include "nsHTMLSelectAccessible.h"
@ -715,7 +714,7 @@ nsAccessibilityService::CreateHTMLRadioButtonAccessible(nsISupports *aFrame, nsI
if (NS_FAILED(rv))
return rv;
*_retval = new nsHTMLRadioButtonAccessibleWrap(node, weakShell);
*_retval = new nsHTMLRadioButtonAccessible(node, weakShell);
if (! *_retval)
return NS_ERROR_OUT_OF_MEMORY;

View File

@ -0,0 +1,143 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* 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 mozilla.org code.
*
* The Initial Developer of the Original Code is
* Mozilla Foundation.
* Portions created by the Initial Developer are Copyright (C) 2007
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Alexander Surkov <surkov.alexander@gmail.com> (original author)
*
* Alternatively, the contents of this file may be used under the terms of
* either of the GNU General Public License Version 2 or later (the "GPL"),
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#include "nsAccessibilityUtils.h"
#include "nsIDOMXULSelectCntrlEl.h"
#include "nsIDOMXULSelectCntrlItemEl.h"
void
nsAccessibilityUtils::GetAccAttr(nsIPersistentProperties *aAttributes,
nsIAtom *aAttrName,
nsAString& aAttrValue)
{
nsCAutoString attrName;
aAttrName->ToUTF8String(attrName);
aAttributes->GetStringProperty(attrName, aAttrValue);
}
void
nsAccessibilityUtils::SetAccAttr(nsIPersistentProperties *aAttributes,
nsIAtom *aAttrName,
const nsAString& aAttrValue)
{
nsAutoString oldValue;
nsCAutoString attrName;
aAttrName->ToUTF8String(attrName);
aAttributes->SetStringProperty(attrName, aAttrValue, oldValue);
}
void
nsAccessibilityUtils::GetAccGroupAttrs(nsIPersistentProperties *aAttributes,
PRInt32 *aLevel,
PRInt32 *aPosInSet,
PRInt32 *aSizeSet)
{
*aLevel = 0;
*aPosInSet = 0;
*aSizeSet = 0;
nsAutoString value;
PRInt32 error = NS_OK;
GetAccAttr(aAttributes, nsAccessibilityAtoms::level, value);
if (!value.IsEmpty()) {
PRInt32 level = value.ToInteger(&error);
if (NS_SUCCEEDED(error))
*aLevel = level;
}
GetAccAttr(aAttributes, nsAccessibilityAtoms::setsize, value);
if (!value.IsEmpty()) {
PRInt32 posInSet = value.ToInteger(&error);
if (NS_SUCCEEDED(error))
*aPosInSet = posInSet;
}
GetAccAttr(aAttributes, nsAccessibilityAtoms::posinset, value);
if (!value.IsEmpty()) {
PRInt32 sizeSet = value.ToInteger(&error);
if (NS_SUCCEEDED(error))
*aSizeSet = sizeSet;
}
}
void
nsAccessibilityUtils::SetAccGroupAttrs(nsIPersistentProperties *aAttributes,
PRInt32 aLevel,
PRInt32 aPosInSet,
PRInt32 aSizeSet)
{
nsAutoString value;
if (aLevel) {
value.AppendInt(aLevel);
SetAccAttr(aAttributes, nsAccessibilityAtoms::level, value);
}
if (aSizeSet && aPosInSet) {
value.Truncate();
value.AppendInt(aPosInSet);
SetAccAttr(aAttributes, nsAccessibilityAtoms::posinset, value);
value.Truncate();
value.AppendInt(aSizeSet);
SetAccAttr(aAttributes, nsAccessibilityAtoms::setsize, value);
}
}
void
nsAccessibilityUtils::SetAccAttrsForXULSelectControlItem(nsIDOMNode *aNode,
nsIPersistentProperties *aAttributes)
{
nsCOMPtr<nsIDOMXULSelectControlItemElement> item(do_QueryInterface(aNode));
if (!item)
return;
nsCOMPtr<nsIDOMXULSelectControlElement> control;
item->GetControl(getter_AddRefs(control));
if (!control)
return;
PRUint32 itemsCount;
control->GetItemCount(&itemsCount);
PRInt32 indexOf;
control->GetIndexOfItem(item, &indexOf);
SetAccGroupAttrs(aAttributes, 0, indexOf + 1, itemsCount);
}

View File

@ -0,0 +1,99 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* 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 mozilla.org code.
*
* The Initial Developer of the Original Code is
* Mozilla Foundation.
* Portions created by the Initial Developer are Copyright (C) 2007
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Alexander Surkov <surkov.alexander@gmail.com> (original author)
*
* Alternatively, the contents of this file may be used under the terms of
* either of the GNU General Public License Version 2 or later (the "GPL"),
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#ifndef nsAccessibilityUtils_h_
#define nsAccessibilityUtils_h_
#include "nsAccessibilityAtoms.h"
#include "nsIDOMNode.h"
#include "nsIPersistentProperties2.h"
class nsAccessibilityUtils
{
public:
/**
* Returns value of attribute from the given attributes container.
*
* @param aAttributes - attributes container
* @param aAttrName - the name of requested attribute
* @param aAttrValue - value of attribute
*/
static void GetAccAttr(nsIPersistentProperties *aAttributes,
nsIAtom *aAttrName,
nsAString& aAttrValue);
/**
* Set value of attribute for the given attributes container.
*
* @param aAttributes - attributes container
* @param aAttrName - the name of requested attribute
* @param aAttrValue - new value of attribute
*/
static void SetAccAttr(nsIPersistentProperties *aAttributes,
nsIAtom *aAttrName,
const nsAString& aAttrValue);
/**
* Return values of group attributes ('level', 'setsize', 'posinset')
*/
static void GetAccGroupAttrs(nsIPersistentProperties *aAttributes,
PRInt32 *aLevel,
PRInt32 *aPosInSet,
PRInt32 *aSizeSet);
/**
* Set group attributes ('level', 'setsize', 'posinset').
*/
static void SetAccGroupAttrs(nsIPersistentProperties *aAttributes,
PRInt32 aLevel,
PRInt32 aPosInSet,
PRInt32 aSizeSet);
/**
* Set group attributes - 'level', 'setsize', 'posinset'.
*
* @param aNode - XUL element that implements
* nsIDOMXULSelectControlItemElement interface
* @param aAttributes - attributes container
*/
static void SetAccAttrsForXULSelectControlItem(nsIDOMNode *aNode,
nsIPersistentProperties *aAttributes);
};
#endif

View File

@ -91,7 +91,6 @@
#include "nsIImageLoadingContent.h"
#include "nsITimer.h"
#include "nsIMutableArray.h"
#include "nsIPersistentProperties2.h"
#include "nsIDOMTreeWalker.h"
#include "nsIDOMDocumentTraversal.h"
#include "nsIDOMNodeFilter.h"
@ -2123,6 +2122,46 @@ NS_IMETHODIMP nsAccessible::GetAttributes(nsIPersistentProperties **aAttributes)
return NS_OK;
}
NS_IMETHODIMP
nsAccessible::GroupPosition(PRInt32 *aGroupLevel,
PRInt32 *aSimilarItemsInGroup,
PRInt32 *aPositionInGroup)
{
// Every element exposes level/posinset/sizeset for IAccessdible::attributes
// if they make sense for it. These attributes are mapped into groupPosition.
// If 'level' attribute doesn't make sense element then it isn't represented
// via IAccessible::attributes and groupLevel of groupPosition method is 0.
// Elements that expose 'level' attribute only (like html headings elements)
// don't support this method and all arguements are equealed 0.
NS_ENSURE_ARG_POINTER(aGroupLevel);
NS_ENSURE_ARG_POINTER(aSimilarItemsInGroup);
NS_ENSURE_ARG_POINTER(aPositionInGroup);
*aGroupLevel = 0;
*aSimilarItemsInGroup = 0;
*aPositionInGroup = 0;
nsCOMPtr<nsIPersistentProperties> attributes;
nsresult rv = GetAttributes(getter_AddRefs(attributes));
NS_ENSURE_SUCCESS(rv, rv);
NS_ENSURE_TRUE(attributes, NS_ERROR_FAILURE);
PRInt32 level, posInSet, setSize;
nsAccessibilityUtils::GetAccGroupAttrs(attributes,
&level, &posInSet, &setSize);
if (!posInSet && !setSize)
return NS_OK;
*aGroupLevel = level;
*aPositionInGroup = posInSet - 1;
*aSimilarItemsInGroup = setSize - 1;
return NS_OK;
}
PRBool nsAccessible::MappedAttrState(nsIContent *aContent, PRUint32 *aStateInOut,
nsStateMapEntry *aStateMapEntry)
{

View File

@ -42,7 +42,7 @@
#include "nsIAccessibleRole.h"
#include "nsIAccessibleStates.h"
#include "nsAccessNodeWrap.h"
#include "nsAccessibilityAtoms.h"
#include "nsAccessibilityUtils.h"
#include "nsIAccessible.h"
#include "nsPIAccessible.h"
#include "nsIAccessibleHyperLink.h"

View File

@ -132,6 +132,50 @@ NS_IMETHODIMP nsHTMLRadioButtonAccessible::GetState(PRUint32 *_retval)
return NS_OK;
}
NS_IMETHODIMP
nsHTMLRadioButtonAccessible::GetAttributes(nsIPersistentProperties **aAttributes)
{
NS_ENSURE_ARG_POINTER(aAttributes);
NS_ENSURE_TRUE(mDOMNode, NS_ERROR_FAILURE);
nsresult rv = nsRadioButtonAccessible::GetAttributes(aAttributes);
NS_ENSURE_SUCCESS(rv, rv);
nsAutoString nsURI;
mDOMNode->GetNamespaceURI(nsURI);
nsAutoString tagName;
mDOMNode->GetLocalName(tagName);
nsCOMPtr<nsIDOMHTMLInputElement> radio(do_QueryInterface(mDOMNode));
nsCOMPtr<nsIDOMHTMLFormElement> form;
radio->GetForm(getter_AddRefs(form));
NS_ENSURE_TRUE(form, NS_OK);
nsCOMPtr<nsIDOMNodeList> radios;
form->GetElementsByTagNameNS(nsURI, tagName, getter_AddRefs(radios));
NS_ENSURE_TRUE(radios, NS_OK);
// setsize
PRUint32 radiosCount = 0;
radios->GetLength(&radiosCount);
// posinset
PRInt32 indexOf = 0;
for (PRUint32 index = 0; index < radiosCount; index++) {
nsCOMPtr<nsIDOMNode> item;
radios->Item(index, getter_AddRefs(item));
if (item == mDOMNode) {
indexOf = index;
break;
}
}
nsAccessibilityUtils::
SetAccGroupAttrs(*aAttributes, 0, indexOf + 1, radiosCount);
return NS_OK;
}
// ----- Button -----
nsHTMLButtonAccessible::nsHTMLButtonAccessible(nsIDOMNode* aNode, nsIWeakReference* aShell):

View File

@ -61,7 +61,9 @@ class nsHTMLRadioButtonAccessible : public nsRadioButtonAccessible
public:
nsHTMLRadioButtonAccessible(nsIDOMNode* aNode, nsIWeakReference* aShell);
NS_IMETHOD GetState(PRUint32 *_retval);
NS_IMETHOD GetState(PRUint32 *_retval);
NS_IMETHOD GetAttributes(nsIPersistentProperties **aAttributes);
};
class nsHTMLButtonAccessible : public nsHyperTextAccessible

View File

@ -521,6 +521,31 @@ NS_IMETHODIMP nsHTMLSelectOptionAccessible::GetName(nsAString& aName)
return NS_ERROR_FAILURE;
}
NS_IMETHODIMP
nsHTMLSelectOptionAccessible::GetAttributes(nsIPersistentProperties **aAttributes)
{
NS_ENSURE_ARG_POINTER(aAttributes);
NS_ENSURE_TRUE(mDOMNode, NS_ERROR_FAILURE);
nsresult rv = nsHyperTextAccessible::GetAttributes(aAttributes);
NS_ENSURE_SUCCESS(rv, rv);
nsCOMPtr<nsIContent> content(do_QueryInterface(mDOMNode));
NS_ENSURE_TRUE(content, NS_ERROR_FAILURE);
nsCOMPtr<nsIContent> parentContent = content->GetParent();
NS_ENSURE_TRUE(parentContent, NS_ERROR_FAILURE);
PRUint32 level =
parentContent->NodeInfo()->Equals(nsAccessibilityAtoms::optgroup) ? 2 : 1;
PRUint32 childCount = parentContent->GetChildCount();
PRUint32 indexOf = parentContent->IndexOf(content);
nsAccessibilityUtils::
SetAccGroupAttrs(*aAttributes, level, indexOf + 1, childCount);
return NS_OK;
}
nsIFrame* nsHTMLSelectOptionAccessible::GetBoundsFrame()
{
nsCOMPtr<nsIContent> selectContent(do_QueryInterface(mDOMNode));

View File

@ -164,6 +164,8 @@ public:
NS_IMETHOD GetState(PRUint32 *_retval);
NS_IMETHOD GetRole(PRUint32 *aRole);
NS_IMETHOD GetName(nsAString& aName);
NS_IMETHOD GetAttributes(nsIPersistentProperties **aAttributes);
nsIFrame* GetBoundsFrame();
static nsresult GetFocusedOptionNode(nsIDOMNode *aListNode, nsIDOMNode **aFocusedOptionNode);
static void SelectionChangedIfOption(nsIContent *aPossibleOption);

View File

@ -51,7 +51,6 @@
#include "nsIDOMHTMLTableSectionElem.h"
#include "nsIDocument.h"
#include "nsIDOMDocument.h"
#include "nsIPersistentProperties2.h"
#include "nsIPresShell.h"
#include "nsIServiceManager.h"
#include "nsITableLayout.h"

View File

@ -47,7 +47,6 @@
#include "nsIPresShell.h"
#include "nsISelection.h"
#include "nsISelectionController.h"
#include "nsIPersistentProperties2.h"
#include "nsComponentManagerUtils.h"
nsHTMLTextAccessible::nsHTMLTextAccessible(nsIDOMNode* aDomNode, nsIWeakReference* aShell, nsIFrame *aFrame):

View File

@ -56,7 +56,6 @@
#include "nsIPlaintextEditor.h"
#include "nsIServiceManager.h"
#include "nsTextFragment.h"
#include "nsIPersistentProperties2.h"
static NS_DEFINE_IID(kRangeCID, NS_RANGE_CID);
@ -823,30 +822,24 @@ NS_IMETHODIMP nsHyperTextAccessible::GetAttributes(nsIPersistentProperties **aAt
NS_ENSURE_TRUE(content, NS_ERROR_UNEXPECTED);
nsIAtom *tag = content->Tag();
PRInt32 headLevel = 0;
if (tag == nsAccessibilityAtoms::h1) {
headLevel = 1;
}
else if (tag == nsAccessibilityAtoms::h2) {
headLevel = 2;
}
else if (tag == nsAccessibilityAtoms::h3) {
headLevel = 3;
}
else if (tag == nsAccessibilityAtoms::h4) {
headLevel = 4;
}
else if (tag == nsAccessibilityAtoms::h5) {
headLevel = 5;
}
else if (tag == nsAccessibilityAtoms::h6) {
headLevel = 6;
}
if (headLevel) {
nsAutoString valueString;
valueString.AppendInt(headLevel);
nsAutoString oldValueUnused;
(*aAttributes)->SetStringProperty(NS_LITERAL_CSTRING("level"), valueString, oldValueUnused);
nsAutoString headLevel;
if (tag == nsAccessibilityAtoms::h1)
headLevel.AssignLiteral("1");
else if (tag == nsAccessibilityAtoms::h2)
headLevel.AssignLiteral("2");
else if (tag == nsAccessibilityAtoms::h3)
headLevel.AssignLiteral("3");
else if (tag == nsAccessibilityAtoms::h4)
headLevel.AssignLiteral("4");
else if (tag == nsAccessibilityAtoms::h5)
headLevel.AssignLiteral("5");
else if (tag == nsAccessibilityAtoms::h6)
headLevel.AssignLiteral("6");
if (!headLevel.IsEmpty()) {
nsAccessibilityUtils::SetAccAttr(*aAttributes,
nsAccessibilityAtoms::level,
headLevel);
}
return NS_OK;

View File

@ -79,7 +79,6 @@ EXPORTS = \
nsAccessibleWrap.h \
nsDocAccessibleWrap.h \
nsRootAccessibleWrap.h \
nsHTMLFormControlAccessibleWrap.h \
nsXULMenuAccessibleWrap.h \
nsXULTreeAccessibleWrap.h \
mozDocAccessible.h \

View File

@ -1,45 +0,0 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* 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 mozilla.org code.
*
* The Initial Developer of the Original Code is IBM Corporation
* Portions created by the Initial Developer are Copyright (C) 2005
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Author: Aaron Leventhal (aleventh@us.ibm.com)
*
* Alternatively, the contents of this file may be used under the terms of
* either of the GNU General Public License Version 2 or later (the "GPL"),
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#ifndef __nsHTMLFormControlAccessibleWrap_h__
#define __nsHTMLFormControlAccessibleWrap_h__
#include "nsHTMLFormControlAccessible.h"
typedef class nsHTMLRadioButtonAccessible nsHTMLRadioButtonAccessibleWrap;
#endif

View File

@ -72,7 +72,6 @@ CPPSRCS = \
nsTextAccessibleWrap.cpp \
nsDocAccessibleWrap.cpp \
nsRootAccessibleWrap.cpp \
nsHTMLFormControlAccessibleWrap.cpp \
nsHTMLWin32ObjectAccessible.cpp \
nsXULMenuAccessibleWrap.cpp \
nsXULTreeAccessibleWrap.cpp \
@ -84,7 +83,6 @@ EXPORTS = \
nsTextAccessibleWrap.h \
nsDocAccessibleWrap.h \
nsRootAccessibleWrap.h \
nsHTMLFormControlAccessibleWrap.h \
nsHTMLWin32ObjectAccessible.h \
nsXULMenuAccessibleWrap.h \
nsXULTreeAccessibleWrap.h \

View File

@ -302,88 +302,99 @@ STDMETHODIMP nsAccessibleWrap::get_accValue(
return S_OK;
}
NS_IMETHODIMP nsAccessibleWrap::GetDescription(nsAString& aDescription)
STDMETHODIMP
nsAccessibleWrap::get_accDescription(VARIANT varChild,
BSTR __RPC_FAR *pszDescription)
{
// For items that are a choice in a list of choices,
// use MSAA description field to shoehorn positional info, it's becoming
// a defacto standard use for the field.
// Tree items override this, because they provide the current level as well
*pszDescription = NULL;
nsCOMPtr<nsIAccessible> xpAccessible;
GetXPAccessibleFor(varChild, getter_AddRefs(xpAccessible));
if (!xpAccessible)
return E_FAIL;
aDescription.Truncate();
// For items that are a choice in a list of choices, use MSAA description
// field to shoehorn positional info, it's becoming a defacto standard use for
// the field.
// Try ARIA properties first:
// If they exist then map them to positional description string
nsIContent *content = GetRoleContent(mDOMNode);
nsAutoString posInSet, setSize;
if (content->GetAttr(kNameSpaceID_WAIProperties, nsAccessibilityAtoms::posinset, posInSet) &&
content->GetAttr(kNameSpaceID_WAIProperties, nsAccessibilityAtoms::setsize, setSize)) {
PRInt32 errPosInSet, errSetSize;
PRInt32 intPosInSet = posInSet.ToInteger(&errPosInSet);
PRInt32 intSetSize = setSize.ToInteger(&errSetSize);
if (NS_SUCCEEDED(errPosInSet) && intPosInSet >=1 && NS_SUCCEEDED(errSetSize) && intSetSize >= 1) {
nsAutoString level;
if (content->GetAttr(kNameSpaceID_WAIProperties, nsAccessibilityAtoms::level, level)) {
// Position has a level
PRInt32 errLevel;
PRInt32 intLevel = level.ToInteger(&errLevel);
if (NS_SUCCEEDED(errLevel) && intLevel >= 1) {
// XXX How do we calculate the number of children?
// Normally we would append " with [numChildren]c" if we had that information
// In the future we may need to use the ARIA owns property to calculate that if it's present
nsTextFormatter::ssprintf(aDescription,
NS_LITERAL_STRING("L%d, %d of %d").get(), intLevel, intPosInSet, intSetSize);
}
nsAutoString description;
// Try nsIAccessible::groupPosition to make a positional description string.
PRInt32 groupLevel;
PRInt32 similarItemsInGroup;
PRInt32 positionInGroup;
nsresult rv = xpAccessible->GroupPosition(&groupLevel, &similarItemsInGroup,
&positionInGroup);
if (NS_SUCCEEDED(rv)) {
if (positionInGroup != -1 && similarItemsInGroup != -1) {
if (groupLevel != -1) {
// XXX: How do we calculate the number of children?
// Normally we would append " with [numChildren]c" if we had that
// information. In the future we may need to use the ARIA owns property
// to calculate that if it's present.
nsTextFormatter::ssprintf(description,
NS_LITERAL_STRING("L%d, %d of %d").get(),
groupLevel, positionInGroup + 1,
similarItemsInGroup + 1);
} else { // Position has no level
nsTextFormatter::ssprintf(description,
NS_LITERAL_STRING("%d of %d").get(),
positionInGroup + 1, similarItemsInGroup + 1);
}
else { // Position has no level
nsTextFormatter::ssprintf(aDescription,
NS_LITERAL_STRING("%d of %d").get(), intPosInSet, intSetSize);
}
return NS_OK;
*pszDescription = ::SysAllocString(description.get());
return S_OK;
}
}
PRUint32 currentRole;
nsresult rv = GetFinalRole(&currentRole);
rv = xpAccessible->GetFinalRole(&currentRole);
if (NS_FAILED(rv) ||
(currentRole != nsIAccessibleRole::ROLE_LISTITEM &&
currentRole != nsIAccessibleRole::ROLE_MENUITEM &&
currentRole != nsIAccessibleRole::ROLE_RADIOBUTTON &&
currentRole != nsIAccessibleRole::ROLE_PAGETAB &&
currentRole != nsIAccessibleRole::ROLE_OUTLINEITEM)) {
nsAutoString description;
nsAccessible::GetDescription(description);
xpAccessible->GetDescription(description);
if (!description.IsEmpty()) {
// Signal to screen readers that this description is speakable
// and is not a formatted positional information description
// Don't localize the "Description: " part of this string, it will be
// parsed out by assistive technologies.
aDescription = NS_LITERAL_STRING("Description: ") + description;
description = NS_LITERAL_STRING("Description: ") + description;
}
return NS_OK;
*pszDescription = ::SysAllocString(description.get());
return S_OK;
}
nsCOMPtr<nsIAccessible> parent(GetParent());
if (!parent) {
return NS_ERROR_FAILURE;
}
// XXX: The role of an accessible can be pointed by ARIA attribute but
// ARIA posinset, level, setsize may be skipped. Therefore we calculate
// here these properties to map them into description. This should be
// handled in cross-platform code.
PRInt32 indexInParent = 0, numSiblings = 0;
nsCOMPtr<nsIAccessible> parent;
xpAccessible->GetParent(getter_AddRefs(parent));
NS_ENSURE_TRUE(parent, NS_ERROR_FAILURE);
positionInGroup = 0;
similarItemsInGroup = 0;
nsCOMPtr<nsIAccessible> sibling, nextSibling;
parent->GetFirstChild(getter_AddRefs(sibling));
NS_ENSURE_TRUE(sibling, NS_ERROR_FAILURE);
if (!sibling)
return E_FAIL;
PRBool foundCurrent = PR_FALSE;
PRUint32 siblingRole;
while (sibling) {
sibling->GetFinalRole(&siblingRole);
if (siblingRole == currentRole) {
++ numSiblings;
++ similarItemsInGroup;
if (!foundCurrent) {
++ indexInParent;
if (sibling == this) {
++ positionInGroup;
if (sibling == this)
foundCurrent = PR_TRUE;
}
}
}
sibling->GetNextSibling(getter_AddRefs(nextSibling));
@ -393,14 +404,14 @@ NS_IMETHODIMP nsAccessibleWrap::GetDescription(nsAString& aDescription)
// Don't localize the string "of" -- that's just the format of this string.
// The AT will parse the relevant numbers out and add its own localization.
if (currentRole == nsIAccessibleRole::ROLE_OUTLINEITEM) {
PRUint32 level = 1;
groupLevel = 1;
nsCOMPtr<nsIAccessible> nextParent;
while (parent) {
parent->GetFinalRole(&currentRole);
if (currentRole != nsIAccessibleRole::ROLE_GROUPING) {
if (currentRole != nsIAccessibleRole::ROLE_GROUPING)
break;
}
++level;
++ groupLevel;
parent->GetParent(getter_AddRefs(nextParent));
parent.swap(nextParent);
}
@ -408,7 +419,7 @@ NS_IMETHODIMP nsAccessibleWrap::GetDescription(nsAString& aDescription)
// Count the number of tree item children
PRInt32 numChildren = 0;
nsCOMPtr<nsIAccessible> groupSibling;
GetNextSibling(getter_AddRefs(groupSibling));
xpAccessible->GetNextSibling(getter_AddRefs(groupSibling));
if (groupSibling) {
groupSibling->GetFinalRole(&currentRole);
if (currentRole == nsIAccessibleRole::ROLE_GROUPING) {
@ -426,32 +437,16 @@ NS_IMETHODIMP nsAccessibleWrap::GetDescription(nsAString& aDescription)
}
// This must be a DHTML tree item -- XUL tree items impl GetDescription()
nsTextFormatter::ssprintf(aDescription,
nsTextFormatter::ssprintf(description,
NS_LITERAL_STRING("L%d, %d of %d with %d").get(),
level, indexInParent, numSiblings, numChildren);
}
else {
nsTextFormatter::ssprintf(aDescription, NS_LITERAL_STRING("%d of %d").get(),
indexInParent, numSiblings);
}
return NS_OK;
}
STDMETHODIMP nsAccessibleWrap::get_accDescription(
/* [optional][in] */ VARIANT varChild,
/* [retval][out] */ BSTR __RPC_FAR *pszDescription)
{
*pszDescription = NULL;
nsCOMPtr<nsIAccessible> xpAccessible;
GetXPAccessibleFor(varChild, getter_AddRefs(xpAccessible));
if (xpAccessible) {
nsAutoString description;
if (NS_FAILED(xpAccessible->GetDescription(description)))
return S_FALSE;
*pszDescription = ::SysAllocString(description.get());
groupLevel, positionInGroup,
similarItemsInGroup, numChildren);
} else {
nsTextFormatter::ssprintf(description, NS_LITERAL_STRING("%d of %d").get(),
positionInGroup, similarItemsInGroup);
}
*pszDescription = ::SysAllocString(description.get());
return S_OK;
}
@ -1149,11 +1144,24 @@ nsAccessibleWrap::scrollTo(boolean topLeft)
}
STDMETHODIMP
nsAccessibleWrap::get_groupPosition(long *groupLevel,
long *similarItemsInGroup,
long *positionInGroup)
nsAccessibleWrap::get_groupPosition(long *aGroupLevel,
long *aSimilarItemsInGroup,
long *aPositionInGroup)
{
return E_NOTIMPL;
PRInt32 groupLevel = 0;
PRInt32 similarItemsInGroup = 0;
PRInt32 positionInGroup = 0;
nsresult rv = GroupPosition(&groupLevel, &similarItemsInGroup,
&positionInGroup);
if (NS_SUCCEEDED(rv)) {
*aGroupLevel = groupLevel;
*aSimilarItemsInGroup = similarItemsInGroup;
*aPositionInGroup = positionInGroup;
return S_OK;
}
return E_FAIL;
}
STDMETHODIMP

View File

@ -276,7 +276,6 @@ class nsAccessibleWrap : public nsAccessible,
virtual void GetXPAccessibleFor(const VARIANT& aVarChild, nsIAccessible **aXPAccessible);
NS_IMETHOD GetNativeInterface(void **aOutAccessible);
NS_IMETHOD GetDescription(nsAString& aDescription);
// NT4 does not have the oleacc that defines these methods. So we define copies here that automatically
// load the library only if needed.

View File

@ -1,80 +0,0 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* 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 mozilla.org code.
*
* The Initial Developer of the Original Code is IBM Corporation
* Portions created by the Initial Developer are Copyright (C) 2005
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Author: Aaron Leventhal (aleventh@us.ibm.com)
*
* Alternatively, the contents of this file may be used under the terms of
* either of the GNU General Public License Version 2 or later (the "GPL"),
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#include "nsHTMLFormControlAccessibleWrap.h"
#include "nsIDOMHTMLInputElement.h"
#include "nsIRadioControlElement.h"
#include "nsIRadioGroupContainer.H"
#include "nsTextFormatter.h"
// --------------------------------------------------------
// nsXULMenuAccessibleWrap Accessible
// --------------------------------------------------------
nsHTMLRadioButtonAccessibleWrap::nsHTMLRadioButtonAccessibleWrap(nsIDOMNode *aDOMNode,
nsIWeakReference *aShell):
nsHTMLRadioButtonAccessible(aDOMNode, aShell)
{
}
NS_IMETHODIMP nsHTMLRadioButtonAccessibleWrap::GetDescription(nsAString& aDescription)
{
aDescription.Truncate();
nsCOMPtr<nsIRadioControlElement> radio(do_QueryInterface(mDOMNode));
if (!radio) {
return NS_ERROR_FAILURE;
}
NS_ASSERTION(radio, "We should only have HTML radio buttons here");
nsCOMPtr<nsIRadioGroupContainer> radioGroupContainer =
radio->GetRadioGroupContainer();
if (radioGroupContainer) {
nsCOMPtr<nsIDOMHTMLInputElement> input(do_QueryInterface(mDOMNode));
PRInt32 radioIndex, radioItemsInGroup;
if (NS_SUCCEEDED(radioGroupContainer->GetPositionInGroup(input, &radioIndex,
&radioItemsInGroup))) {
// Don't localize the string "of" -- that's just the format of this string.
// The AT will parse the relevant numbers out and add its own localization.
nsTextFormatter::ssprintf(aDescription, NS_LITERAL_STRING("%d of %d").get(),
radioIndex + 1, radioItemsInGroup);
return NS_OK;
}
}
return nsAccessibleWrap::GetDescription(aDescription);
}

View File

@ -1,51 +0,0 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* 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 mozilla.org code.
*
* The Initial Developer of the Original Code is IBM Corporation
* Portions created by the Initial Developer are Copyright (C) 2005
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Author: Aaron Leventhal (aleventh@us.ibm.com)
*
* Alternatively, the contents of this file may be used under the terms of
* either of the GNU General Public License Version 2 or later (the "GPL"),
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#ifndef __nsHTMLFormControlAccessibleWrap_h__
#define __nsHTMLFormControlAccessibleWrap_h__
#include "nsHTMLFormControlAccessible.h"
class nsHTMLRadioButtonAccessibleWrap : public nsHTMLRadioButtonAccessible
{
public:
nsHTMLRadioButtonAccessibleWrap(nsIDOMNode *aDOMNode, nsIWeakReference *aShell);
virtual ~nsHTMLRadioButtonAccessibleWrap() {}
NS_IMETHOD GetDescription(nsAString& aName);
};
#endif

View File

@ -130,69 +130,3 @@ NS_IMETHODIMP nsXULTreeitemAccessibleWrap::GetName(nsAString& aName)
return NS_OK;
}
NS_IMETHODIMP nsXULTreeitemAccessibleWrap::GetDescription(nsAString& aDescription)
{
if (!mParent || !mWeakShell || !mTreeView) {
return NS_ERROR_FAILURE;
}
PRUint32 itemRole;
GetRole(&itemRole);
if (itemRole == nsIAccessibleRole::ROLE_LISTITEM) {
return nsAccessibleWrap::GetDescription(aDescription);
}
aDescription.Truncate();
PRInt32 level;
if (NS_FAILED(mTreeView->GetLevel(mRow, &level))) {
return NS_OK;
}
PRInt32 testRow = -1;
if (level > 0) {
mTreeView->GetParentIndex(mRow, &testRow);
}
PRInt32 numRows;
mTreeView->GetRowCount(&numRows);
PRInt32 indexInParent = 0, numSiblings = 0;
// Get the index in parent and number of siblings
while (++ testRow < numRows) {
PRInt32 testLevel = 0;
mTreeView->GetLevel(testRow, &testLevel);
if (testLevel == level) {
if (testRow <= mRow) {
++indexInParent;
}
++numSiblings;
}
else if (testLevel < level) {
break;
}
}
// Count the number of children
testRow = mRow;
PRInt32 numChildren = 0;
while (++ testRow < numRows) {
PRInt32 testLevel = 0;
mTreeView->GetLevel(testRow, &testLevel);
if (testLevel <= level) {
break;
}
else if (testLevel == level + 1) {
++ numChildren;
}
}
// Don't localize "of" or "with" -- that is just the format of
// the string, and are parsed out by the AT
nsTextFormatter::ssprintf(aDescription, NS_LITERAL_STRING("L%d, %d of %d with %d").get(),
level + 1, indexInParent, numSiblings, numChildren);
return NS_OK;
}

View File

@ -57,10 +57,10 @@ public:
nsXULTreeitemAccessibleWrap(nsIAccessible *aParent, nsIDOMNode *aDOMNode, nsIWeakReference *aShell,
PRInt32 aRow, nsITreeColumn* aColumn);
virtual ~nsXULTreeitemAccessibleWrap() {}
NS_IMETHOD GetBounds(PRInt32 *x, PRInt32 *y, PRInt32 *width, PRInt32 *height);
NS_IMETHOD GetRole(PRUint32 *aRole);
NS_IMETHOD GetName(nsAString &aName);
NS_IMETHOD GetDescription(nsAString &aDescription);
};
#endif

View File

@ -81,7 +81,6 @@ EXPORTS = \
nsRootAccessibleWrap.h \
nsXULMenuAccessibleWrap.h \
nsXULTreeAccessibleWrap.h \
nsHTMLFormControlAccessibleWrap.h \
$(NULL)
# we don't want the shared lib, but we want to force the creation of a static lib.

View File

@ -1,45 +0,0 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* 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 mozilla.org code.
*
* The Initial Developer of the Original Code is IBM Corporation
* Portions created by the Initial Developer are Copyright (C) 2005
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Author: Aaron Leventhal (aleventh@us.ibm.com)
*
* Alternatively, the contents of this file may be used under the terms of
* either of the GNU General Public License Version 2 or later (the "GPL"),
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#ifndef __nsHTMLFormControlAccessibleWrap_h__
#define __nsHTMLFormControlAccessibleWrap_h__
#include "nsHTMLFormControlAccessible.h"
typedef class nsHTMLRadioButtonAccessible nsHTMLRadioButtonAccessibleWrap;
#endif

View File

@ -45,7 +45,6 @@
#include "nsIMutableArray.h"
#include "nsIXFormsUtilityService.h"
#include "nsIPlaintextEditor.h"
#include "nsIPersistentProperties2.h"
// nsXFormsAccessibleBase

View File

@ -528,6 +528,21 @@ NS_IMETHODIMP nsXULRadioButtonAccessible::GetState(PRUint32 *_retval)
return NS_OK;
}
NS_IMETHODIMP
nsXULRadioButtonAccessible::GetAttributes(nsIPersistentProperties **aAttributes)
{
NS_ENSURE_ARG_POINTER(aAttributes);
NS_ENSURE_TRUE(mDOMNode, NS_ERROR_FAILURE);
nsresult rv = nsFormControlAccessible::GetAttributes(aAttributes);
NS_ENSURE_SUCCESS(rv, rv);
nsAccessibilityUtils::
SetAccAttrsForXULSelectControlItem(mDOMNode, *aAttributes);
return NS_OK;
}
/**
* XUL Radio Group
* The Radio Group proxies for the Radio Buttons themselves. The Group gets

View File

@ -113,7 +113,8 @@ class nsXULRadioButtonAccessible : public nsRadioButtonAccessible
public:
nsXULRadioButtonAccessible(nsIDOMNode* aNode, nsIWeakReference* aShell);
NS_IMETHOD GetState(PRUint32 *_retval);
NS_IMETHOD GetState(PRUint32 *aState);
NS_IMETHOD GetAttributes(nsIPersistentProperties **aAttributes);
};
class nsXULRadioGroupAccessible : public nsXULSelectableAccessible

View File

@ -434,6 +434,24 @@ NS_IMETHODIMP nsXULMenuitemAccessible::GetRole(PRUint32 *aRole)
return NS_OK;
}
NS_IMETHODIMP
nsXULMenuitemAccessible::GetAttributes(nsIPersistentProperties **aAttributes)
{
NS_ENSURE_ARG_POINTER(aAttributes);
NS_ENSURE_TRUE(mDOMNode, NS_ERROR_FAILURE);
nsresult rv = nsAccessible::GetAttributes(aAttributes);
NS_ENSURE_SUCCESS(rv, rv);
// XXX: we don't support xul:menuitem inside xul:menu element now until
// bug 372552 is fixed.
nsAccessibilityUtils::
SetAccAttrsForXULSelectControlItem(mDOMNode, *aAttributes);
return NS_OK;
}
NS_IMETHODIMP
nsXULMenuitemAccessible::GetAllowsAnonChildAccessibles(PRBool *aAllowsAnonChildren)
{

View File

@ -86,6 +86,7 @@ public:
NS_IMETHOD DoAction(PRUint8 index);
NS_IMETHOD GetActionName(PRUint8 aIndex, nsAString& aName);
NS_IMETHOD GetNumActions(PRUint8 *_retval);
NS_IMETHOD GetAttributes(nsIPersistentProperties **aAttributes);
NS_IMETHOD GetAllowsAnonChildAccessibles(PRBool *aAllowsAnonChildren);
};

View File

@ -127,6 +127,21 @@ NS_IMETHODIMP nsXULTabAccessible::GetState(PRUint32 *_retval)
return NS_OK;
}
NS_IMETHODIMP
nsXULTabAccessible::GetAttributes(nsIPersistentProperties **aAttributes)
{
NS_ENSURE_ARG_POINTER(aAttributes);
NS_ENSURE_TRUE(mDOMNode, NS_ERROR_FAILURE);
nsresult rv = nsLeafAccessible::GetAttributes(aAttributes);
NS_ENSURE_SUCCESS(rv, rv);
nsAccessibilityUtils::
SetAccAttrsForXULSelectControlItem(mDOMNode, *aAttributes);
return NS_OK;
}
/**
* XUL TabBox
* to facilitate naming of the tabPanels object we will give this the name

View File

@ -55,6 +55,7 @@ public:
NS_IMETHOD GetNumActions(PRUint8 *_retval);
NS_IMETHOD GetActionName(PRUint8 aIndex, nsAString& aName);
NS_IMETHOD DoAction(PRUint8 index);
NS_IMETHOD GetAttributes(nsIPersistentProperties **aAttributes);
};
/**

View File

@ -39,8 +39,8 @@
#include "nsIBoxObject.h"
#include "nsIDOMXULElement.h"
#include "nsIDOMXULMultSelectCntrlEl.h"
#include "nsIDOMXULTreeElement.h"
#include "nsITreeSelection.h"
#include "nsITreeColumns.h"
#include "nsXULTreeAccessibleWrap.h"
#include "nsIMutableArray.h"
#include "nsComponentManagerUtils.h"
@ -672,6 +672,47 @@ NS_IMETHODIMP nsXULTreeitemAccessible::GetActionName(PRUint8 aIndex, nsAString&
return NS_ERROR_INVALID_ARG;
}
NS_IMETHODIMP
nsXULTreeitemAccessible::GetAttributes(nsIPersistentProperties **aAttributes)
{
NS_ENSURE_ARG_POINTER(aAttributes);
NS_ENSURE_TRUE(mDOMNode, NS_ERROR_FAILURE);
nsresult rv = nsLeafAccessible::GetAttributes(aAttributes);
NS_ENSURE_SUCCESS(rv, rv);
nsCOMPtr<nsIDOMXULTreeElement> tree(do_QueryInterface(mDOMNode));
NS_ENSURE_TRUE(tree, NS_OK);
nsCOMPtr<nsITreeView> view;
tree->GetView(getter_AddRefs(view));
NS_ENSURE_TRUE(view, NS_OK);
PRInt32 level;
rv = view->GetLevel(mRow, &level);
NS_ENSURE_SUCCESS(rv, rv);
PRInt32 lvl = -1;
PRInt32 startIndex = mRow;
for (;startIndex - 1 > 0 &&
NS_SUCCEEDED(view->GetLevel(startIndex - 1, &lvl)) && lvl != level;
startIndex--);
lvl = -1;
PRInt32 endIndex = mRow;
for (;endIndex - 1 > 0 &&
NS_SUCCEEDED(view->GetLevel(endIndex - 1, &lvl)) && lvl != level;
endIndex--);
PRInt32 setSize = endIndex - startIndex + 1;
PRInt32 posInSet = mRow - startIndex + 1;
nsAccessibilityUtils::
SetAccGroupAttrs(*aAttributes, level + 1, posInSet, setSize);
return NS_OK;
}
NS_IMETHODIMP nsXULTreeitemAccessible::GetParent(nsIAccessible **aParent)
{
*aParent = nsnull;

View File

@ -110,6 +110,7 @@ public:
NS_IMETHOD GetState(PRUint32 *_retval);
NS_IMETHOD GetNumActions(PRUint8 *_retval);
NS_IMETHOD GetActionName(PRUint8 aIndex, nsAString& aName);
NS_IMETHOD GetAttributes(nsIPersistentProperties **aAttributes);
NS_IMETHOD GetParent(nsIAccessible **_retval);
NS_IMETHOD GetNextSibling(nsIAccessible **_retval);