mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-02-25 11:58:55 +00:00
Bug 740766 - dexpcom nsAccessible::GroupPosition, r=surkov, f=tbsaunde
This commit is contained in:
parent
e355fe16f3
commit
7e59e664b6
@ -1268,10 +1268,9 @@ Accessible::GetAttributes(nsIPersistentProperties **aAttributes)
|
|||||||
nsAccUtils::SetAccAttr(attributes, nsGkAtoms::checkable, NS_LITERAL_STRING("true"));
|
nsAccUtils::SetAccAttr(attributes, nsGkAtoms::checkable, NS_LITERAL_STRING("true"));
|
||||||
|
|
||||||
// Group attributes (level/setsize/posinset)
|
// Group attributes (level/setsize/posinset)
|
||||||
PRInt32 level = 0, posInSet = 0, setSize = 0;
|
GroupPos groupPos = GroupPosition();
|
||||||
rv = GroupPosition(&level, &setSize, &posInSet);
|
nsAccUtils::SetAccGroupAttrs(attributes, groupPos.level,
|
||||||
if (NS_SUCCEEDED(rv))
|
groupPos.setSize, groupPos.posInSet);
|
||||||
nsAccUtils::SetAccGroupAttrs(attributes, level, setSize, posInSet);
|
|
||||||
|
|
||||||
// Expose object attributes from ARIA attributes.
|
// Expose object attributes from ARIA attributes.
|
||||||
PRUint32 numAttrs = mContent->GetAttrCount();
|
PRUint32 numAttrs = mContent->GetAttrCount();
|
||||||
@ -1422,6 +1421,44 @@ Accessible::GetAttributesInternal(nsIPersistentProperties *aAttributes)
|
|||||||
return NS_OK;
|
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
|
NS_IMETHODIMP
|
||||||
Accessible::GroupPosition(PRInt32* aGroupLevel,
|
Accessible::GroupPosition(PRInt32* aGroupLevel,
|
||||||
PRInt32* aSimilarItemsInGroup,
|
PRInt32* aSimilarItemsInGroup,
|
||||||
@ -1439,38 +1476,11 @@ Accessible::GroupPosition(PRInt32* aGroupLevel,
|
|||||||
if (IsDefunct())
|
if (IsDefunct())
|
||||||
return NS_ERROR_FAILURE;
|
return NS_ERROR_FAILURE;
|
||||||
|
|
||||||
// Get group position from ARIA attributes.
|
GroupPos groupPos = GroupPosition();
|
||||||
nsCoreUtils::GetUIntAttr(mContent, nsGkAtoms::aria_level,
|
|
||||||
aGroupLevel);
|
|
||||||
nsCoreUtils::GetUIntAttr(mContent, nsGkAtoms::aria_posinset,
|
|
||||||
aPositionInGroup);
|
|
||||||
nsCoreUtils::GetUIntAttr(mContent, nsGkAtoms::aria_setsize,
|
|
||||||
aSimilarItemsInGroup);
|
|
||||||
|
|
||||||
// If ARIA is missed and the accessible is visible then calculate group
|
*aGroupLevel = groupPos.level;
|
||||||
// position from hierarchy.
|
*aSimilarItemsInGroup = groupPos.setSize;
|
||||||
if (State() & states::INVISIBLE)
|
*aPositionInGroup = groupPos.posInSet;
|
||||||
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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
@ -53,6 +53,18 @@ enum ENameValueFlag {
|
|||||||
eNameFromTooltip // Tooltip was used as a name
|
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 a11y
|
||||||
} // namespace mozilla
|
} // namespace mozilla
|
||||||
|
|
||||||
@ -227,6 +239,12 @@ public:
|
|||||||
*/
|
*/
|
||||||
virtual nsresult GetAttributesInternal(nsIPersistentProperties *aAttributes);
|
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.
|
* 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
|
/* 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
|
* 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/. */
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||||
|
|
||||||
#include "ApplicationAccessible.h"
|
#include "ApplicationAccessible.h"
|
||||||
|
|
||||||
#include "nsAccessibilityService.h"
|
#include "nsAccessibilityService.h"
|
||||||
@ -117,18 +117,10 @@ ApplicationAccessible::GetAttributes(nsIPersistentProperties** aAttributes)
|
|||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
NS_IMETHODIMP
|
GroupPos
|
||||||
ApplicationAccessible::GroupPosition(PRInt32* aGroupLevel,
|
ApplicationAccessible::GroupPosition()
|
||||||
PRInt32* aSimilarItemsInGroup,
|
|
||||||
PRInt32* aPositionInGroup)
|
|
||||||
{
|
{
|
||||||
NS_ENSURE_ARG_POINTER(aGroupLevel);
|
return GroupPos();
|
||||||
*aGroupLevel = 0;
|
|
||||||
NS_ENSURE_ARG_POINTER(aSimilarItemsInGroup);
|
|
||||||
*aSimilarItemsInGroup = 0;
|
|
||||||
NS_ENSURE_ARG_POINTER(aPositionInGroup);
|
|
||||||
*aPositionInGroup = 0;
|
|
||||||
return NS_OK;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Accessible*
|
Accessible*
|
||||||
|
@ -16,7 +16,7 @@
|
|||||||
|
|
||||||
namespace mozilla {
|
namespace mozilla {
|
||||||
namespace a11y {
|
namespace a11y {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ApplicationAccessible is for the whole application of Mozilla.
|
* ApplicationAccessible is for the whole application of Mozilla.
|
||||||
* Only one instance of ApplicationAccessible exists for one Mozilla instance.
|
* Only one instance of ApplicationAccessible exists for one Mozilla instance.
|
||||||
@ -48,8 +48,6 @@ public:
|
|||||||
NS_IMETHOD GetNextSibling(nsIAccessible **aNextSibling);
|
NS_IMETHOD GetNextSibling(nsIAccessible **aNextSibling);
|
||||||
NS_IMETHOD GetPreviousSibling(nsIAccessible **aPreviousSibling);
|
NS_IMETHOD GetPreviousSibling(nsIAccessible **aPreviousSibling);
|
||||||
NS_IMETHOD GetAttributes(nsIPersistentProperties **aAttributes);
|
NS_IMETHOD GetAttributes(nsIPersistentProperties **aAttributes);
|
||||||
NS_IMETHOD GroupPosition(PRInt32 *aGroupLevel, PRInt32 *aSimilarItemsInGroup,
|
|
||||||
PRInt32 *aPositionInGroup);
|
|
||||||
NS_IMETHOD GetBounds(PRInt32 *aX, PRInt32 *aY,
|
NS_IMETHOD GetBounds(PRInt32 *aX, PRInt32 *aY,
|
||||||
PRInt32 *aWidth, PRInt32 *aHeight);
|
PRInt32 *aWidth, PRInt32 *aHeight);
|
||||||
NS_IMETHOD SetSelected(bool aIsSelected);
|
NS_IMETHOD SetSelected(bool aIsSelected);
|
||||||
@ -68,7 +66,8 @@ public:
|
|||||||
virtual bool IsPrimaryForNode() const;
|
virtual bool IsPrimaryForNode() const;
|
||||||
|
|
||||||
// Accessible
|
// Accessible
|
||||||
virtual mozilla::a11y::ENameValueFlag Name(nsString& aName);
|
virtual GroupPos GroupPosition();
|
||||||
|
virtual ENameValueFlag Name(nsString& aName);
|
||||||
virtual void ApplyARIAState(PRUint64* aState) const;
|
virtual void ApplyARIAState(PRUint64* aState) const;
|
||||||
virtual void Description(nsString& aDescription);
|
virtual void Description(nsString& aDescription);
|
||||||
virtual void Value(nsString& aValue);
|
virtual void Value(nsString& aValue);
|
||||||
|
@ -1180,24 +1180,17 @@ __try {
|
|||||||
if (IsDefunct())
|
if (IsDefunct())
|
||||||
return CO_E_OBJNOTCONNECTED;
|
return CO_E_OBJNOTCONNECTED;
|
||||||
|
|
||||||
PRInt32 groupLevel = 0;
|
GroupPos groupPos = GroupPosition();
|
||||||
PRInt32 similarItemsInGroup = 0;
|
|
||||||
PRInt32 positionInGroup = 0;
|
|
||||||
|
|
||||||
nsresult rv = GroupPosition(&groupLevel, &similarItemsInGroup,
|
|
||||||
&positionInGroup);
|
|
||||||
if (NS_FAILED(rv))
|
|
||||||
return GetHRESULT(rv);
|
|
||||||
|
|
||||||
// Group information for accessibles having level only (like html headings
|
// Group information for accessibles having level only (like html headings
|
||||||
// elements) isn't exposed by this method. AT should look for 'level' object
|
// elements) isn't exposed by this method. AT should look for 'level' object
|
||||||
// attribute.
|
// attribute.
|
||||||
if (!similarItemsInGroup && !positionInGroup)
|
if (!groupPos.setSize && !groupPos.posInSet)
|
||||||
return S_FALSE;
|
return S_FALSE;
|
||||||
|
|
||||||
*aGroupLevel = groupLevel;
|
*aGroupLevel = groupPos.level;
|
||||||
*aSimilarItemsInGroup = similarItemsInGroup;
|
*aSimilarItemsInGroup = groupPos.setSize;
|
||||||
*aPositionInGroup = positionInGroup;
|
*aPositionInGroup = groupPos.posInSet;
|
||||||
|
|
||||||
return S_OK;
|
return S_OK;
|
||||||
|
|
||||||
|
@ -897,26 +897,14 @@ nsXULTreeItemAccessibleBase::IsPrimaryForNode() const
|
|||||||
// nsXULTreeItemAccessibleBase: Accessible public methods
|
// nsXULTreeItemAccessibleBase: Accessible public methods
|
||||||
|
|
||||||
// nsIAccessible::groupPosition
|
// nsIAccessible::groupPosition
|
||||||
nsresult
|
GroupPos
|
||||||
nsXULTreeItemAccessibleBase::GroupPosition(PRInt32 *aGroupLevel,
|
nsXULTreeItemAccessibleBase::GroupPosition()
|
||||||
PRInt32 *aSimilarItemsInGroup,
|
|
||||||
PRInt32 *aPositionInGroup)
|
|
||||||
{
|
{
|
||||||
NS_ENSURE_ARG_POINTER(aGroupLevel);
|
GroupPos groupPos;
|
||||||
*aGroupLevel = 0;
|
|
||||||
|
|
||||||
NS_ENSURE_ARG_POINTER(aSimilarItemsInGroup);
|
|
||||||
*aSimilarItemsInGroup = 0;
|
|
||||||
|
|
||||||
NS_ENSURE_ARG_POINTER(aPositionInGroup);
|
|
||||||
*aPositionInGroup = 0;
|
|
||||||
|
|
||||||
if (IsDefunct() || !mTreeView)
|
|
||||||
return NS_ERROR_FAILURE;
|
|
||||||
|
|
||||||
PRInt32 level;
|
PRInt32 level;
|
||||||
nsresult rv = mTreeView->GetLevel(mRow, &level);
|
nsresult rv = mTreeView->GetLevel(mRow, &level);
|
||||||
NS_ENSURE_SUCCESS(rv, rv);
|
NS_ENSURE_SUCCESS(rv, groupPos);
|
||||||
|
|
||||||
PRInt32 topCount = 1;
|
PRInt32 topCount = 1;
|
||||||
for (PRInt32 index = mRow - 1; index >= 0; index--) {
|
for (PRInt32 index = mRow - 1; index >= 0; index--) {
|
||||||
@ -932,7 +920,7 @@ nsXULTreeItemAccessibleBase::GroupPosition(PRInt32 *aGroupLevel,
|
|||||||
|
|
||||||
PRInt32 rowCount = 0;
|
PRInt32 rowCount = 0;
|
||||||
rv = mTreeView->GetRowCount(&rowCount);
|
rv = mTreeView->GetRowCount(&rowCount);
|
||||||
NS_ENSURE_SUCCESS(rv, rv);
|
NS_ENSURE_SUCCESS(rv, groupPos);
|
||||||
|
|
||||||
PRInt32 bottomCount = 0;
|
PRInt32 bottomCount = 0;
|
||||||
for (PRInt32 index = mRow + 1; index < rowCount; index++) {
|
for (PRInt32 index = mRow + 1; index < rowCount; index++) {
|
||||||
@ -946,14 +934,11 @@ nsXULTreeItemAccessibleBase::GroupPosition(PRInt32 *aGroupLevel,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
PRInt32 setSize = topCount + bottomCount;
|
groupPos.level = level + 1;
|
||||||
PRInt32 posInSet = topCount;
|
groupPos.setSize = topCount + bottomCount;
|
||||||
|
groupPos.posInSet = topCount;
|
||||||
|
|
||||||
*aGroupLevel = level + 1;
|
return groupPos;
|
||||||
*aSimilarItemsInGroup = setSize;
|
|
||||||
*aPositionInGroup = posInSet;
|
|
||||||
|
|
||||||
return NS_OK;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
PRUint64
|
PRUint64
|
||||||
|
@ -146,10 +146,6 @@ public:
|
|||||||
NS_IMETHOD SetSelected(bool aSelect);
|
NS_IMETHOD SetSelected(bool aSelect);
|
||||||
NS_IMETHOD TakeFocus();
|
NS_IMETHOD TakeFocus();
|
||||||
|
|
||||||
NS_IMETHOD GroupPosition(PRInt32 *aGroupLevel,
|
|
||||||
PRInt32 *aSimilarItemsInGroup,
|
|
||||||
PRInt32 *aPositionInGroup);
|
|
||||||
|
|
||||||
NS_IMETHOD GetActionName(PRUint8 aIndex, nsAString& aName);
|
NS_IMETHOD GetActionName(PRUint8 aIndex, nsAString& aName);
|
||||||
NS_IMETHOD DoAction(PRUint8 aIndex);
|
NS_IMETHOD DoAction(PRUint8 aIndex);
|
||||||
|
|
||||||
@ -158,6 +154,7 @@ public:
|
|||||||
virtual bool IsPrimaryForNode() const;
|
virtual bool IsPrimaryForNode() const;
|
||||||
|
|
||||||
// Accessible
|
// Accessible
|
||||||
|
virtual mozilla::a11y::GroupPos GroupPosition();
|
||||||
virtual PRUint64 NativeState();
|
virtual PRUint64 NativeState();
|
||||||
virtual PRInt32 IndexInParent() const;
|
virtual PRInt32 IndexInParent() const;
|
||||||
virtual Relation RelationByType(PRUint32 aType);
|
virtual Relation RelationByType(PRUint32 aType);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user