Bug 740766 - dexpcom nsAccessible::GroupPosition, r=surkov, f=tbsaunde

This commit is contained in:
Mark Capella 2012-05-29 20:51:00 -04:00
Родитель e355fe16f3
Коммит 7e59e664b6
7 изменённых файлов: 85 добавлений и 91 удалений

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

@ -1268,10 +1268,9 @@ Accessible::GetAttributes(nsIPersistentProperties **aAttributes)
nsAccUtils::SetAccAttr(attributes, nsGkAtoms::checkable, NS_LITERAL_STRING("true"));
// Group attributes (level/setsize/posinset)
PRInt32 level = 0, posInSet = 0, setSize = 0;
rv = GroupPosition(&level, &setSize, &posInSet);
if (NS_SUCCEEDED(rv))
nsAccUtils::SetAccGroupAttrs(attributes, level, setSize, posInSet);
GroupPos groupPos = GroupPosition();
nsAccUtils::SetAccGroupAttrs(attributes, groupPos.level,
groupPos.setSize, groupPos.posInSet);
// Expose object attributes from ARIA attributes.
PRUint32 numAttrs = mContent->GetAttrCount();
@ -1422,6 +1421,44 @@ Accessible::GetAttributesInternal(nsIPersistentProperties *aAttributes)
return NS_OK;
}
GroupPos
Accessible::GroupPosition()
{
GroupPos groupPos;
// Get group position from ARIA attributes.
nsCoreUtils::GetUIntAttr(mContent, nsGkAtoms::aria_level, &groupPos.level);
nsCoreUtils::GetUIntAttr(mContent, nsGkAtoms::aria_setsize, &groupPos.setSize);
nsCoreUtils::GetUIntAttr(mContent, nsGkAtoms::aria_posinset, &groupPos.posInSet);
// If ARIA is missed and the accessible is visible then calculate group
// position from hierarchy.
if (State() & states::INVISIBLE)
return groupPos;
// Calculate group level if ARIA is missed.
if (groupPos.level == 0) {
PRInt32 level = GetLevelInternal();
if (level != 0)
groupPos.level = level;
}
// Calculate position in group and group size if ARIA is missed.
if (groupPos.posInSet == 0 || groupPos.setSize == 0) {
PRInt32 posInSet = 0, setSize = 0;
GetPositionAndSizeInternal(&posInSet, &setSize);
if (posInSet != 0 && setSize != 0) {
if (groupPos.posInSet == 0)
groupPos.posInSet = posInSet;
if (groupPos.setSize == 0)
groupPos.setSize = setSize;
}
}
return groupPos;
}
NS_IMETHODIMP
Accessible::GroupPosition(PRInt32* aGroupLevel,
PRInt32* aSimilarItemsInGroup,
@ -1439,38 +1476,11 @@ Accessible::GroupPosition(PRInt32* aGroupLevel,
if (IsDefunct())
return NS_ERROR_FAILURE;
// Get group position from ARIA attributes.
nsCoreUtils::GetUIntAttr(mContent, nsGkAtoms::aria_level,
aGroupLevel);
nsCoreUtils::GetUIntAttr(mContent, nsGkAtoms::aria_posinset,
aPositionInGroup);
nsCoreUtils::GetUIntAttr(mContent, nsGkAtoms::aria_setsize,
aSimilarItemsInGroup);
GroupPos groupPos = GroupPosition();
// If ARIA is missed and the accessible is visible then calculate group
// position from hierarchy.
if (State() & states::INVISIBLE)
return NS_OK;
// Calculate group level if ARIA is missed.
if (*aGroupLevel == 0) {
PRInt32 level = GetLevelInternal();
if (level != 0)
*aGroupLevel = level;
}
// Calculate position in group and group size if ARIA is missed.
if (*aSimilarItemsInGroup == 0 || *aPositionInGroup == 0) {
PRInt32 posInSet = 0, setSize = 0;
GetPositionAndSizeInternal(&posInSet, &setSize);
if (posInSet != 0 && setSize != 0) {
if (*aPositionInGroup == 0)
*aPositionInGroup = posInSet;
if (*aSimilarItemsInGroup == 0)
*aSimilarItemsInGroup = setSize;
}
}
*aGroupLevel = groupPos.level;
*aSimilarItemsInGroup = groupPos.setSize;
*aPositionInGroup = groupPos.posInSet;
return NS_OK;
}

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

@ -53,6 +53,18 @@ enum ENameValueFlag {
eNameFromTooltip // Tooltip was used as a name
};
/**
* Group position (level, position in set and set size).
*/
struct GroupPos
{
GroupPos() : level(0), posInSet(0), setSize(0) { }
PRInt32 level;
PRInt32 posInSet;
PRInt32 setSize;
};
} // namespace a11y
} // namespace mozilla
@ -227,6 +239,12 @@ public:
*/
virtual nsresult GetAttributesInternal(nsIPersistentProperties *aAttributes);
/**
* Return group position (level, position in set and set size).
*/
virtual mozilla::a11y::GroupPos GroupPosition();
/**
/**
* Used by ChildAtPoint() method to get direct or deepest child at point.
*/

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

@ -4,7 +4,7 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "ApplicationAccessible.h"
#include "nsAccessibilityService.h"
@ -117,18 +117,10 @@ ApplicationAccessible::GetAttributes(nsIPersistentProperties** aAttributes)
return NS_OK;
}
NS_IMETHODIMP
ApplicationAccessible::GroupPosition(PRInt32* aGroupLevel,
PRInt32* aSimilarItemsInGroup,
PRInt32* aPositionInGroup)
GroupPos
ApplicationAccessible::GroupPosition()
{
NS_ENSURE_ARG_POINTER(aGroupLevel);
*aGroupLevel = 0;
NS_ENSURE_ARG_POINTER(aSimilarItemsInGroup);
*aSimilarItemsInGroup = 0;
NS_ENSURE_ARG_POINTER(aPositionInGroup);
*aPositionInGroup = 0;
return NS_OK;
return GroupPos();
}
Accessible*

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

@ -16,7 +16,7 @@
namespace mozilla {
namespace a11y {
/**
* ApplicationAccessible is for the whole application of Mozilla.
* Only one instance of ApplicationAccessible exists for one Mozilla instance.
@ -48,8 +48,6 @@ public:
NS_IMETHOD GetNextSibling(nsIAccessible **aNextSibling);
NS_IMETHOD GetPreviousSibling(nsIAccessible **aPreviousSibling);
NS_IMETHOD GetAttributes(nsIPersistentProperties **aAttributes);
NS_IMETHOD GroupPosition(PRInt32 *aGroupLevel, PRInt32 *aSimilarItemsInGroup,
PRInt32 *aPositionInGroup);
NS_IMETHOD GetBounds(PRInt32 *aX, PRInt32 *aY,
PRInt32 *aWidth, PRInt32 *aHeight);
NS_IMETHOD SetSelected(bool aIsSelected);
@ -68,7 +66,8 @@ public:
virtual bool IsPrimaryForNode() const;
// Accessible
virtual mozilla::a11y::ENameValueFlag Name(nsString& aName);
virtual GroupPos GroupPosition();
virtual ENameValueFlag Name(nsString& aName);
virtual void ApplyARIAState(PRUint64* aState) const;
virtual void Description(nsString& aDescription);
virtual void Value(nsString& aValue);

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

@ -1180,24 +1180,17 @@ __try {
if (IsDefunct())
return CO_E_OBJNOTCONNECTED;
PRInt32 groupLevel = 0;
PRInt32 similarItemsInGroup = 0;
PRInt32 positionInGroup = 0;
nsresult rv = GroupPosition(&groupLevel, &similarItemsInGroup,
&positionInGroup);
if (NS_FAILED(rv))
return GetHRESULT(rv);
GroupPos groupPos = GroupPosition();
// Group information for accessibles having level only (like html headings
// elements) isn't exposed by this method. AT should look for 'level' object
// attribute.
if (!similarItemsInGroup && !positionInGroup)
if (!groupPos.setSize && !groupPos.posInSet)
return S_FALSE;
*aGroupLevel = groupLevel;
*aSimilarItemsInGroup = similarItemsInGroup;
*aPositionInGroup = positionInGroup;
*aGroupLevel = groupPos.level;
*aSimilarItemsInGroup = groupPos.setSize;
*aPositionInGroup = groupPos.posInSet;
return S_OK;

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

@ -897,26 +897,14 @@ nsXULTreeItemAccessibleBase::IsPrimaryForNode() const
// nsXULTreeItemAccessibleBase: Accessible public methods
// nsIAccessible::groupPosition
nsresult
nsXULTreeItemAccessibleBase::GroupPosition(PRInt32 *aGroupLevel,
PRInt32 *aSimilarItemsInGroup,
PRInt32 *aPositionInGroup)
GroupPos
nsXULTreeItemAccessibleBase::GroupPosition()
{
NS_ENSURE_ARG_POINTER(aGroupLevel);
*aGroupLevel = 0;
NS_ENSURE_ARG_POINTER(aSimilarItemsInGroup);
*aSimilarItemsInGroup = 0;
NS_ENSURE_ARG_POINTER(aPositionInGroup);
*aPositionInGroup = 0;
if (IsDefunct() || !mTreeView)
return NS_ERROR_FAILURE;
GroupPos groupPos;
PRInt32 level;
nsresult rv = mTreeView->GetLevel(mRow, &level);
NS_ENSURE_SUCCESS(rv, rv);
NS_ENSURE_SUCCESS(rv, groupPos);
PRInt32 topCount = 1;
for (PRInt32 index = mRow - 1; index >= 0; index--) {
@ -932,7 +920,7 @@ nsXULTreeItemAccessibleBase::GroupPosition(PRInt32 *aGroupLevel,
PRInt32 rowCount = 0;
rv = mTreeView->GetRowCount(&rowCount);
NS_ENSURE_SUCCESS(rv, rv);
NS_ENSURE_SUCCESS(rv, groupPos);
PRInt32 bottomCount = 0;
for (PRInt32 index = mRow + 1; index < rowCount; index++) {
@ -946,14 +934,11 @@ nsXULTreeItemAccessibleBase::GroupPosition(PRInt32 *aGroupLevel,
}
}
PRInt32 setSize = topCount + bottomCount;
PRInt32 posInSet = topCount;
groupPos.level = level + 1;
groupPos.setSize = topCount + bottomCount;
groupPos.posInSet = topCount;
*aGroupLevel = level + 1;
*aSimilarItemsInGroup = setSize;
*aPositionInGroup = posInSet;
return NS_OK;
return groupPos;
}
PRUint64

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

@ -146,10 +146,6 @@ public:
NS_IMETHOD SetSelected(bool aSelect);
NS_IMETHOD TakeFocus();
NS_IMETHOD GroupPosition(PRInt32 *aGroupLevel,
PRInt32 *aSimilarItemsInGroup,
PRInt32 *aPositionInGroup);
NS_IMETHOD GetActionName(PRUint8 aIndex, nsAString& aName);
NS_IMETHOD DoAction(PRUint8 aIndex);
@ -158,6 +154,7 @@ public:
virtual bool IsPrimaryForNode() const;
// Accessible
virtual mozilla::a11y::GroupPos GroupPosition();
virtual PRUint64 NativeState();
virtual PRInt32 IndexInParent() const;
virtual Relation RelationByType(PRUint32 aType);