зеркало из https://github.com/mozilla/pjs.git
Bug 389926 - support group attributes on menu/menuitem accessibles, r=aaronlev, a=mtschrep
This commit is contained in:
Родитель
12f31b30f3
Коммит
8fd154ed33
|
@ -54,6 +54,7 @@
|
|||
#include "nsIDOMDocumentXBL.h"
|
||||
#include "nsIDOMNodeList.h"
|
||||
#include "nsIDOMRange.h"
|
||||
#include "nsIDOMXULContainerElement.h"
|
||||
#include "nsIDOMXULSelectCntrlEl.h"
|
||||
#include "nsIDOMXULSelectCntrlItemEl.h"
|
||||
#include "nsIDOMWindowInternal.h"
|
||||
|
@ -204,6 +205,57 @@ nsAccUtils::SetAccAttrsForXULSelectControlItem(nsIDOMNode *aNode,
|
|||
SetAccGroupAttrs(aAttributes, 0, posInSet + 1, setSize);
|
||||
}
|
||||
|
||||
void
|
||||
nsAccUtils::SetAccAttrsForXULContainerItem(nsIDOMNode *aNode,
|
||||
nsIPersistentProperties *aAttributes)
|
||||
{
|
||||
nsCOMPtr<nsIDOMXULContainerItemElement> item(do_QueryInterface(aNode));
|
||||
if (!item)
|
||||
return;
|
||||
|
||||
nsCOMPtr<nsIDOMXULContainerElement> container;
|
||||
item->GetParentContainer(getter_AddRefs(container));
|
||||
if (!container)
|
||||
return;
|
||||
|
||||
// Get item count.
|
||||
PRUint32 itemsCount = 0;
|
||||
container->GetItemCount(&itemsCount);
|
||||
|
||||
// Get item index.
|
||||
PRInt32 indexOf = 0;
|
||||
container->GetIndexOfItem(item, &indexOf);
|
||||
|
||||
PRUint32 setSize = itemsCount, posInSet = indexOf;
|
||||
for (PRUint32 index = 0; index < itemsCount; index++) {
|
||||
nsCOMPtr<nsIDOMXULElement> currItem;
|
||||
container->GetItemAtIndex(index, getter_AddRefs(currItem));
|
||||
nsCOMPtr<nsIDOMNode> currNode(do_QueryInterface(currItem));
|
||||
|
||||
nsCOMPtr<nsIAccessible> itemAcc;
|
||||
nsAccessNode::GetAccService()->GetAccessibleFor(currNode,
|
||||
getter_AddRefs(itemAcc));
|
||||
if (!itemAcc ||
|
||||
nsAccessible::State(itemAcc) & nsIAccessibleStates::STATE_INVISIBLE) {
|
||||
setSize--;
|
||||
if (index < static_cast<PRUint32>(indexOf))
|
||||
posInSet--;
|
||||
}
|
||||
}
|
||||
|
||||
// Get level of the item.
|
||||
PRInt32 level = -1;
|
||||
while (container) {
|
||||
level++;
|
||||
|
||||
nsCOMPtr<nsIDOMXULContainerElement> parentContainer;
|
||||
container->GetParentContainer(getter_AddRefs(parentContainer));
|
||||
parentContainer.swap(container);
|
||||
}
|
||||
|
||||
SetAccGroupAttrs(aAttributes, level, posInSet + 1, setSize);
|
||||
}
|
||||
|
||||
PRBool
|
||||
nsAccUtils::HasListener(nsIContent *aContent, const nsAString& aEventType)
|
||||
{
|
||||
|
|
|
@ -108,6 +108,16 @@ public:
|
|||
static void SetAccAttrsForXULSelectControlItem(nsIDOMNode *aNode,
|
||||
nsIPersistentProperties *aAttributes);
|
||||
|
||||
/**
|
||||
* Set group attributes - 'level', 'setsize', 'posinset'.
|
||||
*
|
||||
* @param aNode XUL element that implements
|
||||
* nsIDOMXULContainerItemElement interface
|
||||
* @param aAttributes attributes container
|
||||
*/
|
||||
static void SetAccAttrsForXULContainerItem(nsIDOMNode *aNode,
|
||||
nsIPersistentProperties *aAttributes);
|
||||
|
||||
/**
|
||||
* Return true if the given node has registered event listener of the given
|
||||
* type.
|
||||
|
|
|
@ -516,11 +516,7 @@ nsXULMenuitemAccessible::GetAttributesInternal(nsIPersistentProperties *aAttribu
|
|||
nsresult rv = nsAccessible::GetAttributesInternal(aAttributes);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
// XXX: we don't support xul:menuitem inside xul:menu element now until
|
||||
// bug 372552 is fixed.
|
||||
|
||||
nsAccUtils::SetAccAttrsForXULSelectControlItem(mDOMNode, aAttributes);
|
||||
|
||||
nsAccUtils::SetAccAttrsForXULContainerItem(mDOMNode, aAttributes);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче